0.1.2 ⢠Published 8 months ago
@bluefly/tddai v0.1.2
TDDAI - AI-Powered TDD Coding Standards Framework
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
.cursorrulesgeneration for AI-powered TDD guidance - Claude Code Integration: Enhanced
CLAUDE.mdfiles 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 jestMonitor 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 firstgreen- Implement minimal code to pass testrefactor- 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 listShow Preset Details
tddai preset info --name enterpriseApply Preset to Project
tddai preset apply --name startup
tddai preset apply --name enterprise --force # Overwrite existing filesCompare Project with Preset
tddai preset compare --name enterpriseCreate 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 JSONCreate Migration Plan
tddai migrate plan
tddai migrate plan --output migration-plan.json # Save planExecute Migration
tddai migrate execute
tddai migrate execute --dry-run # Preview changes
tddai migrate execute --interactive # Interactive modeCheck Migration Status
tddai migrate statusRollback 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 redGREEN Phase
# Implement minimal code to pass test
tddai tdd workflow --step greenREFACTOR 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 codeCoverage 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:coverageContributing
- Fork the repository
- Create a feature branch
- Follow TDD methodology (write tests first!)
- Run
npm testto ensure all tests pass - Submit a pull request
š Documentation
- Integration Guide - Comprehensive guide for adding TDDAI to existing projects
- Examples - Real-world integration examples for different project types
- API Reference
- TDD Best Practices
- Configuration Guide
- CI/CD Integration
- Setup Scripts - Automation scripts for quick setup
- Troubleshooting
š¤ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: GitHub Wiki
š 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 jestStart your TDD journey today!