empathy-framework 4.6.6__py3-none-any.whl → 4.7.1__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 (273) hide show
  1. empathy_framework-4.7.1.dist-info/METADATA +690 -0
  2. empathy_framework-4.7.1.dist-info/RECORD +379 -0
  3. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/top_level.txt +1 -2
  4. empathy_healthcare_plugin/monitors/monitoring/__init__.py +9 -9
  5. empathy_llm_toolkit/agent_factory/__init__.py +6 -6
  6. empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +7 -10
  7. empathy_llm_toolkit/agents_md/__init__.py +22 -0
  8. empathy_llm_toolkit/agents_md/loader.py +218 -0
  9. empathy_llm_toolkit/agents_md/parser.py +271 -0
  10. empathy_llm_toolkit/agents_md/registry.py +307 -0
  11. empathy_llm_toolkit/commands/__init__.py +51 -0
  12. empathy_llm_toolkit/commands/context.py +375 -0
  13. empathy_llm_toolkit/commands/loader.py +301 -0
  14. empathy_llm_toolkit/commands/models.py +231 -0
  15. empathy_llm_toolkit/commands/parser.py +371 -0
  16. empathy_llm_toolkit/commands/registry.py +429 -0
  17. empathy_llm_toolkit/config/__init__.py +8 -8
  18. empathy_llm_toolkit/config/unified.py +3 -7
  19. empathy_llm_toolkit/context/__init__.py +22 -0
  20. empathy_llm_toolkit/context/compaction.py +455 -0
  21. empathy_llm_toolkit/context/manager.py +434 -0
  22. empathy_llm_toolkit/hooks/__init__.py +24 -0
  23. empathy_llm_toolkit/hooks/config.py +306 -0
  24. empathy_llm_toolkit/hooks/executor.py +289 -0
  25. empathy_llm_toolkit/hooks/registry.py +302 -0
  26. empathy_llm_toolkit/hooks/scripts/__init__.py +39 -0
  27. empathy_llm_toolkit/hooks/scripts/evaluate_session.py +201 -0
  28. empathy_llm_toolkit/hooks/scripts/first_time_init.py +285 -0
  29. empathy_llm_toolkit/hooks/scripts/pre_compact.py +207 -0
  30. empathy_llm_toolkit/hooks/scripts/session_end.py +183 -0
  31. empathy_llm_toolkit/hooks/scripts/session_start.py +163 -0
  32. empathy_llm_toolkit/hooks/scripts/suggest_compact.py +225 -0
  33. empathy_llm_toolkit/learning/__init__.py +30 -0
  34. empathy_llm_toolkit/learning/evaluator.py +438 -0
  35. empathy_llm_toolkit/learning/extractor.py +514 -0
  36. empathy_llm_toolkit/learning/storage.py +560 -0
  37. empathy_llm_toolkit/providers.py +4 -11
  38. empathy_llm_toolkit/security/__init__.py +17 -17
  39. empathy_llm_toolkit/utils/tokens.py +2 -5
  40. empathy_os/__init__.py +202 -70
  41. empathy_os/cache_monitor.py +5 -3
  42. empathy_os/cli/__init__.py +11 -55
  43. empathy_os/cli/__main__.py +29 -15
  44. empathy_os/cli/commands/inspection.py +21 -12
  45. empathy_os/cli/commands/memory.py +4 -12
  46. empathy_os/cli/commands/profiling.py +198 -0
  47. empathy_os/cli/commands/utilities.py +27 -7
  48. empathy_os/cli.py +28 -57
  49. empathy_os/cli_unified.py +525 -1164
  50. empathy_os/cost_tracker.py +9 -3
  51. empathy_os/dashboard/server.py +200 -2
  52. empathy_os/hot_reload/__init__.py +7 -7
  53. empathy_os/hot_reload/config.py +6 -7
  54. empathy_os/hot_reload/integration.py +35 -35
  55. empathy_os/hot_reload/reloader.py +57 -57
  56. empathy_os/hot_reload/watcher.py +28 -28
  57. empathy_os/hot_reload/websocket.py +2 -2
  58. empathy_os/memory/__init__.py +11 -4
  59. empathy_os/memory/claude_memory.py +1 -1
  60. empathy_os/memory/cross_session.py +8 -12
  61. empathy_os/memory/edges.py +6 -6
  62. empathy_os/memory/file_session.py +770 -0
  63. empathy_os/memory/graph.py +30 -30
  64. empathy_os/memory/nodes.py +6 -6
  65. empathy_os/memory/short_term.py +15 -9
  66. empathy_os/memory/unified.py +606 -140
  67. empathy_os/meta_workflows/agent_creator.py +3 -9
  68. empathy_os/meta_workflows/cli_meta_workflows.py +113 -53
  69. empathy_os/meta_workflows/form_engine.py +6 -18
  70. empathy_os/meta_workflows/intent_detector.py +64 -24
  71. empathy_os/meta_workflows/models.py +3 -1
  72. empathy_os/meta_workflows/pattern_learner.py +13 -31
  73. empathy_os/meta_workflows/plan_generator.py +55 -47
  74. empathy_os/meta_workflows/session_context.py +2 -3
  75. empathy_os/meta_workflows/workflow.py +20 -51
  76. empathy_os/models/cli.py +2 -2
  77. empathy_os/models/tasks.py +1 -2
  78. empathy_os/models/telemetry.py +4 -1
  79. empathy_os/models/token_estimator.py +3 -1
  80. empathy_os/monitoring/alerts.py +938 -9
  81. empathy_os/monitoring/alerts_cli.py +346 -183
  82. empathy_os/orchestration/execution_strategies.py +12 -29
  83. empathy_os/orchestration/pattern_learner.py +20 -26
  84. empathy_os/orchestration/real_tools.py +6 -15
  85. empathy_os/platform_utils.py +2 -1
  86. empathy_os/plugins/__init__.py +2 -2
  87. empathy_os/plugins/base.py +64 -64
  88. empathy_os/plugins/registry.py +32 -32
  89. empathy_os/project_index/index.py +49 -15
  90. empathy_os/project_index/models.py +1 -2
  91. empathy_os/project_index/reports.py +1 -1
  92. empathy_os/project_index/scanner.py +1 -0
  93. empathy_os/redis_memory.py +10 -7
  94. empathy_os/resilience/__init__.py +1 -1
  95. empathy_os/resilience/health.py +10 -10
  96. empathy_os/routing/__init__.py +7 -7
  97. empathy_os/routing/chain_executor.py +37 -37
  98. empathy_os/routing/classifier.py +36 -36
  99. empathy_os/routing/smart_router.py +40 -40
  100. empathy_os/routing/{wizard_registry.py → workflow_registry.py} +47 -47
  101. empathy_os/scaffolding/__init__.py +8 -8
  102. empathy_os/scaffolding/__main__.py +1 -1
  103. empathy_os/scaffolding/cli.py +28 -28
  104. empathy_os/socratic/__init__.py +3 -19
  105. empathy_os/socratic/ab_testing.py +25 -36
  106. empathy_os/socratic/blueprint.py +38 -38
  107. empathy_os/socratic/cli.py +34 -20
  108. empathy_os/socratic/collaboration.py +30 -28
  109. empathy_os/socratic/domain_templates.py +9 -1
  110. empathy_os/socratic/embeddings.py +17 -13
  111. empathy_os/socratic/engine.py +135 -70
  112. empathy_os/socratic/explainer.py +70 -60
  113. empathy_os/socratic/feedback.py +24 -19
  114. empathy_os/socratic/forms.py +15 -10
  115. empathy_os/socratic/generator.py +51 -35
  116. empathy_os/socratic/llm_analyzer.py +25 -23
  117. empathy_os/socratic/mcp_server.py +99 -159
  118. empathy_os/socratic/session.py +19 -13
  119. empathy_os/socratic/storage.py +98 -67
  120. empathy_os/socratic/success.py +38 -27
  121. empathy_os/socratic/visual_editor.py +51 -39
  122. empathy_os/socratic/web_ui.py +99 -66
  123. empathy_os/telemetry/cli.py +3 -1
  124. empathy_os/telemetry/usage_tracker.py +1 -3
  125. empathy_os/test_generator/__init__.py +3 -3
  126. empathy_os/test_generator/cli.py +28 -28
  127. empathy_os/test_generator/generator.py +64 -66
  128. empathy_os/test_generator/risk_analyzer.py +11 -11
  129. empathy_os/vscode_bridge 2.py +173 -0
  130. empathy_os/vscode_bridge.py +173 -0
  131. empathy_os/workflows/__init__.py +212 -120
  132. empathy_os/workflows/batch_processing.py +8 -24
  133. empathy_os/workflows/bug_predict.py +1 -1
  134. empathy_os/workflows/code_review.py +20 -5
  135. empathy_os/workflows/code_review_pipeline.py +13 -8
  136. empathy_os/workflows/keyboard_shortcuts/workflow.py +6 -2
  137. empathy_os/workflows/manage_documentation.py +1 -0
  138. empathy_os/workflows/orchestrated_health_check.py +6 -11
  139. empathy_os/workflows/orchestrated_release_prep.py +3 -3
  140. empathy_os/workflows/pr_review.py +18 -10
  141. empathy_os/workflows/progressive/README 2.md +454 -0
  142. empathy_os/workflows/progressive/__init__ 2.py +92 -0
  143. empathy_os/workflows/progressive/__init__.py +2 -12
  144. empathy_os/workflows/progressive/cli 2.py +242 -0
  145. empathy_os/workflows/progressive/cli.py +14 -37
  146. empathy_os/workflows/progressive/core 2.py +488 -0
  147. empathy_os/workflows/progressive/core.py +12 -12
  148. empathy_os/workflows/progressive/orchestrator 2.py +701 -0
  149. empathy_os/workflows/progressive/orchestrator.py +166 -144
  150. empathy_os/workflows/progressive/reports 2.py +528 -0
  151. empathy_os/workflows/progressive/reports.py +22 -31
  152. empathy_os/workflows/progressive/telemetry 2.py +280 -0
  153. empathy_os/workflows/progressive/telemetry.py +8 -14
  154. empathy_os/workflows/progressive/test_gen 2.py +514 -0
  155. empathy_os/workflows/progressive/test_gen.py +29 -48
  156. empathy_os/workflows/progressive/workflow 2.py +628 -0
  157. empathy_os/workflows/progressive/workflow.py +31 -70
  158. empathy_os/workflows/release_prep.py +21 -6
  159. empathy_os/workflows/release_prep_crew.py +1 -0
  160. empathy_os/workflows/secure_release.py +13 -6
  161. empathy_os/workflows/security_audit.py +8 -3
  162. empathy_os/workflows/test_coverage_boost_crew.py +3 -2
  163. empathy_os/workflows/test_maintenance_crew.py +1 -0
  164. empathy_os/workflows/test_runner.py +16 -12
  165. empathy_software_plugin/SOFTWARE_PLUGIN_README.md +25 -703
  166. empathy_software_plugin/cli.py +0 -122
  167. patterns/README.md +119 -0
  168. patterns/__init__.py +95 -0
  169. patterns/behavior.py +298 -0
  170. patterns/code_review_memory.json +441 -0
  171. patterns/core.py +97 -0
  172. patterns/debugging.json +3763 -0
  173. patterns/empathy.py +268 -0
  174. patterns/health_check_memory.json +505 -0
  175. patterns/input.py +161 -0
  176. patterns/memory_graph.json +8 -0
  177. patterns/refactoring_memory.json +1113 -0
  178. patterns/registry.py +663 -0
  179. patterns/security_memory.json +8 -0
  180. patterns/structural.py +415 -0
  181. patterns/validation.py +194 -0
  182. coach_wizards/__init__.py +0 -45
  183. coach_wizards/accessibility_wizard.py +0 -91
  184. coach_wizards/api_wizard.py +0 -91
  185. coach_wizards/base_wizard.py +0 -209
  186. coach_wizards/cicd_wizard.py +0 -91
  187. coach_wizards/code_reviewer_README.md +0 -60
  188. coach_wizards/code_reviewer_wizard.py +0 -180
  189. coach_wizards/compliance_wizard.py +0 -91
  190. coach_wizards/database_wizard.py +0 -91
  191. coach_wizards/debugging_wizard.py +0 -91
  192. coach_wizards/documentation_wizard.py +0 -91
  193. coach_wizards/generate_wizards.py +0 -347
  194. coach_wizards/localization_wizard.py +0 -173
  195. coach_wizards/migration_wizard.py +0 -91
  196. coach_wizards/monitoring_wizard.py +0 -91
  197. coach_wizards/observability_wizard.py +0 -91
  198. coach_wizards/performance_wizard.py +0 -91
  199. coach_wizards/prompt_engineering_wizard.py +0 -661
  200. coach_wizards/refactoring_wizard.py +0 -91
  201. coach_wizards/scaling_wizard.py +0 -90
  202. coach_wizards/security_wizard.py +0 -92
  203. coach_wizards/testing_wizard.py +0 -91
  204. empathy_framework-4.6.6.dist-info/METADATA +0 -1597
  205. empathy_framework-4.6.6.dist-info/RECORD +0 -410
  206. empathy_llm_toolkit/wizards/__init__.py +0 -43
  207. empathy_llm_toolkit/wizards/base_wizard.py +0 -364
  208. empathy_llm_toolkit/wizards/customer_support_wizard.py +0 -190
  209. empathy_llm_toolkit/wizards/healthcare_wizard.py +0 -378
  210. empathy_llm_toolkit/wizards/patient_assessment_README.md +0 -64
  211. empathy_llm_toolkit/wizards/patient_assessment_wizard.py +0 -193
  212. empathy_llm_toolkit/wizards/technology_wizard.py +0 -209
  213. empathy_os/wizard_factory_cli.py +0 -170
  214. empathy_software_plugin/wizards/__init__.py +0 -42
  215. empathy_software_plugin/wizards/advanced_debugging_wizard.py +0 -395
  216. empathy_software_plugin/wizards/agent_orchestration_wizard.py +0 -511
  217. empathy_software_plugin/wizards/ai_collaboration_wizard.py +0 -503
  218. empathy_software_plugin/wizards/ai_context_wizard.py +0 -441
  219. empathy_software_plugin/wizards/ai_documentation_wizard.py +0 -503
  220. empathy_software_plugin/wizards/base_wizard.py +0 -288
  221. empathy_software_plugin/wizards/book_chapter_wizard.py +0 -519
  222. empathy_software_plugin/wizards/code_review_wizard.py +0 -604
  223. empathy_software_plugin/wizards/debugging/__init__.py +0 -50
  224. empathy_software_plugin/wizards/debugging/bug_risk_analyzer.py +0 -414
  225. empathy_software_plugin/wizards/debugging/config_loaders.py +0 -446
  226. empathy_software_plugin/wizards/debugging/fix_applier.py +0 -469
  227. empathy_software_plugin/wizards/debugging/language_patterns.py +0 -385
  228. empathy_software_plugin/wizards/debugging/linter_parsers.py +0 -470
  229. empathy_software_plugin/wizards/debugging/verification.py +0 -369
  230. empathy_software_plugin/wizards/enhanced_testing_wizard.py +0 -537
  231. empathy_software_plugin/wizards/memory_enhanced_debugging_wizard.py +0 -816
  232. empathy_software_plugin/wizards/multi_model_wizard.py +0 -501
  233. empathy_software_plugin/wizards/pattern_extraction_wizard.py +0 -422
  234. empathy_software_plugin/wizards/pattern_retriever_wizard.py +0 -400
  235. empathy_software_plugin/wizards/performance/__init__.py +0 -9
  236. empathy_software_plugin/wizards/performance/bottleneck_detector.py +0 -221
  237. empathy_software_plugin/wizards/performance/profiler_parsers.py +0 -278
  238. empathy_software_plugin/wizards/performance/trajectory_analyzer.py +0 -429
  239. empathy_software_plugin/wizards/performance_profiling_wizard.py +0 -305
  240. empathy_software_plugin/wizards/prompt_engineering_wizard.py +0 -425
  241. empathy_software_plugin/wizards/rag_pattern_wizard.py +0 -461
  242. empathy_software_plugin/wizards/security/__init__.py +0 -32
  243. empathy_software_plugin/wizards/security/exploit_analyzer.py +0 -290
  244. empathy_software_plugin/wizards/security/owasp_patterns.py +0 -241
  245. empathy_software_plugin/wizards/security/vulnerability_scanner.py +0 -604
  246. empathy_software_plugin/wizards/security_analysis_wizard.py +0 -322
  247. empathy_software_plugin/wizards/security_learning_wizard.py +0 -740
  248. empathy_software_plugin/wizards/tech_debt_wizard.py +0 -726
  249. empathy_software_plugin/wizards/testing/__init__.py +0 -27
  250. empathy_software_plugin/wizards/testing/coverage_analyzer.py +0 -459
  251. empathy_software_plugin/wizards/testing/quality_analyzer.py +0 -525
  252. empathy_software_plugin/wizards/testing/test_suggester.py +0 -533
  253. empathy_software_plugin/wizards/testing_wizard.py +0 -274
  254. wizards/__init__.py +0 -82
  255. wizards/admission_assessment_wizard.py +0 -644
  256. wizards/care_plan.py +0 -321
  257. wizards/clinical_assessment.py +0 -769
  258. wizards/discharge_planning.py +0 -77
  259. wizards/discharge_summary_wizard.py +0 -468
  260. wizards/dosage_calculation.py +0 -497
  261. wizards/incident_report_wizard.py +0 -454
  262. wizards/medication_reconciliation.py +0 -85
  263. wizards/nursing_assessment.py +0 -171
  264. wizards/patient_education.py +0 -654
  265. wizards/quality_improvement.py +0 -705
  266. wizards/sbar_report.py +0 -324
  267. wizards/sbar_wizard.py +0 -608
  268. wizards/shift_handoff_wizard.py +0 -535
  269. wizards/soap_note_wizard.py +0 -679
  270. wizards/treatment_plan.py +0 -15
  271. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/WHEEL +0 -0
  272. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/entry_points.txt +0 -0
  273. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/licenses/LICENSE +0 -0
