empathy-framework 4.6.6__py3-none-any.whl → 4.7.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 (247) hide show
  1. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/METADATA +7 -6
  2. empathy_framework-4.7.0.dist-info/RECORD +354 -0
  3. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/top_level.txt +0 -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.py +173 -0
  130. empathy_os/workflows/__init__.py +212 -120
  131. empathy_os/workflows/batch_processing.py +8 -24
  132. empathy_os/workflows/bug_predict.py +1 -1
  133. empathy_os/workflows/code_review.py +20 -5
  134. empathy_os/workflows/code_review_pipeline.py +13 -8
  135. empathy_os/workflows/keyboard_shortcuts/workflow.py +6 -2
  136. empathy_os/workflows/manage_documentation.py +1 -0
  137. empathy_os/workflows/orchestrated_health_check.py +6 -11
  138. empathy_os/workflows/orchestrated_release_prep.py +3 -3
  139. empathy_os/workflows/pr_review.py +18 -10
  140. empathy_os/workflows/progressive/__init__.py +2 -12
  141. empathy_os/workflows/progressive/cli.py +14 -37
  142. empathy_os/workflows/progressive/core.py +12 -12
  143. empathy_os/workflows/progressive/orchestrator.py +166 -144
  144. empathy_os/workflows/progressive/reports.py +22 -31
  145. empathy_os/workflows/progressive/telemetry.py +8 -14
  146. empathy_os/workflows/progressive/test_gen.py +29 -48
  147. empathy_os/workflows/progressive/workflow.py +31 -70
  148. empathy_os/workflows/release_prep.py +21 -6
  149. empathy_os/workflows/release_prep_crew.py +1 -0
  150. empathy_os/workflows/secure_release.py +13 -6
  151. empathy_os/workflows/security_audit.py +8 -3
  152. empathy_os/workflows/test_coverage_boost_crew.py +3 -2
  153. empathy_os/workflows/test_maintenance_crew.py +1 -0
  154. empathy_os/workflows/test_runner.py +16 -12
  155. empathy_software_plugin/SOFTWARE_PLUGIN_README.md +25 -703
  156. empathy_software_plugin/cli.py +0 -122
  157. coach_wizards/__init__.py +0 -45
  158. coach_wizards/accessibility_wizard.py +0 -91
  159. coach_wizards/api_wizard.py +0 -91
  160. coach_wizards/base_wizard.py +0 -209
  161. coach_wizards/cicd_wizard.py +0 -91
  162. coach_wizards/code_reviewer_README.md +0 -60
  163. coach_wizards/code_reviewer_wizard.py +0 -180
  164. coach_wizards/compliance_wizard.py +0 -91
  165. coach_wizards/database_wizard.py +0 -91
  166. coach_wizards/debugging_wizard.py +0 -91
  167. coach_wizards/documentation_wizard.py +0 -91
  168. coach_wizards/generate_wizards.py +0 -347
  169. coach_wizards/localization_wizard.py +0 -173
  170. coach_wizards/migration_wizard.py +0 -91
  171. coach_wizards/monitoring_wizard.py +0 -91
  172. coach_wizards/observability_wizard.py +0 -91
  173. coach_wizards/performance_wizard.py +0 -91
  174. coach_wizards/prompt_engineering_wizard.py +0 -661
  175. coach_wizards/refactoring_wizard.py +0 -91
  176. coach_wizards/scaling_wizard.py +0 -90
  177. coach_wizards/security_wizard.py +0 -92
  178. coach_wizards/testing_wizard.py +0 -91
  179. empathy_framework-4.6.6.dist-info/RECORD +0 -410
  180. empathy_llm_toolkit/wizards/__init__.py +0 -43
  181. empathy_llm_toolkit/wizards/base_wizard.py +0 -364
  182. empathy_llm_toolkit/wizards/customer_support_wizard.py +0 -190
  183. empathy_llm_toolkit/wizards/healthcare_wizard.py +0 -378
  184. empathy_llm_toolkit/wizards/patient_assessment_README.md +0 -64
  185. empathy_llm_toolkit/wizards/patient_assessment_wizard.py +0 -193
  186. empathy_llm_toolkit/wizards/technology_wizard.py +0 -209
  187. empathy_os/wizard_factory_cli.py +0 -170
  188. empathy_software_plugin/wizards/__init__.py +0 -42
  189. empathy_software_plugin/wizards/advanced_debugging_wizard.py +0 -395
  190. empathy_software_plugin/wizards/agent_orchestration_wizard.py +0 -511
  191. empathy_software_plugin/wizards/ai_collaboration_wizard.py +0 -503
  192. empathy_software_plugin/wizards/ai_context_wizard.py +0 -441
  193. empathy_software_plugin/wizards/ai_documentation_wizard.py +0 -503
  194. empathy_software_plugin/wizards/base_wizard.py +0 -288
  195. empathy_software_plugin/wizards/book_chapter_wizard.py +0 -519
  196. empathy_software_plugin/wizards/code_review_wizard.py +0 -604
  197. empathy_software_plugin/wizards/debugging/__init__.py +0 -50
  198. empathy_software_plugin/wizards/debugging/bug_risk_analyzer.py +0 -414
  199. empathy_software_plugin/wizards/debugging/config_loaders.py +0 -446
  200. empathy_software_plugin/wizards/debugging/fix_applier.py +0 -469
  201. empathy_software_plugin/wizards/debugging/language_patterns.py +0 -385
  202. empathy_software_plugin/wizards/debugging/linter_parsers.py +0 -470
  203. empathy_software_plugin/wizards/debugging/verification.py +0 -369
  204. empathy_software_plugin/wizards/enhanced_testing_wizard.py +0 -537
  205. empathy_software_plugin/wizards/memory_enhanced_debugging_wizard.py +0 -816
  206. empathy_software_plugin/wizards/multi_model_wizard.py +0 -501
  207. empathy_software_plugin/wizards/pattern_extraction_wizard.py +0 -422
  208. empathy_software_plugin/wizards/pattern_retriever_wizard.py +0 -400
  209. empathy_software_plugin/wizards/performance/__init__.py +0 -9
  210. empathy_software_plugin/wizards/performance/bottleneck_detector.py +0 -221
  211. empathy_software_plugin/wizards/performance/profiler_parsers.py +0 -278
  212. empathy_software_plugin/wizards/performance/trajectory_analyzer.py +0 -429
  213. empathy_software_plugin/wizards/performance_profiling_wizard.py +0 -305
  214. empathy_software_plugin/wizards/prompt_engineering_wizard.py +0 -425
  215. empathy_software_plugin/wizards/rag_pattern_wizard.py +0 -461
  216. empathy_software_plugin/wizards/security/__init__.py +0 -32
  217. empathy_software_plugin/wizards/security/exploit_analyzer.py +0 -290
  218. empathy_software_plugin/wizards/security/owasp_patterns.py +0 -241
  219. empathy_software_plugin/wizards/security/vulnerability_scanner.py +0 -604
  220. empathy_software_plugin/wizards/security_analysis_wizard.py +0 -322
  221. empathy_software_plugin/wizards/security_learning_wizard.py +0 -740
  222. empathy_software_plugin/wizards/tech_debt_wizard.py +0 -726
  223. empathy_software_plugin/wizards/testing/__init__.py +0 -27
  224. empathy_software_plugin/wizards/testing/coverage_analyzer.py +0 -459
  225. empathy_software_plugin/wizards/testing/quality_analyzer.py +0 -525
  226. empathy_software_plugin/wizards/testing/test_suggester.py +0 -533
  227. empathy_software_plugin/wizards/testing_wizard.py +0 -274
  228. wizards/__init__.py +0 -82
  229. wizards/admission_assessment_wizard.py +0 -644
  230. wizards/care_plan.py +0 -321
  231. wizards/clinical_assessment.py +0 -769
  232. wizards/discharge_planning.py +0 -77
  233. wizards/discharge_summary_wizard.py +0 -468
  234. wizards/dosage_calculation.py +0 -497
  235. wizards/incident_report_wizard.py +0 -454
  236. wizards/medication_reconciliation.py +0 -85
  237. wizards/nursing_assessment.py +0 -171
  238. wizards/patient_education.py +0 -654
  239. wizards/quality_improvement.py +0 -705
  240. wizards/sbar_report.py +0 -324
  241. wizards/sbar_wizard.py +0 -608
  242. wizards/shift_handoff_wizard.py +0 -535
  243. wizards/soap_note_wizard.py +0 -679
  244. wizards/treatment_plan.py +0 -15
  245. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/WHEEL +0 -0
  246. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/entry_points.txt +0 -0
  247. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,503 +0,0 @@
