docs: Complete Framework-Hooks documentation overhaul

Major documentation update focused on technical accuracy and developer clarity:

Documentation Changes:
- Rewrote README.md with focus on hooks system architecture
- Updated all core docs (Overview, Integration, Performance) to match implementation
- Created 6 missing configuration docs for undocumented YAML files
- Updated all 7 hook docs to reflect actual Python implementations
- Created docs for 2 missing shared modules (intelligence_engine, validate_system)
- Updated all 5 pattern docs with real YAML examples
- Added 4 essential operational docs (INSTALLATION, TROUBLESHOOTING, CONFIGURATION, QUICK_REFERENCE)

Key Improvements:
- Removed all marketing language in favor of humble technical documentation
- Fixed critical configuration discrepancies (logging defaults, performance targets)
- Used actual code examples and configuration from implementation
- Complete coverage: 15 configs, 10 modules, 7 hooks, 3 pattern tiers
- Based all documentation on actual file review and code analysis

Technical Accuracy:
- Corrected performance targets to match performance.yaml
- Fixed timeout values from settings.json (10-15 seconds)
- Updated module count and descriptions to match actual shared/ directory
- Aligned all examples with actual YAML and Python implementations

The documentation now provides accurate, practical information for developers
working with the Framework-Hooks system, focusing on what it actually does
rather than aspirational features.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
NomenAK
2025-08-06 15:13:07 +02:00
parent ff7eda0e8a
commit 9edf3f8802
52 changed files with 4990 additions and 10202 deletions

View File

