@vercel/geistdocs 2.14.5 → 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.
Files changed (93) hide show
  1. package/dist/assets/icons/icon-share.d.ts +13 -0
  2. package/dist/assets/icons/icon-share.d.ts.map +1 -0
  3. package/dist/assets/icons/icon-share.js +12 -0
  4. package/dist/assets/icons/index.d.ts +1 -0
  5. package/dist/assets/icons/index.d.ts.map +1 -1
  6. package/dist/assets/icons/index.js +1 -0
  7. package/dist/cli/index.js +5 -5
  8. package/dist/config.d.ts +38 -3
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/controls.d.ts +3 -40
  11. package/dist/controls.d.ts.map +1 -1
  12. package/dist/controls.js +5 -96
  13. package/dist/internal/chat/share-chat.d.ts +7 -0
  14. package/dist/internal/chat/share-chat.d.ts.map +1 -0
  15. package/dist/internal/chat/share-chat.js +76 -0
  16. package/dist/internal/chat/sharing.d.ts +24 -0
  17. package/dist/internal/chat/sharing.d.ts.map +1 -0
  18. package/dist/internal/chat/sharing.js +117 -0
  19. package/dist/internal/chat/shell.d.ts.map +1 -1
  20. package/dist/internal/chat/shell.js +2 -1
  21. package/dist/internal/chat-retrieval.d.ts +10 -9
  22. package/dist/internal/chat-retrieval.d.ts.map +1 -1
  23. package/dist/internal/chat-retrieval.js +32 -68
  24. package/dist/internal/controls-client.d.ts +40 -0
  25. package/dist/internal/controls-client.d.ts.map +1 -0
  26. package/dist/internal/controls-client.js +87 -0
  27. package/dist/internal/language-selector.d.ts +2 -0
  28. package/dist/internal/language-selector.d.ts.map +1 -0
  29. package/dist/internal/language-selector.js +12 -0
  30. package/dist/internal/mixedbread-store.d.ts +53 -0
  31. package/dist/internal/mixedbread-store.d.ts.map +1 -0
  32. package/dist/internal/mixedbread-store.js +129 -0
  33. package/dist/internal/navbar/mobile-menu.js +1 -1
  34. package/dist/internal/page-action-options.d.ts +37 -0
  35. package/dist/internal/page-action-options.d.ts.map +1 -0
  36. package/dist/internal/page-action-options.js +39 -0
  37. package/dist/internal/page-actions-client.d.ts +1 -31
  38. package/dist/internal/page-actions-client.d.ts.map +1 -1
  39. package/dist/internal/page-actions-client.js +5 -103
  40. package/dist/internal/page-actions-gate.d.ts +3 -0
  41. package/dist/internal/page-actions-gate.d.ts.map +1 -0
  42. package/dist/internal/page-actions-gate.js +15 -0
  43. package/dist/internal/provider-client.d.ts.map +1 -1
  44. package/dist/internal/provider-client.js +26 -1
  45. package/dist/internal/relative-docs-link.d.ts +7 -0
  46. package/dist/internal/relative-docs-link.d.ts.map +1 -0
  47. package/dist/internal/relative-docs-link.js +22 -0
  48. package/dist/internal/sidebar.d.ts.map +1 -1
  49. package/dist/internal/sidebar.js +1 -1
  50. package/dist/internal/toc-actions-client.d.ts +9 -0
  51. package/dist/internal/toc-actions-client.d.ts.map +1 -0
  52. package/dist/internal/toc-actions-client.js +78 -0
  53. package/dist/mdx.d.ts.map +1 -1
  54. package/dist/mdx.js +5 -2
  55. package/dist/navbar.js +1 -1
  56. package/dist/pages/changelog.js +1 -1
  57. package/dist/pages/docs.d.ts.map +1 -1
  58. package/dist/pages/docs.js +4 -3
  59. package/dist/routes/chat.d.ts +4 -4
  60. package/dist/routes/chat.d.ts.map +1 -1
  61. package/dist/routes/chat.js +19 -34
  62. package/dist/routes/openapi.d.ts.map +1 -1
  63. package/dist/routes/openapi.js +13 -5
  64. package/dist/routes/search-export.d.ts +1 -1
  65. package/dist/routes/search-export.d.ts.map +1 -1
  66. package/dist/routes/search-export.js +5 -2
  67. package/dist/routes/search.d.ts +10 -2
  68. package/dist/routes/search.d.ts.map +1 -1
  69. package/dist/routes/search.js +215 -55
  70. package/docs/agents.md +3 -3
  71. package/docs/llms.txt +237 -32
  72. package/docs/manifest.json +5 -5
  73. package/docs/pages/ask-ai.md +17 -1
  74. package/docs/pages/configuration.md +33 -3
  75. package/docs/pages/env.md +5 -5
  76. package/docs/pages/index.md +1 -1
  77. package/docs/pages/llms-txt.md +1 -1
  78. package/docs/pages/mixedbread-retrieval.md +174 -18
  79. package/docs/pages/provider.md +3 -0
  80. package/docs/sitemap.md +2 -2
  81. package/package.json +6 -6
  82. package/template/.env.example +1 -0
  83. package/template/AGENTS.md +11 -7
  84. package/template/content/docs/ask-ai.mdx +17 -1
  85. package/template/content/docs/configuration.mdx +33 -3
  86. package/template/content/docs/env.mdx +5 -5
  87. package/template/content/docs/index.mdx +1 -1
  88. package/template/content/docs/llms-txt.mdx +1 -1
  89. package/template/content/docs/mixedbread-retrieval.mdx +174 -18
  90. package/template/content/docs/provider.mdx +3 -0
  91. package/template/geistdocs.tsx +6 -1
  92. package/template/lib/geistdocs/config.tsx +2 -0
  93. package/template/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Link from "fumadocs-core/link";
