feat(codex-lens): add unified reranker architecture and file watcher

Unified Reranker Architecture:
- Add BaseReranker ABC with factory pattern
- Implement 4 backends: ONNX (default), API, LiteLLM, Legacy
- Add .env configuration parsing for API credentials
- Migrate from sentence-transformers to optimum+onnxruntime

File Watcher Module:
- Add real-time file system monitoring with watchdog
- Implement IncrementalIndexer for single-file updates
- Add WatcherManager with signal handling and graceful shutdown
- Add 'codexlens watch' CLI command
- Event filtering, debouncing, and deduplication
- Thread-safe design with proper resource cleanup

Tests: 16 watcher tests + 5 reranker test files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
catlog22
2026-01-01 13:23:52 +08:00
parent 8ac27548ad
commit 520f2d26f2
27 changed files with 3571 additions and 14 deletions

66
codex-lens/.env.example Normal file
View File

@@ -0,0 +1,66 @@
# CodexLens Environment Configuration
# Copy this file to .codexlens/.env and fill in your values
#
# Priority order:
# 1. Environment variables (already set in shell)
# 2. .codexlens/.env (workspace-local, this file)
# 3. .env (project root)
# ============================================
# RERANKER Configuration
# ============================================
# API key for reranker service (SiliconFlow/Cohere/Jina)
# Required for 'api' backend
# RERANKER_API_KEY=sk-xxxx
# Base URL for reranker API (overrides provider default)
# SiliconFlow: https://api.siliconflow.cn
# Cohere: https://api.cohere.ai
# Jina: https://api.jina.ai
# RERANKER_API_BASE=https://api.siliconflow.cn
# Reranker provider: siliconflow, cohere, jina
# RERANKER_PROVIDER=siliconflow
# Reranker model name
# SiliconFlow: BAAI/bge-reranker-v2-m3
# Cohere: rerank-english-v3.0
# Jina: jina-reranker-v2-base-multilingual
# RERANKER_MODEL=BAAI/bge-reranker-v2-m3
# ============================================
# EMBEDDING Configuration
# ============================================
# API key for embedding service (for litellm backend)
# EMBEDDING_API_KEY=sk-xxxx
# Base URL for embedding API
# EMBEDDING_API_BASE=https://api.openai.com
# Embedding model name
# EMBEDDING_MODEL=text-embedding-3-small
# ============================================
# LITELLM Configuration
# ============================================
# API key for LiteLLM (for litellm reranker backend)
# LITELLM_API_KEY=sk-xxxx
# Base URL for LiteLLM
# LITELLM_API_BASE=
# LiteLLM model name
# LITELLM_MODEL=gpt-4o-mini
# ============================================
# General Configuration
# ============================================
# Custom data directory path (default: ~/.codexlens)
# CODEXLENS_DATA_DIR=~/.codexlens
# Enable debug mode (true/false)
# CODEXLENS_DEBUG=false