1
- """AI-First Documentation Wizard - Level 4 Anticipatory Empathy
2
-
3
- Alerts developers when documentation patterns will limit AI effectiveness.
4
-
5
- In our experience, documentation written for humans often confuses AI.
6
- This wizard learned to predict when documentation gaps will cause AI
7
- to give poor recommendations, before developers waste time debugging why.
8
-
9
- Copyright 2025 Smart AI Memory, LLC
10
- Licensed under Fair Source 0.9
11
- """
12
-
13
- import os
14
- import sys
15
- from typing import Any
16
-
17
- sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "src"))
18
-
19
- from empathy_os.plugins import BaseWizard
20
-
21
-
22
- class AIDocumentationWizard(BaseWizard):
23
- """Level 4 Anticipatory: Ensures documentation serves AI and humans.
24
-
25
- Key Insight from Experience:
26
- When we started using AI coding assistants heavily, we discovered our
27
- documentation was great for humans but terrible for AI. Comments that
28
- made perfect sense to us confused AI. Missing context that humans inferred
29
- caused AI to make wrong assumptions.
30
-
31
- This wizard helps you write documentation that makes AI a better partner.
32
- """
33
-
34
- def __init__(self):
35
- super().__init__(
36
- name="AI-First Documentation Wizard",
37
- domain="software",
38
- empathy_level=4,
39
- category="ai_development",
40
- )
41
-
42
- def get_required_context(self) -> list[str]:
43
- """Required context for analysis"""
44
- return [
45
- "documentation_files", # READMEs, docs, comments
46
- "code_files", # Source files with docstrings
47
- "project_path", # Project root
48
- ]
49
-
50
- async def analyze(self, context: dict[str, Any]) -> dict[str, Any]:
51
- """Analyze documentation quality for AI collaboration.
52
-
53
- In our experience: Documentation gaps only become obvious when
54
- AI gives wrong answers. This wizard alerts you proactively.
55
- """
56
- self.validate_context(context)
57
-
58
- doc_files = context["documentation_files"]
59
- code_files = context.get("code_files", [])
60
-
61
- # Current issues
62
- issues = await self._analyze_ai_documentation_quality(doc_files, code_files)
63
-
64
- # Level 4: Predict when gaps will cause AI failures
65
- predictions = await self._predict_ai_confusion_points(doc_files, code_files, context)
66
-
67
- recommendations = self._generate_recommendations(issues, predictions)
68
- patterns = self._extract_patterns(issues, predictions)
69
-
70
- return {
71
- "issues": issues,
72
- "predictions": predictions,
73
- "recommendations": recommendations,
74
- "patterns": patterns,
75
- "confidence": 0.85,
76
- "metadata": {
77
- "wizard": self.name,
78
- "empathy_level": self.empathy_level,
79
- "docs_analyzed": len(doc_files),
80
- "code_files_analyzed": len(code_files),
81
- },
82
- }
83
-
84
- async def _analyze_ai_documentation_quality(
85
- self,
86
- doc_files: list[str],
87
- code_files: list[str],
88
- ) -> list[dict[str, Any]]:
89
- """Analyze current documentation from AI perspective.
90
-
91
- Checks what AI needs to give good recommendations.
92
- """
93
- issues: list[dict[str, Any]] = []
94
-
95
- # Check for missing context that AI needs
96
- for doc_file in doc_files:
97
- try:
98
- with open(doc_file) as f:
99
- content = f.read()
100
- except OSError:
101
- continue
102
-
103
- # AI needs explicit architecture context
104
- if "README" in doc_file.upper():
105
- if not self._has_architecture_overview(content):
106
- issues.append(
107
- {
108
- "severity": "warning",
109
- "type": "missing_architecture_context",
110
- "file": doc_file,
111
- "message": (
112
- "README lacks architecture overview. In our experience, "
113
- "AI makes better suggestions when it understands system structure."
114
- ),
115
- "suggestion": (
116
- "Add ## Architecture section explaining: "
117
- "components, data flow, key abstractions"
118
- ),
119
- },
120
- )
121
-
122
- # AI needs explicit technology choices explained
123
- if not self._has_technology_rationale(content):
124
- issues.append(
125
- {
126
- "severity": "info",
127
- "type": "missing_tech_rationale",
128
- "file": doc_file,
129
- "message": (
130
- "Technology choices not explained. AI assumes common patterns "
131
- "when context is missing, which may not match your approach."
132
- ),
133
- "suggestion": (
134
- "Add ## Technology Choices section explaining WHY you chose "
135
- "specific libraries/frameworks (not just WHAT you use)"
136
- ),
137
- },
138
- )
139
-
140
- # Check for ambiguous language (confuses AI)
141
- ambiguous_phrases = self._find_ambiguous_phrases(content)
142
- if ambiguous_phrases:
143
- issues.append(
144
- {
145
- "severity": "info",
146
- "type": "ambiguous_language",
147
- "file": doc_file,
148
- "message": (
149
- f"Found {len(ambiguous_phrases)} ambiguous phrases. "
150
- "AI interprets these literally, unlike humans who infer meaning."
151
- ),
152
- "examples": ambiguous_phrases[:3],
153
- "suggestion": "Be explicit. Replace 'usually', 'normally', 'try to' with precise rules.",
154
- },
155
- )
156
-
157
- # Check code documentation
158
- for code_file in code_files[:10]: # Sample first 10
159
- try:
160
- with open(code_file) as f:
161
- content = f.read()
162
- except OSError:
163
- continue
164
-
165
- # Check for missing type hints (AI relies on these)
166
- if code_file.endswith(".py"):
167
- if not self._has_type_hints(content):
168
- issues.append(
169
- {
170
- "severity": "warning",
171
- "type": "missing_type_hints",
172
- "file": code_file,
173
- "message": (
174
- "Missing type hints. In our experience, AI gives 60-80% better "
175
- "suggestions when types are explicit."
176
- ),
177
- "suggestion": "Add type hints to function signatures and class attributes",
178
- },
179
- )
180
-
181
- # Check for missing docstrings with examples
182
- if not self._has_docstring_examples(content):
183
- issues.append(
184
- {
185
- "severity": "info",
186
- "type": "missing_docstring_examples",
187
- "file": code_file,
188
- "message": (
189
- "Docstrings lack examples. AI learns your patterns from examples. "
190
- "Without them, AI guesses based on generic knowledge."
191
- ),
192
- "suggestion": ("Add Examples section to docstrings showing actual usage"),
193
- },
194
- )
195
-
196
- return issues
197
-
198
- async def _predict_ai_confusion_points(
199
- self,
200
- doc_files: list[str],
201
- code_files: list[str],
202
- full_context: dict[str, Any],
203
- ) -> list[dict[str, Any]]:
204
- """Level 4: Predict where documentation gaps will confuse AI.
205
-
206
- Based on our experience: AI confusion follows predictable patterns.
207
- """
208
- predictions = []
209
-
210
- # Pattern 1: Implicit conventions
211
- if not self._has_explicit_conventions(doc_files):
212
- predictions.append(
213
- {
214
- "type": "implicit_conventions_confusion",
215
- "alert": (
216
- "No explicit coding conventions documented. "
217
- "In our experience, AI assumes common conventions when not specified. "
218
- "Alert: If your project has unique patterns, AI will generate code "
219
- "that doesn't match your style, causing review friction."
220
- ),
221
- "probability": "high",
222
- "impact": "medium",
223
- "prevention_steps": [
224
- "Create CONVENTIONS.md documenting your patterns",
225
- "Include: naming conventions, file organization, error handling",
226
- "Add examples of 'good' vs 'avoid' code",
227
- "Reference conventions in prompts to AI tools",
228
- ],
229
- "reasoning": (
230
- "AI learns from billions of repos. Your specific conventions "
231
- "get lost in that noise unless you make them explicit."
232
- ),
233
- "personal_experience": (
234
- "We use specific patterns in Empathy Framework (e.g., wizard base classes). "
235
- "Before documenting these, AI would suggest generic patterns. "
236
- "After documenting, AI suggestions matched our architecture 90%+ of time."
237
- ),
238
- },
239
- )
240
-
241
- # Pattern 2: Missing 'why' context
242
- total_why_ratio = self._calculate_why_ratio(doc_files)
243
- if total_why_ratio < 0.2: # Less than 20% 'why' content
244
- predictions.append(
245
- {
246
- "type": "missing_why_context",
247
- "alert": (
248
- f"Documentation is {(1 - total_why_ratio) * 100:.0f}% 'what/how', "
249
- f"only {total_why_ratio * 100:.0f}% 'why'. "
250
- "In our experience, AI needs 'why' context to make good design decisions. "
251
- "Alert: Without 'why', AI suggests technically correct but strategically wrong solutions."
252
- ),
253
- "probability": "high",
254
- "impact": "high",
255
- "prevention_steps": [
256
- "Add 'Design Decisions' section to README",
257
- "Document WHY you chose specific approaches",
258
- "Explain WHY you avoided common alternatives",
259
- "Include context: constraints, requirements, tradeoffs",
260
- ],
261
- "reasoning": (
262
- "AI can generate any solution. Without 'why' context, "
263
- "it picks based on generic best practices, not your needs."
264
- ),
265
- "personal_experience": (
266
- "When we documented WHY we chose 5 empathy levels (not 3 or 7), "
267
- "AI started suggesting features that fit the framework. "
268
- "Before, it suggested generic improvements that didn't align."
269
- ),
270
- },
271
- )
272
-
273
- # Pattern 3: No decision log
274
- if not self._has_decision_log(doc_files):
275
- predictions.append(
276
- {
277
- "type": "missing_decision_history",
278
- "alert": (
279
- "No decision log found (ADR, decision.md, etc.). "
280
- "In our experience, AI repeats past mistakes when it doesn't "
281
- "know what was already tried and rejected. "
282
- "Alert: You'll waste time having AI suggest approaches you already ruled out."
283
- ),
284
- "probability": "medium-high",
285
- "impact": "medium",
286
- "prevention_steps": [
287
- "Create docs/decisions/ directory",
288
- "Document: 'We tried X, it failed because Y, we chose Z instead'",
289
- "Use Architecture Decision Records (ADR) format",
290
- "Update when you reject AI suggestions (so it learns)",
291
- ],
292
- "reasoning": (
293
- "AI doesn't know your history. It will confidently suggest "
294
- "the approach you spent 2 weeks discovering doesn't work."
295
- ),
296
- },
297
- )
298
-
299
- # Pattern 4: Documentation-code drift
300
- if len(code_files) > 20: # Substantial codebase
301
- drift_indicators = self._detect_documentation_drift(doc_files, code_files)
302
- if drift_indicators > 3:
303
- predictions.append(
304
- {
305
- "type": "documentation_drift",
306
- "alert": (
307
- f"Detected {drift_indicators} indicators of documentation-code drift. "
308
- "In our experience, stale docs cause AI to generate code for "
309
- "architecture that no longer exists. "
310
- "Alert: Review and update docs before drift compounds."
311
- ),
312
- "probability": "high",
313
- "impact": "high",
314
- "prevention_steps": [
315
- "Add 'Last Updated' dates to all docs",
316
- "Create documentation review checklist for PRs",
317
- "Implement doc tests (code examples in docs that run)",
318
- "Set up automated stale doc detection",
319
- ],
320
- "reasoning": (
321
- "Code evolves faster than docs. Without active maintenance, "
322
- "docs describe the system you HAD, not the one you HAVE."
323
- ),
324
- },
325
- )
326
-
327
- # Pattern 5: No AI-specific guidance
328
- if not self._has_ai_guidance(doc_files):
329
- predictions.append(
330
- {
331
- "type": "missing_ai_collaboration_guide",
332
- "alert": (
333
- "No guidance for AI collaboration found. "
334
- "In our experience, explicitly telling AI how you want to work with it "
335
- "improves quality dramatically. Alert: Add AI collaboration guide "
336
- "before your team develops inconsistent AI usage patterns."
337
- ),
338
- "probability": "medium",
339
- "impact": "medium",
340
- "prevention_steps": [
341
- "Create AI_COLLABORATION.md",
342
- "Document: How to prompt for this codebase",
343
- "Include: Context to provide, patterns to follow, pitfalls to avoid",
344
- "Add examples of good AI interactions for this project",
345
- ],
346
- "reasoning": (
347
- "Different projects need different AI collaboration styles. "
348
- "Explicit guidance creates consistency across team."
349
- ),
350
- "personal_experience": (
351
- "We created AI collaboration guides for Empathy Framework development. "
352
- "Result: AI suggestions became 3x more relevant because we taught it "
353
- "our patterns explicitly."
354
- ),
355
- },
356
- )
357
-
358
- return predictions
359
-
360
- def _generate_recommendations(self, issues: list[dict], predictions: list[dict]) -> list[str]:
361
- """Generate actionable recommendations"""
362
- recommendations = []
363
-
364
- # Quick wins
365
- type_hint_issues = [i for i in issues if i["type"] == "missing_type_hints"]
366
- if type_hint_issues:
367
- recommendations.append(
368
- f"[QUICK WIN] Add type hints to {len(type_hint_issues)} files. "
369
- "In our experience, this immediately improves AI suggestion quality 60-80%.",
370
- )
371
-
372
- # High-impact predictions
373
- for pred in predictions:
374
- if pred.get("impact") in ["high", "medium"]:
375
- recommendations.append(f"\n[ALERT] {pred['alert']}")
376
- if "personal_experience" in pred:
377
- recommendations.append(f"Experience: {pred['personal_experience']}")
378
- recommendations.append("\nRecommended actions:")
379
- for i, step in enumerate(pred["prevention_steps"][:3], 1):
380
- recommendations.append(f" {i}. {step}")
381
-
382
- return recommendations
383
-
384
- def _extract_patterns(
385
- self,
386
- issues: list[dict],
387
- predictions: list[dict],
388
- ) -> list[dict[str, Any]]:
389
- """Extract cross-domain patterns"""
390
- return [
391
- {
392
- "pattern_type": "context_for_ai_collaboration",
393
- "description": (
394
- "Systems that explicitly document context for AI collaboration "
395
- "(conventions, decisions, 'why' rationale) get dramatically better AI assistance"
396
- ),
397
- "domain_agnostic": True,
398
- "applicable_to": [
399
- "Software development",
400
- "Clinical protocols (healthcare)",
401
- "Legal documentation",
402
- "Any domain using AI assistance",
403
- ],
404
- "key_elements": [
405
- "Explicit conventions (not assumed)",
406
- "'Why' context (not just 'what')",
407
- "Decision history (what was tried/rejected)",
408
- "Examples of desired patterns",
409
- "AI collaboration guidance",
410
- ],
411
- },
412
- ]
413
-
414
- # Helper methods
415
-
416
- def _has_architecture_overview(self, content: str) -> bool:
417
- """Check for architecture explanation"""
418
- keywords = ["architecture", "components", "structure", "design"]
419
- return any(kw in content.lower() for kw in keywords)
420
-
421
- def _has_technology_rationale(self, content: str) -> bool:
422
- """Check for technology choice explanations"""
423
- return "why we chose" in content.lower() or "decision" in content.lower()
424
-
425
- def _find_ambiguous_phrases(self, content: str) -> list[str]:
426
- """Find phrases that confuse AI"""
427
- ambiguous = [
428
- "usually",
429
- "normally",
430
- "typically",
431
- "should probably",
432
- "might want to",
433
- "try to",
434
- ]
435
- found = []
436
- for phrase in ambiguous:
437
- if phrase in content.lower():
438
- found.append(phrase)
439
- return found
440
-
441
- def _has_type_hints(self, content: str) -> bool:
442
- """Check if Python code has type hints"""
443
- return "->" in content or ": int" in content or ": str" in content
444
-
445
- def _has_docstring_examples(self, content: str) -> bool:
446
- """Check if docstrings include examples"""
447
- return "Example" in content or ">>>" in content or "<example>" in content
448
-
449
- def _has_explicit_conventions(self, doc_files: list[str]) -> bool:
450
- """Check for documented conventions"""
451
- for filepath in doc_files:
452
- if "convention" in filepath.lower() or "style" in filepath.lower():
453
- return True
454
- try:
455
- with open(filepath) as f:
456
- if "convention" in f.read().lower():
457
- return True
458
- except OSError:
459
- pass
460
- return False
461
-
462
- def _calculate_why_ratio(self, doc_files: list[str]) -> float:
463
- """Calculate ratio of 'why' content to total content"""
464
- total_chars = 0
465
- why_chars = 0
466
-
467
- for filepath in doc_files:
468
- try:
469
- with open(filepath) as f:
470
- content = f.read()
471
- total_chars += len(content)
472
-
473
- # Rough heuristic: count 'why' sections
474
- why_sections = content.lower().count("why")
475
- why_sections += content.lower().count("rationale")
476
- why_sections += content.lower().count("decision")
477
- why_chars += why_sections * 100 # Estimate
478
- except OSError:
479
- pass
480
-
481
- if total_chars == 0:
482
- return 0
483
- return min(1.0, why_chars / total_chars)
484
-
485
- def _has_decision_log(self, doc_files: list[str]) -> bool:
486
- """Check for decision/ADR documentation"""
487
- for filepath in doc_files:
488
- if "decision" in filepath.lower() or "adr" in filepath.lower():
489
- return True
490
- return False
491
-
492
- def _detect_documentation_drift(self, doc_files: list[str], code_files: list[str]) -> int:
493
- """Detect indicators of doc-code drift"""
494
- # Simplified: just return indicator count
495
- # Real implementation would compare doc references to actual code
496
- return len(doc_files) // 3 # Rough heuristic
497
-
498
- def _has_ai_guidance(self, doc_files: list[str]) -> bool:
499
- """Check for AI collaboration guidance"""
500
- for filepath in doc_files:
501
- if "ai" in filepath.lower() and "collab" in filepath.lower():
502
- return True
503
- return False