.PHONY: install test lint format check ci wiki

ENV := PolyGateway

install:
	conda run -n $(ENV) pip install -e ".[redis,postgres,structured,dev]"

test:
	conda run -n $(ENV) pytest tests/ --cov=src/polygateway --cov-report=term-missing

# lint-imports 在 M1 模块落地前门控跳过（契约见 pyproject.toml [tool.importlinter]）
lint:
	conda run -n $(ENV) ruff check src/ tests/ --fix
	@conda run -n $(ENV) python -c "import polygateway.ports" 2>/dev/null \
	  && conda run -n $(ENV) lint-imports \
	  || echo "import-linter: M1 模块未创建，跳过（契约已在 pyproject.toml 声明）"

format:
	conda run -n $(ENV) ruff format src/ tests/

check:
	conda run -n $(ENV) ruff format --check src/ tests/
	conda run -n $(ENV) ruff check src/ tests/
	@conda run -n $(ENV) python -c "import polygateway.ports" 2>/dev/null \
	  && conda run -n $(ENV) lint-imports \
	  || echo "import-linter: M1 模块未创建，跳过（契约已在 pyproject.toml 声明）"

ci: check test

wiki:
	conda run -n $(ENV) python3 .claude/tools/research_wiki.py rebuild_index research-wiki/
