claude-os/README.md

373 lines
12 KiB
Markdown
Raw Normal View History

2025-10-27 17:41:44 -05:00
# Claude OS
2025-10-22 13:29:28 -05:00
2025-10-24 16:17:47 -05:00
```text
╔═══════════════════════════════════════════════════════════════╗
║ ║
2025-10-27 17:41:44 -05:00
║ ██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗ ██████╗ ███████╗
║ ██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝ ██╔═══██╗██╔════╝
║ ██║ ██║ ███████║██║ ██║██║ ██║█████╗ ██║ ██║███████╗
║ ██║ ██║ ██╔══██║██║ ██║██║ ██║██╔══╝ ██║ ██║╚════██║
║ ╚██████╗███████╗██║ ██║╚██████╔╝██████╔╝███████╗ ╚██████╔╝███████║
║ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝
║ ║
2025-10-24 16:17:47 -05:00
║ Localized Multi-Knowledge-Base RAG System ║
║ with MCP Integration ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
```
2025-10-27 17:41:44 -05:00
> **Production-grade RAG system** with SQLite vector search, Ollama LLMs, and Model Context Protocol. Runs 100% locally on your machine.
[![License: MIT](https://img.shields.io/badge/License-MIT-purple.svg)](LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
2025-10-27 17:41:44 -05:00
[![SQLite](https://img.shields.io/badge/SQLite-3.0+-green.svg)](https://www.sqlite.org/)
[![Ollama](https://img.shields.io/badge/Ollama-Latest-pink.svg)](https://ollama.ai/)
---
2025-10-27 17:41:44 -05:00
## 🚀 What is Claude OS?
2025-10-27 17:41:44 -05:00
**Claude OS** is a **localized RAG (Retrieval-Augmented Generation) system** designed to make AI assistants deeply knowledgeable about your codebase and documentation. It combines:
2025-10-27 17:41:44 -05:00
- **🗄️ SQLite + sqlite-vec** - Lightweight vector database for semantic search
- **🤖 Ollama** - Local LLMs (llama3.1) with no API keys needed
- **🔌 MCP Integration** - Claude Desktop integration via Model Context Protocol
- **⚡ React UI** - Modern dashboard for managing knowledge bases
- **📚 Multi-KB Support** - Separate knowledge bases for different projects
- **🧠 Advanced RAG** - Hybrid search, reranking, and agentic modes
### Perfect For
✅ Making Claude deeply familiar with your codebase
✅ Private, secure knowledge base (never leaves your machine)
✅ Team collaboration (share with coworkers easily)
✅ Integration with Claude Desktop via MCP
✅ Building AI-assisted development workflows
2025-10-22 13:29:28 -05:00
---
## ⚡ Quick Start (5-10 minutes)
2025-10-22 13:29:28 -05:00
### Prerequisites
Before running the setup, ensure you have:
2025-10-27 17:41:44 -05:00
1. **Python 3.11+**
```bash
python3 --version
```
2025-10-27 17:41:44 -05:00
2. **Node.js 16+** (for React frontend)
```bash
node --version
```
2025-10-22 13:29:28 -05:00
### Installation
2025-10-22 13:29:28 -05:00
1. **Clone the repository**
```bash
git clone <repo-url>
2025-10-27 17:41:44 -05:00
cd claude-os
```
2025-10-24 16:17:47 -05:00
2. **Run the setup script** (handles Ollama, Python, models)
```bash
chmod +x setup_native.sh
./setup_native.sh
```
2025-10-24 16:17:47 -05:00
This will:
- ✅ Install/start Ollama
- ✅ Download LLM models (5-10 GB total)
- ✅ Setup Python environment
2025-10-27 17:41:44 -05:00
- ✅ Initialize SQLite database
2025-10-24 16:17:47 -05:00
3. **Start services**
```bash
./start_all_services.sh
```
2025-10-24 16:17:47 -05:00
This starts:
- **MCP Server** (port 8051) - Backend RAG engine
- **React UI** (port 5173) - Web dashboard
- **Ollama** (port 11434) - LLM service
2025-10-24 16:17:47 -05:00
4. **Access the UI**
- Open http://localhost:5173 in your browser
- Start uploading documents to create knowledge bases
2025-10-24 16:17:47 -05:00
---
## 🔌 MCP Integration with Claude Desktop
2025-10-22 13:29:28 -05:00
To use your knowledge bases with Claude Desktop:
2025-10-22 13:29:28 -05:00
### Option 1: Via CLI (Easiest)
2025-10-22 13:29:28 -05:00
```bash
# Add PISTN knowledge base to Claude Desktop
claude mcp add pistn http://localhost:8051/mcp/kb/pistn
2025-10-22 13:29:28 -05:00
# Add PISTN Agent OS knowledge base
claude mcp add pistn-agent-os http://localhost:8051/mcp/kb/pistn-agent-os
```
Then in Claude Desktop, your knowledge bases are available as built-in tools. Ask Claude about your codebase directly!
### Option 2: Manual Configuration
Edit `~/.claude_desktop_config.json`:
2025-10-24 16:17:47 -05:00
2025-10-22 13:29:28 -05:00
```json
{
"mcpServers": {
"pistn": {
"url": "http://localhost:8051/mcp/kb/pistn"
},
"pistn-agent-os": {
"url": "http://localhost:8051/mcp/kb/pistn-agent-os"
}
}
2025-10-22 13:29:28 -05:00
}
```
Then restart Claude Desktop.
2025-10-22 13:29:28 -05:00
---
2025-10-22 13:29:28 -05:00
## 📚 Managing Knowledge Bases
2025-10-24 16:17:47 -05:00
### Create a Knowledge Base
2025-10-22 13:29:28 -05:00
1. Visit http://localhost:5173
2. Click "Create Knowledge Base"
3. Choose type:
- **GENERIC** - General documentation
- **CODE** - Source code repositories
- **DOCUMENTATION** - Technical docs
- **AGENT_OS** - Spec-driven development
2025-10-24 16:17:47 -05:00
### Upload Documents
2025-10-22 13:29:28 -05:00
1. Select a knowledge base
2. Click "Upload Documents"
3. Choose files (supports .md, .txt, .pdf, .py, .js, .ts, .json, .yaml)
4. Watch as documents are indexed
2025-10-24 16:17:47 -05:00
### Query the Knowledge Base
2025-10-22 13:29:28 -05:00
**Via Web UI:**
1. Select a KB from the dropdown
2. Type your question
3. View answer with source citations
2025-10-24 16:17:47 -05:00
**Via Claude Desktop:**
Once added as MCP server, Claude can query automatically when working on your project.
2025-10-22 13:29:28 -05:00
---
2025-10-24 16:17:47 -05:00
## 🏗️ Architecture
2025-10-22 13:29:28 -05:00
```
┌─────────────────────────────────────────────────┐
│ Claude Desktop │
│ (or any MCP client) │
└───────────────────┬─────────────────────────────┘
│ MCP HTTP
┌───────────────────▼─────────────────────────────┐
│ MCP Server (Port 8051) │
│ FastAPI Backend │
└───────────────────┬─────────────────────────────┘
│
┌───────────┴────────────┐
│ │
┌───────▼────────────┐ ┌────────▼──────────┐
│ RAG Engine │ │ React UI │
│ (llama-index) │ │ (Port 5173) │
│ • Vector Search │ │ │
│ • Hybrid Search │ └────────────────────┘
│ • Reranking │
└───────┬────────────┘
│
┌───────▼────────────────────────────────────────┐
2025-10-27 17:41:44 -05:00
│ SQLite + sqlite-vec (Local Database) │
│ • knowledge_bases │
│ • documents (with embeddings) │
2025-10-27 17:41:44 -05:00
│ • Single-file database │
└────────────────────────────────────────────────┘
│
└─────────────────────┐
│
┌─────────▼──────┐
│ Ollama │
│ (Port 11434) │
│ • llama3.1 │
│ • Embeddings │
└────────────────┘
```
2025-10-22 13:29:28 -05:00
---
## ⚙️ Configuration
### Environment Variables
The system uses sensible defaults, but you can customize via environment variables:
2025-10-22 13:29:28 -05:00
```bash
2025-10-27 17:41:44 -05:00
# SQLite Database
SQLITE_DB_PATH=data/claude-os.db # Default: data/claude-os.db
2025-10-22 13:29:28 -05:00
# Ollama
OLLAMA_HOST=http://localhost:11434 # Default: localhost:11434
2025-10-27 17:41:44 -05:00
OLLAMA_MODEL=llama3.1:latest # Default: llama3.1:latest
2025-10-22 13:29:28 -05:00
# MCP Server
MCP_SERVER_HOST=0.0.0.0 # Default: 0.0.0.0
MCP_SERVER_PORT=8051 # Default: 8051
```
2025-10-22 13:29:28 -05:00
---
2025-10-24 16:17:47 -05:00
## 📊 Performance
2025-10-22 13:29:28 -05:00
**Native Ollama Setup (Current)**
- Response time: ~40 seconds per query
- GPU acceleration: Full Metal GPU on Apple Silicon
- Memory usage: 8-10GB (models + context)
- CPU usage: 12 cores (M4 Pro, leaves 2 for system)
2025-10-22 13:29:28 -05:00
**Why it's fast:**
- Direct GPU acceleration (no virtualization)
2025-10-27 17:41:44 -05:00
- Efficient vector search in SQLite
- Optimized RAG engine with caching
2025-10-27 17:41:44 -05:00
- Single-file database with minimal overhead
2025-10-24 16:17:47 -05:00
---
2025-10-22 13:29:28 -05:00
## 📁 Project Structure
2025-10-24 16:17:47 -05:00
```
2025-10-27 17:41:44 -05:00
claude-os/
├── app/ # Backend application
│ ├── core/ # Core modules
│ │ ├── config.py # Configuration management
2025-10-27 17:41:44 -05:00
│ │ ├── sqlite_manager.py # SQLite interface
│ │ ├── rag_engine.py # RAG logic
│ │ └── ...
│ ├── db/ # Database schemas
│ └── ...
├── frontend/ # React UI (Vite)
│ ├── src/
│ │ ├── pages/
│ │ ├── components/
│ │ └── ...
│ └── package.json
├── mcp_server/ # MCP Server (HTTP)
│ ├── server.py # FastAPI + MCP endpoints
│ └── ...
├── migrations/ # Database migrations
├── setup_native.sh # Installation script
├── start_all_services.sh # Start all services
├── stop_all_services.sh # Stop all services
├── requirements.txt # Python dependencies
└── README.md # This file
```
2025-10-22 13:29:28 -05:00
---
## 🐛 Troubleshooting
2025-10-27 17:41:44 -05:00
### Database Issues
2025-10-22 13:29:28 -05:00
2025-10-27 17:41:44 -05:00
The SQLite database is automatically created at `data/claude-os.db`. If you encounter issues:
2025-10-22 13:29:28 -05:00
2025-10-27 17:41:44 -05:00
```bash
# Check if database exists
2025-10-27 17:41:44 -05:00
ls -lh data/claude-os.db
2025-10-22 13:29:28 -05:00
2025-10-27 17:41:44 -05:00
# Remove and recreate (WARNING: deletes all data)
rm data/claude-os.db
# Restart the server to recreate
2025-10-22 13:29:28 -05:00
```
### Ollama Issues
2025-10-22 13:29:28 -05:00
```bash
# Check if Ollama is running
ollama list
2025-10-24 16:17:47 -05:00
# Start Ollama manually
ollama serve
2025-10-22 13:29:28 -05:00
# Check for specific model
ollama list | grep llama3.1
```
2025-10-22 13:29:28 -05:00
### Port Already in Use
2025-10-24 16:17:47 -05:00
```bash
# Find process on port 8051 (MCP Server)
lsof -i :8051
2025-10-24 16:17:47 -05:00
# Find process on port 5173 (React UI)
lsof -i :5173
2025-10-24 16:17:47 -05:00
# Kill if needed (replace PID with actual process ID)
kill -9 <PID>
2025-10-24 16:17:47 -05:00
```
### MCP Server Not Starting
2025-10-24 16:17:47 -05:00
```bash
# Check logs
tail -f /tmp/mcp_server.log
2025-10-24 16:17:47 -05:00
# Verify Python environment
source venv/bin/activate
python mcp_server/server.py
2025-10-24 16:17:47 -05:00
# Check port 8051 is accessible
curl http://localhost:8051/health
```
2025-10-24 16:17:47 -05:00
---
2025-10-24 16:17:47 -05:00
## 📖 Additional Documentation
2025-10-24 16:17:47 -05:00
- **[README_NATIVE_SETUP.md](README_NATIVE_SETUP.md)** - Detailed native setup guide
- **[NATIVE_VS_DOCKER_DECISION.md](NATIVE_VS_DOCKER_DECISION.md)** - Why we chose native Ollama
- **[PERFORMANCE_TEST_RESULTS.md](PERFORMANCE_TEST_RESULTS.md)** - Benchmark results
- **[SLUG_IMPLEMENTATION_SUMMARY.md](SLUG_IMPLEMENTATION_SUMMARY.md)** - URL slug system
- **[MCP_KB_ENDPOINTS.md](MCP_KB_ENDPOINTS.md)** - MCP endpoint documentation
2025-10-24 16:17:47 -05:00
---
## 🤝 Contributing
This is a personal development tool. Feel free to:
- Modify for your specific needs
- Add new KB types
- Optimize RAG strategies
- Contribute improvements back
2025-10-22 13:29:28 -05:00
---
## 📄 License
2025-10-22 13:29:28 -05:00
MIT License - Use it freely!
2025-10-22 13:29:28 -05:00
---
## 🎯 Next Steps
2025-10-22 13:29:28 -05:00
1. **First-time setup:** Run `./setup_native.sh`
2. **Start services:** Run `./start_all_services.sh`
3. **Create knowledge base:** Visit http://localhost:5173
4. **Upload documents:** Add your codebase/docs
5. **Integrate with Claude:** Run `claude mcp add ...`
6. **Start coding:** Ask Claude about your project!
2025-10-22 13:29:28 -05:00
Happy coding! 🚀
2025-10-22 13:29:28 -05:00