# Pre-commit hooks for indus-agents
# Install: pre-commit install
# Run manually: pre-commit run --all-files

repos:
  # General file checks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
        args: [--markdown-linebreak-ext=md]
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-toml
      - id: check-json
      - id: check-added-large-files
        args: [--maxkb=1000]
      - id: check-merge-conflict
      - id: check-case-conflict
      - id: detect-private-key
      - id: mixed-line-ending
        args: [--fix=lf]

  # Python code formatting with Black
  - repo: https://github.com/psf/black
    rev: 23.12.1
    hooks:
      - id: black
        language_version: python3.11
        args: [--line-length=100]

  # Python linting with Ruff
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.1.9
    hooks:
      - id: ruff
        args: [--fix, --exit-non-zero-on-fix]

  # Type checking with mypy
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.8.0
    hooks:
      - id: mypy
        additional_dependencies:
          - types-requests
          - pydantic
        args: [--ignore-missing-imports, --no-strict-optional]
        files: ^src/

  # Security checks
  - repo: https://github.com/PyCQA/bandit
    rev: 1.7.6
    hooks:
      - id: bandit
        args: [-r, src/, -ll]
        exclude: ^tests/

  # Check for common security issues
  - repo: https://github.com/Lucas-C/pre-commit-hooks-safety
    rev: v1.3.3
    hooks:
      - id: python-safety-dependencies-check
        files: pyproject.toml

  # Markdown linting
  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.38.0
    hooks:
      - id: markdownlint
        args: [--fix]

  # YAML formatting
  - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
    rev: v2.11.0
    hooks:
      - id: pretty-format-yaml
        args: [--autofix, --indent, "2"]

  # Python docstring formatting
  - repo: https://github.com/PyCQA/docformatter
    rev: v1.7.5
    hooks:
      - id: docformatter
        args: [--in-place, --wrap-summaries=100, --wrap-descriptions=100]

  # Sort Python imports
  - repo: https://github.com/PyCQA/isort
    rev: 5.13.2
    hooks:
      - id: isort
        args: [--profile=black, --line-length=100]

  # Check Python package setup
  - repo: https://github.com/mgedmin/check-manifest
    rev: "0.49"
    hooks:
      - id: check-manifest
        args: [--no-build-isolation]
        additional_dependencies: [hatchling]

# Configuration
default_language_version:
  python: python3.11

# Exclude patterns
exclude: |
  (?x)^(
      \.git/|
      \.venv/|
      __pycache__/|
      \.pytest_cache/|
      \.mypy_cache/|
      \.ruff_cache/|
      dist/|
      build/|
      .*\.egg-info/|
      htmlcov/
  )
