🎯 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\!
68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Basic usage example for FSS-Mini-RAG.
|
|
Shows how to index a project and search it programmatically.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from claude_rag import ProjectIndexer, CodeSearcher, CodeEmbedder
|
|
|
|
def main():
|
|
# Example project path - change this to your project
|
|
project_path = Path(".") # Current directory
|
|
|
|
print("=== FSS-Mini-RAG Basic Usage Example ===")
|
|
print(f"Project: {project_path}")
|
|
|
|
# Initialize the embedding system
|
|
print("\n1. Initializing embedding system...")
|
|
embedder = CodeEmbedder()
|
|
print(f" Using: {embedder.get_embedding_info()['method']}")
|
|
|
|
# Initialize indexer and searcher
|
|
indexer = ProjectIndexer(project_path, embedder)
|
|
searcher = CodeSearcher(project_path, embedder)
|
|
|
|
# Index the project
|
|
print("\n2. Indexing project...")
|
|
result = indexer.index_project()
|
|
|
|
print(f" Files processed: {result.get('files_processed', 0)}")
|
|
print(f" Chunks created: {result.get('chunks_created', 0)}")
|
|
print(f" Time taken: {result.get('indexing_time', 0):.2f}s")
|
|
|
|
# Get index statistics
|
|
print("\n3. Index statistics:")
|
|
stats = indexer.get_stats()
|
|
print(f" Total files: {stats.get('total_files', 0)}")
|
|
print(f" Total chunks: {stats.get('total_chunks', 0)}")
|
|
print(f" Languages: {', '.join(stats.get('languages', []))}")
|
|
|
|
# Example searches
|
|
queries = [
|
|
"chunker function",
|
|
"embedding system",
|
|
"search implementation",
|
|
"file watcher",
|
|
"error handling"
|
|
]
|
|
|
|
print("\n4. Example searches:")
|
|
for query in queries:
|
|
print(f"\n Query: '{query}'")
|
|
results = searcher.search(query, limit=3)
|
|
|
|
if results:
|
|
for i, result in enumerate(results, 1):
|
|
print(f" {i}. {result.file_path.name} (score: {result.score:.3f})")
|
|
print(f" Type: {result.chunk_type}")
|
|
# Show first 60 characters of content
|
|
content_preview = result.content.replace('\n', ' ')[:60]
|
|
print(f" Preview: {content_preview}...")
|
|
else:
|
|
print(" No results found")
|
|
|
|
print("\n=== Example Complete ===")
|
|
|
|
if __name__ == "__main__":
|
|
main() |