.PHONY: test lint fmt fmt-check typecheck coverage clean test-all e2e-local \
	lint-langchain fmt-langchain fmt-check-langchain typecheck-langchain test-langchain \
	release-prep release-tag release-push release-check release-notes

# Core SDK
test:
	pytest tests/

lint:
	ruff check src/ tests/ scripts/
	python3 scripts/check-gateway-public-terminology.py

fmt:
	ruff format src/ tests/ scripts/

fmt-check:
	ruff format --check src/ tests/ scripts/

typecheck:
	mypy src/

coverage:
	pytest --cov=dome --cov-report=html tests/

# LangChain adapter. Run from the package directory so its own ruff/mypy config
# applies, and so these are the same commands CI runs.
lint-langchain:
	cd packages/dome-langchain && ruff check src/ tests/

fmt-langchain:
	cd packages/dome-langchain && ruff format src/ tests/

fmt-check-langchain:
	cd packages/dome-langchain && ruff format --check src/ tests/

typecheck-langchain:
	cd packages/dome-langchain && mypy src/

test-langchain:
	cd packages/dome-langchain && pytest tests/

# All packages (core + adapters)
test-all: test test-langchain

e2e-local:
	DOME_SDK_E2E=1 pytest tests/e2e -q

# Releases. PKG is core (dome-sdk) or langchain (dome-langchain); pushing the tag
# is what publishes to PyPI, so it is always a separate, explicit step. ARGS
# forwards the script's own flags, e.g. ARGS=--skip-ci-check.
PKG ?= core
ARGS ?=

release-prep:
	python3 scripts/release.py prep $(PKG) $(VERSION) $(ARGS)

release-tag:
	python3 scripts/release.py tag $(PKG) $(ARGS)

release-push:
	python3 scripts/release.py push $(PKG) $(ARGS)

release-check:
	python3 scripts/release.py check --tag $(TAG)

release-notes:
	python3 scripts/release.py notes --tag $(TAG)

clean:
	rm -rf dist/ build/ *.egg-info/ htmlcov/ .coverage coverage.xml .mypy_cache/ .pytest_cache/
	rm -rf packages/dome-langchain/dist/ packages/dome-langchain/build/ packages/dome-langchain/*.egg-info/
	find . -type d -name __pycache__ -exec rm -rf {} +
