Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c7b063c
Add docs RAG ingestion pipeline for Meilisearch
Strift Nov 4, 2026
4e3ca9e
Add custom Ask AI chat widget (Vite bundle, AI SDK, Meilisearch)
Strift Nov 4, 2026
a437430
Add expand_page chat tool and make chunks lossless
Strift Nov 4, 2026
7f5b8f6
checkpoint before checking out main
Strift Nov 10, 2026
c787718
update prompt
Strift Nov 12, 2026
0d9aea4
Widen the Ask AI panel and list each source page once.
Strift Nov 12, 2026
ddc46af
Send the reader's code-sample language with each chat request.
Strift Nov 12, 2026
b8f962d
Index API routes and mounted code samples so chat can answer with req…
Strift Nov 12, 2026
ee7c404
Style Ask AI code samples to match the documentation code groups.
Strift Nov 12, 2026
525d003
Always load the docs chat and read its settings from environment vari…
Strift Nov 18, 2026
1db24b0
Load each docs preview's chat from that branch's Vercel deployment.
Strift Nov 18, 2026
0ab2e23
Load the chat from the local dev server when previewing docs on local…
Strift Nov 18, 2026
fa9be89
Import the compiled samples module so the chat function can start on …
Strift Nov 18, 2026
b94f06b
Make the Ask AI panel push the docs column aside so the page stays re…
Strift Nov 18, 2026
6e6caab
Let the docs chat find API routes by SDK method name and rerank a wid…
Strift Nov 18, 2026
0b1dc30
Log a federated chat trace so search latency and relevancy can be tuned.
Strift Nov 18, 2026
2d48fef
Match the Ask Meilisearch header to the docs navbar.
Strift Nov 18, 2026
2826d06
Cap the docs chat at two searches and run it in London so answers sta…
Strift Nov 18, 2026
becf6e4
Pin the docs chat to OpenAI so follow-ups can decrypt prior reasoning.
Strift Nov 18, 2026
d4c2c68
Raise the docs chat reasoning effort to medium.
Strift Nov 24, 2026
7c5bd61
Index changelog releases separately so the docs chat can cite when a …
Strift Nov 24, 2026
badb9b9
Show only the pages an answer cites, ranked by the final rerank score.
Strift Nov 24, 2026
740f5d2
Let the docs chat answer release-window questions from changelog dates.
Strift Nov 24, 2026
9c95c52
Remove the unused model latency benchmark script.
Strift Nov 24, 2026
9217ff9
Derive chat links from page paths so they stay on the reader's domain.
Strift Nov 24, 2026
8ad3fef
Catch .ts import specifiers in chat/ with oxlint.
Strift Nov 24, 2026
2f1f52c
Split the docs chat into an agent, a widget, and shared helpers.
Strift Nov 24, 2026
485ba97
Test the docs chat and ingestion through one Vitest runner.
Strift Nov 24, 2026
5193b41
Select the sink tests as a Vitest project instead of a second config.
Strift Nov 24, 2026
3f740f6
Revert Node bumps in unrelated workflows and rename the test workflow.
Strift Nov 25, 2026
2f71486
Route docs chat questions through a guardrail router before answering.
Strift Nov 25, 2026
9fa25ad
Filter the chat tests by path and move the test notes into CONTRIBUTING.
Strift Nov 25, 2026
022f2d6
Trace each docs chat answer in PostHog and log feedback clicks.
cursoragent Nov 25, 2026
431fc14
Keep chat traces and conversation ids intact when a step fails.
cursoragent Nov 25, 2026
cdcdb9d
Add on-demand evals so docs chat retrieval and answers can be scored …
Strift Nov 30, 2026
a5de42b
Score docs chat answers by the fact they state, and keep each eval re…
Strift Dec 1, 2026
04c62e7
Improve docs chat prompts, tools, and evals to reach 41/41 passing.
Strift Dec 1, 2026
62ffbcd
Space docs chat replies like the rest of the page.
Strift Dec 1, 2026
2c01154
Send docs chat click events without PostHog identity
Strift Dec 1, 2026
99b4ef7
Send docs chat thumbs as PostHog survey responses so they show on AI …
Strift Dec 1, 2026
bbe581c
Call OpenAI directly for the docs chat and use one env var naming sch…
Strift Dec 1, 2026
b6c3346
Make the docs chat reranking model configurable and group .env exampl…
Strift Dec 1, 2026
2aa99b7
Fix truncated chat code blocks and steer HTTP examples to cURL route …
Strift Dec 2, 2026
ee052d2
Optimize docs chat prompt caching and support code language overrides
Strift Dec 2, 2026
70f163a
Align chat UI tokens, collapse tool steps, and add API source breadcr…
Strift Dec 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Meilisearch (indexing)
MEILISEARCH_URL=https://ms-909f535664f8-173.lon.meilisearch.io
MEILISEARCH_ADMIN_KEY=
MEILISEARCH_DOCS_INDEX=docs-chunks
MEILISEARCH_ROUTES_INDEX=api-routes
MEILISEARCH_CHANGELOG_INDEX=changelog-chunks
MEILISEARCH_EMBEDDER=voyage

