# List all available commands
default:
    @just --list

# Create virtual environment
venv:
    uv venv

# Install dependencies in development mode
install:
    uv sync --all-groups
    uvx prek install

# Format all code (Python + justfile)
format:
    just --fmt --unstable
    uvx ruff format
    uvx ruff check --fix

# Type checking
check:
    uv run pyright
    uvx ty check
    uvx ruff check .

# Run all tests
test: test-unit test-e2e

# Run unit tests with parallel execution and doctest
test-unit:
    uv run pytest tests/unit -n auto --xdoc

# Run end-to-end tests sequentially
test-e2e:
    uv run pytest tests/e2e -v

# Run tests with coverage
cov:
    uv run pytest tests/unit -n auto --xdoc --cov=tensor_spec --cov-report=html --cov-report=xml
    uv run coverage xml

# Generate and open HTML coverage report
cov-open:
    just cov
    open htmlcov/index.html || xdg-open htmlcov/index.html

# Clean build artifacts
clean:
    rm -rf .pytest_cache/
    rm -rf .ruff_cache/
    rm -rf htmlcov/
    rm -rf site/
    rm -rf dist/
    rm -rf build/
    rm -rf *.egg-info/
    find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
    find . -name "*.pyc" -delete 2>/dev/null || true

# Full CI check (format + check + lint + test with coverage)
ci: format check cov

# Run pre-commit on all files
pre-commit:
    uvx prek run --all-files

# Serve docs locally with live reload
docs:
    uv run zensical serve --open

# Build docs for deployment
docs-build:
    uv run zensical build

# Display project information
info:
    @echo "=== tensor-spec ==="
    @echo "uv: $(uv --version)"
    @echo "Python: $(uv run -p 3.12 python --version)"