3
3
  import { DocsBody as FumadocsDocsBody, DocsPage as FumadocsDocsPage, DocsTitle as FumadocsDocsTitle, } from "fumadocs-ui/layouts/docs/page";
4
- import { createRelativeLink } from "fumadocs-ui/mdx";
5
4
  import { notFound } from "next/navigation";
6
5
  import { cache, } from "react";
7
6
  import { cn } from "#geistdocs-ui/utils";
@@ -14,11 +13,13 @@ import { omitLanguageParam, resolveRouteLanguage } from "../internal/languages";
14
13
  import { resolveLinkHref, stripBasePathFromHref } from "../internal/link-href";
15
14
  import { resolvePageMarkdownUrl as resolveInternalPageMarkdownUrl } from "../internal/markdown-url.js";
16
15
  import { createPageActions as createInternalPageActions } from "../internal/page-actions";
17
- import { GeistdocsPageActions, GeistdocsTableOfContentsActions, } from "../internal/page-actions-client";
16
+ import { GeistdocsPageActions } from "../internal/page-actions-gate";
18
17
  import { PageBreadcrumb } from "../internal/page-breadcrumb";
19
18
  import { getPageFooterItems, PageFooter } from "../internal/page-footer";
20
19
  import { filterPageTree } from "../internal/page-tree-visibility";
20
+ import { createRelativeDocsLink } from "../internal/relative-docs-link";
21
21
  import { GeistdocsTableOfContents } from "../internal/table-of-contents";
22
+ import { GeistdocsTableOfContentsActions } from "../internal/toc-actions-client";
22
23
  import { createMdxComponents } from "../mdx";
23
24
  import { getPageRobots, } from "../page-visibility";