# Voyage (embedding, reranking in evals)
VOYAGE_API_KEY=

# OpenAI API key (completion in evals, embedding in search staging)
OPENAI_API_KEY=

# AI assistant models (evals)
CHAT_MODEL=gpt-6-luna
CHAT_RERANKING_MODEL=rerank-3

# Meilisearch (search in evals, falls back to MEILISEARCH_ADMIN_KEY)
MEILISEARCH_SEARCH_KEY=

# Meilisearch (Mintlify search staging)
MEILISEARCH_HOST_URL=https://ms-909f535664f8-173.lon.meilisearch.io
MEILISEARCH_API_KEY=
44 changes: 44 additions & 0 deletions .github/workflows/ingest-chat-indexes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Keeps the docs chat indexes in sync. Sync state lives in Meilisearch, so unchanged pages are skipped.
name: Ingest chat indexes

on:
workflow_dispatch:
inputs:
force:
description: Re-sync every page, even unchanged ones
type: boolean
default: false
push:
branches:
- main

jobs:
ingest:
name: Ingest docs into Meilisearch
if: github.repository == 'meilisearch/documentation'
runs-on: ubuntu-latest
concurrency:
group: ingest
cancel-in-progress: false
steps:
- uses: actions/checkout@v6

# `--env-file-if-exists` in the ingest script needs Node.js 22.
- uses: actions/setup-node@v7
with:
node-version: "22"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Ingest
run: npm run ingest -- ${{ github.event_name == 'workflow_dispatch' && inputs.force && '--force' || '' }}
env:
MEILISEARCH_URL: ${{ vars.MEILISEARCH_URL }}
MEILISEARCH_ADMIN_KEY: ${{ secrets.MEILISEARCH_ADMIN_KEY }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
MEILISEARCH_DOCS_INDEX: ${{ vars.MEILISEARCH_DOCS_INDEX }}
MEILISEARCH_ROUTES_INDEX: ${{ vars.MEILISEARCH_ROUTES_INDEX }}
MEILISEARCH_CHANGELOG_INDEX: ${{ vars.MEILISEARCH_CHANGELOG_INDEX }}
MEILISEARCH_EMBEDDER: ${{ vars.MEILISEARCH_EMBEDDER }}
101 changes: 101 additions & 0 deletions .github/workflows/test-chat.yml
Comment thread
Strift marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Test the docs chat

on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- "chat/**"
- "scripts/ingest/**"
- "config/navigation.json"
- "assets/release-assets/**"
- "package.json"
- "package-lock.json"
- "vitest.config.ts"
- ".oxlintrc.json"
- ".github/workflows/test-chat.yml"

jobs:
lint:
name: Lint and typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm

- name: Install dependencies
run: |
npm ci
npm ci --prefix chat

- name: Lint
run: npm run lint

- name: Typecheck
run: npm run typecheck

ingest:
name: Test ingestion
runs-on: ubuntu-latest
services:
meilisearch:
image: getmeili/meilisearch:v1.58
ports:
- 7700:7700
env:
MEILI_ENV: development
MEILI_MASTER_KEY: masterKey
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm

- name: Install dependencies
run: |
npm ci
npm ci --prefix chat

- name: Wait for Meilisearch
run: |
for _ in $(seq 1 30); do
curl -sf http://localhost:7700/health && exit 0
sleep 1
done
echo "Meilisearch did not become healthy" >&2
exit 1

- name: Unit tests
run: npm run ingest:test

- name: Integration tests
run: npm run ingest:integration
env:
MEILI_TEST_URL: http://localhost:7700
MEILI_TEST_KEY: masterKey

chat:
name: Test chat
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm

- name: Install dependencies
run: |
npm ci
npm ci --prefix chat

- name: Unit tests
run: npm run chat:test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ yarn-error.log

# Script output
broken-links.txt
.ingest/
.evals/

# Evals index override. Loaded after .env by `npm run chat:eval`.
.env.evals

# Claude Code (local only, not committed)
.claude/superpowers
Expand Down
1 change: 1 addition & 0 deletions .mintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Agent instruction files are not documentation pages.
**/AGENTS.md
chat/
45 changes: 45 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"ignorePatterns": [
"node_modules",
"chat/dist",
"chat/.vercel",
"snippets",
"assets/release-assets"
],
"overrides": [
{
// Only chat/ is bundled by Vite
"files": [
"chat/**/*.ts",
"chat/**/*.tsx"
],
"excludeFiles": [
"chat/**/__tests__/**"
],
"rules": {
"no-restricted-imports": [
"error",
{
"patterns": [
{
// Vite compiles api/*.ts to *.js but copies relative specifiers
// verbatim, so a .ts import ships a function that crashes at startup
// with ERR_MODULE_NOT_FOUND. chat/tsconfig.json sets
// allowImportingTsExtensions and Vite resolves .ts in dev, so this
// only shows up in production.
"group": [
"**/*.ts",
"**/*.tsx",
"**/*.mts",
"**/*.cts"
],
"message": "Import the .js specifier instead. Vercel compiles chat/ to JavaScript and keeps the specifier verbatim, so a .ts import crashes the deployed function with ERR_MODULE_NOT_FOUND."
}
]
}
]
}
}
]
}
6 changes: 5 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

