repos:
  - repo: local
    hooks:

      - id: check-broken-links
        name: Check Broken Links
        entry: uv run --active tools/scripts/check_broken_links.py
        language: python
        files: \.md$
        pass_filenames: false
        stages: [pre-commit, manual]

      - id: check-link-format
        name: Check Link Format (ipynb priority)
        entry: uv run --active tools/scripts/check_link_format.py
        language: python
        files: \.md$
        pass_filenames: false
        stages: [pre-commit, manual]

      - id: jupytext-sync
        name: Jupytext Sync
        entry: uv run --active tools/scripts/jupytext_sync.py
        language: python
        files: \.(md|ipynb)$
        pass_filenames: true
        require_serial: true
        stages: [pre-commit]

      - id: jupytext-verify-pair
        name: Jupytext Verify Pair
        entry: uv run --active tools/scripts/jupytext_verify_pair.py
        language: python
        files: \.(md|ipynb)$
        pass_filenames: true
        require_serial: true
        stages: [pre-commit]

      - id: check-api-keys
        name: Check API Keys
        entry: uv run --active tools/scripts/check_api_keys.py
        language: python
        pass_filenames: true
        exclude: ^(tools/tests/test_check_api_keys\.py|tools/docs/scripts_instructions/check_api_keys_py_script\.md)$
        stages: [pre-commit]

      - id: check-json-files
        name: Check JSON Files
        entry: uv run --active tools/scripts/check_json_files.py
        language: python
        files: \.json$
        pass_filenames: true
        exclude: ^(tools/tests/|\.vscode/)
        stages: [pre-commit]

      - id: check-script-suite
        name: Check Script Suite (script + test + doc)
        entry: uv run --active tools/scripts/check_script_suite.py
        language: python
        files: ^tools/(scripts/.*\.py|tests/test_.*\.py|docs/scripts_instructions/.*_py_script\.md)$
        pass_filenames: false
        stages: [pre-commit]

      - id: check-adr-index
        name: Check ADR Index
        entry: uv run --active tools/scripts/check_adr_index.py --fix
        language: python
        files: ^architecture/(adr/adr_.*\.md|adr_index\.md)$
        pass_filenames: false
        stages: [pre-commit, manual]

      # ---TESTS of HOOK SCRIPTS---
      # Trigger this whenever any script or test in the scripts
      # directory changes
      - id: test-check-broken-links
        name: Test Check Broken Links script
        entry: uv run --active pytest tools/tests/test_check_broken_links.py
        language: python
        files: ^tools/(scripts/check_broken_links\.py|scripts/paths\.py|tests/test_check_broken_links\.py)$
        pass_filenames: false

      - id: test-check-link-format
        name: Test Check Link Format script
        entry: uv run --active pytest tools/tests/test_check_link_format.py
        language: python
        files: ^tools/(scripts/check_link_format\.py|scripts/paths\.py|tests/test_check_link_format\.py)$
        pass_filenames: false

      - id: test-jupytext-sync
        name: Test Jupytext Sync script
        entry: uv run --active pytest tools/tests/test_jupytext_sync.py
        language: python
        files: ^tools/(scripts/jupytext_sync\.py|scripts/paths\.py|tests/test_jupytext_sync\.py)$
        pass_filenames: false

      - id: test-jupytext-verify-pair
        name: Test Jupytext Verify Pair script
        entry: uv run --active pytest tools/tests/test_jupytext_verify_pair.py
        language: python
        files: ^tools/(scripts/jupytext_verify_pair\.py|scripts/paths\.py|tests/test_jupytext_verify_pair\.py)$
        pass_filenames: false

      - id: test-check-api-keys
        name: Test Check API Keys script
        entry: uv run --active pytest tools/tests/test_check_api_keys.py
        language: python
        files: ^tools/(scripts/check_api_keys\.py|scripts/paths\.py|tests/test_check_api_keys\.py)$
        pass_filenames: false

      - id: test-check-json-files
        name: Test JSON validation script
        entry: uv run --active pytest tools/tests/test_check_json_files.py
        language: system
        files: ^tools/(scripts/check_json_files\.py|scripts/paths\.py|tests/test_check_json_files\.py)$
        pass_filenames: false

      - id: test-prepare-prompt
        name: Test Prepare Prompt script
        entry: uv run --active pytest tools/tests/test_prepare_prompt.py
        language: python
        files: ^tools/(scripts/prepare_prompt\.py|scripts/paths\.py|tests/test_prepare_prompt\.py)$
        pass_filenames: false

      - id: test-check-script-suite
        name: Test Check Script Suite script
        entry: uv run --active pytest tools/tests/test_check_script_suite.py
        language: python
        files: ^tools/(scripts/check_script_suite\.py|scripts/paths\.py|tests/test_check_script_suite\.py)$
        pass_filenames: false

      - id: test-check-adr-index
        name: Test Check ADR Index script
        entry: uv run --active pytest tools/tests/test_check_adr_index.py
        language: python
        files: ^tools/(scripts/check_adr_index\.py|tests/test_check_adr_index\.py)$
        pass_filenames: false
