# 提交前检查:web/(oxlint + prettier + knip,整目录跑均亚秒级)、shell 脚本
# (shellcheck)、deploy/ 的 Dockerfile(hadolint),对应文件有改动即触发。
# 注意:git 根是父仓 model-agent、本配置在子目录 rag/,而 pre-commit 按 git 根
# 匹配 files 且 hook 也在 git 根下运行——故 files 一律带 ^rag/ 前缀、entry 里
# 的相对路径(yarn --cwd、bin/、deploy/…)也一律从父仓根出发。
# 装钩子(一次性):uvx pre-commit install。python 侧 ruff/ty 仍按 AGENTS.md 手动跑。
repos:
  - repo: local
    hooks:
      - id: web-format
        name: prettier check (web/)
        entry: yarn --cwd rag/web format:check
        language: system
        files: ^rag/web/
        pass_filenames: false
      - id: web-lint
        name: oxlint (web/)
        entry: yarn --cwd rag/web lint
        language: system
        files: ^rag/web/
        pass_filenames: false
      - id: web-knip
        name: knip (web/)
        entry: yarn --cwd rag/web knip
        language: system
        files: ^rag/web/
        pass_filenames: false
      - id: shell-lint
        name: shellcheck
        entry: uvx --from shellcheck-py shellcheck
        language: system
        files: ^rag/.*\.sh$
        exclude: ^rag/\.agents/   # vendored agent 技能自带脚本,同 ruff/ty 豁免
      - id: dockerfile-lint
        name: hadolint (deploy/)
        # 首次触发自动下载二进制到 bin/(gitignored);
        # 豁免规则与理由见 .hadolint.yaml
        entry: "bash -c 'cd rag && set -e; [ -x bin/hadolint ] || { mkdir -p bin && gh release download v2.12.0 -R hadolint/hadolint -p hadolint-Linux-x86_64 -O bin/hadolint && chmod +x bin/hadolint; }; bin/hadolint --config .hadolint.yaml deploy/all-in-one/Dockerfile deploy/split/Dockerfile'"
        language: system
        files: ^rag/deploy/.*Dockerfile
        pass_filenames: false