empathy-framework 5.3.0__py3-none-any.whl → 5.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (458) hide show
  1. empathy_framework-5.4.0.dist-info/METADATA +47 -0
  2. empathy_framework-5.4.0.dist-info/RECORD +8 -0
  3. {empathy_framework-5.3.0.dist-info → empathy_framework-5.4.0.dist-info}/top_level.txt +0 -1
  4. empathy_healthcare_plugin/__init__.py +12 -11
  5. empathy_llm_toolkit/__init__.py +12 -26
  6. empathy_os/__init__.py +12 -356
  7. empathy_software_plugin/__init__.py +12 -11
  8. empathy_framework-5.3.0.dist-info/METADATA +0 -1026
  9. empathy_framework-5.3.0.dist-info/RECORD +0 -456
  10. empathy_framework-5.3.0.dist-info/entry_points.txt +0 -26
  11. empathy_framework-5.3.0.dist-info/licenses/LICENSE +0 -201
  12. empathy_framework-5.3.0.dist-info/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md +0 -101
  13. empathy_healthcare_plugin/monitors/__init__.py +0 -9
  14. empathy_healthcare_plugin/monitors/clinical_protocol_monitor.py +0 -315
  15. empathy_healthcare_plugin/monitors/monitoring/__init__.py +0 -44
  16. empathy_healthcare_plugin/monitors/monitoring/protocol_checker.py +0 -300
  17. empathy_healthcare_plugin/monitors/monitoring/protocol_loader.py +0 -214
  18. empathy_healthcare_plugin/monitors/monitoring/sensor_parsers.py +0 -306
  19. empathy_healthcare_plugin/monitors/monitoring/trajectory_analyzer.py +0 -389
  20. empathy_healthcare_plugin/protocols/cardiac.json +0 -93
  21. empathy_healthcare_plugin/protocols/post_operative.json +0 -92
  22. empathy_healthcare_plugin/protocols/respiratory.json +0 -92
  23. empathy_healthcare_plugin/protocols/sepsis.json +0 -141
  24. empathy_llm_toolkit/README.md +0 -553
  25. empathy_llm_toolkit/agent_factory/__init__.py +0 -53
  26. empathy_llm_toolkit/agent_factory/adapters/__init__.py +0 -85
  27. empathy_llm_toolkit/agent_factory/adapters/autogen_adapter.py +0 -312
  28. empathy_llm_toolkit/agent_factory/adapters/crewai_adapter.py +0 -483
  29. empathy_llm_toolkit/agent_factory/adapters/haystack_adapter.py +0 -298
  30. empathy_llm_toolkit/agent_factory/adapters/langchain_adapter.py +0 -362
  31. empathy_llm_toolkit/agent_factory/adapters/langgraph_adapter.py +0 -333
  32. empathy_llm_toolkit/agent_factory/adapters/native.py +0 -228
  33. empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +0 -423
  34. empathy_llm_toolkit/agent_factory/base.py +0 -305
  35. empathy_llm_toolkit/agent_factory/crews/__init__.py +0 -67
  36. empathy_llm_toolkit/agent_factory/crews/code_review.py +0 -1113
  37. empathy_llm_toolkit/agent_factory/crews/health_check.py +0 -1262
  38. empathy_llm_toolkit/agent_factory/crews/refactoring.py +0 -1128
  39. empathy_llm_toolkit/agent_factory/crews/security_audit.py +0 -1018
  40. empathy_llm_toolkit/agent_factory/decorators.py +0 -287
  41. empathy_llm_toolkit/agent_factory/factory.py +0 -558
  42. empathy_llm_toolkit/agent_factory/framework.py +0 -193
  43. empathy_llm_toolkit/agent_factory/memory_integration.py +0 -328
  44. empathy_llm_toolkit/agent_factory/resilient.py +0 -320
  45. empathy_llm_toolkit/agents_md/__init__.py +0 -22
  46. empathy_llm_toolkit/agents_md/loader.py +0 -218
  47. empathy_llm_toolkit/agents_md/parser.py +0 -271
  48. empathy_llm_toolkit/agents_md/registry.py +0 -307
  49. empathy_llm_toolkit/claude_memory.py +0 -466
  50. empathy_llm_toolkit/cli/__init__.py +0 -8
  51. empathy_llm_toolkit/cli/sync_claude.py +0 -487
  52. empathy_llm_toolkit/code_health.py +0 -1313
  53. empathy_llm_toolkit/commands/__init__.py +0 -51
  54. empathy_llm_toolkit/commands/context.py +0 -375
  55. empathy_llm_toolkit/commands/loader.py +0 -301
  56. empathy_llm_toolkit/commands/models.py +0 -231
  57. empathy_llm_toolkit/commands/parser.py +0 -371
  58. empathy_llm_toolkit/commands/registry.py +0 -429
  59. empathy_llm_toolkit/config/__init__.py +0 -29
  60. empathy_llm_toolkit/config/unified.py +0 -291
  61. empathy_llm_toolkit/context/__init__.py +0 -22
  62. empathy_llm_toolkit/context/compaction.py +0 -455
  63. empathy_llm_toolkit/context/manager.py +0 -434
  64. empathy_llm_toolkit/contextual_patterns.py +0 -361
  65. empathy_llm_toolkit/core.py +0 -907
  66. empathy_llm_toolkit/git_pattern_extractor.py +0 -435
  67. empathy_llm_toolkit/hooks/__init__.py +0 -24
  68. empathy_llm_toolkit/hooks/config.py +0 -306
  69. empathy_llm_toolkit/hooks/executor.py +0 -289
  70. empathy_llm_toolkit/hooks/registry.py +0 -302
  71. empathy_llm_toolkit/hooks/scripts/__init__.py +0 -39
  72. empathy_llm_toolkit/hooks/scripts/evaluate_session.py +0 -201
  73. empathy_llm_toolkit/hooks/scripts/first_time_init.py +0 -285
  74. empathy_llm_toolkit/hooks/scripts/pre_compact.py +0 -207
  75. empathy_llm_toolkit/hooks/scripts/session_end.py +0 -183
  76. empathy_llm_toolkit/hooks/scripts/session_start.py +0 -163
  77. empathy_llm_toolkit/hooks/scripts/suggest_compact.py +0 -225
  78. empathy_llm_toolkit/learning/__init__.py +0 -30
  79. empathy_llm_toolkit/learning/evaluator.py +0 -438
  80. empathy_llm_toolkit/learning/extractor.py +0 -514
  81. empathy_llm_toolkit/learning/storage.py +0 -560
  82. empathy_llm_toolkit/levels.py +0 -227
  83. empathy_llm_toolkit/pattern_confidence.py +0 -414
  84. empathy_llm_toolkit/pattern_resolver.py +0 -272
  85. empathy_llm_toolkit/pattern_summary.py +0 -350
  86. empathy_llm_toolkit/providers.py +0 -967
  87. empathy_llm_toolkit/routing/__init__.py +0 -32
  88. empathy_llm_toolkit/routing/model_router.py +0 -362
  89. empathy_llm_toolkit/security/IMPLEMENTATION_SUMMARY.md +0 -413
  90. empathy_llm_toolkit/security/PHASE2_COMPLETE.md +0 -384
  91. empathy_llm_toolkit/security/PHASE2_SECRETS_DETECTOR_COMPLETE.md +0 -271
  92. empathy_llm_toolkit/security/QUICK_REFERENCE.md +0 -316
  93. empathy_llm_toolkit/security/README.md +0 -262
  94. empathy_llm_toolkit/security/__init__.py +0 -62
  95. empathy_llm_toolkit/security/audit_logger.py +0 -929
  96. empathy_llm_toolkit/security/audit_logger_example.py +0 -152
  97. empathy_llm_toolkit/security/pii_scrubber.py +0 -640
  98. empathy_llm_toolkit/security/secrets_detector.py +0 -678
  99. empathy_llm_toolkit/security/secrets_detector_example.py +0 -304
  100. empathy_llm_toolkit/security/secure_memdocs.py +0 -1192
  101. empathy_llm_toolkit/security/secure_memdocs_example.py +0 -278
  102. empathy_llm_toolkit/session_status.py +0 -745
  103. empathy_llm_toolkit/state.py +0 -246
  104. empathy_llm_toolkit/utils/__init__.py +0 -5
  105. empathy_llm_toolkit/utils/tokens.py +0 -349
  106. empathy_os/adaptive/__init__.py +0 -13
  107. empathy_os/adaptive/task_complexity.py +0 -127
  108. empathy_os/agent_monitoring.py +0 -414
  109. empathy_os/cache/__init__.py +0 -117
  110. empathy_os/cache/base.py +0 -166
  111. empathy_os/cache/dependency_manager.py +0 -256
  112. empathy_os/cache/hash_only.py +0 -251
  113. empathy_os/cache/hybrid.py +0 -457
  114. empathy_os/cache/storage.py +0 -285
  115. empathy_os/cache_monitor.py +0 -356
  116. empathy_os/cache_stats.py +0 -298
  117. empathy_os/cli/__init__.py +0 -152
  118. empathy_os/cli/__main__.py +0 -12
  119. empathy_os/cli/commands/__init__.py +0 -1
  120. empathy_os/cli/commands/batch.py +0 -264
  121. empathy_os/cli/commands/cache.py +0 -248
  122. empathy_os/cli/commands/help.py +0 -331
  123. empathy_os/cli/commands/info.py +0 -140
  124. empathy_os/cli/commands/inspect.py +0 -436
  125. empathy_os/cli/commands/inspection.py +0 -57
  126. empathy_os/cli/commands/memory.py +0 -48
  127. empathy_os/cli/commands/metrics.py +0 -92
  128. empathy_os/cli/commands/orchestrate.py +0 -184
  129. empathy_os/cli/commands/patterns.py +0 -207
  130. empathy_os/cli/commands/profiling.py +0 -202
  131. empathy_os/cli/commands/provider.py +0 -98
  132. empathy_os/cli/commands/routing.py +0 -285
  133. empathy_os/cli/commands/setup.py +0 -96
  134. empathy_os/cli/commands/status.py +0 -235
  135. empathy_os/cli/commands/sync.py +0 -166
  136. empathy_os/cli/commands/tier.py +0 -121
  137. empathy_os/cli/commands/utilities.py +0 -114
  138. empathy_os/cli/commands/workflow.py +0 -579
  139. empathy_os/cli/core.py +0 -32
  140. empathy_os/cli/parsers/__init__.py +0 -68
  141. empathy_os/cli/parsers/batch.py +0 -118
  142. empathy_os/cli/parsers/cache.py +0 -65
  143. empathy_os/cli/parsers/help.py +0 -41
  144. empathy_os/cli/parsers/info.py +0 -26
  145. empathy_os/cli/parsers/inspect.py +0 -66
  146. empathy_os/cli/parsers/metrics.py +0 -42
  147. empathy_os/cli/parsers/orchestrate.py +0 -61
  148. empathy_os/cli/parsers/patterns.py +0 -54
  149. empathy_os/cli/parsers/provider.py +0 -40
  150. empathy_os/cli/parsers/routing.py +0 -110
  151. empathy_os/cli/parsers/setup.py +0 -42
  152. empathy_os/cli/parsers/status.py +0 -47
  153. empathy_os/cli/parsers/sync.py +0 -31
  154. empathy_os/cli/parsers/tier.py +0 -33
  155. empathy_os/cli/parsers/workflow.py +0 -77
  156. empathy_os/cli/utils/__init__.py +0 -1
  157. empathy_os/cli/utils/data.py +0 -242
  158. empathy_os/cli/utils/helpers.py +0 -68
  159. empathy_os/cli_legacy.py +0 -3957
  160. empathy_os/cli_minimal.py +0 -1159
  161. empathy_os/cli_router.py +0 -437
  162. empathy_os/cli_unified.py +0 -814
  163. empathy_os/config/__init__.py +0 -66
  164. empathy_os/config/xml_config.py +0 -286
  165. empathy_os/config.py +0 -545
  166. empathy_os/coordination.py +0 -870
  167. empathy_os/core.py +0 -1511
  168. empathy_os/core_modules/__init__.py +0 -15
  169. empathy_os/cost_tracker.py +0 -626
  170. empathy_os/dashboard/__init__.py +0 -41
  171. empathy_os/dashboard/app.py +0 -512
  172. empathy_os/dashboard/simple_server.py +0 -435
  173. empathy_os/dashboard/standalone_server.py +0 -547
  174. empathy_os/discovery.py +0 -306
  175. empathy_os/emergence.py +0 -306
  176. empathy_os/exceptions.py +0 -123
  177. empathy_os/feedback_loops.py +0 -373
  178. empathy_os/hot_reload/README.md +0 -473
  179. empathy_os/hot_reload/__init__.py +0 -62
  180. empathy_os/hot_reload/config.py +0 -83
  181. empathy_os/hot_reload/integration.py +0 -229
  182. empathy_os/hot_reload/reloader.py +0 -298
  183. empathy_os/hot_reload/watcher.py +0 -183
  184. empathy_os/hot_reload/websocket.py +0 -177
  185. empathy_os/levels.py +0 -577
  186. empathy_os/leverage_points.py +0 -441
  187. empathy_os/logging_config.py +0 -261
  188. empathy_os/mcp/__init__.py +0 -10
  189. empathy_os/mcp/server.py +0 -506
  190. empathy_os/memory/__init__.py +0 -237
  191. empathy_os/memory/claude_memory.py +0 -469
  192. empathy_os/memory/config.py +0 -224
  193. empathy_os/memory/control_panel.py +0 -1290
  194. empathy_os/memory/control_panel_support.py +0 -145
  195. empathy_os/memory/cross_session.py +0 -845
  196. empathy_os/memory/edges.py +0 -179
  197. empathy_os/memory/encryption.py +0 -159
  198. empathy_os/memory/file_session.py +0 -770
  199. empathy_os/memory/graph.py +0 -570
  200. empathy_os/memory/long_term.py +0 -913
  201. empathy_os/memory/long_term_types.py +0 -99
  202. empathy_os/memory/mixins/__init__.py +0 -25
  203. empathy_os/memory/mixins/backend_init_mixin.py +0 -249
  204. empathy_os/memory/mixins/capabilities_mixin.py +0 -208
  205. empathy_os/memory/mixins/handoff_mixin.py +0 -208
  206. empathy_os/memory/mixins/lifecycle_mixin.py +0 -49
  207. empathy_os/memory/mixins/long_term_mixin.py +0 -352
  208. empathy_os/memory/mixins/promotion_mixin.py +0 -109
  209. empathy_os/memory/mixins/short_term_mixin.py +0 -182
  210. empathy_os/memory/nodes.py +0 -179
  211. empathy_os/memory/redis_bootstrap.py +0 -540
  212. empathy_os/memory/security/__init__.py +0 -31
  213. empathy_os/memory/security/audit_logger.py +0 -932
  214. empathy_os/memory/security/pii_scrubber.py +0 -640
  215. empathy_os/memory/security/secrets_detector.py +0 -678
  216. empathy_os/memory/short_term.py +0 -2192
  217. empathy_os/memory/simple_storage.py +0 -302
  218. empathy_os/memory/storage/__init__.py +0 -15
  219. empathy_os/memory/storage_backend.py +0 -167
  220. empathy_os/memory/summary_index.py +0 -583
  221. empathy_os/memory/types.py +0 -446
  222. empathy_os/memory/unified.py +0 -182
  223. empathy_os/meta_workflows/__init__.py +0 -74
  224. empathy_os/meta_workflows/agent_creator.py +0 -248
  225. empathy_os/meta_workflows/builtin_templates.py +0 -567
  226. empathy_os/meta_workflows/cli_commands/__init__.py +0 -56
  227. empathy_os/meta_workflows/cli_commands/agent_commands.py +0 -321
  228. empathy_os/meta_workflows/cli_commands/analytics_commands.py +0 -442
  229. empathy_os/meta_workflows/cli_commands/config_commands.py +0 -232
  230. empathy_os/meta_workflows/cli_commands/memory_commands.py +0 -182
  231. empathy_os/meta_workflows/cli_commands/template_commands.py +0 -354
  232. empathy_os/meta_workflows/cli_commands/workflow_commands.py +0 -382
  233. empathy_os/meta_workflows/cli_meta_workflows.py +0 -59
  234. empathy_os/meta_workflows/form_engine.py +0 -292
  235. empathy_os/meta_workflows/intent_detector.py +0 -409
  236. empathy_os/meta_workflows/models.py +0 -569
  237. empathy_os/meta_workflows/pattern_learner.py +0 -738
  238. empathy_os/meta_workflows/plan_generator.py +0 -384
  239. empathy_os/meta_workflows/session_context.py +0 -397
  240. empathy_os/meta_workflows/template_registry.py +0 -229
  241. empathy_os/meta_workflows/workflow.py +0 -984
  242. empathy_os/metrics/__init__.py +0 -12
  243. empathy_os/metrics/collector.py +0 -31
  244. empathy_os/metrics/prompt_metrics.py +0 -194
  245. empathy_os/models/__init__.py +0 -172
  246. empathy_os/models/__main__.py +0 -13
  247. empathy_os/models/adaptive_routing.py +0 -437
  248. empathy_os/models/auth_cli.py +0 -444
  249. empathy_os/models/auth_strategy.py +0 -450
  250. empathy_os/models/cli.py +0 -655
  251. empathy_os/models/empathy_executor.py +0 -354
  252. empathy_os/models/executor.py +0 -257
  253. empathy_os/models/fallback.py +0 -762
  254. empathy_os/models/provider_config.py +0 -282
  255. empathy_os/models/registry.py +0 -472
  256. empathy_os/models/tasks.py +0 -359
  257. empathy_os/models/telemetry/__init__.py +0 -71
  258. empathy_os/models/telemetry/analytics.py +0 -594
  259. empathy_os/models/telemetry/backend.py +0 -196
  260. empathy_os/models/telemetry/data_models.py +0 -431
  261. empathy_os/models/telemetry/storage.py +0 -489
  262. empathy_os/models/token_estimator.py +0 -420
  263. empathy_os/models/validation.py +0 -280
  264. empathy_os/monitoring/__init__.py +0 -52
  265. empathy_os/monitoring/alerts.py +0 -946
  266. empathy_os/monitoring/alerts_cli.py +0 -448
  267. empathy_os/monitoring/multi_backend.py +0 -271
  268. empathy_os/monitoring/otel_backend.py +0 -362
  269. empathy_os/optimization/__init__.py +0 -19
  270. empathy_os/optimization/context_optimizer.py +0 -272
  271. empathy_os/orchestration/__init__.py +0 -67
  272. empathy_os/orchestration/agent_templates.py +0 -707
  273. empathy_os/orchestration/config_store.py +0 -499
  274. empathy_os/orchestration/execution_strategies.py +0 -2111
  275. empathy_os/orchestration/meta_orchestrator.py +0 -1168
  276. empathy_os/orchestration/pattern_learner.py +0 -696
  277. empathy_os/orchestration/real_tools.py +0 -931
  278. empathy_os/pattern_cache.py +0 -187
  279. empathy_os/pattern_library.py +0 -542
  280. empathy_os/patterns/debugging/all_patterns.json +0 -81
  281. empathy_os/patterns/debugging/workflow_20260107_1770825e.json +0 -77
  282. empathy_os/patterns/refactoring_memory.json +0 -89
  283. empathy_os/persistence.py +0 -564
  284. empathy_os/platform_utils.py +0 -265
  285. empathy_os/plugins/__init__.py +0 -28
  286. empathy_os/plugins/base.py +0 -361
  287. empathy_os/plugins/registry.py +0 -268
  288. empathy_os/project_index/__init__.py +0 -32
  289. empathy_os/project_index/cli.py +0 -335
  290. empathy_os/project_index/index.py +0 -667
  291. empathy_os/project_index/models.py +0 -504
  292. empathy_os/project_index/reports.py +0 -474
  293. empathy_os/project_index/scanner.py +0 -777
  294. empathy_os/project_index/scanner_parallel.py +0 -291
  295. empathy_os/prompts/__init__.py +0 -61
  296. empathy_os/prompts/config.py +0 -77
  297. empathy_os/prompts/context.py +0 -177
  298. empathy_os/prompts/parser.py +0 -285
  299. empathy_os/prompts/registry.py +0 -313
  300. empathy_os/prompts/templates.py +0 -208
  301. empathy_os/redis_config.py +0 -302
  302. empathy_os/redis_memory.py +0 -799
  303. empathy_os/resilience/__init__.py +0 -56
  304. empathy_os/resilience/circuit_breaker.py +0 -256
  305. empathy_os/resilience/fallback.py +0 -179
  306. empathy_os/resilience/health.py +0 -300
  307. empathy_os/resilience/retry.py +0 -209
  308. empathy_os/resilience/timeout.py +0 -135
  309. empathy_os/routing/__init__.py +0 -43
  310. empathy_os/routing/chain_executor.py +0 -433
  311. empathy_os/routing/classifier.py +0 -217
  312. empathy_os/routing/smart_router.py +0 -234
  313. empathy_os/routing/workflow_registry.py +0 -343
  314. empathy_os/scaffolding/README.md +0 -589
  315. empathy_os/scaffolding/__init__.py +0 -35
  316. empathy_os/scaffolding/__main__.py +0 -14
  317. empathy_os/scaffolding/cli.py +0 -240
  318. empathy_os/socratic/__init__.py +0 -256
  319. empathy_os/socratic/ab_testing.py +0 -958
  320. empathy_os/socratic/blueprint.py +0 -533
  321. empathy_os/socratic/cli.py +0 -703
  322. empathy_os/socratic/collaboration.py +0 -1114
  323. empathy_os/socratic/domain_templates.py +0 -924
  324. empathy_os/socratic/embeddings.py +0 -738
  325. empathy_os/socratic/engine.py +0 -794
  326. empathy_os/socratic/explainer.py +0 -682
  327. empathy_os/socratic/feedback.py +0 -772
  328. empathy_os/socratic/forms.py +0 -629
  329. empathy_os/socratic/generator.py +0 -732
  330. empathy_os/socratic/llm_analyzer.py +0 -637
  331. empathy_os/socratic/mcp_server.py +0 -702
  332. empathy_os/socratic/session.py +0 -312
  333. empathy_os/socratic/storage.py +0 -667
  334. empathy_os/socratic/success.py +0 -730
  335. empathy_os/socratic/visual_editor.py +0 -860
  336. empathy_os/socratic/web_ui.py +0 -958
  337. empathy_os/telemetry/__init__.py +0 -39
  338. empathy_os/telemetry/agent_coordination.py +0 -475
  339. empathy_os/telemetry/agent_tracking.py +0 -367
  340. empathy_os/telemetry/approval_gates.py +0 -545
  341. empathy_os/telemetry/cli.py +0 -1231
  342. empathy_os/telemetry/commands/__init__.py +0 -14
  343. empathy_os/telemetry/commands/dashboard_commands.py +0 -696
  344. empathy_os/telemetry/event_streaming.py +0 -409
  345. empathy_os/telemetry/feedback_loop.py +0 -567
  346. empathy_os/telemetry/usage_tracker.py +0 -591
  347. empathy_os/templates.py +0 -754
  348. empathy_os/test_generator/__init__.py +0 -38
  349. empathy_os/test_generator/__main__.py +0 -14
  350. empathy_os/test_generator/cli.py +0 -234
  351. empathy_os/test_generator/generator.py +0 -355
  352. empathy_os/test_generator/risk_analyzer.py +0 -216
  353. empathy_os/tier_recommender.py +0 -384
  354. empathy_os/tools.py +0 -183
  355. empathy_os/trust/__init__.py +0 -28
  356. empathy_os/trust/circuit_breaker.py +0 -579
  357. empathy_os/trust_building.py +0 -527
  358. empathy_os/validation/__init__.py +0 -19
  359. empathy_os/validation/xml_validator.py +0 -281
  360. empathy_os/vscode_bridge.py +0 -173
  361. empathy_os/workflow_commands.py +0 -780
  362. empathy_os/workflow_patterns/__init__.py +0 -33
  363. empathy_os/workflow_patterns/behavior.py +0 -249
  364. empathy_os/workflow_patterns/core.py +0 -76
  365. empathy_os/workflow_patterns/output.py +0 -99
  366. empathy_os/workflow_patterns/registry.py +0 -255
  367. empathy_os/workflow_patterns/structural.py +0 -288
  368. empathy_os/workflows/__init__.py +0 -539
  369. empathy_os/workflows/autonomous_test_gen.py +0 -1268
  370. empathy_os/workflows/base.py +0 -2667
  371. empathy_os/workflows/batch_processing.py +0 -342
  372. empathy_os/workflows/bug_predict.py +0 -1084
  373. empathy_os/workflows/builder.py +0 -273
  374. empathy_os/workflows/caching.py +0 -253
  375. empathy_os/workflows/code_review.py +0 -1048
  376. empathy_os/workflows/code_review_adapters.py +0 -312
  377. empathy_os/workflows/code_review_pipeline.py +0 -722
  378. empathy_os/workflows/config.py +0 -645
  379. empathy_os/workflows/dependency_check.py +0 -644
  380. empathy_os/workflows/document_gen/__init__.py +0 -25
  381. empathy_os/workflows/document_gen/config.py +0 -30
  382. empathy_os/workflows/document_gen/report_formatter.py +0 -162
  383. empathy_os/workflows/document_gen/workflow.py +0 -1426
  384. empathy_os/workflows/document_manager.py +0 -216
  385. empathy_os/workflows/document_manager_README.md +0 -134
  386. empathy_os/workflows/documentation_orchestrator.py +0 -1205
  387. empathy_os/workflows/history.py +0 -510
  388. empathy_os/workflows/keyboard_shortcuts/__init__.py +0 -39
  389. empathy_os/workflows/keyboard_shortcuts/generators.py +0 -391
  390. empathy_os/workflows/keyboard_shortcuts/parsers.py +0 -416
  391. empathy_os/workflows/keyboard_shortcuts/prompts.py +0 -295
  392. empathy_os/workflows/keyboard_shortcuts/schema.py +0 -193
  393. empathy_os/workflows/keyboard_shortcuts/workflow.py +0 -509
  394. empathy_os/workflows/llm_base.py +0 -363
  395. empathy_os/workflows/manage_docs.py +0 -87
  396. empathy_os/workflows/manage_docs_README.md +0 -134
  397. empathy_os/workflows/manage_documentation.py +0 -821
  398. empathy_os/workflows/new_sample_workflow1.py +0 -149
  399. empathy_os/workflows/new_sample_workflow1_README.md +0 -150
  400. empathy_os/workflows/orchestrated_health_check.py +0 -849
  401. empathy_os/workflows/orchestrated_release_prep.py +0 -600
  402. empathy_os/workflows/output.py +0 -413
  403. empathy_os/workflows/perf_audit.py +0 -863
  404. empathy_os/workflows/pr_review.py +0 -762
  405. empathy_os/workflows/progress.py +0 -785
  406. empathy_os/workflows/progress_server.py +0 -322
  407. empathy_os/workflows/progressive/README 2.md +0 -454
  408. empathy_os/workflows/progressive/README.md +0 -454
  409. empathy_os/workflows/progressive/__init__.py +0 -82
  410. empathy_os/workflows/progressive/cli.py +0 -219
  411. empathy_os/workflows/progressive/core.py +0 -488
  412. empathy_os/workflows/progressive/orchestrator.py +0 -723
  413. empathy_os/workflows/progressive/reports.py +0 -520
  414. empathy_os/workflows/progressive/telemetry.py +0 -274
  415. empathy_os/workflows/progressive/test_gen.py +0 -495
  416. empathy_os/workflows/progressive/workflow.py +0 -589
  417. empathy_os/workflows/refactor_plan.py +0 -694
  418. empathy_os/workflows/release_prep.py +0 -895
  419. empathy_os/workflows/release_prep_crew.py +0 -969
  420. empathy_os/workflows/research_synthesis.py +0 -404
  421. empathy_os/workflows/routing.py +0 -168
  422. empathy_os/workflows/secure_release.py +0 -593
  423. empathy_os/workflows/security_adapters.py +0 -297
  424. empathy_os/workflows/security_audit.py +0 -1329
  425. empathy_os/workflows/security_audit_phase3.py +0 -355
  426. empathy_os/workflows/seo_optimization.py +0 -633
  427. empathy_os/workflows/step_config.py +0 -234
  428. empathy_os/workflows/telemetry_mixin.py +0 -269
  429. empathy_os/workflows/test5.py +0 -125
  430. empathy_os/workflows/test5_README.md +0 -158
  431. empathy_os/workflows/test_coverage_boost_crew.py +0 -849
  432. empathy_os/workflows/test_gen/__init__.py +0 -52
  433. empathy_os/workflows/test_gen/ast_analyzer.py +0 -249
  434. empathy_os/workflows/test_gen/config.py +0 -88
  435. empathy_os/workflows/test_gen/data_models.py +0 -38
  436. empathy_os/workflows/test_gen/report_formatter.py +0 -289
  437. empathy_os/workflows/test_gen/test_templates.py +0 -381
  438. empathy_os/workflows/test_gen/workflow.py +0 -655
  439. empathy_os/workflows/test_gen.py +0 -54
  440. empathy_os/workflows/test_gen_behavioral.py +0 -477
  441. empathy_os/workflows/test_gen_parallel.py +0 -341
  442. empathy_os/workflows/test_lifecycle.py +0 -526
  443. empathy_os/workflows/test_maintenance.py +0 -627
  444. empathy_os/workflows/test_maintenance_cli.py +0 -590
  445. empathy_os/workflows/test_maintenance_crew.py +0 -840
  446. empathy_os/workflows/test_runner.py +0 -622
  447. empathy_os/workflows/tier_tracking.py +0 -531
  448. empathy_os/workflows/xml_enhanced_crew.py +0 -285
  449. empathy_software_plugin/SOFTWARE_PLUGIN_README.md +0 -57
  450. empathy_software_plugin/cli/__init__.py +0 -120
  451. empathy_software_plugin/cli/inspect.py +0 -362
  452. empathy_software_plugin/cli.py +0 -574
  453. empathy_software_plugin/plugin.py +0 -188
  454. workflow_scaffolding/__init__.py +0 -11
  455. workflow_scaffolding/__main__.py +0 -12
  456. workflow_scaffolding/cli.py +0 -206
  457. workflow_scaffolding/generator.py +0 -265
  458. {empathy_framework-5.3.0.dist-info → empathy_framework-5.4.0.dist-info}/WHEEL +0 -0
