.PHONY: install test check lint format smoke pypi clean

install:
	uv sync --group dev
	uv run pre-commit install

test:
	uv run pytest

check: lint test

lint:
	uvx ruff check src tests
	uvx ruff format --check src tests
	uv run ty check src

format:
	uvx ruff check --fix src tests
	uvx ruff format src tests

# Lightweight CLI smoke that doesn't pull a model. Real indexing smoke
# (`uv run climble search "function" --repo . -k 1`) downloads
# potion-code-16M and is too heavy for CI; run it locally if you want.
smoke:
	uv run climble --help >/dev/null
	uv run climble search --help >/dev/null
	uv run climble find-related --help >/dev/null

# Manual fallback only — DO NOT USE for canonical releases.
#
# The supported release path is:
#   1. Bump `version` in pyproject.toml and `__version__` in src/climble/__init__.py
#   2. Promote `## Unreleased` in CHANGELOG.md to `## X.Y.Z — YYYY-MM-DD`
#   3. Commit as `chore(release): vX.Y.Z`
#   4. git push
#   5. Write the release notes to a temp file (typically the new CHANGELOG
#      entry's body, minus the `## X.Y.Z` header) and tag with:
#        git tag -a vX.Y.Z --cleanup=verbatim -F notes.md && git push origin vX.Y.Z
#      The tag annotation becomes the GitHub Release body via
#      `--notes-from-tag` in the next step. `--cleanup=verbatim` keeps
#      `##` markdown headers — without it, git strips any line starting
#      with `#` as a comment. A one-line `-m vX.Y.Z` annotation produces
#      an empty release body; don't use it.
#   6. gh release create vX.Y.Z --notes-from-tag --title vX.Y.Z
#
# The published GitHub Release fires .github/workflows/publish.yml, which
# runs `uv build && uv publish --trusted-publishing always` via OIDC in the
# `pypi` environment. No stored PyPI tokens. See README "Releasing" section.
pypi:
	rm -rf dist
	uv build
	uv publish

clean:
	rm -rf dist build *.egg-info .pytest_cache
