.PHONY: run dev test test-local lint format typecheck validate clean install pigfarm pigfarm-dev

VENV := .venv
PYTHON := $(VENV)/bin/python
PYTEST := $(VENV)/bin/pytest
RUFF := $(VENV)/bin/ruff
MYPY := $(VENV)/bin/mypy
TEXTUAL := $(VENV)/bin/textual

# Create venv with uv
venv:
	uv venv
	uv pip install -e ".[dev]"

run:
	$(PYTHON) -m agent_tui

dev:
	$(TEXTUAL) run --dev dev.py

# P.I.G. Farm targets
pigfarm:
	$(VENV)/bin/pigfarm --directory samples

pigfarm-dev:
	$(TEXTUAL) run --dev -c "from pathlib import Path; from pigfarm.app import PigFarmApp; app = PigFarmApp(working_directory=Path('samples')); app.run()"

test:
	$(PYTEST) tests/ -v

test-coverage:
	$(PYTEST) tests/ --cov=src --cov-report=html --cov-report=term-missing

lint:
	$(RUFF) check .

format:
	$(RUFF) format .

typecheck:
	$(MYPY) src/

validate: lint typecheck test

clean:
	rm -rf .pytest_cache .mypy_cache .ruff_cache __pycache__
	find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true

install:
	uv pip install -e ".[dev]"