@@ -570,127 +570,5 @@ Examples:
570
570
  return 0
571
571
 
572
572
 
573
- def scan_command():
574
- """Entry point for empathy-scan command (converted from bin/empathy-scan).
575
- One-click security & performance scanner.
576
- """
577
- logger.info("Empathy Framework security and performance scanner started")
578
-
579
- if len(sys.argv) < 3:
580
- logger.warning("Insufficient arguments provided to scan_command")
581
- print("Usage: empathy-scan [security|performance|all] <file-or-directory>")
582
- print("\nExamples:")
583
- print(" empathy-scan security app.py")
584
- print(" empathy-scan performance ./src")
585
- print(" empathy-scan all ./project")
586
- sys.exit(1)
587
-
588
- scan_type = sys.argv[1].lower()
589
- target = sys.argv[2]
590
-
591
- logger.info(f"Scan initiated: type={scan_type}, target={target}")
592
-
593
- # Import wizards
594
- try:
595
- from coach_wizards import PerformanceWizard, SecurityWizard
596
- except ImportError:
597
- logger.error("Empathy Framework wizards not installed")
598
- print("Error: Empathy Framework wizards not installed.")
599
- print("Run: pip install empathy-framework[all]")
600
- sys.exit(1)
601
-
602
- # Determine if target is file or directory
603
- target_path = Path(target)
604
- if not target_path.exists():
605
- logger.error(f"Target does not exist: {target}")
606
- print(f"Error: {target} does not exist")
607
- sys.exit(1)
608
-
609
- # Collect files to scan
610
- files_to_scan = []
611
- if target_path.is_file():
612
- files_to_scan = [target_path]
613
- else:
614
- # Scan directory for Python files
615
- files_to_scan = list(target_path.rglob("*.py"))
616
-
617
- if not files_to_scan:
618
- logger.warning(f"No Python files found in {target}")
619
- print(f"No Python files found in {target}")
620
- sys.exit(0)
621
-
622
- logger.info(f"Scanning {len(files_to_scan)} file(s)")
623
- print(f"🔍 Scanning {len(files_to_scan)} file(s)...")
624
- print()
625
-
626
- total_issues = 0
627
- total_predictions = 0
628
-
629
- # Run appropriate wizards
630
- wizards = []
631
- if scan_type in ["security", "all"]:
632
- wizards.append(("Security", SecurityWizard()))
633
- if scan_type in ["performance", "all"]:
634
- wizards.append(("Performance", PerformanceWizard()))
635
-
636
- if not wizards:
637
- print(f"Unknown scan type: {scan_type}")
638
- print("Use: security, performance, or all")
639
- sys.exit(1)
640
-
641
- # Scan each file
642
- for file_path in files_to_scan:
643
- try:
644
- with open(file_path, encoding="utf-8") as f:
645
- code = f.read()
646
- except Exception as e:
647
- print(f"⚠️ Could not read {file_path}: {e}")
648
- continue
649
-
650
- print(f"📄 {file_path}")
651
-
652
- for wizard_name, wizard in wizards:
653
- result = wizard.run_full_analysis(
654
- code=code,
655
- file_path=str(file_path),
656
- language="python",
657
- )
658
-
659
- if result.issues:
660
- print(f" {wizard_name}: {len(result.issues)} issue(s) found")
661
- for issue in result.issues[:3]: # Show first 3
662
- severity_icon = (
663
- "🔴"
664
- if issue.severity == "high"
665
- else "🟡" if issue.severity == "medium" else "🔵"
666
- )
667
- print(f" {severity_icon} Line {issue.line_number}: {issue.message}")
668
- if len(result.issues) > 3:
669
- print(f" ... and {len(result.issues) - 3} more")
670
- total_issues += len(result.issues)
671
- else:
672
- print(f" {wizard_name}: ✅ No issues")
673
-
674
- if result.predictions:
675
- print(f" 🔮 {len(result.predictions)} prediction(s) for next 90 days")
676
- total_predictions += len(result.predictions)
677
-
678
- print()
679
-
680
- # Summary
681
- print("=" * 50)
682
- print("📊 SUMMARY")
683
- print(f" Files scanned: {len(files_to_scan)}")
684
- print(f" Current issues: {total_issues}")
685
- print(f" Future predictions: {total_predictions}")
686
-
687
- if total_issues > 0:
688
- print(f"\n⚠️ Found {total_issues} issue(s) that need attention")
689
- sys.exit(1)
690
- else:
691
- print("\n✅ All checks passed!")
692
- sys.exit(0)
693
-
694
-
695
573
  if __name__ == "__main__":
