Skip to content
This repository was archived by the owner on Mar 20, 2026. It is now read-only.

Latest commit

 

History

History
182 lines (148 loc) · 6.09 KB

File metadata and controls

182 lines (148 loc) · 6.09 KB

🔧 Core Module Consolidation Plan

Current State: 75+ Files with Massive Duplication

After analyzing the core directory, I've identified significant duplication across modules. Here's the consolidation strategy:

🎯 Duplicate Groups to Consolidate

1. Backend Implementations (7 files → 1 file)

Duplicates:

  • backend_real.py - Main backend implementation
  • executor.py - Command execution
  • command_executor.py - Another executor
  • nix_real_executor.py - Yet another executor
  • native_nix_api.py - Native API interface
  • native_operations.py - Native operations
  • native_operations_advanced.py - Advanced native ops

Target: backend.py - Unified backend with all operations

2. Intent Processing (8 files → 1 file)

Duplicates:

  • intent_pipeline.py - Main pipeline
  • intent_pipeline_enhanced.py - Enhanced version
  • intent_factory.py - Intent creation
  • intent_improvement.py - Intent improvements
  • intent_secure_wrapper.py - Security wrapper
  • intent_security.py - Security checks
  • secure_intent_integration.py - More security
  • llm_intent_recognizer.py - LLM recognition

Target: intent.py - Unified intent system with built-in security

3. Configuration Management (6 files → 2 files)

Duplicates:

  • config.py - Basic config
  • config_enhanced_intent.py - Enhanced config
  • config_executor.py - Config execution
  • config_generator.py - Config generation
  • config_generator_ast.py - AST-based generation
  • simple_config_generator.py - Simple generation

Target:

  • config.py - Configuration management
  • config_generator.py - Generation logic (unified)

4. Error Handling (9 files → 1 file)

Duplicates:

  • error_handler.py - Basic handler
  • error_intelligence.py - Smart errors
  • error_intelligence_ast.py - AST errors
  • error_intelligence_unified.py - Unified errors
  • error_recovery.py - Recovery logic
  • error_translator.py - Translation
  • educational_errors.py - Educational messages
  • friendly_errors.py - Friendly messages
  • graceful_degradation.py - Degradation logic

Target: errors.py - Unified intelligent error system

5. Package Discovery (3 files → 1 file)

Duplicates:

  • package_discovery.py - Basic discovery
  • smart_package_discovery.py - Smart discovery
  • search_cache.py - Search caching

Target: discovery.py - Unified discovery with caching

6. Response Handling (3 files → 1 file)

Duplicates:

  • responses.py - Basic responses
  • response_adapter.py - Response adaptation
  • response_enhancer.py - Response enhancement
  • enhanced_output.py - Output enhancement

Target: response.py - Unified response system

7. System Core (4 files → 1 file)

Duplicates:

  • engine.py - Core engine
  • luminous_core.py - Luminous core
  • system_orchestrator.py - Orchestration
  • unified_system.py - Unified system

Target: engine.py - Single core engine

8. Persona/Mode Files (3 files → personas/ directory)

Move to separate module:

  • grandma_mode.pypersonas/grandma.py
  • maya_mode.pypersonas/maya.py
  • personality.pypersonas/base.py

9. Sacred/Consciousness Files (4 files → Remove or Plugin)

Extract to plugins:

  • sacred_pause.py - Remove (over-abstraction)
  • sacred_utils.py - Remove (over-abstraction)
  • conscious_integration.py - Extract to plugin
  • adaptive_behavior.py - Keep core parts only

10. Feature-Specific (Keep as separate files)

These are distinct features:

  • flake_manager.py - Flake management
  • home_manager.py - Home manager
  • generation_manager.py - Generation management
  • nixos_doctor.py - System health
  • profile_migration.py - Profile migration
  • progress_indicator.py - Progress display

📊 Consolidation Summary

Before: 75+ files

  • Massive duplication
  • Unclear responsibilities
  • Hard to navigate
  • Multiple implementations of same features

After: ~20 files

src/luminous_nix/core/
├── __init__.py
├── backend.py           # All NixOS operations
├── intent.py            # Intent recognition & processing
├── config.py            # Configuration management
├── config_generator.py  # Config generation
├── errors.py            # Unified error handling
├── discovery.py         # Package discovery
├── response.py          # Response formatting
├── engine.py            # Core engine
├── knowledge.py         # Knowledge base
├── cache.py             # Caching logic
├── flake_manager.py     # Flake management
├── home_manager.py      # Home manager
├── generation_manager.py # Generations
├── nixos_doctor.py      # System health
├── profile_migration.py  # Profile migration
├── progress_indicator.py # Progress display
├── first_run_wizard.py  # First run experience
└── plugin_system.py     # Plugin architecture

🚀 Implementation Steps

Phase 1: Create Unified Modules

  1. backend.py - Merge all backend/executor files
  2. intent.py - Merge all intent processing
  3. errors.py - Merge all error handling
  4. response.py - Merge all response handling

Phase 2: Move Feature Files

  1. Move persona files to personas/ module
  2. Extract consciousness files to plugins
  3. Keep distinct feature files as-is

Phase 3: Update Imports

  1. Update all imports across the codebase
  2. Update tests to use new structure
  3. Verify no broken dependencies

Phase 4: Clean Up

  1. Archive old files
  2. Update documentation
  3. Run full test suite

✅ Benefits

  1. Clarity: Each file has ONE clear purpose
  2. Maintainability: No more hunting through duplicates
  3. Performance: Less code to load and parse
  4. Simplicity: Easy to understand structure
  5. Elegance: Clean architecture that makes sense

🎯 Success Metrics

  • File count: 75+ → ~20 (73% reduction)
  • Lines of code: ~15,000 → ~5,000 (66% reduction)
  • Import complexity: Significantly reduced
  • Test coverage: Maintained or improved
  • Performance: Faster startup and execution

This consolidation maintains all functionality while dramatically simplifying the codebase.