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.
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/METADATA +7 -6
- empathy_framework-4.7.0.dist-info/RECORD +354 -0
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/top_level.txt +0 -2
- empathy_healthcare_plugin/monitors/monitoring/__init__.py +9 -9
- empathy_llm_toolkit/agent_factory/__init__.py +6 -6
- empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +7 -10
- empathy_llm_toolkit/agents_md/__init__.py +22 -0
- empathy_llm_toolkit/agents_md/loader.py +218 -0
- empathy_llm_toolkit/agents_md/parser.py +271 -0
- empathy_llm_toolkit/agents_md/registry.py +307 -0
- empathy_llm_toolkit/commands/__init__.py +51 -0
- empathy_llm_toolkit/commands/context.py +375 -0
- empathy_llm_toolkit/commands/loader.py +301 -0
- empathy_llm_toolkit/commands/models.py +231 -0
- empathy_llm_toolkit/commands/parser.py +371 -0
- empathy_llm_toolkit/commands/registry.py +429 -0
- empathy_llm_toolkit/config/__init__.py +8 -8
- empathy_llm_toolkit/config/unified.py +3 -7
- empathy_llm_toolkit/context/__init__.py +22 -0
- empathy_llm_toolkit/context/compaction.py +455 -0
- empathy_llm_toolkit/context/manager.py +434 -0
- empathy_llm_toolkit/hooks/__init__.py +24 -0
- empathy_llm_toolkit/hooks/config.py +306 -0
- empathy_llm_toolkit/hooks/executor.py +289 -0
- empathy_llm_toolkit/hooks/registry.py +302 -0
- empathy_llm_toolkit/hooks/scripts/__init__.py +39 -0
- empathy_llm_toolkit/hooks/scripts/evaluate_session.py +201 -0
- empathy_llm_toolkit/hooks/scripts/first_time_init.py +285 -0
- empathy_llm_toolkit/hooks/scripts/pre_compact.py +207 -0
- empathy_llm_toolkit/hooks/scripts/session_end.py +183 -0
- empathy_llm_toolkit/hooks/scripts/session_start.py +163 -0
- empathy_llm_toolkit/hooks/scripts/suggest_compact.py +225 -0
- empathy_llm_toolkit/learning/__init__.py +30 -0
- empathy_llm_toolkit/learning/evaluator.py +438 -0
- empathy_llm_toolkit/learning/extractor.py +514 -0
- empathy_llm_toolkit/learning/storage.py +560 -0
- empathy_llm_toolkit/providers.py +4 -11
- empathy_llm_toolkit/security/__init__.py +17 -17
- empathy_llm_toolkit/utils/tokens.py +2 -5
- empathy_os/__init__.py +202 -70
- empathy_os/cache_monitor.py +5 -3
- empathy_os/cli/__init__.py +11 -55
- empathy_os/cli/__main__.py +29 -15
- empathy_os/cli/commands/inspection.py +21 -12
- empathy_os/cli/commands/memory.py +4 -12
- empathy_os/cli/commands/profiling.py +198 -0
- empathy_os/cli/commands/utilities.py +27 -7
- empathy_os/cli.py +28 -57
- empathy_os/cli_unified.py +525 -1164
- empathy_os/cost_tracker.py +9 -3
- empathy_os/dashboard/server.py +200 -2
- empathy_os/hot_reload/__init__.py +7 -7
- empathy_os/hot_reload/config.py +6 -7
- empathy_os/hot_reload/integration.py +35 -35
- empathy_os/hot_reload/reloader.py +57 -57
- empathy_os/hot_reload/watcher.py +28 -28
- empathy_os/hot_reload/websocket.py +2 -2
- empathy_os/memory/__init__.py +11 -4
- empathy_os/memory/claude_memory.py +1 -1
- empathy_os/memory/cross_session.py +8 -12
- empathy_os/memory/edges.py +6 -6
- empathy_os/memory/file_session.py +770 -0
- empathy_os/memory/graph.py +30 -30
- empathy_os/memory/nodes.py +6 -6
- empathy_os/memory/short_term.py +15 -9
- empathy_os/memory/unified.py +606 -140
- empathy_os/meta_workflows/agent_creator.py +3 -9
- empathy_os/meta_workflows/cli_meta_workflows.py +113 -53
- empathy_os/meta_workflows/form_engine.py +6 -18
- empathy_os/meta_workflows/intent_detector.py +64 -24
- empathy_os/meta_workflows/models.py +3 -1
- empathy_os/meta_workflows/pattern_learner.py +13 -31
- empathy_os/meta_workflows/plan_generator.py +55 -47
- empathy_os/meta_workflows/session_context.py +2 -3
- empathy_os/meta_workflows/workflow.py +20 -51
- empathy_os/models/cli.py +2 -2
- empathy_os/models/tasks.py +1 -2
- empathy_os/models/telemetry.py +4 -1
- empathy_os/models/token_estimator.py +3 -1
- empathy_os/monitoring/alerts.py +938 -9
- empathy_os/monitoring/alerts_cli.py +346 -183
- empathy_os/orchestration/execution_strategies.py +12 -29
- empathy_os/orchestration/pattern_learner.py +20 -26
- empathy_os/orchestration/real_tools.py +6 -15
- empathy_os/platform_utils.py +2 -1
- empathy_os/plugins/__init__.py +2 -2
- empathy_os/plugins/base.py +64 -64
- empathy_os/plugins/registry.py +32 -32
- empathy_os/project_index/index.py +49 -15
- empathy_os/project_index/models.py +1 -2
- empathy_os/project_index/reports.py +1 -1
- empathy_os/project_index/scanner.py +1 -0
- empathy_os/redis_memory.py +10 -7
- empathy_os/resilience/__init__.py +1 -1
- empathy_os/resilience/health.py +10 -10
- empathy_os/routing/__init__.py +7 -7
- empathy_os/routing/chain_executor.py +37 -37
- empathy_os/routing/classifier.py +36 -36
- empathy_os/routing/smart_router.py +40 -40
- empathy_os/routing/{wizard_registry.py → workflow_registry.py} +47 -47
- empathy_os/scaffolding/__init__.py +8 -8
- empathy_os/scaffolding/__main__.py +1 -1
- empathy_os/scaffolding/cli.py +28 -28
- empathy_os/socratic/__init__.py +3 -19
- empathy_os/socratic/ab_testing.py +25 -36
- empathy_os/socratic/blueprint.py +38 -38
- empathy_os/socratic/cli.py +34 -20
- empathy_os/socratic/collaboration.py +30 -28
- empathy_os/socratic/domain_templates.py +9 -1
- empathy_os/socratic/embeddings.py +17 -13
- empathy_os/socratic/engine.py +135 -70
- empathy_os/socratic/explainer.py +70 -60
- empathy_os/socratic/feedback.py +24 -19
- empathy_os/socratic/forms.py +15 -10
- empathy_os/socratic/generator.py +51 -35
- empathy_os/socratic/llm_analyzer.py +25 -23
- empathy_os/socratic/mcp_server.py +99 -159
- empathy_os/socratic/session.py +19 -13
- empathy_os/socratic/storage.py +98 -67
- empathy_os/socratic/success.py +38 -27
- empathy_os/socratic/visual_editor.py +51 -39
- empathy_os/socratic/web_ui.py +99 -66
- empathy_os/telemetry/cli.py +3 -1
- empathy_os/telemetry/usage_tracker.py +1 -3
- empathy_os/test_generator/__init__.py +3 -3
- empathy_os/test_generator/cli.py +28 -28
- empathy_os/test_generator/generator.py +64 -66
- empathy_os/test_generator/risk_analyzer.py +11 -11
- empathy_os/vscode_bridge.py +173 -0
- empathy_os/workflows/__init__.py +212 -120
- empathy_os/workflows/batch_processing.py +8 -24
- empathy_os/workflows/bug_predict.py +1 -1
- empathy_os/workflows/code_review.py +20 -5
- empathy_os/workflows/code_review_pipeline.py +13 -8
- empathy_os/workflows/keyboard_shortcuts/workflow.py +6 -2
- empathy_os/workflows/manage_documentation.py +1 -0
- empathy_os/workflows/orchestrated_health_check.py +6 -11
- empathy_os/workflows/orchestrated_release_prep.py +3 -3
- empathy_os/workflows/pr_review.py +18 -10
- empathy_os/workflows/progressive/__init__.py +2 -12
- empathy_os/workflows/progressive/cli.py +14 -37
- empathy_os/workflows/progressive/core.py +12 -12
- empathy_os/workflows/progressive/orchestrator.py +166 -144
- empathy_os/workflows/progressive/reports.py +22 -31
- empathy_os/workflows/progressive/telemetry.py +8 -14
- empathy_os/workflows/progressive/test_gen.py +29 -48
- empathy_os/workflows/progressive/workflow.py +31 -70
- empathy_os/workflows/release_prep.py +21 -6
- empathy_os/workflows/release_prep_crew.py +1 -0
- empathy_os/workflows/secure_release.py +13 -6
- empathy_os/workflows/security_audit.py +8 -3
- empathy_os/workflows/test_coverage_boost_crew.py +3 -2
- empathy_os/workflows/test_maintenance_crew.py +1 -0
- empathy_os/workflows/test_runner.py +16 -12
- empathy_software_plugin/SOFTWARE_PLUGIN_README.md +25 -703
- empathy_software_plugin/cli.py +0 -122
- coach_wizards/__init__.py +0 -45
- coach_wizards/accessibility_wizard.py +0 -91
- coach_wizards/api_wizard.py +0 -91
- coach_wizards/base_wizard.py +0 -209
- coach_wizards/cicd_wizard.py +0 -91
- coach_wizards/code_reviewer_README.md +0 -60
- coach_wizards/code_reviewer_wizard.py +0 -180
- coach_wizards/compliance_wizard.py +0 -91
- coach_wizards/database_wizard.py +0 -91
- coach_wizards/debugging_wizard.py +0 -91
- coach_wizards/documentation_wizard.py +0 -91
- coach_wizards/generate_wizards.py +0 -347
- coach_wizards/localization_wizard.py +0 -173
- coach_wizards/migration_wizard.py +0 -91
- coach_wizards/monitoring_wizard.py +0 -91
- coach_wizards/observability_wizard.py +0 -91
- coach_wizards/performance_wizard.py +0 -91
- coach_wizards/prompt_engineering_wizard.py +0 -661
- coach_wizards/refactoring_wizard.py +0 -91
- coach_wizards/scaling_wizard.py +0 -90
- coach_wizards/security_wizard.py +0 -92
- coach_wizards/testing_wizard.py +0 -91
- empathy_framework-4.6.6.dist-info/RECORD +0 -410
- empathy_llm_toolkit/wizards/__init__.py +0 -43
- empathy_llm_toolkit/wizards/base_wizard.py +0 -364
- empathy_llm_toolkit/wizards/customer_support_wizard.py +0 -190
- empathy_llm_toolkit/wizards/healthcare_wizard.py +0 -378
- empathy_llm_toolkit/wizards/patient_assessment_README.md +0 -64
- empathy_llm_toolkit/wizards/patient_assessment_wizard.py +0 -193
- empathy_llm_toolkit/wizards/technology_wizard.py +0 -209
- empathy_os/wizard_factory_cli.py +0 -170
- empathy_software_plugin/wizards/__init__.py +0 -42
- empathy_software_plugin/wizards/advanced_debugging_wizard.py +0 -395
- empathy_software_plugin/wizards/agent_orchestration_wizard.py +0 -511
- empathy_software_plugin/wizards/ai_collaboration_wizard.py +0 -503
- empathy_software_plugin/wizards/ai_context_wizard.py +0 -441
- empathy_software_plugin/wizards/ai_documentation_wizard.py +0 -503
- empathy_software_plugin/wizards/base_wizard.py +0 -288
- empathy_software_plugin/wizards/book_chapter_wizard.py +0 -519
- empathy_software_plugin/wizards/code_review_wizard.py +0 -604
- empathy_software_plugin/wizards/debugging/__init__.py +0 -50
- empathy_software_plugin/wizards/debugging/bug_risk_analyzer.py +0 -414
- empathy_software_plugin/wizards/debugging/config_loaders.py +0 -446
- empathy_software_plugin/wizards/debugging/fix_applier.py +0 -469
- empathy_software_plugin/wizards/debugging/language_patterns.py +0 -385
- empathy_software_plugin/wizards/debugging/linter_parsers.py +0 -470
- empathy_software_plugin/wizards/debugging/verification.py +0 -369
- empathy_software_plugin/wizards/enhanced_testing_wizard.py +0 -537
- empathy_software_plugin/wizards/memory_enhanced_debugging_wizard.py +0 -816
- empathy_software_plugin/wizards/multi_model_wizard.py +0 -501
- empathy_software_plugin/wizards/pattern_extraction_wizard.py +0 -422
- empathy_software_plugin/wizards/pattern_retriever_wizard.py +0 -400
- empathy_software_plugin/wizards/performance/__init__.py +0 -9
- empathy_software_plugin/wizards/performance/bottleneck_detector.py +0 -221
- empathy_software_plugin/wizards/performance/profiler_parsers.py +0 -278
- empathy_software_plugin/wizards/performance/trajectory_analyzer.py +0 -429
- empathy_software_plugin/wizards/performance_profiling_wizard.py +0 -305
- empathy_software_plugin/wizards/prompt_engineering_wizard.py +0 -425
- empathy_software_plugin/wizards/rag_pattern_wizard.py +0 -461
- empathy_software_plugin/wizards/security/__init__.py +0 -32
- empathy_software_plugin/wizards/security/exploit_analyzer.py +0 -290
- empathy_software_plugin/wizards/security/owasp_patterns.py +0 -241
- empathy_software_plugin/wizards/security/vulnerability_scanner.py +0 -604
- empathy_software_plugin/wizards/security_analysis_wizard.py +0 -322
- empathy_software_plugin/wizards/security_learning_wizard.py +0 -740
- empathy_software_plugin/wizards/tech_debt_wizard.py +0 -726
- empathy_software_plugin/wizards/testing/__init__.py +0 -27
- empathy_software_plugin/wizards/testing/coverage_analyzer.py +0 -459
- empathy_software_plugin/wizards/testing/quality_analyzer.py +0 -525
- empathy_software_plugin/wizards/testing/test_suggester.py +0 -533
- empathy_software_plugin/wizards/testing_wizard.py +0 -274
- wizards/__init__.py +0 -82
- wizards/admission_assessment_wizard.py +0 -644
- wizards/care_plan.py +0 -321
- wizards/clinical_assessment.py +0 -769
- wizards/discharge_planning.py +0 -77
- wizards/discharge_summary_wizard.py +0 -468
- wizards/dosage_calculation.py +0 -497
- wizards/incident_report_wizard.py +0 -454
- wizards/medication_reconciliation.py +0 -85
- wizards/nursing_assessment.py +0 -171
- wizards/patient_education.py +0 -654
- wizards/quality_improvement.py +0 -705
- wizards/sbar_report.py +0 -324
- wizards/sbar_wizard.py +0 -608
- wizards/shift_handoff_wizard.py +0 -535
- wizards/soap_note_wizard.py +0 -679
- wizards/treatment_plan.py +0 -15
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/WHEEL +0 -0
- {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.0.dist-info}/entry_points.txt +0 -0
- {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
|