default_install_hook_types:
  - pre-commit
  - commit-msg
default_stages:
  - pre-commit
exclude: ^target/|\.alef/
repos:
  - repo: local
    hooks:
      - id: no-project-special-casing
        name: no project-name special casing
        entry: hooks/check_project_mentions.py
        language: python
        types:
          - text
      - id: no-backend-local-naming-helpers
        name: no backend-local naming helpers
        entry: hooks/check_backend_naming_helpers.py
        language: python
        pass_filenames: false

  - repo: https://github.com/Goldziher/gitfluff
    rev: v0.8.0
    hooks:
      - id: gitfluff-lint
        args:
          - --write
        stages:
          - commit-msg

  - repo: https://github.com/kreuzberg-dev/pre-commit-hooks
    rev: v2.1.0
    hooks:
      # AI governance
      - id: ai-rulez-generate

      # File safety (general)
      - id: trailing-whitespace
      - id: end-of-file-fixer
        exclude: ^src/backends/php/templates/php_file_header\.jinja$
      - id: check-merge-conflict
      - id: check-added-large-files
      - id: detect-private-key
      - id: check-case-conflict
      - id: check-executables-have-shebangs
      - id: check-shebang-scripts-are-executable
        exclude: \.(jinja|rs)$
      - id: mixed-line-ending
      - id: typos
        args:
          - --force-exclude
      - id: check-json
      - id: check-yaml
        args:
          - --allow-multiple-documents
          - --unsafe
      - id: check-toml

      # GitHub Actions
      - id: actionlint
      - id: gh-actions-updater

      # Shell
      - id: shfmt
        args:
          - -w
          - -i
          - "2"
      - id: shellcheck

      # Markdown
      - id: rumdl-fmt
      - id: markdownlint-rumdl-strict
        exclude: ^(\.ai-rulez/|CHANGELOG\.md|README\.md|docs/design/|skills/alef/)
      - id: textlint
        exclude: ^docs/design/

      # Rust (canonical block; cargo-check dropped — cargo-clippy with -D warnings supersedes it)
      - id: cargo-fmt
        args:
          - --all
      - id: cargo-clippy
        args:
          - --fix
          - --allow-dirty
          - --allow-staged
          - --all-targets
          - --
          - -D
          - warnings
      - id: cargo-sort
      - id: cargo-machete
      - id: cargo-deny
        args:
          - check
      - id: rustdoc-lint
      # Enforces the file-modularization rule (CLAUDE.md): 1,000 LOC ceiling per .rs file.
      # The exclude list tracks the file-modularization remediation backlog —
      # existing files over the cap that need splitting. New files are subject
      # to the cap. Shrink this list as files are split.
      - id: rust-max-lines
        args:
          - --max=1000
        exclude: ^(src/backends/csharp/gen_bindings/methods\.rs|src/backends/csharp/gen_bindings/types\.rs|src/backends/csharp/trait_bridge\.rs|src/backends/dart/frb_rewrite\.rs|src/backends/dart/gen_bindings/service_api\.rs|src/backends/dart/gen_rust_crate/bridge_fn\.rs|src/backends/dart/gen_rust_crate/trait_bridge\.rs|src/backends/ffi/gen_bindings/functions\.rs|src/backends/ffi/gen_bindings/service_api\.rs|src/backends/ffi/gen_visitor\.rs|src/backends/go/gen_bindings/functions\.rs|src/backends/go/gen_bindings/methods\.rs|src/backends/go/gen_bindings/service_api\.rs|src/backends/go/trait_bridge\.rs|src/backends/java/gen_bindings/ffi_class\.rs|src/backends/java/gen_bindings/trait_bridge\.rs|src/backends/jni/gen_shims\.rs|src/backends/kotlin/gen_bindings/jni_emitter\.rs|src/backends/kotlin/gen_bindings/object_wrapper\.rs|src/backends/kotlin_android/gen_bindings\.rs|src/backends/magnus/gen_bindings/classes\.rs|src/backends/magnus/gen_bindings/functions\.rs|src/backends/magnus/gen_bindings/mod\.rs|src/backends/magnus/gen_bindings/service_api\.rs|src/backends/magnus/trait_bridge\.rs|src/backends/napi/gen_bindings/functions\.rs|src/backends/napi/trait_bridge\.rs|src/backends/php/gen_bindings/functions\.rs|src/backends/php/gen_bindings/helpers\.rs|src/backends/php/gen_bindings/service_api\.rs|src/backends/php/gen_bindings/types\.rs|src/backends/php/trait_bridge\.rs|src/backends/pyo3/gen_bindings/functions\.rs|src/backends/pyo3/gen_bindings/service_api\.rs|src/backends/pyo3/trait_bridge\.rs|src/backends/rustler/gen_bindings/functions\.rs|src/backends/rustler/gen_bindings/helpers\.rs|src/backends/rustler/gen_bindings/service_api\.rs|src/backends/rustler/gen_bindings/types\.rs|src/backends/rustler/template_env\.rs|src/backends/rustler/trait_bridge\.rs|src/backends/swift/gen_bindings/service_api\.rs|src/backends/swift/gen_rust_crate/plugin_inbound\.rs|src/backends/swift/gen_rust_crate/wrappers\.rs|src/backends/swift/template_env\.rs|src/backends/wasm/gen_bindings/enums\.rs|src/backends/wasm/gen_bindings/functions\.rs|src/backends/zig/gen_bindings/opaque_handles\.rs|src/backends/zig/trait_bridge\.rs|src/cli/pipeline/commands\.rs|src/cli/pipeline/extract\.rs|src/cli/pipeline/generate\.rs|src/codegen/conversions/binding_to_core\.rs|src/codegen/conversions/core_to_binding\.rs|src/codegen/conversions/helpers\.rs|src/codegen/generators/binding_helpers\.rs|src/codegen/generators/methods\.rs|src/codegen/naming\.rs|src/core/config/e2e\.rs|src/core/config/languages\.rs|src/core/config/new_config\.rs|src/core/config/output\.rs|src/core/hash\.rs|src/core/keywords\.rs|src/docs/doc_cleaning\.rs|src/docs/signatures\.rs|src/docs/type_mapping\.rs|src/e2e/codegen/kotlin_android\.rs|src/e2e/codegen/python/test_function\.rs|src/e2e/codegen/r\.rs|src/e2e/codegen/rust/mock_server\.rs|src/e2e/codegen/rust/test_file\.rs|src/e2e/codegen/streaming_assertions\.rs|src/extract/extractor/functions\.rs|src/extract/extractor/helpers\.rs|src/extract/extractor/service\.rs|src/main\.rs|src/publish/vendor\.rs)$

      # Python — repo-internal pre-commit helper scripts only
      - id: ruff
        files: ^hooks/.*\.py$
      - id: ruff-format
        files: ^hooks/.*\.py$
      - id: mypy
        files: ^hooks/.*\.py$

      # JSON / generated manifest formatting (no JS/TS in this repo, but oxfmt covers JSON)
      - id: oxfmt
