# Pre-commit hooks for Tree-sitter Analyzer
# Install: uv add --dev pre-commit && uv run pre-commit install

repos:
  # Python code formatting - disabled in favor of ruff-format
  # - repo: https://github.com/psf/black
  #   rev: 24.10.0
  #   hooks:
  #     - id: black
  #       language_version: python3
  #       args: [--line-length=88]

  # Python linting and code quality
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.8.4
    hooks:
      - id: ruff
        args: [--fix, --exit-non-zero-on-fix]
      - id: ruff-format

  # Basic file checks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: trailing-whitespace
        exclude: \.md$
      - id: end-of-file-fixer
        exclude: \.md$
      - id: check-yaml
        args: [--allow-multiple-documents]
      - id: check-json
        exclude: ^examples/.*\.(json|summary\.json)$
      - id: check-toml
      - id: check-merge-conflict
      - id: check-added-large-files
        args: [--maxkb=1000]
      - id: check-case-conflict
      - id: mixed-line-ending
        args: [--fix=lf]
      - id: check-ast
      - id: check-builtin-literals
      - id: check-docstring-first
      - id: debug-statements
      - id: name-tests-test
        args: [--pytest-test-first]
        exclude: ^tests/format_testing/(cross_version_compatibility|format_monitor|generate_compatibility_report|update_baselines|validate_golden_masters|format_assertions|integration_tests|format_contract_tests|comprehensive_test_suite|enhanced_assertions|cross_component_tests|schema_validation|specification_compliance_tests|performance_tests|generate_regression_report|golden_master|end_to_end_tests)\.py$|^tests/test_workflows/validate_.*\.py$|^tests/fixtures/.*\.py$

  # Security checks
  - repo: https://github.com/PyCQA/bandit
    rev: 1.7.10
    hooks:
      - id: bandit
        exclude: ^tests/|^openspec/changes/archive/|^scripts/|^build_standalone\.py$|^check_quality\.py$|^run_regression_tests\.py$|^test_fixes\.py$|^upload_interactive\.py$|^upload_to_pypi\.py$|^examples/
        args: [--format, json]

  # Type checking - temporarily disabled for commit
  # - repo: https://github.com/pre-commit/mirrors-mypy
  #   rev: v1.18.2
  #   hooks:
  #     - id: mypy
  #       args: [--ignore-missing-imports, --no-error-summary, --show-error-codes, --explicit-package-bases]
  #       exclude: ^(examples/|scripts/|compatibility_test/|collect_project_metrics\.py|test_emergency_fix\.py|debug_async_test\.py|run_regression_tests\.py)
  #       additional_dependencies: [
  #         types-psutil>=5.9.0,
  #       ]

  # Documentation checks - temporarily disabled for commit
  # - repo: https://github.com/pycqa/pydocstyle
  #   rev: 6.3.0
  #   hooks:
  #     - id: pydocstyle
  #       args: [--convention=google, --add-ignore=D100,D101,D102,D103,D104,D105,D107]
  #       exclude: ^(tests/|examples/)

  # Python modernization
  - repo: https://github.com/asottile/pyupgrade
    rev: v3.19.0
    hooks:
      - id: pyupgrade
        args: [--py310-plus]

  # Additional linting - temporarily disabled for commit
  # - repo: https://github.com/PyCQA/flake8
  #   rev: 7.1.1
  #   hooks:
  #     - id: flake8
  #       args: [--max-line-length=88, --extend-ignore=E203,W503,E501]
  #       additional_dependencies: [
  #         flake8-bugbear,
  #         flake8-comprehensions,
  #         flake8-simplify,
  #       ]

  # Workflow consistency tests
  - repo: local
    hooks:
      - id: workflow-consistency-tests
        name: Workflow Consistency Tests
        entry: uv run pytest tests/test_workflows/test_workflow_properties.py -v --tb=short
        language: system
        pass_filenames: false
        files: ^\.github/workflows/.*\.yml$
        stages: [pre-commit]

# Configuration
default_stages: [pre-commit]
fail_fast: false
minimum_pre_commit_version: "3.0.0"