Canonical setup and commands stay in [CONTRIBUTING.md](CONTRIBUTING.md). These details are easy to miss when running the docs in a Cloud Agent:

- Mintlify requires Node.js 20.17 or newer and refuses Node.js 25. Node.js 22 on the default Cloud Agent image is enough. `.nvmrc` lists 23, and CI uses Node.js 20. Do not install another Node.js version unless `mint dev` fails its version check.
- Mintlify requires Node.js 20.17 or newer and refuses Node.js 25. The chat and ingestion tests need Node.js 22 or newer. Node.js 22 on the default Cloud Agent image is enough. `.nvmrc` lists 23. Do not install another Node.js version unless `mint dev` fails its version check.
- Install dependencies with `npm ci`. The local preview client is stored in `~/.mintlify` and is downloaded from `releases.mintlify.com` when it is missing.
- Start the site with `npx mint dev --no-open`. It listens on `http://localhost:3000`. `/` redirects to `/getting_started/overview`.
- Reading pages does not require a Mintlify account. Full-text search in the preview requires `mint login`.

## Tests

`npm run chat:eval` runs the docs assistant evals. It needs `OPENAI_API_KEY` in `.env`, costs money, and is not part of `npm test`. It uses `MEILISEARCH_SEARCH_KEY`, or `MEILISEARCH_ADMIN_KEY` when that is unset. `.env.evals` overrides the Meilisearch URL and index names.

## Moving pages

Putting an existing page under another navigation group, tab, or section is a page move, even when the request only names the group. Use the `move-page` skill: it moves the file to a path that matches the new group, updates `config/navigation.json` and internal links, and adds redirects in `config/redirects.json`. Do not only edit `config/navigation.json`.
36 changes: 35 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This guide covers how to set up your environment and run the docs locally, rebui

## Technical requirements

- **Node.js** 20.17 or newer, but older than 25 (required by Mintlify)
- **Node.js** 22 or newer, but older than 25. Mintlify refuses Node.js 25. Ingestion uses `path.matchesGlob`, which needs Node.js 22.
- **npm** (comes with Node.js)

## Install
Expand All @@ -26,8 +26,11 @@ From the root of the repository:

```bash
npm install
npm install --prefix chat
```

The chat widget is its own package. The second command installs it. Unit tests and `npm run typecheck` need both.

## Docs writing

