> ## Documentation Index
> Fetch the complete documentation index at: https://docs.deepmako.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Base

> Curated Base ecosystem knowledge with auto-injection and explicit search.

Mako includes a lightweight RAG (Retrieval-Augmented Generation) system with curated knowledge about top projects in the Base ecosystem.

## How it works

At startup, the gateway loads JSON files from `gateway/src/knowledge/` into an in-memory index. Each file describes a single project with structured metadata.

### Entry format

```json theme={null}
{
  "name": "Aerodrome",
  "category": "DeFi",
  "summary": "The central DEX and liquidity hub on Base.",
  "keywords": ["aerodrome", "aero", "dex", "liquidity", "ve33"],
  "token": { "symbol": "AERO", "chain": "base" },
  "links": { "website": "https://aerodrome.finance" },
  "details": "Aerodrome is a ve(3,3) DEX that serves as the primary...",
  "notable_agents": [
    { "name": "AeroBot", "description": "Automated LP management" }
  ]
}
```

## Two retrieval modes

### 1. Automatic context injection

Before every inference call, the gateway scans the user's message against **85+ keyword triggers** built from each project's `keywords` array and `name`.

If keywords match, the gateway injects up to **2 project summaries** (\~500 tokens) as a system message immediately after the main system prompt. This happens before the model sees the message, so the model has relevant context without needing to call any tool.

**Matching rules:**

* Keywords are matched as whole words (word-boundary regex) to avoid false positives
* Short keywords (≤3 chars) require extra context — either a `$` prefix or strict word-boundary matching
* Matches are scored by keyword hit count; the top 2 are injected
* Project details are truncated to 600 characters to save tokens

### 2. Explicit search via `knowledge_search`

The model can also call `knowledge_search` directly when it needs project information.

**Parameters:** `query` (required)

The search scores entries across multiple fields with weighted relevance:

| Field        | Score weight  |
| ------------ | ------------- |
| Project name | +10 per match |
| Keywords     | +5 per match  |
| Category     | +3 per match  |
| Summary      | +2 per match  |
| Details      | +1 per match  |

Returns up to **5 results**, each including:

```json theme={null}
{
  "query": "defi on base",
  "results": [
    {
      "name": "Aerodrome",
      "category": "DeFi",
      "summary": "The central DEX and liquidity hub on Base.",
      "details": "Aerodrome is a ve(3,3) DEX...",
      "token": "$AERO",
      "website": "https://aerodrome.finance",
      "notable_agents": "AeroBot: Automated LP management"
    }
  ],
  "count": 1
}
```

If `query` is empty, the tool returns all entries (name, category, summary only).

## Covered projects

The knowledge base currently includes 15+ entries spanning:

* **DeFi** — Aerodrome, Moonwell, Morpho, Aave
* **AI Agents** — Virtuals, Venice, Clanker
* **Social** — Farcaster, Zora
* **Infrastructure** — Coinbase Wallet, Smart Wallets, Basescan
* **Memecoins** — Notable memecoins on Base

## Adding entries

To add a new project, create a JSON file in `gateway/src/knowledge/` following the entry format above. The gateway will load it automatically on the next restart — no code changes needed.
