---
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.14.10
    hooks:
      # Run the linter
      - id: ruff
        args: [--fix]
      # Run the formatter
      - id: ruff-format

  - repo: https://github.com/python-poetry/poetry
    rev: 1.8.0
    hooks:
      # Check that poetry.lock is in sync with pyproject.toml
      - id: poetry-check
        name: poetry-check
        description: Check that poetry.lock is in sync with pyproject.toml
        entry: poetry check
        language: system
        files: ^(pyproject.toml|poetry.lock)$
        pass_filenames: false

      # Auto-update poetry.lock when pyproject.toml changes
      - id: poetry-lock
        name: poetry-lock
        description: Update poetry.lock when pyproject.toml changes
        entry: poetry lock
        language: system
        files: ^pyproject.toml$
        pass_filenames: false

  # Local hook to prevent accidental workflow file truncation
  - repo: local
    hooks:
      - id: check-workflow-truncation
        name: check for workflow file truncation
        description: Detect accidental truncation of critical workflow files
        entry: scripts/check-workflow-truncation.sh
        language: script
        files: ^\.github/workflows/ci\.yml$

