#!/bin/bash # Rust-specific pre-edit hook for RuVector # Runs cargo check, clippy hints, and detects crate context set -e FILE="$1" if [ -z "$FILE" ]; then echo "Usage: $0 " exit 1 fi EXT="${FILE##*.}" if [ "$EXT" != "rs" ]; then exit 0 # Not a Rust file fi cd /workspaces/ruvector # Detect which crate this file belongs to CRATE_DIR=$(echo "$FILE" | grep -oP "crates/[^/]+" | head -1 || echo "") CRATE_NAME="" if [ -n "$CRATE_DIR" ]; then CRATE_NAME=$(basename "$CRATE_DIR") echo "πŸ¦€ Crate: $CRATE_NAME" # Show crate-specific context case "$CRATE_NAME" in "ruvector-core") echo " πŸ“Š Core vector engine (HNSW, SIMD, quantization)" echo " πŸ“¦ Key: VectorStore, HnswIndex, Distance metrics" ;; "rvlite") echo " 🌐 WASM standalone DB (SQL/SPARQL/Cypher)" echo " πŸ“¦ Key: RvLite, SqlExecutor, CypherParser" echo " ⚠️ Size target: <3MB gzipped" ;; "ruvector-wasm") echo " 🌐 WASM bindings for ruvector-core" echo " πŸ“¦ Key: WasmVectorStore, IndexedDB storage" ;; "ruvector-graph"|"ruvector-graph-wasm"|"ruvector-graph-node") echo " πŸ•ΈοΈ Graph database with Cypher support" echo " πŸ“¦ Key: GraphStore, CypherQuery, HyperEdge" ;; "ruvector-gnn"|"ruvector-gnn-wasm"|"ruvector-gnn-node") echo " 🧠 Graph Neural Networks (GCN, GraphSAGE, GAT)" echo " πŸ“¦ Key: GnnLayer, MessagePassing, Aggregation" ;; "ruvector-postgres") echo " 🐘 PostgreSQL extension (pgvector compatible)" echo " πŸ“¦ Key: pgrx, SQL functions, background workers" ;; "sona") echo " πŸŽ“ ReasoningBank with 9 RL algorithms" echo " πŸ“¦ Key: Trajectory, Verdict, LoRA, EWC++" ;; "ruvector-mincut"|"ruvector-mincut-wasm"|"ruvector-mincut-node") echo " βœ‚οΈ Subpolynomial dynamic min-cut algorithm" echo " πŸ“¦ Key: ContractedGraph, LambdaCut, SparseCertificate" ;; "ruvector-attention"|"ruvector-attention-wasm"|"ruvector-attention-node") echo " πŸ‘οΈ 39+ attention mechanisms" echo " πŸ“¦ Key: MultiHeadAttention, GeometricAttention" ;; "ruvector-tiny-dancer"|"ruvector-tiny-dancer-wasm"|"ruvector-tiny-dancer-node") echo " πŸ’ƒ FastGRNN neural router for agents" echo " πŸ“¦ Key: Router, FastGRNN, CircuitBreaker" ;; "ruvector-cli") echo " ⌨️ CLI and MCP server" echo " πŸ“¦ Key: Commands, MCP protocol, REST API" ;; *) echo " πŸ“¦ Crate: $CRATE_NAME" ;; esac # Quick cargo check for the specific crate echo "" echo "πŸ” Running cargo check -p $CRATE_NAME..." if cargo check -p "$CRATE_NAME" --message-format=short 2>&1 | head -10; then echo "βœ… Cargo check passed" else echo "⚠️ Check for warnings/errors above" fi fi # Check for WASM-related files if echo "$FILE" | grep -qE "wasm|rvlite"; then echo "" echo "πŸ“ WASM file detected - size considerations apply" echo " Target: <3MB gzipped for rvlite" fi echo ""