Before writing or editing documentation content, read our guide on [Contributing to our documentation](https://www.meilisearch.com/docs/resources/help/contributing_docs).
Expand Down Expand Up @@ -68,6 +71,27 @@ npm run rebuild-search-staging

## Tests

`chat/agent/`, `chat/shared/`, and `scripts/ingest/` run in Node. `chat/app/` runs in jsdom. Integration tests talk to a real Meilisearch and are not part of `npm test`.

| Script | What it runs |
|--------|----------------|
| `npm test` | Every unit test |
| `npm run chat:test` | The assistant, the widget, and `chat/shared/` |
| `npm run ingest:test` | Ingestion, plus `chat/shared/` (ingestion imports those helpers) |
| `npm run ingest:integration` | The Meilisearch sink. Fails if `MEILI_TEST_URL` is unset. |
| `npm run chat:eval` | The docs assistant against the indexes in `.env`. Needs `OPENAI_API_KEY` and costs money. Uses `MEILISEARCH_SEARCH_KEY`, or `MEILISEARCH_ADMIN_KEY` when the search key is unset. `.env.evals` overrides the URL and index names. Not part of `npm test`. |
| `npm run test:watch` | The unit tests in watch mode |
| `npm run typecheck` | `scripts/ingest` and `chat/` |

Write the failing test first. Name the test after the behavior, and put it in `__tests__/` next to the module.

To run the integration tests locally:

```bash
docker run --rm -p 7700:7700 -e MEILI_ENV=development -e MEILI_MASTER_KEY=masterKey getmeili/meilisearch:v1.58
MEILI_TEST_URL=http://localhost:7700 MEILI_TEST_KEY=masterKey npm run ingest:integration
```

### Broken links

Check for broken links in the doc site:
Expand All @@ -87,6 +111,16 @@ npx mint broken-links
| `npm run check-broken-links` | Checks internal links in MDX files against local pages, OpenAPI-generated reference pages, and redirect sources. Runs from local files only. |
| `npm run check-openapi-routes-coverage` | Checks that every route of the OpenAPI spec is listed in the API reference pages of `config/navigation.json`. Exits with error if not. |

## Linting

Lint the repository with:

```bash
npm run lint
```

`npm run lint:chat` lints only the assistant app.

## Code samples

### What they are
Expand Down
53 changes: 53 additions & 0 deletions chat-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Loads the "Ask AI" chat widget (source in /chat, built with Vite and hosted on Vercel).
// Mintlify serves this file on every page; the widget itself is not part of the docs build.
//
// Mintlify cannot read Vercel's env vars. A preview hostname already ends with the branch
// slug Vercel puts in VERCEL_BRANCH_URL:
// meilisearch-6b28dec2-<branch>.mintlify.site
// -> documentation-chat-git-<branch>-meili.vercel.app
// The bundle then calls the API on the origin baked in from that env var.

const MEILI_CHAT_PROD_URL = 'https://documentation-chat.vercel.app'
// Used only when `npm run dev` is running in chat/. 127.0.0.1 avoids an IPv6-only bind.
const MEILI_CHAT_DEV_URL = 'http://127.0.0.1:5173'
const MINTLIFY_PREVIEW = /^meilisearch-6b28dec2-(.+)\.mintlify\.site$/
// DNS labels are at most 63 characters. Vercel truncates the branch alias to fit.
const BRANCH_PREFIX = 'documentation-chat-git-'
const BRANCH_SUFFIX = '-meili'

function branchChatUrl(hostname) {
const match = hostname.match(MINTLIFY_PREVIEW)
if (!match || !/^[a-z0-9-]+$/.test(match[1])) return ''
const room = 63 - BRANCH_PREFIX.length - BRANCH_SUFFIX.length
const branch = match[1].slice(0, room).replace(/-+$/, '')
if (!branch) return ''
return `https://${BRANCH_PREFIX}${branch}${BRANCH_SUFFIX}.vercel.app`
}

function loadMeilisearchChat() {
if (window.__meiliChatLoaded) {
return
}

const { hostname } = window.location
const isLocal = hostname === 'localhost' || hostname === '127.0.0.1'
// Local docs always use the chat dev server (`npm run dev` in chat/).
const base = (isLocal ? MEILI_CHAT_DEV_URL : branchChatUrl(hostname) || MEILI_CHAT_PROD_URL).replace(/\/$/, '')
window.__meiliChatLoaded = true

const script = document.createElement('script')
script.src = `${base}/chat.js`
script.async = true
script.onload = () => window.MeiliChat && window.MeiliChat.mount({ apiBase: base })
script.onerror = () => {
window.__meiliChatLoaded = false
console.warn('Meilisearch chat widget failed to load from', script.src)
}
document.head.appendChild(script)
}

if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadMeilisearchChat)
} else {
loadMeilisearchChat()
}
26 changes: 26 additions & 0 deletions chat/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# OpenAI API key (completion)
OPENAI_API_KEY=

# AI assistant models
CHAT_MODEL=gpt-6-luna
CHAT_RERANKING_MODEL=rerank-3

# Meilisearch (search)
MEILISEARCH_URL=https://ms-909f535664f8-173.lon.meilisearch.io
MEILISEARCH_SEARCH_KEY=
MEILISEARCH_DOCS_INDEX=docs-chunks
MEILISEARCH_ROUTES_INDEX=api-routes
MEILISEARCH_CHANGELOG_INDEX=changelog-chunks
MEILISEARCH_EMBEDDER=voyage

# Voyage (reranking)
VOYAGE_API_KEY=

# Chat API (CORS)
CHAT_ALLOWED_ORIGINS=meilisearch.com,*.meilisearch.com,*.mintlify.site

# PostHog (analytics, optional)
POSTHOG_PROJECT_TOKEN=
POSTHOG_HOST=https://eu.i.posthog.com
POSTHOG_FEEDBACK_SURVEY_ID=
POSTHOG_FEEDBACK_QUESTION_ID=
Loading
Loading