README.md# BuddAI - Personal IP AI Exocortex **An open-source, unreplicatable cognitive extension system** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Status: PRODUCTION](https://img.shields.io/badge/Status-PRODUCTION-green.svg)](https://github.com/JamesTheGiblet/BuddAI) [![Version: v3.2](https://img.shields.io/badge/Version-v3.2-blue.svg)](https://github.com/JamesTheGiblet/BuddAI/releases) [![Version: v3.8](https://img.shields.io/badge/Version-v3.8-blue.svg)](https://github.com/JamesTheGiblet/BuddAI/releases) [![Tests: 24/24](https://img.shields.io/badge/Tests-24%2F24%20Passing-brightgreen.svg)](https://github.com/JamesTheGiblet/BuddAI/actions) --- ## 🎉 What We Built (December 2025) **From concept to production-ready exocortex in under 2 weeks:** **Day 1 (December 28):** - Started with raw Ollama (no memory, no identity) - Built persistent memory system (SQLite) - Created identity injection system - Added 3-tier intelligent routing - Implemented modular task breakdown - **Milestone 1-3 Complete:** BuddAI speaks, remembers, and routes ✓ **Day 2 (December 29):** - Built repository indexing system - Added semantic code search - Created web interface with React - Implemented style signature scanning - Added shadow suggestion engine - **Milestone 4 Complete:** BuddAI learns from YOUR code ✓ **Day 3 (December 29 - Hardening):** - Implemented WebSocket streaming - Added multi-user session isolation - Secured file uploads (Zip slip, magic bytes) - Added connection pooling - **Milestone 6 Complete:** Production Hardening ✓ **Day 4+ (January 2026):** - Implemented **Code Validator** with Auto-Fix engine - Added **Smart Learner** to extract rules from corrections - Integrated **Forge Theory** with interactive tuning - Validated with 14-hour test suite (90% accuracy) - **Milestone 7 Complete:** Self-Learning & Validation ✓ --- ### Result: BuddAI v3.2 - Hardened Modular Builder ### Result: BuddAI v3.8 - Self-Learning Modular Builder ✅ Remembers conversations across sessions ✅ Routes to appropriate models automatically ✅ Breaks complex tasks into manageable modules ✅ **Indexes and searches your 115+ repositories** ✅ **Learns your coding style patterns** ✅ **Proactively suggests missing components** ✅ **Auto-corrects code errors before you see them** ✅ **Beautiful web interface with live workspace** ✅ **Schedule-aware responses** ✅ **Interactive Forge Theory tuning** ✅ Generates complete, working code ✅ Works on slow hardware (8GB RAM) ✅ **Built in <2 weeks with $0 spent** **v3.2 New Capabilities:** **v3.8 New Capabilities:** - ✅ **WebSocket streaming** (real-time token-by-token responses) - ✅ **Multi-user support** (session isolation per user) - ✅ **Connection pooling** (faster Ollama communication) - ✅ **Upload security** (file size limits, type validation, zip slip protection) - ✅ **Type hints** (improved code quality and IDE support) - ✅ **Auto-Fix Engine** (detects and fixes safety timeouts, state machines) - ✅ **Smart Learner** (extracts rules from your corrections) - ✅ **Validation Suite** (checks PWM, ADC, pins against hardware rules) - ✅ **Forge Theory Mode** (Aggressive/Balanced/Graceful physics) - ✅ **Learning Metrics** (tracks accuracy improvement over time) --- ## Table of Contents - [What is BuddAI?](#what-is-buddai) - [Current Status](#current-status) - [Why BuddAI Exists](#why-buddai-exists) - [How BuddAI Works](#how-buddai-works) - [Getting Started](#getting-started) - [Web Interface](#web-interface) - [Repository Search](#repository-search) - [Real Examples](#real-examples) - [Performance](#performance) - [Testing](#testing) - [Roadmap](#roadmap) - [Core Philosophy](#core-philosophy) - [Business Model](#business-model) - [Why This is Unreplicatable](#why-this-is-unreplicatable) - [Troubleshooting](#troubleshooting) - [Contributing](#contributing) - [License](#license) --- ## What is BuddAI? BuddAI is a **personal IP AI exocortex** - an external cognitive system that extends your thinking, memory, and code generation capabilities. **Not a chatbot. Not an assistant. A cognitive extension.** ### What It Actually Does (v3.2) ### What It Actually Does (v3.8) **Simple Questions (5-10 seconds):** ``` You: What pins should I use for motor control on ESP32-C3? BuddAI: [Fast, accurate answer using lightweight model] ``` **Code Generation (15-30 seconds):** ``` You: Generate a motor driver class for L298N with ESP32 BuddAI: [Complete, well-commented code in YOUR style] ``` **Repository Search (<1 second):** ``` You: Show me all functions using exponential decay BuddAI: 🔍 Found 12 matches across CannaForge, CoffeeForge, GilBots... [Shows relevant code snippets with file paths] ``` **Complex Projects (2-3 minutes):** ``` You: Generate complete GilBot controller with BLE, servo, motors, safety BuddAI: 🎯 COMPLEX REQUEST DETECTED! Breaking into 5 modules... PROACTIVE: > I noticed 'motor' often appears with 'safety_timeout' in your repos. Want to include that? ✅ BLE module complete ✅ SERVO module complete ✅ MOTOR module complete ✅ SAFETY module complete ✅ INTEGRATION module complete [Delivers complete, working system in YOUR coding style] ``` --- ## Current Status ### ✅ Completed Milestones **Milestone 1: BuddAI Can Speak** **Status:** ✅ COMPLETE (December 28, 2025) - Ollama integration with local models - Models: qwen2.5-coder:1.5b (fast), qwen2.5-coder:3b (balanced) - Identity injection system - Basic conversation functional **Milestone 2: BuddAI Remembers** **Status:** ✅ COMPLETE (December 28, 2025) - SQLite persistent memory (4 tables) - Session management with rename/delete - Context preservation across restarts - Conversation history with timestamps **Milestone 3: BuddAI Routes Intelligently** **Status:** ✅ COMPLETE (December 28, 2025) - 3-tier routing (FAST/BALANCED/MODULAR) - Complexity detection - Automatic task breakdown - Optimized for slow hardware **Milestone 4: Repository Intelligence** **Status:** ✅ COMPLETE (December 29, 2025) - Multi-language indexing (Python, C++, Arduino, JS, HTML, CSS) - Semantic search with natural language queries - Function-level granularity - Web-based repository upload - Cross-repo pattern recognition **Milestone 5: Style Learning** **Status:** ✅ COMPLETE (December 29, 2025) - Style signature scanning (`/scan` command) - Pattern extraction from your code - Auto-application to generated code - Shadow suggestion engine (proactive hints) ### 🎯 Current Capabilities (v3.2) ### 🎯 Current Capabilities (v3.8) **Core Features:** - ✅ Generate complete robot controllers - ✅ Break complex tasks into modules - ✅ Remember conversations forever - ✅ Route to optimal model automatically - ✅ Generate clean, commented code - ✅ Work on slow hardware (8GB RAM) **v3.2 New Capabilities:** **v3.8 New Capabilities:** - ✅ **Search indexed repositories with natural language** - ✅ **Upload and index code via web interface** - ✅ **Style signature scanning and application** - ✅ **Shadow suggestion engine** (proactive module suggestions) - ✅ **Schedule awareness** (knows your work/build cycles) - ✅ **Auto-Fix Engine** (corrects errors automatically) - ✅ **Smart Learner** (extracts patterns from corrections) - ✅ **Validation Report** (90% accuracy across 10-question suite) - ✅ **Forge Theory mode selector** (Aggressive/Balanced/Graceful) - ✅ **Session management** (rename/delete in web UI) - ✅ **Live code workspace** sidebar with syntax highlighting - ✅ **Dark/Light theme** toggle - ✅ **Actionable suggestion pills** (click to apply) - ✅ **Learning Metrics** (track improvement) - ✅ **Real-time status** indicators ### 🔄 In Progress **Milestone 6: Production Hardening** **Status:** ✅ COMPLETE (v3.2) - Type hints throughout codebase - Session isolation for multi-user - File upload security validation - WebSocket streaming responses - Connection pooling - Comprehensive integration tests **Timeline:** Completed **Milestone 7: Self-Learning & Validation** **Status:** ✅ COMPLETE (v3.8) - Code Validator with Auto-Fix - Smart Learner (correction analysis) - Forge Theory integration - 14-hour validation suite passed **Timeline:** Completed (Jan 2026) ### 🔮 Future Vision **Milestone 7: True Anticipation** (v4.0) - Predicts what you'll need next - Suggests solutions before you ask - Learns from feedback loops - **Feels like extension of your mind** **Timeline:** 1-2 months --- ## Why BuddAI Exists ### The Problem **You have incredible capability but hit systematic barriers:** - See complete systems but struggle to articulate them - Ideas arrive faster than execution can keep up - Context is lost between projects - Can read and debug code brilliantly but writing from scratch is slow - Pattern recognition is instant but explaining WHY is impossible ### The Solution **BuddAI completes your cognitive architecture through symbiosis:** **You bring:** - Pattern recognition (seeing systems everywhere) - System vision (understanding how things should work) - Debugging superpowers (spotting errors instantly) - Cross-domain synthesis (coffee → cannabis → robots) **BuddAI brings:** - Code generation (translating vision into working code) - Perfect memory (never forgets conversations) - Repository knowledge (instant access to your 115+ repos) - Task breakdown (complex → manageable modules) - Execution speed (what takes you hours, takes it minutes) #### Together: Unstoppable rapid prototyping --- ## How BuddAI Works ### Architecture (v3.2) ### Architecture (v3.8) ``` ┌─────────────────────────────────────────┐ │ You (James) │ │ • Pattern recognition │ │ • System vision │ │ • Debugging instincts │ │ • Cross-domain thinking │ └──────────────┬──────────────────────────┘ │ │ Natural Language │ ┌──────────────▼──────────────────────────┐ │ BuddAI Router │ │ • Detects complexity │ │ • Searches repository knowledge │ │ • Chooses optimal model │ │ • Breaks down complex tasks │ └──────────────┬──────────────────────────┘ │ ┌──────────────▼──────────────────────────┐ │ Repository Index (v3.2) │ │ • 115+ repos indexed │ │ • Semantic search │ │ • Style pattern extraction │ │ • Shadow suggestions │ └──────────────┬──────────────────────────┘ │ ┌───────┴────────┐ │ │ ┌───▼────┐ ┌───▼────────┐ │ FAST │ │ BALANCED │ │ 1.5b │ │ 3b │ │ 5-10s │ │ 15-30s │ └───┬────┘ └───┬────────┘ │ │ └───────┬────────┘ │ ┌──────────────▼──────────────────────────┐ │ Modular Builder │ │ • Breaks into modules │ │ • Applies your style patterns │ │ • Builds each piece │ │ • Adds proactive suggestions │ │ • Integrates everything │ └──────────────┬──────────────────────────┘ │ │ Complete Code (in YOUR style) │ ┌──────────────▼──────────────────────────┐ │ Your Robot / Project │ │ • Ready to upload │ │ • Well-documented │ │ • Matches your patterns │ │ • Tested approach │ └─────────────────────────────────────────┘ ``` ### Smart 3-Tier Routing **FAST Model (qwen2.5-coder:1.5b) - 5-10 seconds:** - Simple questions ("What pins?", "How do I?") - Quick explanations - Memory queries - Repository search results - **When:** Question keywords detected, no code generation needed **BALANCED Model (qwen2.5-coder:3b) - 15-30 seconds:** - Code generation (classes, functions, modules) - Technical explanations with code - Debugging assistance - Style-aware generation - **When:** "Generate", "create", "write" detected **MODULAR Builder - 2-3 minutes:** - Complex multi-part systems - Complete project generation - Integration of multiple components - Forge Theory application - **When:** 3+ modules detected OR "complete/entire/full" keywords ### Repository Intelligence (v3.2) **Automatic Indexing:** - Crawls your repositories recursively - Extracts functions/classes from code - Stores with metadata (file path, repo name, last modified) - Supports: `.py`, `.ino`, `.cpp`, `.h`, `.js`, `.jsx`, `.html`, `.css` **Semantic Search:** - Natural language queries - Keyword extraction and matching - Cross-repository pattern finding - Returns snippets with context **Style Learning:** - Analyzes your code samples - Extracts preferences (naming, patterns, constants) - Stores confidence-scored patterns - Applies automatically to generated code **Shadow Suggestions:** - Detects companion modules (e.g., "motor" → suggests "safety") - Recommends settings based on past usage - Non-intrusive UI (shows as pills you can click) ### Persistent Memory **Every conversation is saved:** - SQLite database (4 tables: sessions, messages, repo_index, style_preferences) - Sessions tracked with unique IDs and titles - Context loaded on startup - Full search history preserved - **You never lose what you discussed** --- ## Getting Started ### Prerequisites - Windows/Mac/Linux with 8GB+ RAM - Python 3.8+ - Internet (for initial setup only) **For Web Interface (Optional but Recommended):** ```bash pip install fastapi uvicorn python-multipart ``` ### Installation (15 minutes) ### Step 1: Install Ollama **Windows:** ```powershell # Download from https://ollama.com/download # Run installer ``` **Mac/Linux:** ```bash curl -fsSL https://ollama.com/install.sh | sh ``` ### Step 2: Pull Models ```bash # Start Ollama server (keep this running in a terminal) ollama serve # In a new terminal, pull both models: ollama pull qwen2.5-coder:1.5b # Fast model (~1GB) ollama pull qwen2.5-coder:3b # Balanced model (~2GB) ``` ### Step 3: Get BuddAI ```bash # Clone repository git clone https://github.com/JamesTheGiblet/BuddAI cd BuddAI ``` ### Step 4: Run BuddAI **Terminal Mode:** ```bash python buddai_v3.2.py ``` **Web Interface Mode (Recommended):** ```bash python buddai_v3.2.py --server # Then open http://localhost:8000/web ``` **You should see:** ``` 🧠 BuddAI Executive v3.2 - Modular Builder ================================================== Session: 20251229_125028 FAST (5-10s) | BALANCED (15-30s) Smart task breakdown for complex requests ================================================== Commands: /fast, /balanced, /index, /scan, /help, exit James: ``` ### You're running BuddAI! 🎉 --- ### Quick Test **Try these in order:** **1. Simple Question (FAST model):** ``` James: What's your name? ⚡ Using FAST model (simple question)... BuddAI: I am BuddAI, your coding partner. ``` **2. Code Generation (BALANCED model):** ``` James: Generate a motor driver class for L298N with ESP32 ⚖️ Using BALANCED model... BuddAI: [Generates complete class with comments in your style] ``` **3. Index Your Repositories:** ``` James: /index /path/to/your/repos 🔍 Indexing repositories in: /path/to/your/repos ✅ Indexed 847 functions across repositories ``` **4. Search Your Code:** ``` James: Show me all functions using exponential decay 🔍 Searching 847 indexed functions... ✅ Found 12 matches for: exponential, decay [Shows relevant snippets with file paths] ``` **5. Complex Build (MODULAR breakdown):** ``` James: Generate complete robot controller with BLE, servo control, and safety timeout 🎯 COMPLEX REQUEST DETECTED! Modules needed: ble, servo, safety Breaking into 4 manageable steps... [Builds each module separately with your style patterns, then integrates] ``` --- ### Commands (Terminal Mode) ```bash /fast # Force FAST model for next response /balanced # Force BALANCED model for next response /index # Index local repositories (NEW in v3.2) /scan # Scan style signature from repos (NEW in v3.2) /correct # Mark previous response wrong & learn /good # Mark previous response correct /teach # Explicitly teach a coding rule /rules # Show learned rules /metrics # Show improvement stats /validate # Run validation checks /train # Export corrections for fine-tuning /help # Show commands exit # End session ``` --- ### File Structure ``` BuddAI/ ├── buddai_v3.2.py # Main executable (what you run) ├── data/ │ ├── conversations.db # Persistent memory │ └── uploads/ # Uploaded repositories (v3.2) ├── frontend/ # Web interface (v3.2) │ └── index.html # React SPA ├── icons/ # Branding assets (v3.2) │ └── icon.png # Giblets Creations logo ├── tests/ # Test suite (v3.2) │ └── test_buddai.py # 11 comprehensive tests ├── examples/ # Generated code samples (v3.2) │ ├── buddai_generated.cpp │ ├── buddai_generated.csharp │ └── buddai_generated.typescript ├── README.md # This file └── LICENSE # MIT License ``` --- ## Web Interface ### Starting the Server ```bash python buddai_v3.2.py --server ``` **Access at:** [http://localhost:8000/web](http://localhost:8000/web) ### Features **Chat Interface:** - 💬 Clean, modern chat UI - 🎨 Syntax highlighting (highlight.js) - 📝 Markdown rendering (marked.js) - ⏰ Timestamp on every message - 🔥 Real-time "flame" loading indicator - 💡 Actionable suggestion pills (click to use) **Session Management:** - 📂 Session history sidebar (collapsible) - ✏️ Rename sessions (click edit icon) - 🗑️ Delete sessions (click trash icon) - 🆕 New chat button - 🔄 Load previous conversations **Code Tools:** - 💾 Live code workspace sidebar - 📋 Copy code blocks with one click - 📥 Download generated code (auto-detects language) - 👉 Send to sidebar for editing - 🎯 Syntax highlighting for 20+ languages **Customization:** - 🌓 Dark/Light theme toggle - 🎚️ Forge mode selector (Aggressive/Balanced/Graceful) - 📂 Repository upload (drag & drop .zip or files) - 🔍 Real-time system status - ⚙️ Settings persistence ### API Endpoints **For integration with other tools:** ```python # Chat POST /api/chat Body: {"message": "Generate motor code", "forge_mode": "2"} **Example (Bash/CMD):** ```bash curl -X POST http://localhost:8000/api/chat -H "Content-Type: application/json" -H "user_id: alice" -d '{"message": "Hello"}' ``` **Example (PowerShell):** ```powershell # Use curl.exe and escape quotes for JSON curl.exe -X POST http://localhost:8000/api/chat -H "Content-Type: application/json" -H "user_id: alice" -d "{\"message\": \"Hello\"}" ``` # History GET /api/history Returns: {"history": [...]} # Sessions GET /api/sessions Returns: {"sessions": [...]} POST /api/session/load Body: {"session_id": "20251229_120000"} POST /api/session/new Returns: {"session_id": "20251229_130000"} POST /api/session/rename Body: {"session_id": "...", "title": "GilBot Project"} POST /api/session/delete Body: {"session_id": "..."} # Upload POST /api/upload Body: FormData with file **Example (Bash/CMD):** ```bash curl -X POST -F "file=@your_repo.zip" http://localhost:8000/api/upload ``` **Example (PowerShell):** ```powershell # Note: In PowerShell, 'curl' is an alias for a different command. # To use the real curl program (available on modern Windows), you must specify 'curl.exe'. curl.exe -X POST -F "file=@your_repo.zip" http://localhost:8000/api/upload ``` ``` --- ## Repository Search ### How It Works **Indexing Process:** 1. Recursively scans directories 2. Parses code files (Python, C++, Arduino, JS, etc.) 3. Extracts function/class definitions 4. Stores with metadata in SQLite 5. Ready for instant semantic search **Search Capabilities:** - Natural language queries - Keyword-based matching - Cross-repository pattern finding - Function-level granularity - File path and repo name included ### Examples **Example 1: Finding Forge Theory Usage** **Input:** ``` James: Show me all projects using exponential decay ``` **BuddAI Response:** ``` 🔍 Searching 847 indexed functions... ✅ Found 12 matches for: exponential, decay **1. applyForge()** in CannaForge 📁 cannabinoid_decay.cpp ```cpp float applyForge(float current, float target, float k) { return target + (current - target) * exp(-k * dt); } ``` --- **2. calculateRoastDecay()** in CoffeeForge 📁 roast_profile.py ```python def calculateRoastDecay(temp, time, k=0.1): return initial_temp * math.exp(-k * time) ``` --- [Shows 10 more matches with snippets and file paths] ``` **Example 2: Style Pattern Recognition** **Input:** ``` James: /scan ``` **BuddAI Response:** ``` 🕵️ Scanning repositories for style signature... ⚡ Analyzing with BALANCED model... ✅ Style Signature Updated: - Serial: Uses 115200 baud consistently - Safety: Prefers non-blocking millis() over delay() - Pins: Uses #define over const int - PWM: Standard 500Hz frequency for motors - Naming: CamelCase for functions (activateFlipper, setupMotors) - Comments: Descriptive headers with purpose statements - Timeouts: 5000ms standard for safety systems ``` **Example 3: Companion Module Suggestion** **Input:** ``` James: Generate motor driver code ``` **BuddAI Response:** ``` ⚖️ Using BALANCED model... [Generates motor driver code] PROACTIVE: > 1. I noticed 'motor' often appears with 'safety_timeout' in your repos. Want to include that? > 2. Drive system lacks safety timeout (GilBot_V2 uses 5s failsafe). Add that? ``` ### Indexing Your Repositories **Terminal:** ```bash /index /path/to/your/repos ``` **Web Interface:** 1. Click "📂 Upload" button 2. Drag and drop .zip file or individual code files 3. BuddAI automatically indexes and confirms **Supported File Types:** - Python: `.py` - C++/Arduino: `.cpp`, `.h`, `.ino` - JavaScript: `.js`, `.jsx` - Web: `.html`, `.css` --- ## Real Examples ### Example 1: Motor Driver Class **Input:** ``` James: Generate a motor driver class for L298N with ESP32 ``` **Output (15 seconds):** ```cpp #include // L298N Motor Driver Class // Purpose: Control DC motors with ESP32-C3 via L298N H-bridge class MotorDriver { public: MotorDriver(int in1Pin, int in2Pin, int pwmPin) : _in1(in1Pin), _in2(in2Pin), _pwm(pwmPin) { pinMode(_in1, OUTPUT); pinMode(_in2, OUTPUT); pinMode(_pwm, OUTPUT); // Setup PWM: channel 0, 500Hz, 8-bit resolution ledcSetup(0, 500, 8); ledcAttachPin(_pwm, 0); } void forward(int speed) { digitalWrite(_in1, HIGH); digitalWrite(_in2, LOW); ledcWrite(0, speed); } void backward(int speed) { digitalWrite(_in1, LOW); digitalWrite(_in2, HIGH); ledcWrite(0, speed); } void stop() { digitalWrite(_in1, LOW); digitalWrite(_in2, LOW); ledcWrite(0, 0); } private: int _in1, _in2, _pwm; }; ``` **Style Applied:** - ✅ 500Hz PWM (from your pattern) - ✅ Descriptive naming (forward, backward, stop) - ✅ Purpose comment header - ✅ ledcSetup with 8-bit resolution --- ### Example 2: Complete Robot Controller **Input:** ``` James: Generate the complete GilBot flipper controller with BLE, servo control, motor drivers, and safety timeout ``` **Process:** ``` 🎯 COMPLEX REQUEST DETECTED! Modules needed: ble, servo, motor, safety Breaking into 5 manageable steps ⚡ FORGE THEORY TUNING: 1. Aggressive (k=0.3) - High snap, combat ready 2. Balanced (k=0.1) - Standard movement 3. Graceful (k=0.03) - Smooth curves Select Forge Constant [1-3, default 2]: 1 📦 Step 1/5: BLE communication setup ⚡ Building... ✅ Complete (18s) 📦 Step 2/5: Servo motor control ⚡ Building... ✅ Complete (22s) 📦 Step 3/5: Motor driver setup ⚡ Building... ✅ Complete (25s) 📦 Step 4/5: Safety timeout systems ⚡ Building... ✅ Complete (19s) 📦 Step 5/5: Integration (k=0.3) ⚡ Building... ✅ Complete (28s) PROACTIVE: > Apply Forge Theory smoothing to movement? > Drive system lacks safety timeout. Add 5s failsafe? ``` **Output:** Complete 200+ line controller with: - BLE phone app control via ESP32 BLE library - Servo flipper weapon with Forge Theory smoothing (k=0.3) - L298N motor drivers with PWM - 5-second safety timeout failsafe - Full integration code - **All in YOUR coding style** **Time:** 2 minutes total **Result:** Ready to upload to ESP32-C3 --- ### Example 3: Repository Search **Input:** ``` James: Find examples of non-blocking code in my repos ``` **Output (<1 second):** ``` 🔍 Searching 847 indexed functions... ✅ Found 23 matches for: non-blocking, millis **1. checkSafetyTimeout()** in GilBot_V2 📁 safety_system.ino ```cpp void checkSafetyTimeout() { if (millis() - lastCommandTime > TIMEOUT_MS) { emergencyStop(); } } ``` --- **2. updateLEDPattern()** in StatusLED 📁 led_manager.cpp ```cpp void updateLEDPattern() { unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= interval) { previousMillis = currentMillis; toggleLED(); } } ``` --- [Shows 21 more matches] ``` --- ## Performance ### Benchmarks (v3.2) **Tested on:** ASUS FX505D (slow laptop) - CPU: Ryzen 5 3550H - RAM: 8GB - Storage: HDD | Operation | Time | Model/System | |-----------|------|--------------| | Simple Q&A | 5-10s | FAST (1.5b) | | Code generation | 15-30s | BALANCED (3b) | | Complex project | 2-3min | MODULAR | | Repository index | ~1min | Per 100 files | | Search query | <1s | SQLite | | Session load | <100ms | Database | | Style scan | 30-45s | BALANCED | **Memory Usage:** - Idle: ~200MB - Active (FAST): ~1.2GB - Active (BALANCED): ~2.5GB - Repository index: ~50MB per 1000 files **If it works on this, it'll work on anything.** --- ## Testing ### Run the Test Suite ```bash # Unit Tests python tests/test_buddai.py # Integration Tests python tests/test_integration.py ``` ### Test Coverage (11/11 Passing) **✅ Security Tests:** - Database initialization (4 tables) - SQL injection prevention - Search query safety (XSS protection) - Malicious input handling **✅ Functionality Tests:** - Module detection logic - Complexity routing - Auto-learning pattern extraction - Repository indexing - Context window management - Actionable suggestions - LRU cache performance **✅ Quality Tests:** - Session export functionality - Search result accuracy - Code generation validation **Last Run:** 11/11 tests passing (100%) --- ## Roadmap ### Current Version: v3.2 - Hardened Modular Builder ✅ **Completed (December 29, 2025):** - Persistent memory across sessions - 3-tier intelligent routing - Modular task breakdown - **Repository indexing and search** ✅ - **Style signature learning** ✅ - **Shadow suggestion engine** ✅ - **Web interface with live workspace** ✅ - **Schedule awareness** ✅ - **Forge Theory mode selector** ✅ - **24/24 tests passing** ✅ --- ### Next Version: v4.0 - True Anticipation 🔮 **Goal:** Exocortex that predicts your needs **Features:** - Predictive module suggestions based on context - Learn from feedback loops (thumbs up/down) - Cross-project pattern synthesis - Automatic test generation from code - Multi-model orchestration (Sonnet + specialized models) - Voice interface option - Mobile app (iOS/Android) - Team collaboration features **Timeline:** 1-2 months --- ### Future Version: v5.0 - Ecosystem 🌐 **Goal:** Platform for personal AI exocortex systems **Features:** - Plugin system (custom tools, integrations) - Model marketplace (community models) - Export to various formats (Jupyter, PDF, LaTeX) - Real-time collaboration - Cloud sync (optional, encrypted) - API for third-party integrations - **BuddAI as a framework, not just a tool** **Timeline:** 6+ months --- ## Core Philosophy ### 1. Open Source, Unreplicatable **The Genius Move:** - **MIT Licensed:** Anyone can copy the code - **Unreplicatable:** Your experience is the training data - **Competitive Moat:** System is public, knowledge is yours **Why this works:** - Can't be stolen (already public) - Can't be copied (training data is lived experience) - Can't be exploited (you own everything) ### 2. Freedom-Preserving Design **Built to protect your autonomy:** - Runs locally (no API costs, no surveillance) - You own the stack (can't be locked in) - Fully portable (take it anywhere) - No external dependencies (can't be shut down) - Your data never leaves your machine ### 3. Symbiosis Over Replacement **BuddAI doesn't replace you - it extends you:** **You remain:** - The pattern recognizer - The system designer - The quality validator - The decision maker **BuddAI handles:** - Code generation - Memory - Repository knowledge - Task breakdown - Execution speed #### Together: Unstoppable --- ## Business Model ### What You're Selling **Not the code** (MIT licensed - free forever) **But access to your trained exocortex:** - 8+ years of cross-domain expertise - 115+ repositories of proven solutions - Rapid prototyping capability - **Knowledge system that took years to build** ### Revenue Streams #### 1. Consulting (Project-Based) - Your exocortex + their problem = rapid solutions - 20-hour cycle prototyping - Cross-domain insights nobody else has - **Pricing:** $2,500-$10,000 per project #### 2. IP Licensing - CoffeeForge methodology - CannaForge frameworks - GilBot designs - Forge Theory applications - **Pricing:** $5,000-$50,000 per license #### 3. Training & Workshops - "Build Your Own IP AI Exocortex" (1-day, $500) - "Train on Your Repos" (3-day, $1,500) - "Deploy Production System" (1-week, $2,500) - Corporate training (custom pricing) #### 4. Product Revenue (Passive) - Pre-designed robot kits - Optimization services - Custom conversions - Forge Theory consulting ### The Pitch > "I have an IP AI exocortex trained on 8 years of cross-domain work. > > **You're not hiring a developer.** > **You're licensing access to a knowledge system that took 8 years to build.** > > I can rapid-prototype your solution in 20-hour cycles because my exocortex handles research, memory, and articulation overhead. > > **Interested?**" ### Comparison Table | Feature | GitHub Copilot | ChatGPT | BuddAI | |---------|----------------|---------|-------- | | Trained on YOUR code | ❌ | ❌ | ✅ | | Runs locally | ❌ | ❌ | ✅ | | Knows your patterns | ❌ | ❌ | ✅ | | $0 ongoing cost | ❌ | ❌ | ✅ | | Perfect memory | ❌ | ❌ | ✅ | | Repository search | ❌ | ❌ | ✅ | | Style learning | ❌ | ❌ | ✅ | | No data mining | ❌ | ❌ | ✅ | --- ## Why This is Unreplicatable ### What Anyone Can Copy ✅ The BuddAI code (MIT licensed) ✅ The architecture (fully documented) ✅ The setup process (installation guide) ✅ The concept (IP AI exocortex) ### What Nobody Can Copy ❌ **Your 8+ years of experience** - Can't download lived experience - Can't replicate trial and error - Can't copy pattern recognition intuition ❌ **Your 115+ repositories** - Can fork the code (already public) - Can't replicate the PROCESS that created them - Can't access the failed attempts (stepping stones) - Can't duplicate the cross-domain synthesis ❌ **Your trained BuddAI instance** - Their repos ≠ your repos - Their experience ≠ your experience - Their BuddAI ≠ your BuddAI ### The Paradox **By making it completely open, you make YOUR version completely unreplicatable.** The value isn't the code - it's the **8 years of experience that trained the AI**. Someone can build BuddAI in a day (you just did). They can't replicate your 8 years of work. --- ## Troubleshooting ### Common Issues **"ModuleNotFoundError: No module named 'fastapi'"** ```bash pip install fastapi uvicorn python-multipart ``` **"Ollama not responding"** ```bash # Check if Ollama is running: curl http://localhost:11434/api/tags # If not, start it: ollama serve ``` **"Models not found"** ```bash # Re-pull models: ollama pull qwen2.5-coder:1.5b ollama pull qwen2.5-coder:3b # Verify: ollama list ``` **"Database locked"** - Close any other BuddAI instances - Delete `data/conversations.db-journal` if it exists - Restart BuddAI **"Upload fails"** - Check file size (<50MB recommended for .zip files) - Ensure `.zip` files are valid archives - Verify file types: `.py`, `.ino`, `.cpp`, `.h`, `.js`, `.jsx`, `.html`, `.css` - Check available disk space **"Slow generation"** - First generation is always slower (model loading) - Subsequent generations are faster - Consider using FAST model for simple queries - Close other applications to free RAM **"Search returns no results"** - Run `/index ` to index repositories first - Check that repositories contain supported file types - Verify file paths are correct - Try broader keywords **"Web interface not loading"** ```bash # Check server is running: curl http://localhost:8000 # Check FastAPI is installed: pip show fastapi # Try different port: python buddai_v3.2.py --server --port 8080 ``` --- ## Contributing BuddAI is MIT licensed and open to contributions. ### How to Contribute **For the Core System:** 1. Fork the repository 2. Create feature branch (`git checkout -b feature/amazing-feature`) 3. Commit changes (`git commit -m 'Add amazing feature'`) 4. Push to branch (`git push origin feature/amazing-feature`) 5. Open Pull Request **For Your Own Exocortex:** - Build your own BuddAI - Train it on YOUR repos - Share your experience (blog posts, videos) - Contribute improvements back to core **The Beautiful Part:** Everyone's BuddAI is unique. - Yours trains on your repos - Mine trains on my repos - Someone else's trains on theirs **The code is shared. The knowledge is personal.** ### Development Setup ```bash # Clone repo git clone https://github.com/JamesTheGiblet/BuddAI cd BuddAI # Install dev dependencies pip install fastapi uvicorn python-multipart pytest mypy black # Run tests python tests/test_buddai.py # Run with type checking mypy buddai_v3.2.py # Format code black buddai_v3.2.py ``` --- ## FAQ **Q: Will this work on my laptop?** A: If you have 8GB RAM, yes. Tested on a slow Ryzen 5 with HDD. **Q: Do I need to be online?** A: Only for initial setup (download models). After that, 100% offline. **Q: How much does it cost?** A: $0. Forever. MIT licensed, runs locally, no subscriptions. **Q: Can others copy my BuddAI?** A: They can copy the code. They can't copy your 8 years of experience. **Q: How is this different from Copilot?** A: Copilot trains on all code. BuddAI trains on YOUR code, in YOUR style. **Q: What if I don't have 115 repos?** A: Start with what you have. It grows with you. Even 10 repos provide value. **Q: Is my code/data private?** A: Yes. Everything runs locally. No data ever leaves your machine. **Q: Can I use this commercially?** A: Yes. MIT license allows commercial use. **Q: Does it work with other languages?** A: Currently optimized for Python, C++, Arduino, JS. More coming in v4.0. **Q: Can I deploy this for my team?** A: Not yet (single-user architecture). Multi-tenant coming in v3.2. --- ## What Happens Next **Your journey from here:** **Week 1:** - Use BuddAI for real projects - Index your repositories - Let it learn your style - Build something with its help **Week 2-4:** - Enable semantic search - Use proactive suggestions - Try complex project generation - "Show me all projects using X" **Month 2-3:** - Style learning refines - BuddAI codes in YOUR style consistently - Suggests based on YOUR history - Feels like extension of your mind **Month 6+:** - True exocortex achieved - Anticipates your needs - Seamless integration - **Unstoppable** --- ## Acknowledgments **Built in <2 weeks:** - December 28-29, 2025 - ~20 hours of relentless building - $0 spent on tools or services - **Pure determination and vision** **Built on:** - Ollama (local LLM runtime) - Qwen 2.5 Coder (1.5b and 3b models) - SQLite (persistence) - FastAPI (web server) - React (frontend) - Python (glue code) - **Your idea to break tasks into modules** **Inspired by:** - Tony Stark's JARVIS (but real, and local) - Andy Clark's "Natural-Born Cyborgs" - Douglas Engelbart's vision of augmentation - Every polymath who refused to specialize --- ## License MIT License Copyright (c) 2025 James Gilbert / Giblets Creations Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- ## Contact **Creator:** James Gilbert (JamesTheGiblet) **GitHub:** [@JamesTheGiblet](https://github.com/JamesTheGiblet) **Organization:** [ModularDev-Tools](https://github.com/ModularDev-Tools) **BuddAI Repository:** [https://github.com/JamesTheGiblet/BuddAI](https://github.com/JamesTheGiblet/BuddAI) --- **Status:** ✅ PRODUCTION **Version:** v3.2 - Hardened Modular Builder **Last Updated:** December 29, 2025 **Tests:** 24/24 Passing (100%) **Built:** In <2 weeks with relentless spirit ⚡ --- > "I build what I want. People play games, I make stuff." > — James Gilbert