.PHONY: setup dev test test-cov lint format check inspect clean

# Setup development environment
setup:
	python -m venv .venv
	. .venv/Scripts/activate 2>/dev/null || . .venv/bin/activate && \
		pip install -e ".[dev]"
	@echo ""
	@echo "Setup complete. Activate venv:"
	@echo "  Windows: .venv\\Scripts\\activate"
	@echo "  Linux:   source .venv/bin/activate"
	@echo ""
	@echo "Then copy .env.example to .env and configure."

# Run development server
dev:
	. .venv/Scripts/activate 2>/dev/null || . .venv/bin/activate && \
		tally-mcp

# Run tests
test:
	. .venv/Scripts/activate 2>/dev/null || . .venv/bin/activate && \
		pytest -v

# Run tests with coverage
test-cov:
	. .venv/Scripts/activate 2>/dev/null || . .venv/bin/activate && \
		pytest -v --cov=tally_mcp --cov-report=term-missing

# Run linter
lint:
	. .venv/Scripts/activate 2>/dev/null || . .venv/bin/activate && \
		ruff check src/ tests/

# Run formatter
format:
	. .venv/Scripts/activate 2>/dev/null || . .venv/bin/activate && \
		ruff format src/ tests/

# Run all checks (lint + test)
check: lint test

# Open MCP Inspector (requires npx)
inspect:
	npx @modelcontextprotocol/inspector

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