0.1.2 • Published 8 months ago

@bluefly/tddai v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

TDDAI - AI-Powered TDD Coding Standards Framework

Version License Node.js Test Coverage

A comprehensive framework for Test-Driven Development with AI integration, automated setup, and real-time compliance monitoring.

šŸš€ Features

Core TDD Framework

  • Complete TDD Setup: Automated setup for Node.js, TypeScript, React, Drupal, and PHP projects
  • Test Framework Integration: Support for Jest, PHPUnit, Vitest, and Mocha
  • Coverage Monitoring: Real-time test coverage tracking with configurable thresholds
  • TDD Workflow: Guided RED-GREEN-REFACTOR workflow with step-by-step assistance

šŸŽÆ Project Presets (NEW!)

  • 7 Built-in Presets: Enterprise, Startup, React, CLI, API, Library, and Drupal configurations
  • Quick Setup: Apply complete TDD setup with a single command
  • Intelligent Detection: Automatically recommends the best preset for your project
  • Custom Presets: Create and share your own project configurations

šŸ”„ Project Migration (NEW!)

  • Automated Analysis: Intelligent analysis of existing projects for TDD adoption
  • Migration Planning: Detailed migration plans with step-by-step instructions
  • Safe Migration: Backup and rollback capabilities for risk-free transitions
  • Batch Processing: Migrate multiple projects simultaneously

AI Integration

  • Cursor IDE Integration: Automatic .cursorrules generation for AI-powered TDD guidance
  • Claude Code Integration: Enhanced CLAUDE.md files for comprehensive AI assistance
  • Smart Recommendations: AI-powered suggestions for improving code quality
  • Automated Code Review: Intelligent analysis of TDD compliance and standards

Multi-Platform Support

  • Node.js/TypeScript: Full Jest integration with TypeScript support
  • React: React Testing Library and component testing setup
  • Drupal: PHPUnit integration with Drupal-specific TDD patterns
  • CLI Tools: Command testing utilities and argument validation
  • APIs: Endpoint testing with Supertest integration
  • Libraries: Public API testing and documentation generation

Real-Time Monitoring

  • Live Compliance Tracking: Monitor TDD compliance in real-time
  • Performance Metrics: Track test execution time and coverage trends
  • Violation Detection: Instant notification of standards violations
  • Automated Scripts: Quick setup scripts for instant project integration

šŸ“¦ Installation

# Global installation
npm install -g @bluefly/tddai

# Local installation
npm install --save-dev @bluefly/tddai

šŸŽÆ Quick Start

šŸš€ Method 1: Use Presets (Recommended)

# List available presets
tddai preset list

# Apply a preset (auto-detects project type)
tddai preset apply --name startup

# Apply specific presets
tddai preset apply --name enterprise    # Strict TypeScript with 95% coverage
tddai preset apply --name react         # React with component testing
tddai preset apply --name api           # Express.js with endpoint testing
tddai preset apply --name cli           # CLI tool development
tddai preset apply --name library       # NPM package development
tddai preset apply --name drupal        # Drupal module development

šŸ”„ Method 2: Migrate Existing Project

# Analyze your existing project
tddai migrate analyze

# Create migration plan
tddai migrate plan

# Execute migration (with backup)
tddai migrate execute

# Check migration status
tddai migrate status

⚔ Method 3: Quick Setup Script

# Interactive setup for current project
npm run setup:quick

# Batch setup for multiple projects (if in LLM directory)
npm run setup:all-projects

šŸ› ļø Method 4: Manual Setup

# Setup for Node.js project
tddai setup --type node --framework jest

# Setup for React project
tddai setup --type react --framework jest

# Setup for Drupal module
tddai setup --type drupal --framework phpunit

# Setup for TypeScript project
tddai setup --type typescript --framework jest

šŸ¤– AI Integration Setup

# Setup all AI integrations (Cursor, Claude Code)
tddai ai setup-all

# Or setup individually
tddai ai setup-cursor      # Cursor IDE integration
tddai ai setup-claude      # Claude Code integration

