# AgentHome Makefile
# Convenient commands for development and deployment

.PHONY: help install install-all test lint clean run-chat run-research run-support run-automation docker-build docker-run

# Default target
help:
	@echo "🏠 AgentHome - AI Agent Development Toolkit"
	@echo ""
	@echo "Usage:"
	@echo "  make install           Install core dependencies"
	@echo "  make install-all      Install all dependencies (including optional)"
	@echo "  make test             Run tests"
	@echo "  make lint             Run linters"
	@echo "  make clean            Clean temporary files"
	@echo ""
	@echo "Ready-made Agents:"
	@echo "  make run-chat         Run Chat Assistant"
	@echo "  make run-research     Run Research Agent"
	@echo "  make run-support      Run Customer Support Bot"
	@echo "  make run-automation   Run Task Automation"
	@echo ""
	@echo "Docker:"
	@echo "  make docker-build     Build Docker image"
	@echo "  make docker-run       Run Docker container"
	@echo ""

# Installation
install:
	@echo "📦 Installing core dependencies..."
	pip install -r requirements.txt

install-all:
	@echo "📦 Installing all dependencies..."
	pip install -e ".[all]"

install-dev:
	@echo "📦 Installing development dependencies..."
	pip install -e ".[dev]"

# Testing
test:
	@echo "🧪 Running tests..."
	pytest tests/ -v

test-coverage:
	@echo "🧪 Running tests with coverage..."
	pytest tests/ -v --cov=. --cov-report=html

# Linting and formatting
lint:
	@echo "🔍 Running linters..."
	flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
	black --check .
	mypy .

format:
	@echo "🎨 Formatting code..."
	black .

# Clean
clean:
	@echo "🧹 Cleaning temporary files..."
	find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name "*.pyc" -delete 2>/dev/null || true
	find . -type f -name "*.pyo" -delete 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
	rm -rf build/ dist/ .coverage htmlcov/ .tox/

# Ready-made agents
run-chat:
	@echo "🤖 Running Chat Assistant..."
	cd ready-made-agents/chat-assistant && pip install -r requirements.txt && python main.py

run-research:
	@echo "🔍 Running Research Agent..."
	cd ready-made-agents/research-agent && pip install -r requirements.txt && python main.py

run-support:
	@echo "💬 Running Customer Support Bot..."
	cd ready-made-agents/customer-support && pip install -r requirements.txt && python main.py

run-automation:
	@echo "⚡ Running Task Automation..."
	cd ready-made-agents/task-automation && pip install -r requirements.txt && python main.py

# Docker
docker-build:
	@echo "🐳 Building Docker image..."
	docker build -t agenthome:latest .

docker-run:
	@echo "🐳 Running Docker container..."
	docker run -it --env-file .env agenthome:latest

docker-build-advanced:
	@echo "🐳 Building advanced Docker image with GPU support..."
	docker build -f Dockerfile.advanced -t agenthome:advanced .

# Development helpers
dev:
	@echo "🚀 Setting up development environment..."
	pip install -e ".[dev]"
	@echo "✅ Development environment ready!"

check:
	@echo "🔍 Running all checks..."
	@echo "1. Linting..."
	flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
	@echo "2. Type checking..."
	mypy .
	@echo "3. Testing..."
	pytest tests/ -v
	@echo "✅ All checks passed!"

# Git helpers
commit:
	@read -p "Enter commit message: " msg; \
	git add -A && \
	git commit -m "$$msg"

push:
	git push origin main

# Build distribution
build:
	@echo "📦 Building distribution..."
	python -m build

upload:
	@echo "📤 Uploading to PyPI..."
	twine upload dist/*

# Project info
info:
	@echo "🏠 AgentHome Project Information"
	@echo "Version: 1.0.0"
	@echo "Python: 3.8+"
	@echo "License: MIT"
	@echo ""
	@echo "Available commands:"
	@echo "  make help         Show this help"
	@echo "  make install      Install dependencies"
	@echo "  make test         Run tests"
	@echo "  make lint        Run linters"
	@echo "  make clean       Clean temporary files"
