name: Feature Port
description: Port functionality from one codebase to another
category: development

variables:
  source:
    description: Source codebase or package
    required: true
  feature:
    description: Feature to port
    required: true
  target:
    description: Target location in codebase
    required: false

guidelines:
  - Understand the source implementation thoroughly
  - Adapt to target architecture patterns
  - Avoid copy-paste without understanding
  - Test thoroughly in new environment

phases:
  - name: Analysis
    description: Understand the source implementation
    tasks:
      - Study the source code structure
      - Identify all dependencies
      - Document the feature's behaviour
      - List configuration requirements
      - Identify integration points

  - name: Planning
    description: Plan the port
    tasks:
      - Map source patterns to target patterns
      - Identify what needs adaptation
      - List files to create/modify
      - Plan database migrations if needed
      - Create a port checklist

  - name: Infrastructure
    description: Set up base requirements
    tasks:
      - Create necessary directories
      - Add required dependencies
      - Set up configuration
      - Create database migrations
      - Add base models/interfaces

  - name: Core Port
    description: Port the main functionality
    tasks:
      - Port core classes/services
      - Adapt to target patterns
      - Update namespaces and imports
      - Fix type hints and return types
      - Ensure PSR-12 compliance

  - name: Integration
    description: Connect to existing systems
    tasks:
      - Add routes and controllers
      - Integrate with existing services
      - Add UI components
      - Wire up events and listeners
      - Configure middleware

  - name: Testing
    description: Verify the port
    tasks:
      - Port existing tests
      - Add new integration tests
      - Test edge cases
      - Verify UI functionality
      - Performance testing

  - name: Cleanup
    description: Finalise the port
    tasks:
      - Remove unused code
      - Update documentation
      - Add code comments
      - Create pull request
      - Document any differences from source