@@ -1,83 +1,57 @@
# Minimal Patterns: Ultra-Fast Project Bootstrap
# Minimal Patterns: Project Detection and Bootstrap
## Overview
Minimal Patterns form the foundation of SuperClaude's revolutionary bootstrap system, achieving **40-50ms initialization times** with **3-5KB context footprints**. These patterns enable instant project detection and intelligent MCP server coordination through lightweight, rule-based classification.
Minimal patterns provide project type detection and initial Framework-Hooks configuration. These patterns are stored in `/patterns/minimal/` and automatically configure MCP server activation and auto-flags based on detected project characteristics.
## Architecture Principles
## Purpose
### Ultra-Lightweight Design
Minimal patterns handle:
Minimal Patterns are designed for maximum speed and minimal memory usage:
```yaml
design_constraints:
size_limit: "5KB maximum per pattern"
load_time: "<50ms target"
memory_footprint: "minimal heap allocation"
cache_duration: "45-60 minutes optimal"
detection_accuracy: ">98% required"
```
### Bootstrap Sequence
```
File Detection → Pattern Matching → MCP Activation → Auto-Flags → Ready
↓ ↓ ↓ ↓ ↓
<10ms <15ms <20ms <5ms 40-50ms
```
- **Project Detection**: Identify project type from file structure and dependencies
- **MCP Server Selection**: Configure primary and secondary MCP servers
- **Auto-Flag Configuration**: Set automatic flags for immediate activation
- **Performance Targets**: Define bootstrap timing and context size goals
## Pattern Structure
### Core Schema
Every minimal pattern follows this optimized structure:
All minimal patterns follow this YAML structure:
```yaml
# Pattern Identification
project_type: "string" # Unique project classifier
project_type: "string" # Unique project identifier
detection_patterns: [] # File/directory detection rules
# MCP Server Coordination
auto_flags: [] # Automatic flag activation
mcp_servers:
primary: "string" # Primary MCP server
secondary: [] # Fallback servers
# Intelligence Configuration
patterns: {} # Project structure patterns
intelligence: {} # Mode triggers and validation
performance_targets: {} # Benchmarks and cache settings
patterns:
file_structure: [] # Expected project files/dirs
common_tasks: [] # Typical operations
intelligence:
mode_triggers: [] # Mode activation conditions
validation_focus: [] # Quality validation priorities
performance_targets:
bootstrap_ms: number # Bootstrap time target
context_size: "string" # Context footprint target
cache_duration: "string" # Cache retention time
```
### Detection Pattern Optimization
### Detection Rules
Detection patterns use efficient rule-based matching:
Detection patterns identify projects through:
- **File Extensions**: Look for specific file types (`.py`, `.jsx`, etc.)
- **Dependency Files**: Check for `package.json`, `requirements.txt`, `pyproject.toml`
- **Directory Structure**: Verify expected directories exist
- **Configuration Files**: Detect framework-specific config files
## Current Minimal Patterns
### Python Project Pattern (`python_project.yaml`)
This is the actual pattern file for Python projects:
```yaml
detection_optimization:
file_extension_matching:
- strategy: "glob_patterns"
- performance: "O(1) hash lookup"
- examples: ["*.py", "*.jsx", "*.tsx"]
directory_structure_detection:
- strategy: "existence_checks"
- performance: "single_filesystem_stat"
- examples: ["src/", "tests/", "node_modules/"]
dependency_manifest_parsing:
- strategy: "key_extraction"
- performance: "minimal_file_reading"
- examples: ["package.json", "requirements.txt", "pyproject.toml"]
```
## Project Type Patterns
### Python Project Pattern
```yaml
# /patterns/minimal/python_project.yaml
project_type: "python"
detection_patterns:
- "*.py files present"
@@ -85,8 +59,8 @@ detection_patterns:
- "__pycache__/ directories"
auto_flags:
- "--serena" # Semantic analysis for Python
- "--context7" # Python documentation lookup
- "--serena" # Semantic analysis
- "--context7" # Python documentation
mcp_servers:
primary: "serena"
@@ -94,13 +68,13 @@ mcp_servers:
patterns:
file_structure:
- "src/ or lib/" # Source code organization
- "tests/" # Testing directory
- "docs/" # Documentation
- "requirements.txt" # Dependencies
- "src/ or lib/"
- "tests/"
- "docs/"
- "requirements.txt"
common_tasks:
- "function refactoring" # Python-specific operations
- "function refactoring"
- "class extraction"
- "import optimization"
- "testing setup"
@@ -117,21 +91,16 @@ intelligence:
- "testing_coverage"
performance_targets:
bootstrap_ms: 40 # 40ms bootstrap target
context_size: "4KB" # Minimal context footprint
cache_duration: "45min" # Optimal cache retention
bootstrap_ms: 40
context_size: "4KB"
cache_duration: "45min"
```
**Performance Analysis**:
- **Detection Time**: 15ms (file system scan + pattern matching)
- **MCP Activation**: 20ms (serena primary, context7 secondary)
- **Flag Processing**: 5ms (--serena, --context7 auto-activation)
- **Total Bootstrap**: **40ms average**
This pattern automatically activates Serena (for semantic analysis) and Context7 (for Python documentation) when Python projects are detected.
### React Project Pattern
### React Project Pattern (`react_project.yaml`)
```yaml
# /patterns/minimal/react_project.yaml
project_type: "react"
detection_patterns:
- "package.json with react dependency"
@@ -148,13 +117,13 @@ mcp_servers:
patterns:
file_structure:
- "src/components/" # Component organization
- "src/hooks/" # Custom hooks
- "src/pages/" # Page components
- "src/utils/" # Utility functions
- "src/components/"
- "src/hooks/"
- "src/pages/"
- "src/utils/"
common_tasks:
- "component creation" # React-specific operations
- "component creation"
- "state management"
- "routing setup"
- "performance optimization"
@@ -171,431 +140,86 @@ intelligence:
- "performance"
performance_targets:
bootstrap_ms: 30 # 30ms bootstrap target (faster than Python)
context_size: "3KB" # Smaller context (focused on UI)
cache_duration: "60min" # Longer cache (stable patterns)
bootstrap_ms: 30
context_size: "3KB"
cache_duration: "60min"
```
**Performance Analysis**:
- **Detection Time**: 12ms (package.json parsing optimized)
- **MCP Activation**: 15ms (magic primary, lighter secondary)
- **Flag Processing**: 3ms (--magic, --context7 activation)
- **Total Bootstrap**: **30ms average**
This pattern activates Magic (for UI component generation) and Context7 (for React documentation) when React projects are detected.
## Advanced Minimal Patterns
## Creating New Minimal Patterns
### Node.js Backend Pattern
### Pattern Creation Process
1. **Identify Project Type**: Determine unique characteristics of the project type
2. **Define Detection Rules**: Create file/directory patterns for identification
3. **Select MCP Servers**: Choose primary and secondary servers for the project type
4. **Configure Auto-Flags**: Set flags that should activate automatically
5. **Define Intelligence**: Specify mode triggers and validation focus
6. **Set Performance Targets**: Define bootstrap time and context size goals
### Pattern Template
```yaml
project_type: "node_backend"
project_type: "your_project_type"
detection_patterns:
- "package.json with express|fastify|koa"
- "server.js or app.js or index.js"
- "routes/ or controllers/ directories"
- "unique file or directory patterns"
- "dependency or configuration files"
- "framework-specific indicators"
auto_flags:
- "--serena" # Code analysis
- "--context7" # Node.js documentation
- "--sequential" # API design analysis
- "--primary_server"
- "--supporting_server"
mcp_servers:
primary: "serena"
secondary: ["context7", "sequential"]
primary: "most_relevant_server"
secondary: ["fallback", "servers"]
patterns:
file_structure:
- "routes/ or controllers/"
- "middleware/"
- "models/ or schemas/"
- "__tests__/ or test/"
- "expected/directories/"
- "important files"
common_tasks:
- "API endpoint creation"
- "middleware implementation"
- "database integration"
- "authentication setup"
- "typical operations"
- "common workflows"
intelligence:
mode_triggers:
- "task_management: api|endpoint|server"
- "token_efficiency: context >70%"
- "mode_name: trigger_conditions"
validation_focus:
- "javascript_syntax"
- "api_patterns"
- "security_practices"
- "error_handling"
- "syntax_validation"
- "best_practices"
- "quality_checks"
performance_targets:
bootstrap_ms: 35
context_size: "4.5KB"
cache_duration: "50min"
```
### Vue.js Project Pattern
```yaml
project_type: "vue"
detection_patterns:
- "package.json with vue dependency"
- "src/ directory with .vue files"
- "vue.config.js or vite.config.js"
auto_flags:
- "--magic" # Vue component generation
- "--context7" # Vue documentation
mcp_servers:
primary: "magic"
secondary: ["context7", "morphllm"]
patterns:
file_structure:
- "src/components/"
- "src/views/"
- "src/composables/"
- "src/stores/"
common_tasks:
- "component development"
- "composable creation"
- "store management"
- "routing configuration"
intelligence:
mode_triggers:
- "task_management: component|view|composable"
- "token_efficiency: context >75%"
validation_focus:
- "vue_syntax"
- "composition_api"
- "reactivity_patterns"
- "performance"
performance_targets:
bootstrap_ms: 32
context_size: "3.2KB"
cache_duration: "55min"
```
## Detection Algorithm Optimization
### File System Scanning Strategy
```yaml
scanning_optimization:
directory_traversal:
strategy: "breadth_first_limited"
max_depth: 3
skip_patterns: [".git", "node_modules", "__pycache__", ".next"]
file_pattern_matching:
strategy: "compiled_regex_cache"
pattern_compilation: "startup_time"
match_performance: "O(1) average"
manifest_file_parsing:
strategy: "streaming_key_extraction"
parse_limit: "first_100_lines"
key_extraction: "dependency_section_only"
```
### Caching Strategy
```yaml
caching_architecture:
pattern_cache:
key_format: "{project_path}:{mtime_hash}"
storage: "in_memory_lru"
capacity: "100_patterns"
eviction: "least_recently_used"
detection_cache:
key_format: "{directory_hash}:{pattern_type}"
ttl: "45_minutes"
invalidation: "file_system_change_detection"
mcp_activation_cache:
key_format: "{project_type}:{mcp_servers}"
ttl: "session_duration"
warming: "predictive_loading"
```
## Performance Benchmarking
### Bootstrap Time Targets
| Project Type | Target (ms) | Achieved (ms) | Improvement |
|--------------|-------------|---------------|-------------|
| **Python** | 40 | 38 ± 3 | 5% better |
| **React** | 30 | 28 ± 2 | 7% better |
| **Node.js** | 35 | 33 ± 2 | 6% better |
| **Vue.js** | 32 | 30 ± 2 | 6% better |
### Context Size Analysis
| Project Type | Target Size | Actual Size | Efficiency |
|--------------|-------------|-------------|------------|
| **Python** | 4KB | 3.8KB | 95% efficiency |
| **React** | 3KB | 2.9KB | 97% efficiency |
| **Node.js** | 4.5KB | 4.2KB | 93% efficiency |
| **Vue.js** | 3.2KB | 3.1KB | 97% efficiency |
### Cache Performance
```yaml
cache_metrics:
hit_rate: 96.3% # Excellent cache utilization
miss_penalty: 45ms # Full pattern load time
memory_usage: 2.1MB # Minimal memory footprint
eviction_rate: 0.8% # Very stable cache
```
## Integration with Hook System
### Session Start Hook Integration
```python
# Conceptual integration - actual implementation in hooks
def on_session_start(context):
"""Minimal pattern loading during session initialization"""
# 1. Rapid project detection (10-15ms)
project_type = detect_project_type(context.project_path)
# 2. Pattern loading (15-25ms)
pattern = load_minimal_pattern(project_type)
# 3. MCP server activation (10-20ms)
activate_mcp_servers(pattern.mcp_servers)
# 4. Auto-flag processing (3-5ms)
process_auto_flags(pattern.auto_flags)
# Total: 38-65ms (target: <50ms)
return bootstrap_context
```
### Performance Monitoring
```yaml
monitoring_integration:
bootstrap_timing:
measurement: "per_pattern_load"
alert_threshold: ">60ms"
optimization_trigger: ">50ms_average"
cache_efficiency:
measurement: "hit_rate_tracking"
alert_threshold: "<90%"
optimization_trigger: "<95%_efficiency"
memory_usage:
measurement: "pattern_memory_footprint"
alert_threshold: ">10KB_per_pattern"
optimization_trigger: ">5KB_average"
```
## Quality Validation
### Pattern Validation Framework
```yaml
validation_rules:
schema_compliance:
- required_fields: ["project_type", "detection_patterns", "auto_flags"]
- size_limits: ["<5KB total", "<100 detection_patterns"]
- performance_requirements: ["<50ms bootstrap", ">98% accuracy"]
detection_accuracy:
- true_positive_rate: ">98%"
- false_positive_rate: "<2%"
- edge_case_handling: "graceful_fallback"
mcp_coordination:
- server_availability: "fallback_strategies"
- activation_timing: "<20ms target"
- flag_processing: "error_handling"
```
### Testing Framework
```yaml
testing_strategy:
unit_tests:
- pattern_loading: "isolated_testing"
- detection_logic: "comprehensive_scenarios"
- mcp_coordination: "mock_server_testing"
integration_tests:
- full_bootstrap: "end_to_end_timing"
- hook_integration: "session_lifecycle"
- cache_behavior: "multi_session_testing"
performance_tests:
- bootstrap_benchmarking: "statistical_analysis"
- memory_profiling: "resource_usage"
- cache_efficiency: "hit_rate_validation"
bootstrap_ms: target_milliseconds
context_size: "target_size"
cache_duration: "cache_time"
```
## Best Practices
### Pattern Creation Guidelines
### Detection Pattern Guidelines
1. **Minimalism First**: Keep patterns under 5KB, focus on essential detection
2. **Performance Optimization**: Optimize for <50ms bootstrap times
3. **Accurate Detection**: Maintain >98% detection accuracy
4. **Smart Caching**: Design for 45-60 minute cache duration
5. **Fallback Strategies**: Handle edge cases gracefully
1. **Use Specific Identifiers**: Look for unique files or dependency patterns
2. **Multiple Signals**: Combine file extensions, directories, and config files
3. **Avoid Generic Patterns**: Don't rely on common files like `README.md`
4. **Test Edge Cases**: Handle missing files or permission errors gracefully
### Detection Pattern Design
### MCP Server Selection
```yaml
detection_best_practices:
specificity:
- use_unique_identifiers: "package.json keys, manifest files"
- avoid_generic_patterns: "*.txt, common directory names"
- combine_multiple_signals: "file + directory + manifest"
performance:
- optimize_filesystem_access: "minimize stat() calls"
- cache_compiled_patterns: "regex compilation at startup"
- fail_fast_on_mismatch: "early_exit_strategies"
reliability:
- handle_edge_cases: "missing files, permission errors"
- graceful_degradation: "partial_detection_acceptance"
- version_compatibility: "framework_version_tolerance"
```
1. **Primary Server**: Choose the most relevant MCP server for the project type
2. **Secondary Servers**: Add complementary servers as fallbacks
3. **Auto-Flags**: Set flags that provide immediate value for the project type
4. **Performance Targets**: Set realistic bootstrap and context size goals
### MCP Server Coordination
## Integration Notes
```yaml
mcp_coordination_best_practices:
server_selection:
- primary_server: "most_relevant_for_project_type"
- secondary_servers: "complementary_capabilities"
- fallback_chain: "graceful_degradation_order"
activation_timing:
- lazy_loading: "activate_on_first_use"
- parallel_activation: "concurrent_server_startup"
- health_checking: "server_availability_validation"
resource_management:
- memory_efficiency: "minimal_server_footprint"
- connection_pooling: "reuse_server_connections"
- cleanup_procedures: "proper_server_shutdown"
```
Minimal patterns integrate with Framework-Hooks through:
## Troubleshooting
- **session_start hook**: Loads and applies patterns during initialization
- **Project detection**: Scans files and directories to identify project type
- **MCP activation**: Automatically starts relevant MCP servers
- **Flag processing**: Sets auto-flags for immediate feature activation
### Common Issues
#### 1. Slow Bootstrap Times
**Symptoms**: Bootstrap >60ms consistently
**Diagnosis**:
- Check file system performance
- Analyze detection pattern complexity
- Monitor cache hit rates
**Solutions**:
- Optimize detection patterns for early exit
- Improve caching strategy
- Reduce file system access
#### 2. Detection Accuracy Issues
**Symptoms**: Wrong project type detection
**Diagnosis**:
- Review detection pattern specificity
- Check for conflicting patterns
- Analyze edge case scenarios
**Solutions**:
- Add more specific detection criteria
- Implement confidence scoring
- Improve fallback strategies
#### 3. Cache Inefficiency
**Symptoms**: Low cache hit rates <90%
**Diagnosis**:
- Monitor cache key generation
- Check cache eviction patterns
- Analyze pattern modification frequency
**Solutions**:
- Optimize cache key strategies
- Adjust cache duration
- Implement intelligent cache warming
### Debugging Tools
```yaml
debugging_capabilities:
bootstrap_profiling:
- timing_breakdown: "per_phase_analysis"
- bottleneck_identification: "critical_path_analysis"
- resource_usage: "memory_and_cpu_tracking"
pattern_validation:
- detection_testing: "project_type_accuracy"
- schema_validation: "structure_compliance"
- performance_testing: "benchmark_validation"
cache_analysis:
- hit_rate_monitoring: "efficiency_tracking"
- eviction_analysis: "pattern_usage_analysis"
- memory_usage: "footprint_optimization"
```
## Future Enhancements
### Planned Optimizations
#### 1. Sub-40ms Bootstrap
- **Target**: <25ms for all project types
- **Strategy**: Predictive pattern loading and parallel processing
- **Implementation**: Pre-warm cache based on workspace analysis
#### 2. Intelligent Pattern Selection
- **Target**: >99% detection accuracy
- **Strategy**: Machine learning-based pattern refinement
- **Implementation**: Feedback loop from user corrections
#### 3. Dynamic Pattern Generation
- **Target**: Auto-generated patterns for custom project types
- **Strategy**: Analyze project structure and generate detection rules
- **Implementation**: Pattern synthesis from successful detections
### Scalability Improvements
```yaml
scalability_roadmap:
pattern_library_expansion:
- target_languages: ["rust", "go", "swift", "kotlin"]
- framework_support: ["nextjs", "nuxt", "django", "rails"]
- deployment_patterns: ["docker", "kubernetes", "serverless"]
performance_optimization:
- sub_25ms_bootstrap: "parallel_processing_optimization"
- predictive_loading: "workspace_analysis_based"
- adaptive_caching: "ml_driven_cache_strategies"
intelligence_enhancement:
- pattern_synthesis: "automatic_pattern_generation"
- confidence_scoring: "probabilistic_detection"
- learning_integration: "continuous_improvement"
```
## Conclusion
Minimal Patterns represent the foundation of SuperClaude's performance revolution, achieving unprecedented bootstrap speeds while maintaining high accuracy and intelligent automation. Through careful optimization of detection algorithms, caching strategies, and MCP server coordination, these patterns enable:
- **Ultra-Fast Bootstrap**: 30-40ms initialization times
- **Minimal Resource Usage**: 3-5KB context footprints
- **High Accuracy**: >98% project type detection
- **Intelligent Automation**: Smart MCP server activation and auto-flagging
- **Scalable Architecture**: Foundation for dynamic and learned pattern evolution
The system continues to evolve with planned enhancements targeting sub-25ms bootstrap times and >99% detection accuracy through machine learning integration and predictive optimization strategies.
The pattern system provides a declarative way to configure Framework-Hooks behavior for different project types without requiring code changes.