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,931 +0,0 @@
1
- """Real tool implementations for meta-orchestration agents.
2
-
3
- This module provides actual tool integrations for agents to interact with
4
- real systems instead of returning mock data.
5
-
6
- Security:
7
- - All file operations validated with _validate_file_path()
8
- - Subprocess calls sanitized
9
- - Output size limited to prevent memory issues
10
- """
11
-
12
- import json
13
- import logging
14
- import subprocess
15
- from dataclasses import dataclass
16
- from pathlib import Path
17
- from typing import Any
18
-
19
- logger = logging.getLogger(__name__)
20
-
21
-
22
- def _validate_file_path(path: str) -> Path:
23
- """Validate file path to prevent path traversal (simplified version).
24
-
25
- Args:
26
- path: File path to validate
27
-
28
- Returns:
29
- Validated Path object
30
-
31
- Raises:
32
- ValueError: If path is invalid
33
- """
34
- if not path or not isinstance(path, str):
35
- raise ValueError("path must be a non-empty string")
36
-
37
- if "\x00" in path:
38
- raise ValueError("path contains null bytes")
39
-
40
- try:
41
- resolved = Path(path).resolve()
42
- except (OSError, RuntimeError) as e:
43
- raise ValueError(f"Invalid path: {e}") from e
44
-
45
- # Block system directories
46
- dangerous_paths = ["/etc", "/sys", "/proc", "/dev"]
47
- for dangerous in dangerous_paths:
48
- if str(resolved).startswith(dangerous):
49
- raise ValueError(f"Cannot write to system directory: {dangerous}")
50
-
51
- return resolved
52
-
53
-
54
- @dataclass
55
- class CoverageReport:
56
- """Coverage analysis report from pytest-cov."""
57
-
58
- total_coverage: float
59
- files_analyzed: int
60
- uncovered_files: list[dict[str, Any]]
61
- missing_lines: dict[str, list[int]]
62
-
63
-
64
- class RealCoverageAnalyzer:
65
- """Runs real pytest coverage analysis."""
66
-
67
- def __init__(self, project_root: str = "."):
68
- """Initialize coverage analyzer.
69
-
70
- Args:
71
- project_root: Project root directory
72
- """
73
- self.project_root = Path(project_root).resolve()
74
-
75
- def analyze(self, use_existing: bool = True) -> CoverageReport:
76
- """Run coverage analysis on all project packages.
77
-
78
- Analyzes coverage for: empathy_os, empathy_llm_toolkit,
79
- empathy_software_plugin, empathy_healthcare_plugin
80
-
81
- Args:
82
- use_existing: Use existing coverage.json if available (default: True)
83
-
84
- Returns:
85
- CoverageReport with results
86
-
87
- Raises:
88
- RuntimeError: If coverage analysis fails
89
- """
90
- logger.info("Running coverage analysis on all packages")
91
-
92
- coverage_file = self.project_root / "coverage.json"
93
-
94
- # Check if we can use existing coverage data
95
- if use_existing and coverage_file.exists():
96
- import time
97
-
98
- file_age = time.time() - coverage_file.stat().st_mtime
99
- # Use existing file if less than 1 hour old
100
- if file_age < 3600:
101
- logger.info(f"Using existing coverage data (age: {file_age / 60:.1f} minutes)")
102
- else:
103
- logger.info("Existing coverage data is stale, regenerating")
104
- use_existing = False
105
-
106
- if not use_existing or not coverage_file.exists():
107
- try:
108
- # Run pytest with coverage on test suite
109
- logger.info("Running test suite to generate coverage (may take 2-5 minutes)")
110
-
111
- # Use actual package names (match pyproject.toml configuration)
112
- cov_packages = [
113
- "empathy_os",
114
- "empathy_llm_toolkit",
115
- "empathy_software_plugin",
116
- "empathy_healthcare_plugin",
117
- ]
118
-
119
- cmd = [
120
- "pytest",
121
- "tests/", # Run all tests to measure coverage
122
- "--cov-report=json",
123
- "--cov-report=term-missing",
124
- "-q",
125
- "--tb=no",
126
- "--maxfail=50", # Continue despite failures
127
- ]
128
-
129
- # Add --cov for each package
130
- for pkg in cov_packages:
131
- cmd.append(f"--cov={pkg}")
132
-
133
- _result = subprocess.run( # Result not needed, only coverage.json
134
- cmd,
135
- cwd=self.project_root,
136
- capture_output=True,
137
- text=True,
138
- timeout=600, # Increased to 10 minutes
139
- )
140
-
141
- except subprocess.TimeoutExpired:
142
- logger.warning("Coverage generation timed out, checking for partial results")
143
- # Fall through to use whatever coverage.json exists
144
-
145
- # Read coverage.json
146
- if not coverage_file.exists():
147
- raise RuntimeError(
148
- "Coverage report not found. Run 'pytest --cov=src --cov-report=json' first."
149
- )
150
-
151
- try:
152
- with coverage_file.open() as f:
153
- coverage_data = json.load(f)
154
-
155
- # Parse results
156
- total_coverage = coverage_data["totals"]["percent_covered"]
157
- files = coverage_data.get("files", {})
158
-
159
- # Identify low coverage files
160
- uncovered_files = []
161
- missing_lines = {}
162
-
163
- for filepath, file_data in files.items():
164
- file_coverage = file_data["summary"]["percent_covered"]
165
- if file_coverage < 80: # Below target
166
- uncovered_files.append(
167
- {
168
- "path": filepath,
169
- "coverage": file_coverage,
170
- "missing_lines": file_data["missing_lines"],
171
- }
172
- )
173
- missing_lines[filepath] = file_data["missing_lines"]
174
-
175
- logger.info(
176
- f"Coverage analysis complete: {total_coverage:.1f}% "
177
- f"({len(uncovered_files)} files below 80%)"
178
- )
179
-
180
- return CoverageReport(
181
- total_coverage=total_coverage,
182
- files_analyzed=len(files),
183
- uncovered_files=uncovered_files,
184
- missing_lines=missing_lines,
185
- )
186
-
187
- except Exception as e:
188
- logger.error(f"Coverage analysis failed: {e}")
189
- raise RuntimeError(f"Coverage analysis failed: {e}") from e
190
-
191
-
192
- class RealTestGenerator:
193
- """Generates actual test code using LLM."""
194
-
195
- def __init__(
196
- self,
197
- project_root: str = ".",
198
- output_dir: str = "tests/generated",
199
- api_key: str | None = None,
200
- use_llm: bool = True,
201
- ):
202
- """Initialize test generator.
203
-
204
- Args:
205
- project_root: Project root directory
206
- output_dir: Directory for generated tests (relative to project_root)
207
- api_key: Anthropic API key (or uses env var)
208
- use_llm: Whether to use LLM for intelligent test generation
209
- """
210
- self.project_root = Path(project_root).resolve()
211
- self.output_dir = self.project_root / output_dir
212
- self.output_dir.mkdir(parents=True, exist_ok=True)
213
- self.api_key = api_key
214
- self.use_llm = use_llm
215
-
216
- # Initialize LLM client if needed
217
- self._llm = None
218
- if use_llm:
219
- self._initialize_llm()
220
-
221
- def _initialize_llm(self):
222
- """Initialize Anthropic LLM client."""
223
- try:
224
- import os
225
-
226
- from anthropic import Anthropic
227
-
228
- # Try to load .env file
229
- try:
230
- from dotenv import load_dotenv
231
-
232
- load_dotenv()
233
- except ImportError:
234
- pass # python-dotenv not required
235
-
236
- api_key = self.api_key or os.environ.get("ANTHROPIC_API_KEY")
237
- if not api_key:
238
- logger.warning(
239
- "No Anthropic API key found. Set ANTHROPIC_API_KEY environment variable "
240
- "or create .env file with ANTHROPIC_API_KEY=your_key_here. "
241
- "Falling back to basic templates."
242
- )
243
- self.use_llm = False
244
- return
245
-
246
- self._llm = Anthropic(api_key=api_key)
247
- logger.info("✓ LLM client initialized successfully with Claude")
248
-
249
- except ImportError as e:
250
- logger.warning(f"Required package not installed: {e}. Falling back to templates")
251
- self.use_llm = False
252
- except Exception as e:
253
- logger.warning(f"Failed to initialize LLM: {e}. Falling back to templates")
254
- self.use_llm = False
255
-
256
- def generate_tests_for_file(self, source_file: str, missing_lines: list[int]) -> Path:
257
- """Generate tests for uncovered code in a file.
258
-
259
- Args:
260
- source_file: Path to source file
261
- missing_lines: Line numbers without coverage
262
-
263
- Returns:
264
- Path to generated test file
265
-
266
- Raises:
267
- RuntimeError: If test generation fails
268
- """
269
- logger.info(f"Generating tests for {source_file} (lines: {missing_lines[:5]}...)")
270
-
271
- # Read source file
272
- source_path = Path(source_file)
273
- if not source_path.exists():
274
- source_path = self.project_root / source_file
275
-
276
- # Resolve to absolute path for relative_to() to work correctly
277
- source_path = source_path.resolve()
278
-
279
- try:
280
- source_code = source_path.read_text()
281
- except Exception as e:
282
- raise RuntimeError(f"Cannot read source file: {e}") from e
283
-
284
- # Create unique test name from full path to avoid collisions
285
- # Example: src/empathy_os/telemetry/cli.py → test_src_empathy_os_telemetry_cli_generated.py
286
- relative_path = str(source_path.relative_to(self.project_root))
287
- test_name = f"test_{relative_path.replace('/', '_').replace('.py', '')}_generated.py"
288
- test_path = self.output_dir / test_name
289
-
290
- # Generate tests using LLM or template
291
- if self.use_llm and self._llm:
292
- test_code = self._generate_llm_tests(source_file, source_code, missing_lines)
293
- else:
294
- test_code = self._generate_basic_test_template(source_file, source_code, missing_lines)
295
-
296
- # Write test file
297
- validated_path = _validate_file_path(str(test_path))
298
- validated_path.write_text(test_code)
299
-
300
- logger.info(f"Generated test file: {test_path}")
301
- return test_path
302
-
303
- def _generate_llm_tests(
304
- self, source_file: str, source_code: str, missing_lines: list[int]
305
- ) -> str:
306
- """Generate tests using LLM (Claude).
307
-
308
- Args:
309
- source_file: Source file path
310
- source_code: Source file content
311
- missing_lines: Uncovered line numbers
312
-
313
- Returns:
314
- Generated test code
315
-
316
- Raises:
317
- RuntimeError: If LLM generation fails
318
- """
319
- logger.info(f"Using LLM to generate intelligent tests for {source_file}")
320
-
321
- # Extract API signatures using AST
322
- api_docs = self._extract_api_docs(source_code)
323
-
324
- # Extract module path
325
- module_path = source_file.replace("/", ".").replace(".py", "")
326
-
327
- # Create prompt for Claude with full context
328
- prompt = f"""Generate comprehensive pytest tests for the following Python code.
329
-
330
- **Source File:** `{source_file}`
331
- **Module Path:** `{module_path}`
332
- **Uncovered Lines:** {missing_lines[:20]}
333
-
334
- {api_docs}
335
-
336
- **Full Source Code:**
337
- ```python
338
- {source_code}
339
- ```
340
-
341
- **CRITICAL Requirements - API Accuracy:**
342
- 1. **READ THE SOURCE CODE CAREFULLY** - Extract exact API signatures from:
343
- - Dataclass definitions (@dataclass) - use EXACT parameter names
344
- - Function signatures - match parameter names and types
345
- - Class __init__ methods - use correct constructor arguments
346
-
347
- 2. **DO NOT GUESS** parameter names - if you see:
348
- ```python
349
- @dataclass
350
- class Foo:
351
- bar: str # Parameter name is 'bar', NOT 'bar_name'
352
- ```
353
- Then use: `Foo(bar="value")` NOT `Foo(bar_name="value")`
354
-
355
- 3. **Computed Properties** - Do NOT pass @property values to constructors:
356
- - If source has `@property def total(self): return self.a + self.b`
357
- - Then DO NOT use `Foo(total=10)` - it's computed from `a` and `b`
358
-
359
- **Test Requirements:**
360
- 1. Write complete, runnable pytest tests
361
- 2. Focus on covering uncovered lines: {missing_lines[:10]}
362
- 3. Include:
363
- - Test class with descriptive name
364
- - Test methods for key functions/classes
365
- - Proper imports from the actual module path
366
- - Mock external dependencies (database, API calls, etc.)
367
- - Edge cases (empty inputs, None, zero, negative numbers)
368
- - Error handling tests (invalid input, exceptions)
369
- 4. Follow pytest best practices
370
- 5. Use clear, descriptive test method names
371
- 6. Add docstrings explaining what each test validates
372
-
373
- **Output Format:**
374
- Return ONLY the Python test code, starting with imports. No markdown, no explanations.
375
- """
376
-
377
- try:
378
- # Try Sonnet models only (Capable tier) - do NOT downgrade
379
- models_to_try = [
380
- "claude-sonnet-4-5-20250929", # Sonnet 4.5 (January 2025 - latest)
381
- "claude-3-5-sonnet-20241022", # 3.5 Sonnet Oct 2024
382
- "claude-3-5-sonnet-20240620", # 3.5 Sonnet Jun 2024
383
- ]
384
-
385
- response = None
386
- last_error = None
387
-
388
- for model_name in models_to_try:
389
- try:
390
- response = self._llm.messages.create(
391
- model=model_name,
392
- max_tokens=12000, # Increased to prevent truncation on large files
393
- temperature=0.3, # Lower temperature for consistent code
394
- messages=[{"role": "user", "content": prompt}],
395
- )
396
- logger.info(f"✓ Using Sonnet model: {model_name}")
397
- break
398
- except Exception as e:
399
- last_error = e
400
- logger.debug(f"Model {model_name} not available: {e}")
401
- continue
402
-
403
- if response is None:
404
- error_msg = f"All Sonnet models unavailable. Last error: {last_error}"
405
- logger.error(error_msg)
406
- raise RuntimeError(error_msg)
407
-
408
- test_code = response.content[0].text
409
-
410
- # Clean up markdown if present
411
- if "```python" in test_code:
412
- test_code = test_code.split("```python")[1].split("```")[0].strip()
413
- elif "```" in test_code:
414
- test_code = test_code.split("```")[1].split("```")[0].strip()
415
-
416
- logger.info(f"✓ LLM generated {len(test_code)} chars of test code")
417
- return test_code
418
-
419
- except Exception as e:
420
- logger.error(f"LLM test generation failed: {e}, falling back to template")
421
- return self._generate_basic_test_template(source_file, source_code, missing_lines)
422
-
423
- def _extract_api_docs(self, source_code: str) -> str:
424
- """Extract API signatures from source code using AST.
425
-
426
- Args:
427
- source_code: Python source code
428
-
429
- Returns:
430
- Formatted API documentation for LLM prompt
431
- """
432
- try:
433
- import sys
434
- from pathlib import Path
435
-
436
- # Add scripts to path
437
- scripts_dir = Path(__file__).parent.parent.parent.parent / "scripts"
438
- if str(scripts_dir) not in sys.path:
439
- sys.path.insert(0, str(scripts_dir))
440
-
441
- from ast_api_extractor import extract_api_signatures, format_api_docs
442
-
443
- classes, functions = extract_api_signatures(source_code)
444
- return format_api_docs(classes, functions)
445
- except Exception as e:
446
- logger.warning(f"AST extraction failed: {e}, proceeding without API docs")
447
- return "# API extraction failed - use source code carefully"
448
-
449
- def _generate_basic_test_template(
450
- self, source_file: str, source_code: str, missing_lines: list[int]
451
- ) -> str:
452
- """Generate basic test template.
453
-
454
- Args:
455
- source_file: Source file path
456
- source_code: Source file content
457
- missing_lines: Uncovered line numbers
458
-
459
- Returns:
460
- Test code as string
461
- """
462
- # Extract module name
463
- module_path = source_file.replace("/", ".").replace(".py", "")
464
-
465
- template = f'''"""Auto-generated tests for {source_file}.
466
-
467
- Coverage gaps on lines: {missing_lines[:10]}
468
- """
469
-
470
- import pytest
471
-
472
-
473
- class TestGeneratedCoverage:
474
- """Tests to improve coverage for {source_file}."""
475
-
476
- def test_module_imports(self):
477
- """Test that module can be imported."""
478
- try:
479
- import {module_path}
480
- assert True
481
- except ImportError as e:
482
- pytest.fail(f"Module import failed: {{e}}")
483
-
484
- def test_placeholder_for_lines_{missing_lines[0] if missing_lines else 0}(self):
485
- """Placeholder test for uncovered code.
486
-
487
- TODO: Implement actual test logic for lines {missing_lines[:5]}
488
- """
489
- # This is a placeholder - connect to LLM for real test generation
490
- assert True, "Placeholder test - needs implementation"
491
- '''
492
- return template
493
-
494
-
495
- class RealTestValidator:
496
- """Validates generated tests by running them."""
497
-
498
- def __init__(self, project_root: str = "."):
499
- """Initialize test validator.
500
-
501
- Args:
502
- project_root: Project root directory
503
- """
504
- self.project_root = Path(project_root).resolve()
505
-
506
- def validate_tests(self, test_files: list[Path]) -> dict[str, Any]:
507
- """Run tests and measure coverage improvement.
508
-
509
- Args:
510
- test_files: List of test file paths
511
-
512
- Returns:
513
- Validation results dict
514
-
515
- Raises:
516
- RuntimeError: If validation fails
517
- """
518
- logger.info(f"Validating {len(test_files)} generated test files")
519
-
520
- try:
521
- # Run tests
522
- test_paths = [str(t) for t in test_files]
523
- cmd = ["pytest"] + test_paths + ["-v", "--tb=short"]
524
-
525
- result = subprocess.run(
526
- cmd,
527
- cwd=self.project_root,
528
- capture_output=True,
529
- text=True,
530
- timeout=300,
531
- )
532
-
533
- tests_passed = result.returncode == 0
534
- output_lines = result.stdout.split("\n")
535
-
536
- # Count passed/failed
537
- passed = sum(1 for line in output_lines if " PASSED" in line)
538
- failed = sum(1 for line in output_lines if " FAILED" in line)
539
-
540
- logger.info(
541
- f"Validation complete: {passed} passed, {failed} failed, "
542
- f"tests_passed={tests_passed}"
543
- )
544
-
545
- return {
546
- "all_passed": tests_passed,
547
- "passed_count": passed,
548
- "failed_count": failed,
549
- "output": result.stdout[:1000], # Limit output
550
- }
551
-
552
- except subprocess.TimeoutExpired:
553
- raise RuntimeError("Test validation timed out after 5 minutes")
554
- except Exception as e:
555
- logger.error(f"Test validation failed: {e}")
556
- raise RuntimeError(f"Test validation failed: {e}") from e
557
-
558
-
559
- @dataclass
560
- class SecurityReport:
561
- """Security audit report from bandit."""
562
-
563
- total_issues: int
564
- critical_count: int
565
- high_count: int
566
- medium_count: int
567
- low_count: int
568
- issues_by_file: dict[str, list[dict[str, Any]]]
569
- passed: bool
570
-
571
-
572
- class RealSecurityAuditor:
573
- """Runs real security audit using bandit."""
574
-
575
- def __init__(self, project_root: str = "."):
576
- """Initialize security auditor.
577
-
578
- Args:
579
- project_root: Project root directory
580
- """
581
- self.project_root = Path(project_root).resolve()
582
-
583
- def audit(self, target_path: str = "src") -> SecurityReport:
584
- """Run security audit on codebase.
585
-
586
- Args:
587
- target_path: Path to audit (default: src)
588
-
589
- Returns:
590
- SecurityReport with vulnerability findings
591
-
592
- Raises:
593
- RuntimeError: If security audit fails
594
- """
595
- logger.info(f"Running security audit on {target_path}")
596
-
597
- try:
598
- # Run bandit with JSON output
599
- cmd = [
600
- "bandit",
601
- "-r",
602
- target_path,
603
- "-f",
604
- "json",
605
- "-q", # Quiet mode - suppress progress bar and log messages
606
- "-ll", # Only report medium and above
607
- ]
608
-
609
- result = subprocess.run(
610
- cmd,
611
- cwd=self.project_root,
612
- capture_output=True,
613
- text=True,
614
- timeout=300,
615
- )
616
-
617
- # Parse JSON output
618
- try:
619
- bandit_data = json.loads(result.stdout)
620
- except json.JSONDecodeError as e:
621
- # Bandit might not be installed or JSON output malformed
622
- logger.warning(f"Bandit not available or returned invalid JSON: {e}")
623
- stdout = result.stdout if isinstance(result.stdout, str) else ""
624
- stderr = result.stderr if isinstance(result.stderr, str) else ""
625
- logger.debug(f"Bandit stdout: {stdout[:500]}")
626
- logger.debug(f"Bandit stderr: {stderr[:500]}")
627
- return SecurityReport(
628
- total_issues=0,
629
- critical_count=0,
630
- high_count=0,
631
- medium_count=0,
632
- low_count=0,
633
- issues_by_file={},
634
- passed=True,
635
- )
636
-
637
- # Count issues by severity
638
- results = bandit_data.get("results", [])
639
- critical_count = sum(1 for r in results if r.get("issue_severity") == "CRITICAL")
640
- high_count = sum(1 for r in results if r.get("issue_severity") == "HIGH")
641
- medium_count = sum(1 for r in results if r.get("issue_severity") == "MEDIUM")
642
- low_count = sum(1 for r in results if r.get("issue_severity") == "LOW")
643
-
644
- # Group by file
645
- issues_by_file = {}
646
- for issue in results:
647
- filepath = issue.get("filename", "unknown")
648
- if filepath not in issues_by_file:
649
- issues_by_file[filepath] = []
650
- issues_by_file[filepath].append(
651
- {
652
- "line": issue.get("line_number"),
653
- "severity": issue.get("issue_severity"),
654
- "confidence": issue.get("issue_confidence"),
655
- "message": issue.get("issue_text"),
656
- "test_id": issue.get("test_id"),
657
- }
658
- )
659
-
660
- total_issues = len(results)
661
- passed = critical_count == 0 and high_count == 0
662
-
663
- logger.info(
664
- f"Security audit complete: {total_issues} issues "
665
- f"(critical={critical_count}, high={high_count}, medium={medium_count})"
666
- )
667
-
668
- return SecurityReport(
669
- total_issues=total_issues,
670
- critical_count=critical_count,
671
- high_count=high_count,
672
- medium_count=medium_count,
673
- low_count=low_count,
674
- issues_by_file=issues_by_file,
675
- passed=passed,
676
- )
677
-
678
- except subprocess.TimeoutExpired:
679
- raise RuntimeError("Security audit timed out after 5 minutes")
680
- except Exception as e:
681
- logger.error(f"Security audit failed: {e}")
682
- raise RuntimeError(f"Security audit failed: {e}") from e
683
-
684
-
685
- @dataclass
686
- class QualityReport:
687
- """Code quality report from ruff and mypy."""
688
-
689
- quality_score: float # 0-10
690
- ruff_issues: int
691
- mypy_issues: int
692
- total_files: int
693
- issues_by_category: dict[str, int]
694
- passed: bool
695
-
696
-
697
- class RealCodeQualityAnalyzer:
698
- """Runs real code quality analysis using ruff and mypy."""
699
-
700
- def __init__(self, project_root: str = "."):
701
- """Initialize code quality analyzer.
702
-
703
- Args:
704
- project_root: Project root directory
705
- """
706
- self.project_root = Path(project_root).resolve()
707
-
708
- def analyze(self, target_path: str = "src") -> QualityReport:
709
- """Run code quality analysis.
710
-
711
- Args:
712
- target_path: Path to analyze (default: src)
713
-
714
- Returns:
715
- QualityReport with quality metrics
716
-
717
- Raises:
718
- RuntimeError: If quality analysis fails
719
- """
720
- logger.info(f"Running code quality analysis on {target_path}")
721
-
722
- try:
723
- # Run ruff for linting
724
- ruff_issues = self._run_ruff(target_path)
725
-
726
- # Run mypy for type checking (optional - may not be installed)
727
- mypy_issues = self._run_mypy(target_path)
728
-
729
- # Count files
730
- target = self.project_root / target_path
731
- py_files = list(target.rglob("*.py")) if target.is_dir() else [target]
732
- total_files = len(py_files)
733
-
734
- # Calculate quality score (0-10 scale)
735
- # Start with 10, deduct points for issues
736
- quality_score = 10.0
737
- quality_score -= min(ruff_issues * 0.01, 3.0) # Max -3 points for ruff
738
- quality_score -= min(mypy_issues * 0.02, 2.0) # Max -2 points for mypy
739
- quality_score = max(0.0, quality_score) # Floor at 0
740
-
741
- # Passed if score >= 7.0
742
- passed = quality_score >= 7.0
743
-
744
- logger.info(
745
- f"Quality analysis complete: score={quality_score:.1f}/10 "
746
- f"(ruff={ruff_issues}, mypy={mypy_issues})"
747
- )
748
-
749
- return QualityReport(
750
- quality_score=quality_score,
751
- ruff_issues=ruff_issues,
752
- mypy_issues=mypy_issues,
753
- total_files=total_files,
754
- issues_by_category={"ruff": ruff_issues, "mypy": mypy_issues},
755
- passed=passed,
756
- )
757
-
758
- except Exception as e:
759
- logger.error(f"Quality analysis failed: {e}")
760
- raise RuntimeError(f"Quality analysis failed: {e}") from e
761
-
762
- def _run_ruff(self, target_path: str) -> int:
763
- """Run ruff linter and count issues."""
764
- try:
765
- cmd = ["ruff", "check", target_path, "--output-format=json"]
766
-
767
- result = subprocess.run(
768
- cmd,
769
- cwd=self.project_root,
770
- capture_output=True,
771
- text=True,
772
- timeout=120,
773
- )
774
-
775
- # Parse JSON output
776
- try:
777
- ruff_data = json.loads(result.stdout) if result.stdout else []
778
- return len(ruff_data)
779
- except json.JSONDecodeError:
780
- logger.warning("Ruff returned invalid JSON")
781
- return 0
782
-
783
- except FileNotFoundError:
784
- logger.warning("Ruff not installed, skipping")
785
- return 0
786
- except Exception as e:
787
- logger.warning(f"Ruff check failed: {e}")
788
- return 0
789
-
790
- def _run_mypy(self, target_path: str) -> int:
791
- """Run mypy type checker and count issues."""
792
- try:
793
- cmd = ["mypy", target_path, "--no-error-summary"]
794
-
795
- result = subprocess.run(
796
- cmd,
797
- cwd=self.project_root,
798
- capture_output=True,
799
- text=True,
800
- timeout=120,
801
- )
802
-
803
- # Count error lines
804
- error_count = sum(1 for line in result.stdout.split("\n") if ": error:" in line)
805
- return error_count
806
-
807
- except FileNotFoundError:
808
- logger.warning("Mypy not installed, skipping")
809
- return 0
810
- except Exception as e:
811
- logger.warning(f"Mypy check failed: {e}")
812
- return 0
813
-
814
-
815
- @dataclass
816
- class DocumentationReport:
817
- """Documentation completeness report."""
818
-
819
- completeness_percentage: float
820
- total_functions: int
821
- documented_functions: int
822
- total_classes: int
823
- documented_classes: int
824
- missing_docstrings: list[str]
825
- passed: bool
826
-
827
-
828
- class RealDocumentationAnalyzer:
829
- """Analyzes documentation completeness by scanning docstrings."""
830
-
831
- def __init__(self, project_root: str = "."):
832
- """Initialize documentation analyzer.
833
-
834
- Args:
835
- project_root: Project root directory
836
- """
837
- self.project_root = Path(project_root).resolve()
838
-
839
- def analyze(self, target_path: str = "src") -> DocumentationReport:
840
- """Analyze documentation completeness.
841
-
842
- Args:
843
- target_path: Path to analyze (default: src)
844
-
845
- Returns:
846
- DocumentationReport with completeness metrics
847
-
848
- Raises:
849
- RuntimeError: If analysis fails
850
- """
851
- logger.info(f"Analyzing documentation completeness in {target_path}")
852
-
853
- import ast
854
-
855
- target = self.project_root / target_path
856
- py_files = list(target.rglob("*.py")) if target.is_dir() else [target]
857
-
858
- total_functions = 0
859
- documented_functions = 0
860
- total_classes = 0
861
- documented_classes = 0
862
- missing_docstrings = []
863
-
864
- for py_file in py_files:
865
- if py_file.name.startswith("__") and py_file.name.endswith("__.py"):
866
- continue # Skip __init__.py, __main__.py
867
-
868
- try:
869
- tree = ast.parse(py_file.read_text())
870
-
871
- for node in ast.walk(tree):
872
- if isinstance(node, ast.FunctionDef):
873
- if not node.name.startswith("_"): # Public functions
874
- total_functions += 1
875
- if ast.get_docstring(node):
876
- documented_functions += 1
877
- else:
878
- missing_docstrings.append(
879
- f"{py_file.relative_to(self.project_root)}:{node.lineno} - function {node.name}"
880
- )
881
-
882
- elif isinstance(node, ast.ClassDef):
883
- if not node.name.startswith("_"): # Public classes
884
- total_classes += 1
885
- if ast.get_docstring(node):
886
- documented_classes += 1
887
- else:
888
- missing_docstrings.append(
889
- f"{py_file.relative_to(self.project_root)}:{node.lineno} - class {node.name}"
890
- )
891
-
892
- except Exception as e:
893
- logger.warning(f"Failed to parse {py_file}: {e}")
894
- continue
895
-
896
- # Calculate completeness
897
- total_items = total_functions + total_classes
898
- documented_items = documented_functions + documented_classes
899
-
900
- if total_items > 0:
901
- completeness_percentage = (documented_items / total_items) * 100
902
- else:
903
- completeness_percentage = 100.0 # No public APIs, consider complete
904
-
905
- passed = completeness_percentage >= 80.0
906
-
907
- logger.info(
908
- f"Documentation analysis complete: {completeness_percentage:.1f}% "
909
- f"({documented_items}/{total_items} items documented)"
910
- )
911
-
912
- return DocumentationReport(
913
- completeness_percentage=completeness_percentage,
914
- total_functions=total_functions,
915
- documented_functions=documented_functions,
916
- total_classes=total_classes,
917
- documented_classes=documented_classes,
918
- missing_docstrings=missing_docstrings[:10], # Limit to first 10
919
- passed=passed,
920
- )
921
-
922
-
923
- # Tool registry for agents
924
- REAL_TOOLS = {
925
- "coverage_analyzer": RealCoverageAnalyzer,
926
- "test_generator": RealTestGenerator,
927
- "test_validator": RealTestValidator,
928
- "security_auditor": RealSecurityAuditor,
929
- "code_quality_analyzer": RealCodeQualityAnalyzer,
930
- "documentation_analyzer": RealDocumentationAnalyzer,
931
- }