### Install and Verify TinyBrain Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/integrations/cursor.md Standard installation sequence for the TinyBrain repository and command-line verification. ```bash git clone https://github.com/rainmana/tinybrain.git cd tinybrain make install tinybrain --version ``` -------------------------------- ### Install TinyBrain from Source using Go Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md Installs the TinyBrain server directly using the `go install` command. This is suitable if the repository is public and you prefer a direct installation method. Ensure your Go environment is configured correctly. ```bash go install github.com/rainmana/tinybrain/cmd/server@latest ``` -------------------------------- ### Troubleshoot Authentication Errors with `go install` Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md Provides an alternative installation method when `go install` encounters authentication errors. It suggests cloning the repository, building the binary, and then moving it to the desired location. ```bash # Use direct clone method instead git clone https://github.com/rainmana/tinybrain.git cd tinybrain go build -o tinybrain cmd/server/main.go ``` -------------------------------- ### Clone and Build TinyBrain Locally Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md Installs TinyBrain by cloning the repository and using the make command. This method is recommended for full control over the build process. The binary is installed to the `$GOPATH/bin` directory. ```bash git clone https://github.com/rainmana/tinybrain.git cd tinybrain make install ``` -------------------------------- ### Setup and Initialization Script Source: https://github.com/rainmana/tinybrain-python/blob/main/IMPLEMENTATION.md Shell script to set up the TinyBrain project, including installation and initialization steps. This is the primary script for getting the project running. ```bash ./setup.sh ``` -------------------------------- ### Installation and Environment Setup Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain/README.md Commands to activate the virtual environment and install the TinyBrain package. Supports optional dependencies like ChromaDB for semantic search. ```bash source .venv/bin/activate uv pip install -e . uv pip install -e ".[chromadb]" ``` -------------------------------- ### Clone TinyBrain and Install Dependencies Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Clones the TinyBrain Python repository, optionally installs a specific Python version using mise, creates a virtual environment, and installs project dependencies using UV. ```bash # Clone the repository git clone https://github.com/yourusername/tinybrain-python.git cd tinybrain-python # Install Python version with mise (optional) mise install # Create virtual environment and install dependencies uv sync # Activate virtual environment source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install in development mode uv pip install -e . ``` -------------------------------- ### Build and Install TinyBrain Binary Manually Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md Builds the TinyBrain binary from source and manually moves it to a system-wide executable path. This method provides flexibility in choosing the installation location. ```bash git clone https://github.com/rainmana/tinybrain.git cd tinybrain go build -o tinybrain cmd/server/main.go sudo mv tinybrain /usr/local/bin/ ``` -------------------------------- ### Project Initialization and Setup Source: https://github.com/rainmana/tinybrain-python/blob/main/IMPLEMENTATION.md Standard workflow for setting up the environment, installing dependencies via UV, and initializing the TinyBrain database. ```bash # 1. Run setup script ./setup.sh # 2. Activate virtual environment source .venv/bin/activate # 3. Install package uv pip install -e . # 4. Initialize database tinybrain init # 5. Start server tinybrain serve ``` -------------------------------- ### Bypass Go Module Proxy for Installation Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md Installs the TinyBrain server by explicitly setting `GOPROXY` to `direct`. This can resolve issues related to Go module proxy configurations. ```bash GOPROXY=direct go install github.com/rainmana/tinybrain/cmd/server@latest ``` -------------------------------- ### Configure TinyBrain and MCP Servers Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/CURSOR_SETUP.md Commands to install the rules file and JSON configuration for integrating MCP servers into the Cursor IDE environment. ```bash # Copy the main rules file to your project root cp .cursorrules /path/to/your/project/ # Or copy to your global Cursor config cp .cursorrules ~/.cursor/rules/ # Copy the user template cp .cursorrules.user-template .cursorrules.user # Edit the user file to add your custom MCP servers and preferences nano .cursorrules.user ``` ```json { "mcpServers": { "tinybrain": { "command": "tinybrain", "args": [] }, "clear-thought": { "command": "npx", "args": ["@clear-thought/mcp-server"] }, "stochastic-thinking": { "command": "npx", "args": ["@stochastic-thinking/mcp-server"] } } } ``` -------------------------------- ### Development Environment Setup in Bash Source: https://github.com/rainmana/tinybrain-python/blob/main/README.md Provides commands for setting up the development environment, including installing dependencies, running tests with coverage, formatting code, linting, and type checking. ```bash # Install with dev dependencies uv sync --all-extras # Run tests pytest # Run tests with coverage pytest --cov=tinybrain --cov-report=html # Format code ruff format . # Lint code ruff check . # Type check mypy tinybrain ``` -------------------------------- ### Configure TinyBrain Environment Variables Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Copies the example environment file and allows customization of database path, log level, and log file location by editing the `.env` file. ```bash cp .env.example .env TINYBRAIN_DB_PATH=~/.tinybrain/memory.db TINYBRAIN_LOG_LEVEL=INFO TINYBRAIN_LOG_FILE=~/.tinybrain/logs/tinybrain.log ``` -------------------------------- ### Start TinyBrain MCP Server Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Starts the TinyBrain MCP (Message Communication Protocol) server. The server listens for MCP protocol messages on standard input and output. ```bash tinybrain serve ``` -------------------------------- ### Start TinyBrain Server Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/README.md Instructions on how to start the TinyBrain server, including the default command and how to specify a custom database path using an environment variable. ```bash # Start the server (uses ~/.tinybrain/memory.db by default) tinybrain # Or with custom database path TINYBRAIN_DB_PATH=/path/to/your/memory.db tinybrain ``` -------------------------------- ### Install UV Package Manager Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Installs the UV package manager using a curl script. This is a prerequisite for managing Python dependencies and running the TinyBrain server efficiently. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### MCP Client: Create Session Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md An example MCP client message to create a new session in TinyBrain. It requires a name, task type, and an optional description for the session. ```json { "name": "create_session", "arguments": { "name": "Web App Security Review", "task_type": "security_review", "description": "Comprehensive security review of web application" } } ``` -------------------------------- ### Install TinyBrain Server Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/README.md Provides instructions for installing the TinyBrain server using different methods, including cloning the repository and building locally, installing from source, or building the binary directly. It covers common troubleshooting steps for Go installation issues. ```bash # Method 1: Clone and build locally (recommended) git clone https://github.com/rainmana/tinybrain.git cd tinybrain make install # Method 2: Install from source (if repository is public) go install github.com/rainmana/tinybrain/cmd/server@latest # Method 3: Build binary directly git clone https://github.com/rainmana/tinybrain.git cd tinybrain go build -o tinybrain cmd/server/main.go sudo mv tinybrain /usr/local/bin/ ``` ```bash # If you get authentication errors, use direct clone method git clone https://github.com/rainmana/tinybrain.git cd tinybrain go build -o tinybrain cmd/server/main.go # If repository is private, ensure you have access git config --global url."git@github.com:".insteadOf "https://github.com/" # For Go module proxy issues, use direct mode GOPROXY=direct go install github.com/rainmana/tinybrain/cmd/server@latest ``` -------------------------------- ### Quick Start Workflow in Python Source: https://github.com/rainmana/tinybrain-python/blob/main/README.md Demonstrates a typical workflow for using TinyBrain, including getting help, listing valid values, creating sessions, storing memories, and establishing relationships between memories. ```python # 1. Get help get_tinybrain_help() # 2. See valid values list_memory_categories() list_task_types() # 3. Create a session create_session(name="Security Review", task_type="security_review") # Returns: {"id": "sess_abc123", "status": "created"} # 4. Store memories store_memory( session_id="sess_abc123", title="SQL Injection Found", content="Login form vulnerable to SQL injection", category="vulnerability", priority=8, confidence=0.9 ) # 5. Search and relate search_memories(query="SQL injection", session_id="sess_abc123") create_relationship( source_memory_id="mem_123", target_memory_id="mem_456", relationship_type="exploits" ) ``` -------------------------------- ### Configure Cursor Rules and Templates Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/integrations/cursor.md Commands to deploy the required .cursorrules file to your project or global configuration and initialize user-specific templates. ```bash # Copy to your project root cp .cursorrules /path/to/your/project/ # Or copy to your global Cursor config cp .cursorrules ~/.cursor/rules/ # Copy the user template cp .cursorrules.user-template .cursorrules.user ``` -------------------------------- ### TinyBrain CLI Commands Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Demonstrates various command-line interface commands for TinyBrain, including database initialization, server startup, statistics retrieval, memory cleanup, and custom configuration. ```bash # Initialize database tinybrain init # Start MCP server tinybrain serve # Show statistics tinybrain stats # Clean up old memories (dry run) tinybrain cleanup --max-age 30 --dry-run # Clean up old memories (actual deletion) tinybrain cleanup --max-age 30 # Use custom database path tinybrain serve --db-path /path/to/custom.db # Set log level tinybrain serve --log-level DEBUG ``` -------------------------------- ### Avoid Context Overload Example (Bash) Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/CWE_TINYBRAIN_INTEGRATION.md An example demonstrating a command to avoid within TinyBrain's context-optimized usage. Loading the entire dataset at once is discouraged to prevent context window overload. ```bash # ❌ DON'T: Load entire dataset at once cline "Load all 28 CWE patterns into TinyBrain" # Too much context ``` -------------------------------- ### Start TinyBrain Web UI Source: https://github.com/rainmana/tinybrain-python/blob/main/WEB_UI_DEMO.md Commands to start the TinyBrain web interface and access it via a web browser. It also shows how to specify a custom port or database path. ```bash # Start the web interface tinybrain web # Open in browser open http://localhost:8080 ``` ```bash tinybrain web --port 3000 ``` ```bash tinybrain web --db-path ~/my-security-work/findings.db ``` ```bash # Use a different port tinybrain web --port 8081 ``` -------------------------------- ### Troubleshoot Database Issues Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Instructions for resolving database issues by removing the existing database file and reinitializing it using the `tinybrain init` command. ```bash # Reinitialize database rm ~/.tinybrain/memory.db tinybrain init ``` -------------------------------- ### Configure MCP Servers in Cursor Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/integrations/cursor.md JSON configuration snippets for the Cursor settings file to enable TinyBrain and additional MCP servers like clear-thought or filesystem access. ```json { "mcpServers": { "tinybrain": { "command": "tinybrain", "args": [] }, "clear-thought": { "command": "npx", "args": ["@clear-thought/mcp-server"] }, "stochastic-thinking": { "command": "npx", "args": ["@stochastic-thinking/mcp-server"] } } } ``` -------------------------------- ### Start TinyBrain MCP Server (Bash) Source: https://context7.com/rainmana/tinybrain-python/llms.txt Starts the TinyBrain MCP server, which communicates via standard input and output. Allows configuration of the database path and log level. ```bash # Start the MCP server (communicates via stdin/stdout) tinybrain serve # With custom database and log level tinybrain serve --db-path ~/.tinybrain/memory.db --log-level DEBUG ``` -------------------------------- ### Package Installation via Pip Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain/README.md Standard installation method for the TinyBrain package using the pip package manager. ```bash pip install tinybrain ``` -------------------------------- ### Troubleshoot UV Issues Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Steps to resolve issues with the UV package manager, including updating UV, clearing its cache, and synchronizing dependencies. ```bash # Update UV curl -LsSf https://astral.sh/uv/install.sh | sh # Clear cache rm -rf .uv uv sync ``` -------------------------------- ### Define Custom Security Templates and Quality Standards Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/CURSOR_SETUP.md Configuration snippets for defining custom vulnerability patterns and setting quality assurance thresholds within the TinyBrain workflow. ```json { "name": "my_custom_vulnerability", "title": "Custom Vulnerability Pattern", "content": "Description of your custom vulnerability pattern...", "category": "vulnerability", "priority": 8, "confidence": 0.9 } ``` ```python QUALITY_CHECKS = { "min_findings_per_assessment": 10, "min_high_priority_findings": 3, "require_exploit_code": true, "require_remediation_steps": true } ``` -------------------------------- ### Ensure Database Directory Permissions Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md Creates the TinyBrain database directory and sets appropriate permissions to ensure the server can write to it. This is a common fix for database-related startup issues. ```bash mkdir -p ~/.tinybrain chmod 755 ~/.tinybrain ``` -------------------------------- ### Advanced MCP Database and Logging Configuration Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/integrations/cursor.md JSON configurations for customizing database paths (local or shared) and enabling debug logging levels within the MCP server definition. ```json { "mcpServers": { "tinybrain": { "command": "tinybrain", "env": { "TINYBRAIN_DB_PATH": "~/.tinybrain/memory.db", "TINYBRAIN_LOG_LEVEL": "debug" } } } } ``` -------------------------------- ### Initialize TinyBrain Database Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Initializes the TinyBrain SQLite database, creating all necessary tables and indexes. The database file is typically located at `~/.tinybrain/memory.db`. ```bash tinybrain init ``` -------------------------------- ### Start TinyBrain Web Interface (Bash) Source: https://context7.com/rainmana/tinybrain-python/llms.txt Starts the TinyBrain web interface. By default, it runs on port 8080. Custom host, port, and database path can be specified. ```bash # Start the web interface on default port 8080 tinybrain web # Custom host and port tinybrain web --host 0.0.0.0 --port 3000 --db-path ~/.tinybrain/memory.db ``` -------------------------------- ### Configure Claude Desktop MCP Server Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Adds configuration to Claude Desktop's `claude_desktop_config.json` to connect to the TinyBrain MCP server, specifying the command, arguments, and environment variables. ```json { "mcpServers": { "tinybrain": { "command": "tinybrain", "args": ["serve"], "env": { "TINYBRAIN_DB_PATH": "~/.tinybrain/memory.db", "TINYBRAIN_LOG_LEVEL": "INFO" } } } } ``` -------------------------------- ### Configure UV for MCP Server Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Configures Claude Desktop to use UV to run the TinyBrain MCP server, specifying the command, arguments, working directory, and environment variables. ```json { "mcpServers": { "tinybrain": { "command": "uv", "args": ["run", "tinybrain", "serve"], "cwd": "/path/to/tinybrain-python", "env": { "TINYBRAIN_DB_PATH": "~/.tinybrain/memory.db" } } } } ``` -------------------------------- ### Start Penetration Test with Roo Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/AI_ASSISTANT_INTEGRATION.md Initiates a TinyBrain session for comprehensive penetration testing of a target domain. This command sets up the environment for subsequent testing phases. ```bash # Start penetration test roo "Initialize TinyBrain session for comprehensive penetration testing of target.com" ``` -------------------------------- ### Run TinyBrain Tests with Pytest Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md Commands to run tests for the TinyBrain project using Pytest. Includes options for running all tests, running with code coverage, and running specific test files. ```bash # Run all tests pytest # Run with coverage pytest --cov=tinybrain --cov-report=html # Run specific test file pytest tests/test_database.py ``` -------------------------------- ### Initialize TinyBrain Server Components Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/architecture.md A sequence of Go code snippets demonstrating the initialization of the TinyBrain MCP server, including logger setup, database path resolution, repository creation, and tool registration. ```go logger := log.NewWithOptions(os.Stderr, log.Options{ ReportCaller: true, ReportTimestamp: true, TimeFormat: time.Kitchen, Prefix: "TinyBrain 🧠 ", Level: log.InfoLevel, }) ``` ```go dbPath := os.Getenv("TINYBRAIN_DB_PATH") if dbPath == "" { homeDir, err := os.UserHomeDir() if err != nil { logger.Fatal("Failed to get user home directory", "error", err) } dbPath = filepath.Join(homeDir, ".tinybrain", "memory.db") } ``` ```go db, err := database.NewDatabase(dbPath, logger) if err != nil { logger.Fatal("Failed to initialize database", "error", err) } defer db.Close() ``` ```go repo := repository.NewMemoryRepository(db.GetDB(), logger) ``` ```go mcpServer := mcp.NewServer("TinyBrain Memory Storage", "1.0.0", "Security-focused LLM memory storage MCP server", logger) ``` ```go tinyBrain.registerTools(mcpServer) ``` ```go if err := mcpServer.ServeStdio(); err != nil { logger.Fatal("Server error", "error", err) } ``` -------------------------------- ### Create Test Session in TinyBrain Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md A JSON payload to send to the TinyBrain server to create a test session. This is part of the verification process to ensure the installation is working correctly. ```json { "name": "create_session", "arguments": { "name": "Test Session", "description": "Testing TinyBrain installation", "task_type": "general" } } ``` -------------------------------- ### Development Environment Setup Commands Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/contributing.md Commands to clone the repository, configure remotes, and initialize the development environment using Go and Make. ```bash git clone https://github.com/YOUR_USERNAME/tinybrain.git cd tinybrain git remote add upstream https://github.com/rainmana/tinybrain.git make dev-setup go mod download go mod tidy make test make build ``` -------------------------------- ### MCP Client: Search Memories Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md An example MCP client message to search for memories in TinyBrain. It allows specifying a query, session ID, minimum priority, and a limit for the results. ```json { "name": "search_memories", "arguments": { "query": "SQL injection", "session_id": "sess_abc123", "min_priority": 7, "limit": 20 } } ``` -------------------------------- ### MCP Client: Store Memory Source: https://github.com/rainmana/tinybrain-python/blob/main/QUICKSTART.md An example MCP client message to store a memory in TinyBrain. It includes details like session ID, title, content, category, priority, confidence, tags, and source. ```json { "name": "store_memory", "arguments": { "session_id": "sess_abc123", "title": "SQL Injection in Login Form", "content": "Found SQL injection vulnerability in username parameter", "category": "vulnerability", "priority": 8, "confidence": 0.9, "tags": ["sql-injection", "authentication", "critical"], "source": "manual-testing" } } ``` -------------------------------- ### Running TinyBrain Server and UI Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain/README.md Commands to launch the MCP server with custom database paths and start the Streamlit-based web interface. ```bash tinybrain serve tinybrain serve --db-path ~/.tinybrain/data.db streamlit run tinybrain/ui/app.py tinybrain ui ``` -------------------------------- ### Get Memory Example Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/api/examples.md Provides an example of how to retrieve a specific memory item using its unique ID. ```json { "name": "get_memory", "arguments": { "memory_id": "memory_sql_injection" } } ``` -------------------------------- ### Start TinyBrain Service Command Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain/test_scenarios/quick_test_guide.md This command is used to start the TinyBrain service from the terminal. It's a basic command to ensure the TinyBrain application is running. ```bash tinybrain ``` -------------------------------- ### Get Database Statistics Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/examples/basic_usage.md Retrieves statistics about the database. ```APIDOC ## POST /get_database_stats ### Description Retrieves statistics about the database. ### Method POST ### Endpoint /get_database_stats ### Parameters #### Request Body (No parameters required) ### Request Example ```json { "name": "get_database_stats", "arguments": {} } ``` ### Response #### Success Response (200) - **stats** (object) - An object containing various database statistics (e.g., number of records, storage usage, query performance). #### Response Example ```json { "stats": { "total_memories": 15000, "storage_gb": 2.5, "average_query_time_ms": 50 } } ``` ``` -------------------------------- ### TinyBrain Configuration Files Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/AI_ASSISTANT_INTEGRATION.md Illustrates the file structure for configuring the TinyBrain project, including rulesets for Cursor and Cline, Roo mode configuration, user-specific settings, and integration documentation. ```bash your-project/ ├── .cursorrules # Cursor security assessment rules ├── .clinerules # Cline code review and exploitation rules ├── .roo-mode # Roo penetration testing configuration ├── .cursorrules.user # User-specific Cursor configuration └── AI_ASSISTANT_INTEGRATION.md # This integration guide ``` -------------------------------- ### Memory Operations - Get Memory Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/api/examples.md Retrieve a specific memory entry by its unique ID. ```APIDOC ## Memory Operations - Get Memory ### Description Retrieve a specific memory entry using its unique identifier. ### Method GET ### Endpoint /api/memories/{memory_id} ### Parameters #### Path Parameters - **memory_id** (string) - Required - The unique identifier of the memory to retrieve. ### Request Example ```json { "name": "get_memory", "arguments": { "memory_id": "memory_sql_injection" } } ``` ### Response #### Success Response (200) - **memory** (object) - The retrieved memory object, containing fields like `id`, `title`, `content`, `category`, etc. #### Response Example ```json { "memory": { "id": "memory_sql_injection", "session_id": "session_123", "title": "SQL Injection in User Search", "content": "Found SQL injection vulnerability...", "category": "vulnerability", "priority": 9, "confidence": 0.95, "tags": ["sql-injection", "search", "critical", "data-loss"], "source": "code-review", "created_at": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### Get Context Summary Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/examples/basic_usage.md Retrieves a summary of relevant memories for the current task within a given session. ```APIDOC ## POST /get_context_summary ### Description Retrieves a summary of relevant memories for the current task within a given session. ### Method POST ### Endpoint /get_context_summary ### Parameters #### Request Body - **session_id** (string) - Required - The ID of the current session. - **current_task** (string) - Required - A description of the current task being performed. - **max_memories** (integer) - Optional - The maximum number of memories to include in the summary. ### Request Example ```json { "name": "get_context_summary", "arguments": { "session_id": "session_123", "current_task": "Analyzing authentication vulnerabilities in web application", "max_memories": 15 } } ``` ### Response #### Success Response (200) - **context_summary** (string) - A textual summary of relevant memories. #### Response Example ```json { "context_summary": "Relevant memories include details on previous authentication bypass techniques and known vulnerabilities in similar applications." } ``` ``` -------------------------------- ### Get Related Memories Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/examples/basic_usage.md Finds memories related to a specific memory ID, based on a defined relationship type. ```APIDOC ## POST /get_related_memories ### Description Finds memories related to a specific memory ID, based on a defined relationship type. ### Method POST ### Endpoint /get_related_memories ### Parameters #### Request Body - **memory_id** (string) - Required - The ID of the memory to find related items for. - **relationship_type** (string) - Required - The type of relationship to search for (e.g., "exploits", "vulnerabilities", "techniques"). - **limit** (integer) - Optional - Maximum number of related memories to return. ### Request Example ```json { "name": "get_related_memories", "arguments": { "memory_id": "memory_sql_injection", "relationship_type": "exploits", "limit": 5 } } ``` ### Response #### Success Response (200) - **related_memories** (array of objects) - A list of related memory objects. #### Response Example ```json { "related_memories": [ { "memory_id": "mem_exploit_001", "title": "Exploit for SQL Injection Vulnerability", "relationship": "exploit" } ] } ``` ``` -------------------------------- ### Go Implementation and Testing Patterns Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/contributing.md Examples demonstrating the expected Go coding style for repository methods and table-driven unit testing. ```go // CreateSession creates a new security assessment session func (r *Repository) CreateSession(ctx context.Context, session *models.Session) error { if session == nil { return fmt.Errorf("session cannot be nil") } if err := session.Validate(); err != nil { return fmt.Errorf("invalid session: %w", err) } _, err := r.db.ExecContext(ctx, query, session.ID, session.Name, ...) if err != nil { return fmt.Errorf("failed to create session: %w", err) } return nil } ``` ```go func TestCreateSession(t *testing.T) { tests := []struct { name string session *models.Session wantErr bool }{ {"valid session", &models.Session{ID: "test-id", Name: "Test Session"}, false}, {"nil session", nil, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := repo.CreateSession(ctx, tt.session) if (err != nil) != tt.wantErr { t.Errorf("CreateSession() error = %v, wantErr %v", err, tt.wantErr) } }) } } ``` -------------------------------- ### Context & Task Tracking - Get Context Summary Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/api/examples.md Retrieve a summary of relevant memories for the current task within a given session. ```APIDOC ## Context & Task Tracking - Get Context Summary ### Description Obtain a summarized view of relevant memory entries pertinent to the current task being performed within a specific session. ### Method POST ### Endpoint /api/context/summary ### Parameters #### Request Body - **name** (string) - Required - The name of the operation to perform ('get_context_summary'). - **arguments** (object) - Required - Contains the parameters for the operation. - **session_id** (string) - Required - The ID of the session. - **current_task** (string) - Required - A description of the current task. - **max_memories** (integer) - Optional - The maximum number of memories to include in the summary. ### Request Example ```json { "name": "get_context_summary", "arguments": { "session_id": "session_123", "current_task": "Analyzing authentication vulnerabilities in web application", "max_memories": 15 } } ``` ### Response #### Success Response (200) - **summary** (string) - A textual summary of relevant memories. - **relevant_memories** (array) - A list of memory objects considered relevant. #### Response Example ```json { "summary": "Key findings include SQL injection and XSS vulnerabilities in the authentication module. Further analysis is needed on session management.", "relevant_memories": [ { "id": "memory_sql_injection", "title": "SQL Injection in User Search" }, { "id": "memory_xss_auth", "title": "XSS in Login Form" } ] } ``` ``` -------------------------------- ### Reset TinyBrain Database Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/getting-started.md Commands to reset the TinyBrain database. This can be done using the `make db-reset` command or by manually removing the database files. ```bash make db-reset # Or manually: rm -f ~/.tinybrain/memory.db* ``` -------------------------------- ### Relationship Management - Get Related Memories Source: https://github.com/rainmana/tinybrain-python/blob/main/tinybrain-copilot-add-github-pages-documentation/tinybrain-copilot-add-github-pages-documentation/docs/api/examples.md Find memory entries that are related to a given memory ID through specified relationship types. ```APIDOC ## Relationship Management - Get Related Memories ### Description Retrieve memory entries that are connected to a specified memory ID via a particular type of relationship. ### Method GET ### Endpoint /api/memories/{memory_id}/related ### Parameters #### Path Parameters - **memory_id** (string) - Required - The ID of the memory to find related entries for. #### Query Parameters - **relationship_type** (string) - Optional - Filter by a specific relationship type (e.g., 'exploits'). - **limit** (integer) - Optional - The maximum number of related memories to return. ### Request Example ```json { "name": "get_related_memories", "arguments": { "memory_id": "memory_sql_injection", "relationship_type": "exploits", "limit": 5 } } ``` ### Response #### Success Response (200) - **related_memories** (array) - A list of memory objects related to the specified memory ID. #### Response Example ```json { "related_memories": [ { "id": "memory_exploit_1", "title": "Exploit for SQL Injection", "category": "exploit", "strength": 0.8 }, { "id": "memory_exploit_2", "title": "Advanced SQLi Attack", "category": "exploit", "strength": 0.75 } ] } ``` ``` -------------------------------- ### Execute Database Query in Go and Python Source: https://github.com/rainmana/tinybrain-python/blob/main/GO_VS_PYTHON.md Shows how to execute a SQL query to retrieve memory entries based on session ID and priority. The Go example uses the standard `database/sql` package, while the Python example uses an asynchronous SQLite driver. ```go rows, err := db.Query(` SELECT * FROM memory_entries WHERE session_id = ? AND priority >= ? ORDER BY created_at DESC LIMIT ? `, sessionID, minPriority, limit) ``` ```python cursor = await db._conn.execute( """SELECT * FROM memory_entries WHERE session_id = ? AND priority >= ? ORDER BY created_at DESC LIMIT ?""", (session_id, min_priority, limit) ) ``` -------------------------------- ### Configure FastAPI Web Server Source: https://github.com/rainmana/tinybrain-python/blob/main/WEB_UI_DESIGN.md Initializes the FastAPI application, mounts static file directories, and defines the root route to serve the main HTML interface. ```python from pathlib import Path from fastapi import FastAPI from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse app = FastAPI() static_dir = Path(__file__).parent / "static" app.mount("/static", StaticFiles(directory=static_dir), name="static") @app.get("/") async def root(): return FileResponse(static_dir / "index.html") ```