āœ… Validation & Monitoring

# Validate current project
tddai validate --strict

# Monitor TDD compliance in real-time
tddai monitor --interval 30

# Output results as JSON
tddai validate --json

šŸ”§ TDD Commands

Setup TDD Framework

tddai tdd setup [options]

Options:

  • -t, --type <type> - Project type (node, drupal, react, typescript, php)
  • -f, --framework <framework> - Test framework (jest, phpunit, vitest, mocha)
  • -c, --coverage <number> - Coverage threshold percentage (default: 95)
  • --no-ai - Disable AI integration
  • --no-auto - Disable auto-setup
  • -p, --path <path> - Project path

Validate TDD Compliance

tddai tdd validate [options]

Options:

  • -t, --type <type> - Project type
  • -f, --framework <framework> - Test framework
  • -c, --coverage <number> - Coverage threshold
  • -p, --path <path> - Project path
  • --json - Output results as JSON

Generate Test Structure

tddai tdd generate <module> [options]

Example:

tddai tdd generate my-service --type node --framework jest

Monitor TDD Compliance

tddai tdd monitor [options]

Options:

  • -i, --interval <seconds> - Check interval in seconds (default: 30)

TDD Workflow Helper

tddai tdd workflow --step <step> [options]

Steps:

  • red - Write failing test first
  • green - Implement minimal code to pass test
  • refactor - Clean up code while keeping tests green

Example:

# Start with RED phase
tddai tdd workflow --step red

# Move to GREEN phase
tddai tdd workflow --step green

# Complete with REFACTOR phase
tddai tdd workflow --step refactor

šŸŽÆ Preset Commands

List Available Presets

tddai preset list

Show Preset Details

tddai preset info --name enterprise

Apply Preset to Project

tddai preset apply --name startup
tddai preset apply --name enterprise --force  # Overwrite existing files

Compare Project with Preset

tddai preset compare --name enterprise

Create Custom Preset

tddai preset create --name my-preset --output my-preset.json

šŸ”„ Migration Commands

Analyze Existing Project

tddai migrate analyze
tddai migrate analyze --json  # Output as JSON

Create Migration Plan

tddai migrate plan
tddai migrate plan --output migration-plan.json  # Save plan

Execute Migration

tddai migrate execute
tddai migrate execute --dry-run      # Preview changes
tddai migrate execute --interactive  # Interactive mode

Check Migration Status

tddai migrate status

Rollback Migration

tddai migrate rollback
tddai migrate rollback --backup-dir .my-backup

šŸ—ļø Project Structure

After running tddai setup, your project will have:

project/
ā”œā”€ā”€ __tests__/                 # Test directory
│   ā”œā”€ā”€ unit/                  # Unit tests
│   ā”œā”€ā”€ integration/           # Integration tests
│   └── fixtures/              # Test fixtures
ā”œā”€ā”€ src/                       # Source code
ā”œā”€ā”€ jest.config.js             # Jest configuration
ā”œā”€ā”€ jest.setup.js              # Jest setup file
ā”œā”€ā”€ CLAUDE.md                  # AI assistant configuration
ā”œā”€ā”€ .ai-standards.json         # AI coding standards
ā”œā”€ā”€ .gitlab-ci.yml             # GitLab CI configuration
ā”œā”€ā”€ .github/workflows/         # GitHub Actions workflows
└── package.json               # Updated with TDD scripts

šŸ“Š Validation Results

TDDAI provides comprehensive validation results:

$ tddai validate

šŸ“Š TDDAI Validation Results:
  Overall Score: 85/100 šŸ„‡
  TDD Compliant: āœ… Yes
  Test Coverage: 92%
  Standards Compliant: āœ… Yes

šŸ’” Recommendations:
  - Increase test coverage to 95%
  - Add integration tests for API endpoints
  - Implement error boundary tests

šŸ”„ TDD Workflow Integration

RED Phase

