feat: Implement YAML-first declarative intelligence architecture

Revolutionary transformation from hardcoded Python intelligence to hot-reloadable
YAML patterns, enabling dynamic configuration without code changes.

## Phase 1: Foundation Intelligence Complete

### YAML Intelligence Patterns (6 files)
- intelligence_patterns.yaml: Multi-dimensional pattern recognition with adaptive learning
- mcp_orchestration.yaml: Server selection decision trees with load balancing
- hook_coordination.yaml: Parallel execution patterns with dependency resolution
- performance_intelligence.yaml: Resource zones and auto-optimization triggers
- validation_intelligence.yaml: Health scoring and proactive diagnostic patterns
- user_experience.yaml: Project detection and smart UX adaptations

### Python Infrastructure Enhanced (4 components)
- intelligence_engine.py: Generic YAML pattern interpreter with hot-reload
- learning_engine.py: Enhanced with YAML intelligence integration
- yaml_loader.py: Added intelligence configuration helper methods
- validate_system.py: New YAML-driven validation with health scoring

### Key Features Implemented
- Hot-reload intelligence: Update patterns without code changes or restarts
- Declarative configuration: All intelligence logic expressed in YAML
- Graceful fallbacks: System works correctly even with missing YAML files
- Multi-pattern coordination: Intelligent recommendations from multiple sources
- Health scoring: Component-weighted validation with predictive diagnostics
- Generic architecture: Single engine consumes all intelligence pattern types

### Testing Results
 All components integrate correctly
 Hot-reload mechanism functional
 Graceful error handling verified
 YAML-driven validation operational
 Health scoring system working (detected real system issues)

This enables users to modify intelligence behavior by editing YAML files,
add new pattern types without coding, and hot-reload improvements in real-time.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
NomenAK
2025-08-06 13:26:04 +02:00
parent 73dfcbb228
commit da0a356eec
47 changed files with 19817 additions and 2802 deletions

View File

@@ -545,6 +545,15 @@ class PostToolUseHook:
{'hook': 'post_tool_use', 'effectiveness': overall_effectiveness}
)
# Track tool preference if execution was successful
if context.get('success') and overall_effectiveness > 0.7:
operation_type = self._categorize_operation(context['tool_name'])
if operation_type:
self.learning_engine.update_last_preference(
f"tool_{operation_type}",
context['tool_name']
)
# Record MCP server effectiveness
for server in context.get('mcp_servers_used', []):
self.learning_engine.record_learning_event(
@@ -622,6 +631,9 @@ class PostToolUseHook:
time_ratio = execution_time / max(self.performance_target_ms, 1)
time_penalty = min(time_ratio, 1.0)
# Initialize error penalty (no penalty when no error occurs)
error_penalty = 1.0
# Adjust for error occurrence
if context.get('error_occurred'):
error_severity = self._assess_error_severity(context)
@@ -736,6 +748,22 @@ class PostToolUseHook:
pattern_analysis['description'] = f"Error pattern detected: {error_type}"
return pattern_analysis
def _categorize_operation(self, tool_name: str) -> Optional[str]:
"""Categorize tool into operation type for preference tracking."""
operation_map = {
'read': ['Read', 'Get', 'List', 'Search', 'Find'],
'write': ['Write', 'Create', 'Generate'],
'edit': ['Edit', 'Update', 'Modify', 'Replace'],
'analyze': ['Analyze', 'Validate', 'Check', 'Test'],
'mcp': ['Context7', 'Sequential', 'Magic', 'Playwright', 'Morphllm', 'Serena']
}
for operation_type, tools in operation_map.items():
if any(tool in tool_name for tool in tools):
return operation_type
return None
def main():