repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.3.0
    hooks:
      - id: no-commit-to-branch # prevent direct commits to protected branches
        args: ["--branch", "master"]
      - id: check-yaml # validate YAML syntax
        args: ["--unsafe"] # allow custom tags
      - id: check-toml # validate TOML syntax
      - id: end-of-file-fixer # ensure files end with a newline
      - id: trailing-whitespace # remove trailing whitespace from lines
        exclude: \.ambr$

  # Text normalization hooks for consistent formatting
  - repo: https://github.com/sirosen/texthooks
    rev: 0.6.8
    hooks:
      - id: fix-smartquotes # replace curly quotes with straight quotes
      - id: fix-spaces # replace non-standard spaces (e.g., non-breaking) with regular spaces

  # Per-package format and lint hooks for the monorepo
  - repo: local
    hooks:
      - id: core
        name: format and lint core
        language: system
        entry: make -C libs/core format lint
        files: ^libs/core/
        pass_filenames: false
      - id: langchain
        name: format and lint langchain
        language: system
        entry: make -C libs/langchain format lint
        files: ^libs/langchain/
        pass_filenames: false
      - id: standard-tests
        name: format and lint standard-tests
        language: system
        entry: make -C libs/standard-tests format lint
        files: ^libs/standard-tests/
        pass_filenames: false
      - id: text-splitters
        name: format and lint text-splitters
        language: system
        entry: make -C libs/text-splitters format lint
        files: ^libs/text-splitters/
        pass_filenames: false
      - id: anthropic
        name: format and lint partners/anthropic
        language: system
        entry: make -C libs/partners/anthropic format lint
        files: ^libs/partners/anthropic/
        pass_filenames: false
      - id: chroma
        name: format and lint partners/chroma
        language: system
        entry: make -C libs/partners/chroma format lint
        files: ^libs/partners/chroma/
        pass_filenames: false
      - id: exa
        name: format and lint partners/exa
        language: system
        entry: make -C libs/partners/exa format lint
        files: ^libs/partners/exa/
        pass_filenames: false
      - id: fireworks
        name: format and lint partners/fireworks
        language: system
        entry: make -C libs/partners/fireworks format lint
        files: ^libs/partners/fireworks/
        pass_filenames: false
      - id: groq
        name: format and lint partners/groq
        language: system
        entry: make -C libs/partners/groq format lint
        files: ^libs/partners/groq/
        pass_filenames: false
      - id: huggingface
        name: format and lint partners/huggingface
        language: system
        entry: make -C libs/partners/huggingface format lint
        files: ^libs/partners/huggingface/
        pass_filenames: false
      - id: mistralai
        name: format and lint partners/mistralai
        language: system
        entry: make -C libs/partners/mistralai format lint
        files: ^libs/partners/mistralai/
        pass_filenames: false
      - id: nomic
        name: format and lint partners/nomic
        language: system
        entry: make -C libs/partners/nomic format lint
        files: ^libs/partners/nomic/
        pass_filenames: false
      - id: ollama
        name: format and lint partners/ollama
        language: system
        entry: make -C libs/partners/ollama format lint
        files: ^libs/partners/ollama/
        pass_filenames: false
      - id: openai
        name: format and lint partners/openai
        language: system
        entry: make -C libs/partners/openai format lint
        files: ^libs/partners/openai/
        pass_filenames: false
      - id: qdrant
        name: format and lint partners/qdrant
        language: system
        entry: make -C libs/partners/qdrant format lint
        files: ^libs/partners/qdrant/
        pass_filenames: false
      - id: core-version
        name: check core version consistency
        language: system
        entry: make -C libs/core check_version
        files: ^libs/core/(pyproject\.toml|langchain_core/version\.py)$
        pass_filenames: false
      - id: langchain-v1-version
        name: check langchain version consistency
        language: system
        entry: make -C libs/langchain_v1 check_version
        files: ^libs/langchain_v1/(pyproject\.toml|langchain/__init__\.py)$
        pass_filenames: false
      - id: anthropic-version
        name: check anthropic version consistency
        language: system
        entry: make -C libs/partners/anthropic check_version
        files: ^libs/partners/anthropic/(pyproject\.toml|langchain_anthropic/_version\.py)$
        pass_filenames: false
