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.

chore(pre-commit): add recommend-vitest nudge for frontend JS changes (#4262)

LearningCircuitd621b4197c09
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2ded2f6702..a96d5c53cd 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -309,6 +309,14 @@ repos:
always_run: true
verbose: true
description: "Direct recommendation to include tests when source files change"
+ - id: recommend-vitest
+ name: Vitest Coverage Nudge
+ entry: .pre-commit-hooks/recommend-vitest.py
+ language: script
+ pass_filenames: false
+ always_run: true
+ verbose: true
+ description: "Nudge to add vitest tests when frontend JS source changes lack them"
- id: recommend-performance-tests
name: Performance Test Reminder
entry: .pre-commit-hooks/recommend-performance-tests.py
diff --git a/.pre-commit-hooks/recommend-vitest.py b/.pre-commit-hooks/recommend-vitest.py
new file mode 100755
index 0000000000..c546bd7f5a
--- /dev/null
+++ b/.pre-commit-hooks/recommend-vitest.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+"""Nudge toward vitest tests when frontend JS source changes lack them.
+
+Always exits 0 (non-blocking). Prints when staged JS source files under
+src/.../static/js/ have no companion vitest tests staged. Sibling of
+recommend-tests.py but vitest-specific so a Python-test-only commit
+doesn't suppress the JS nudge.
+"""
+
+import sys
+from pathlib import Path
+
+# Allow importing sibling module
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+
+from _commit_analysis import analyze_commit, suggest_test_path
+
+
+def main():
+ analysis = analyze_commit()
+
+ js_sources = [f for f in analysis.source_files if f.path.endswith(".js")]
+ if not js_sources:
+ return 0
+
+ vitest_tests = [
+ f for f in analysis.test_files if f.path.endswith(".test.js")
+ ]
+ if vitest_tests:
+ return 0
+
+ print()
+ print(" \033[33mVitest Coverage Nudge\033[0m")
+ print(" " + "-" * 40)
+ print(
+ f" You're committing {len(js_sources)} frontend JS source file(s) "
+ "with no vitest tests."
+ )
+ print()
+ print(" Files and suggested test paths:")
+ for f in js_sources:
+ print(f" {f.path} (+{f.added} lines)")
+ print(f" -> {suggest_test_path(f.path)}")
+ print()
+ print(
+ " Vitest already runs in CI (docker-tests.yml). Run locally: npm test"
+ )
+ print()
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())