""" Welcome page for Code-Forge with onboarding and system status checks. """ import streamlit as st import os import subprocess import requests from app.core.pg_manager import get_pg_manager from app.core.config import Config # Page config st.set_page_config( page_title="Welcome to Code-Forge", page_icon="🔥", layout="wide", initial_sidebar_state="collapsed" ) # Redirect to Welcome page (this IS the default landing page) st.switch_page("pages/0_Welcome.py") # Custom CSS for Archon-inspired design st.markdown(""" """, unsafe_allow_html=True) # Header st.markdown('
✅ Connected
', unsafe_allow_html=True) st.metric("Knowledge Bases", len(collections)) except Exception as e: st.markdown(f'❌ Not Connected
', unsafe_allow_html=True) st.error(f"Error: {str(e)}") st.info("Make sure PostgreSQL is running and the `codeforge` database exists.") # Check Ollama with col2: st.markdown("### Ollama") try: response = requests.get(f"{Config.OLLAMA_HOST}/api/tags", timeout=2) if response.status_code == 200: models = response.json().get("models", []) st.markdown(f'✅ Running
', unsafe_allow_html=True) st.metric("Models Installed", len(models)) else: st.markdown(f'⚠️ Unexpected Response
', unsafe_allow_html=True) except Exception as e: st.markdown(f'❌ Not Running
', unsafe_allow_html=True) st.error(f"Error: {str(e)}") st.info("Make sure Ollama container is running: `docker-compose up -d`") # Check Required Models with col3: st.markdown("### Required Models") try: response = requests.get(f"{Config.OLLAMA_HOST}/api/tags", timeout=2) if response.status_code == 200: models = response.json().get("models", []) model_names = [m["name"] for m in models] required_models = ["nomic-embed-text:latest", "llama3.2:3b"] missing_models = [m for m in required_models if m not in model_names] if not missing_models: st.markdown(f'✅ All Present
', unsafe_allow_html=True) st.success("All required models are installed!") else: st.markdown(f'⚠️ Missing Models
', unsafe_allow_html=True) st.warning(f"Missing: {', '.join(missing_models)}") st.info("Run: `ollama pull nomic-embed-text && ollama pull llama3.2:3b`") except Exception: st.markdown(f'❌ Cannot Check
', unsafe_allow_html=True) st.markdown("---") # Quick Start Guide st.markdown("## 🎯 Quick Start Guide") tab1, tab2, tab3, tab4 = st.tabs(["1️⃣ Create KB", "2️⃣ Ingest Docs", "3️⃣ Query", "4️⃣ MCP"]) with tab1: st.markdown(""" ### Creating Your First Knowledge Base 1. **Navigate to the main page** (use the sidebar) 2. **Expand "➕ Create New KB"** in the sidebar 3. **Choose a KB type**: - 📚 **GENERIC** - General-purpose knowledge - 💻 **CODE** - Source code repositories - 📖 **DOCUMENTATION** - Technical documentation - 🤖 **AGENT_OS** - Spec-driven development 4. **Enter a name** (e.g., `my-project`) 5. **Add a description** (optional) 6. **Click "Create"** ✨ Your knowledge base is now ready for documents! """) st.info("💡 **Tip**: Use separate KBs for different projects to keep contexts isolated.") with tab2: st.markdown(""" ### Ingesting Documents **Option 1: File Upload** 1. Select your KB from the sidebar 2. Go to the **"📚 Knowledge Base"** tab 3. Click **"Choose files"** and select documents 4. Click **"Upload Files"** **Option 2: Directory Import** 1. Select your KB from the sidebar 2. Go to the **"📚 Knowledge Base"** tab 3. Enter the full path to your project directory 4. Click **"Import Directory"** **Supported File Types:** - Documents: `.md`, `.txt`, `.pdf` - Code: `.py`, `.js`, `.jsx`, `.ts`, `.tsx`, `.go`, `.rs`, `.java`, `.cpp`, `.c`, `.h` - Config: `.json`, `.yaml`, `.yml` """) st.info("💡 **Tip**: For large codebases, use directory import to ingest all files at once.") with tab3: st.markdown(""" ### Querying Your Knowledge Base 1. **Select your KB** from the sidebar 2. **Go to the "💬 Chat" tab** 3. **Choose a RAG strategy**: - 🔍 **Base** - Simple vector search (fastest) - 🔀 **Hybrid** - BM25 + vector fusion (better for keywords) - 🎯 **Reranking** - Cross-encoder reranking (most accurate) - 🤖 **Agentic** - Sub-question decomposition (best for complex queries) 4. **Type your question** and press Enter 5. **View sources** by expanding "📚 View Sources" **Example Queries:** - "How does authentication work in this codebase?" - "What are the main components of the system?" - "Show me examples of error handling" """) st.info("💡 **Tip**: Use hybrid search for technical queries with specific keywords.") with tab4: st.markdown(""" ### MCP Integration (Model Context Protocol) Code-Forge exposes your knowledge bases via HTTP for AI agent integration. **MCP Server Endpoint:** ``` http://localhost:8051/mcp ``` **Available Tools:** - `list_knowledge_bases` - List all KBs - `create_knowledge_base` - Create new KB - `search_knowledge_base` - Query KB with RAG - `get_kb_stats` - Get KB statistics - `ingest_documents` - Add documents - `get_standards` - Get Agent OS standards - `get_workflows` - Get Agent OS workflows - `get_specs` - Get Agent OS specs **Example Request:** ```bash curl -X POST http://localhost:8051/mcp \\ -H "Content-Type: application/json" \\ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "search_knowledge_base", "arguments": { "kb_name": "my-docs", "query": "How do I configure authentication?", "strategy": "hybrid" } } }' ``` """) st.info("💡 **Tip**: See the README for full MCP API documentation.") st.markdown("---") # Feature Highlights st.markdown("## ✨ Feature Highlights") col1, col2 = st.columns(2) with col1: st.markdown("""PostgreSQL + pgvector ensures your data is safe with ACID compliance, transaction safety, and bulletproof persistence. Your data survives all Docker operations and system restarts.
Choose from multiple retrieval strategies: vector search, hybrid search (BM25 + vector), reranking with cross-encoders, or agentic RAG with sub-question decomposition.
All data stays on your machine. No API keys, no cloud dependencies, no telemetry. Perfect for sensitive codebases and proprietary documentation.
First-class support for spec-driven development with Agent OS. Ingest standards, workflows, and specs with specialized retrieval tools.
Expose your knowledge bases to AI agents via Model Context Protocol. 12 HTTP endpoints for seamless integration with Claude Desktop and other agents.
Create isolated knowledge bases for different projects. Each KB has its own type, metadata, and documents. Perfect for teams working on multiple projects.
Ready to get started?
Use the sidebar to navigate to the main page and create your first knowledge base!
Built with ❤️ for the local-first AI community