empathy-framework 3.2.3__py3-none-any.whl → 3.8.2__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.
- coach_wizards/__init__.py +11 -12
- coach_wizards/accessibility_wizard.py +12 -12
- coach_wizards/api_wizard.py +12 -12
- coach_wizards/base_wizard.py +26 -20
- coach_wizards/cicd_wizard.py +15 -13
- coach_wizards/code_reviewer_README.md +60 -0
- coach_wizards/code_reviewer_wizard.py +180 -0
- coach_wizards/compliance_wizard.py +12 -12
- coach_wizards/database_wizard.py +12 -12
- coach_wizards/debugging_wizard.py +12 -12
- coach_wizards/documentation_wizard.py +12 -12
- coach_wizards/generate_wizards.py +1 -2
- coach_wizards/localization_wizard.py +101 -19
- coach_wizards/migration_wizard.py +12 -12
- coach_wizards/monitoring_wizard.py +12 -12
- coach_wizards/observability_wizard.py +12 -12
- coach_wizards/performance_wizard.py +12 -12
- coach_wizards/prompt_engineering_wizard.py +22 -25
- coach_wizards/refactoring_wizard.py +12 -12
- coach_wizards/scaling_wizard.py +12 -12
- coach_wizards/security_wizard.py +12 -12
- coach_wizards/testing_wizard.py +12 -12
- {empathy_framework-3.2.3.dist-info → empathy_framework-3.8.2.dist-info}/METADATA +513 -58
- empathy_framework-3.8.2.dist-info/RECORD +333 -0
- empathy_framework-3.8.2.dist-info/entry_points.txt +22 -0
- {empathy_framework-3.2.3.dist-info → empathy_framework-3.8.2.dist-info}/top_level.txt +5 -1
- empathy_healthcare_plugin/__init__.py +1 -2
- empathy_healthcare_plugin/monitors/__init__.py +9 -0
- empathy_healthcare_plugin/monitors/clinical_protocol_monitor.py +315 -0
- empathy_healthcare_plugin/monitors/monitoring/__init__.py +44 -0
- empathy_healthcare_plugin/monitors/monitoring/protocol_checker.py +300 -0
- empathy_healthcare_plugin/monitors/monitoring/protocol_loader.py +214 -0
- empathy_healthcare_plugin/monitors/monitoring/sensor_parsers.py +306 -0
- empathy_healthcare_plugin/monitors/monitoring/trajectory_analyzer.py +389 -0
- empathy_llm_toolkit/__init__.py +7 -7
- empathy_llm_toolkit/agent_factory/__init__.py +53 -0
- empathy_llm_toolkit/agent_factory/adapters/__init__.py +85 -0
- empathy_llm_toolkit/agent_factory/adapters/autogen_adapter.py +312 -0
- empathy_llm_toolkit/agent_factory/adapters/crewai_adapter.py +454 -0
- empathy_llm_toolkit/agent_factory/adapters/haystack_adapter.py +298 -0
- empathy_llm_toolkit/agent_factory/adapters/langchain_adapter.py +362 -0
- empathy_llm_toolkit/agent_factory/adapters/langgraph_adapter.py +333 -0
- empathy_llm_toolkit/agent_factory/adapters/native.py +228 -0
- empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +426 -0
- empathy_llm_toolkit/agent_factory/base.py +305 -0
- empathy_llm_toolkit/agent_factory/crews/__init__.py +67 -0
- empathy_llm_toolkit/agent_factory/crews/code_review.py +1113 -0
- empathy_llm_toolkit/agent_factory/crews/health_check.py +1246 -0
- empathy_llm_toolkit/agent_factory/crews/refactoring.py +1128 -0
- empathy_llm_toolkit/agent_factory/crews/security_audit.py +1018 -0
- empathy_llm_toolkit/agent_factory/decorators.py +286 -0
- empathy_llm_toolkit/agent_factory/factory.py +558 -0
- empathy_llm_toolkit/agent_factory/framework.py +192 -0
- empathy_llm_toolkit/agent_factory/memory_integration.py +324 -0
- empathy_llm_toolkit/agent_factory/resilient.py +320 -0
- empathy_llm_toolkit/claude_memory.py +14 -15
- empathy_llm_toolkit/cli/__init__.py +8 -0
- empathy_llm_toolkit/cli/sync_claude.py +487 -0
- empathy_llm_toolkit/code_health.py +177 -22
- empathy_llm_toolkit/config/__init__.py +29 -0
- empathy_llm_toolkit/config/unified.py +295 -0
- empathy_llm_toolkit/contextual_patterns.py +11 -12
- empathy_llm_toolkit/core.py +51 -49
- empathy_llm_toolkit/git_pattern_extractor.py +16 -12
- empathy_llm_toolkit/levels.py +6 -13
- empathy_llm_toolkit/pattern_confidence.py +14 -18
- empathy_llm_toolkit/pattern_resolver.py +10 -12
- empathy_llm_toolkit/pattern_summary.py +13 -11
- empathy_llm_toolkit/providers.py +194 -28
- empathy_llm_toolkit/routing/__init__.py +32 -0
- empathy_llm_toolkit/routing/model_router.py +362 -0
- empathy_llm_toolkit/security/IMPLEMENTATION_SUMMARY.md +413 -0
- empathy_llm_toolkit/security/PHASE2_COMPLETE.md +384 -0
- empathy_llm_toolkit/security/PHASE2_SECRETS_DETECTOR_COMPLETE.md +271 -0
- empathy_llm_toolkit/security/QUICK_REFERENCE.md +316 -0
- empathy_llm_toolkit/security/README.md +262 -0
- empathy_llm_toolkit/security/__init__.py +62 -0
- empathy_llm_toolkit/security/audit_logger.py +929 -0
- empathy_llm_toolkit/security/audit_logger_example.py +152 -0
- empathy_llm_toolkit/security/pii_scrubber.py +640 -0
- empathy_llm_toolkit/security/secrets_detector.py +678 -0
- empathy_llm_toolkit/security/secrets_detector_example.py +304 -0
- empathy_llm_toolkit/security/secure_memdocs.py +1192 -0
- empathy_llm_toolkit/security/secure_memdocs_example.py +278 -0
- empathy_llm_toolkit/session_status.py +18 -20
- empathy_llm_toolkit/state.py +20 -21
- empathy_llm_toolkit/wizards/__init__.py +38 -0
- empathy_llm_toolkit/wizards/base_wizard.py +364 -0
- empathy_llm_toolkit/wizards/customer_support_wizard.py +190 -0
- empathy_llm_toolkit/wizards/healthcare_wizard.py +362 -0
- empathy_llm_toolkit/wizards/patient_assessment_README.md +64 -0
- empathy_llm_toolkit/wizards/patient_assessment_wizard.py +193 -0
- empathy_llm_toolkit/wizards/technology_wizard.py +194 -0
- empathy_os/__init__.py +76 -77
- empathy_os/adaptive/__init__.py +13 -0
- empathy_os/adaptive/task_complexity.py +127 -0
- empathy_os/{monitoring.py → agent_monitoring.py} +27 -27
- empathy_os/cache/__init__.py +117 -0
- empathy_os/cache/base.py +166 -0
- empathy_os/cache/dependency_manager.py +253 -0
- empathy_os/cache/hash_only.py +248 -0
- empathy_os/cache/hybrid.py +390 -0
- empathy_os/cache/storage.py +282 -0
- empathy_os/cli.py +515 -109
- empathy_os/cli_unified.py +189 -42
- empathy_os/config/__init__.py +63 -0
- empathy_os/config/xml_config.py +239 -0
- empathy_os/config.py +87 -36
- empathy_os/coordination.py +48 -54
- empathy_os/core.py +90 -99
- empathy_os/cost_tracker.py +20 -23
- empathy_os/dashboard/__init__.py +15 -0
- empathy_os/dashboard/server.py +743 -0
- empathy_os/discovery.py +9 -11
- empathy_os/emergence.py +20 -21
- empathy_os/exceptions.py +18 -30
- empathy_os/feedback_loops.py +27 -30
- empathy_os/levels.py +31 -34
- empathy_os/leverage_points.py +27 -28
- empathy_os/logging_config.py +11 -12
- empathy_os/memory/__init__.py +195 -0
- empathy_os/memory/claude_memory.py +466 -0
- empathy_os/memory/config.py +224 -0
- empathy_os/memory/control_panel.py +1298 -0
- empathy_os/memory/edges.py +179 -0
- empathy_os/memory/graph.py +567 -0
- empathy_os/memory/long_term.py +1194 -0
- empathy_os/memory/nodes.py +179 -0
- empathy_os/memory/redis_bootstrap.py +540 -0
- empathy_os/memory/security/__init__.py +31 -0
- empathy_os/memory/security/audit_logger.py +930 -0
- empathy_os/memory/security/pii_scrubber.py +640 -0
- empathy_os/memory/security/secrets_detector.py +678 -0
- empathy_os/memory/short_term.py +2119 -0
- empathy_os/memory/storage/__init__.py +15 -0
- empathy_os/memory/summary_index.py +583 -0
- empathy_os/memory/unified.py +619 -0
- empathy_os/metrics/__init__.py +12 -0
- empathy_os/metrics/prompt_metrics.py +190 -0
- empathy_os/models/__init__.py +136 -0
- empathy_os/models/__main__.py +13 -0
- empathy_os/models/cli.py +655 -0
- empathy_os/models/empathy_executor.py +354 -0
- empathy_os/models/executor.py +252 -0
- empathy_os/models/fallback.py +671 -0
- empathy_os/models/provider_config.py +563 -0
- empathy_os/models/registry.py +382 -0
- empathy_os/models/tasks.py +302 -0
- empathy_os/models/telemetry.py +548 -0
- empathy_os/models/token_estimator.py +378 -0
- empathy_os/models/validation.py +274 -0
- empathy_os/monitoring/__init__.py +52 -0
- empathy_os/monitoring/alerts.py +23 -0
- empathy_os/monitoring/alerts_cli.py +268 -0
- empathy_os/monitoring/multi_backend.py +271 -0
- empathy_os/monitoring/otel_backend.py +363 -0
- empathy_os/optimization/__init__.py +19 -0
- empathy_os/optimization/context_optimizer.py +272 -0
- empathy_os/pattern_library.py +29 -28
- empathy_os/persistence.py +30 -34
- empathy_os/platform_utils.py +261 -0
- empathy_os/plugins/__init__.py +28 -0
- empathy_os/plugins/base.py +361 -0
- empathy_os/plugins/registry.py +268 -0
- empathy_os/project_index/__init__.py +30 -0
- empathy_os/project_index/cli.py +335 -0
- empathy_os/project_index/crew_integration.py +430 -0
- empathy_os/project_index/index.py +425 -0
- empathy_os/project_index/models.py +501 -0
- empathy_os/project_index/reports.py +473 -0
- empathy_os/project_index/scanner.py +538 -0
- empathy_os/prompts/__init__.py +61 -0
- empathy_os/prompts/config.py +77 -0
- empathy_os/prompts/context.py +177 -0
- empathy_os/prompts/parser.py +285 -0
- empathy_os/prompts/registry.py +313 -0
- empathy_os/prompts/templates.py +208 -0
- empathy_os/redis_config.py +144 -58
- empathy_os/redis_memory.py +53 -56
- empathy_os/resilience/__init__.py +56 -0
- empathy_os/resilience/circuit_breaker.py +256 -0
- empathy_os/resilience/fallback.py +179 -0
- empathy_os/resilience/health.py +300 -0
- empathy_os/resilience/retry.py +209 -0
- empathy_os/resilience/timeout.py +135 -0
- empathy_os/routing/__init__.py +43 -0
- empathy_os/routing/chain_executor.py +433 -0
- empathy_os/routing/classifier.py +217 -0
- empathy_os/routing/smart_router.py +234 -0
- empathy_os/routing/wizard_registry.py +307 -0
- empathy_os/templates.py +12 -11
- empathy_os/trust/__init__.py +28 -0
- empathy_os/trust/circuit_breaker.py +579 -0
- empathy_os/trust_building.py +44 -36
- empathy_os/validation/__init__.py +19 -0
- empathy_os/validation/xml_validator.py +281 -0
- empathy_os/wizard_factory_cli.py +170 -0
- empathy_os/{workflows.py → workflow_commands.py} +123 -31
- empathy_os/workflows/__init__.py +360 -0
- empathy_os/workflows/base.py +1660 -0
- empathy_os/workflows/bug_predict.py +962 -0
- empathy_os/workflows/code_review.py +960 -0
- empathy_os/workflows/code_review_adapters.py +310 -0
- empathy_os/workflows/code_review_pipeline.py +720 -0
- empathy_os/workflows/config.py +600 -0
- empathy_os/workflows/dependency_check.py +648 -0
- empathy_os/workflows/document_gen.py +1069 -0
- empathy_os/workflows/documentation_orchestrator.py +1205 -0
- empathy_os/workflows/health_check.py +679 -0
- empathy_os/workflows/keyboard_shortcuts/__init__.py +39 -0
- empathy_os/workflows/keyboard_shortcuts/generators.py +386 -0
- empathy_os/workflows/keyboard_shortcuts/parsers.py +414 -0
- empathy_os/workflows/keyboard_shortcuts/prompts.py +295 -0
- empathy_os/workflows/keyboard_shortcuts/schema.py +193 -0
- empathy_os/workflows/keyboard_shortcuts/workflow.py +505 -0
- empathy_os/workflows/manage_documentation.py +804 -0
- empathy_os/workflows/new_sample_workflow1.py +146 -0
- empathy_os/workflows/new_sample_workflow1_README.md +150 -0
- empathy_os/workflows/perf_audit.py +687 -0
- empathy_os/workflows/pr_review.py +748 -0
- empathy_os/workflows/progress.py +445 -0
- empathy_os/workflows/progress_server.py +322 -0
- empathy_os/workflows/refactor_plan.py +693 -0
- empathy_os/workflows/release_prep.py +808 -0
- empathy_os/workflows/research_synthesis.py +404 -0
- empathy_os/workflows/secure_release.py +585 -0
- empathy_os/workflows/security_adapters.py +297 -0
- empathy_os/workflows/security_audit.py +1046 -0
- empathy_os/workflows/step_config.py +234 -0
- empathy_os/workflows/test5.py +125 -0
- empathy_os/workflows/test5_README.md +158 -0
- empathy_os/workflows/test_gen.py +1855 -0
- empathy_os/workflows/test_lifecycle.py +526 -0
- empathy_os/workflows/test_maintenance.py +626 -0
- empathy_os/workflows/test_maintenance_cli.py +590 -0
- empathy_os/workflows/test_maintenance_crew.py +821 -0
- empathy_os/workflows/xml_enhanced_crew.py +285 -0
- empathy_software_plugin/__init__.py +1 -2
- empathy_software_plugin/cli/__init__.py +120 -0
- empathy_software_plugin/cli/inspect.py +362 -0
- empathy_software_plugin/cli.py +35 -26
- empathy_software_plugin/plugin.py +4 -8
- empathy_software_plugin/wizards/__init__.py +42 -0
- empathy_software_plugin/wizards/advanced_debugging_wizard.py +392 -0
- empathy_software_plugin/wizards/agent_orchestration_wizard.py +511 -0
- empathy_software_plugin/wizards/ai_collaboration_wizard.py +503 -0
- empathy_software_plugin/wizards/ai_context_wizard.py +441 -0
- empathy_software_plugin/wizards/ai_documentation_wizard.py +503 -0
- empathy_software_plugin/wizards/base_wizard.py +288 -0
- empathy_software_plugin/wizards/book_chapter_wizard.py +519 -0
- empathy_software_plugin/wizards/code_review_wizard.py +606 -0
- empathy_software_plugin/wizards/debugging/__init__.py +50 -0
- empathy_software_plugin/wizards/debugging/bug_risk_analyzer.py +414 -0
- empathy_software_plugin/wizards/debugging/config_loaders.py +442 -0
- empathy_software_plugin/wizards/debugging/fix_applier.py +469 -0
- empathy_software_plugin/wizards/debugging/language_patterns.py +383 -0
- empathy_software_plugin/wizards/debugging/linter_parsers.py +470 -0
- empathy_software_plugin/wizards/debugging/verification.py +369 -0
- empathy_software_plugin/wizards/enhanced_testing_wizard.py +537 -0
- empathy_software_plugin/wizards/memory_enhanced_debugging_wizard.py +816 -0
- empathy_software_plugin/wizards/multi_model_wizard.py +501 -0
- empathy_software_plugin/wizards/pattern_extraction_wizard.py +422 -0
- empathy_software_plugin/wizards/pattern_retriever_wizard.py +400 -0
- empathy_software_plugin/wizards/performance/__init__.py +9 -0
- empathy_software_plugin/wizards/performance/bottleneck_detector.py +221 -0
- empathy_software_plugin/wizards/performance/profiler_parsers.py +278 -0
- empathy_software_plugin/wizards/performance/trajectory_analyzer.py +429 -0
- empathy_software_plugin/wizards/performance_profiling_wizard.py +305 -0
- empathy_software_plugin/wizards/prompt_engineering_wizard.py +425 -0
- empathy_software_plugin/wizards/rag_pattern_wizard.py +461 -0
- empathy_software_plugin/wizards/security/__init__.py +32 -0
- empathy_software_plugin/wizards/security/exploit_analyzer.py +290 -0
- empathy_software_plugin/wizards/security/owasp_patterns.py +241 -0
- empathy_software_plugin/wizards/security/vulnerability_scanner.py +604 -0
- empathy_software_plugin/wizards/security_analysis_wizard.py +322 -0
- empathy_software_plugin/wizards/security_learning_wizard.py +740 -0
- empathy_software_plugin/wizards/tech_debt_wizard.py +726 -0
- empathy_software_plugin/wizards/testing/__init__.py +27 -0
- empathy_software_plugin/wizards/testing/coverage_analyzer.py +459 -0
- empathy_software_plugin/wizards/testing/quality_analyzer.py +531 -0
- empathy_software_plugin/wizards/testing/test_suggester.py +533 -0
- empathy_software_plugin/wizards/testing_wizard.py +274 -0
- hot_reload/README.md +473 -0
- hot_reload/__init__.py +62 -0
- hot_reload/config.py +84 -0
- hot_reload/integration.py +228 -0
- hot_reload/reloader.py +298 -0
- hot_reload/watcher.py +179 -0
- hot_reload/websocket.py +176 -0
- scaffolding/README.md +589 -0
- scaffolding/__init__.py +35 -0
- scaffolding/__main__.py +14 -0
- scaffolding/cli.py +240 -0
- test_generator/__init__.py +38 -0
- test_generator/__main__.py +14 -0
- test_generator/cli.py +226 -0
- test_generator/generator.py +325 -0
- test_generator/risk_analyzer.py +216 -0
- workflow_patterns/__init__.py +33 -0
- workflow_patterns/behavior.py +249 -0
- workflow_patterns/core.py +76 -0
- workflow_patterns/output.py +99 -0
- workflow_patterns/registry.py +255 -0
- workflow_patterns/structural.py +288 -0
- workflow_scaffolding/__init__.py +11 -0
- workflow_scaffolding/__main__.py +12 -0
- workflow_scaffolding/cli.py +206 -0
- workflow_scaffolding/generator.py +265 -0
- agents/code_inspection/patterns/inspection/recurring_B112.json +0 -18
- agents/code_inspection/patterns/inspection/recurring_F541.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_FORMAT.json +0 -25
- agents/code_inspection/patterns/inspection/recurring_bug_20250822_def456.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20250915_abc123.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_3c5b9951.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_97c0f72f.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_a0871d53.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_a9b6ec41.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_null_001.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_builtin.json +0 -16
- agents/compliance_anticipation_agent.py +0 -1427
- agents/epic_integration_wizard.py +0 -541
- agents/trust_building_behaviors.py +0 -891
- empathy_framework-3.2.3.dist-info/RECORD +0 -104
- empathy_framework-3.2.3.dist-info/entry_points.txt +0 -7
- empathy_llm_toolkit/htmlcov/status.json +0 -1
- empathy_llm_toolkit/security/htmlcov/status.json +0 -1
- {empathy_framework-3.2.3.dist-info → empathy_framework-3.8.2.dist-info}/WHEEL +0 -0
- {empathy_framework-3.2.3.dist-info → empathy_framework-3.8.2.dist-info}/licenses/LICENSE +0 -0
empathy_llm_toolkit/core.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Empathy LLM - Core Wrapper
|
|
1
|
+
"""Empathy LLM - Core Wrapper
|
|
3
2
|
|
|
4
3
|
Main class that wraps any LLM provider with Empathy Framework levels.
|
|
5
4
|
|
|
@@ -23,7 +22,13 @@ from empathy_os.memory import (
|
|
|
23
22
|
)
|
|
24
23
|
|
|
25
24
|
from .levels import EmpathyLevel
|
|
26
|
-
from .providers import
|
|
25
|
+
from .providers import (
|
|
26
|
+
AnthropicProvider,
|
|
27
|
+
BaseLLMProvider,
|
|
28
|
+
GeminiProvider,
|
|
29
|
+
LocalProvider,
|
|
30
|
+
OpenAIProvider,
|
|
31
|
+
)
|
|
27
32
|
from .routing import ModelRouter
|
|
28
33
|
from .state import CollaborationState, PatternType, UserPattern
|
|
29
34
|
|
|
@@ -31,8 +36,7 @@ logger = logging.getLogger(__name__)
|
|
|
31
36
|
|
|
32
37
|
|
|
33
38
|
class EmpathyLLM:
|
|
34
|
-
"""
|
|
35
|
-
Wraps any LLM provider with Empathy Framework levels.
|
|
39
|
+
"""Wraps any LLM provider with Empathy Framework levels.
|
|
36
40
|
|
|
37
41
|
Automatically progresses from Level 1 (reactive) to Level 4 (anticipatory)
|
|
38
42
|
based on user collaboration state.
|
|
@@ -86,6 +90,7 @@ class EmpathyLLM:
|
|
|
86
90
|
... user_input="Design the architecture",
|
|
87
91
|
... task_type="architectural_decision"
|
|
88
92
|
... )
|
|
93
|
+
|
|
89
94
|
"""
|
|
90
95
|
|
|
91
96
|
def __init__(
|
|
@@ -102,8 +107,7 @@ class EmpathyLLM:
|
|
|
102
107
|
enable_model_routing: bool = False,
|
|
103
108
|
**kwargs,
|
|
104
109
|
):
|
|
105
|
-
"""
|
|
106
|
-
Initialize EmpathyLLM.
|
|
110
|
+
"""Initialize EmpathyLLM.
|
|
107
111
|
|
|
108
112
|
Args:
|
|
109
113
|
provider: "anthropic", "openai", or "local"
|
|
@@ -127,6 +131,7 @@ class EmpathyLLM:
|
|
|
127
131
|
- CAPABLE (Sonnet): code generation, bug fixes, security review
|
|
128
132
|
- PREMIUM (Opus): coordination, synthesis, architectural decisions
|
|
129
133
|
**kwargs: Provider-specific options
|
|
134
|
+
|
|
130
135
|
"""
|
|
131
136
|
self.target_level = target_level
|
|
132
137
|
self.pattern_library = pattern_library or {}
|
|
@@ -158,7 +163,7 @@ class EmpathyLLM:
|
|
|
158
163
|
self._cached_memory = self.claude_memory_loader.load_all_memory(project_root)
|
|
159
164
|
logger.info(
|
|
160
165
|
f"EmpathyLLM initialized with Claude memory: "
|
|
161
|
-
f"{len(self._cached_memory)} chars loaded"
|
|
166
|
+
f"{len(self._cached_memory)} chars loaded",
|
|
162
167
|
)
|
|
163
168
|
|
|
164
169
|
# Initialize Phase 3 security controls (v1.8.0+)
|
|
@@ -174,7 +179,7 @@ class EmpathyLLM:
|
|
|
174
179
|
logger.info(
|
|
175
180
|
f"EmpathyLLM initialized: provider={provider}, target_level={target_level}, "
|
|
176
181
|
f"security={'enabled' if enable_security else 'disabled'}, "
|
|
177
|
-
f"model_routing={'enabled' if enable_model_routing else 'disabled'}"
|
|
182
|
+
f"model_routing={'enabled' if enable_model_routing else 'disabled'}",
|
|
178
183
|
)
|
|
179
184
|
|
|
180
185
|
def _initialize_security(self):
|
|
@@ -208,24 +213,30 @@ class EmpathyLLM:
|
|
|
208
213
|
logger.info(f"Audit Logger initialized: {audit_log_dir}")
|
|
209
214
|
|
|
210
215
|
def _create_provider(
|
|
211
|
-
self,
|
|
216
|
+
self,
|
|
217
|
+
provider: str,
|
|
218
|
+
api_key: str | None,
|
|
219
|
+
model: str | None,
|
|
220
|
+
**kwargs,
|
|
212
221
|
) -> BaseLLMProvider:
|
|
213
222
|
"""Create appropriate provider instance"""
|
|
214
|
-
|
|
215
223
|
if provider == "anthropic":
|
|
216
224
|
return AnthropicProvider(
|
|
217
|
-
api_key=api_key,
|
|
225
|
+
api_key=api_key,
|
|
226
|
+
model=model or "claude-sonnet-4-5-20250929",
|
|
227
|
+
**kwargs,
|
|
218
228
|
)
|
|
219
|
-
|
|
229
|
+
if provider == "openai":
|
|
220
230
|
return OpenAIProvider(api_key=api_key, model=model or "gpt-4-turbo-preview", **kwargs)
|
|
221
|
-
|
|
231
|
+
if provider in ("google", "gemini"):
|
|
232
|
+
return GeminiProvider(api_key=api_key, model=model or "gemini-1.5-pro", **kwargs)
|
|
233
|
+
if provider == "local":
|
|
222
234
|
return LocalProvider(
|
|
223
235
|
endpoint=kwargs.get("endpoint", "http://localhost:11434"),
|
|
224
236
|
model=model or "llama2",
|
|
225
237
|
**kwargs,
|
|
226
238
|
)
|
|
227
|
-
|
|
228
|
-
raise ValueError(f"Unknown provider: {provider}")
|
|
239
|
+
raise ValueError(f"Unknown provider: {provider}")
|
|
229
240
|
|
|
230
241
|
def _get_or_create_state(self, user_id: str) -> CollaborationState:
|
|
231
242
|
"""Get or create collaboration state for user"""
|
|
@@ -234,8 +245,7 @@ class EmpathyLLM:
|
|
|
234
245
|
return self.states[user_id]
|
|
235
246
|
|
|
236
247
|
def _determine_level(self, state: CollaborationState) -> int:
|
|
237
|
-
"""
|
|
238
|
-
Determine which empathy level to use.
|
|
248
|
+
"""Determine which empathy level to use.
|
|
239
249
|
|
|
240
250
|
Progresses automatically based on state, up to target_level.
|
|
241
251
|
"""
|
|
@@ -252,8 +262,7 @@ class EmpathyLLM:
|
|
|
252
262
|
return level
|
|
253
263
|
|
|
254
264
|
def _build_system_prompt(self, level: int) -> str:
|
|
255
|
-
"""
|
|
256
|
-
Build system prompt including Claude memory (if enabled).
|
|
265
|
+
"""Build system prompt including Claude memory (if enabled).
|
|
257
266
|
|
|
258
267
|
Claude memory is prepended to the level-specific prompt,
|
|
259
268
|
so instructions from CLAUDE.md files affect all interactions.
|
|
@@ -263,6 +272,7 @@ class EmpathyLLM:
|
|
|
263
272
|
|
|
264
273
|
Returns:
|
|
265
274
|
Complete system prompt
|
|
275
|
+
|
|
266
276
|
"""
|
|
267
277
|
level_prompt = EmpathyLevel.get_system_prompt(level)
|
|
268
278
|
|
|
@@ -276,12 +286,10 @@ class EmpathyLLM:
|
|
|
276
286
|
|
|
277
287
|
Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
278
288
|
"""
|
|
279
|
-
|
|
280
|
-
return level_prompt
|
|
289
|
+
return level_prompt
|
|
281
290
|
|
|
282
291
|
def reload_memory(self):
|
|
283
|
-
"""
|
|
284
|
-
Reload Claude memory files.
|
|
292
|
+
"""Reload Claude memory files.
|
|
285
293
|
|
|
286
294
|
Useful if CLAUDE.md files have been updated during runtime.
|
|
287
295
|
Call this to pick up changes without restarting.
|
|
@@ -302,8 +310,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
302
310
|
force_level: int | None = None,
|
|
303
311
|
task_type: str | None = None,
|
|
304
312
|
) -> dict[str, Any]:
|
|
305
|
-
"""
|
|
306
|
-
Main interaction method.
|
|
313
|
+
"""Main interaction method.
|
|
307
314
|
|
|
308
315
|
Automatically selects appropriate empathy level and responds.
|
|
309
316
|
|
|
@@ -337,6 +344,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
337
344
|
|
|
338
345
|
Raises:
|
|
339
346
|
SecurityError: If secrets detected and block_on_secrets=True
|
|
347
|
+
|
|
340
348
|
"""
|
|
341
349
|
start_time = time.time()
|
|
342
350
|
state = self._get_or_create_state(user_id)
|
|
@@ -359,7 +367,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
359
367
|
"routed_tier": tier.value,
|
|
360
368
|
}
|
|
361
369
|
logger.info(
|
|
362
|
-
f"Model routing: task={effective_task} -> model={routed_model} (tier={tier.value})"
|
|
370
|
+
f"Model routing: task={effective_task} -> model={routed_model} (tier={tier.value})",
|
|
363
371
|
)
|
|
364
372
|
|
|
365
373
|
# Initialize security tracking
|
|
@@ -375,7 +383,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
375
383
|
security_metadata["pii_scrubbed"] = len(pii_detections) > 0
|
|
376
384
|
if pii_detections:
|
|
377
385
|
logger.info(
|
|
378
|
-
f"PII detected for user {user_id}: {len(pii_detections)} items scrubbed"
|
|
386
|
+
f"PII detected for user {user_id}: {len(pii_detections)} items scrubbed",
|
|
379
387
|
)
|
|
380
388
|
|
|
381
389
|
# Phase 3: Security Pipeline (Step 2 - Secrets Detection)
|
|
@@ -387,7 +395,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
387
395
|
block_on_secrets = self.security_config.get("block_on_secrets", True)
|
|
388
396
|
logger.warning(
|
|
389
397
|
f"Secrets detected for user {user_id}: {len(secrets_detections)} secrets, "
|
|
390
|
-
f"blocking={block_on_secrets}"
|
|
398
|
+
f"blocking={block_on_secrets}",
|
|
391
399
|
)
|
|
392
400
|
|
|
393
401
|
# Log security violation
|
|
@@ -407,7 +415,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
407
415
|
if block_on_secrets:
|
|
408
416
|
raise SecurityError(
|
|
409
417
|
f"Request blocked: {len(secrets_detections)} secret(s) detected in input. "
|
|
410
|
-
f"Please remove sensitive credentials before submitting."
|
|
418
|
+
f"Please remove sensitive credentials before submitting.",
|
|
411
419
|
)
|
|
412
420
|
|
|
413
421
|
# Determine level to use
|
|
@@ -487,8 +495,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
487
495
|
context: dict[str, Any],
|
|
488
496
|
model_override: str | None = None,
|
|
489
497
|
) -> dict[str, Any]:
|
|
490
|
-
"""
|
|
491
|
-
Level 1: Reactive - Simple Q&A
|
|
498
|
+
"""Level 1: Reactive - Simple Q&A
|
|
492
499
|
|
|
493
500
|
No memory, no patterns, just respond to question.
|
|
494
501
|
"""
|
|
@@ -516,8 +523,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
516
523
|
context: dict[str, Any],
|
|
517
524
|
model_override: str | None = None,
|
|
518
525
|
) -> dict[str, Any]:
|
|
519
|
-
"""
|
|
520
|
-
Level 2: Guided - Ask clarifying questions
|
|
526
|
+
"""Level 2: Guided - Ask clarifying questions
|
|
521
527
|
|
|
522
528
|
Uses conversation history for context.
|
|
523
529
|
"""
|
|
@@ -553,8 +559,7 @@ Follow the CLAUDE.md instructions above, then apply the Empathy Framework below.
|
|
|
553
559
|
context: dict[str, Any],
|
|
554
560
|
model_override: str | None = None,
|
|
555
561
|
) -> dict[str, Any]:
|
|
556
|
-
"""
|
|
557
|
-
Level 3: Proactive - Act on detected patterns
|
|
562
|
+
"""Level 3: Proactive - Act on detected patterns
|
|
558
563
|
|
|
559
564
|
Checks for matching patterns and acts proactively.
|
|
560
565
|
"""
|
|
@@ -621,8 +626,7 @@ Was this helpful? If not, I can adjust my pattern detection.
|
|
|
621
626
|
context: dict[str, Any],
|
|
622
627
|
model_override: str | None = None,
|
|
623
628
|
) -> dict[str, Any]:
|
|
624
|
-
"""
|
|
625
|
-
Level 4: Anticipatory - Predict future needs
|
|
629
|
+
"""Level 4: Anticipatory - Predict future needs
|
|
626
630
|
|
|
627
631
|
Analyzes trajectory and alerts to future bottlenecks.
|
|
628
632
|
"""
|
|
@@ -682,8 +686,7 @@ Use anticipatory format:
|
|
|
682
686
|
context: dict[str, Any],
|
|
683
687
|
model_override: str | None = None,
|
|
684
688
|
) -> dict[str, Any]:
|
|
685
|
-
"""
|
|
686
|
-
Level 5: Systems - Cross-domain pattern learning
|
|
689
|
+
"""Level 5: Systems - Cross-domain pattern learning
|
|
687
690
|
|
|
688
691
|
Leverages shared pattern library across domains.
|
|
689
692
|
"""
|
|
@@ -734,8 +737,7 @@ TASK:
|
|
|
734
737
|
state: CollaborationState,
|
|
735
738
|
current_input: str,
|
|
736
739
|
) -> None:
|
|
737
|
-
"""
|
|
738
|
-
Detect user behavior patterns in background.
|
|
740
|
+
"""Detect user behavior patterns in background.
|
|
739
741
|
|
|
740
742
|
Analyzes conversation history to identify:
|
|
741
743
|
- Sequential patterns: User always does X then Y
|
|
@@ -834,7 +836,7 @@ TASK:
|
|
|
834
836
|
state.add_pattern(pattern)
|
|
835
837
|
|
|
836
838
|
logger.debug(
|
|
837
|
-
f"Pattern detection complete. Detected {len(state.detected_patterns)} patterns."
|
|
839
|
+
f"Pattern detection complete. Detected {len(state.detected_patterns)} patterns.",
|
|
838
840
|
)
|
|
839
841
|
|
|
840
842
|
except Exception as e:
|
|
@@ -842,13 +844,13 @@ TASK:
|
|
|
842
844
|
logger.warning(f"Pattern detection error (non-critical): {e}")
|
|
843
845
|
|
|
844
846
|
def update_trust(self, user_id: str, outcome: str, magnitude: float = 1.0):
|
|
845
|
-
"""
|
|
846
|
-
Update trust level based on interaction outcome.
|
|
847
|
+
"""Update trust level based on interaction outcome.
|
|
847
848
|
|
|
848
849
|
Args:
|
|
849
850
|
user_id: User identifier
|
|
850
851
|
outcome: "success" or "failure"
|
|
851
852
|
magnitude: How much to adjust (0.0 to 1.0)
|
|
853
|
+
|
|
852
854
|
"""
|
|
853
855
|
state = self._get_or_create_state(user_id)
|
|
854
856
|
state.update_trust(outcome, magnitude)
|
|
@@ -856,12 +858,12 @@ TASK:
|
|
|
856
858
|
logger.info(f"Trust updated for {user_id}: {outcome} -> {state.trust_level:.2f}")
|
|
857
859
|
|
|
858
860
|
def add_pattern(self, user_id: str, pattern: UserPattern):
|
|
859
|
-
"""
|
|
860
|
-
Manually add a detected pattern.
|
|
861
|
+
"""Manually add a detected pattern.
|
|
861
862
|
|
|
862
863
|
Args:
|
|
863
864
|
user_id: User identifier
|
|
864
865
|
pattern: UserPattern instance
|
|
866
|
+
|
|
865
867
|
"""
|
|
866
868
|
state = self._get_or_create_state(user_id)
|
|
867
869
|
state.add_pattern(pattern)
|
|
@@ -869,14 +871,14 @@ TASK:
|
|
|
869
871
|
logger.info(f"Pattern added for {user_id}: {pattern.pattern_type.value}")
|
|
870
872
|
|
|
871
873
|
def get_statistics(self, user_id: str) -> dict[str, Any]:
|
|
872
|
-
"""
|
|
873
|
-
Get collaboration statistics for user.
|
|
874
|
+
"""Get collaboration statistics for user.
|
|
874
875
|
|
|
875
876
|
Args:
|
|
876
877
|
user_id: User identifier
|
|
877
878
|
|
|
878
879
|
Returns:
|
|
879
880
|
Dictionary with stats
|
|
881
|
+
|
|
880
882
|
"""
|
|
881
883
|
state = self._get_or_create_state(user_id)
|
|
882
884
|
return state.get_statistics()
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Git Pattern Extractor
|
|
1
|
+
"""Git Pattern Extractor
|
|
3
2
|
|
|
4
3
|
Automatically detects bug fixes from git commits and creates
|
|
5
4
|
draft pattern entries for review.
|
|
@@ -32,8 +31,7 @@ logger = logging.getLogger(__name__)
|
|
|
32
31
|
|
|
33
32
|
|
|
34
33
|
class GitPatternExtractor:
|
|
35
|
-
"""
|
|
36
|
-
Extracts bug fix patterns from git commits.
|
|
34
|
+
"""Extracts bug fix patterns from git commits.
|
|
37
35
|
|
|
38
36
|
Analyzes commit messages and diffs to detect common
|
|
39
37
|
fix patterns, then creates draft pattern files.
|
|
@@ -104,14 +102,14 @@ class GitPatternExtractor:
|
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
def extract_from_recent_commits(self, num_commits: int = 1) -> list[dict[str, Any]]:
|
|
107
|
-
"""
|
|
108
|
-
Extract patterns from recent git commits.
|
|
105
|
+
"""Extract patterns from recent git commits.
|
|
109
106
|
|
|
110
107
|
Args:
|
|
111
108
|
num_commits: Number of recent commits to analyze
|
|
112
109
|
|
|
113
110
|
Returns:
|
|
114
111
|
List of detected pattern dicts
|
|
112
|
+
|
|
115
113
|
"""
|
|
116
114
|
patterns = []
|
|
117
115
|
|
|
@@ -138,11 +136,11 @@ class GitPatternExtractor:
|
|
|
138
136
|
return patterns
|
|
139
137
|
|
|
140
138
|
def extract_from_staged(self) -> list[dict[str, Any]]:
|
|
141
|
-
"""
|
|
142
|
-
Extract patterns from currently staged changes.
|
|
139
|
+
"""Extract patterns from currently staged changes.
|
|
143
140
|
|
|
144
141
|
Returns:
|
|
145
142
|
List of detected pattern dicts
|
|
143
|
+
|
|
146
144
|
"""
|
|
147
145
|
diff = self._get_staged_diff()
|
|
148
146
|
if not diff:
|
|
@@ -158,14 +156,14 @@ class GitPatternExtractor:
|
|
|
158
156
|
return self._analyze_diff(diff, commit_info)
|
|
159
157
|
|
|
160
158
|
def save_pattern(self, pattern: dict[str, Any]) -> Path | None:
|
|
161
|
-
"""
|
|
162
|
-
Save a detected pattern as a draft for review.
|
|
159
|
+
"""Save a detected pattern as a draft for review.
|
|
163
160
|
|
|
164
161
|
Args:
|
|
165
162
|
pattern: Pattern dict from extraction
|
|
166
163
|
|
|
167
164
|
Returns:
|
|
168
165
|
Path to saved file, or None if failed
|
|
166
|
+
|
|
169
167
|
"""
|
|
170
168
|
self.debugging_dir.mkdir(parents=True, exist_ok=True)
|
|
171
169
|
|
|
@@ -201,6 +199,7 @@ class GitPatternExtractor:
|
|
|
201
199
|
try:
|
|
202
200
|
result = subprocess.run(
|
|
203
201
|
["git", "log", "-1", "--format=%H%n%s%n%an%n%aI", ref],
|
|
202
|
+
check=False,
|
|
204
203
|
capture_output=True,
|
|
205
204
|
text=True,
|
|
206
205
|
timeout=5,
|
|
@@ -226,6 +225,7 @@ class GitPatternExtractor:
|
|
|
226
225
|
try:
|
|
227
226
|
result = subprocess.run(
|
|
228
227
|
["git", "diff", ref1, ref2],
|
|
228
|
+
check=False,
|
|
229
229
|
capture_output=True,
|
|
230
230
|
text=True,
|
|
231
231
|
timeout=10,
|
|
@@ -239,6 +239,7 @@ class GitPatternExtractor:
|
|
|
239
239
|
try:
|
|
240
240
|
result = subprocess.run(
|
|
241
241
|
["git", "diff", "--cached"],
|
|
242
|
+
check=False,
|
|
242
243
|
capture_output=True,
|
|
243
244
|
text=True,
|
|
244
245
|
timeout=10,
|
|
@@ -252,6 +253,7 @@ class GitPatternExtractor:
|
|
|
252
253
|
try:
|
|
253
254
|
result = subprocess.run(
|
|
254
255
|
["git", "config", key],
|
|
256
|
+
check=False,
|
|
255
257
|
capture_output=True,
|
|
256
258
|
text=True,
|
|
257
259
|
timeout=5,
|
|
@@ -286,7 +288,9 @@ class GitPatternExtractor:
|
|
|
286
288
|
# Process previous file
|
|
287
289
|
if current_file and added_lines:
|
|
288
290
|
file_patterns = self._detect_fix_patterns(
|
|
289
|
-
current_file,
|
|
291
|
+
current_file,
|
|
292
|
+
added_lines,
|
|
293
|
+
commit_info,
|
|
290
294
|
)
|
|
291
295
|
patterns.extend(file_patterns)
|
|
292
296
|
|
|
@@ -334,7 +338,7 @@ class GitPatternExtractor:
|
|
|
334
338
|
"matches_count": len(matches),
|
|
335
339
|
"author": commit_info.get("author", "unknown"),
|
|
336
340
|
"date": commit_info.get("date", datetime.now().isoformat()),
|
|
337
|
-
}
|
|
341
|
+
},
|
|
338
342
|
)
|
|
339
343
|
|
|
340
344
|
return detected
|
empathy_llm_toolkit/levels.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Empathy Level Definitions
|
|
1
|
+
"""Empathy Level Definitions
|
|
3
2
|
|
|
4
3
|
Defines behavior for each of the 5 empathy levels.
|
|
5
4
|
|
|
@@ -11,8 +10,7 @@ from enum import IntEnum
|
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
class EmpathyLevel(IntEnum):
|
|
14
|
-
"""
|
|
15
|
-
The 5 levels of AI-human collaboration empathy.
|
|
13
|
+
"""The 5 levels of AI-human collaboration empathy.
|
|
16
14
|
|
|
17
15
|
Each level builds on previous levels.
|
|
18
16
|
"""
|
|
@@ -38,7 +36,6 @@ class EmpathyLevel(IntEnum):
|
|
|
38
36
|
@classmethod
|
|
39
37
|
def get_system_prompt(cls, level: int) -> str:
|
|
40
38
|
"""Get system prompt for operating at specific level"""
|
|
41
|
-
|
|
42
39
|
base = """You are an AI assistant using the Empathy Framework for collaboration.
|
|
43
40
|
|
|
44
41
|
Your responses should be:
|
|
@@ -117,8 +114,7 @@ Pattern contribution:
|
|
|
117
114
|
|
|
118
115
|
@classmethod
|
|
119
116
|
def get_temperature_recommendation(cls, level: int) -> float:
|
|
120
|
-
"""
|
|
121
|
-
Get recommended temperature for each level.
|
|
117
|
+
"""Get recommended temperature for each level.
|
|
122
118
|
|
|
123
119
|
Higher levels benefit from lower temperature (more focused).
|
|
124
120
|
"""
|
|
@@ -133,8 +129,7 @@ Pattern contribution:
|
|
|
133
129
|
|
|
134
130
|
@classmethod
|
|
135
131
|
def get_required_context(cls, level: int) -> dict[str, bool]:
|
|
136
|
-
"""
|
|
137
|
-
Get context requirements for each level.
|
|
132
|
+
"""Get context requirements for each level.
|
|
138
133
|
|
|
139
134
|
Returns dict of {context_type: required}
|
|
140
135
|
"""
|
|
@@ -175,8 +170,7 @@ Pattern contribution:
|
|
|
175
170
|
|
|
176
171
|
@classmethod
|
|
177
172
|
def get_max_tokens_recommendation(cls, level: int) -> int:
|
|
178
|
-
"""
|
|
179
|
-
Get recommended max_tokens for each level.
|
|
173
|
+
"""Get recommended max_tokens for each level.
|
|
180
174
|
|
|
181
175
|
Higher levels often need longer responses.
|
|
182
176
|
"""
|
|
@@ -190,8 +184,7 @@ Pattern contribution:
|
|
|
190
184
|
|
|
191
185
|
@classmethod
|
|
192
186
|
def should_use_json_mode(cls, level: int) -> bool:
|
|
193
|
-
"""
|
|
194
|
-
Determine if JSON mode is beneficial for level.
|
|
187
|
+
"""Determine if JSON mode is beneficial for level.
|
|
195
188
|
|
|
196
189
|
Levels 4-5 benefit from structured output.
|
|
197
190
|
"""
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Pattern Confidence Scoring
|
|
1
|
+
"""Pattern Confidence Scoring
|
|
3
2
|
|
|
4
3
|
Tracks how often stored fixes resolve similar issues,
|
|
5
4
|
building confidence scores over time.
|
|
@@ -85,8 +84,7 @@ class PatternUsageStats:
|
|
|
85
84
|
|
|
86
85
|
|
|
87
86
|
class PatternConfidenceTracker:
|
|
88
|
-
"""
|
|
89
|
-
Tracks pattern usage and calculates confidence scores.
|
|
87
|
+
"""Tracks pattern usage and calculates confidence scores.
|
|
90
88
|
|
|
91
89
|
Stores usage data in patterns/confidence/usage_stats.json
|
|
92
90
|
"""
|
|
@@ -151,8 +149,7 @@ class PatternConfidenceTracker:
|
|
|
151
149
|
return self._stats[pattern_id]
|
|
152
150
|
|
|
153
151
|
def record_suggestion(self, pattern_id: str) -> None:
|
|
154
|
-
"""
|
|
155
|
-
Record that a pattern was suggested to the user.
|
|
152
|
+
"""Record that a pattern was suggested to the user.
|
|
156
153
|
|
|
157
154
|
Call this when a pattern is shown as a potential fix.
|
|
158
155
|
"""
|
|
@@ -168,13 +165,13 @@ class PatternConfidenceTracker:
|
|
|
168
165
|
successful: bool = True,
|
|
169
166
|
notes: str | None = None,
|
|
170
167
|
) -> None:
|
|
171
|
-
"""
|
|
172
|
-
Record that a pattern fix was applied.
|
|
168
|
+
"""Record that a pattern fix was applied.
|
|
173
169
|
|
|
174
170
|
Args:
|
|
175
171
|
pattern_id: The pattern that was applied
|
|
176
172
|
successful: Whether the fix resolved the issue
|
|
177
173
|
notes: Optional feedback notes
|
|
174
|
+
|
|
178
175
|
"""
|
|
179
176
|
stats = self._get_or_create_stats(pattern_id)
|
|
180
177
|
stats.times_applied += 1
|
|
@@ -191,7 +188,7 @@ class PatternConfidenceTracker:
|
|
|
191
188
|
"date": datetime.now().isoformat(),
|
|
192
189
|
"successful": successful,
|
|
193
190
|
"notes": notes,
|
|
194
|
-
}
|
|
191
|
+
},
|
|
195
192
|
)
|
|
196
193
|
|
|
197
194
|
self._save()
|
|
@@ -203,11 +200,11 @@ class PatternConfidenceTracker:
|
|
|
203
200
|
)
|
|
204
201
|
|
|
205
202
|
def get_pattern_stats(self, pattern_id: str) -> dict[str, Any]:
|
|
206
|
-
"""
|
|
207
|
-
Get usage statistics for a pattern.
|
|
203
|
+
"""Get usage statistics for a pattern.
|
|
208
204
|
|
|
209
205
|
Returns:
|
|
210
206
|
Dict with usage stats and calculated scores
|
|
207
|
+
|
|
211
208
|
"""
|
|
212
209
|
stats = self._get_or_create_stats(pattern_id)
|
|
213
210
|
return {
|
|
@@ -230,14 +227,14 @@ class PatternConfidenceTracker:
|
|
|
230
227
|
return [self.get_pattern_stats(pid) for pid in self._stats]
|
|
231
228
|
|
|
232
229
|
def get_top_patterns(self, limit: int = 10) -> list[dict[str, Any]]:
|
|
233
|
-
"""
|
|
234
|
-
Get top patterns by confidence score.
|
|
230
|
+
"""Get top patterns by confidence score.
|
|
235
231
|
|
|
236
232
|
Args:
|
|
237
233
|
limit: Maximum patterns to return
|
|
238
234
|
|
|
239
235
|
Returns:
|
|
240
236
|
List of pattern stats, sorted by confidence
|
|
237
|
+
|
|
241
238
|
"""
|
|
242
239
|
self._ensure_loaded()
|
|
243
240
|
all_stats = self.get_all_stats()
|
|
@@ -249,14 +246,14 @@ class PatternConfidenceTracker:
|
|
|
249
246
|
return sorted_stats[:limit]
|
|
250
247
|
|
|
251
248
|
def get_stale_patterns(self, days: int = 90) -> list[dict[str, Any]]:
|
|
252
|
-
"""
|
|
253
|
-
Get patterns that haven't been used recently.
|
|
249
|
+
"""Get patterns that haven't been used recently.
|
|
254
250
|
|
|
255
251
|
Args:
|
|
256
252
|
days: Number of days to consider stale
|
|
257
253
|
|
|
258
254
|
Returns:
|
|
259
255
|
List of stale pattern stats
|
|
256
|
+
|
|
260
257
|
"""
|
|
261
258
|
self._ensure_loaded()
|
|
262
259
|
stale = []
|
|
@@ -275,8 +272,7 @@ class PatternConfidenceTracker:
|
|
|
275
272
|
return stale
|
|
276
273
|
|
|
277
274
|
def update_pattern_summary(self) -> bool:
|
|
278
|
-
"""
|
|
279
|
-
Update the patterns_summary.md with confidence scores.
|
|
275
|
+
"""Update the patterns_summary.md with confidence scores.
|
|
280
276
|
|
|
281
277
|
This adds a confidence section to the generated summary.
|
|
282
278
|
"""
|
|
@@ -297,7 +293,7 @@ class PatternConfidenceTracker:
|
|
|
297
293
|
icon = "🟢" if score >= 0.8 else "🟡" if score >= 0.5 else "🔴"
|
|
298
294
|
confidence_section.append(
|
|
299
295
|
f"- {icon} **{p['pattern_id']}**: {score:.0%} confidence "
|
|
300
|
-
f"({p['times_applied']} applied, {p['times_successful']} successful)"
|
|
296
|
+
f"({p['times_applied']} applied, {p['times_successful']} successful)",
|
|
301
297
|
)
|
|
302
298
|
|
|
303
299
|
confidence_section.append("")
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Pattern Resolution Module
|
|
1
|
+
"""Pattern Resolution Module
|
|
3
2
|
|
|
4
3
|
Provides CLI workflow for resolving investigating bug patterns
|
|
5
4
|
by adding root cause, fix, and resolution time.
|
|
@@ -40,8 +39,7 @@ logger = logging.getLogger(__name__)
|
|
|
40
39
|
|
|
41
40
|
|
|
42
41
|
class PatternResolver:
|
|
43
|
-
"""
|
|
44
|
-
Resolves investigating bug patterns with root cause and fix information.
|
|
42
|
+
"""Resolves investigating bug patterns with root cause and fix information.
|
|
45
43
|
|
|
46
44
|
Searches through pattern directories to find matching bug IDs
|
|
47
45
|
and updates them with resolution details.
|
|
@@ -52,14 +50,14 @@ class PatternResolver:
|
|
|
52
50
|
self._debugging_dirs = ["debugging", "debugging_demo", "repo_test/debugging"]
|
|
53
51
|
|
|
54
52
|
def find_bug(self, bug_id: str) -> tuple[Path | None, dict[str, Any] | None]:
|
|
55
|
-
"""
|
|
56
|
-
Find a bug pattern by ID.
|
|
53
|
+
"""Find a bug pattern by ID.
|
|
57
54
|
|
|
58
55
|
Args:
|
|
59
56
|
bug_id: The bug ID to find (e.g., "bug_20251212_3c5b9951")
|
|
60
57
|
|
|
61
58
|
Returns:
|
|
62
59
|
Tuple of (file_path, pattern_data) or (None, None) if not found
|
|
60
|
+
|
|
63
61
|
"""
|
|
64
62
|
for debug_dir in self._debugging_dirs:
|
|
65
63
|
dir_path = self.patterns_dir / debug_dir
|
|
@@ -88,11 +86,11 @@ class PatternResolver:
|
|
|
88
86
|
return None, None
|
|
89
87
|
|
|
90
88
|
def list_investigating(self) -> list[dict[str, Any]]:
|
|
91
|
-
"""
|
|
92
|
-
List all bugs with status 'investigating'.
|
|
89
|
+
"""List all bugs with status 'investigating'.
|
|
93
90
|
|
|
94
91
|
Returns:
|
|
95
92
|
List of bug patterns that need resolution
|
|
93
|
+
|
|
96
94
|
"""
|
|
97
95
|
investigating = []
|
|
98
96
|
|
|
@@ -122,8 +120,7 @@ class PatternResolver:
|
|
|
122
120
|
resolution_time_minutes: int = 0,
|
|
123
121
|
resolved_by: str = "@developer",
|
|
124
122
|
) -> bool:
|
|
125
|
-
"""
|
|
126
|
-
Resolve a bug pattern by updating its fields.
|
|
123
|
+
"""Resolve a bug pattern by updating its fields.
|
|
127
124
|
|
|
128
125
|
Args:
|
|
129
126
|
bug_id: The bug ID to resolve
|
|
@@ -135,6 +132,7 @@ class PatternResolver:
|
|
|
135
132
|
|
|
136
133
|
Returns:
|
|
137
134
|
True if successfully resolved, False otherwise
|
|
135
|
+
|
|
138
136
|
"""
|
|
139
137
|
file_path, pattern = self.find_bug(bug_id)
|
|
140
138
|
|
|
@@ -165,11 +163,11 @@ class PatternResolver:
|
|
|
165
163
|
return False
|
|
166
164
|
|
|
167
165
|
def regenerate_summary(self) -> bool:
|
|
168
|
-
"""
|
|
169
|
-
Regenerate the patterns_summary.md file.
|
|
166
|
+
"""Regenerate the patterns_summary.md file.
|
|
170
167
|
|
|
171
168
|
Returns:
|
|
172
169
|
True if successful, False otherwise
|
|
170
|
+
|
|
173
171
|
"""
|
|
174
172
|
try:
|
|
175
173
|
from empathy_llm_toolkit.pattern_summary import PatternSummaryGenerator
|