# Write failing test first
tddai tdd workflow --step red

GREEN Phase

# Implement minimal code to pass test
tddai tdd workflow --step green

REFACTOR Phase

# Clean up code while keeping tests green
tddai tdd workflow --step refactor

šŸŽ›ļø Configuration

AI Integration

TDDAI automatically creates CLAUDE.md for AI assistant configuration:

# TDD Coding Standards for Claude AI

## Project Overview
This project follows Test-Driven Development (TDD) methodology with strict coding standards.

## TDD Workflow
1. Write failing test first (RED)
2. Write minimal code to pass test (GREEN)  
3. Refactor while keeping tests green (REFACTOR)

## Coding Standards
- Test coverage must be 95% or higher
- All code must have corresponding tests
- Follow node best practices
- Use dependency injection
- Write clean, readable code

Coverage Thresholds

Configure coverage thresholds in your setup:

# Set 90% coverage threshold
tddai setup --coverage 90

# Validate with custom threshold
tddai validate --coverage 90

šŸš€ CI/CD Integration

GitLab CI

TDDAI automatically generates .gitlab-ci.yml:

stages:
  - validate
  - test
  - build

validate:standards:
  stage: validate
  script:
    - npm install -g @bluefly/tddai
    - tddai validate project
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

test:tdd:
  stage: test
  script:
    - npm install
    - npm run test:ci
    - npm run test:coverage
  coverage: '/Lines:\s*(\d+\.\d+)%/'

GitHub Actions

Automatically generates GitHub Actions workflow:

name: TDD Validation

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - name: Install TDDAI
        run: npm install -g @bluefly/tddai
      - name: Validate TDD Standards
        run: tddai validate project

šŸ“ˆ Monitoring Dashboard

Real-time monitoring provides live insights:

šŸ”„ TDDAI Compliance Monitor - 14:30:25
  Score: 92/100 šŸ„‡
  Coverage: 94%
  TDD Status: āœ… Compliant
  Standards Status: āœ… Compliant

šŸ’” Active recommendations:
  - Add edge case tests for error handling
  - Implement performance benchmarks
  - Consider adding visual regression tests

šŸ”Œ API Usage

Programmatic Usage

import { TDDAI } from '@bluefly/tddai';

const tddai = new TDDAI({
  projectType: 'node',
  testFramework: 'jest',
  coverageThreshold: 95,
  aiIntegration: true,
  autoSetup: true
});

// Validate project
const result = await tddai.validateProject();
console.log(`Score: ${result.score}/100`);

// Setup TDD framework
const setupResult = await tddai.setupProject();
console.log(`Files created: ${setupResult.filesCreated.length}`);

// Generate test structure
await tddai.generateTestStructure('./src/services', 'user-service');

Custom Configuration

import { TDDFramework } from '@bluefly/tddai';

const framework = new TDDFramework({
  projectType: 'drupal',
  testFramework: 'phpunit',
  coverageThreshold: 90,
  aiIntegration: true,
  autoSetup: true,
  projectRoot: './my-drupal-module'
});

// Custom validation
const validation = await framework.validateProject();
console.log(`TDD Compliant: ${validation.tddCompliant}`);

šŸ› ļø Development

Building from Source

# Clone repository
git clone https://github.com/bluefly/tddai.git
cd tddai

# Install dependencies
npm install

# Build project
npm run build

# Run tests
npm test

# Run with coverage
npm run test:coverage

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Follow TDD methodology (write tests first!)
  4. Run npm test to ensure all tests pass
  5. Submit a pull request

šŸ“š Documentation

šŸ¤ Support

šŸ“„ License

MIT License - see LICENSE file for details.

šŸ™ Acknowledgments

  • Built with ā¤ļø by the Bluefly.io team
  • Inspired by Test-Driven Development principles
  • Powered by modern AI integration
  • Supported by the open-source community

Ready to transform your development workflow? šŸš€

npm install -g @bluefly/tddai
tddai setup --type node --framework jest

Start your TDD journey today!