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.

1.4 KB
Raw Blame
#!/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())