@@ -1,1262 +0,0 @@
1
- """Health Check Crew
2
-
3
- A multi-agent crew that diagnoses and fixes project health issues.
4
- Uses XML-enhanced prompts for structured, consistent output.
5
-
6
- Agents:
7
- 1. Health Lead (Coordinator) - Orchestrates checks, prioritizes fixes
8
- 2. Lint Fixer - Runs ruff, generates auto-fix patches
9
- 3. Type Resolver - Runs mypy, suggests type annotations
10
- 4. Test Doctor - Runs pytest, diagnoses and fixes test failures
11
- 5. Dep Auditor - Checks outdated/vulnerable dependencies
12
-
13
- Usage:
14
- from empathy_llm_toolkit.agent_factory.crews import HealthCheckCrew
15
-
16
- crew = HealthCheckCrew(api_key="...")
17
- report = await crew.check(path=".", auto_fix=True)
18
-
19
- print(f"Health Score: {report.health_score}")
20
- for fix in report.applied_fixes:
21
- print(f" Fixed: {fix.title}")
22
-
23
- Copyright 2025 Smart-AI-Memory
24
- Licensed under Fair Source License 0.9
25
- """
26
-
27
- import logging
28
- import subprocess
29
- from dataclasses import dataclass, field
30
- from enum import Enum
31
- from pathlib import Path
32
- from typing import Any
33
-
34
- logger = logging.getLogger(__name__)
35
-
36
-
37
- class HealthCategory(Enum):
38
- """Health check categories."""
39
-
40
- LINT = "lint"
41
- TYPES = "types"
42
- TESTS = "tests"
43
- DEPENDENCIES = "dependencies"
44
- SECURITY = "security"
45
- GENERAL = "general"
46
-
47
-
48
- class IssueSeverity(Enum):
49
- """Issue severity levels."""
50
-
51
- CRITICAL = "critical"
52
- HIGH = "high"
53
- MEDIUM = "medium"
54
- LOW = "low"
55
- INFO = "info"
56
-
57
-
58
- class FixStatus(Enum):
59
- """Status of an attempted fix."""
60
-
61
- APPLIED = "applied"
62
- SUGGESTED = "suggested"
63
- FAILED = "failed"
64
- SKIPPED = "skipped"
65
-
66
-
67
- @dataclass
68
- class HealthIssue:
69
- """A single health issue found."""
70
-
71
- title: str
72
- description: str
73
- category: HealthCategory
74
- severity: IssueSeverity
75
- file_path: str | None = None
76
- line_number: int | None = None
77
- code_snippet: str | None = None
78
- tool: str | None = None
79
- rule_id: str | None = None
80
- metadata: dict = field(default_factory=dict)
81
-
82
- def to_dict(self) -> dict:
83
- """Convert issue to dictionary."""
84
- return {
85
- "title": self.title,
86
- "description": self.description,
87
- "category": self.category.value,
88
- "severity": self.severity.value,
89
- "file_path": self.file_path,
90
- "line_number": self.line_number,
91
- "code_snippet": self.code_snippet,
92
- "tool": self.tool,
93
- "rule_id": self.rule_id,
94
- "metadata": self.metadata,
95
- }
96
-
97
-
98
- @dataclass
99
- class HealthFix:
100
- """A fix applied or suggested."""
101
-
102
- title: str
103
- description: str
104
- category: HealthCategory
105
- status: FixStatus
106
- file_path: str | None = None
107
- before_code: str | None = None
108
- after_code: str | None = None
109
- patch: str | None = None
110
- related_issues: list[str] = field(default_factory=list)
111
- metadata: dict = field(default_factory=dict)
112
-
113
- def to_dict(self) -> dict:
114
- """Convert fix to dictionary."""
115
- return {
116
- "title": self.title,
117
- "description": self.description,
118
- "category": self.category.value,
119
- "status": self.status.value,
120
- "file_path": self.file_path,
121
- "before_code": self.before_code,
122
- "after_code": self.after_code,
123
- "patch": self.patch,
124
- "related_issues": self.related_issues,
125
- "metadata": self.metadata,
126
- }
127
-
128
-
129
- @dataclass
130
- class HealthCheckReport:
131
- """Complete health check report."""
132
-
133
- target: str
134
- issues: list[HealthIssue]
135
- fixes: list[HealthFix]
136
- health_score: float
137
- check_duration_seconds: float = 0.0
138
- agents_used: list[str] = field(default_factory=list)
139
- memory_graph_hits: int = 0
140
- checks_run: dict = field(default_factory=dict)
141
- metadata: dict = field(default_factory=dict)
142
-
143
- @property
144
- def critical_issues(self) -> list[HealthIssue]:
145
- """Get critical severity issues."""
146
- return [i for i in self.issues if i.severity == IssueSeverity.CRITICAL]
147
-
148
- @property
149
- def applied_fixes(self) -> list[HealthFix]:
150
- """Get successfully applied fixes."""
151
- return [f for f in self.fixes if f.status == FixStatus.APPLIED]
152
-
153
- @property
154
- def issues_by_category(self) -> dict[str, list[HealthIssue]]:
155
- """Group issues by category."""
156
- result: dict[str, list[HealthIssue]] = {}
157
- for issue in self.issues:
158
- cat = issue.category.value
159
- if cat not in result:
160
- result[cat] = []
161
- result[cat].append(issue)
162
- return result
163
-
164
- @property
165
- def is_healthy(self) -> bool:
166
- """Check if project is healthy (score >= 80)."""
167
- return self.health_score >= 80.0
168
-
169
- def to_dict(self) -> dict:
170
- """Convert report to dictionary."""
171
- return {
172
- "target": self.target,
173
- "issues": [i.to_dict() for i in self.issues],
174
- "fixes": [f.to_dict() for f in self.fixes],
175
- "health_score": self.health_score,
176
- "check_duration_seconds": self.check_duration_seconds,
177
- "agents_used": self.agents_used,
178
- "memory_graph_hits": self.memory_graph_hits,
179
- "checks_run": self.checks_run,
180
- "is_healthy": self.is_healthy,
181
- "issue_counts": {
182
- "critical": len(self.critical_issues),
183
- "total": len(self.issues),
184
- "by_category": {k: len(v) for k, v in self.issues_by_category.items()},
185
- },
186
- "fix_counts": {
187
- "applied": len(self.applied_fixes),
188
- "total": len(self.fixes),
189
- },
190
- "metadata": self.metadata,
191
- }
192
-
193
-
194
- @dataclass
195
- class HealthCheckConfig:
196
- """Configuration for health check crew."""
197
-
198
- # API Configuration
199
- provider: str = "anthropic"
200
- api_key: str | None = None
201
-
202
- # Check Configuration
203
- check_lint: bool = True
204
- check_types: bool = True
205
- check_tests: bool = True
206
- check_deps: bool = True
207
- auto_fix: bool = False # Apply fixes automatically
208
- fix_safe_only: bool = True # Only apply safe fixes
209
-
210
- # Paths
211
- target_path: str = "."
212
- exclude_paths: list[str] = field(default_factory=lambda: [".git", "venv", "__pycache__"])
213
-
214
- # Memory Graph
215
- memory_graph_enabled: bool = True
216
- memory_graph_path: str = "patterns/health_check_memory.json"
217
-
218
- # Agent Tiers
219
- lead_tier: str = "premium"
220
- lint_tier: str = "capable"
221
- types_tier: str = "capable"
222
- tests_tier: str = "capable"
223
- deps_tier: str = "capable"
224
-
225
- # XML Prompts
226
- xml_prompts_enabled: bool = True
227
- xml_schema_version: str = "1.0"
228
-
229
- # Resilience
230
- resilience_enabled: bool = True
231
- timeout_seconds: float = 300.0
232
-
233
-
234
- # XML Prompt Templates for Health Check Agents
235
- XML_PROMPT_TEMPLATES = {
236
- "health_lead": """<agent role="health_lead" version="{schema_version}">
237
- <identity>
238
- <role>Health Check Coordinator</role>
239
- <expertise>Project health assessment, issue prioritization, fix orchestration</expertise>
240
- </identity>
241
-
242
- <goal>
243
- Coordinate the health check team to diagnose and fix project issues.
244
- Synthesize findings from all agents into a prioritized action plan.
245
- </goal>
246
-
247
- <instructions>
248
- <step>Review health check results from all team members</step>
249
- <step>Prioritize issues by severity and impact</step>
250
- <step>Identify quick wins (easy fixes with high impact)</step>
251
- <step>Create an ordered fix plan</step>
252
- <step>Calculate overall health score (0-100)</step>
253
- <step>Generate executive summary with recommendations</step>
254
- </instructions>
255
-
256
- <constraints>
257
- <rule>Be conservative with auto-fix recommendations</rule>
258
- <rule>Prioritize breaking issues first</rule>
259
- <rule>Consider fix dependencies (some fixes enable others)</rule>
260
- <rule>Flag risky fixes that need human review</rule>
261
- </constraints>
262
-
263
- <output_format>
264
- <section name="summary">Executive summary of health status</section>
265
- <section name="health_score">Numeric score 0-100</section>
266
- <section name="critical_issues">Blocking issues requiring immediate attention</section>
267
- <section name="fix_plan">Ordered list of recommended fixes</section>
268
- <section name="metrics">Lint errors, type errors, test failures, dep issues</section>
269
- </output_format>
270
- </agent>""",
271
- "lint_fixer": """<agent role="lint_fixer" version="{schema_version}">
272
- <identity>
273
- <role>Lint Analyst & Fixer</role>
274
- <expertise>Code style, ruff rules, auto-formatting, code quality</expertise>
275
- </identity>
276
-
277
- <goal>
278
- Analyze lint issues and generate fixes. Apply safe auto-fixes when enabled.
279
- </goal>
280
-
281
- <instructions>
282
- <step>Parse ruff output to identify all lint violations</step>
283
- <step>Categorize by rule type (style, error, security)</step>
284
- <step>Identify auto-fixable issues (ruff --fix compatible)</step>
285
- <step>Generate patch for complex issues requiring manual fix</step>
286
- <step>Explain why each fix is necessary</step>
287
- </instructions>
288
-
289
- <constraints>
290
- <rule>Only auto-fix style and formatting issues</rule>
291
- <rule>Flag security-related lint issues as high priority</rule>
292
- <rule>Preserve code semantics - never change behavior</rule>
293
- <rule>Respect noqa comments and intentional suppressions</rule>
294
- </constraints>
295
-
296
- <tools>
297
- <tool name="ruff">python -m ruff check --output-format=json</tool>
298
- <tool name="ruff_fix">python -m ruff check --fix</tool>
299
- </tools>
300
-
301
- <output_format>
302
- <section name="issues">List of lint issues with file, line, rule, message</section>
303
- <section name="auto_fixable">Issues that can be auto-fixed</section>
304
- <section name="manual_fixes">Issues requiring manual intervention with suggested code</section>
305
- <section name="summary">Count by category and severity</section>
306
- </output_format>
307
- </agent>""",
308
- "type_resolver": """<agent role="type_resolver" version="{schema_version}">
309
- <identity>
310
- <role>Type Error Resolver</role>
311
- <expertise>Python type hints, mypy, type inference, generic types</expertise>
312
- </identity>
313
-
314
- <goal>
315
- Diagnose type errors and suggest type annotations to resolve them.
316
- </goal>
317
-
318
- <instructions>
319
- <step>Parse mypy output to identify all type errors</step>
320
- <step>Categorize errors (missing annotation, incompatible types, etc.)</step>
321
- <step>Infer correct types from context and usage</step>
322
- <step>Generate type stub suggestions for third-party libraries</step>
323
- <step>Suggest incremental typing strategy for untyped code</step>
324
- </instructions>
325
-
326
- <constraints>
327
- <rule>Prefer simple types over complex generics when possible</rule>
328
- <rule>Use | union syntax (Python 3.10+) over Union</rule>
329
- <rule>Suggest Any only as last resort</rule>
330
- <rule>Consider runtime type checking implications</rule>
331
- </constraints>
332
-
333
- <tools>
334
- <tool name="mypy">python -m mypy --output=json</tool>
335
- </tools>
336
-
337
- <output_format>
338
- <section name="errors">List of type errors with file, line, message</section>
339
- <section name="fixes">Suggested type annotations for each error</section>
340
- <section name="stubs">Type stubs needed for third-party packages</section>
341
- <section name="summary">Error count and typing coverage estimate</section>
342
- </output_format>
343
- </agent>""",
344
- "test_doctor": """<agent role="test_doctor" version="{schema_version}">
345
- <identity>
346
- <role>Test Failure Diagnostician</role>
347
- <expertise>pytest, test fixtures, mocking, assertion debugging</expertise>
348
- </identity>
349
-
350
- <goal>
351
- Diagnose test failures and suggest fixes to make tests pass.
352
- </goal>
353
-
354
- <instructions>
355
- <step>Parse pytest output to identify failing tests</step>
356
- <step>Analyze failure type (assertion, exception, timeout, fixture)</step>
357
- <step>Determine root cause (test bug vs code bug)</step>
358
- <step>Generate fix for test-side issues</step>
359
- <step>Flag code-side issues for other agents</step>
360
- <step>Identify flaky tests that need stabilization</step>
361
- </instructions>
362
-
363
- <constraints>
364
- <rule>Distinguish between test bugs and code bugs</rule>
365
- <rule>Never suggest removing assertions to fix tests</rule>
366
- <rule>Prefer fixing test setup over mocking more</rule>
367
- <rule>Flag tests that test implementation not behavior</rule>
368
- </constraints>
369
-
370
- <tools>
371
- <tool name="pytest">python -m pytest --tb=short -q</tool>
372
- <tool name="pytest_collect">python -m pytest --collect-only -q</tool>
373
- </tools>
374
-
375
- <output_format>
376
- <section name="failures">List of failing tests with traceback summary</section>
377
- <section name="diagnosis">Root cause analysis for each failure</section>
378
- <section name="test_fixes">Fixes for test-side issues</section>
379
- <section name="code_issues">Code bugs discovered via tests</section>
380
- <section name="summary">Pass/fail counts and coverage if available</section>
381
- </output_format>
382
- </agent>""",
383
- "dep_auditor": """<agent role="dep_auditor" version="{schema_version}">
384
- <identity>
385
- <role>Dependency Auditor</role>
386
- <expertise>pip, package versions, security advisories, compatibility</expertise>
387
- </identity>
388
-
389
- <goal>
390
- Audit dependencies for security vulnerabilities and outdated packages.
391
- </goal>
392
-
393
- <instructions>
394
- <step>Parse requirements.txt/pyproject.toml for dependencies</step>
395
- <step>Check for known security vulnerabilities (pip-audit)</step>
396
- <step>Identify outdated packages with available updates</step>
397
- <step>Assess update risk (major vs minor vs patch)</step>
398
- <step>Check for dependency conflicts</step>
399
- <step>Suggest safe update path</step>
400
- </instructions>
401
-
402
- <constraints>
403
- <rule>Prioritize security vulnerabilities over outdated packages</rule>
404
- <rule>Be conservative with major version upgrades</rule>
405
- <rule>Check changelog for breaking changes before suggesting upgrades</rule>
406
- <rule>Consider transitive dependency impacts</rule>
407
- </constraints>
408
-
409
- <tools>
410
- <tool name="pip_audit">pip-audit --format=json</tool>
411
- <tool name="pip_outdated">pip list --outdated --format=json</tool>
412
- </tools>
413
-
414
- <output_format>
415
- <section name="vulnerabilities">Security issues with CVE and severity</section>
416
- <section name="outdated">Packages with available updates</section>
417
- <section name="conflicts">Dependency conflicts detected</section>
418
- <section name="update_plan">Safe update sequence</section>
419
- <section name="summary">Vulnerability count and overall dep health</section>
420
- </output_format>
421
- </agent>""",
422
- }
423
-
424
-
425
- class HealthCheckCrew:
426
- """Multi-agent crew for project health diagnosis and fixing.
427
-
428
- The crew consists of 5 specialized agents using XML-enhanced prompts:
429
-
430
- 1. **Health Lead** (Coordinator)
431
- - Orchestrates the health check team
432
- - Synthesizes findings from all agents
433
- - Prioritizes fixes by impact
434
- - Calculates health score
435
- - Model: Premium tier
436
-
437
- 2. **Lint Fixer** (Analyst)
438
- - Runs ruff for lint checking
439
- - Identifies auto-fixable issues
440
- - Generates patches for manual fixes
441
- - Model: Capable tier
442
-
443
- 3. **Type Resolver** (Analyst)
444
- - Runs mypy for type checking
445
- - Suggests type annotations
446
- - Generates type stubs
447
- - Model: Capable tier
448
-
449
- 4. **Test Doctor** (Analyst)
450
- - Runs pytest for test checking
451
- - Diagnoses test failures
452
- - Distinguishes test bugs from code bugs
453
- - Model: Capable tier
454
-
455
- 5. **Dep Auditor** (Analyst)
456
- - Checks for vulnerabilities
457
- - Identifies outdated packages
458
- - Suggests safe update paths
459
- - Model: Capable tier
460
-
461
- Example:
462
- crew = HealthCheckCrew(api_key="...")
463
- report = await crew.check(path=".", auto_fix=True)
464
-
465
- if report.is_healthy:
466
- print("Project is healthy!")
467
- else:
468
- print(f"Health Score: {report.health_score}/100")
469
- for issue in report.critical_issues:
470
- print(f" - {issue.title}")
471
-
472
- """
473
-
474
- def __init__(self, config: HealthCheckConfig | None = None, **kwargs: Any):
475
- """Initialize the Health Check Crew.
476
-
477
- Args:
478
- config: HealthCheckConfig or pass individual params as kwargs
479
- **kwargs: Individual config parameters (api_key, provider, etc.)
480
-
481
- """
482
- if config:
483
- self.config = config
484
- else:
485
- self.config = HealthCheckConfig(**kwargs)
486
-
487
- self._factory: Any = None
488
- self._agents: dict[str, Any] = {}
489
- self._workflow: Any = None
490
- self._graph: Any = None
491
- self._initialized = False
492
-
493
- def _render_xml_prompt(self, template_key: str) -> str:
494
- """Render XML prompt template with config values."""
495
- template = XML_PROMPT_TEMPLATES.get(template_key, "")
496
- return template.format(schema_version=self.config.xml_schema_version)
497
-
498
- def _get_system_prompt(self, agent_key: str, fallback: str) -> str:
499
- """Get system prompt - XML if enabled, fallback otherwise."""
500
- if self.config.xml_prompts_enabled:
501
- return self._render_xml_prompt(agent_key)
502
- return fallback
503
-
504
- async def _initialize(self) -> None:
505
- """Lazy initialization of agents and workflow."""
506
- if self._initialized:
507
- return
508
-
509
- from empathy_llm_toolkit.agent_factory import AgentFactory, Framework
510
-
511
- # Check if CrewAI is available
512
- try:
513
- from empathy_llm_toolkit.agent_factory.adapters.crewai_adapter import _check_crewai
514
-
515
- use_crewai = _check_crewai()
516
- except ImportError:
517
- use_crewai = False
518
-
519
- # Use CrewAI if available, otherwise fall back to Native
520
- framework = Framework.CREWAI if use_crewai else Framework.NATIVE
521
-
522
- self._factory = AgentFactory(
523
- framework=framework,
524
- provider=self.config.provider,
525
- api_key=self.config.api_key,
526
- )
527
-
528
- # Initialize Memory Graph if enabled
529
- if self.config.memory_graph_enabled:
530
- try:
531
- from empathy_os.memory import MemoryGraph
532
-
533
- self._graph = MemoryGraph(path=self.config.memory_graph_path)
534
- except ImportError:
535
- logger.warning("Memory Graph not available, continuing without it")
536
-
537
- # Create the 5 specialized agents
538
- await self._create_agents()
539
-
540
- # Create hierarchical workflow
541
- await self._create_workflow()
542
-
543
- self._initialized = True
544
-
545
- async def _create_agents(self) -> None:
546
- """Create the 5 specialized health check agents with XML prompts."""
547
- # 1. Health Lead (Coordinator)
548
- self._agents["lead"] = self._factory.create_agent(
549
- name="health_lead",
550
- role="coordinator",
551
- description="Senior engineer who orchestrates the health check team",
552
- system_prompt=self._get_system_prompt(
553
- "health_lead",
554
- """You are the Health Lead, coordinating project health checks.
555
-
556
- Your responsibilities:
557
- 1. Coordinate the health check team
558
- 2. Synthesize findings from all checkers
559
- 3. Prioritize issues by severity and impact
560
- 4. Calculate overall health score (0-100)
561
- 5. Generate actionable fix plan
562
-
563
- Health Score calculation:
564
- - Start at 100
565
- - Deduct 25 per critical issue
566
- - Deduct 10 per high issue
567
- - Deduct 3 per medium issue
568
- - Deduct 1 per low issue
569
-
570
- Be constructive and prioritize quick wins.""",
571
- ),
572
- model_tier=self.config.lead_tier,
573
- memory_graph_enabled=self.config.memory_graph_enabled,
574
- memory_graph_path=self.config.memory_graph_path,
575
- resilience_enabled=self.config.resilience_enabled,
576
- )
577
-
578
- # 2. Lint Fixer
579
- self._agents["lint"] = self._factory.create_agent(
580
- name="lint_fixer",
581
- role="analyst",
582
- description="Expert at identifying and fixing lint issues",
583
- system_prompt=self._get_system_prompt(
584
- "lint_fixer",
585
- """You are the Lint Fixer, a code quality expert.
586
-
587
- Your focus:
588
- 1. Parse ruff output for lint violations
589
- 2. Categorize by type (style, error, security)
590
- 3. Identify auto-fixable issues
591
- 4. Generate patches for complex fixes
592
- 5. Explain each fix
593
-
594
- Rules:
595
- - Only auto-fix safe style issues
596
- - Flag security-related issues as high priority
597
- - Never change code behavior
598
- - Respect noqa comments""",
599
- ),
600
- model_tier=self.config.lint_tier,
601
- memory_graph_enabled=self.config.memory_graph_enabled,
602
- memory_graph_path=self.config.memory_graph_path,
603
- )
604
-
605
- # 3. Type Resolver
606
- self._agents["types"] = self._factory.create_agent(
607
- name="type_resolver",
608
- role="analyst",
609
- description="Expert at resolving type errors",
610
- system_prompt=self._get_system_prompt(
611
- "type_resolver",
612
- """You are the Type Resolver, a typing expert.
613
-
614
- Your focus:
615
- 1. Parse mypy output for type errors
616
- 2. Categorize errors by type
617
- 3. Infer correct types from context
618
- 4. Generate type annotations
619
- 5. Suggest typing strategy
620
-
621
- Rules:
622
- - Prefer simple types over complex generics
623
- - Use | union syntax (Python 3.10+)
624
- - Suggest Any only as last resort
625
- - Consider runtime implications""",
626
- ),
627
- model_tier=self.config.types_tier,
628
- memory_graph_enabled=self.config.memory_graph_enabled,
629
- memory_graph_path=self.config.memory_graph_path,
630
- )
631
-
632
- # 4. Test Doctor
633
- self._agents["tests"] = self._factory.create_agent(
634
- name="test_doctor",
635
- role="analyst",
636
- description="Expert at diagnosing test failures",
637
- system_prompt=self._get_system_prompt(
638
- "test_doctor",
639
- """You are the Test Doctor, a testing expert.
640
-
641
- Your focus:
642
- 1. Parse pytest output for failures
643
- 2. Analyze failure type (assertion, exception, timeout)
644
- 3. Determine root cause (test bug vs code bug)
645
- 4. Generate fixes for test issues
646
- 5. Identify flaky tests
647
-
648
- Rules:
649
- - Distinguish test bugs from code bugs
650
- - Never remove assertions to fix tests
651
- - Prefer fixing setup over mocking
652
- - Flag implementation-coupled tests""",
653
- ),
654
- model_tier=self.config.tests_tier,
655
- memory_graph_enabled=self.config.memory_graph_enabled,
656
- memory_graph_path=self.config.memory_graph_path,
657
- )
658
-
659
- # 5. Dep Auditor
660
- self._agents["deps"] = self._factory.create_agent(
661
- name="dep_auditor",
662
- role="analyst",
663
- description="Expert at auditing dependencies",
664
- system_prompt=self._get_system_prompt(
665
- "dep_auditor",
666
- """You are the Dep Auditor, a dependency expert.
667
-
668
- Your focus:
669
- 1. Check for security vulnerabilities
670
- 2. Identify outdated packages
671
- 3. Assess update risk
672
- 4. Check for conflicts
673
- 5. Suggest safe update paths
674
-
675
- Rules:
676
- - Prioritize security over outdated
677
- - Be conservative with major upgrades
678
- - Check changelogs for breaking changes
679
- - Consider transitive impacts""",
680
- ),
681
- model_tier=self.config.deps_tier,
682
- memory_graph_enabled=self.config.memory_graph_enabled,
683
- memory_graph_path=self.config.memory_graph_path,
684
- )
685
-
686
- async def _create_workflow(self) -> None:
687
- """Create hierarchical workflow with Health Lead as manager."""
688
- agents = list(self._agents.values())
689
-
690
- self._workflow = self._factory.create_workflow(
691
- name="health_check_workflow",
692
- agents=agents,
693
- mode="hierarchical",
694
- description="Comprehensive health check with coordinated diagnosis and fixes",
695
- )
696
-
697
- async def check(
698
- self,
699
- path: str = ".",
700
- auto_fix: bool | None = None,
701
- context: dict | None = None,
702
- ) -> HealthCheckReport:
703
- """Perform a comprehensive health check.
704
-
705
- Args:
706
- path: Path to check (default: current directory)
707
- auto_fix: Override config auto_fix setting
708
- context: Optional context (focus areas, previous checks, etc.)
709
-
710
- Returns:
711
- HealthCheckReport with issues, fixes, and health score
712
-
713
- """
714
- import time
715
-
716
- start_time = time.time()
717
-
718
- # Initialize if needed
719
- await self._initialize()
720
-
721
- context = context or {}
722
- auto_fix = auto_fix if auto_fix is not None else self.config.auto_fix
723
- issues: list[HealthIssue] = []
724
- fixes: list[HealthFix] = []
725
- checks_run: dict[str, dict] = {}
726
- memory_hits = 0
727
-
728
- # Run the individual checks first to gather data
729
- if self.config.check_lint:
730
- lint_result = await self._run_lint_check(path)
731
- checks_run["lint"] = lint_result
732
- issues.extend(lint_result.get("issues", []))
733
-
734
- if self.config.check_types:
735
- types_result = await self._run_type_check(path)
736
- checks_run["types"] = types_result
737
- issues.extend(types_result.get("issues", []))
738
-
739
- if self.config.check_tests:
740
- tests_result = await self._run_test_check(path)
741
- checks_run["tests"] = tests_result
742
- issues.extend(tests_result.get("issues", []))
743
-
744
- if self.config.check_deps:
745
- deps_result = await self._run_dep_check(path)
746
- checks_run["deps"] = deps_result
747
- issues.extend(deps_result.get("issues", []))
748
-
749
- # Check Memory Graph for similar past issues
750
- if self._graph and self.config.memory_graph_enabled:
751
- try:
752
- similar = self._graph.find_similar(
753
- {"name": f"health_check:{path}", "description": f"Health check of {path}"},
754
- threshold=0.4,
755
- limit=10,
756
- )
757
- if similar:
758
- memory_hits = len(similar)
759
- context["past_checks"] = [
760
- {
761
- "name": node.name,
762
- "health_score": node.metadata.get("health_score", 0),
763
- "issues_found": node.metadata.get("issues_found", 0),
764
- }
765
- for node, score in similar
766
- ]
767
- logger.info(f"Found {memory_hits} similar past health checks")
768
- except Exception as e: # noqa: BLE001
769
- # INTENTIONAL: Memory Graph is optional - continue health check if unavailable
770
- logger.warning(f"Error querying Memory Graph: {e}")
771
-
772
- # Build task for the crew to analyze and generate fixes
773
- check_task = self._build_check_task(path, checks_run, issues, auto_fix, context)
774
-
775
- # Execute the workflow for analysis
776
- try:
777
- result = await self._workflow.run(check_task, initial_state=context)
778
-
779
- # Parse fixes from result
780
- fixes = self._parse_fixes(result, issues)
781
-
782
- # Apply auto-fixes if enabled
783
- if auto_fix:
784
- fixes = await self._apply_fixes(fixes, path)
785
-
786
- except Exception as e: # noqa: BLE001
787
- # INTENTIONAL: Analysis failure shouldn't crash - return partial results
788
- logger.error(f"Health check analysis failed: {e}")
789
-
790
- # Calculate health score
791
- health_score = self._calculate_health_score(issues)
792
-
793
- # Build the report
794
- duration = time.time() - start_time
795
- report = HealthCheckReport(
796
- target=path,
797
- issues=issues,
798
- fixes=fixes,
799
- health_score=health_score,
800
- check_duration_seconds=duration,
801
- agents_used=list(self._agents.keys()),
802
- memory_graph_hits=memory_hits,
803
- checks_run={k: {"passed": v.get("passed", False)} for k, v in checks_run.items()},
804
- metadata={
805
- "auto_fix": auto_fix,
806
- "framework": str(self._factory.framework.value) if self._factory else "unknown",
807
- "xml_prompts": self.config.xml_prompts_enabled,
808
- },
809
- )
810
-
811
- # Store check in Memory Graph
812
- if self._graph and self.config.memory_graph_enabled:
813
- try:
814
- self._graph.add_finding(
815
- "health_check_crew",
816
- {
817
- "type": "health_check",
818
- "name": f"check:{path}",
819
- "description": f"Health score: {health_score}/100",
820
- "health_score": health_score,
821
- "issues_found": len(issues),
822
- "fixes_applied": len(report.applied_fixes),
823
- },
824
- )
825
- self._graph._save()
826
- except Exception as e: # noqa: BLE001
827
- # INTENTIONAL: Memory Graph storage is optional - continue without it
828
- logger.warning(f"Error storing check in Memory Graph: {e}")
829
-
830
- return report
831
-
832
- async def _run_lint_check(self, path: str) -> dict:
833
- """Run ruff lint check."""
834
- issues = []
835
- passed = True
836
-
837
- try:
838
- result = subprocess.run(
839
- ["python", "-m", "ruff", "check", path, "--output-format=json"],
840
- check=False,
841
- capture_output=True,
842
- text=True,
843
- timeout=60,
844
- )
845
-
846
- if result.returncode != 0:
847
- passed = False
848
-
849
- # Parse JSON output
850
- import json
851
-
852
- try:
853
- violations = json.loads(result.stdout) if result.stdout else []
854
- for v in violations[:50]: # Limit to 50
855
- issues.append(
856
- HealthIssue(
857
- title=f"{v.get('code', 'LINT')}: {v.get('message', 'Lint error')}",
858
- description=v.get("message", ""),
859
- category=HealthCategory.LINT,
860
- severity=IssueSeverity.MEDIUM,
861
- file_path=v.get("filename"),
862
- line_number=v.get("location", {}).get("row"),
863
- rule_id=v.get("code"),
864
- tool="ruff",
865
- ),
866
- )
867
- except json.JSONDecodeError:
868
- pass
869
-
870
- except (subprocess.TimeoutExpired, FileNotFoundError) as e:
871
- logger.warning(f"Lint check failed: {e}")
872
-
873
- return {"passed": passed, "issues": issues, "tool": "ruff"}
874
-
875
- async def _run_type_check(self, path: str) -> dict:
876
- """Run mypy type check."""
877
- issues = []
878
- passed = True
879
-
880
- # Only scan production code packages
881
- production_packages = [
882
- "empathy_os",
883
- "empathy_software_plugin",
884
- "empathy_healthcare_plugin",
885
- "empathy_llm_toolkit",
886
- "patterns",
887
- ]
888
-
889
- # Use production packages if checking current directory
890
- scan_args = []
891
- if path in [".", "./"]:
892
- # Use package notation for packages in src/
893
- for pkg in production_packages:
894
- scan_args.extend(["-p", pkg])
895
- else:
896
- # For specific paths, use file notation
897
- scan_args.append(path)
898
-
899
- try:
900
- result = subprocess.run(
901
- ["python", "-m", "mypy"]
902
- + scan_args
903
- + ["--ignore-missing-imports", "--no-error-summary"],
904
- check=False,
905
- capture_output=True,
906
- text=True,
907
- timeout=120,
908
- )
909
-
910
- if result.returncode != 0:
911
- passed = False
912
-
913
- # Parse text output
914
- for line in result.stdout.splitlines()[:50]:
915
- if ": error:" in line:
916
- parts = line.split(": error:", 1)
917
- location = parts[0] if parts else ""
918
- message = parts[1].strip() if len(parts) > 1 else line
919
-
920
- file_path = None
921
- line_num = None
922
- if ":" in location:
923
- loc_parts = location.rsplit(":", 2)
924
- file_path = loc_parts[0]
925
- try:
926
- line_num = int(loc_parts[1]) if len(loc_parts) > 1 else None
927
- except ValueError:
928
- pass
929
-
930
- issues.append(
931
- HealthIssue(
932
- title=f"Type error: {message[:60]}",
933
- description=message,
934
- category=HealthCategory.TYPES,
935
- severity=IssueSeverity.MEDIUM,
936
- file_path=file_path,
937
- line_number=line_num,
938
- tool="mypy",
939
- ),
940
- )
941
-
942
- except (subprocess.TimeoutExpired, FileNotFoundError) as e:
943
- logger.warning(f"Type check failed: {e}")
944
-
945
- return {"passed": passed, "issues": issues, "tool": "mypy"}
946
-
947
- async def _run_test_check(self, path: str) -> dict:
948
- """Run pytest test check."""
949
- issues = []
950
- passed = True
951
-
952
- # Only run tests in tests/ directory for production health check
953
- test_path = "tests/" if path in [".", "./"] else path
954
-
955
- try:
956
- result = subprocess.run(
957
- ["python", "-m", "pytest", test_path, "--collect-only", "-q"],
958
- check=False,
959
- capture_output=True,
960
- text=True,
961
- timeout=60,
962
- )
963
-
964
- if result.returncode != 0:
965
- passed = False
966
-
967
- # Check for collection errors in stderr
968
- error_output = result.stderr + result.stdout
969
- for line in error_output.splitlines()[:50]:
970
- if "ERROR" in line or "INTERNALERROR" in line:
971
- # Only report actual errors, not counts
972
- if "error" in line.lower() and not line.strip().startswith("="):
973
- issues.append(
974
- HealthIssue(
975
- title=f"Test error: {line[:50]}",
976
- description=line,
977
- category=HealthCategory.TESTS,
978
- severity=IssueSeverity.CRITICAL,
979
- tool="pytest",
980
- ),
981
- )
982
-
983
- except (subprocess.TimeoutExpired, FileNotFoundError) as e:
984
- logger.warning(f"Test check failed: {e}")
985
-
986
- return {"passed": passed, "issues": issues, "tool": "pytest"}
987
-
988
- async def _run_dep_check(self, path: str) -> dict:
989
- """Run dependency security check."""
990
- issues = []
991
- passed = True
992
-
993
- # Try pip-audit first
994
- try:
995
- result = subprocess.run(
996
- ["pip-audit", "--format=json"],
997
- check=False,
998
- capture_output=True,
999
- text=True,
1000
- timeout=60,
1001
- cwd=path if Path(path).is_dir() else ".",
1002
- )
1003
-
1004
- if result.returncode != 0:
1005
- passed = False
1006
-
1007
- import json
1008
-
1009
- try:
1010
- vulns = json.loads(result.stdout) if result.stdout else []
1011
- # Ensure vulns is a list
1012
- if isinstance(vulns, dict):
1013
- vulns = vulns.get("vulnerabilities", []) or list(vulns.values())
1014
- if not isinstance(vulns, list):
1015
- vulns = []
1016
- for v in vulns[:20]:
1017
- # Handle different vulnerability formats
1018
- if not isinstance(v, dict):
1019
- # Skip non-dict items or convert to basic format
1020
- continue
1021
-
1022
- severity = IssueSeverity.HIGH
1023
- if "critical" in str(v).lower():
1024
- severity = IssueSeverity.CRITICAL
1025
-
1026
- issues.append(
1027
- HealthIssue(
1028
- title=f"Vulnerability in {v.get('name', 'unknown')}",
1029
- description=v.get("description", str(v)),
1030
- category=HealthCategory.DEPENDENCIES,
1031
- severity=severity,
1032
- rule_id=v.get("id"),
1033
- tool="pip-audit",
1034
- metadata={"fix_versions": v.get("fix_versions", [])},
1035
- ),
1036
- )
1037
- except json.JSONDecodeError:
1038
- pass
1039
-
1040
- except (subprocess.TimeoutExpired, FileNotFoundError):
1041
- # pip-audit not installed, try basic pip check
1042
- try:
1043
- result = subprocess.run(
1044
- ["pip", "check"],
1045
- check=False,
1046
- capture_output=True,
1047
- text=True,
1048
- timeout=30,
1049
- )
1050
- if result.returncode != 0:
1051
- passed = False
1052
- for line in result.stdout.splitlines()[:10]:
1053
- issues.append(
1054
- HealthIssue(
1055
- title=f"Dependency conflict: {line[:50]}",
1056
- description=line,
1057
- category=HealthCategory.DEPENDENCIES,
1058
- severity=IssueSeverity.MEDIUM,
1059
- tool="pip",
1060
- ),
1061
- )
1062
- except (subprocess.TimeoutExpired, FileNotFoundError):
1063
- pass
1064
-
1065
- return {"passed": passed, "issues": issues, "tool": "pip-audit/pip"}
1066
-
1067
- def _build_check_task(
1068
- self,
1069
- path: str,
1070
- checks_run: dict,
1071
- issues: list[HealthIssue],
1072
- auto_fix: bool,
1073
- context: dict,
1074
- ) -> str:
1075
- """Build the check task description for the crew."""
1076
- issues_summary = "\n".join(
1077
- f" - [{i.severity.value.upper()}] {i.category.value}: {i.title}" for i in issues[:30]
1078
- )
1079
-
1080
- task = f"""Analyze health check results and generate fixes.
1081
-
1082
- Target: {path}
1083
- Auto-fix enabled: {auto_fix}
1084
-
1085
- Checks Run:
1086
- - Lint (ruff): {"PASS" if checks_run.get("lint", {}).get("passed") else "FAIL"}
1087
- - Types (mypy): {"PASS" if checks_run.get("types", {}).get("passed") else "FAIL"}
1088
- - Tests (pytest): {"PASS" if checks_run.get("tests", {}).get("passed") else "FAIL"}
1089
- - Dependencies: {"PASS" if checks_run.get("deps", {}).get("passed") else "FAIL"}
1090
-
1091
- Issues Found ({len(issues)}):
1092
- {issues_summary}
1093
-
1094
- Workflow:
1095
- 1. Health Lead coordinates analysis
1096
- 2. Lint Fixer analyzes and suggests fixes for lint issues
1097
- 3. Type Resolver suggests type annotations
1098
- 4. Test Doctor diagnoses test failures
1099
- 5. Dep Auditor suggests dependency updates
1100
-
1101
- For each issue, provide:
1102
- - Root cause analysis
1103
- - Fix recommendation (code if applicable)
1104
- - Safety assessment (safe to auto-fix or needs review)
1105
- - Priority (1=critical, 2=high, 3=medium, 4=low)
1106
-
1107
- Generate a prioritized fix plan.
1108
- """
1109
-
1110
- if context.get("past_checks"):
1111
- task += f"""
1112
- Past Health Checks Found: {len(context["past_checks"])}
1113
- Consider patterns from past fixes.
1114
- """
1115
-
1116
- return task
1117
-
1118
- def _parse_fixes(self, result: dict, issues: list[HealthIssue]) -> list[HealthFix]:
1119
- """Parse fixes from workflow result."""
1120
- fixes = []
1121
-
1122
- # Check for structured fixes in metadata
1123
- metadata = result.get("metadata", {})
1124
- if "fixes" in metadata:
1125
- for f in metadata["fixes"]:
1126
- fixes.append(
1127
- HealthFix(
1128
- title=f.get("title", "Fix"),
1129
- description=f.get("description", ""),
1130
- category=HealthCategory(f.get("category", "general")),
1131
- status=FixStatus.SUGGESTED,
1132
- file_path=f.get("file_path"),
1133
- before_code=f.get("before_code"),
1134
- after_code=f.get("after_code"),
1135
- patch=f.get("patch"),
1136
- ),
1137
- )
1138
- return fixes
1139
-
1140
- # Generate suggested fixes based on issues
1141
- for issue in issues:
1142
- if issue.category == HealthCategory.LINT and issue.rule_id:
1143
- fixes.append(
1144
- HealthFix(
1145
- title=f"Fix {issue.rule_id}",
1146
- description=f"Run: ruff check --fix --select {issue.rule_id}",
1147
- category=issue.category,
1148
- status=FixStatus.SUGGESTED,
1149
- file_path=issue.file_path,
1150
- related_issues=[issue.title],
1151
- ),
1152
- )
1153
-
1154
- return fixes
1155
-
1156
- async def _apply_fixes(self, fixes: list[HealthFix], path: str) -> list[HealthFix]:
1157
- """Apply safe auto-fixes."""
1158
- updated_fixes = []
1159
-
1160
- for fix in fixes:
1161
- if fix.category == HealthCategory.LINT and self.config.fix_safe_only:
1162
- # Run ruff --fix for lint issues
1163
- try:
1164
- result = subprocess.run(
1165
- ["python", "-m", "ruff", "check", path, "--fix"],
1166
- check=False,
1167
- capture_output=True,
1168
- text=True,
1169
- timeout=60,
1170
- )
1171
- fix.status = FixStatus.APPLIED if result.returncode == 0 else FixStatus.FAILED
1172
- except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
1173
- fix.status = FixStatus.FAILED
1174
- else:
1175
- fix.status = FixStatus.SUGGESTED
1176
-
1177
- updated_fixes.append(fix)
1178
-
1179
- return updated_fixes
1180
-
1181
- def _calculate_health_score(self, issues: list[HealthIssue]) -> float:
1182
- """Calculate health score from issues.
1183
-
1184
- Uses category-capped deductions to prevent one category (e.g., lint)
1185
- from dominating the score. This makes the score more meaningful -
1186
- 50 lint warnings shouldn't tank a project that passes tests and has
1187
- no security issues.
1188
-
1189
- Category caps:
1190
- - lint: max -15 points
1191
- - types: max -20 points
1192
- - tests: max -25 points
1193
- - security/dependencies: max -30 points
1194
- - general: max -10 points
1195
- """
1196
- if not issues:
1197
- return 100.0
1198
-
1199
- # Per-issue deductions by severity
1200
- severity_deductions = {
1201
- IssueSeverity.CRITICAL: 15,
1202
- IssueSeverity.HIGH: 8,
1203
- IssueSeverity.MEDIUM: 2,
1204
- IssueSeverity.LOW: 0.5,
1205
- IssueSeverity.INFO: 0,
1206
- }
1207
-
1208
- # Maximum deduction per category (prevents one area from tanking score)
1209
- category_caps = {
1210
- HealthCategory.LINT: 15,
1211
- HealthCategory.TYPES: 20,
1212
- HealthCategory.TESTS: 25,
1213
- HealthCategory.DEPENDENCIES: 30,
1214
- HealthCategory.SECURITY: 30,
1215
- HealthCategory.GENERAL: 10,
1216
- }
1217
-
1218
- # Calculate deductions per category
1219
- category_deductions: dict[HealthCategory, float] = {}
1220
- for issue in issues:
1221
- cat = issue.category
1222
- deduction = severity_deductions.get(issue.severity, 0)
1223
- category_deductions[cat] = category_deductions.get(cat, 0) + deduction
1224
-
1225
- # Apply caps per category
1226
- total_deduction = 0.0
1227
- for cat, deduction in category_deductions.items():
1228
- cap = category_caps.get(cat, 10)
1229
- total_deduction += min(deduction, cap)
1230
-
1231
- return max(0.0, 100.0 - total_deduction)
1232
-
1233
- @property
1234
- def agents(self) -> dict[str, Any]:
1235
- """Get the crew's agents."""
1236
- return self._agents
1237
-
1238
- @property
1239
- def is_initialized(self) -> bool:
1240
- """Check if crew is initialized."""
1241
- return self._initialized
1242
-
1243
- async def get_agent_stats(self) -> dict:
1244
- """Get statistics about crew agents."""
1245
- await self._initialize()
1246
-
1247
- agents_dict: dict = {}
1248
- stats: dict = {
1249
- "agent_count": len(self._agents),
1250
- "agents": agents_dict,
1251
- "framework": self._factory.framework.value if self._factory else "unknown",
1252
- "memory_graph_enabled": self.config.memory_graph_enabled,
1253
- "xml_prompts_enabled": self.config.xml_prompts_enabled,
1254
- }
1255
-
1256
- for name, agent in self._agents.items():
1257
- agents_dict[name] = {
1258
- "role": agent.config.role if hasattr(agent, "config") else "unknown",
1259
- "model_tier": getattr(agent.config, "model_tier", "unknown"),
1260
- }
1261
-
1262
- return stats