fss-mini-rag-github/rag-mini-enhanced
BobAi 4166d0a362 Initial release: FSS-Mini-RAG - Lightweight semantic code search system
🎯 Complete transformation from 5.9GB bloated system to 70MB optimized solution

 Key Features:
- Hybrid embedding system (Ollama + ML fallback + hash backup)
- Intelligent chunking with language-aware parsing
- Semantic + BM25 hybrid search with rich context
- Zero-config portable design with graceful degradation
- Beautiful TUI for beginners + powerful CLI for experts
- Comprehensive documentation with 8+ Mermaid diagrams
- Professional animated demo (183KB optimized GIF)

🏗️ Architecture Highlights:
- LanceDB vector storage with streaming indexing
- Smart file tracking (size/mtime) to avoid expensive rehashing
- Progressive chunking: Markdown headers → Python functions → fixed-size
- Quality filtering: 200+ chars, 20+ words, 30% alphanumeric content
- Concurrent batch processing with error recovery

📦 Package Contents:
- Core engine: claude_rag/ (11 modules, 2,847 lines)
- Entry points: rag-mini (unified), rag-tui (beginner interface)
- Documentation: README + 6 guides with visual diagrams
- Assets: 3D icon, optimized demo GIF, recording tools
- Tests: 8 comprehensive integration and validation tests
- Examples: Usage patterns, config templates, dependency analysis

🎥 Demo System:
- Scripted demonstration showing 12 files → 58 chunks indexing
- Semantic search with multi-line result previews
- Complete workflow from TUI startup to CLI mastery
- Professional recording pipeline with asciinema + GIF conversion

🛡️ Security & Quality:
- Complete .gitignore with personal data protection
- Dependency optimization (removed python-dotenv)
- Code quality validation and educational test suite
- Agent-reviewed architecture and documentation

Ready for production use - copy folder, run ./rag-mini, start searching\!
2025-08-12 16:38:28 +10:00

167 lines
5.3 KiB
Bash
Executable File

#!/bin/bash
# rag-mini-enhanced - FSS-Mini-RAG with smart features
# Enhanced version with intelligent defaults and better UX
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PYTHON="$SCRIPT_DIR/.venv/bin/python3"
# Check if venv exists
if [ ! -f "$PYTHON" ]; then
echo "❌ Virtual environment not found at $SCRIPT_DIR/.venv"
exit 1
fi
# Enhanced search with smart features
smart_search() {
local project_path="$1"
local query="$2"
local limit="${3:-5}"
# Smart query enhancement
enhanced_query="$query"
# Add context clues based on query type
if [[ "$query" =~ ^[A-Z][a-zA-Z]*$ ]]; then
# Looks like a class name
enhanced_query="class $query OR function $query OR def $query"
elif [[ "$query" =~ [a-z_]+\(\) ]]; then
# Looks like a function call
func_name="${query%()}"
enhanced_query="def $func_name OR function $func_name"
fi
echo "🔍 Smart search: '$enhanced_query' in $project_path"
"$PYTHON" "$SCRIPT_DIR/rag-mini.py" search "$project_path" "$enhanced_query" --limit "$limit"
# Show related suggestions
echo ""
echo "💡 Try also:"
echo " rag-mini-enhanced context '$project_path' '$query' # Show surrounding code"
echo " rag-mini-enhanced similar '$project_path' '$query' # Find similar patterns"
}
# Context-aware search
context_search() {
local project_path="$1"
local query="$2"
echo "📖 Context search for: '$query'"
"$PYTHON" "$SCRIPT_DIR/rag-mini.py" search "$project_path" "$query" --limit 3
# TODO: Add context expansion here
echo " (Context expansion not yet implemented)"
}
# Similar pattern search
similar_search() {
local project_path="$1"
local query="$2"
echo "🔄 Finding similar patterns to: '$query'"
# Use semantic search with pattern-focused terms
pattern_query="similar to $query OR like $query OR pattern $query"
"$PYTHON" "$SCRIPT_DIR/rag-mini.py" search "$project_path" "$pattern_query" --limit 5
}
# Smart indexing with optimizations
smart_index() {
local project_path="$1"
local force="$2"
echo "🧠 Smart indexing: $project_path"
# Check if we can optimize first
if [ -f "$project_path/.claude-rag/manifest.json" ]; then
echo "📊 Analyzing current index for optimization..."
"$PYTHON" "$SCRIPT_DIR/smart_config_suggestions.py" "$project_path/.claude-rag/manifest.json"
echo ""
fi
# Run indexing
if [ "$force" = "--force" ]; then
"$PYTHON" "$SCRIPT_DIR/rag-mini.py" index "$project_path" --force
else
"$PYTHON" "$SCRIPT_DIR/rag-mini.py" index "$project_path"
fi
}
# Enhanced status with recommendations
smart_status() {
local project_path="$1"
"$PYTHON" "$SCRIPT_DIR/rag-mini.py" status "$project_path"
# Add smart recommendations
if [ -f "$project_path/.claude-rag/manifest.json" ]; then
echo ""
echo "🎯 Quick Recommendations:"
# Count files vs chunks ratio
files=$(jq -r '.file_count // 0' "$project_path/.claude-rag/manifest.json")
chunks=$(jq -r '.chunk_count // 0' "$project_path/.claude-rag/manifest.json")
if [ "$files" -gt 0 ]; then
ratio=$(echo "scale=1; $chunks / $files" | bc -l 2>/dev/null || echo "1.5")
if (( $(echo "$ratio < 1.2" | bc -l 2>/dev/null || echo 0) )); then
echo " 💡 Low chunk ratio ($ratio) - consider smaller chunk sizes"
elif (( $(echo "$ratio > 3" | bc -l 2>/dev/null || echo 0) )); then
echo " 💡 High chunk ratio ($ratio) - consider larger chunk sizes"
else
echo " ✅ Good chunk ratio ($ratio chunks/file)"
fi
fi
echo " 💡 Run 'rag-mini-enhanced analyze $project_path' for detailed suggestions"
fi
}
# Show usage
show_usage() {
echo "FSS-Mini-RAG Enhanced - Smart semantic code search"
echo ""
echo "Usage:"
echo " rag-mini-enhanced <command> <project_path> [options]"
echo ""
echo "Commands:"
echo " index <path> [--force] Smart indexing with optimizations"
echo " search <path> <query> Enhanced semantic search"
echo " context <path> <query> Context-aware search"
echo " similar <path> <query> Find similar code patterns"
echo " status <path> Status with recommendations"
echo " analyze <path> Deep analysis and suggestions"
echo ""
echo "Examples:"
echo " rag-mini-enhanced search /project 'user authentication'"
echo " rag-mini-enhanced context /project 'login()'"
echo " rag-mini-enhanced similar /project 'def process_data'"
}
# Main dispatch
case "$1" in
"index")
smart_index "$2" "$3"
;;
"search")
smart_search "$2" "$3" "$4"
;;
"context")
context_search "$2" "$3"
;;
"similar")
similar_search "$2" "$3"
;;
"status")
smart_status "$2"
;;
"analyze")
if [ -f "$2/.claude-rag/manifest.json" ]; then
"$PYTHON" "$SCRIPT_DIR/smart_config_suggestions.py" "$2/.claude-rag/manifest.json"
else
echo "❌ No index found. Run 'rag-mini-enhanced index $2' first"
fi
;;
*)
show_usage
;;
esac