.PHONY: install test lint format check ci wiki wiki-check

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:
	conda run -n $(ENV) ruff check src/ tests/ --fix
	conda run -n $(ENV) lint-imports

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) lint-imports

ci: check test

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

# 用户文档站(Gitea Wiki)与源码的机械对齐校验。wiki 是独立仓库,须显式给路径:
#   make wiki-check WIKI=~/PolyGateway.wiki
# 不并入 ci: 仓库里没有 wiki,自动跳过等于静默降级(违 P5),宁可让人显式跑。
wiki-check:
	@test -n "$(WIKI)" || (echo "用法: make wiki-check WIKI=<PolyGateway.wiki 克隆路径>" && exit 1)
	conda run -n $(ENV) python3 tools/check_wiki_alignment.py --wiki $(WIKI)
