Spaces:
Running
Running
Asish Karthikeya Gogineni commited on
Commit Β·
23a9623
1
Parent(s): 7dec411
docs: Organize project with clear README and clean exports
Browse files- README.md +125 -52
- code_chatbot/__init__.py +35 -0
README.md
CHANGED
|
@@ -1,71 +1,144 @@
|
|
| 1 |
-
# Codebase Agent
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
-
|
| 15 |
-
- **π Universal Ingestion**: Upload ZIP files or point to GitHub repositories.
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
-
|
| 20 |
-
-
|
| 21 |
-
- **π§© Semantic Chunking**: AST-based code splitting that respects function/class boundaries
|
| 22 |
-
- **π Rich Metadata**: Automatic extraction of symbols, imports, and cyclomatic complexity
|
| 23 |
-
- **π― Hybrid Search**: Combines semantic similarity with keyword matching
|
| 24 |
-
- **βοΈ Highly Configurable**: Fine-tune chunking, retrieval, and privacy settings
|
| 25 |
-
|
| 26 |
-
**[π Read the Technical Deep-Dive](docs/RAG_PIPELINE.md)** to understand how our RAG pipeline works.
|
| 27 |
|
| 28 |
## π Quick Start
|
| 29 |
|
| 30 |
-
1.
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
```bash
|
| 38 |
-
pip install -r requirements.txt
|
| 39 |
-
```
|
| 40 |
|
| 41 |
-
|
| 42 |
-
```bash
|
| 43 |
-
streamlit run app.py
|
| 44 |
-
```
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
- Enter your API Key (e.g., Gemini or Groq) in the sidebar
|
| 49 |
-
- Upload a `.zip` of your code or provide a GitHub URL
|
| 50 |
-
- Start chatting!
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
##
|
| 61 |
|
| 62 |
-
|
| 63 |
-
- **Streamlit** for the UI
|
| 64 |
-
- **LangChain** for orchestration
|
| 65 |
-
- **ChromaDB** for vector storage
|
| 66 |
-
- **NetworkX** for code graph analysis
|
| 67 |
-
- **Tree-sitter** for robust parsing
|
| 68 |
|
| 69 |
-
## License
|
| 70 |
|
| 71 |
-
|
|
|
|
| 1 |
+
# π·οΈ Code Crawler - Intelligent Codebase Agent
|
| 2 |
|
| 3 |
+
An AI-powered codebase assistant that understands your code and helps you navigate, analyze, and modify it. Built with RAG (Retrieval-Augmented Generation), MCP (Model Context Protocol), and CrewAI multi-agent workflows.
|
| 4 |
|
| 5 |
+
## β¨ Features
|
| 6 |
|
| 7 |
+
### π¬ Chat Mode
|
| 8 |
+
- Ask questions about your codebase
|
| 9 |
+
- Get explanations of functions, modules, and workflows
|
| 10 |
+
- Understand code architecture and data flow
|
| 11 |
|
| 12 |
+
### π Search Mode (MCP-Powered)
|
| 13 |
+
- Regex pattern matching across your entire codebase
|
| 14 |
+
- Context-aware search results with surrounding code
|
| 15 |
+
- File pattern filtering (glob)
|
| 16 |
|
| 17 |
+
### π§ Refactor Mode (MCP-Powered)
|
| 18 |
+
- Automated search-and-replace refactorings
|
| 19 |
+
- Dry-run preview before applying changes
|
| 20 |
+
- Common refactoring patterns built-in
|
|
|
|
| 21 |
|
| 22 |
+
### β¨ Generate Mode (AI-Powered)
|
| 23 |
+
- Generate complete features from descriptions
|
| 24 |
+
- Follows your codebase's existing patterns
|
| 25 |
+
- Includes tests and documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## π Quick Start
|
| 28 |
|
| 29 |
+
### 1. Install Dependencies
|
| 30 |
+
```bash
|
| 31 |
+
pip install -r requirements.txt
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
### 2. Set Environment Variables
|
| 35 |
+
```bash
|
| 36 |
+
export GOOGLE_API_KEY="your-api-key"
|
| 37 |
+
```
|
| 38 |
+
Or create a `.env` file:
|
| 39 |
+
```
|
| 40 |
+
GOOGLE_API_KEY=your-api-key
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
### 3. Run the App
|
| 44 |
+
```bash
|
| 45 |
+
streamlit run app.py
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
### 4. Use the App
|
| 49 |
+
1. Upload a ZIP file of your codebase
|
| 50 |
+
2. Click "Process & Index"
|
| 51 |
+
3. Start chatting or switch modes!
|
| 52 |
+
|
| 53 |
+
## π Project Structure
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
Codebase_Agent/
|
| 57 |
+
βββ app.py # Main Streamlit application
|
| 58 |
+
β
|
| 59 |
+
βββ code_chatbot/ # Core library
|
| 60 |
+
β β
|
| 61 |
+
β βββ Core RAG Engine
|
| 62 |
+
β βββ rag.py # Chat engine with RAG
|
| 63 |
+
β βββ prompts.py # System prompts
|
| 64 |
+
β βββ config.py # Centralized configuration
|
| 65 |
+
β β
|
| 66 |
+
β βββ Indexing & Chunking
|
| 67 |
+
β βββ indexer.py # Vector database indexing
|
| 68 |
+
β βββ chunker.py # AST-aware code chunking
|
| 69 |
+
β βββ merkle_tree.py # Incremental change detection
|
| 70 |
+
β βββ incremental_indexing.py # Incremental indexing logic
|
| 71 |
+
β βββ indexing_progress.py # Progress tracking UI
|
| 72 |
+
β βββ path_obfuscator.py # Privacy-preserving paths
|
| 73 |
+
β β
|
| 74 |
+
β βββ Retrieval
|
| 75 |
+
β βββ retriever_wrapper.py # Enhanced retriever
|
| 76 |
+
β βββ llm_retriever.py # LLM-based retrieval
|
| 77 |
+
β βββ reranker.py # Result reranking
|
| 78 |
+
β βββ graph_rag.py # Graph-enhanced RAG
|
| 79 |
+
β β
|
| 80 |
+
β βββ Code Analysis
|
| 81 |
+
β βββ ast_analysis.py # AST parsing & call graphs
|
| 82 |
+
β βββ code_symbols.py # Symbol extraction
|
| 83 |
+
β β
|
| 84 |
+
β βββ MCP Tools
|
| 85 |
+
β βββ mcp_server.py # MCP server (search, refactor)
|
| 86 |
+
β βββ mcp_client.py # MCP client interface
|
| 87 |
+
β β
|
| 88 |
+
β βββ Multi-Agent (CrewAI)
|
| 89 |
+
β βββ agents/ # Agent definitions
|
| 90 |
+
β βββ crews/ # Crew workflows
|
| 91 |
+
β βββ agent_workflow.py # Agent orchestration
|
| 92 |
+
β βββ tools.py # Agent tools
|
| 93 |
+
β β
|
| 94 |
+
β βββ Utilities
|
| 95 |
+
β βββ universal_ingestor.py # File ingestion (ZIP, GitHub, Web)
|
| 96 |
+
β βββ rate_limiter.py # API rate limiting
|
| 97 |
+
β
|
| 98 |
+
βββ components/ # Streamlit UI components
|
| 99 |
+
β βββ multi_mode.py # Mode selector & interfaces
|
| 100 |
+
β
|
| 101 |
+
βββ api/ # FastAPI REST endpoints
|
| 102 |
+
β βββ main.py # API entry point
|
| 103 |
+
β βββ routes/ # Route handlers
|
| 104 |
+
β βββ schemas.py # Pydantic models
|
| 105 |
+
β
|
| 106 |
+
βββ docs/ # Documentation
|
| 107 |
+
β βββ RAG_PIPELINE.md # Technical documentation
|
| 108 |
+
β
|
| 109 |
+
βββ tests/ # Test suite
|
| 110 |
+
β
|
| 111 |
+
βββ assets/ # Static assets (logo, etc.)
|
| 112 |
+
```
|
| 113 |
|
| 114 |
+
## π§ Configuration
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
All configuration is centralized in `code_chatbot/config.py`:
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
+
```python
|
| 119 |
+
from code_chatbot.config import get_default_config
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
+
config = get_default_config()
|
| 122 |
+
print(config.chunking.max_chunk_size) # 1000
|
| 123 |
+
print(config.retrieval.top_k) # 10
|
| 124 |
+
```
|
| 125 |
|
| 126 |
+
## π οΈ Technology Stack
|
| 127 |
|
| 128 |
+
| Component | Technology |
|
| 129 |
+
|-----------|------------|
|
| 130 |
+
| **UI** | Streamlit |
|
| 131 |
+
| **LLM** | Google Gemini |
|
| 132 |
+
| **Embeddings** | gemini-embedding-001 |
|
| 133 |
+
| **Vector DB** | ChromaDB / FAISS / Qdrant |
|
| 134 |
+
| **RAG** | LangChain |
|
| 135 |
+
| **Agents** | CrewAI |
|
| 136 |
+
| **Code Tools** | MCP (Model Context Protocol) |
|
| 137 |
|
| 138 |
+
## π Documentation
|
| 139 |
|
| 140 |
+
- [RAG Pipeline](docs/RAG_PIPELINE.md) - Technical deep-dive
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
+
## π License
|
| 143 |
|
| 144 |
+
Apache 2.0 - See [LICENSE](LICENSE)
|
code_chatbot/__init__.py
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Code Chatbot - AI-powered codebase assistant.
|
| 3 |
+
|
| 4 |
+
Core modules:
|
| 5 |
+
- rag: Chat engine with RAG
|
| 6 |
+
- indexer: Vector database indexing
|
| 7 |
+
- chunker: AST-aware code chunking
|
| 8 |
+
- merkle_tree: Incremental change detection
|
| 9 |
+
- mcp_server/mcp_client: Code search & refactoring tools
|
| 10 |
+
- agents/crews: Multi-agent workflows
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
# Core
|
| 14 |
+
from .rag import ChatEngine
|
| 15 |
+
from .config import get_default_config
|
| 16 |
+
|
| 17 |
+
# Indexing
|
| 18 |
+
from .indexer import Indexer
|
| 19 |
+
from .chunker import CodeChunker
|
| 20 |
+
|
| 21 |
+
# Tools
|
| 22 |
+
from .mcp_client import MCPClient
|
| 23 |
+
|
| 24 |
+
__all__ = [
|
| 25 |
+
# Core
|
| 26 |
+
'ChatEngine',
|
| 27 |
+
'get_default_config',
|
| 28 |
+
# Indexing
|
| 29 |
+
'Indexer',
|
| 30 |
+
'CodeChunker',
|
| 31 |
+
# Tools
|
| 32 |
+
'MCPClient',
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
__version__ = "2.0.0"
|