24
25
  const renderPrefetchedDocsLink = (siteUrl, basePath, { children, className, href, rel, target, ...props }) => {
@@ -106,7 +107,7 @@ export const createDocsPage = ({ canViewPage, config, source, mdx, pageActions =
106
107
  const pageTree = await getPageTree(resolvedParams);
107
108
  const data = page.data;
108
109
  const MDX = data.body;
109
- const defaultLink = createRelativeLink(source.source, page, DocsLink);
110
+ const defaultLink = createRelativeDocsLink(source.source, page, DocsLink);
110
111
  const link = resolveLink
111
112
  ? resolveLink({
112
113
  link: defaultLink,
@@ -1,7 +1,7 @@
1
1
  import { type LanguageModel } from "ai";
2
2
  import { type GeistdocsConfig } from "../config";
3
- import { type ChatMixedbreadOptions } from "../internal/chat-retrieval";
4
3
  import { type EveAgentClientContext } from "../internal/eve-agent";
4
+ import { type GeistdocsMixedbreadOptions } from "../internal/mixedbread-store";
5
5
  import { type GeistdocsPageFilter } from "../page-visibility";
6
6
  import type { GeistdocsSourceBundle } from "../source";
7
7
  type SourceBundle = GeistdocsSourceBundle;
@@ -130,10 +130,10 @@ interface CreateChatRouteOptions {
130
130
  */
131
131
  limits?: ChatRequestLimits;
132
132
  /**
133
- * Server-only Mixedbread overrides. Environment variables are used when
134
- * these values are omitted.
133
+ * Server-only Mixedbread overrides. `MXBAI_API_KEY` and `MXBAI_STORE_ID`
134
+ * fill omitted credentials.
135
135
  */
136
- mixedbread?: ChatMixedbreadOptions;
136
+ mixedbread?: GeistdocsMixedbreadOptions;
137
137
  /**
138
138
  * Model used to answer Ask AI requests in the default AI Gateway mode.
139
139
  * Accepts any AI SDK `LanguageModel`, including AI Gateway model strings
@@ -1 +1 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/routes/chat.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,aAAa,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AE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,sBAAsB;IAC9B,MAAM,EAAE,IAAI,CACV,eAAe,EACb,IAAI,GACJ,UAAU,GACV,iBAAiB,GACjB,QAAQ,GACR,SAAS,GACT,cAAc,CACjB,CAAC;IACF;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B;AAstDD,eAAO,MAAM,eAAe,GAAI,wGAW7B,sBAAsB;gBAqBE,OAAO;;CAkMjC,CAAC"}
@@ -8,6 +8,7 @@ import { createSourceChunk, createSourceChunks, } from "../internal/chat/source-
8
8
  import { createChatDocumentSearch, } from "../internal/chat-retrieval";
9
9
  import { buildEveAgentTranscript, capLastUserMessageText, createEmptyEveAgentSession, getEveAgentMessageMetadata, hasPriorEveAgentTurn, normalizeAgentUrl, prewarmExistingEveAgentSession, resolveEveAgentUrl, startOrContinueEveAgentSession, streamEveAgentTurn, } from "../internal/eve-agent";
10
10
  import { CHAT_SECRET_ENV, createEveAgentSessionCookieCodec, EVE_AGENT_SESSION_COOKIE, isSameSessionTag, readCookieValues, serializeEveAgentSessionCookie, } from "../internal/eve-agent-session-cookie";
11
+ import { getReaderProvider, } from "../internal/mixedbread-store";
11
12
  import { isPageVisibleForSurface, } from "../page-visibility";
12
13
  const DEFAULT_CHAT_MODEL = "openai/gpt-5.6-sol";
13
14
  const DEFAULT_MAX_REQUEST_BYTES = 1_000_000;
@@ -159,46 +160,30 @@ const searchDocsWithOrama = async ({ basePath, filterPage, lang, limit, query, s
159
160
  })
160
161
  .slice(0, limit);
161
162
  };
162
- const createDocumentSearch = ({ config, filterPage, mixedbread, sources, }) => {
163
- const fallback = ({ lang, limit, query }) => searchDocsWithOrama({
163
+ const createDocumentSearch = ({ config, filterPage, mixedbread, sources, }) => createChatDocumentSearch({
164
+ basePath: config.basePath,
165
+ fallback: ({ lang, limit, query }) => searchDocsWithOrama({
164
166
  basePath: config.basePath,
165
167
  filterPage,
166
168
  lang,
167
169
  limit,
168
170
  query,
169
171
  sources,
170
- });
171
- const search = createChatDocumentSearch({
172
- fallback,
173
- mixedbread: {
174
- ...mixedbread,
175
- apiKey: mixedbread?.apiKey ?? process.env.MXBAI_API_KEY,
176
- storeId: mixedbread?.storeId ?? process.env.MXBAI_STORE_ID,
177
- },
178
- onWarning: (message, error) => {
179
- if (error === undefined) {
180
- console.warn(message);
181
- }
182
- else {
183
- console.warn(message, error);
184
- }
185
- },
186
- provider: config.ai?.retrieval,
187
- siteId: config.siteId,
188
- });
189
- return async (input) => {
190
- const documents = await search({ ...input, limit: input.limit * 3 });
191
- return documents
192
- .filter((document) => sources.some((source) => {
193
- const result = source.source.getPageByHref(document.slug, {
194
- language: input.lang,
195
- });
196
- return Boolean(result?.page &&
197
- isChatPageVisible(result.page, input.lang, source, filterPage));
198
- }))
199
- .slice(0, input.limit);
200
- };
201
- };
172
+ }),
173
+ filterPage,
174
+ mixedbread,
175
+ onWarning: (message, error) => {
176
+ if (error === undefined) {
177
+ console.warn(message);
178
+ }
179
+ else {
180
+ console.warn(message, error);
181
+ }
182
+ },
183
+ provider: getReaderProvider(config, "chat"),
184
+ siteId: config.siteId,
185
+ sources,
186
+ });
202
187
  const formatDocForContext = (doc) => `**${doc.title}**\nURL: ${doc.url}\n${doc.description || ""}\n\n${doc.content.slice(0, MAX_CONTEXT_CHARS)}${doc.content.length > MAX_CONTEXT_CHARS ? "..." : ""}`;
203
188
  const getRouteCandidates = ({ basePath, currentRoute, lang, }) => {
204
189
  const pathname = normalizePathname(currentRoute);
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/routes/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAA+B,MAAM,WAAW,CAAC;AAS9E,eAAO,MAAM,yBAAyB,kBAAkB,CAAC;AAEzD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,IAAI,CACV,eAAe,EACb,OAAO,GACP,IAAI,GACJ,UAAU,GACV,SAAS,GACT,iBAAiB,GACjB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,OAAO,GACP,cAAc,CACjB,CAAC;IACF;;;;;OAKG;IACH,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE,CACV,QAAQ,EAAE,wBAAwB,EAClC,OAAO,EAAE;QAAE,OAAO,EAAE,WAAW,CAAA;KAAE,KAC9B,OAAO,CAAC,wBAAwB,CAAC,GAAG,wBAAwB,CAAC;CACnE;AAID,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,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E,gBAAgB,CAAC,CAAC,CAAC;IACxD,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClB,OAAO,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChD,IAAI,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/C;AAglBD,eAAO,MAAM,kBAAkB,GAAI,mCAIhC,yBAAyB;mBAmBE,WAAW;;;;;CA6BxC,CAAC"}
@@ -41,8 +41,9 @@ const present = (parts) => parts.filter((part) => Boolean(part));
41
41
  const joinList = (parts) => parts.length > 2
42
42
  ? `${parts.slice(0, -1).join(", ")}, and ${parts.at(-1)}`
43
43
  : parts.join(" and ");
44
+ const isSemanticSearch = (config) => config.search?.provider === "mixedbread";
44
45
  /** Prose for the endpoint families the document actually lists. */
45
- const describeEndpointFamilies = (endpoints) => {
46
+ const describeEndpointFamilies = (endpoints, config) => {
46
47
  const apiPaths = present([
47
48
  endpoints.search ? "`/api/search`" : undefined,
48
49
  endpoints.chat ? `\`${endpoints.chatPath}\`` : undefined,
@@ -51,6 +52,9 @@ const describeEndpointFamilies = (endpoints) => {
51
52
  endpoints.search ? "the `locale` parameter" : undefined,
52
53
  endpoints.chat ? "the `currentRoute` field" : undefined,
53
54
  ]);
55
+ const searchLabel = isSemanticSearch(config)
56
+ ? "semantic search"
57
+ : "full-text search";
54
58
  return {
55
59
  summary: joinList(present([
56
60
  endpoints.search ? "Search" : undefined,
@@ -58,7 +62,7 @@ const describeEndpointFamilies = (endpoints) => {
58
62
  "Markdown discovery",
59
63
  ])),
60
64
  description: joinList(present([
61
- endpoints.search ? "full-text search" : undefined,
65
+ endpoints.search ? searchLabel : undefined,
62
66
  endpoints.chat ? "the Ask AI assistant" : undefined,
63
67
  "Markdown versions of every page",
64
68
  ])),
@@ -75,7 +79,7 @@ const buildInfo = (config, endpoints, origin) => {
75
79
  .filter((lang) => lang !== defaultLanguage)
76
80
  .map((lang) => `\`/${lang}\``)
77
81
  .join(", ");
78
- const families = describeEndpointFamilies(endpoints);
82
+ const families = describeEndpointFamilies(endpoints, config);
79
83
  const description = [
80
84
  `HTTP endpoints served by the ${name} documentation site: ${families.description}.`,
81
85
  `This document describes the documentation site only. It does not describe a ${name} product API.`,
@@ -111,7 +115,9 @@ const buildSearchPath = (config) => {
111
115
  operationId: "searchDocs",
112
116
  tags: ["Search"],
113
117
  summary: "Search the documentation",
114
- description: "Runs a full-text search over all documentation pages and returns matching pages, headings, and text fragments ranked by relevance. Returns an empty array when `query` is omitted or empty.",
118
+ description: isSemanticSearch(config)
119
+ ? "Runs a semantic search over all documentation pages and returns matching pages, headings, and text fragments ranked by relevance. Answers from full-text search when the semantic index cannot. Returns an empty array when `query` is omitted or empty."
120
+ : "Runs a full-text search over all documentation pages and returns matching pages, headings, and text fragments ranked by relevance. Returns an empty array when `query` is omitted or empty.",
115
121
  parameters: [
116
122
  {
117
123
  name: "query",
@@ -435,7 +441,9 @@ const buildDocument = ({ config, endpoints, origin, selfPath, }) => {
435
441
  schemas.add("SearchResult");
436
442
  tags.push({
437
443
  name: "Search",
438
- description: "Full-text search over the documentation.",
444
+ description: isSemanticSearch(config)
445
+ ? "Semantic search over the documentation."
446
+ : "Full-text search over the documentation.",
439
447
  });
440
448
  }
441
449
  if (endpoints.chat) {
@@ -2,7 +2,7 @@ import { type GeistdocsConfig } from "../config";
2
2
  import { type GeistdocsPageFilter } from "../page-visibility";
3
3
  import type { GeistdocsSourceBundle } from "../source";
4
4
  interface CreateSearchExportRouteOptions {
5
- config: Pick<GeistdocsConfig, "ai" | "basePath" | "defaultLanguage" | "siteId" | "translations">;
5
+ config: Pick<GeistdocsConfig, "ai" | "basePath" | "defaultLanguage" | "search" | "siteId" | "translations">;
6
6
  filterPage?: GeistdocsPageFilter;
7
7
  source?: GeistdocsSourceBundle;
8
8
  sources?: GeistdocsSourceBundle[];
@@ -1 +1 @@
1
- {"version":3,"file":"search-export.d.ts","sourceRoot":"","sources":["../../src/routes/search-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,WAAW,CAAC;AAMhE,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,UAAU,8BAA8B;IACtC,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,iBAAiB,GAAG,QAAQ,GAAG,cAAc,CAClE,CAAC;IACF,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAwBD,eAAO,MAAM,uBAAuB,GAAI,0CAKrC,8BAA8B;;CA6ChC,CAAC"}
1
+ {"version":3,"file":"search-export.d.ts","sourceRoot":"","sources":["../../src/routes/search-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,WAAW,CAAC;AAOhE,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,UAAU,8BAA8B;IACtC,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,CAC7E,CAAC;IACF,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAwBD,eAAO,MAAM,uBAAuB,GAAI,0CAKrC,8BAA8B;;CAiDhC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { getPublicPath } from "../config";
2
+ import { getMixedbreadReaders } from "../internal/mixedbread-store";
2
3
  import { GEISTDOCS_SEARCH_EXPORT_VERSION, } from "../internal/search-export";
3
4
  import { isPageVisibleForSurface, } from "../page-visibility";
4
5
  const resolveSources = (source, sources) => {
@@ -14,12 +15,14 @@ const getLanguages = (config) => {
14
15
  };
15
16
  export const createSearchExportRoute = ({ config, filterPage, source, sources, }) => {
16
17
  const routeSources = resolveSources(source, sources);
18
+ const readers = getMixedbreadReaders(config);
19
+ const surfaces = readers.length > 0 ? readers : ["chat"];
17
20
  const GET = async () => {
18
21
  const documents = await Promise.all(getLanguages(config).flatMap((locale) => routeSources.flatMap((entry, sourceIndex) => {
19
22
  const sourceId = entry.id ?? `source-${sourceIndex + 1}`;
20
23
  return entry.source
21
24
  .getPages(locale)
22
- .filter((page) => isPageVisibleForSurface(page, "chat") &&
25
+ .filter((page) => surfaces.some((surface) => isPageVisibleForSurface(page, surface)) &&
23
26
  (filterPage?.(page, { lang: locale, source: entry }) ?? true))
24
27
  .map(async (page) => ({
25
28
  content: await entry.getPageMarkdown(page),
@@ -35,7 +38,7 @@ export const createSearchExportRoute = ({ config, filterPage, source, sources, }
35
38
  documents.sort((left, right) => left.id.localeCompare(right.id));
36
39
  const exported = {
37
40
  documents,
38
- provider: config.ai?.retrieval ?? "local",
41
+ provider: readers.length > 0 ? "mixedbread" : "local",
39
42
  siteId: config.siteId,
40
43
  version: GEISTDOCS_SEARCH_EXPORT_VERSION,
41
44
  };
@@ -1,15 +1,23 @@
1
1
  import type { GeistdocsConfig } from "../config";
2
+ import { type GeistdocsMixedbreadOptions } from "../internal/mixedbread-store";
2
3
  import { type GeistdocsPageFilter } from "../page-visibility";
3
4
  import { type GeistdocsSourceBundle } from "../source";
4
5
  type SourceBundle = GeistdocsSourceBundle;
5
6
  type SearchSource = SourceBundle["source"];
6
7
  type SearchSourceInput = SearchSource | SourceBundle;
8
+ type SearchGET = (request: Request) => Promise<Response>;
7
9
  interface CreateSearchRouteOptions {
8
- config: Pick<GeistdocsConfig, "defaultLanguage" | "translations">;
10
+ config: Pick<GeistdocsConfig, "defaultLanguage" | "search" | "siteId" | "translations">;
9
11
  filterPage?: GeistdocsPageFilter<ReturnType<SearchSource["getPages"]>[number], SearchSourceInput>;
12
+ /**
13
+ * Server-only Mixedbread overrides, used when `config.search.provider` is
14
+ * `"mixedbread"`. `MXBAI_API_KEY` and `MXBAI_STORE_ID` fill omitted
15
+ * credentials.
16
+ */
17
+ mixedbread?: GeistdocsMixedbreadOptions;
10
18
  source?: SearchSourceInput;
11
19
  sources?: SearchSourceInput[];
12
20
  }
13
- export declare const createSearchRoute: ({ config, filterPage, source, sources, }: CreateSearchRouteOptions) => (request: Request) => Promise<Response>;
21
+ export declare const createSearchRoute: ({ config, filterPage, mixedbread, source, sources, }: CreateSearchRouteOptions) => SearchGET;
14
22
  export {};
15
23
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/routes/search.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAEhF,KAAK,YAAY,GAAG,qBAAqB,CAAC;AAC1C,KAAK,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,KAAK,iBAAiB,GAAG,YAAY,GAAG,YAAY,CAAC;AAIrD,UAAU,wBAAwB;IAChC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,UAAU,CAAC,EAAE,mBAAmB,CAC9B,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAC5C,iBAAiB,CAClB,CAAC;IACF,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAgFD,eAAO,MAAM,iBAAiB,GAAI,0CAK/B,wBAAwB,4CA4E1B,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/routes/search.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAEL,KAAK,0BAA0B,EAKhC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAEhF,KAAK,YAAY,GAAG,qBAAqB,CAAC;AAC1C,KAAK,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,KAAK,iBAAiB,GAAG,YAAY,GAAG,YAAY,CAAC;AACrD,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAIzD,UAAU,wBAAwB;IAChC,MAAM,EAAE,IAAI,CACV,eAAe,EACf,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,CACzD,CAAC;IACF,UAAU,CAAC,EAAE,mBAAmB,CAC9B,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAC5C,iBAAiB,CAClB,CAAC;IACF;;;;OAIG;IACH,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AA6ND,eAAO,MAAM,iBAAiB,GAAI,sDAM/B,wBAAwB,KAAG,SA+J7B,CAAC"}
@@ -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
- export const createSearchRoute = ({ config, filterPage, source, sources, }) => {
52
- const translations = config.translations ?? {};
53
- const routeSources = resolveSources(source, sources);
54
- const { defaultLanguage, languages } = getLanguages(config);
55
- const i18n = defineI18n({
56
- defaultLanguage,
57
- languages,
58
- hideLocale: "default-locale",
59
- });
60
- const localeMap = Object.fromEntries(Object.entries(translations).map(([locale, translation]) => [
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
- if ("jp" in translations) {
76
- localeMap.jp = {
77
- components: {
78
- tokenizer: createTokenizerJapanese(),
79
- },
80
- search: {
81
- threshold: 0,
82
- tolerance: 0,
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
- const getIndexes = () => languages.flatMap((locale) => routeSources.flatMap((source) => {
87
- const pageTree = getPageTree(source, locale);
88
- return getPages(source, locale)
89
- .filter((page) => isPageVisibleForSurface(page, "search") &&
90
- (filterPage?.(page, { lang: locale, source }) ?? true))
91
- .map((page) => {
92
- const data = page.data;
93
- return {
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
- title: data.title ?? page.url,
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.5 so agents can understand the installed package without web access.
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 answers with Mixedbread](pages/mixedbread-retrieval.md): Provision a Mixedbread Store for one Geistdocs consumer site, enable semantic retrieval, and sync documentation during production builds.
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.