.PHONY: install lint format check test ci

ENV := PolyLoop

# 命令形状是固定的：PYTHONUNBUFFERED=1 加 conda run --live-stream。conda 和 Python 各缓冲
# 一层，两层都得拆——只加其中一个，长跑命令仍然全程无输出，直到进程结束才一次性吐出。
RUN := PYTHONUNBUFFERED=1 conda run --live-stream -n $(ENV)

install:
	$(RUN) pip install -e ".[dev]"

# lint 带 --fix 会改工作区，check 只读。CI 用 check，人手修用 lint。
lint:
	$(RUN) ruff check src/ tests/ tools/ --fix
	$(RUN) lint-imports

format:
	$(RUN) ruff format src/ tests/ tools/

check:
	$(RUN) ruff format --check src/ tests/ tools/
	$(RUN) ruff check src/ tests/ tools/
	$(RUN) lint-imports

test:
	$(RUN) pytest

ci: check test
