markitect-main/markitect/explode_variants/enums.py

136 lines
3.4 KiB
Python
Raw Normal View History

feat: implement Issue #148 core infrastructure for explode-implode variants Complete implementation of Phase 1 core infrastructure: Core Infrastructure Components: - ExplodeVariant enum (flat, hierarchical, semantic) - ExplodeMode, ManifestVersion, DetectionConfidence enums - BaseVariant abstract class with common interface - ExplodeOptions, ImplodeOptions, ExplodeResult, ImplodeResult dataclasses Manifest System: - ManifestManager class for manifest.md creation and parsing - StructureEntry and ManifestData dataclasses - YAML front matter with complete metadata preservation - Validation and update mechanisms Variant Detection: - VariantDetector class with multiple detection strategies - Manifest-based detection (highest priority) - Directory naming pattern recognition - Semantic structure analysis with confidence scoring - Automatic fallback and combination logic Command Interface Updates: - md-explode: Added --variant parameter with [flat|hierarchical|semantic] - md-explode: Added --create-manifest/--no-manifest option - md-implode: Added --force-variant parameter for manual override - md-implode: Integrated auto-detection with verbose output - Updated help text and examples for both commands Test Coverage: - Comprehensive test suite with 21 test cases - Tests for all enums, dataclasses, and core functionality - ManifestManager creation, reading, and validation tests - VariantDetector pattern recognition and confidence tests - 100% test pass rate with robust edge case handling Infrastructure Features: - Backward compatibility maintained (flat variant default) - Graceful handling of unimplemented variants with user warnings - Extensible design for easy addition of new variants - Clear separation between infrastructure and implementation Success Criteria Met: ✅ ExplodeVariant enum with all planned variants ✅ ManifestManager creates and parses manifest.md files ✅ Commands accept variant parameters ✅ Auto-detection logic identifies variant types ✅ Unit tests achieve 100% pass rate ✅ Backward compatibility maintained Ready for Phase 2: Variant implementations (Issue #149) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-12 20:17:41 +02:00
"""
Enums for explode-implode variant system.
"""
from enum import Enum
class ExplodeVariant(Enum):
"""
Available explode variants for different directory organization strategies.
Each variant defines how a markdown file is exploded into a directory
structure and how that structure is imploded back.
"""
FLAT = "flat"
"""
Flat structure - current default behavior.
Creates directories based on h1 headings with nested content.
Example:
book.mdd/
manifest.md
book_title/
index.md
chapter_1.md
chapter_2.md
conclusion.md
"""
HIERARCHICAL = "hierarchical"
"""
Hierarchical structure with numbered prefixes.
Creates nested directories reflecting heading hierarchy with ordering.
Example:
book.mdd/
manifest.md
01_book_title/
index.md
01_chapter_1/
index.md
01_section_1.md
02_chapter_2/
99_conclusion.md
"""
SEMANTIC = "semantic"
"""
Semantic structure with content-based grouping.
Groups content into semantic categories like parts, chapters, appendices.
Example:
book.mdd/
manifest.md
parts/
01_fundamentals/
02_advanced/
chapters/
01_basics/
02_intermediate/
appendices/
"""
feat: complete Issue #150 - Advanced Packaging Features (.mdz, .mdt) Implement comprehensive advanced packaging system using complete TDD8 methodology: ## Core Features Delivered - **MDZ Format**: Self-contained ZIP packages with embedded assets and metadata - **Transclusion Engine**: Dynamic content inclusion with variables and conditionals - **Asset Management**: Automated discovery, integrity validation, and path rewriting - **Variant Integration**: Seamless integration with existing explode-implode system ## Technical Implementation - **53 comprehensive tests** with 100% coverage for new functionality - **Circular import resolution** using lazy loading pattern in variant factory - **Cross-platform compatibility** with proper path handling - **Robust error handling** with specialized exception hierarchy ## Quality Assurance - ✅ All 1798 tests passing (100% system compatibility maintained) - ✅ Complete documentation (user guide + API reference) - ✅ Working demonstration script showcasing all features - ✅ Zero breaking changes to existing functionality ## Files Added/Modified - **Core Implementation**: 17 new files (4,149+ lines) - **Documentation**: Complete user and API documentation - **Tests**: 53 new tests across 3 test modules - **Integration**: Enhanced variant factory with MDZ support Built on solid foundation from Issues #148-149. Production-ready with comprehensive test coverage and full backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 23:09:18 +02:00
MDZ = "mdz"
"""
Packaging variant for creating compressed packages (.mdz format).
Creates self-contained packages with embedded assets and metadata.
Example:
document.mdz (ZIP archive containing):
content.md
manifest.json
assets/
image1.png
style.css
"""
MDT = "mdt"
"""
Packaging variant for creating template packages (.mdt format).
Creates template packages with variable substitution and conditional content.
Example:
template.mdt (archive containing):
template.md
variables.json
assets/
template.css
default.png
"""
feat: implement Issue #148 core infrastructure for explode-implode variants Complete implementation of Phase 1 core infrastructure: Core Infrastructure Components: - ExplodeVariant enum (flat, hierarchical, semantic) - ExplodeMode, ManifestVersion, DetectionConfidence enums - BaseVariant abstract class with common interface - ExplodeOptions, ImplodeOptions, ExplodeResult, ImplodeResult dataclasses Manifest System: - ManifestManager class for manifest.md creation and parsing - StructureEntry and ManifestData dataclasses - YAML front matter with complete metadata preservation - Validation and update mechanisms Variant Detection: - VariantDetector class with multiple detection strategies - Manifest-based detection (highest priority) - Directory naming pattern recognition - Semantic structure analysis with confidence scoring - Automatic fallback and combination logic Command Interface Updates: - md-explode: Added --variant parameter with [flat|hierarchical|semantic] - md-explode: Added --create-manifest/--no-manifest option - md-implode: Added --force-variant parameter for manual override - md-implode: Integrated auto-detection with verbose output - Updated help text and examples for both commands Test Coverage: - Comprehensive test suite with 21 test cases - Tests for all enums, dataclasses, and core functionality - ManifestManager creation, reading, and validation tests - VariantDetector pattern recognition and confidence tests - 100% test pass rate with robust edge case handling Infrastructure Features: - Backward compatibility maintained (flat variant default) - Graceful handling of unimplemented variants with user warnings - Extensible design for easy addition of new variants - Clear separation between infrastructure and implementation Success Criteria Met: ✅ ExplodeVariant enum with all planned variants ✅ ManifestManager creates and parses manifest.md files ✅ Commands accept variant parameters ✅ Auto-detection logic identifies variant types ✅ Unit tests achieve 100% pass rate ✅ Backward compatibility maintained Ready for Phase 2: Variant implementations (Issue #149) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-12 20:17:41 +02:00
class ExplodeMode(Enum):
"""
Modes for explode operations affecting behavior and output.
"""
STANDARD = "standard"
"""Standard explode operation with manifest generation."""
LEGACY = "legacy"
"""Legacy mode without manifest for backward compatibility."""
PREVIEW = "preview"
"""Preview mode showing what would be created without actual creation."""
class ManifestVersion(Enum):
"""
Manifest format versions for backward compatibility.
"""
V1_0 = "1.0"
"""Initial manifest format with basic structure preservation."""
V1_1 = "1.1"
"""Enhanced manifest with asset tracking and metadata."""
class DetectionConfidence(Enum):
"""
Confidence levels for variant auto-detection.
"""
HIGH = "high"
"""High confidence - manifest found or clear patterns detected."""
MEDIUM = "medium"
"""Medium confidence - some patterns match but ambiguous."""
LOW = "low"
"""Low confidence - minimal patterns, fallback detection."""
UNKNOWN = "unknown"
"""Cannot determine variant - requires manual specification."""