# Pre-commit hooks for MCP Hub
# Install: pip install pre-commit
# Setup: pre-commit install
# Run manually: pre-commit run --all-files

repos:
  # Black - Python code formatter
  - repo: https://github.com/psf/black
    rev: 24.1.1
    hooks:
      - id: black
        language_version: python3.11
        args: ['--line-length=100']

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

  # isort - Import sorting
  - repo: https://github.com/PyCQA/isort
    rev: 5.13.2
    hooks:
      - id: isort
        args: ['--profile', 'black', '--line-length', '100']

  # pyupgrade - Upgrade Python syntax
  - repo: https://github.com/asottile/pyupgrade
    rev: v3.15.0
    hooks:
      - id: pyupgrade
        args: ['--py311-plus']

  # General file checks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      # Check file formatting
      - id: trailing-whitespace
        args: ['--markdown-linebreak-ext=md']
      - id: end-of-file-fixer
      - id: check-yaml
        args: ['--safe']
      - id: check-json
      - id: check-toml
      - id: check-added-large-files
        args: ['--maxkb=1000']

      # Check for common issues
      - id: check-merge-conflict
      - id: check-case-conflict
      - id: mixed-line-ending
        args: ['--fix=lf']

      # Python-specific checks
      - id: check-ast
      - id: check-builtin-literals
      - id: check-docstring-first
      - id: debug-statements
      - id: name-tests-test
        args: ['--pytest-test-first']

  # Security checks
  - repo: https://github.com/PyCQA/bandit
    rev: 1.7.6
    hooks:
      - id: bandit
        args: ['-c', 'pyproject.toml', '--skip', 'B101,B601']
        additional_dependencies: ['bandit[toml]']

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

  # Shellcheck for bash scripts
  - repo: https://github.com/shellcheck-py/shellcheck-py
    rev: v0.9.0.6
    hooks:
      - id: shellcheck
        files: \.(sh|bash)$

# Configuration for specific hooks
exclude: |
  (?x)^(
    \.git/|
    \.venv/|
    venv/|
    __pycache__/|
    \.pytest_cache/|
    \.mypy_cache/|
    \.ruff_cache/|
    logs/|
    htmlcov/|
    dist/|
    build/|
    .*\.egg-info/
  )
