.PHONY: up down logs restart test test-unit test-integration lint format \
        migrate seed health clean generate-audit-key

up:
	docker compose up -d --wait && sleep 3 && uv run alembic upgrade head

down:
	docker compose down

logs:
	docker compose logs -f api

restart:
	docker compose down && docker compose up -d --wait

test:
	uv run pytest tests/ -x --tb=short -m "not claude_api"

test-unit:
	uv run pytest tests/unit/ -v --cov=core --cov=api --cov-fail-under=80

test-integration:
	uv run pytest tests/integration/ -v --tb=long -m integration

lint:
	uv run ruff check . && uv run mypy core/ api/ --ignore-missing-imports

format:
	uv run ruff format . && uv run ruff check . --fix

migrate:
	uv run alembic upgrade head

seed:
	uv run python scripts/seed_data.py

health:
	@bash scripts/health_check.sh

clean:
	docker compose down -v
	find . -type d -name pycache -exec rm -rf {} + 2>/dev/null; true
	find . -name "*.pyc" -delete 2>/dev/null; true

generate-audit-key:
	uv run python scripts/gen_audit_key.py
