# ai-config development tasks

default:
    @just --list

# Install all dependencies
setup:
    uv sync --all-extras

# Run all code quality checks
check: lint ty test

# Lint source code
lint:
    uv run ruff check src/

# Format source code
format:
    uv run ruff format src/

# Fix linting issues
fix:
    uv run ruff check src/ --fix

# Type check with ty
ty:
    uv run ty check src/

# Run tests
test:
    uv run pytest tests/ -v

# Run tests with coverage
test-cov:
    uv run pytest tests/ -v --cov=src/ai_config --cov-report=term-missing

# Run specific test file
test-file file:
    uv run pytest {{file}} -v

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

# Build package
build:
    uv build

# Install in development mode (editable, as uv tool)
dev:
    uv tool install -e . --force

# Ensure local editable install (source, not PyPI)
dev-install:
    uv tool install -e . --force

# Verify module path resolves to local repo
dev-check:
    uv run python - <<'PY'
    import ai_config, sys
    print("ai_config module:", ai_config.__file__)
    print("python:", sys.executable)
    PY

# Serve documentation locally
docs-serve:
    uv run mkdocs serve

# Build documentation
docs-build:
    uv run mkdocs build

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

# Run pre-commit on all files
pre-commit:
    uv run pre-commit run --all-files

# Docker dev shells (no local pollution)
docker-shell:
    env -u VIRTUAL_ENV uv sync --all-extras
    env -u VIRTUAL_ENV uv run --python .venv/bin/python tests/docker/test_in_docker.py --shell

docker-shell-claude:
    env -u VIRTUAL_ENV uv sync --all-extras
    env -u VIRTUAL_ENV uv run --python .venv/bin/python tests/docker/test_in_docker.py --shell --claude-only

# Persistent Docker dev container (attachable)
docker-dev-up:
    uv run python tests/docker/test_in_docker.py --build-only
    docker rm -f ai-config-dev 2>/dev/null || true
    docker run -d --name ai-config-dev -v "{{justfile_directory()}}":/home/testuser/ai-config -w /home/testuser/ai-config -u testuser ai-config-test:all-tools sleep infinity

docker-dev-attach:
    docker exec -it ai-config-dev /bin/bash

docker-dev-down:
    docker rm -f ai-config-dev
