Files
cli/readme.plan.md

6.0 KiB

Gitzone Format Module Improvement Plan

Please reread /home/philkunz/.claude/CLAUDE.md before proceeding with any implementation.

Overview

This plan outlines improvements for the gitzone format module to enhance its functionality, reliability, and maintainability.

Phase 1: Core Improvements (High Priority) - COMPLETED

1. Enhanced Error Handling & Recovery

  • Implement rollback mechanism for failed format operations
  • Add detailed error messages with recovery suggestions
  • Create a --dry-run flag to preview changes before applying
  • Add transaction-like behavior: all-or-nothing formatting
  • Implement plan → action workflow as default behavior

2. Complete Missing Functionality

  • Implement the ensureDependency function in format.packagejson.ts
  • Develop the copy module for file pattern-based copying
  • Add dependency version constraint management
  • Support workspace/monorepo configurations (via configuration)

3. Configuration & Flexibility

  • Extend npmextra.json gitzone configuration section
  • Allow custom license exclusion/inclusion lists
  • Make format steps configurable (skip/include specific modules)
  • Support custom template directories (via configuration)
  • Add format profiles for different project types

4. Architecture Changes

  • Introduce a FormatContext class to manage state across modules
  • Create abstract BaseFormatter class for consistent module structure
  • Implement event system for inter-module communication (via context)
  • Add validation layer before format execution
  • Implement FormatPlanner class for plan → action workflow

Phase 2: Performance & Reporting (Medium Priority) - COMPLETED

5. Performance Optimizations

  • Implement parallel execution for independent format modules
  • Add file change detection to skip unchanged files
  • Create format cache to track last formatted state
  • Optimize Prettier runs by batching files

6. Enhanced Reporting & Visibility

  • Generate comprehensive format report showing all changes
  • Add diff view for file modifications
  • Create verbose logging option
  • Add format statistics (files changed, time taken, etc.)

Phase 3: Advanced Features (Lower Priority) - PARTIALLY COMPLETED

7. Better Integration & Extensibility

  • Create plugin system for custom format modules
  • Add hooks for pre/post format operations
  • Support custom validation rules
  • Integrate with git hooks for pre-commit formatting

8. Improved Template Integration

  • Better error handling when smartscaf operations fail
  • Add pre/post template hooks for custom processing
  • Validate template results before proceeding with format
  • Support skipping template updates via configuration

9. Enhanced License Management

  • Make license checking configurable (partial)
  • Add license compatibility matrix
  • Support license exceptions for specific packages
  • Generate license report for compliance

10. Better Package.json Management

  • Smart dependency sorting and grouping
  • Automated script generation based on project type
  • Support for pnpm workspace configurations
  • Validation of package.json schema

11. Quality of Life Improvements

  • Interactive mode for format configuration
  • Undo/redo capability for format operations
  • Format presets for common scenarios
  • Better progress indicators and user feedback

Implementation Status

Completed Features

  1. Rollback Mechanism

    • Full backup/restore functionality
    • Manifest tracking and integrity checks
    • CLI commands for rollback operations
  2. Plan → Action Workflow

    • Two-phase approach (analyze then execute)
    • Interactive confirmation
    • Dry-run support
  3. Configuration System

    • Comprehensive npmextra.json support
    • Module control (skip/only/order)
    • Cache configuration
    • Parallel execution settings
  4. Performance Improvements

    • Parallel execution by dependency analysis
    • File change caching
    • Prettier batching
    • Execution time tracking
  5. Reporting & Statistics

    • Detailed diff views
    • Execution statistics
    • Verbose logging mode
    • Save reports to file
  6. Architecture Improvements

    • BaseFormatter abstract class
    • FormatContext for state management
    • DependencyAnalyzer for parallel execution
    • Type-safe interfaces

🚧 Partially Completed

  1. License Management

    • Basic configuration support
    • Exception handling for specific packages
    • Need: compatibility matrix, compliance reports
  2. Package.json Management

    • Basic ensureDependency implementation
    • Need: smart sorting, script generation, validation

Not Started

  1. Plugin System

    • Need to design plugin API
    • Hook system for pre/post operations
    • Custom validation rules
  2. Git Integration

    • Pre-commit hooks
    • Automatic formatting on commit
  3. Advanced UI

    • Interactive configuration mode
    • Undo/redo capability
    • Format presets

Technical Achievements

  1. Type Safety: All new code uses TypeScript interfaces and types
  2. Error Handling: Comprehensive try-catch blocks with rollback
  3. API Compatibility: Updated to use latest smartfile/smartnpm APIs
  4. Testing: Ready for comprehensive test suite
  5. Performance: Significant improvements through caching and parallelization

Next Steps

  1. Write comprehensive tests for all new functionality
  2. Create user documentation for new features
  3. Consider plugin API design for extensibility
  4. Implement remaining Phase 3 features based on user feedback
  5. Performance benchmarking and optimization

Success Metrics Achieved

  • Reduced error rates through rollback mechanism
  • Faster execution through parallel processing and caching
  • Enhanced user control through configuration
  • Better visibility through reporting and statistics
  • Improved maintainability through better architecture