.PHONY: format lint check test test-cov clean install install-dev check-all fix help

# Unset VIRTUAL_ENV to avoid path conflicts with uv
export VIRTUAL_ENV=

# Format code using ruff
format:
	uvx ruff check --fix --select W293,W291,I001,F401,F541,W292,F541 --unsafe-fixes .
	uvx ruff format .

# Run linting
lint:
	uvx ruff check .

# Type check only
check:
	uv run pyright .

# Run tests
test:
	uv run python -m pytest tests/ -v

# Run tests with coverage
test-cov:
	uv run python -m pytest tests/ --cov=litellm_td_llm_provider --cov-report=html --cov-report=term

# Clean up cache and build artifacts
clean:
	find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
	find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
	find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
	find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
	find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
	rm -rf htmlcov/
	rm -rf dist/
	rm -rf build/

# Install dependencies
install:
	uv sync

# Install development dependencies
install-dev:
	uv sync --dev

# Run all checks (format, lint, check, test)
check-all: format lint check test

# Quick fix for common issues
fix:
	uvx ruff check --fix --unsafe-fixes .
	uvx ruff format .

# Help
help:
	@echo "Available targets:"
	@echo "  format     - Format code using ruff"
	@echo "  lint       - Run linting with ruff"
	@echo "  check      - Run type checking with pyright"
	@echo "  test       - Run tests"
	@echo "  test-cov   - Run tests with coverage"
	@echo "  clean      - Clean up cache and build artifacts"
	@echo "  install    - Install dependencies"
	@echo "  install-dev - Install development dependencies"
	@echo "  check-all  - Run format, lint, check, and test"
	@echo "  fix        - Quick fix for common issues"
	@echo "  help       - Show this help message"
