@vercel/geistdocs 2.14.6 → 2.14.7-canary.6ce58a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +5 -5
- package/dist/config.d.ts +23 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/controls.d.ts +3 -40
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +5 -96
- package/dist/internal/chat-retrieval.d.ts +10 -9
- package/dist/internal/chat-retrieval.d.ts.map +1 -1
- package/dist/internal/chat-retrieval.js +32 -68
- package/dist/internal/controls-client.d.ts +40 -0
- package/dist/internal/controls-client.d.ts.map +1 -0
- package/dist/internal/controls-client.js +87 -0
- package/dist/internal/language-selector.d.ts +2 -0
- package/dist/internal/language-selector.d.ts.map +1 -0
- package/dist/internal/language-selector.js +12 -0
- package/dist/internal/mixedbread-store.d.ts +53 -0
- package/dist/internal/mixedbread-store.d.ts.map +1 -0
- package/dist/internal/mixedbread-store.js +129 -0
- package/dist/internal/navbar/mobile-menu.js +1 -1
- package/dist/internal/page-action-options.d.ts +37 -0
- package/dist/internal/page-action-options.d.ts.map +1 -0
- package/dist/internal/page-action-options.js +39 -0
- package/dist/internal/page-actions-client.d.ts +1 -31
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +5 -103
- package/dist/internal/page-actions-gate.d.ts +3 -0
- package/dist/internal/page-actions-gate.d.ts.map +1 -0
- package/dist/internal/page-actions-gate.js +15 -0
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +26 -1
- package/dist/internal/relative-docs-link.d.ts +7 -0
- package/dist/internal/relative-docs-link.d.ts.map +1 -0
- package/dist/internal/relative-docs-link.js +22 -0
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +1 -1
- package/dist/internal/toc-actions-client.d.ts +9 -0
- package/dist/internal/toc-actions-client.d.ts.map +1 -0
- package/dist/internal/toc-actions-client.js +78 -0
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +5 -2
- package/dist/navbar.js +1 -1
- package/dist/pages/changelog.js +1 -1
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +4 -3
- package/dist/routes/chat.d.ts +4 -4
- package/dist/routes/chat.d.ts.map +1 -1
- package/dist/routes/chat.js +19 -34
- package/dist/routes/openapi.d.ts.map +1 -1
- package/dist/routes/openapi.js +13 -5
- package/dist/routes/search-export.d.ts +1 -1
- package/dist/routes/search-export.d.ts.map +1 -1
- package/dist/routes/search-export.js +5 -2
- package/dist/routes/search.d.ts +10 -2
- package/dist/routes/search.d.ts.map +1 -1
- package/dist/routes/search.js +215 -55
- package/docs/agents.md +3 -3
- package/docs/llms.txt +214 -32
- package/docs/manifest.json +5 -5
- package/docs/pages/ask-ai.md +1 -1
- package/docs/pages/configuration.md +26 -3
- package/docs/pages/env.md +5 -5
- package/docs/pages/index.md +1 -1
- package/docs/pages/llms-txt.md +1 -1
- package/docs/pages/mixedbread-retrieval.md +174 -18
- package/docs/pages/provider.md +3 -0
- package/docs/sitemap.md +2 -2
- package/package.json +6 -6
- package/template/.env.example +1 -0
- package/template/AGENTS.md +11 -7
- package/template/content/docs/ask-ai.mdx +1 -1
- package/template/content/docs/configuration.mdx +26 -3
- package/template/content/docs/env.mdx +5 -5
- package/template/content/docs/index.mdx +1 -1
- package/template/content/docs/llms-txt.mdx +1 -1
- package/template/content/docs/mixedbread-retrieval.mdx +174 -18
- package/template/content/docs/provider.mdx +3 -0
- package/template/geistdocs.tsx +6 -1
- package/template/lib/geistdocs/config.tsx +2 -0
- package/template/package.json +1 -1
package/dist/routes/search.js
CHANGED
|
@@ -2,9 +2,18 @@ import { createTokenizer as createTokenizerJapanese } from "@orama/tokenizers/ja
|
|
|
2
2
|
import { createTokenizer as createTokenizerMandarin } from "@orama/tokenizers/mandarin";
|
|
3
3
|
import { defineI18n } from "fumadocs-core/i18n";
|
|
4
4
|
import { findPath } from "fumadocs-core/page-tree";
|
|
5
|
+
import { createContentHighlighter, } from "fumadocs-core/search";
|
|
5
6
|
import { createI18nSearchAPI, } from "fumadocs-core/search/server";
|
|
7
|
+
import { createStoreReader, getReaderProvider, resolveMixedbreadConnection, } from "../internal/mixedbread-store";
|
|
6
8
|
import { isPageVisibleForSurface, } from "../page-visibility";
|
|
7
9
|
import { isGeistdocsSourceBundle } from "../source";
|
|
10
|
+
const MIXEDBREAD_REQUEST_TIMEOUT_MS = 1500;
|
|
11
|
+
const MIXEDBREAD_TOP_K = 32;
|
|
12
|
+
const MAX_PAGES = 8;
|
|
13
|
+
const MAX_SECTIONS_PER_PAGE = 3;
|
|
14
|
+
const PROVIDER_HEADER = "x-geistdocs-search-provider";
|
|
15
|
+
const NON_WORD_PATTERN = /[^\p{L}\p{N}]+/gu;
|
|
16
|
+
const WHITESPACE_PATTERN = /\s+/;
|
|
8
17
|
const getLanguages = (config) => {
|
|
9
18
|
const defaultLanguage = config.defaultLanguage ?? "en";
|
|
10
19
|
const languages = Object.keys(config.translations ?? {});
|
|
@@ -48,65 +57,216 @@ const getBreadcrumbs = (pageTree, url) => {
|
|
|
48
57
|
}
|
|
49
58
|
return breadcrumbs.length > 0 ? breadcrumbs : undefined;
|
|
50
59
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
locale,
|
|
62
|
-
translation.displayName.toLowerCase(),
|
|
63
|
-
]));
|
|
64
|
-
if ("cn" in translations) {
|
|
65
|
-
localeMap.cn = {
|
|
66
|
-
components: {
|
|
67
|
-
tokenizer: createTokenizerMandarin(),
|
|
68
|
-
},
|
|
69
|
-
search: {
|
|
70
|
-
threshold: 0,
|
|
71
|
-
tolerance: 0,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
60
|
+
const normalizeHeading = (text) => text.toLowerCase().replace(NON_WORD_PATTERN, " ").trim();
|
|
61
|
+
const locateHeading = (chunk, headings) => {
|
|
62
|
+
for (const candidate of chunk.headings) {
|
|
63
|
+
const normalized = normalizeHeading(candidate);
|
|
64
|
+
const heading = normalized
|
|
65
|
+
? headings.find((entry) => normalizeHeading(entry.content) === normalized)
|
|
66
|
+
: undefined;
|
|
67
|
+
if (heading) {
|
|
68
|
+
return heading;
|
|
69
|
+
}
|
|
74
70
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
};
|
|
72
|
+
const countQueryTerms = (content, terms) => {
|
|
73
|
+
const text = content.toLowerCase();
|
|
74
|
+
return terms.filter((term) => text.includes(term)).length;
|
|
75
|
+
};
|
|
76
|
+
const pickParagraph = (contents, terms) => {
|
|
77
|
+
let best;
|
|
78
|
+
let bestCount = -1;
|
|
79
|
+
for (const entry of contents) {
|
|
80
|
+
const count = countQueryTerms(entry.content, terms);
|
|
81
|
+
if (count > bestCount) {
|
|
82
|
+
best = entry;
|
|
83
|
+
bestCount = count;
|
|
84
|
+
}
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
return best;
|
|
87
|
+
};
|
|
88
|
+
const renderStoreResults = ({ hits, locale, query, }) => {
|
|
89
|
+
const highlighter = createContentHighlighter(query);
|
|
90
|
+
const terms = Array.from(new Set(query.toLowerCase().split(WHITESPACE_PATTERN).filter(Boolean)));
|
|
91
|
+
const toResult = (result) => ({
|
|
92
|
+
...result,
|
|
93
|
+
contentWithHighlights: highlighter.highlight(result.content),
|
|
94
|
+
});
|
|
95
|
+
return hits.slice(0, MAX_PAGES).flatMap(({ chunks, page, source }) => {
|
|
96
|
+
const data = page.data;
|
|
97
|
+
const { contents, headings } = data.structuredData ?? {
|
|
98
|
+
contents: [],
|
|
99
|
+
headings: [],
|
|
100
|
+
};
|
|
101
|
+
const results = [
|
|
102
|
+
toResult({
|
|
103
|
+
breadcrumbs: getBreadcrumbs(getPageTree(source, locale), page.url),
|
|
104
|
+
content: data.title ?? page.url,
|
|
94
105
|
id: page.url,
|
|
95
|
-
|
|
96
|
-
description: data.description ?? "",
|
|
97
|
-
breadcrumbs: getBreadcrumbs(pageTree, page.url),
|
|
98
|
-
locale,
|
|
99
|
-
structuredData: data.structuredData ?? {
|
|
100
|
-
contents: [],
|
|
101
|
-
headings: [],
|
|
102
|
-
},
|
|
106
|
+
type: "page",
|
|
103
107
|
url: page.url,
|
|
108
|
+
}),
|
|
109
|
+
];
|
|
110
|
+
const sections = new Set();
|
|
111
|
+
for (const chunk of chunks) {
|
|
112
|
+
if (sections.size === MAX_SECTIONS_PER_PAGE) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
const heading = locateHeading(chunk, headings);
|
|
116
|
+
if (sections.has(heading?.id)) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
sections.add(heading?.id);
|
|
120
|
+
const url = heading ? `${page.url}#${heading.id}` : page.url;
|
|
121
|
+
if (heading) {
|
|
122
|
+
results.push(toResult({ content: heading.content, id: url, type: "heading", url }));
|
|
123
|
+
}
|
|
124
|
+
const paragraph = pickParagraph(contents.filter((entry) => entry.heading === heading?.id), terms);
|
|
125
|
+
if (paragraph) {
|
|
126
|
+
results.push(toResult({
|
|
127
|
+
content: paragraph.content,
|
|
128
|
+
id: `text:${url}`,
|
|
129
|
+
type: "text",
|
|
130
|
+
url,
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return results;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const withProvider = (response, provider) => {
|
|
138
|
+
const headers = new Headers(response.headers);
|
|
139
|
+
headers.set(PROVIDER_HEADER, provider);
|
|
140
|
+
return new Response(response.body, {
|
|
141
|
+
headers,
|
|
142
|
+
status: response.status,
|
|
143
|
+
statusText: response.statusText,
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
export const createSearchRoute = ({ config, filterPage, mixedbread, source, sources, }) => {
|
|
147
|
+
const translations = config.translations ?? {};
|
|
148
|
+
const routeSources = resolveSources(source, sources);
|
|
149
|
+
const { defaultLanguage, languages } = getLanguages(config);
|
|
150
|
+
const createLocalSearch = () => {
|
|
151
|
+
const i18n = defineI18n({
|
|
152
|
+
defaultLanguage,
|
|
153
|
+
languages,
|
|
154
|
+
hideLocale: "default-locale",
|
|
155
|
+
});
|
|
156
|
+
const localeMap = Object.fromEntries(Object.entries(translations).map(([locale, translation]) => [
|
|
157
|
+
locale,
|
|
158
|
+
translation.displayName.toLowerCase(),
|
|
159
|
+
]));
|
|
160
|
+
if ("cn" in translations) {
|
|
161
|
+
localeMap.cn = {
|
|
162
|
+
components: {
|
|
163
|
+
tokenizer: createTokenizerMandarin(),
|
|
164
|
+
},
|
|
165
|
+
search: {
|
|
166
|
+
threshold: 0,
|
|
167
|
+
tolerance: 0,
|
|
168
|
+
},
|
|
104
169
|
};
|
|
170
|
+
}
|
|
171
|
+
if ("jp" in translations) {
|
|
172
|
+
localeMap.jp = {
|
|
173
|
+
components: {
|
|
174
|
+
tokenizer: createTokenizerJapanese(),
|
|
175
|
+
},
|
|
176
|
+
search: {
|
|
177
|
+
threshold: 0,
|
|
178
|
+
tolerance: 0,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const getIndexes = () => languages.flatMap((locale) => routeSources.flatMap((source) => {
|
|
183
|
+
const pageTree = getPageTree(source, locale);
|
|
184
|
+
return getPages(source, locale)
|
|
185
|
+
.filter((page) => isPageVisibleForSurface(page, "search") &&
|
|
186
|
+
(filterPage?.(page, { lang: locale, source }) ?? true))
|
|
187
|
+
.map((page) => {
|
|
188
|
+
const data = page.data;
|
|
189
|
+
return {
|
|
190
|
+
id: page.url,
|
|
191
|
+
title: data.title ?? page.url,
|
|
192
|
+
description: data.description ?? "",
|
|
193
|
+
breadcrumbs: getBreadcrumbs(pageTree, page.url),
|
|
194
|
+
locale,
|
|
195
|
+
structuredData: data.structuredData ?? {
|
|
196
|
+
contents: [],
|
|
197
|
+
headings: [],
|
|
198
|
+
},
|
|
199
|
+
url: page.url,
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}));
|
|
203
|
+
return createI18nSearchAPI("advanced", {
|
|
204
|
+
i18n,
|
|
205
|
+
indexes: getIndexes,
|
|
206
|
+
localeMap,
|
|
207
|
+
}).GET;
|
|
208
|
+
};
|
|
209
|
+
if (getReaderProvider(config, "search") !== "mixedbread") {
|
|
210
|
+
return createLocalSearch();
|
|
211
|
+
}
|
|
212
|
+
let localSearch;
|
|
213
|
+
const answerLocally = async (request) => {
|
|
214
|
+
localSearch ??= createLocalSearch();
|
|
215
|
+
return withProvider(await localSearch(request), "local");
|
|
216
|
+
};
|
|
217
|
+
const connection = resolveMixedbreadConnection({
|
|
218
|
+
defaultTimeoutMs: MIXEDBREAD_REQUEST_TIMEOUT_MS,
|
|
219
|
+
options: mixedbread,
|
|
220
|
+
siteId: config.siteId,
|
|
221
|
+
});
|
|
222
|
+
const store = connection.status === "ready"
|
|
223
|
+
? {
|
|
224
|
+
read: createStoreReader({
|
|
225
|
+
connection,
|
|
226
|
+
filterPage,
|
|
227
|
+
sources: routeSources,
|
|
228
|
+
surface: "search",
|
|
229
|
+
}),
|
|
230
|
+
status: "ready",
|
|
231
|
+
}
|
|
232
|
+
: connection;
|
|
233
|
+
let warnedUnconfigured = false;
|
|
234
|
+
return async (request) => {
|
|
235
|
+
const url = new URL(request.url);
|
|
236
|
+
const query = url.searchParams.get("query")?.trim() ?? "";
|
|
237
|
+
const locale = url.searchParams.get("locale") ?? defaultLanguage;
|
|
238
|
+
if (!query || url.searchParams.has("tag") || !languages.includes(locale)) {
|
|
239
|
+
return answerLocally(request);
|
|
240
|
+
}
|
|
241
|
+
if (store.status === "unconfigured") {
|
|
242
|
+
if (!warnedUnconfigured) {
|
|
243
|
+
warnedUnconfigured = true;
|
|
244
|
+
console.warn(`[Geistdocs search] search.provider is "mixedbread" but ${store.missing.join(", ")} is missing. Serving local search.`);
|
|
245
|
+
}
|
|
246
|
+
return answerLocally(request);
|
|
247
|
+
}
|
|
248
|
+
let hits;
|
|
249
|
+
try {
|
|
250
|
+
hits = await store.read({
|
|
251
|
+
locale,
|
|
252
|
+
query,
|
|
253
|
+
signal: request.signal,
|
|
254
|
+
topK: MIXEDBREAD_TOP_K,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
if (request.signal.aborted) {
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
console.warn("[Geistdocs search] Mixedbread search failed. Serving local search.", error);
|
|
262
|
+
return answerLocally(request);
|
|
263
|
+
}
|
|
264
|
+
const results = renderStoreResults({ hits, locale, query });
|
|
265
|
+
if (results.length === 0) {
|
|
266
|
+
return answerLocally(request);
|
|
267
|
+
}
|
|
268
|
+
return Response.json(results, {
|
|
269
|
+
headers: { [PROVIDER_HEADER]: "mixedbread" },
|
|
105
270
|
});
|
|
106
|
-
}
|
|
107
|
-
return createI18nSearchAPI("advanced", {
|
|
108
|
-
i18n,
|
|
109
|
-
indexes: getIndexes,
|
|
110
|
-
localeMap,
|
|
111
|
-
}).GET;
|
|
271
|
+
};
|
|
112
272
|
};
|
package/docs/agents.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Geistdocs Package Docs
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@vercel/geistdocs` 2.14.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.14.7-canary.6ce58a6 so agents can understand the installed package without web access.
|
|
4
4
|
They are generated from `apps/template/content/docs` during the package build.
|
|
5
5
|
|
|
6
6
|
## How to use these files
|
|
@@ -24,7 +24,7 @@ They are generated from `apps/template/content/docs` during the package build.
|
|
|
24
24
|
|
|
25
25
|
- [Overview](pages/index.md): Geistdocs is a packaged documentation system for creating Next.js and Fumadocs sites with shared runtime features.
|
|
26
26
|
- [Getting Started](pages/getting-started.md): Create a Geistdocs project, run it locally, and edit your first documentation page.
|
|
27
|
-
- [Environment Variables](pages/env.md): Environment variables required by Geistdocs for AI chat, Mixedbread retrieval, proxy mode, eve agent session cookies, and production URL configuration.
|
|
27
|
+
- [Environment Variables](pages/env.md): Environment variables required by Geistdocs for AI chat, Mixedbread retrieval for Ask AI and site search, proxy mode, eve agent session cookies, and production URL configuration.
|
|
28
28
|
- [Deploy to Vercel](pages/deployment.md): Deploy a Geistdocs site to Vercel with the required project settings and environment variables.
|
|
29
29
|
- [Migrate to Geistdocs](pages/migration.md): Move an existing documentation site to @vercel/geistdocs while keeping local content, routing, middleware behavior, and AI-readable surfaces intact.
|
|
30
30
|
- [Choose a Geistdocs package](pages/packages.md): Use the public package by default and the private package only where restricted Vercel npm dependencies are already available.
|
|
@@ -52,7 +52,7 @@ They are generated from `apps/template/content/docs` during the package build.
|
|
|
52
52
|
- [Edit on GitHub](pages/edit-on-github.md): A direct link on every documentation page that lets readers propose changes through GitHub pull requests.
|
|
53
53
|
- [Feedback](pages/feedback.md): An interactive feedback widget that collects user sentiment and creates structured GitHub Issues automatically.
|
|
54
54
|
- [Image](pages/components/image.md): Use the Geistdocs Image wrapper for documentation-aware Next.js images.
|
|
55
|
-
- [Improve Ask AI
|
|
55
|
+
- [Improve Ask AI and site search with Mixedbread](pages/mixedbread-retrieval.md): Provision a Mixedbread Store for one Geistdocs consumer site, turn on semantic retrieval for Ask AI with ai.retrieval and for site search with search.provider, and sync documentation during production builds.
|
|
56
56
|
- [Input](pages/components/input.md): Use Input for text entry in custom documentation and application interfaces.
|
|
57
57
|
- [Internationalization](pages/internationalization.md): Serve documentation in multiple languages with automatic translation via the Geistdocs CLI and Fumadocs routing.
|
|
58
58
|
- [llms.txt](pages/llms-txt.md): A single endpoint that returns all documentation as plain Markdown text following the llms.txt standard.
|