Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

ci: add pre-commit hooks for pdm.lock and version sync (#2116)

LearningCircuit0a8006eaab85
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index 899eedc26d..487951a089 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -29,6 +29,11 @@ jobs:
with:
python-version: '3.12'
+ - name: Set up PDM
+ uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4
+ with:
+ python-version: '3.12'
+
- name: Install system dependencies for SQLCipher
run: |
sudo apt-get update
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6940910218..b3ff2b791e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -172,6 +172,19 @@ repos:
files: \.(py|json)$
description: "Ensure search engine module_path values use relative imports, not
absolute paths"
+ - id: check-pdm-lock
+ name: Check pdm.lock sync
+ entry: .pre-commit-hooks/check-pdm-lock.sh
+ language: script
+ files: ^pyproject\.toml$
+ description: "Ensure pdm.lock is up-to-date with pyproject.toml"
+ - id: check-version-sync
+ name: Check Version Sync
+ entry: .pre-commit-hooks/check-version-sync.py
+ language: script
+ files: ^(package\.json|src/local_deep_research/__version__\.py)$
+ pass_filenames: false
+ description: "Ensure package.json version matches src/local_deep_research/__version__.py"
- id: recommend-docs
name: Documentation Reminder
entry: .pre-commit-hooks/recommend-docs.py
diff --git a/.pre-commit-hooks/check-pdm-lock.sh b/.pre-commit-hooks/check-pdm-lock.sh
new file mode 100755
index 0000000000..603ec585bb
--- /dev/null
+++ b/.pre-commit-hooks/check-pdm-lock.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Check if pdm.lock is in sync with pyproject.toml
+
+set -e
+
+echo "Checking pdm.lock is up-to-date..."
+
+if ! pdm lock --check 2>/dev/null; then
+ echo ""
+ echo "ERROR: pdm.lock is out of sync with pyproject.toml!"
+ echo ""
+ echo "Run this to fix:"
+ echo " pdm lock"
+ echo " git add pdm.lock"
+ echo ""
+ exit 1
+fi
+
+echo "pdm.lock is up-to-date."
diff --git a/.pre-commit-hooks/check-version-sync.py b/.pre-commit-hooks/check-version-sync.py
new file mode 100755
index 0000000000..dbb2371736
--- /dev/null
+++ b/.pre-commit-hooks/check-version-sync.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+"""Check that package.json version matches __version__.py."""
+
+import json
+import re
+import sys
+from pathlib import Path
+
+
+def main():
+ root = Path(__file__).parent.parent
+
+ # Read __version__.py
+ version_file = root / "src" / "local_deep_research" / "__version__.py"
+ if not version_file.exists():
+ print(f"ERROR: Version file not found: {version_file}")
+ return 1
+
+ try:
+ version_content = version_file.read_text()
+ except OSError as e:
+ print(f"ERROR: Could not read {version_file}: {e}")
+ return 1
+
+ match = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', version_content)
+ if not match:
+ print("ERROR: Could not parse __version__.py")
+ return 1
+ py_version = match.group(1)
+
+ # Read package.json
+ package_file = root / "package.json"
+ if not package_file.exists():
+ print(f"ERROR: package.json not found: {package_file}")
+ return 1
+
+ try:
+ package_content = package_file.read_text()
+ package_data = json.loads(package_content)
+ except OSError as e:
+ print(f"ERROR: Could not read {package_file}: {e}")
+ return 1
+ except json.JSONDecodeError as e:
+ print(f"ERROR: Invalid JSON in {package_file}: {e}")
+ return 1
+
+ js_version = package_data.get("version", "")
+ if not js_version:
+ print("ERROR: No 'version' field found in package.json")
+ return 1
+
+ if py_version != js_version:
+ print("ERROR: Version mismatch!")
+ print(f" __version__.py: {py_version}")
+ print(f" package.json: {js_version}")
+ print()
+ print("Fix by updating one of the files to match.")
+ return 1
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())