103 lines
3.3 KiB
YAML
103 lines
3.3 KiB
YAML
# Pre-commit configuration for CleverAgents
|
|
# See https://pre-commit.com for more information
|
|
# Install: pre-commit install
|
|
# Run manually: pre-commit run --all-files
|
|
|
|
default_language_version:
|
|
python: python3.13
|
|
|
|
repos:
|
|
# ----- Branch Protection & General Checks -----
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v4.6.0
|
|
hooks:
|
|
- id: no-commit-to-branch
|
|
name: Prevent direct commits to master
|
|
args: ["--branch", "master"]
|
|
- id: check-yaml
|
|
name: Validate YAML syntax
|
|
- id: check-toml
|
|
name: Validate TOML syntax
|
|
- id: check-json
|
|
name: Validate JSON syntax
|
|
exclude: "^\\.vscode/"
|
|
- id: check-merge-conflict
|
|
name: Check for merge conflicts
|
|
- id: check-added-large-files
|
|
name: Prevent large file commits
|
|
args: ["--maxkb=500"]
|
|
- id: end-of-file-fixer
|
|
name: Fix end of file
|
|
- id: trailing-whitespace
|
|
name: Trim trailing whitespace
|
|
args: ["--markdown-linebreak-ext=md"]
|
|
- id: debug-statements
|
|
name: Detect debug statements (pdb, breakpoint)
|
|
|
|
# ----- Ruff: Formatting & Linting -----
|
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
rev: v0.15.0
|
|
hooks:
|
|
- id: ruff-format
|
|
name: Ruff format (auto-fix)
|
|
- id: ruff
|
|
name: Ruff lint (auto-fix safe rules)
|
|
args: ["--fix", "--exit-non-zero-on-fix"]
|
|
|
|
# ----- Bandit: Security Scanning -----
|
|
- repo: https://github.com/PyCQA/bandit
|
|
rev: 1.8.3
|
|
hooks:
|
|
- id: bandit
|
|
name: Bandit security scan
|
|
args: ["-c", "pyproject.toml", "-r", "--severity-level", "medium"]
|
|
additional_dependencies: ["bandit[toml]"]
|
|
files: "^src/"
|
|
|
|
# ----- Vulture: Dead Code Detection -----
|
|
- repo: https://github.com/jendrikseipp/vulture
|
|
rev: v2.14
|
|
hooks:
|
|
- id: vulture
|
|
name: Vulture dead code detection
|
|
args:
|
|
[
|
|
"src/cleveragents",
|
|
"vulture_whitelist.py",
|
|
"--min-confidence",
|
|
"80",
|
|
"--exclude",
|
|
"src/cleveragents/discovery",
|
|
]
|
|
pass_filenames: false
|
|
|
|
# ----- Local Hooks (use installed tools) -----
|
|
- repo: local
|
|
hooks:
|
|
# Pyright: Type Checking (runs serially, uses local installation)
|
|
- id: pyright
|
|
name: Pyright type checking
|
|
language: system
|
|
entry: pyright
|
|
types: [python]
|
|
files: "^src/"
|
|
pass_filenames: false
|
|
stages: [pre-commit]
|
|
# Semgrep: Advanced security scanning for eval/exec detection
|
|
- id: semgrep-eval-exec
|
|
name: Semgrep eval/exec detection
|
|
language: system
|
|
entry: semgrep --config=.semgrep.yml --error --quiet src/
|
|
types: [python]
|
|
files: "^src/"
|
|
pass_filenames: false
|
|
stages: [pre-commit]
|
|
|
|
# ----- Commit Message Linting -----
|
|
- repo: https://github.com/commitizen-tools/commitizen
|
|
rev: v4.2.2
|
|
hooks:
|
|
- id: commitizen
|
|
name: Conventional commit message check
|
|
stages: [commit-msg]
|