set dotenv-load

_default:
  @ just --list --unsorted


# -----------------------------------------------------------------------------
# Full Repo Refactor
# -----------------------------------------------------------------------------
# Run a scenario
[group: 'Setting']
run scenario *args:
  full-repo-refactor --config scenarios/{{scenario}}.yaml {{args}}

# Run a scenario in honest mode
[group: 'Setting']
run-honest scenario *args:
  full-repo-refactor --config scenarios/{{scenario}}.yaml --eval-mode honest {{args}}

# Run a scenario in attack mode
[group: 'Setting']
run-attack scenario *args:
  full-repo-refactor --config scenarios/{{scenario}}.yaml --eval-mode attack {{args}}


# -----------------------------------------------------------------------------
# Virtual Environment
# -----------------------------------------------------------------------------
# Initialize the virtual environment
[group: 'Virtual Environment']
init:
  uv venv --python 3.12 .venv

# Install the package in editable mode
[group: 'Virtual Environment']
install:
  uv pip install -e .

# Install the package in editable mode with all optional dependencies
[group: 'Virtual Environment']
install-all:
  uv pip install -e ".[dev,doc,dist]"

# Sync core dependencies
[group: 'Virtual Environment']
sync:
  uv sync && uv pip install -e .

# Sync all dependencies
[group: 'Virtual Environment']
sync-all:
  uv sync && uv pip install -e ".[dev,doc,dist]"


# -----------------------------------------------------------------------------
# Dependency Management
# -----------------------------------------------------------------------------
# Add dependency
[group: 'Dependencies']
add target:
  uv add {{target}}

# Upgrade dependency
[group: 'Dependencies']
upgrade target:
  uv lock --upgrade-package {{target}} && uv sync

# Remove dependency
[group: 'Dependencies']
remove target:
  uv remove {{target}}

# Show outdated dependencies
[group: 'Dependencies']
outdated:
  uv tree --outdated --depth=1


# -----------------------------------------------------------------------------
# Testing
# -----------------------------------------------------------------------------
# Run tests
[group: 'Testing']
test *args:
  python -m pytest tests/ -v {{args}}


# -----------------------------------------------------------------------------
# Linting & Formatting
# -----------------------------------------------------------------------------
# Run linting
[group: 'Linting & Formatting']
lint:
  flake8 src/
  mypy src/

# Format code
[group: 'Linting & Formatting']
format:
  black src/
  isort src/


# -----------------------------------------------------------------------------
# Documentation
# -----------------------------------------------------------------------------
# Build and preview the documentation locally
[group: 'Documentation']
docs:
  just docs-build-api
  quarto preview docs --port 4200

# Build the API reference pages
[group: 'Documentation']
docs-build-api:
  PYTHONPATH=src uv run python scripts/gen_quarto_api.py

# Build the full documentation, including the API reference pages
[group: 'Documentation']
docs-build:
  just docs-build-api
  quarto render docs

# View the documentation locally
[group: 'Documentation']
view-docs:
  quarto preview docs --port 4200


# -----------------------------------------------------------------------------
# Building & Publishing
# -----------------------------------------------------------------------------
# Generate a distribution package
[group: 'Building & Publishing']
build:
  python -m build

# Publish a distribution package to TestPyPI
[group: 'Building & Publishing']
publish:
  python -m twine upload --repository testpypi dist/*


# -----------------------------------------------------------------------------
# Utilities
# -----------------------------------------------------------------------------
# Clean up testing and build artifacts
[group: 'Utilities']
clean:
  find . -type f -name "*.pyc" -delete
  find . -type d -name "__pycache__" -delete
  rm -rf build/
  rm -rf dist/
  rm -rf *.egg-info/