696
574
  sys.exit(main())
patterns/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # Empathy Framework Pattern Catalog
2
+
3
+ A catalog of reusable patterns extracted from the Empathy Framework codebase, organized for cross-domain transfer and Level 5 (Systems Thinking) capability development.
4
+
5
+ ## Purpose
6
+
7
+ This catalog serves three goals:
8
+
9
+ 1. **Document existing patterns** - Capture what we've already built
10
+ 2. **Enable cross-domain transfer** - Apply patterns from reliability to trust, from observability to empathy
11
+ 3. **Accelerate Level 5 thinking** - Train the ability to recognize "this problem is like that solved problem"
12
+
13
+ ## Pattern Categories
14
+
15
+ ### Reliability Patterns
16
+ *Source: `src/empathy_os/resilience/`*
17
+
18
+ | Pattern | Level | Key Insight |
19
+ |---------|-------|-------------|
20
+ | [Circuit Breaker](reliability/circuit-breaker.md) | 4 | Predict failures, fail fast |
21
+ | [Graceful Degradation](reliability/graceful-degradation.md) | 4 | Partial value beats total failure |
22
+ | [Retry with Backoff](reliability/retry-with-backoff.md) | 3 | Transient failures are recoverable |
23
+
24
+ ### Observability Patterns
25
+ *Source: `src/empathy_os/models/telemetry.py`, `src/empathy_os/resilience/health.py`*
26
+
27
+ | Pattern | Level | Key Insight |
28
+ |---------|-------|-------------|
29
+ | [Health Monitoring](observability/health-monitoring.md) | 4 | Degraded predicts unhealthy |
30
+ | [Telemetry Tracking](observability/telemetry-tracking.md) | 3-4 | Failures are learning data |
31
+
32
+ ### Cross-Domain Transfers
33
+ *The Level 5 breakthrough patterns*
34
+
35
+ | Transfer | From → To | Status | Key Insight |
36
+ |----------|-----------|--------|-------------|
37
+ | [Circuit Breaker → Trust](cross-domain/circuit-breaker-to-trust.md) | Reliability → Trust | **IMPLEMENTED** | Protect relationships like systems |
38
+ | [Alerting → Empathy Levels](cross-domain/alerting-to-empathy-levels.md) | Observability → Empathy | Documented | Thresholds trigger level changes |
39
+ | [Degradation → Conversation](cross-domain/graceful-degradation-to-conversation.md) | Reliability → UX | Documented | Degraded response beats failure |
40
+
41
+ ### Implemented Transfers
42
+
43
+ | Transfer | Implementation | Guide |
44
+ |----------|----------------|-------|
45
+ | Circuit Breaker → Trust | [`src/empathy_os/trust/`](../src/empathy_os/trust/) | [Trust Circuit Breaker Guide](../docs/guides/trust-circuit-breaker.md) |
46
+
47
+ ## Capability Level Reference
48
+
49
+ | Level | Name | Pattern Characteristic |
50
+ |-------|------|----------------------|
51
+ | 1 | Reactive | Respond to explicit requests |
52
+ | 2 | Guided | Follow established patterns |
53
+ | 3 | Proactive | Anticipate immediate needs |
54
+ | 4 | Anticipatory | Predict future needs (30-90 days) |
55
+ | 5 | Systems | Transfer patterns across domains |
56
+
57
+ ## How to Use This Catalog
58
+
59
+ ### For Developers
60
+ 1. When facing a new problem, search for similar patterns
61
+ 2. Check cross-domain transfers for non-obvious solutions
62
+ 3. Contribute new patterns following the template
63
+
64
+ ### For AI Systems
65
+ 1. Reference patterns when solving problems
66
+ 2. Propose cross-domain transfers when patterns match
67
+ 3. Track pattern usage for learning
68
+
69
+ ### For Architects
70
+ 1. Ensure new features follow established patterns
71
+ 2. Identify opportunities for pattern consolidation
72
+ 3. Propose new cross-domain transfers
73
+
74
+ ## Pattern Template
75
+
76
+ ```markdown
77
+ # Pattern Name
78
+
79
+ **Source Domain:** Where this pattern originated
80
+ **Location in Codebase:** File paths
81
+ **Level:** Capability level (1-5)
82
+
83
+ ## Overview
84
+ What problem does this solve?
85
+
86
+ ## Implementation
87
+ Code examples from actual codebase
88
+
89
+ ## Key Insight
90
+ The one thing to remember
91
+
92
+ ## Cross-Domain Transfer Potential
93
+ Where else could this apply?
94
+ ```
95
+
96
+ ## Contributing
97
+
98
+ 1. Identify a pattern in the codebase
99
+ 2. Document using the template above
100
+ 3. Look for cross-domain transfer opportunities
101
+ 4. Add to the appropriate category
102
+
103
+ ## Metrics
104
+
105
+ Track pattern catalog health:
106
+ - Patterns documented: 5
107
+ - Cross-domain transfers: 3 (1 implemented)
108
+ - Implementations: 1 (Trust Circuit Breaker)
109
+ - Coverage of codebase: ~40%
110
+ - Last updated: 2025-12-28
111
+
112
+ ## Documentation
113
+
114
+ - [Pattern Catalog Guide](../docs/guides/pattern-catalog.md) - How to use and contribute to the catalog
115
+ - [Trust Circuit Breaker Guide](../docs/guides/trust-circuit-breaker.md) - Detailed guide for the implemented transfer
116
+
117
+ ---
118
+
119
+ *This catalog is a key component of reaching Level 5 (Systems Thinking) capability.*
patterns/__init__.py ADDED
@@ -0,0 +1,95 @@
1
+ """Wizard Factory Pattern Library.
2
+
3
+ This package provides a comprehensive pattern library for creating wizards
4
+ in the Empathy Framework. Patterns are extracted from 78 existing wizards
5
+ and encoded as Pydantic models for type safety and code generation.
6
+
7
+ **Pattern Categories:**
8
+ - Structural: Overall wizard flow and architecture
9
+ - Input: Data collection patterns
10
+ - Validation: Data validation and approval patterns
11
+ - Behavior: Wizard behavior and capabilities
12
+ - Empathy: User experience and empathy patterns
13
+
14
+ **Usage:**
15
+ from patterns import get_pattern_registry, LinearFlowPattern
16
+
17
+ # Get pattern registry
18
+ registry = get_pattern_registry()
19
+
20
+ # Search for patterns
21
+ patterns = registry.search("linear")
22
+
23
+ # Get pattern by ID
24
+ pattern = registry.get("linear_flow")
25
+
26
+ # Generate code from pattern
27
+ code = pattern.generate_code()
28
+
29
+ Copyright 2025 Smart AI Memory, LLC
30
+ Licensed under Fair Source 0.9
31
+ """
32
+
33
+ from .behavior import (
34
+ AIEnhancementPattern,
35
+ FixApplicationPattern,
36
+ PredictionPattern,
37
+ RiskAssessmentPattern,
38
+ RiskLevel,
39
+ )
40
+ from .core import BasePattern, CodeGeneratorMixin, PatternCategory, ValidationMixin
41
+ from .empathy import EducationalBannerPattern, EmpathyLevelPattern, UserGuidancePattern
42
+ from .input import (
43
+ CodeAnalysisPattern,
44
+ ContextBasedPattern,
45
+ FieldDefinition,
46
+ StructuredFieldsPattern,
47
+ )
48
+ from .registry import PatternRegistry, get_pattern_registry, load_patterns
49
+ from .structural import (
50
+ LinearFlowPattern,
51
+ PhaseConfig,
52
+ PhasedProcessingPattern,
53
+ SessionBasedPattern,
54
+ StepConfig,
55
+ )
56
+ from .validation import ApprovalPattern, ConfigValidationPattern, StepValidationPattern
57
+
58
+ __all__ = [
59
+ # Core
60
+ "BasePattern",
61
+ "PatternCategory",
62
+ "CodeGeneratorMixin",
63
+ "ValidationMixin",
64
+ # Structural
65
+ "StepConfig",
66
+ "LinearFlowPattern",
67
+ "PhaseConfig",
68
+ "PhasedProcessingPattern",
69
+ "SessionBasedPattern",
70
+ # Input
71
+ "FieldDefinition",
72
+ "StructuredFieldsPattern",
73
+ "CodeAnalysisPattern",
74
+ "ContextBasedPattern",
75
+ # Validation
76
+ "ConfigValidationPattern",
77
+ "StepValidationPattern",
78
+ "ApprovalPattern",
79
+ # Behavior
80
+ "RiskLevel",
81
+ "RiskAssessmentPattern",
82
+ "AIEnhancementPattern",
83
+ "PredictionPattern",
84
+ "FixApplicationPattern",
85
+ # Empathy
86
+ "EmpathyLevelPattern",
87
+ "EducationalBannerPattern",
88
+ "UserGuidancePattern",
89
+ # Registry
90
+ "PatternRegistry",
91
+ "get_pattern_registry",
92
+ "load_patterns",
93
+ ]
94
+
95
+ __version__ = "1.0.0"
patterns/behavior.py ADDED
@@ -0,0 +1,298 @@
1
+ """Behavior patterns for wizard capabilities.
2
+
3
+ Behavior patterns define what wizards can do beyond basic data collection:
4
+ - Risk Assessment: Level 4 Anticipatory risk analysis
5
+ - AI Enhancement: Improve user input with AI
6
+ - Prediction: Predict future issues (Level 4)
7
+ - Fix Application: Automatically fix detected issues
8
+
9
+ Copyright 2025 Smart AI Memory, LLC
10
+ Licensed under Fair Source 0.9
11
+ """
12
+
13
+ from typing import Literal
14
+
15
+ from pydantic import BaseModel, Field
16
+
17
+ from .core import BasePattern, CodeGeneratorMixin, PatternCategory
18
+
19
+
20
+ class RiskLevel(BaseModel):
21
+ """Definition of a risk level."""
22
+
23
+ name: str = Field(..., description="Risk level name (e.g., 'critical', 'high')")
24
+ threshold: int = Field(..., description="Issue count threshold for this level", ge=0)
25
+ alert_message: str = Field(..., description="Alert message when threshold exceeded")
26
+
27
+
28
+ class RiskAssessmentPattern(BasePattern, CodeGeneratorMixin):
29
+ """Level 4 Anticipatory risk assessment pattern.
30
+
31
+ **Description:**
32
+ Wizards that analyze issues and predict which ones will cause problems.
33
+ This implements Level 4 Anticipatory Empathy by forecasting future failures.
34
+
35
+ **Usage:** 16 wizards (all coach wizards)
36
+ **Reusability:** 0.8
37
+
38
+ **Risk Levels:**
39
+ - CRITICAL: Will cause production failures (>0 critical issues)
40
+ - HIGH: High probability of bugs (>5 high-risk issues)
41
+ - MEDIUM: Moderate concern (>20 medium issues)
42
+ - LOW: Minor issues
43
+
44
+ **Output:**
45
+ {
46
+ "alert_level": "CRITICAL",
47
+ "by_risk_level": {"critical": 5, "high": 12, "medium": 8},
48
+ "predictions": [...],
49
+ "recommendations": [...],
50
+ }
51
+ """
52
+
53
+ category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
54
+ risk_levels: list[RiskLevel] = Field(
55
+ default_factory=lambda: [
56
+ RiskLevel(
57
+ name="critical",
58
+ threshold=1,
59
+ alert_message="Critical issues detected - production failure likely",
60
+ ),
61
+ RiskLevel(
62
+ name="high",
63
+ threshold=5,
64
+ alert_message="High-risk issues accumulating - bugs probable",
65
+ ),
66
+ RiskLevel(
67
+ name="medium",
68
+ threshold=20,
69
+ alert_message="Medium issues detected - quality degrading",
70
+ ),
71
+ ],
72
+ description="Risk level definitions with thresholds",
73
+ )
74
+
75
+ def generate_code(self) -> str:
76
+ """Generate risk assessment code."""
77
+ return '''
78
+ class RiskAnalyzer:
79
+ """Analyze issues for risk levels"""
80
+
81
+ def __init__(self):
82
+ self.risk_levels = ["critical", "high", "medium", "low"]
83
+
84
+ def analyze(self, issues: list) -> dict[str, Any]:
85
+ """Analyze issues and assess risk.
86
+
87
+ Args:
88
+ issues: List of issues to analyze
89
+
90
+ Returns:
91
+ Risk assessment with alert level and breakdown
92
+ """
93
+ # Count by risk level
94
+ by_level = {level: 0 for level in self.risk_levels}
95
+
96
+ for issue in issues:
97
+ severity = issue.get("severity", "low")
98
+ if severity in by_level:
99
+ by_level[severity] += 1
100
+
101
+ # Determine alert level
102
+ alert_level = self._determine_alert_level(by_level)
103
+
104
+ return {
105
+ "alert_level": alert_level,
106
+ "by_risk_level": by_level,
107
+ "total_issues": len(issues),
108
+ }
109
+
110
+ def _determine_alert_level(self, by_level: dict[str, int]) -> str:
111
+ """Determine overall alert level"""
112
+ if by_level["critical"] > 0:
113
+ return "CRITICAL"
114
+ elif by_level["high"] > 5:
115
+ return "HIGH"
116
+ elif by_level["medium"] > 20:
117
+ return "MEDIUM"
118
+ else:
119
+ return "LOW"
120
+ '''
121
+
122
+
123
+ class AIEnhancementPattern(BasePattern, CodeGeneratorMixin):
124
+ """AI text enhancement pattern.
125
+
126
+ **Description:**
127
+ Wizards that use AI to improve user-provided text. Common in healthcare
128
+ wizards where users provide rough notes and AI enhances them with:
129
+ - Professional medical terminology
130
+ - Proper formatting
131
+ - Clarity improvements
132
+ - Grammar/spelling fixes
133
+
134
+ **Usage:** 16 wizards (all healthcare wizards)
135
+ **Reusability:** 0.7
136
+
137
+ **Endpoint:**
138
+ POST /{wizard_id}/enhance
139
+ Body: {"text": "...", "field": "chief_complaint"}
140
+
141
+ **Enhancement Guidelines:**
142
+ - Preserve original meaning
143
+ - Use domain-appropriate terminology
144
+ - Maintain professional tone
145
+ - Follow documentation standards
146
+ """
147
+
148
+ category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
149
+ enhancement_guidelines: list[str] = Field(
150
+ default_factory=lambda: [
151
+ "Use appropriate clinical terminology",
152
+ "Clear and concise language",
153
+ "Maintain professional tone",
154
+ "Preserve all key information",
155
+ "Follow documentation standards",
156
+ ],
157
+ description="Guidelines for AI enhancement",
158
+ )
159
+
160
+ def generate_code(self) -> str:
161
+ """Generate AI enhancement endpoint."""
162
+ guidelines = "\n".join(f"- {g}" for g in self.enhancement_guidelines)
163
+
164
+ return f'''
165
+ @router.post("/{{wizard_id}}/enhance")
166
+ async def enhance_text(wizard_id: str, text_data: dict[str, Any]):
167
+ """Enhance user text with AI
168
+
169
+ Args:
170
+ wizard_id: Wizard session ID
171
+ text_data: {{"text": "...", "field": "field_name"}}
172
+
173
+ Returns:
174
+ Enhanced text
175
+ """
176
+ session = await _get_session(wizard_id)
177
+ if not session:
178
+ raise HTTPException(404, "Wizard session not found")
179
+
180
+ original_text = text_data.get("text", "")
181
+ field_name = text_data.get("field", "text")
182
+
183
+ if not original_text:
184
+ raise HTTPException(422, "No text provided for enhancement")
185
+
186
+ # Get chat service
187
+ chat_service = get_service("chat")
188
+
189
+ # Enhancement prompt
190
+ prompt = f"""
191
+ You are assisting with documentation. Please enhance the following text:
192
+
193
+ Field: {{field_name}}
194
+ Original: {{original_text}}
195
+
196
+ Enhancement guidelines:
197
+ {guidelines}
198
+
199
+ Enhanced text:"""
200
+
201
+ response = await chat_service.chat(
202
+ message=prompt,
203
+ conversation_id=f"enhance_{{wizard_id}}",
204
+ context={{"wizard_id": wizard_id, "field": field_name}},
205
+ )
206
+
207
+ return {{
208
+ "original_text": original_text,
209
+ "enhanced_text": response.get("response", original_text),
210
+ "field": field_name,
211
+ }}
212
+ '''
213
+
214
+
215
+ class PredictionPattern(BasePattern):
216
+ """Level 4 Anticipatory prediction pattern.
217
+
218
+ **Description:**
219
+ Wizards that predict future issues before they occur. This implements
220
+ Level 4 Anticipatory Empathy by forecasting problems.
221
+
222
+ **Usage:** 16 wizards (all coach wizards)
223
+ **Reusability:** 0.8
224
+
225
+ **Prediction Types:**
226
+ - production_failure_risk: Critical issues → runtime errors
227
+ - bug_density_increase: High-risk accumulation → more bugs
228
+ - technical_debt_accumulation: Code quality degradation
229
+ - test_maintenance_burden: Flaky tests → maintenance overhead
230
+
231
+ **Signature:**
232
+ def predict_future_issues(
233
+ self,
234
+ code: str,
235
+ file_path: str,
236
+ project_context: dict,
237
+ timeline_days: int = 90
238
+ ) -> list[WizardPrediction]
239
+ """
240
+
241
+ category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
242
+ timeline_days: int = Field(
243
+ default=90,
244
+ description="Prediction timeline in days",
245
+ ge=1,
246
+ le=365,
247
+ )
248
+ prediction_types: list[str] = Field(
249
+ default_factory=lambda: [
250
+ "production_failure_risk",
251
+ "bug_density_increase",
252
+ "technical_debt_accumulation",
253
+ ],
254
+ description="Types of predictions this wizard makes",
255
+ )
256
+
257
+
258
+ class FixApplicationPattern(BasePattern):
259
+ """Automatic fix application pattern.
260
+
261
+ **Description:**
262
+ Wizards that can automatically fix detected issues. Issues are grouped
263
+ into auto-fixable and manual categories.
264
+
265
+ **Usage:** 8 wizards (AI wizards with code modification)
266
+ **Reusability:** 0.75
267
+
268
+ **Workflow:**
269
+ 1. Detect issues
270
+ 2. Group by fixability (auto vs manual)
271
+ 3. Apply auto-fixes if enabled
272
+ 4. Track success/failure per fix
273
+
274
+ **Auto-Fixable Examples:**
275
+ - Linting issues (ruff --fix)
276
+ - Import sorting (isort)
277
+ - Code formatting (black)
278
+ - Simple refactorings
279
+
280
+ **Manual-Only Examples:**
281
+ - Architecture changes
282
+ - Logic bugs
283
+ - Security vulnerabilities
284
+ """
285
+
286
+ category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
287
+ auto_fix_enabled: bool = Field(
288
+ default=False,
289
+ description="Whether auto-fix is enabled by default",
290
+ )
291
+ dry_run_by_default: bool = Field(
292
+ default=True,
293
+ description="Whether to dry-run fixes before applying",
294
+ )
295
+ supported_fix_types: list[str] = Field(
296
+ default_factory=lambda: ["lint", "format", "import", "refactor"],
297
+ description="Types of fixes this wizard supports",
298
+ )