install-dependencies-dev:
	uv sync --no-install-project --only-group dev

install-dependencies-examples:
	uv sync --no-install-project --only-group examples

install-dependencies-main:
	uv sync --no-install-project --no-default-groups

install-dependencies-all:
	uv sync --no-install-project --group examples

install-pre-commit:
	uv run pre-commit install --install-hooks

install:
	uv sync --no-install-project
	make install-pre-commit

prepare:
	uv run pre-commit run --all-files

lint: prepare

lock:
	uv lock

lock-upgrade:
	uv lock --upgrade

test-integration:
	uv run pytest tests/integration

# These tests spend nearly all their wall time blocked on provider APIs, so they parallelize well past
# the core count. `loadfile` rather than `worksteal` because several files own shared external state for
# their whole duration (the Neo4j graph wipes, the `test_user_facts` pgvector table, the `default`
# Pinecone index written by one test and read by the next) and must not be split across workers.
test-integration-with-creds:
	uv run pytest tests/integration_with_creds -m "not smoke" -n auto --dist loadfile

# Smoke tests: slow, paid end-to-end production scenarios. Excluded from every default target and
# run ONLY here (gated behind the `run-smoke-tests` PR label in CI). -n auto parallelizes the
# matrix; if E2B quota / provider 429s appear, dial back to `-n 4` or group same-provider cases.
test-smoke:
	uv run pytest tests -m smoke -n auto --dist worksteal

test-exclude-integration-with-creds:
	uv run pytest tests --ignore=tests/integration_with_creds -m "not smoke"

test-unit:
	uv run pytest tests/unit

test:
	uv run pytest tests -m "not smoke"

# `pytest --cov` rather than `coverage run -m pytest`: xdist runs the tests in worker subprocesses that
# `coverage run` does not trace, which silently reports ~31% instead of ~84%. pytest-cov starts coverage
# inside each worker and combines the data. `--cov-report=` suppresses its own reporting so the three
# commands below still produce exactly the reports the coverage job consumes.
# This target includes tests/integration_with_creds, so it distributes by file for the reason given on
# test-integration-with-creds above; the exclude variant below has no such files and can split per test.
test-cov:
	mkdir -p ./reports
	uv run pytest --junitxml=./reports/test-results.xml -m "not smoke" tests -n auto --dist loadfile --cov --cov-report=
	uv run coverage report --skip-empty --skip-covered
	uv run coverage html -d ./reports/htmlcov --omit="*/test_*,*/tests.py"
	uv run coverage xml -o ./reports/coverage.xml --omit="*/test_*,*/tests.py"

test-cov-exclude-integration-with-creds:
	mkdir -p ./reports
	uv run pytest --junitxml=./reports/test-results.xml -m "not smoke" tests --ignore=tests/integration_with_creds -n auto --dist worksteal --cov --cov-report=
	uv run coverage report --skip-empty --skip-covered
	uv run coverage html -d ./reports/htmlcov --omit="*/test_*,*/tests.py"
	uv run coverage xml -o ./reports/coverage.xml --omit="*/test_*,*/tests.py"

build-mkdocs:
	rm -rf mkdocs/
	uv run python scripts/generate_mkdocs.py
	cp README.md mkdocs/index.md
	cp -rf docs/tutorials/ mkdocs/tutorials/
	uv run mkdocs build

publish-mkdocs:
	make build-mkdocs
	uv run mkdocs gh-deploy --force

run-mkdocs-locally:
	make build-mkdocs
	uv run mkdocs serve
