@farming-labs/docs 0.2.60 → 0.2.62

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 (51) hide show
  1. package/README.md +1 -1
  2. package/package.json +11 -1
  3. package/dist/agent-BFqyqEnC.mjs +0 -4547
  4. package/dist/agent-DlxriaTs.mjs +0 -624
  5. package/dist/agent-evals-kJs2Y9xR.mjs +0 -2144
  6. package/dist/agent-export-BgUaiW8f.mjs +0 -869
  7. package/dist/agent-scope-CCaIY1aK.mjs +0 -283
  8. package/dist/agents-Djh-HXih.mjs +0 -219
  9. package/dist/analytics-Bx44lg6d.mjs +0 -177
  10. package/dist/cli/index.d.mts +0 -15
  11. package/dist/cli/index.mjs +0 -452
  12. package/dist/client/react.d.mts +0 -45
  13. package/dist/client/react.mjs +0 -223
  14. package/dist/cloud-BH_sHX64.mjs +0 -1615
  15. package/dist/cloud-analytics-CSyFE6SS.mjs +0 -132
  16. package/dist/cloud-ask-ai-B2WnG4fF.d.mts +0 -23
  17. package/dist/cloud-ask-ai-hnJfj8-X.mjs +0 -382
  18. package/dist/code-blocks-qe0T8-xe.mjs +0 -871
  19. package/dist/codeblocks-Bq67u32v.mjs +0 -250
  20. package/dist/config-DASewQ0x.mjs +0 -363
  21. package/dist/dev-DgY5xGl9.mjs +0 -1333
  22. package/dist/docs-cloud-server.d.mts +0 -70
  23. package/dist/docs-cloud-server.mjs +0 -310
  24. package/dist/doctor-CO1VMcF_.mjs +0 -1906
  25. package/dist/downgrade-BZs86NVr.mjs +0 -184
  26. package/dist/errors-CVqZ3kOO.mjs +0 -20
  27. package/dist/golden-evaluations-BN9u2wxw.mjs +0 -1483
  28. package/dist/i18n-CAlj1ADU.mjs +0 -40
  29. package/dist/index.d.mts +0 -1099
  30. package/dist/index.mjs +0 -9
  31. package/dist/init-Bd_k06bR.mjs +0 -1233
  32. package/dist/mcp-B_yXL5G5.mjs +0 -137
  33. package/dist/mcp.d.mts +0 -287
  34. package/dist/mcp.mjs +0 -4135
  35. package/dist/metadata-BDuewuzq.mjs +0 -237
  36. package/dist/package-version-qik_4J6C.mjs +0 -128
  37. package/dist/reading-time-BkEft6SD.mjs +0 -741
  38. package/dist/review-NC-sOdXn.mjs +0 -665
  39. package/dist/robots-DskPvGPw.mjs +0 -178
  40. package/dist/robots-ltltiLJF.mjs +0 -197
  41. package/dist/search-C1JitPwi.d.mts +0 -397
  42. package/dist/search-D57JXQLj.mjs +0 -1758
  43. package/dist/search-o4Ud6OXv.mjs +0 -102
  44. package/dist/server.d.mts +0 -341
  45. package/dist/server.mjs +0 -11
  46. package/dist/sitemap-Cq-Yj_iA.mjs +0 -247
  47. package/dist/sitemap-server-C1ibVKOy.mjs +0 -1137
  48. package/dist/templates-DNw15P-x.mjs +0 -2373
  49. package/dist/types-XHABMh_f.d.mts +0 -3248
  50. package/dist/upgrade-BCJTCW3O.mjs +0 -56
  51. package/dist/utils-6UCLxv4B.mjs +0 -225
@@ -1,3248 +0,0 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Theme / UI configuration types for the docs framework.
4
- * Inspired by Fumadocs: https://github.com/fuma-nama/fumadocs
5
- */
6
- /**
7
- * Fine-grained UI configuration for docs themes.
8
- *
9
- * Theme authors define defaults for these values in their `createTheme` call.
10
- * End users can override any value when calling the theme factory.
11
- *
12
- * @example
13
- * ```ts
14
- * const myTheme = createTheme({
15
- * name: "my-theme",
16
- * ui: {
17
- * colors: { primary: "#6366f1", background: "#0a0a0a" },
18
- * radius: "0px",
19
- * codeBlock: { showLineNumbers: true, theme: "github-dark" },
20
- * sidebar: { width: 280, style: "bordered" },
21
- * },
22
- * });
23
- * ```
24
- */
25
- /**
26
- * Font style configuration for a single text element (heading, body, etc.).
27
- *
28
- * @example
29
- * ```ts
30
- * h1: { size: "2.25rem", weight: 700, lineHeight: "1.2", letterSpacing: "-0.02em" }
31
- * ```
32
- */
33
- interface FontStyle {
34
- /** CSS `font-size` value (e.g. "2.25rem", "36px", "clamp(1.8rem, 3vw, 2.5rem)") */
35
- size?: string;
36
- /** CSS `font-weight` value (e.g. 700, "bold", "600") */
37
- weight?: string | number;
38
- /** CSS `line-height` value (e.g. "1.2", "1.5", "28px") */
39
- lineHeight?: string;
40
- /** CSS `letter-spacing` value (e.g. "-0.02em", "0.05em") */
41
- letterSpacing?: string;
42
- }
43
- /**
44
- * Typography configuration for the docs.
45
- *
46
- * @example
47
- * ```ts
48
- * typography: {
49
- * font: {
50
- * style: { sans: "Inter, sans-serif", mono: "JetBrains Mono, monospace" },
51
- * h1: { size: "2.25rem", weight: 700, letterSpacing: "-0.02em" },
52
- * h2: { size: "1.75rem", weight: 600 },
53
- * body: { size: "1rem", lineHeight: "1.75" },
54
- * },
55
- * }
56
- * ```
57
- */
58
- interface TypographyConfig {
59
- /**
60
- * Font configuration.
61
- */
62
- font?: {
63
- /**
64
- * Font family definitions.
65
- */
66
- style?: {
67
- /** Sans-serif font family — used for body text, headings, and UI elements. */sans?: string; /** Monospace font family — used for code blocks, inline code, and terminal output. */
68
- mono?: string;
69
- }; /** Heading 1 (`<h1>`) style overrides */
70
- h1?: FontStyle; /** Heading 2 (`<h2>`) style overrides */
71
- h2?: FontStyle; /** Heading 3 (`<h3>`) style overrides */
72
- h3?: FontStyle; /** Heading 4 (`<h4>`) style overrides */
73
- h4?: FontStyle; /** Body text style */
74
- body?: FontStyle; /** Small text style (captions, meta text) */
75
- small?: FontStyle;
76
- };
77
- }
78
- interface UIConfig {
79
- /**
80
- * Theme color tokens.
81
- *
82
- * These are mapped to `--color-fd-*` CSS variables at runtime.
83
- * Accepts any valid CSS color value (hex, rgb, oklch, hsl, etc.).
84
- *
85
- * @example
86
- * ```ts
87
- * colors: {
88
- * primary: "oklch(0.72 0.19 149)", // green primary
89
- * primaryForeground: "#ffffff", // white text on primary
90
- * accent: "hsl(220 80% 60%)", // blue accent
91
- * }
92
- * ```
93
- */
94
- colors?: {
95
- primary?: string;
96
- primaryForeground?: string;
97
- background?: string;
98
- foreground?: string;
99
- muted?: string;
100
- mutedForeground?: string;
101
- border?: string;
102
- card?: string;
103
- cardForeground?: string;
104
- accent?: string;
105
- accentForeground?: string;
106
- secondary?: string;
107
- secondaryForeground?: string;
108
- popover?: string;
109
- popoverForeground?: string;
110
- ring?: string;
111
- };
112
- /**
113
- * Typography settings — font families, heading sizes, weights, etc.
114
- *
115
- * @example
116
- * ```ts
117
- * typography: {
118
- * font: {
119
- * style: { sans: "Inter, sans-serif", mono: "JetBrains Mono, monospace" },
120
- * h1: { size: "2.25rem", weight: 700, letterSpacing: "-0.02em" },
121
- * body: { size: "1rem", lineHeight: "1.75" },
122
- * },
123
- * }
124
- * ```
125
- */
126
- typography?: TypographyConfig;
127
- /**
128
- * Global border-radius. Maps to CSS `--radius`.
129
- * Use "0px" for sharp corners, "0.5rem" for rounded, etc.
130
- */
131
- radius?: string;
132
- /** Layout dimensions */
133
- layout?: {
134
- contentWidth?: number;
135
- sidebarWidth?: number;
136
- tocWidth?: number;
137
- toc?: {
138
- enabled?: boolean;
139
- depth?: number;
140
- /**
141
- * Visual style of the TOC indicator.
142
- * - `"default"` — highlight active link text color only
143
- * - `"directional"` — animated thumb bar that tracks active headings (fumadocs style)
144
- * @default "default"
145
- */
146
- style?: "default" | "directional";
147
- };
148
- header?: {
149
- height?: number;
150
- sticky?: boolean;
151
- };
152
- };
153
- /** Code block rendering config */
154
- codeBlock?: {
155
- /** Show line numbers in code blocks @default false */showLineNumbers?: boolean; /** Show copy button @default true */
156
- showCopyButton?: boolean; /** Shiki theme name for syntax highlighting */
157
- theme?: string; /** Dark mode shiki theme (for dual-theme setups) */
158
- darkTheme?: string;
159
- };
160
- /** Sidebar styling hints (consumed by theme CSS) */
161
- sidebar?: {
162
- /**
163
- * Visual style of the sidebar.
164
- * - "default" — standard fumadocs sidebar
165
- * - "bordered" — visible bordered sections (like better-auth)
166
- * - "floating" — floating card sidebar
167
- */
168
- style?: "default" | "bordered" | "floating"; /** Background color override */
169
- background?: string; /** Border color override */
170
- borderColor?: string;
171
- };
172
- /** Card styling */
173
- card?: {
174
- /** Whether cards have visible borders @default true */bordered?: boolean; /** Card background color override */
175
- background?: string;
176
- };
177
- /** Default props/variants for built-in MDX components (Callout, CodeBlock, Tabs, HoverLink, Prompt, etc.) */
178
- components?: {
179
- [key: string]: Record<string, unknown> | ((defaults: unknown) => unknown);
180
- };
181
- }
182
- /**
183
- * A docs theme configuration.
184
- *
185
- * Theme authors create these with `createTheme()`. The `name` identifies the
186
- * theme (useful for CSS scoping, debugging, analytics). The `ui` object holds
187
- * all visual configuration.
188
- *
189
- * @example
190
- * ```ts
191
- * import { createTheme } from "@farming-labs/docs";
192
- *
193
- * export const myTheme = createTheme({
194
- * name: "my-theme",
195
- * ui: {
196
- * colors: { primary: "#ff4d8d" },
197
- * radius: "0px",
198
- * },
199
- * });
200
- * ```
201
- */
202
- interface DocsTheme {
203
- /** Unique name for this theme (used for CSS scoping and debugging) */
204
- name?: string;
205
- /** UI configuration — colors, typography, layout, components */
206
- ui?: UIConfig;
207
- /**
208
- * @internal
209
- * User-provided color overrides tracked by `createTheme`.
210
- * Only these colors are emitted as inline CSS variables at runtime.
211
- * Preset defaults stay in the theme's CSS file.
212
- */
213
- _userColorOverrides?: Record<string, string>;
214
- }
215
- interface DocsMetadata {
216
- titleTemplate?: string;
217
- description?: string;
218
- twitterCard?: "summary" | "summary_large_image";
219
- }
220
- interface OGConfig {
221
- enabled?: boolean;
222
- type?: "static" | "dynamic";
223
- endpoint?: string;
224
- defaultImage?: string;
225
- }
226
- /** Single image entry for Open Graph (frontmatter or Next metadata). */
227
- interface OpenGraphImage {
228
- url: string;
229
- width?: number;
230
- height?: number;
231
- }
232
- /** Open Graph block in page frontmatter. When present, used as-is for metadata (replaces generated OG). */
233
- interface PageOpenGraph {
234
- images?: OpenGraphImage[];
235
- title?: string;
236
- description?: string;
237
- }
238
- /** Twitter card block in page frontmatter. When present, used as-is for metadata (replaces generated twitter). */
239
- interface PageTwitter {
240
- card?: "summary" | "summary_large_image";
241
- images?: string[];
242
- title?: string;
243
- description?: string;
244
- }
245
- type DocsRelatedItem = string;
246
- interface ResolvedDocsRelatedLink {
247
- href: string;
248
- }
249
- interface PageAgentAppliesTo {
250
- /** Framework name or names this task applies to, for example `"nextjs"`. */
251
- framework?: string | string[];
252
- /** Version range or ranges this task applies to, for example `">=16"`. */
253
- version?: string | string[];
254
- /** Package name or names this task applies to, for example `"@farming-labs/next"`. */
255
- package?: string | string[];
256
- }
257
- interface PageAgentCommand {
258
- /** Exact command an agent may run. */
259
- run: string;
260
- /** Optional working directory, relative to the project root unless documented otherwise. */
261
- cwd?: string;
262
- /** Short explanation of what the command does. */
263
- description?: string;
264
- }
265
- interface PageAgentVerification {
266
- /** Human-readable verification step. */
267
- description?: string;
268
- /** Optional command used to verify the result. */
269
- run?: string;
270
- /** Observable result that indicates success. */
271
- expect?: string;
272
- }
273
- interface PageAgentFailureMode {
274
- /** Symptom an agent may observe. */
275
- symptom: string;
276
- /** Recovery guidance for the symptom. */
277
- resolution?: string;
278
- }
279
- interface PageAgentFrontmatter {
280
- /**
281
- * Approximate output token target for machine-readable compaction on this page.
282
- * Used by `docs agent compact` as a per-page override.
283
- */
284
- tokenBudget?: number;
285
- /** Concrete task the page helps an agent complete. */
286
- task?: string;
287
- /** Observable end state the agent should reach. */
288
- outcome?: string;
289
- /** Framework, version, and package applicability constraints. */
290
- appliesTo?: PageAgentAppliesTo;
291
- /** Conditions or setup that must already be true. */
292
- prerequisites?: string[];
293
- /** Files the task is expected to read or change. */
294
- files?: string[];
295
- /** Commands the task may require. Strings are supported as a concise shorthand. */
296
- commands?: Array<string | PageAgentCommand>;
297
- /** Material state changes or external effects the task can cause. */
298
- sideEffects?: string[];
299
- /** Checks that prove the task completed successfully. */
300
- verification?: Array<string | PageAgentVerification>;
301
- /** Steps that restore the previous state when the task must be undone. */
302
- rollback?: string[];
303
- /** Common symptoms and optional recovery guidance. */
304
- failureModes?: Array<string | PageAgentFailureMode>;
305
- }
306
- interface PageSidebarFrontmatter {
307
- /**
308
- * Override how this folder page behaves in the default sidebar when it has children.
309
- *
310
- * This is only read from folder landing pages such as `page.mdx` / `index.md`.
311
- */
312
- folderIndexBehavior?: SidebarFolderIndexBehavior;
313
- }
314
- interface PageFrontmatter {
315
- title: string;
316
- description?: string;
317
- /** Related doc URLs rendered into machine-readable markdown routes and MCP page output. */
318
- related?: DocsRelatedItem[];
319
- /** Per-page agent-oriented metadata used by machine-readable docs features. */
320
- agent?: PageAgentFrontmatter;
321
- /** Per-page sidebar metadata used when building the docs navigation tree. */
322
- sidebar?: PageSidebarFrontmatter;
323
- /** Override or disable the estimated reading time for this page. */
324
- readingTime?: boolean | number;
325
- tags?: string[];
326
- icon?: string;
327
- /** Path to custom OG image for this page (shorthand). Ignored if `openGraph` is set. */
328
- ogImage?: string;
329
- /** Full Open Graph object. When set, replaces any generated OG from config (e.g. dynamic endpoint). */
330
- openGraph?: PageOpenGraph;
331
- /** Full Twitter card object. When set, replaces any generated twitter from config. */
332
- twitter?: PageTwitter;
333
- /** Sort order in the sidebar. Lower numbers appear first. Pages without `order` are sorted alphabetically after ordered pages. */
334
- order?: number;
335
- }
336
- interface DocsNav {
337
- /**
338
- * Sidebar title — a plain string or a React element (e.g. a div with an icon).
339
- *
340
- * @example
341
- * ```tsx
342
- * // Simple string
343
- * nav: { title: "My Docs" }
344
- *
345
- * // React element with icon
346
- * nav: {
347
- * title: <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
348
- * <Rocket size={18} /> Example Docs
349
- * </div>
350
- * }
351
- * ```
352
- */
353
- title?: unknown;
354
- /** URL the title links to. Defaults to `/{entry}`. */
355
- url?: string;
356
- }
357
- interface ThemeToggleConfig {
358
- /**
359
- * Whether to show the light/dark theme toggle in the sidebar.
360
- * @default true
361
- */
362
- enabled?: boolean;
363
- /**
364
- * The default / forced theme when the toggle is hidden.
365
- * Only applies when `enabled` is `false`.
366
- * @default "system"
367
- *
368
- * @example
369
- * ```ts
370
- * // Hide toggle, force dark mode
371
- * themeToggle: { enabled: false, default: "dark" }
372
- * ```
373
- */
374
- default?: "light" | "dark" | "system";
375
- /**
376
- * Toggle mode — show only light/dark, or include a system option.
377
- * @default "light-dark"
378
- */
379
- mode?: "light-dark" | "light-dark-system";
380
- }
381
- interface BreadcrumbConfig {
382
- /**
383
- * Whether to show the breadcrumb navigation above page content.
384
- * @default true
385
- */
386
- enabled?: boolean;
387
- /**
388
- * Custom breadcrumb component. Receives the default breadcrumb as children
389
- * so you can wrap/modify it.
390
- *
391
- * @example
392
- * ```tsx
393
- * breadcrumb: {
394
- * component: ({ items }) => <MyBreadcrumb items={items} />,
395
- * }
396
- * ```
397
- */
398
- component?: unknown;
399
- }
400
- /**
401
- * A leaf page in the sidebar tree.
402
- */
403
- interface SidebarPageNode {
404
- type: "page";
405
- name: string;
406
- url: string;
407
- icon?: unknown;
408
- }
409
- /**
410
- * A folder (group) in the sidebar tree. May contain child pages
411
- * and nested folders, forming a recursive hierarchy.
412
- */
413
- interface SidebarFolderNode {
414
- type: "folder";
415
- name: string;
416
- icon?: unknown;
417
- /** Index page for this folder (the folder's own landing page). */
418
- index?: SidebarPageNode;
419
- /**
420
- * Optional per-folder override read from the folder page frontmatter before the
421
- * tree is normalized for the default sidebar.
422
- */
423
- folderIndexBehavior?: SidebarFolderIndexBehavior;
424
- /** Child pages and sub-folders. */
425
- children: SidebarNode[];
426
- /** Whether this folder section is collapsible. */
427
- collapsible?: boolean;
428
- /** Whether this folder starts open. */
429
- defaultOpen?: boolean;
430
- }
431
- /** A node in the sidebar tree — either a page or a folder. */
432
- type SidebarNode = SidebarPageNode | SidebarFolderNode;
433
- /** The full sidebar tree passed to custom sidebar components. */
434
- interface SidebarTree {
435
- name: string;
436
- children: SidebarNode[];
437
- }
438
- /**
439
- * Props passed to a custom sidebar component.
440
- *
441
- * Contains all the information needed to build a fully custom sidebar:
442
- * the complete page tree with parent-child relationships, and the
443
- * current sidebar configuration.
444
- */
445
- interface SidebarComponentProps {
446
- /** Full page tree with all parent-child-folder relationships. */
447
- tree: SidebarTree;
448
- /** Whether folders are collapsible. */
449
- collapsible: boolean;
450
- /** Whether folders are rendered flat (Mintlify-style). */
451
- flat: boolean;
452
- }
453
- /**
454
- * Controls how folders with their own landing page behave in the default sidebar.
455
- *
456
- * - `"link"` — clicking the parent row navigates to the folder landing page
457
- * - `"toggle"` — clicking the parent row only expands/collapses children, and the
458
- * landing page is rendered as the first child item instead
459
- */
460
- type SidebarFolderIndexBehavior = "link" | "toggle" | "hidden";
461
- type SidebarFolderIndexBehaviorOverrides = Record<string, SidebarFolderIndexBehavior>;
462
- interface SidebarConfig {
463
- /**
464
- * Whether to show the sidebar.
465
- * @default true
466
- */
467
- enabled?: boolean;
468
- /**
469
- * Custom sidebar component to replace the default navigation.
470
- *
471
- * **Next.js** — Pass a render function that receives `SidebarComponentProps`:
472
- * ```tsx
473
- * sidebar: {
474
- * component: ({ tree, collapsible, flat }) => (
475
- * <MySidebar tree={tree} />
476
- * ),
477
- * }
478
- * ```
479
- *
480
- * **Astro** — Use the `sidebar` named slot on `<DocsLayout>`:
481
- * ```astro
482
- * <DocsLayout tree={tree} config={config}>
483
- * <MySidebar slot="sidebar" tree={tree} />
484
- * <slot />
485
- * </DocsLayout>
486
- * ```
487
- *
488
- * **SvelteKit** — Use the `sidebar` snippet on `<DocsLayout>`:
489
- * ```svelte
490
- * <DocsLayout {tree} {config}>
491
- * {#snippet sidebar({ tree, isActive })}
492
- * <MySidebarNav {tree} {isActive} />
493
- * {/snippet}
494
- * {@render children()}
495
- * </DocsLayout>
496
- * ```
497
- *
498
- * **Nuxt / Vue** — Use the `#sidebar` scoped slot on `<DocsLayout>`:
499
- * ```vue
500
- * <DocsLayout :tree="tree" :config="config">
501
- * <template #sidebar="{ tree, isActive }">
502
- * <MySidebarNav :tree="tree" :is-active="isActive" />
503
- * </template>
504
- * <DocsContent />
505
- * </DocsLayout>
506
- * ```
507
- */
508
- component?: (props: SidebarComponentProps) => unknown;
509
- /**
510
- * Sidebar footer content (rendered below navigation items).
511
- */
512
- footer?: unknown;
513
- /**
514
- * Sidebar banner content (rendered above navigation items).
515
- */
516
- banner?: unknown;
517
- /**
518
- * Whether the sidebar is collapsible on desktop.
519
- * @default true
520
- */
521
- collapsible?: boolean;
522
- /**
523
- * When true, all folder children are rendered flat in the sidebar
524
- * (no collapsible sections). Folder index pages appear as category
525
- * headings with all children listed directly below them.
526
- *
527
- * This creates a Mintlify-style sidebar where all navigation items
528
- * are always visible.
529
- *
530
- * @default false
531
- */
532
- flat?: boolean;
533
- /**
534
- * How folders with their own `page.mdx` / `page.md` behave in the default sidebar.
535
- *
536
- * - `"link"` — clicking the parent row navigates to the folder landing page
537
- * - `"toggle"` — clicking the parent row only expands/collapses children, and the
538
- * folder landing page appears as the first child item instead
539
- * - `"hidden"` — the folder landing page route still exists, but the parent row
540
- * becomes a plain label and only the child pages appear in the sidebar
541
- *
542
- * This is the global default. Individual folder pages can still override it with
543
- * page frontmatter:
544
- *
545
- * ```mdx
546
- * ---
547
- * sidebar:
548
- * folderIndexBehavior: "hidden"
549
- * ---
550
- * ```
551
- *
552
- * When omitted, each adapter keeps its existing folder-parent behavior. Set this
553
- * explicitly if you want the same sidebar interaction across frameworks.
554
- */
555
- folderIndexBehavior?: SidebarFolderIndexBehavior;
556
- /**
557
- * Selective per-folder overrides keyed by the folder landing-page URL.
558
- * Folder page frontmatter still wins when both are present.
559
- *
560
- * ```ts
561
- * sidebar: {
562
- * folderIndexBehavior: "link",
563
- * folderIndexBehaviorOverrides: {
564
- * "/docs/components": "toggle",
565
- * "/docs/guides": "toggle",
566
- * },
567
- * }
568
- * ```
569
- */
570
- folderIndexBehaviorOverrides?: SidebarFolderIndexBehaviorOverrides;
571
- }
572
- type OpenDocsTarget = "markdown" | "page" | "source" | "github";
573
- type OpenDocsProviderId = "chatgpt" | "claude" | "cursor" | "gemini" | "copilot" | "perplexity" | "github";
574
- /**
575
- * A single "Open in …" provider shown in the Open dropdown.
576
- *
577
- * Pass a string for a built-in provider preset, or pass an object to customize a known provider
578
- * or keep using a custom `urlTemplate`.
579
- *
580
- * @example
581
- * ```ts
582
- * "cursor"
583
- * ```
584
- *
585
- * @example
586
- * ```ts
587
- * {
588
- * id: "cursor",
589
- * prompt: "Use this docs page while editing the codebase: {url}",
590
- * }
591
- * ```
592
- *
593
- * @example
594
- * ```ts
595
- * {
596
- * name: "Claude",
597
- * icon: <ClaudeIcon />,
598
- * urlTemplate: "https://claude.ai?url={url}.md",
599
- * promptUrlTemplate: "https://claude.ai/new?q={prompt}",
600
- * }
601
- * ```
602
- */
603
- type OpenDocsProvider = OpenDocsProviderId | OpenDocsProviderConfig;
604
- interface OpenDocsProviderConfig {
605
- /** Built-in provider preset to use as the base. */
606
- id?: OpenDocsProviderId | string;
607
- /** Display name (e.g. "ChatGPT", "Claude", "Cursor") */
608
- name?: string;
609
- /** Alias for `name` when configuring a preset provider. */
610
- label?: string;
611
- /** Icon element rendered next to the name */
612
- icon?: unknown;
613
- /** Override the target URL inserted into `{url}` for this provider. */
614
- target?: OpenDocsTarget;
615
- /** Prompt text used by known provider presets. Supports `{url}`, `{pageUrl}`, `{markdownUrl}`, `{sourceUrl}`, `{mdxUrl}`, and `{githubUrl}`. */
616
- prompt?: string;
617
- /** Cursor-specific mode. `"web"` opens cursor.com; `"app"` opens the Cursor app deeplink. */
618
- mode?: "web" | "app";
619
- /**
620
- * URL template. Placeholders:
621
- * - `{url}` — selected target URL, controlled by `openDocs.target` or provider `target` (encoded).
622
- * - `{pageUrl}` — rendered docs page URL (encoded).
623
- * - `{markdownUrl}` — public `.md` route for the page (encoded).
624
- * - `{sourceUrl}` / `{mdxUrl}` — page URL with `.mdx` suffix (encoded).
625
- * - `{githubUrl}` — GitHub edit URL for the current page (same as "Edit on GitHub"). Requires `github` in config.
626
- * - `{prompt}` — prompt text after resolving the target URL placeholders (encoded).
627
- *
628
- * @example "https://claude.ai/new?q=Read+this+doc:+{url}.md"
629
- * @example "{githubUrl}" — open current page file on GitHub (edit view)
630
- */
631
- urlTemplate?: string;
632
- /**
633
- * Optional URL template used by the built-in `Prompt` MDX component.
634
- * When omitted, known providers such as ChatGPT, Claude, Cursor, Gemini,
635
- * Copilot, and Perplexity fall back to a built-in `{prompt}` template by provider name.
636
- *
637
- * Placeholders:
638
- * - `{prompt}` — prompt text (encoded).
639
- *
640
- * @example "https://cursor.com/link/prompt?text={prompt}"
641
- */
642
- promptUrlTemplate?: string;
643
- }
644
- /**
645
- * Configuration for the "Open in …" dropdown that lets users
646
- * send the current page to an LLM or external tool.
647
- *
648
- * @example
649
- * ```ts
650
- * openDocs: {
651
- * enabled: true,
652
- * target: "markdown",
653
- * providers: [
654
- * "chatgpt",
655
- * "claude",
656
- * "cursor",
657
- * ],
658
- * }
659
- * ```
660
- */
661
- interface OpenDocsConfig {
662
- /** Whether to show the "Open" dropdown. @default false */
663
- enabled?: boolean;
664
- /**
665
- * Which URL should be inserted into `{url}` for preset providers and provider templates.
666
- * @default "markdown"
667
- */
668
- target?: OpenDocsTarget;
669
- /**
670
- * Prompt text used by built-in provider presets.
671
- * Supports `{url}`, `{pageUrl}`, `{markdownUrl}`, `{sourceUrl}`, `{mdxUrl}`,
672
- * and `{githubUrl}`.
673
- *
674
- * @default "Read this documentation: {url}"
675
- */
676
- prompt?: string;
677
- /**
678
- * List of LLM / tool providers to show in the dropdown.
679
- * If not provided, a sensible default list is used.
680
- */
681
- providers?: OpenDocsProvider[];
682
- }
683
- /**
684
- * Configuration for the "Copy Markdown" button that copies
685
- * the current page's content as Markdown to the clipboard.
686
- */
687
- type CopyMarkdownFormat = "markdown" | "text";
688
- interface CopyMarkdownConfig {
689
- /** Whether to show the "Copy Markdown" button. @default false */
690
- enabled?: boolean;
691
- /** Content format copied by the button. @default "markdown" */
692
- format?: CopyMarkdownFormat;
693
- /** Whether to prepend the current page title to copied content. @default false */
694
- includeTitle?: boolean;
695
- /** Button label shown before the page is copied. @default "Copy page" */
696
- label?: string;
697
- /** Button label shown after a successful copy. @default "Copied!" */
698
- copiedLabel?: string;
699
- }
700
- /**
701
- * Page-level action buttons shown above the page content
702
- * (e.g. "Copy Markdown", "Open in …" dropdown).
703
- *
704
- * @example
705
- * ```ts
706
- * pageActions: {
707
- * copyMarkdown: { enabled: true },
708
- * openDocs: {
709
- * enabled: true,
710
- * target: "markdown",
711
- * providers: [
712
- * "chatgpt",
713
- * "claude",
714
- * { id: "cursor", mode: "app" },
715
- * ],
716
- * },
717
- * }
718
- * ```
719
- */
720
- interface PageActionsConfig {
721
- /** "Copy Markdown" button */
722
- copyMarkdown?: boolean | CopyMarkdownConfig;
723
- /** "Open in …" dropdown with LLM / tool providers */
724
- openDocs?: boolean | OpenDocsConfig;
725
- /**
726
- * Where to render the page action buttons relative to the page title.
727
- *
728
- * - `"below-title"` — render below the first `<h1>` heading (default)
729
- * - `"above-title"` — render above the page title / content
730
- * - `"toc"` — render as a compact rail in the table-of-contents column
731
- *
732
- * @default "below-title"
733
- */
734
- position?: "above-title" | "below-title" | "toc";
735
- /**
736
- * Horizontal alignment of page action buttons.
737
- *
738
- * - `"left"` — align to the left (default)
739
- * - `"right"` — align to the right
740
- *
741
- * @default "left"
742
- */
743
- alignment?: "left" | "right";
744
- }
745
- type DocsAnalyticsSource = "client" | "server" | "mcp";
746
- type DocsAgentTraceStatus = "started" | "success" | "error" | "retry" | "timeout";
747
- type DocsAgentTraceEventType = "run.start" | "run.end" | "run.error" | "user.input" | "prompt.build" | "retrieval.query" | "retrieval.result" | "retrieval.error" | "model.call" | "model.response" | "model.stream" | "model.error" | "tool.call" | "tool.result" | "tool.error" | "retry" | "timeout" | "error" | "agent.final";
748
- type DocsAnalyticsEventType = "page_view" | "search_open" | "search_close" | "search_query" | "search_result_click" | "search_error" | "ai_open" | "ai_close" | "ai_question" | "ai_response" | "ai_feedback" | "ai_error" | "ai_clear" | "page_action_copy_markdown" | "page_action_open_docs_menu" | "page_action_open_docs" | "code_block_copy" | "feedback_select" | "feedback_submit" | "feedback_error" | "agent_read" | "agent_spec_request" | "agents_request" | "agent_feedback_schema" | "agent_feedback_submit" | "agent_feedback_error" | "markdown_request" | "llms_request" | "skill_request" | "api_search" | "api_ai_request" | "api_ai_response" | "api_ai_error" | "mcp_request" | "mcp_tool";
749
- interface DocsAnalyticsInput {
750
- query?: string;
751
- question?: string;
752
- feedbackValue?: string;
753
- feedbackComment?: string;
754
- feedbackContext?: DocsAgentFeedbackContext;
755
- feedbackPayload?: Record<string, unknown>;
756
- agentFeedbackContext?: DocsAgentFeedbackContext;
757
- agentFeedbackPayload?: Record<string, unknown>;
758
- content?: string;
759
- }
760
- interface DocsEventBase {
761
- timestamp: string;
762
- source: DocsAnalyticsSource;
763
- url?: string;
764
- path?: string;
765
- referrer?: string;
766
- locale?: string;
767
- input?: DocsAnalyticsInput;
768
- metadata?: Record<string, unknown>;
769
- properties?: Record<string, unknown>;
770
- }
771
- interface DocsAnalyticsEvent extends DocsEventBase {
772
- type: DocsAnalyticsEventType | (string & {});
773
- }
774
- type DocsAnalyticsEventInput = Omit<DocsAnalyticsEvent, "timestamp" | "source"> & {
775
- timestamp?: string;
776
- source?: DocsAnalyticsSource;
777
- };
778
- interface DocsObservabilityEvent extends DocsEventBase {
779
- type: DocsAgentTraceEventType | (string & {});
780
- traceId?: string;
781
- spanId?: string;
782
- parentSpanId?: string;
783
- name?: string;
784
- startedAt?: string;
785
- endedAt?: string;
786
- durationMs?: number;
787
- status?: DocsAgentTraceStatus;
788
- inputPreview?: Record<string, unknown>;
789
- outputPreview?: Record<string, unknown>;
790
- }
791
- type DocsObservabilityEventInput = Omit<DocsObservabilityEvent, "timestamp" | "source"> & {
792
- timestamp?: string;
793
- source?: DocsAnalyticsSource;
794
- };
795
- type DocsAgentTraceEventInput = Omit<DocsObservabilityEventInput, "type"> & {
796
- type: DocsAgentTraceEventType;
797
- name: string;
798
- };
799
- interface DocsAnalyticsConfig {
800
- /** Enable event emission. Defaults to `true` when this object is provided. */
801
- enabled?: boolean;
802
- /**
803
- * Log events to the console.
804
- *
805
- * `analytics: true` logs with `console.info`. When `onEvent` is provided,
806
- * console logging is disabled unless this is set.
807
- */
808
- console?: boolean | "log" | "info" | "debug";
809
- /**
810
- * Include raw search queries, AI questions, feedback comments, and copied
811
- * content in emitted events.
812
- *
813
- * Defaults to `false`; events still include safe metadata such as lengths,
814
- * counts, routes, status, and duration.
815
- */
816
- includeInputs?: boolean;
817
- /** Callback fired for every emitted event. */
818
- onEvent?: (event: DocsAnalyticsEvent) => void | Promise<void>;
819
- /**
820
- * Forward events to Docs Cloud when project env vars are available.
821
- *
822
- * @default true
823
- */
824
- cloud?: boolean;
825
- }
826
- type DocsTelemetryFramework = "next" | "tanstack-start" | "sveltekit" | "astro" | "nuxt" | "mcp" | (string & {});
827
- type DocsTelemetryEventType = "project_detected" | "agent_surface_used" | "mcp_request" | "mcp_tool_used" | (string & {});
828
- type DocsTelemetryAgentSurface = "agent_spec" | "agents" | "skill" | "markdown" | "llms" | "agent_feedback_schema" | "agent_feedback_submit" | "ask_ai" | "mcp";
829
- interface DocsTelemetryConfig {
830
- /** Enable Farming Labs maintainer telemetry. Defaults to production-only enabled. */
831
- enabled?: boolean;
832
- /**
833
- * Public site origin to include in telemetry events.
834
- *
835
- * When omitted, the runtime request origin or deployment URL is used when available. Localhost
836
- * and loopback origins are ignored.
837
- */
838
- siteOrigin?: string;
839
- /**
840
- * Override the telemetry ingestion endpoint.
841
- *
842
- * This is mostly useful for self-hosting, development verification, or tests.
843
- */
844
- endpoint?: string;
845
- }
846
- interface DocsTelemetryFeatures {
847
- search: boolean;
848
- ai: boolean;
849
- mcp: boolean;
850
- llmsTxt: boolean;
851
- pageActions: boolean;
852
- feedback: boolean;
853
- agentFeedback: boolean;
854
- sitemap: boolean;
855
- robots: boolean;
856
- apiReference: boolean;
857
- staticExport: boolean;
858
- changelog: boolean;
859
- cloud: boolean;
860
- review: boolean;
861
- codeBlocksValidate: boolean;
862
- }
863
- interface DocsTelemetryEvent {
864
- type: DocsTelemetryEventType;
865
- timestamp: string;
866
- package: {
867
- name: "@farming-labs/docs";
868
- version?: string;
869
- };
870
- framework?: DocsTelemetryFramework;
871
- runtime?: {
872
- name?: string;
873
- version?: string;
874
- };
875
- site?: {
876
- origin?: string;
877
- };
878
- deployment?: {
879
- provider?: string;
880
- environment?: string;
881
- id?: string;
882
- region?: string;
883
- };
884
- features?: Partial<DocsTelemetryFeatures>;
885
- properties?: Record<string, unknown>;
886
- }
887
- type DocsTelemetryEventInput = Omit<DocsTelemetryEvent, "timestamp" | "package"> & {
888
- timestamp?: string;
889
- package?: Partial<DocsTelemetryEvent["package"]>;
890
- };
891
- interface DocsCloudApiKeyConfig {
892
- /**
893
- * Environment variable that stores the Docs Cloud API key.
894
- *
895
- * The key value is never written to docs.json; only this env var name is
896
- * mirrored for CLI and CI workflows.
897
- *
898
- * @default "DOCS_CLOUD_API_KEY"
899
- */
900
- env?: string;
901
- }
902
- interface DocsCloudPreviewConfig {
903
- /**
904
- * Legacy hosted preview deployment gate.
905
- *
906
- * Prefer `cloud.deploy.enabled` in new configs.
907
- *
908
- * @default true when this legacy object is provided
909
- */
910
- enabled?: boolean;
911
- }
912
- interface DocsCloudPublishConfig {
913
- /** How Docs Cloud should publish generated docs changes. @default "draft-pr" */
914
- mode?: "draft-pr" | "direct-commit";
915
- /** Branch that generated docs work should target. @default "main" */
916
- baseBranch?: string;
917
- }
918
- interface DocsCloudFeatureConfig {
919
- /** Whether the hosted cloud feature is enabled. @default true */
920
- enabled?: boolean;
921
- }
922
- interface DocsCloudConfig {
923
- /**
924
- * Optional explicit cloud toggle.
925
- *
926
- * Prefer omitting this in new projects; the presence of `cloud` opts the
927
- * project into cloud-aware CLI flows. This remains available for backwards
928
- * compatibility with older docs.json files.
929
- */
930
- enabled?: boolean;
931
- /** API key lookup used by `docs deploy` and other cloud CLI commands. */
932
- apiKey?: DocsCloudApiKeyConfig;
933
- /**
934
- * Same-origin route for the generated Docs API handler.
935
- *
936
- * Next.js layouts use this as the default client analytics proxy when no
937
- * hosted analytics endpoint env is configured. Set it when the route is
938
- * mounted somewhere other than `/api/docs`, or when a deployment uses a
939
- * public base path.
940
- *
941
- * @default "/api/docs"
942
- */
943
- apiRoute?: string;
944
- /** Legacy hosted preview deployment settings. Prefer `deploy` in new configs. */
945
- preview?: DocsCloudPreviewConfig;
946
- /** Generated docs publishing settings. */
947
- publish?: DocsCloudPublishConfig;
948
- /** Hosted analytics settings that can be mirrored to docs.json. */
949
- analytics?: boolean | Omit<DocsAnalyticsConfig, "onEvent">;
950
- /** Hosted AI feature toggle. */
951
- ai?: DocsCloudFeatureConfig;
952
- /** Hosted deployment feature toggle used by `docs deploy`. */
953
- deploy?: DocsCloudFeatureConfig;
954
- }
955
- interface DocsObservabilityConfig {
956
- /** Enable trace emission. Defaults to `true` when this object is provided. */
957
- enabled?: boolean;
958
- /**
959
- * Log trace events to the console.
960
- *
961
- * `observability: true` logs with `console.info`. When `onEvent` is provided,
962
- * console logging is disabled unless this is set.
963
- */
964
- console?: boolean | "log" | "info" | "debug";
965
- /**
966
- * Include raw `input` fields on observability events.
967
- *
968
- * Defaults to `false`; events still include safe metadata such as lengths,
969
- * counts, routes, status, and duration. Built-in trace events use previews
970
- * instead of raw user-authored text.
971
- */
972
- includeInputs?: boolean;
973
- /** Callback fired for every emitted trace event. */
974
- onEvent?: (event: DocsObservabilityEvent) => void | Promise<void>;
975
- }
976
- /**
977
- * Configuration for the "Last updated" date display.
978
- *
979
- * @example
980
- * ```ts
981
- * lastUpdated: { position: "below-title" }
982
- * ```
983
- */
984
- /**
985
- * Configuration for auto-generated `/llms.txt` and `/llms-full.txt` routes.
986
- * Native static files at the same public routes take precedence.
987
- *
988
- * @see https://llmstxt.org
989
- */
990
- interface LlmsTxtConfig {
991
- /**
992
- * Whether to enable llms.txt generation.
993
- * @default true
994
- */
995
- enabled?: boolean;
996
- /**
997
- * Whether to expose and advertise the RFC 9727 API catalog.
998
- * Agent Skills discovery remains available when this is disabled.
999
- * @default true
1000
- */
1001
- apiCatalog?: boolean;
1002
- /**
1003
- * Base URL for your docs site (used to build absolute links in llms.txt).
1004
- * @example "https://docs.example.com"
1005
- */
1006
- baseUrl?: string;
1007
- /**
1008
- * Site title shown at the top of llms.txt.
1009
- * Falls back to `nav.title` if not set.
1010
- */
1011
- siteTitle?: string;
1012
- /**
1013
- * Site description shown below the title.
1014
- */
1015
- siteDescription?: string;
1016
- /**
1017
- * Character budget for generated compact `llms.txt` files.
1018
- *
1019
- * `mode: "warn"` logs a warning when the generated content is over budget.
1020
- * `mode: "error"` returns an error response for that generated file.
1021
- * `mode: "off"` disables the budget check.
1022
- *
1023
- * @default { mode: "warn", chars: 50000 }
1024
- */
1025
- maxChars?: LlmsTxtMaxCharsConfig;
1026
- /**
1027
- * Optional section-level llms.txt files for progressive disclosure.
1028
- *
1029
- * Each section is matched against public docs URLs, for example
1030
- * `/docs/api/**` derives `/docs/api/llms.txt` and
1031
- * `/docs/api/llms-full.txt`.
1032
- */
1033
- sections?: LlmsTxtSectionConfig[];
1034
- }
1035
- type LlmsTxtMaxCharsMode = "warn" | "error" | "off";
1036
- interface LlmsTxtMaxCharsConfig {
1037
- /**
1038
- * How to handle generated llms.txt content that exceeds `chars`.
1039
- *
1040
- * @default "warn"
1041
- */
1042
- mode?: LlmsTxtMaxCharsMode;
1043
- /**
1044
- * Maximum recommended character count.
1045
- *
1046
- * @default 50000
1047
- */
1048
- chars?: number;
1049
- }
1050
- interface LlmsTxtSectionConfig {
1051
- /**
1052
- * Human-readable section title shown in the root and section files.
1053
- */
1054
- title: string;
1055
- /**
1056
- * Optional description shown next to the section link in root llms.txt.
1057
- */
1058
- description?: string;
1059
- /**
1060
- * Public URL matcher for pages included in this section.
1061
- *
1062
- * Supported forms include exact paths such as `/docs/reference` and
1063
- * prefix globs such as `/docs/api/**`.
1064
- */
1065
- match: string | string[];
1066
- /**
1067
- * Optional section-specific character budget. Inherits `llmsTxt.maxChars`
1068
- * when omitted.
1069
- */
1070
- maxChars?: LlmsTxtMaxCharsConfig;
1071
- }
1072
- interface SitemapXmlConfig {
1073
- /**
1074
- * Whether to expose the XML sitemap route.
1075
- * @default true
1076
- */
1077
- enabled?: boolean;
1078
- /**
1079
- * Include per-page `<lastmod>` entries when a reliable page date is available.
1080
- * @default true
1081
- */
1082
- includeLastmod?: boolean;
1083
- }
1084
- interface SitemapMarkdownConfig {
1085
- /**
1086
- * Whether to expose the Markdown sitemap route.
1087
- * @default true
1088
- */
1089
- enabled?: boolean;
1090
- /**
1091
- * Include page descriptions in the Markdown sitemap.
1092
- * @default true
1093
- */
1094
- includeDescriptions?: boolean;
1095
- /**
1096
- * Include per-page freshness dates in the Markdown sitemap.
1097
- * @default true
1098
- */
1099
- includeLastmod?: boolean;
1100
- /**
1101
- * Which URL each Markdown list item should primarily link to.
1102
- * @default "both"
1103
- */
1104
- linkTarget?: "html" | "markdown" | "both";
1105
- }
1106
- /**
1107
- * Configuration for generated `/sitemap.xml`, `/sitemap.md`, `/docs/sitemap.md`, and
1108
- * `/.well-known/sitemap.md` routes.
1109
- */
1110
- interface DocsSitemapConfig {
1111
- /**
1112
- * Whether to enable sitemap routes.
1113
- * @default true
1114
- */
1115
- enabled?: boolean;
1116
- /**
1117
- * Optional route prefix. For example, `"/docs"` generates
1118
- * `/docs/sitemap.xml`, `/docs/sitemap.md`, and `/docs/.well-known/sitemap.md`.
1119
- * @default ""
1120
- */
1121
- routePrefix?: string;
1122
- /**
1123
- * Public site URL used to build absolute XML sitemap URLs.
1124
- * Falls back to the request origin at runtime or llmsTxt.baseUrl in the CLI.
1125
- */
1126
- baseUrl?: string;
1127
- /**
1128
- * Internal generated manifest path.
1129
- * @default ".farming-labs/sitemap-manifest.json"
1130
- */
1131
- manifestPath?: string;
1132
- /** XML sitemap options. */
1133
- xml?: boolean | SitemapXmlConfig;
1134
- /** Markdown sitemap options. */
1135
- markdown?: boolean | SitemapMarkdownConfig;
1136
- }
1137
- interface DocsRobotsRule {
1138
- /** User-agent name or names for this robots.txt rule block. */
1139
- userAgent: string | string[];
1140
- /** Routes to allow for the user-agent block. */
1141
- allow?: string | string[];
1142
- /** Routes to disallow for the user-agent block. */
1143
- disallow?: string | string[];
1144
- /** Optional crawl-delay value emitted as-is for crawlers that support it. */
1145
- crawlDelay?: number;
1146
- }
1147
- /**
1148
- * Configuration for generated `robots.txt` agent access policy files.
1149
- */
1150
- interface DocsRobotsConfig {
1151
- /**
1152
- * Whether robots.txt generation is enabled.
1153
- * @default true when `robots` is an object
1154
- */
1155
- enabled?: boolean;
1156
- /**
1157
- * Output file path used by `docs robots generate`.
1158
- * Falls back to the framework public directory, such as `public/robots.txt`
1159
- * or `static/robots.txt` for SvelteKit.
1160
- */
1161
- path?: string;
1162
- /**
1163
- * Public site URL used for the `Sitemap:` line.
1164
- * Falls back to `sitemap.baseUrl` or `llmsTxt.baseUrl` in the CLI.
1165
- */
1166
- baseUrl?: string;
1167
- /**
1168
- * Whether to explicitly allow or disallow common AI crawlers.
1169
- * @default "allow"
1170
- */
1171
- ai?: boolean | "allow" | "disallow";
1172
- /**
1173
- * Additional AI user-agent names to include beside the defaults.
1174
- */
1175
- aiUserAgents?: string | string[];
1176
- /**
1177
- * Extra robots.txt rule blocks appended after the generated agent policy.
1178
- */
1179
- extraRules?: DocsRobotsRule[];
1180
- }
1181
- /**
1182
- * Tool-level toggles for the built-in MCP server.
1183
- *
1184
- * All tools default to `true` when omitted.
1185
- */
1186
- interface DocsMcpToolsConfig {
1187
- /** Expose a `list_docs` tool that returns docs pages grouped by section. */
1188
- listDocs?: boolean;
1189
- /** Expose a `list_pages` tool that returns the known docs pages. */
1190
- listPages?: boolean;
1191
- /** Expose a `read_page` tool that returns a page by slug or URL path. */
1192
- readPage?: boolean;
1193
- /** Expose a `list_tasks` tool for pages with actionable agent contracts. */
1194
- listTasks?: boolean;
1195
- /** Expose a `read_task` tool that returns a page's full agent contract. */
1196
- readTask?: boolean;
1197
- /** Expose a `search_docs` tool for keyword search over page content. */
1198
- searchDocs?: boolean;
1199
- /** Expose a `get_navigation` tool for the docs tree. */
1200
- getNavigation?: boolean;
1201
- /** Expose a `get_code_examples` tool for fenced code blocks and their metadata. */
1202
- getCodeExamples?: boolean;
1203
- /** Expose a `get_config_schema` tool for docs.config option metadata. */
1204
- getConfigSchema?: boolean;
1205
- /** Expose deterministic `get_context` retrieval with a conservative UTF-8 byte ceiling. */
1206
- getContext?: boolean;
1207
- }
1208
- /** Authenticated identity returned by an MCP authentication callback. */
1209
- interface DocsMcpAuthPrincipal {
1210
- /** Stable identifier for the authenticated user, service, or agent. */
1211
- id: string;
1212
- /** Optional authorization scopes that source adapters can inspect. */
1213
- scopes?: string[];
1214
- /** Additional application-specific identity claims. */
1215
- claims?: Record<string, unknown>;
1216
- }
1217
- /** Context passed to an MCP Origin policy callback. */
1218
- interface DocsMcpOriginContext {
1219
- /** Origin header supplied by the HTTP client. */
1220
- origin: string;
1221
- /** Portable Web Request for the incoming MCP request. */
1222
- request: Request;
1223
- }
1224
- /** Context passed to an opt-in MCP authentication callback. */
1225
- interface DocsMcpAuthenticateContext {
1226
- /** Portable Web Request for the incoming MCP request. */
1227
- request: Request;
1228
- /** Normalized pathname of the MCP endpoint being requested. */
1229
- pathname: string;
1230
- }
1231
- type DocsMcpAllowedOrigins = "same-origin" | readonly string[] | ((context: DocsMcpOriginContext) => boolean | Promise<boolean>);
1232
- type DocsMcpAuthenticateResult = DocsMcpAuthPrincipal | null | Response;
1233
- type DocsMcpAuthenticate = (context: DocsMcpAuthenticateContext) => DocsMcpAuthenticateResult | Promise<DocsMcpAuthenticateResult>;
1234
- /** Browser CORS response controls for an Origin already accepted by `allowedOrigins`. */
1235
- interface DocsMcpCorsConfig {
1236
- /** Additional request headers accepted during browser preflight. */
1237
- allowedHeaders?: readonly string[];
1238
- /** Additional response headers exposed to browser clients. */
1239
- exposedHeaders?: readonly string[];
1240
- /** Emit `Access-Control-Allow-Credentials: true`. Defaults to `false`. */
1241
- allowCredentials?: boolean;
1242
- /** Browser preflight cache lifetime in seconds. Defaults to 600. */
1243
- maxAgeSeconds?: number;
1244
- }
1245
- /** Security controls for the Streamable HTTP MCP transport. */
1246
- interface DocsMcpSecurityConfig {
1247
- /**
1248
- * Allowed values for a supplied HTTP Origin header.
1249
- * Defaults to `"same-origin"`. Requests without Origin remain supported for non-browser clients.
1250
- */
1251
- allowedOrigins?: DocsMcpAllowedOrigins;
1252
- /**
1253
- * Optional authentication callback. HTTP MCP stays public when omitted. When present,
1254
- * returning `null` rejects the request with 401 and returning a Response passes it through.
1255
- */
1256
- authenticate?: DocsMcpAuthenticate;
1257
- /** Maximum POST body size in bytes. Defaults to 1 MiB. */
1258
- maxBodyBytes?: number;
1259
- /**
1260
- * CORS responses for accepted browser Origins. Defaults to enabled with exact-Origin responses;
1261
- * set `false` to suppress CORS headers or use an object for credential/header controls.
1262
- */
1263
- cors?: boolean | DocsMcpCorsConfig;
1264
- }
1265
- /**
1266
- * Built-in MCP server configuration.
1267
- *
1268
- * When enabled, adapters can expose a Streamable HTTP endpoint for your docs
1269
- * at `/mcp` and `/.well-known/mcp`, backed by the canonical `/api/docs/mcp` route.
1270
- * The same config is also reused by the local `docs mcp` stdio command.
1271
- */
1272
- interface DocsMcpConfig {
1273
- /** Whether to enable the built-in MCP server. Defaults to `true` when this object is provided. */
1274
- enabled?: boolean;
1275
- /**
1276
- * Streamable HTTP route for the MCP endpoint.
1277
- * Defaults to `/api/docs/mcp`; generated projects can also expose it publicly at `/mcp` and `/.well-known/mcp`.
1278
- */
1279
- route?: string;
1280
- /**
1281
- * Human-readable MCP server name shown to clients.
1282
- * Defaults to the string `nav.title` when available, otherwise `@farming-labs/docs`.
1283
- */
1284
- name?: string;
1285
- /**
1286
- * Version string reported by the MCP server.
1287
- * Defaults to `"0.0.0"` when not set.
1288
- */
1289
- version?: string;
1290
- /** Fine-grained tool toggles. Omitted tools stay enabled. */
1291
- tools?: DocsMcpToolsConfig;
1292
- /** Streamable HTTP security controls. Authentication is opt-in; stdio is unaffected. */
1293
- security?: DocsMcpSecurityConfig;
1294
- }
1295
- type DocsSearchResultType = "page" | "heading" | "text";
1296
- interface DocsSearchSourcePage {
1297
- title: string;
1298
- url: string;
1299
- content: string;
1300
- description?: string;
1301
- related?: ResolvedDocsRelatedLink[];
1302
- agent?: PageAgentFrontmatter;
1303
- sourcePath?: string;
1304
- lastModified?: string;
1305
- lastmod?: string;
1306
- rawContent?: string;
1307
- agentContent?: string;
1308
- agentRawContent?: string;
1309
- agentFallbackContent?: string;
1310
- agentFallbackRawContent?: string;
1311
- type?: "page" | "api" | "code" | "changelog";
1312
- locale?: string;
1313
- framework?: string;
1314
- version?: string;
1315
- tags?: string[];
1316
- }
1317
- interface DocsSearchDocument {
1318
- id: string;
1319
- url: string;
1320
- title: string;
1321
- content: string;
1322
- description?: string;
1323
- section?: string;
1324
- type: DocsSearchResultType;
1325
- locale?: string;
1326
- framework?: string;
1327
- version?: string;
1328
- tags?: string[];
1329
- }
1330
- interface DocsSearchResult {
1331
- id: string;
1332
- url: string;
1333
- content: string;
1334
- description?: string;
1335
- type: DocsSearchResultType;
1336
- score?: number;
1337
- section?: string;
1338
- }
1339
- interface DocsSearchQuery {
1340
- query: string;
1341
- limit?: number;
1342
- locale?: string;
1343
- pathname?: string;
1344
- }
1345
- interface DocsSearchAdapterContext {
1346
- pages: DocsSearchSourcePage[];
1347
- documents: DocsSearchDocument[];
1348
- locale?: string;
1349
- pathname?: string;
1350
- siteTitle?: string;
1351
- /** Optional cancellation signal, including diagnostic timeouts. */
1352
- signal?: AbortSignal;
1353
- }
1354
- interface DocsSearchAdapter {
1355
- name: string;
1356
- index?(context: DocsSearchAdapterContext): Promise<void>;
1357
- search(query: DocsSearchQuery, context: DocsSearchAdapterContext): Promise<DocsSearchResult[]>;
1358
- }
1359
- type DocsSearchAdapterFactory = (context: DocsSearchAdapterContext) => DocsSearchAdapter | Promise<DocsSearchAdapter>;
1360
- interface DocsSearchChunkingConfig {
1361
- /**
1362
- * How docs content should be chunked before searching.
1363
- *
1364
- * - `"page"` keeps one search document per page
1365
- * - `"section"` splits pages by headings and improves precision
1366
- *
1367
- * @default "section"
1368
- */
1369
- strategy?: "page" | "section";
1370
- }
1371
- interface DocsSearchEmbeddingsConfig {
1372
- /**
1373
- * Embeddings provider used for hybrid / semantic search.
1374
- * The initial built-in provider is Ollama for local or self-hosted setups.
1375
- */
1376
- provider: "ollama";
1377
- /** Embedding model id, e.g. `embeddinggemma`. */
1378
- model: string;
1379
- /** Base URL of the embedding API. @default "http://127.0.0.1:11434" */
1380
- baseUrl?: string;
1381
- }
1382
- interface SimpleDocsSearchConfig {
1383
- provider?: "simple";
1384
- enabled?: boolean;
1385
- maxResults?: number;
1386
- chunking?: DocsSearchChunkingConfig;
1387
- }
1388
- interface AlgoliaDocsSearchConfig {
1389
- provider: "algolia";
1390
- enabled?: boolean;
1391
- appId: string;
1392
- indexName: string;
1393
- searchApiKey: string;
1394
- adminApiKey?: string;
1395
- maxResults?: number;
1396
- syncOnSearch?: boolean;
1397
- chunking?: DocsSearchChunkingConfig;
1398
- }
1399
- interface TypesenseDocsSearchConfig {
1400
- provider: "typesense";
1401
- enabled?: boolean;
1402
- baseUrl: string;
1403
- collection: string;
1404
- apiKey: string;
1405
- adminApiKey?: string;
1406
- maxResults?: number;
1407
- syncOnSearch?: boolean;
1408
- queryBy?: string[];
1409
- mode?: "keyword" | "hybrid";
1410
- embeddings?: DocsSearchEmbeddingsConfig;
1411
- chunking?: DocsSearchChunkingConfig;
1412
- }
1413
- interface McpDocsSearchConfig {
1414
- provider: "mcp";
1415
- enabled?: boolean;
1416
- /**
1417
- * Streamable HTTP MCP endpoint. Relative paths like `/mcp` or `/.well-known/mcp`
1418
- * are resolved against the current docs API request URL.
1419
- */
1420
- endpoint: string;
1421
- /**
1422
- * Optional extra headers passed to the MCP endpoint on initialize/tool calls.
1423
- */
1424
- headers?: Record<string, string>;
1425
- /**
1426
- * MCP tool name used for search. Defaults to `search_docs`.
1427
- */
1428
- toolName?: string;
1429
- /**
1430
- * Override the MCP protocol version header when needed.
1431
- */
1432
- protocolVersion?: string;
1433
- maxResults?: number;
1434
- chunking?: DocsSearchChunkingConfig;
1435
- }
1436
- type DocsAskAIMcpConfig = Omit<McpDocsSearchConfig, "provider"> & {
1437
- provider?: "mcp";
1438
- };
1439
- interface CustomDocsSearchConfig {
1440
- provider: "custom";
1441
- enabled?: boolean;
1442
- adapter: DocsSearchAdapter | DocsSearchAdapterFactory;
1443
- maxResults?: number;
1444
- chunking?: DocsSearchChunkingConfig;
1445
- }
1446
- type DocsSearchConfig = SimpleDocsSearchConfig | AlgoliaDocsSearchConfig | McpDocsSearchConfig | TypesenseDocsSearchConfig | CustomDocsSearchConfig;
1447
- interface LastUpdatedConfig {
1448
- /**
1449
- * Whether to show the "Last updated" date.
1450
- * @default true
1451
- */
1452
- enabled?: boolean;
1453
- /**
1454
- * Label shown before the formatted date.
1455
- * @default "Last updated"
1456
- */
1457
- label?: string;
1458
- /**
1459
- * Where to render the "Last updated" date.
1460
- *
1461
- * - `"footer"` — next to the "Edit on GitHub" link at the bottom (default)
1462
- * - `"below-title"` — below the page title/description, above the content
1463
- *
1464
- * @default "footer"
1465
- */
1466
- position?: "footer" | "below-title";
1467
- }
1468
- type ReadingTimeFormat = "long" | "short";
1469
- /**
1470
- * Configuration for estimated page reading time.
1471
- *
1472
- * @example
1473
- * ```ts
1474
- * readingTime: { enabled: true, wordsPerMinute: 220 }
1475
- * ```
1476
- */
1477
- interface ReadingTimeConfig {
1478
- /**
1479
- * Whether to show the estimated reading time.
1480
- * @default true
1481
- */
1482
- enabled?: boolean;
1483
- /**
1484
- * Words-per-minute rate used for the estimate.
1485
- * @default 220
1486
- */
1487
- wordsPerMinute?: number;
1488
- /**
1489
- * Label style used when rendering the reading-time estimate.
1490
- *
1491
- * `"long"` renders labels like `3 min read`; `"short"` renders `3 min`.
1492
- *
1493
- * @default "long"
1494
- */
1495
- format?: ReadingTimeFormat;
1496
- /**
1497
- * Whether fenced and inline code should count toward the estimate.
1498
- *
1499
- * Code is ignored by default so the label reflects human prose. Set this to
1500
- * `true` when code-heavy guides should include examples in the estimate.
1501
- *
1502
- * @default false
1503
- */
1504
- includeCode?: boolean;
1505
- }
1506
- /**
1507
- * GitHub repository configuration for "Edit on GitHub" links
1508
- * and source file references.
1509
- *
1510
- * @example
1511
- * ```ts
1512
- * // Simple repo (not a monorepo)
1513
- * github: {
1514
- * url: "https://github.com/Kinfe123/my-docs",
1515
- * }
1516
- *
1517
- * // Monorepo — docs site lives in "website/" subdirectory
1518
- * github: {
1519
- * url: "https://github.com/farming-labs/docs",
1520
- * directory: "website",
1521
- * branch: "main",
1522
- * }
1523
- * ```
1524
- *
1525
- * Or as a simple string (branch defaults to "main", no directory prefix):
1526
- * ```ts
1527
- * github: "https://github.com/Kinfe123/my-docs"
1528
- * ```
1529
- */
1530
- interface GithubConfig {
1531
- /** Repository URL (e.g. "https://github.com/farming-labs/docs") */
1532
- url: string;
1533
- /** Branch name. @default "main" */
1534
- branch?: string;
1535
- /**
1536
- * Subdirectory inside the repo where the docs site lives.
1537
- * Use this for monorepos where the docs app is not at the repo root.
1538
- *
1539
- * @example "website" → links point to `website/app/docs/…/page.mdx`
1540
- */
1541
- directory?: string;
1542
- }
1543
- type DocsAskAIFeedbackValue = "like" | "dislike";
1544
- type DocsAskAIActionType = "copy" | DocsAskAIFeedbackValue;
1545
- interface DocsAskAIFeedbackMessage {
1546
- role: "user" | "assistant";
1547
- content: string;
1548
- }
1549
- interface DocsAskAIActionData {
1550
- type: DocsAskAIActionType;
1551
- value?: DocsAskAIFeedbackValue;
1552
- question: string;
1553
- answer: string;
1554
- messageId?: string;
1555
- messageIndex?: number;
1556
- model?: string;
1557
- surface?: string;
1558
- url?: string;
1559
- path?: string;
1560
- messages?: DocsAskAIFeedbackMessage[];
1561
- copied?: boolean;
1562
- }
1563
- interface DocsAskAIFeedbackData {
1564
- value: DocsAskAIFeedbackValue;
1565
- question: string;
1566
- answer: string;
1567
- messageId?: string;
1568
- messageIndex?: number;
1569
- model?: string;
1570
- surface?: string;
1571
- url?: string;
1572
- path?: string;
1573
- messages?: DocsAskAIFeedbackMessage[];
1574
- }
1575
- interface DocsAskAIFeedbackConfig {
1576
- /**
1577
- * Whether to show the copy, like, and dislike action row after each completed Ask AI answer.
1578
- * @default true
1579
- */
1580
- enabled?: boolean;
1581
- /** Label for the positive rating button. @default "Helpful" */
1582
- positiveLabel?: string;
1583
- /** Label for the negative rating button. @default "Not helpful" */
1584
- negativeLabel?: string;
1585
- /** Called when a user rates an Ask AI response. */
1586
- onFeedback?: (data: DocsAskAIFeedbackData) => void | Promise<void>;
1587
- }
1588
- /**
1589
- * Configuration for "Ask AI" — a RAG-powered chat that lets users
1590
- * ask questions about the documentation content.
1591
- *
1592
- * The AI handler searches relevant doc pages, builds context, and
1593
- * streams a response from an LLM (OpenAI-compatible API).
1594
- *
1595
- * The API key is **never** stored in the config. It is read from the
1596
- * `OPENAI_API_KEY` environment variable at runtime on the server.
1597
- *
1598
- * @example
1599
- * ```ts
1600
- * ai: {
1601
- * enabled: true,
1602
- * model: "gpt-4o-mini",
1603
- * systemPrompt: "You are a helpful assistant for our developer docs.",
1604
- * }
1605
- * ```
1606
- */
1607
- interface AIConfig {
1608
- /**
1609
- * Whether to enable "Ask AI" functionality.
1610
- * When enabled, the unified `/api/docs` route handler will accept
1611
- * POST requests for AI chat.
1612
- * @default false
1613
- */
1614
- enabled?: boolean;
1615
- /**
1616
- * How the AI chat UI is presented.
1617
- *
1618
- * - `"search"` — AI tab integrated into the Cmd+K search dialog (default)
1619
- * - `"floating"` — A floating chat widget (bubble button + slide-out panel)
1620
- *
1621
- * @default "search"
1622
- *
1623
- * @example
1624
- * ```ts
1625
- * // Floating chat bubble in the bottom-right corner
1626
- * ai: {
1627
- * enabled: true,
1628
- * mode: "floating",
1629
- * position: "bottom-right",
1630
- * }
1631
- * ```
1632
- */
1633
- mode?: "search" | "floating" | "sidebar-icon";
1634
- /**
1635
- * Position of the floating chat button on screen.
1636
- * Only used when `mode` is `"floating"`.
1637
- *
1638
- * - `"bottom-right"` — bottom-right corner (default)
1639
- * - `"bottom-left"` — bottom-left corner
1640
- * - `"bottom-center"` — bottom center
1641
- *
1642
- * @default "bottom-right"
1643
- */
1644
- position?: "bottom-right" | "bottom-left" | "bottom-center";
1645
- /**
1646
- * Visual style of the floating chat when opened.
1647
- * Only used when `mode` is `"floating"`.
1648
- *
1649
- * - `"panel"` — A tall panel that slides up from the button position (default).
1650
- * Stays anchored near the floating button. No backdrop overlay.
1651
- *
1652
- * - `"modal"` — A centered modal dialog with a backdrop overlay,
1653
- * similar to the Cmd+K search dialog. Feels more focused and immersive.
1654
- *
1655
- * - `"popover"` — A compact popover near the button. Smaller than the
1656
- * panel, suitable for quick questions without taking much screen space.
1657
- *
1658
- * - `"full-modal"` — A full-screen immersive overlay (inspired by better-auth).
1659
- * Messages scroll in the center, input is pinned at the bottom.
1660
- * Suggested questions appear as horizontal pills. Best for
1661
- * documentation-heavy sites that want a premium AI experience.
1662
- *
1663
- * @default "panel"
1664
- *
1665
- * @example
1666
- * ```ts
1667
- * ai: {
1668
- * enabled: true,
1669
- * mode: "floating",
1670
- * position: "bottom-right",
1671
- * floatingStyle: "full-modal",
1672
- * }
1673
- * ```
1674
- */
1675
- floatingStyle?: "panel" | "modal" | "popover" | "full-modal";
1676
- /**
1677
- * Custom trigger component for the floating chat button (Next.js only).
1678
- * Only used when `mode` is `"floating"`.
1679
- *
1680
- * The click handler is attached automatically by the wrapper.
1681
- *
1682
- * - **Next.js**: Pass a JSX element via this config option.
1683
- * - **SvelteKit**: Use the `aiTrigger` snippet on `<DocsLayout>`.
1684
- * - **Nuxt / Vue**: Use the `ai-trigger` slot on `<DocsLayout>`.
1685
- * - **Astro**: Use `<MyTrigger slot="ai-trigger" />` on `<DocsLayout>`.
1686
- *
1687
- * @example
1688
- * ```tsx
1689
- * // Next.js — pass JSX directly in config
1690
- * triggerComponent: <button className="my-chat-btn">Ask AI</button>,
1691
- * ```
1692
- *
1693
- * ```svelte
1694
- * <!-- SvelteKit — use snippet in layout -->
1695
- * <DocsLayout {tree} {config}>
1696
- * {#snippet aiTrigger()}<AskAITrigger />{/snippet}
1697
- * {@render children()}
1698
- * </DocsLayout>
1699
- * ```
1700
- *
1701
- * ```vue
1702
- * <!-- Nuxt / Vue — use named slot in layout -->
1703
- * <DocsLayout :tree="tree" :config="config">
1704
- * <template #ai-trigger><AskAITrigger /></template>
1705
- * <DocsContent />
1706
- * </DocsLayout>
1707
- * ```
1708
- *
1709
- * ```astro
1710
- * <!-- Astro — use named slot in layout -->
1711
- * <DocsLayout tree={tree} config={config}>
1712
- * <AskAITrigger slot="ai-trigger" />
1713
- * <DocsContent />
1714
- * </DocsLayout>
1715
- * ```
1716
- */
1717
- triggerComponent?: unknown;
1718
- /**
1719
- * Server-side answer provider used by Ask AI.
1720
- *
1721
- * - `"docs-cloud"` — send questions to the configured Docs Cloud project
1722
- * using `PUBLIC_DOCS_CLOUD_PROJECT_ID` and a browser-safe
1723
- * Docs Cloud API key env such as `PUBLIC_DOCS_CLOUD_API_KEY`.
1724
- * If only a server-side key is configured, framework integrations may
1725
- * proxy through the local docs API route.
1726
- * - Omit this option to use the built-in OpenAI-compatible RAG handler.
1727
- *
1728
- * @example
1729
- * ```ts
1730
- * ai: {
1731
- * enabled: true,
1732
- * provider: "docs-cloud",
1733
- * }
1734
- * ```
1735
- */
1736
- provider?: "docs-cloud" | (string & {});
1737
- /**
1738
- * Whether Ask AI should request streaming responses when the selected
1739
- * provider supports them.
1740
- *
1741
- * Docs Cloud streams token deltas by default for `provider: "docs-cloud"`.
1742
- * Set this to `false` to request a single JSON answer instead.
1743
- *
1744
- * @default true
1745
- */
1746
- stream?: boolean;
1747
- /**
1748
- * The LLM model configuration.
1749
- *
1750
- * **Simple** — pass a plain string for a single model:
1751
- * ```ts
1752
- * model: "gpt-4o-mini"
1753
- * ```
1754
- *
1755
- * **Advanced** — pass an object with multiple selectable models and an
1756
- * optional `provider` key that references a named provider in `providers`:
1757
- * ```ts
1758
- * model: {
1759
- * models: [
1760
- * { id: "gpt-4o-mini", label: "GPT-4o mini (fast)", provider: "openai" },
1761
- * { id: "llama-3.3-70b-versatile", label: "Llama 3.3 70B", provider: "groq" },
1762
- * ],
1763
- * defaultModel: "gpt-4o-mini",
1764
- * }
1765
- * ```
1766
- *
1767
- * When an object is provided, a model selector dropdown appears in the
1768
- * AI chat interface.
1769
- *
1770
- * @default "gpt-4o-mini"
1771
- */
1772
- model?: string | {
1773
- models: {
1774
- id: string;
1775
- label: string;
1776
- provider?: string;
1777
- }[];
1778
- defaultModel?: string;
1779
- };
1780
- /**
1781
- * Named provider configurations for multi-provider setups.
1782
- *
1783
- * Each key is a provider name referenced by `model.models[].provider`.
1784
- * Each value contains a `baseUrl` and optional `apiKey`.
1785
- *
1786
- * @example
1787
- * ```ts
1788
- * providers: {
1789
- * openai: {
1790
- * baseUrl: "https://api.openai.com/v1",
1791
- * apiKey: process.env.OPENAI_API_KEY,
1792
- * },
1793
- * groq: {
1794
- * baseUrl: "https://api.groq.com/openai/v1",
1795
- * apiKey: process.env.GROQ_API_KEY,
1796
- * },
1797
- * }
1798
- * ```
1799
- */
1800
- providers?: Record<string, {
1801
- baseUrl: string;
1802
- apiKey?: string;
1803
- }>;
1804
- /**
1805
- * Custom system prompt prepended to the AI conversation.
1806
- * The documentation context is automatically appended after this prompt.
1807
- *
1808
- * @default "You are a helpful documentation assistant. Answer questions
1809
- * based on the provided documentation context. Be concise and accurate.
1810
- * If the answer is not in the context, say so honestly."
1811
- */
1812
- systemPrompt?: string;
1813
- /**
1814
- * Default base URL for an OpenAI-compatible API endpoint.
1815
- * Used when no per-model `provider` is configured.
1816
- * @default "https://api.openai.com/v1"
1817
- */
1818
- baseUrl?: string;
1819
- /**
1820
- * Default API key for the LLM provider.
1821
- * Used when no per-model `provider` is configured.
1822
- * Falls back to `process.env.OPENAI_API_KEY` if not set.
1823
- *
1824
- * @default process.env.OPENAI_API_KEY
1825
- *
1826
- * @example
1827
- * ```ts
1828
- * // Default — reads OPENAI_API_KEY automatically
1829
- * ai: { enabled: true }
1830
- *
1831
- * // Custom provider key
1832
- * ai: {
1833
- * enabled: true,
1834
- * apiKey: process.env.GROQ_API_KEY,
1835
- * }
1836
- * ```
1837
- */
1838
- apiKey?: string;
1839
- /**
1840
- * Maximum number of search results to include as context for the AI.
1841
- * More results = more context but higher token usage.
1842
- * @default 5
1843
- */
1844
- maxResults?: number;
1845
- /**
1846
- * Route Ask AI retrieval through the configured MCP `search_docs` tool.
1847
- *
1848
- * - `true` uses the MCP server this docs site already exposes at `mcp.route`
1849
- * (default `/api/docs/mcp`)
1850
- * - an object can point Ask AI at another Streamable HTTP MCP endpoint
1851
- *
1852
- * This only affects Ask AI retrieval. The normal docs search API still uses
1853
- * the top-level `search` config.
1854
- *
1855
- * @default false
1856
- *
1857
- * @example
1858
- * ```ts
1859
- * ai: {
1860
- * enabled: true,
1861
- * useMcp: true,
1862
- * }
1863
- * ```
1864
- */
1865
- useMcp?: boolean | DocsAskAIMcpConfig;
1866
- /**
1867
- * Pre-filled suggested questions shown in the AI chat when empty.
1868
- * When a user clicks one, it fills the input and submits automatically.
1869
- *
1870
- * @example
1871
- * ```ts
1872
- * ai: {
1873
- * enabled: true,
1874
- * suggestedQuestions: [
1875
- * "How do I install this?",
1876
- * "What themes are available?",
1877
- * "How do I create a custom component?",
1878
- * ],
1879
- * }
1880
- * ```
1881
- */
1882
- suggestedQuestions?: string[];
1883
- /**
1884
- * Display name for the AI assistant in the chat UI.
1885
- * Shown as the message label, header title, and passed to the loading component.
1886
- *
1887
- * @default "AI"
1888
- *
1889
- * @example
1890
- * ```ts
1891
- * ai: {
1892
- * enabled: true,
1893
- * aiLabel: "DocsBot",
1894
- * }
1895
- * ```
1896
- */
1897
- aiLabel?: string;
1898
- /**
1899
- * Optional npm package-name override used in import examples.
1900
- * Ask AI normally infers package names and exact imports from retrieved docs context.
1901
- *
1902
- * @example
1903
- * ```ts
1904
- * ai: {
1905
- * enabled: true,
1906
- * packageName: "@farming-labs/docs",
1907
- * }
1908
- * ```
1909
- */
1910
- packageName?: string;
1911
- /**
1912
- * The public URL of the documentation site.
1913
- * The AI will use this for links instead of relative paths.
1914
- *
1915
- * @example
1916
- * ```ts
1917
- * ai: {
1918
- * enabled: true,
1919
- * docsUrl: "https://docs.farming-labs.dev",
1920
- * }
1921
- * ```
1922
- */
1923
- docsUrl?: string;
1924
- /**
1925
- * Loading indicator variant shown while the AI generates a response.
1926
- *
1927
- * - `"shimmer-dots"` — shimmer text + typing dots (default)
1928
- * - `"circular"` — spinning ring
1929
- * - `"dots"` — bouncing dots
1930
- * - `"typing"` — typing dots
1931
- * - `"wave"` — wave bars
1932
- * - `"bars"` — thick wave bars
1933
- * - `"pulse"` — pulsing ring
1934
- * - `"pulse-dot"` — pulsing dot
1935
- * - `"terminal"` — blinking terminal cursor
1936
- * - `"text-blink"` — blinking text
1937
- * - `"text-shimmer"` — shimmer text only
1938
- * - `"loading-dots"` — "Thinking..." with animated dots
1939
- *
1940
- * @default "shimmer-dots"
1941
- *
1942
- * @example
1943
- * ```ts
1944
- * ai: {
1945
- * enabled: true,
1946
- * loader: "wave",
1947
- * }
1948
- * ```
1949
- */
1950
- loader?: "shimmer-dots" | "circular" | "dots" | "typing" | "wave" | "bars" | "pulse" | "pulse-dot" | "terminal" | "text-blink" | "text-shimmer" | "loading-dots";
1951
- /**
1952
- * Custom loading indicator that overrides the built-in `loader` variant.
1953
- * Receives `{ name }` (the `aiLabel` value) and returns a React element.
1954
- *
1955
- * Only works in Next.js. For other frameworks, use the `loader` option.
1956
- *
1957
- * @example
1958
- * ```tsx
1959
- * ai: {
1960
- * enabled: true,
1961
- * aiLabel: "Sage",
1962
- * loadingComponent: ({ name }) => (
1963
- * <div className="flex items-center gap-2 text-sm text-zinc-400">
1964
- * <span className="animate-pulse">🤔</span>
1965
- * <span>{name} is thinking...</span>
1966
- * </div>
1967
- * ),
1968
- * }
1969
- * ```
1970
- */
1971
- loadingComponent?: (props: {
1972
- name: string;
1973
- }) => unknown;
1974
- /**
1975
- * Copy, like, and dislike action row for generated Ask AI answers.
1976
- *
1977
- * Set to `false` to hide the row. Pass an object to customize rating labels
1978
- * and receive legacy like/dislike callback payloads.
1979
- *
1980
- * @default true
1981
- *
1982
- * @example
1983
- * ```ts
1984
- * ai: {
1985
- * enabled: true,
1986
- * feedback: {
1987
- * onFeedback(data) {
1988
- * console.log(data.value, data.question, data.answer);
1989
- * },
1990
- * },
1991
- * }
1992
- * ```
1993
- */
1994
- feedback?: boolean | DocsAskAIFeedbackConfig;
1995
- /**
1996
- * Called when a user clicks an Ask AI response action.
1997
- *
1998
- * `data.type` is `"copy"`, `"like"`, or `"dislike"`.
1999
- *
2000
- * @example
2001
- * ```ts
2002
- * ai: {
2003
- * enabled: true,
2004
- * onActions(data) {
2005
- * if (data.type === "copy") console.log("Copied", data.answer);
2006
- * if (data.type === "like") console.log("Helpful", data.question);
2007
- * if (data.type === "dislike") console.log("Not helpful", data.question);
2008
- * },
2009
- * }
2010
- * ```
2011
- */
2012
- onActions?: (data: DocsAskAIActionData) => void | Promise<void>;
2013
- }
2014
- /**
2015
- * A single item in the slug-based sidebar ordering.
2016
- *
2017
- * @example
2018
- * ```ts
2019
- * ordering: [
2020
- * { slug: "installation" },
2021
- * { slug: "cli" },
2022
- * { slug: "themes", children: [
2023
- * { slug: "default" },
2024
- * { slug: "darksharp" },
2025
- * { slug: "pixel-border" },
2026
- * { slug: "creating-themes" },
2027
- * ]},
2028
- * { slug: "reference" },
2029
- * ]
2030
- * ```
2031
- */
2032
- interface OrderingItem {
2033
- /** Folder name (not the full path, just the directory name at this level) */
2034
- slug: string;
2035
- /** Ordering for child pages within this folder */
2036
- children?: OrderingItem[];
2037
- }
2038
- /**
2039
- * Data passed to the `onCopyClick` callback when the user clicks the copy button
2040
- * on a code block in the docs.
2041
- */
2042
- interface CodeBlockCopyData {
2043
- /** Title of the code block (e.g. from the fenced code block meta string), if present */
2044
- title?: string;
2045
- /** Raw code content (the text that was copied to the clipboard) */
2046
- content: string;
2047
- /** Current page URL at the time of copy */
2048
- url: string;
2049
- /** Language / syntax hint (e.g. "tsx", "bash"), if present */
2050
- language?: string;
2051
- }
2052
- /** Feedback value emitted by the built-in docs page feedback buttons. */
2053
- type DocsFeedbackValue = "positive" | "negative";
2054
- /**
2055
- * Data passed to the `feedback.onFeedback` callback when the user submits
2056
- * page feedback from the built-in docs feedback UI.
2057
- */
2058
- interface DocsFeedbackData {
2059
- /** Whether the user gave positive or negative feedback. */
2060
- value: DocsFeedbackValue;
2061
- /** Optional free-form feedback left by the reader. */
2062
- comment?: string;
2063
- /** Current page title, when available. */
2064
- title?: string;
2065
- /** Current page description, when available. */
2066
- description?: string;
2067
- /** Full current page URL at the time of feedback. */
2068
- url: string;
2069
- /** Current URL pathname (without origin). */
2070
- pathname: string;
2071
- /** Alias of `pathname` for analytics tools that prefer `path`. */
2072
- path: string;
2073
- /** Docs entry root, e.g. `"docs"`. */
2074
- entry: string;
2075
- /** Page slug relative to the docs entry, e.g. `"installation"` or `"guides/setup"`. */
2076
- slug: string;
2077
- /** Active locale, when docs i18n is enabled. */
2078
- locale?: string;
2079
- }
2080
- /**
2081
- * Page and transport context supplied alongside agent feedback payloads.
2082
- *
2083
- * The `payload` itself is customizable through `feedback.agent.schema`; this
2084
- * context object keeps a small stable envelope for route-aware metadata.
2085
- */
2086
- interface DocsAgentFeedbackContext {
2087
- /** Docs page path, e.g. `"/docs/installation"`. */
2088
- page?: string;
2089
- /** Full docs URL, when the caller has one available. */
2090
- url?: string;
2091
- /** Docs slug relative to the entry root, e.g. `"installation"`. */
2092
- slug?: string;
2093
- /** Active locale when docs i18n is enabled. */
2094
- locale?: string;
2095
- /** Arbitrary source label such as `"md-route"`, `"mcp"`, or `"api"`. */
2096
- source?: string;
2097
- }
2098
- /**
2099
- * Data passed to `feedback.agent.onFeedback`.
2100
- *
2101
- * The request body always follows the stable `{ context?, payload }` envelope
2102
- * while `payload` stays schema-driven so projects can add or remove agent
2103
- * fields without changing the callback contract.
2104
- */
2105
- interface DocsAgentFeedbackData {
2106
- /** Optional docs/page context associated with the agent feedback. */
2107
- context?: DocsAgentFeedbackContext;
2108
- /** Arbitrary payload validated by the configured agent feedback schema. */
2109
- payload: Record<string, unknown>;
2110
- }
2111
- /**
2112
- * Agent feedback endpoint configuration served through the shared `/api/docs`
2113
- * route wrapper.
2114
- */
2115
- interface AgentFeedbackConfig {
2116
- /** Enable the agent feedback endpoints. Defaults to `true`; set to `false` to opt out. */
2117
- enabled?: boolean;
2118
- /**
2119
- * Public HTTP route for posting agent feedback.
2120
- * @default "/api/docs/agent/feedback"
2121
- */
2122
- route?: string;
2123
- /**
2124
- * Public HTTP route for the machine-readable schema describing the agent
2125
- * feedback payload.
2126
- *
2127
- * Defaults to `${route}/schema`.
2128
- */
2129
- schemaRoute?: string;
2130
- /**
2131
- * JSON Schema object describing the `payload` field of the request body.
2132
- *
2133
- * The shared docs API wraps this under a stable top-level envelope:
2134
- * `{ context?: DocsAgentFeedbackContext, payload: <schema> }`.
2135
- */
2136
- schema?: Record<string, unknown>;
2137
- /**
2138
- * Async callback fired when the agent feedback endpoint receives a valid
2139
- * `{ context?, payload }` body.
2140
- */
2141
- onFeedback?: (data: DocsAgentFeedbackData) => void | Promise<void>;
2142
- }
2143
- /**
2144
- * Built-in page feedback configuration.
2145
- *
2146
- * When enabled, docs pages render a small feedback prompt at the end of the
2147
- * content. Clicking a button emits a callback/event with the current page
2148
- * metadata and the selected sentiment.
2149
- */
2150
- interface FeedbackConfig {
2151
- /** Show the feedback UI. Defaults to `true` when this object is provided. */
2152
- enabled?: boolean;
2153
- /** Prompt shown above the feedback buttons. @default "How is this guide?" */
2154
- question?: string;
2155
- /** Placeholder shown in the optional free-form feedback field. @default "Share what could be clearer..." */
2156
- placeholder?: string;
2157
- /** Require a non-empty comment before feedback can be submitted. @default false */
2158
- requireComment?: boolean;
2159
- /** Label for the positive button. @default "Good" */
2160
- positiveLabel?: string;
2161
- /** Label for the negative button. @default "Bad" */
2162
- negativeLabel?: string;
2163
- /** Label for the submit button. @default "Submit" */
2164
- submitLabel?: string;
2165
- /** Message shown after feedback is submitted successfully. @default "Thanks for the feedback." */
2166
- successMessage?: string;
2167
- /** Message shown when feedback submission fails. @default "Could not send feedback. Please try again." */
2168
- errorMessage?: string;
2169
- /**
2170
- * Callback fired when the user submits the feedback form.
2171
- *
2172
- * For client-only frameworks this runs directly in the browser. In
2173
- * environments where the config cannot be serialized to the client, the same
2174
- * payload is also emitted through `window.__fdOnFeedback__` and the
2175
- * `fd:feedback` custom event.
2176
- */
2177
- onFeedback?: (data: DocsFeedbackData) => void | Promise<void>;
2178
- /**
2179
- * Machine-oriented feedback endpoints exposed through the shared `/api/docs`
2180
- * route. The shared docs API exposes the default no-op schema/submit routes
2181
- * unless this is set to `false`.
2182
- *
2183
- * This does not enable the human page feedback UI by itself. To show the
2184
- * built-in footer prompt, keep using `feedback: true` or `feedback.enabled`.
2185
- */
2186
- agent?: boolean | AgentFeedbackConfig;
2187
- }
2188
- interface DocsI18nConfig {
2189
- /** Supported locale identifiers (e.g. ["en", "fr"]). */
2190
- locales: string[];
2191
- /** Default locale when `?lang=` is missing or invalid. Defaults to first locale. */
2192
- defaultLocale?: string;
2193
- }
2194
- interface ChangelogFrontmatter {
2195
- /** Entry title shown in the changelog feed and detail page. */
2196
- title?: string;
2197
- /** Short summary shown in the feed and page metadata. */
2198
- description?: string;
2199
- /** Optional cover image path or URL for future custom changelog layouts. */
2200
- image?: string;
2201
- /** Optional author name(s) displayed in entry meta. */
2202
- authors?: string | string[];
2203
- /** Optional version badge (for example `v0.1.0`). */
2204
- version?: string;
2205
- /** Optional tags shown as compact badges. */
2206
- tags?: string[];
2207
- /** Keep important entries pinned to the top of the listing. */
2208
- pinned?: boolean;
2209
- /** Hide the entry from generated routes and search indexes. */
2210
- draft?: boolean;
2211
- }
2212
- interface ChangelogConfig {
2213
- /**
2214
- * Whether to enable generated changelog pages.
2215
- * @default false
2216
- */
2217
- enabled?: boolean;
2218
- /**
2219
- * URL path where the changelog listing lives inside the docs layout.
2220
- * Example: `"changelogs"` → `/docs/changelogs` when `entry` is `"docs"`
2221
- * @default "changelog"
2222
- */
2223
- path?: string;
2224
- /**
2225
- * Changelog source directory inside the docs content root.
2226
- *
2227
- * With the default docs content tree, this becomes:
2228
- * `app/docs/changelog/2026-03-04/page.mdx`
2229
- *
2230
- * Relative values are resolved from the docs content root. Absolute values
2231
- * are used as-is.
2232
- *
2233
- * @default "changelog"
2234
- */
2235
- contentDir?: string;
2236
- /**
2237
- * Listing page title.
2238
- * @default "Changelog"
2239
- */
2240
- title?: string;
2241
- /**
2242
- * Listing page description shown in the changelog header and metadata.
2243
- */
2244
- description?: string;
2245
- /**
2246
- * Show the built-in changelog search field.
2247
- * @default true
2248
- */
2249
- search?: boolean;
2250
- /**
2251
- * Custom React element rendered in the changelog rail.
2252
- *
2253
- * This stays `unknown` in the framework-agnostic core so adapters can accept
2254
- * JSX without adding a React dependency here.
2255
- */
2256
- actionsComponent?: unknown;
2257
- }
2258
- type ApiReferenceRenderer = "fumadocs" | "scalar";
2259
- interface ApiReferenceConfig {
2260
- /**
2261
- * Whether to enable generated API reference pages.
2262
- * Supported adapters can generate references from framework route handlers
2263
- * or a hosted OpenAPI JSON document.
2264
- * @default false
2265
- */
2266
- enabled?: boolean;
2267
- /**
2268
- * URL path where the generated API reference lives.
2269
- * Example: `"api-reference"` → `/api-reference`
2270
- * @default "api-reference"
2271
- */
2272
- path?: string;
2273
- /**
2274
- * URL to a remote OpenAPI JSON document.
2275
- *
2276
- * When provided, the API reference is generated from this hosted spec instead
2277
- * of scanning local framework route files.
2278
- *
2279
- * Supports:
2280
- * - absolute URLs like `https://example.com/openapi.json`
2281
- * - request-relative URLs like `/api/openapi.json` in Next.js
2282
- *
2283
- * @example
2284
- * ```ts
2285
- * apiReference: {
2286
- * enabled: true,
2287
- * specUrl: "https://petstore3.swagger.io/api/v3/openapi.json",
2288
- * }
2289
- * ```
2290
- */
2291
- specUrl?: string;
2292
- /**
2293
- * Which renderer to use for the API reference UI.
2294
- *
2295
- * - `"fumadocs"` uses the Fumadocs OpenAPI renderer bundled by `@farming-labs/next`
2296
- * - `"scalar"` uses the Scalar renderer bundled by `@farming-labs/docs` and the adapters
2297
- *
2298
- * Defaults are framework-aware:
2299
- * - Next.js: `"fumadocs"`
2300
- * - TanStack Start / SvelteKit / Astro / Nuxt: `"scalar"`
2301
- */
2302
- renderer?: ApiReferenceRenderer;
2303
- /**
2304
- * Filesystem route root to scan for API handlers.
2305
- *
2306
- * For Next.js this defaults to the App Router convention:
2307
- * `app/api` or `src/app/api`.
2308
- *
2309
- * You can override it with a project-relative path like `"app/v1"` or
2310
- * `"src/app/internal-api"`. If you pass a bare segment like `"api"` or
2311
- * `"v1"`, it will be resolved inside the detected app directory.
2312
- */
2313
- routeRoot?: string;
2314
- /**
2315
- * Route entries to exclude from the generated API reference.
2316
- *
2317
- * Accepts either URL-style paths like `"/api/hello"` or route-root-relative
2318
- * entries like `"hello"` / `"hello/route.ts"`.
2319
- */
2320
- exclude?: string[];
2321
- }
2322
- interface DocsAgentCompactConfig {
2323
- /**
2324
- * Direct API key for the Docs Cloud compression API. Prefer `cloud.apiKey.env`
2325
- * so all Docs Cloud CLI commands share the same root API key configuration.
2326
- *
2327
- * @deprecated Configure `cloud.apiKey.env` instead.
2328
- */
2329
- apiKey?: string;
2330
- /**
2331
- * Environment variable name that stores the Docs Cloud API key. Prefer
2332
- * `cloud.apiKey.env` so all Docs Cloud CLI commands share the same root API
2333
- * key configuration.
2334
- *
2335
- * @deprecated Configure `cloud.apiKey.env` instead.
2336
- */
2337
- apiKeyEnv?: string;
2338
- /**
2339
- * Base URL for the compression API.
2340
- */
2341
- baseUrl?: string;
2342
- /**
2343
- * Compression model name.
2344
- * @default "docs-cloud-compress-v1"
2345
- */
2346
- model?: string;
2347
- /**
2348
- * Compression aggressiveness passed to the API.
2349
- * Must be between `0` and `1`.
2350
- * @default 0.3
2351
- */
2352
- aggressiveness?: number;
2353
- /**
2354
- * Upper token target for compressed output.
2355
- */
2356
- maxOutputTokens?: number;
2357
- /**
2358
- * Lower token target for compressed output.
2359
- */
2360
- minOutputTokens?: number;
2361
- /**
2362
- * Preserve JSON objects during compression when supported by the provider.
2363
- */
2364
- protectJson?: boolean;
2365
- }
2366
- interface DocsAgentGoldenTaskFilters {
2367
- /** Limit retrieval to a framework such as `nextjs`, `astro`, or `nuxt`. */
2368
- framework?: string;
2369
- /** Limit retrieval to an exact documented version. */
2370
- version?: string;
2371
- /** Limit retrieval to a locale. */
2372
- locale?: string;
2373
- }
2374
- interface DocsAgentGoldenTaskExpectation {
2375
- /** Canonical page or section URLs that should answer this task. */
2376
- relevantSources: string[];
2377
- /** Additional sources that may be cited without reducing precision. */
2378
- allowedSources?: string[];
2379
- /** Sources that must not be selected, for example an obsolete version. */
2380
- forbiddenSources?: string[];
2381
- /** Citations that must appear. Defaults to `relevantSources`. */
2382
- requiredCitations?: string[];
2383
- /** Minimum relevant-source recall in the top K results. Defaults to `1`. */
2384
- minRecallAtK?: number;
2385
- /** Maximum acceptable rank for the first relevant source. Defaults to `topK`. */
2386
- maxFirstRelevantRank?: number;
2387
- /** Runnable examples that must be found in retrieved context. */
2388
- examples?: DocsAgentGoldenExpectedExample[];
2389
- /** Minimum share of context bytes that must come from relevant sources. */
2390
- minUsefulByteRatio?: number;
2391
- /**
2392
- * Scope that the returned sources must actually select. Unlike `filters`, this is an
2393
- * assertion and does not constrain retrieval, so it can detect a wrong framework,
2394
- * version, or locale result.
2395
- */
2396
- scope?: DocsAgentGoldenTaskFilters;
2397
- /** Assertions evaluated against an explicitly configured answer runner. */
2398
- answer?: DocsAgentGoldenAnswerExpectation;
2399
- }
2400
- interface DocsAgentGoldenAnswerExpectation {
2401
- /** Literal fragments that must occur in the generated answer. */
2402
- includes?: string[];
2403
- /** Literal fragments that must not occur in the generated answer. */
2404
- excludes?: string[];
2405
- /** Citations that the generated answer must contain. */
2406
- requiredCitations?: string[];
2407
- /** Additional answer citations that are valid but not required. */
2408
- allowedCitations?: string[];
2409
- /** Citations that the generated answer must not contain. */
2410
- forbiddenCitations?: string[];
2411
- }
2412
- type DocsAgentGoldenExampleVerification = "present" | "syntax" | "execute";
2413
- interface DocsAgentGoldenExpectedExample {
2414
- /** Canonical page or section URL containing the example. */
2415
- source?: string;
2416
- language?: string;
2417
- framework?: string;
2418
- packageManager?: string;
2419
- title?: string;
2420
- /** Defaults to true. Set false for an intentionally non-runnable example. */
2421
- runnable?: boolean;
2422
- /** Literal fragments that must occur in the example. */
2423
- includes?: string[];
2424
- /**
2425
- * Verification strength. Runnable examples default to `syntax`; explicitly
2426
- * non-runnable examples default to `present`. Runtime execution is always opt-in.
2427
- */
2428
- verification?: DocsAgentGoldenExampleVerification;
2429
- }
2430
- type DocsAgentEvaluationSurface = "mcp-context" | "configured-search" | "ask-ai-context";
2431
- interface DocsAgentGoldenTask {
2432
- /** Stable identifier shown in doctor/review reports. */
2433
- id: string;
2434
- /** User-shaped retrieval query. */
2435
- query: string;
2436
- /** Optional retrieval scope. */
2437
- filters?: DocsAgentGoldenTaskFilters;
2438
- /** Conservative context budget. Uses the MCP context UTF-8 accounting strategy. */
2439
- tokenBudget?: number;
2440
- /** Number of ranked search results to evaluate. */
2441
- topK?: number;
2442
- /** Override the evaluation surface configured for the task suite. */
2443
- surface?: DocsAgentEvaluationSurface;
2444
- /** Evaluator-only expectations used to score the task. */
2445
- expect: DocsAgentGoldenTaskExpectation;
2446
- }
2447
- interface DocsAgentEvaluationSourceReference {
2448
- url: string;
2449
- title?: string;
2450
- framework?: string;
2451
- version?: string;
2452
- locale?: string;
2453
- }
2454
- /** Blind task input sent to answer providers. Golden expectations stay evaluator-only. */
2455
- interface DocsAgentEvaluationTaskInput {
2456
- id: string;
2457
- query: string;
2458
- filters?: DocsAgentGoldenTaskFilters;
2459
- }
2460
- /** Serializable, expectation-blind request sent to every configured answer provider. */
2461
- interface DocsAgentEvaluationAnswerRequest {
2462
- task: DocsAgentEvaluationTaskInput;
2463
- surface: DocsAgentEvaluationSurface;
2464
- context: string;
2465
- sources: readonly DocsAgentEvaluationSourceReference[];
2466
- }
2467
- /** Callback answer input. The abort signal is not serialized for HTTP providers. */
2468
- interface DocsAgentEvaluationAnswerInput extends DocsAgentEvaluationAnswerRequest {
2469
- /** Aborted when the configured answer timeout elapses. */
2470
- signal: AbortSignal;
2471
- }
2472
- interface DocsAgentEvaluationAnswerResult {
2473
- text: string;
2474
- /** Canonical URLs cited by the answer. Markdown links are also extracted from `text`. */
2475
- citations?: string[];
2476
- }
2477
- type DocsAgentEvaluationAnswerRunner = (input: DocsAgentEvaluationAnswerInput) => DocsAgentEvaluationAnswerResult | Promise<DocsAgentEvaluationAnswerResult>;
2478
- type DocsAgentEvaluationAnswerProvider = {
2479
- provider: "callback";
2480
- run: DocsAgentEvaluationAnswerRunner; /** Abort the callback after this many milliseconds. @default 30000 */
2481
- timeoutMs?: number;
2482
- } | {
2483
- provider: "http"; /** Endpoint that accepts `DocsAgentEvaluationAnswerRequest` JSON and returns an answer result. */
2484
- endpoint: string; /** Optional request headers. Values are never included in evaluation reports. */
2485
- headers?: Record<string, string>; /** Abort the request after this many milliseconds. @default 30000 */
2486
- timeoutMs?: number;
2487
- };
2488
- interface DocsAgentEvaluationsConfig {
2489
- /** Enable golden-task evaluation. */
2490
- enabled?: boolean;
2491
- /** Default conservative context budget for tasks that omit `tokenBudget`. */
2492
- tokenBudget?: number;
2493
- /** Default retrieval depth for tasks that omit `topK`. */
2494
- topK?: number;
2495
- /** Retrieval/context surface measured by the task suite. @default "mcp-context" */
2496
- surface?: DocsAgentEvaluationSurface;
2497
- /**
2498
- * Permit configured external search, HTTP answers, and explicit executable-example
2499
- * verification. Disabled by default so doctor/review remain offline unless explicitly opted in.
2500
- */
2501
- allowNetwork?: boolean;
2502
- /** Timeout for configured retrieval during each task. @default 30000 */
2503
- searchTimeoutMs?: number;
2504
- /** Optional callback or HTTP runner used to measure actual generated answers. */
2505
- answer?: DocsAgentEvaluationAnswerProvider;
2506
- /** Golden tasks evaluated by `docs doctor` and `docs review`. */
2507
- tasks?: DocsAgentGoldenTask[];
2508
- }
2509
- interface DocsAgentConfig {
2510
- /**
2511
- * Defaults for `docs agent compact`.
2512
- */
2513
- compact?: DocsAgentCompactConfig;
2514
- /**
2515
- * Offline-by-default retrieval, citation, version, example, and token-budget evaluations.
2516
- * External providers and runtime execution require explicit opt-in.
2517
- */
2518
- evaluations?: boolean | DocsAgentEvaluationsConfig;
2519
- }
2520
- type DocsReviewSeverity = "off" | "suggestion" | "warn" | "error";
2521
- type DocsReviewCiMode = "off" | "warn" | "block";
2522
- interface DocsReviewRulesConfig {
2523
- /** Check internal markdown/docs links. */
2524
- brokenLinks?: DocsReviewSeverity;
2525
- /** Check required page frontmatter such as title and description. */
2526
- frontmatter?: DocsReviewSeverity;
2527
- /** Check duplicate docs slugs in the resolved docs tree. */
2528
- duplicateSlugs?: DocsReviewSeverity;
2529
- /** Check whether changed markdown/MDX files can be parsed. */
2530
- invalidMdx?: DocsReviewSeverity;
2531
- /** Check docs.config examples against known config options when possible. */
2532
- configExamples?: DocsReviewSeverity;
2533
- /** Check code fences for useful metadata such as title and framework. */
2534
- codeFenceMetadata?: DocsReviewSeverity;
2535
- /** Check runnable command/code fences for package manager context. */
2536
- runnableMetadata?: DocsReviewSeverity;
2537
- /** Validate structured page agent contracts and suggest context for implementation-heavy pages. */
2538
- agentContext?: DocsReviewSeverity;
2539
- /** Statically validate commands referenced by agent contracts and runnable examples. */
2540
- commandHealth?: DocsReviewSeverity;
2541
- /** Require useful related-page coverage on actionable docs pages. */
2542
- relatedCoverage?: DocsReviewSeverity;
2543
- /** Report when docs.config could not be evaluated and only partial static parsing is available. */
2544
- configConfidence?: DocsReviewSeverity;
2545
- /** Detect disagreement between discovery, resolved config, and the public config schema. */
2546
- agentSurfaceDrift?: DocsReviewSeverity;
2547
- /** Run configured agent golden tasks and report failed or unmeasured behavior. */
2548
- goldenTasks?: DocsReviewSeverity;
2549
- }
2550
- interface DocsReviewScoreConfig {
2551
- /**
2552
- * Minimum healthy score.
2553
- * CI reports the threshold in warn mode and blocks below it only when `ci.mode` is `"block"`.
2554
- *
2555
- * @default 80
2556
- */
2557
- threshold?: number;
2558
- /**
2559
- * Point deductions by finding severity.
2560
- *
2561
- * @default { error: 20, warn: 8, suggestion: 2 }
2562
- */
2563
- weights?: Partial<Record<"error" | "warn" | "suggestion", number>>;
2564
- }
2565
- interface DocsReviewCiConfig {
2566
- /**
2567
- * Enable Docs Review CI workflow generation.
2568
- *
2569
- * @default true
2570
- */
2571
- enabled?: boolean;
2572
- /**
2573
- * GitHub Actions job/check name for the generated workflow.
2574
- *
2575
- * @default "docs-review"
2576
- */
2577
- name?: string;
2578
- /**
2579
- * How CI should treat unhealthy review results.
2580
- *
2581
- * - `"off"`: do not create/report CI output
2582
- * - `"warn"`: report annotations but pass CI
2583
- * - `"block"`: fail CI when errors exist or the score is below threshold
2584
- *
2585
- * @default "warn"
2586
- */
2587
- mode?: DocsReviewCiMode;
2588
- /**
2589
- * Emit GitHub workflow command annotations in CI.
2590
- *
2591
- * @default true
2592
- */
2593
- annotations?: boolean;
2594
- /**
2595
- * Reserved for GitHub PR comments from the official action/bot.
2596
- *
2597
- * @default true
2598
- */
2599
- comment?: boolean;
2600
- }
2601
- interface DocsReviewConfig {
2602
- /**
2603
- * Enable Docs Review.
2604
- *
2605
- * Omitted review config is treated as enabled so docs sites get PR review CI by default.
2606
- * Set `review: false` to opt out.
2607
- *
2608
- * @default true
2609
- */
2610
- enabled?: boolean;
2611
- /** Score threshold and severity weights. */
2612
- score?: DocsReviewScoreConfig;
2613
- /** GitHub Actions behavior. */
2614
- ci?: boolean | DocsReviewCiConfig;
2615
- /** Optional rule severity overrides. */
2616
- rules?: DocsReviewRulesConfig;
2617
- }
2618
- type DocsCodeBlocksPlannerProvider = "metadata" | "openai" | "openai-compatible" | "cloud";
2619
- type DocsCodeBlocksRunnerProvider = "local" | "vercel-sandbox" | "e2b" | "daytona" | "cloud";
2620
- type DocsCodeBlocksValidationMode = "plan" | "report";
2621
- type DocsCodeBlocksValidationPolicy = "skip" | "warn" | "error";
2622
- interface DocsCodeBlocksPlannerConfig {
2623
- /**
2624
- * Planner used to turn code fence metadata into an execution plan.
2625
- *
2626
- * - `"metadata"` reads the fence language and metadata locally.
2627
- * - `"openai"` calls OpenAI's chat completions API.
2628
- * - `"openai-compatible"` calls an OpenAI-compatible chat completions endpoint.
2629
- * - `"cloud"` is reserved for the hosted Farming Labs planner.
2630
- *
2631
- * @default "metadata"
2632
- */
2633
- provider?: DocsCodeBlocksPlannerProvider;
2634
- /** Model name for LLM-backed planners. */
2635
- model?: string;
2636
- /** OpenAI-compatible base URL. Defaults to `https://api.openai.com/v1` for `provider: "openai"`. */
2637
- baseUrl?: string;
2638
- /** Environment variable containing the OpenAI-compatible base URL. */
2639
- baseUrlEnv?: string;
2640
- /** API key value. Prefer `apiKeyEnv` so secrets stay out of docs.config. */
2641
- apiKey?: string;
2642
- /** Environment variable containing the planner API key. */
2643
- apiKeyEnv?: string;
2644
- }
2645
- interface DocsCodeBlocksRunnerConfig {
2646
- /**
2647
- * Runner used to execute planned code blocks.
2648
- *
2649
- * @default "local"
2650
- */
2651
- provider?: DocsCodeBlocksRunnerProvider;
2652
- /** Environment variable containing the sandbox provider token. */
2653
- tokenEnv?: string;
2654
- /** Advanced override for the Vercel project id env var used by `provider: "vercel-sandbox"`. */
2655
- projectIdEnv?: string;
2656
- /** Advanced override for the Vercel team/org id env var used by `provider: "vercel-sandbox"`. */
2657
- teamIdEnv?: string;
2658
- /**
2659
- * Path to a Vercel project metadata file. When enabled, the runner reads
2660
- * `projectId` and `orgId` from `.vercel/project.json`. If those are not
2661
- * available, the runner can auto-discover an accessible project from
2662
- * `VERCEL_TOKEN`.
2663
- *
2664
- * @default ".vercel/project.json"
2665
- */
2666
- projectJson?: string | false;
2667
- /** Vercel Sandbox runtime. */
2668
- runtime?: "node24" | "node22" | "python3.13";
2669
- /** Daytona API URL env var used by `provider: "daytona"`. */
2670
- apiUrlEnv?: string;
2671
- /** Daytona target/region env var used by `provider: "daytona"`. */
2672
- targetEnv?: string;
2673
- /** Per-command timeout in milliseconds. */
2674
- timeoutMs?: number;
2675
- }
2676
- interface DocsCodeBlocksValidateConfig {
2677
- /**
2678
- * Enable code block validation.
2679
- *
2680
- * @default true when `codeBlocks.validate` is an object or `true`
2681
- */
2682
- enabled?: boolean;
2683
- /** Planner config. Use `"metadata"` for local deterministic planning. */
2684
- planner?: DocsCodeBlocksPlannerProvider | DocsCodeBlocksPlannerConfig;
2685
- /** Runner config. Use `"vercel-sandbox"` for isolated runtime checks. */
2686
- runner?: DocsCodeBlocksRunnerProvider | DocsCodeBlocksRunnerConfig;
2687
- /**
2688
- * Env files loaded for validation. These are read locally and never committed.
2689
- *
2690
- * @default [".env.local", ".env.test", ".env"]
2691
- */
2692
- envFile?: string | string[];
2693
- /**
2694
- * Runtime env mapping.
2695
- *
2696
- * The key is the env var used by the docs code block. The value is the local
2697
- * env var to read from. For example, `{ OPENAI_API_KEY: "OPENAI_TEST_API_KEY" }`
2698
- * injects `OPENAI_API_KEY` into the runner from `OPENAI_TEST_API_KEY`.
2699
- */
2700
- env?: Record<string, string>;
2701
- /**
2702
- * Behavior when a runnable block declares an env var that cannot be resolved.
2703
- *
2704
- * @default "skip"
2705
- */
2706
- missingEnv?: DocsCodeBlocksValidationPolicy;
2707
- /**
2708
- * Behavior when a language cannot be executed by the selected runner.
2709
- *
2710
- * @default "skip"
2711
- */
2712
- unsupportedLanguage?: DocsCodeBlocksValidationPolicy;
2713
- /**
2714
- * Default command mode.
2715
- *
2716
- * - `"plan"` builds execution plans without running them.
2717
- * - `"report"` runs executable plans and reports pass/skip/fail.
2718
- *
2719
- * @default "report"
2720
- */
2721
- mode?: DocsCodeBlocksValidationMode;
2722
- }
2723
- interface DocsCodeBlocksConfig {
2724
- /**
2725
- * Validate fenced code blocks from MD/MDX docs.
2726
- *
2727
- * @example
2728
- * ```ts
2729
- * codeBlocks: {
2730
- * validate: {
2731
- * planner: {
2732
- * provider: "openai",
2733
- * model: "gpt-4.1-mini",
2734
- * apiKeyEnv: "OPENAI_API_KEY",
2735
- * },
2736
- * runner: {
2737
- * provider: "vercel-sandbox",
2738
- * tokenEnv: "VERCEL_TOKEN",
2739
- * },
2740
- * env: {
2741
- * OPENAI_API_KEY: "OPENAI_TEST_API_KEY",
2742
- * },
2743
- * },
2744
- * }
2745
- * ```
2746
- */
2747
- validate?: boolean | DocsCodeBlocksValidateConfig;
2748
- }
2749
- interface DocsConfig {
2750
- /** Entry folder for docs (e.g. "docs" → /docs) */
2751
- entry: string;
2752
- /**
2753
- * Public route prefix for docs pages. Defaults to the `entry` path.
2754
- * Set to "" or "/" to serve docs from the site root while keeping the
2755
- * source files and generated app route under `entry`.
2756
- */
2757
- docsPath?: string;
2758
- /** Path to the content directory. Defaults to `entry` value. */
2759
- contentDir?: string;
2760
- /**
2761
- * Internationalization (i18n) configuration.
2762
- * When set, docs content is expected under `${contentDir}/{locale}` and
2763
- * the active locale is selected by `?lang=<locale>` in the URL.
2764
- */
2765
- i18n?: DocsI18nConfig;
2766
- /**
2767
- * Set to `true` when building for full static export (e.g. Cloudflare Pages).
2768
- * When using `output: 'export'` in Next.js, the `/api/docs` route is not generated.
2769
- * Set `ai.enabled: false` and optionally rely on client-side search or leave search disabled.
2770
- */
2771
- staticExport?: boolean;
2772
- /** Theme configuration - single source of truth for UI */
2773
- theme?: DocsTheme;
2774
- /**
2775
- * Built-in analytics event stream for docs interactions.
2776
- *
2777
- * - `false` -> analytics disabled
2778
- * - omitted -> analytics disabled unless Docs Cloud provides project identity
2779
- * - `true` -> log product/usage events to the console
2780
- * - `{ onEvent(event) { ... } }` -> send events to your analytics sink
2781
- *
2782
- * Raw queries, AI questions, feedback comments, and copied content are not
2783
- * included unless `includeInputs: true` is set.
2784
- */
2785
- analytics?: boolean | DocsAnalyticsConfig;
2786
- /**
2787
- * Farming Labs maintainer telemetry for production adoption and coarse
2788
- * agent-optimized feature usage.
2789
- *
2790
- * This is separate from project-owned `analytics`. It avoids visitor
2791
- * identities, page views, raw inputs, docs content, cookies, and per-user
2792
- * sessions. Disable with `telemetry: false`, `DOCS_TELEMETRY=false`, or
2793
- * `DOCS_TELEMETRY_DISABLED=1`.
2794
- */
2795
- telemetry?: boolean | DocsTelemetryConfig;
2796
- /**
2797
- * Docs Cloud integration settings.
2798
- *
2799
- * Use this to configure the API key env var and cloud deploy defaults once
2800
- * in `docs.config.ts`; cloud CLI commands mirror the serializable subset into
2801
- * `docs.json` automatically.
2802
- *
2803
- * @example
2804
- * ```ts
2805
- * cloud: {
2806
- * apiKey: { env: "DOCS_CLOUD_API_KEY" },
2807
- * deploy: { enabled: true },
2808
- * publish: { mode: "draft-pr", baseBranch: "main" },
2809
- * }
2810
- * ```
2811
- */
2812
- cloud?: DocsCloudConfig;
2813
- /**
2814
- * Built-in observability stream for agent traces, timing, errors, and runtime debugging.
2815
- * This is separate from `analytics`; it emits span-like Ask AI and MCP trace events.
2816
- *
2817
- * ```ts
2818
- * observability: {
2819
- * console: "debug",
2820
- * onEvent(event) {
2821
- * console.info(event.type, event.traceId, event.durationMs)
2822
- * },
2823
- * }
2824
- * ```
2825
- */
2826
- observability?: boolean | DocsObservabilityConfig;
2827
- /**
2828
- * GitHub repository URL or config. Enables "Edit on GitHub" links
2829
- * on each docs page footer, pointing to the source `.mdx` file.
2830
- *
2831
- * @example
2832
- * ```ts
2833
- * // Simple — branch defaults to "main"
2834
- * github: "https://github.com/Kinfe123/my-docs"
2835
- *
2836
- * // Monorepo — docs site lives in "website/" subdirectory
2837
- * github: {
2838
- * url: "https://github.com/farming-labs/docs",
2839
- * directory: "website",
2840
- * }
2841
- *
2842
- * // Custom branch
2843
- * github: {
2844
- * url: "https://github.com/Kinfe123/my-docs",
2845
- * branch: "develop",
2846
- * }
2847
- * ```
2848
- */
2849
- github?: string | GithubConfig;
2850
- /**
2851
- * Sidebar navigation header.
2852
- * Customise the title shown at the top of the sidebar.
2853
- */
2854
- nav?: DocsNav;
2855
- /**
2856
- * Theme toggle (light/dark mode switcher) in the sidebar.
2857
- *
2858
- * - `true` or `undefined` → toggle is shown (default)
2859
- * - `false` → toggle is hidden, defaults to system theme
2860
- * - `{ enabled: false, default: "dark" }` → toggle hidden, force dark
2861
- *
2862
- * @example
2863
- * ```ts
2864
- * // Hide toggle, force dark mode
2865
- * themeToggle: { enabled: false, default: "dark" }
2866
- *
2867
- * // Show toggle with system option
2868
- * themeToggle: { mode: "light-dark-system" }
2869
- * ```
2870
- */
2871
- themeToggle?: boolean | ThemeToggleConfig;
2872
- /**
2873
- * Breadcrumb navigation above page content.
2874
- *
2875
- * - `true` or `undefined` → breadcrumb is shown (default)
2876
- * - `false` → breadcrumb is hidden
2877
- * - `{ enabled: false }` → breadcrumb is hidden
2878
- * - `{ component: MyBreadcrumb }` → custom breadcrumb component
2879
- */
2880
- breadcrumb?: boolean | BreadcrumbConfig;
2881
- /**
2882
- * Sidebar customisation.
2883
- *
2884
- * - `true` or `undefined` → default sidebar
2885
- * - `false` → sidebar is hidden
2886
- * - `{ component: MySidebar }` → custom sidebar component
2887
- * - `{ footer: <MyFooter />, banner: <MyBanner /> }` → add footer/banner
2888
- */
2889
- sidebar?: boolean | SidebarConfig;
2890
- /**
2891
- * Custom MDX component overrides.
2892
- *
2893
- * Pass your own React components to replace defaults (e.g. Callout, CodeBlock).
2894
- * Components must match the expected props interface.
2895
- *
2896
- * @example
2897
- * ```ts
2898
- * import { MyCallout } from "./components/my-callout";
2899
- *
2900
- * export default defineDocs({
2901
- * entry: "docs",
2902
- * theme: fumadocs(),
2903
- * components: {
2904
- * Callout: MyCallout,
2905
- * },
2906
- * });
2907
- * ```
2908
- */
2909
- components?: Record<string, unknown>;
2910
- /**
2911
- * Callback fired when the user clicks the copy button on a code block.
2912
- * Called in addition to the default copy-to-clipboard behavior.
2913
- * Use it for analytics, logging, or custom behavior.
2914
- *
2915
- * @example
2916
- * ```ts
2917
- * export default defineDocs({
2918
- * entry: "docs",
2919
- * theme: fumadocs(),
2920
- * onCopyClick(data) {
2921
- * console.log("Code copied", data.title, data.language, data.url);
2922
- * analytics.track("code_block_copy", { title: data.title, url: data.url });
2923
- * },
2924
- * });
2925
- * ```
2926
- */
2927
- onCopyClick?: (data: CodeBlockCopyData) => void;
2928
- /**
2929
- * Code block intelligence for MD/MDX fences, including validation planning
2930
- * and optional sandboxed execution.
2931
- */
2932
- codeBlocks?: DocsCodeBlocksConfig;
2933
- /**
2934
- * Built-in page feedback prompt shown at the end of a docs page.
2935
- *
2936
- * - `false` or `undefined` → hidden (default)
2937
- * - `true` → shown with default labels
2938
- * - `{ enabled: true, onFeedback(data) { ... } }` → shown with callback
2939
- *
2940
- * @example
2941
- * ```ts
2942
- * import type { DocsFeedbackData } from "@farming-labs/docs";
2943
- *
2944
- * export default defineDocs({
2945
- * entry: "docs",
2946
- * feedback: {
2947
- * enabled: true,
2948
- * onFeedback(data: DocsFeedbackData) {
2949
- * console.log("Docs feedback", data.value, data.slug, data.url);
2950
- * },
2951
- * },
2952
- * });
2953
- * ```
2954
- */
2955
- feedback?: boolean | FeedbackConfig;
2956
- /**
2957
- * Built-in MCP server for agent/assistant access to your docs content.
2958
- *
2959
- * - omitted → enable the default MCP surface at `/mcp` and `/.well-known/mcp`, backed by `/api/docs/mcp`
2960
- * - `true` → enable the default MCP surface at `/mcp` and `/.well-known/mcp`, backed by `/api/docs/mcp`
2961
- * - `{ route: "/api/docs/mcp" }` → enable with explicit route/config
2962
- * - `false` or `{ enabled: false }` → disable MCP explicitly
2963
- */
2964
- mcp?: boolean | DocsMcpConfig;
2965
- /**
2966
- * Shared icon registry for sidebar items and built-in MDX components.
2967
- *
2968
- * Map string labels to React elements. Reference them in page frontmatter
2969
- * with `icon: "label"` and the matching icon renders in the sidebar.
2970
- * Built-in components such as `Prompt` can also reference these keys for
2971
- * their card and action icons.
2972
- *
2973
- * @example
2974
- * ```tsx
2975
- * import { Book, Terminal, Rocket } from "lucide-react";
2976
- *
2977
- * export default defineDocs({
2978
- * entry: "docs",
2979
- * theme: fumadocs(),
2980
- * icons: {
2981
- * book: <Book />,
2982
- * terminal: <Terminal />,
2983
- * rocket: <Rocket />,
2984
- * },
2985
- * });
2986
- * ```
2987
- *
2988
- * Then in `page.mdx` frontmatter:
2989
- * ```yaml
2990
- * ---
2991
- * title: "CLI Reference"
2992
- * icon: "terminal"
2993
- * ---
2994
- * ```
2995
- */
2996
- icons?: Record<string, unknown>;
2997
- /**
2998
- * Page action buttons shown above the content area.
2999
- * Includes "Copy Markdown" and "Open in …" (LLM dropdown).
3000
- *
3001
- * @example
3002
- * ```ts
3003
- * pageActions: {
3004
- * copyMarkdown: { enabled: true },
3005
- * openDocs: {
3006
- * enabled: true,
3007
- * target: "markdown",
3008
- * providers: [
3009
- * "chatgpt",
3010
- * "claude",
3011
- * "cursor",
3012
- * ],
3013
- * },
3014
- * }
3015
- * ```
3016
- */
3017
- pageActions?: PageActionsConfig;
3018
- /**
3019
- * Built-in docs search configuration.
3020
- *
3021
- * - `true` or omitted → use the built-in simple search
3022
- * - `{ provider: "typesense", ... }` → use Typesense
3023
- * - `{ provider: "algolia", ... }` → use Algolia
3024
- * - `{ provider: "custom", adapter }` → use a custom adapter
3025
- * - `false` → disable docs search
3026
- */
3027
- search?: boolean | DocsSearchConfig;
3028
- /**
3029
- * Configuration for the "Last updated" date display.
3030
- *
3031
- * - `true` or `undefined` → shown in footer next to "Edit on GitHub" (default)
3032
- * - `false` → hidden
3033
- * - `{ position: "below-title" }` → shown below the page title
3034
- * - `{ position: "footer" }` → shown next to "Edit on GitHub" (default)
3035
- *
3036
- * @example
3037
- * ```ts
3038
- * // Show below title (Mintlify style)
3039
- * lastUpdated: { position: "below-title" }
3040
- *
3041
- * // Hide entirely
3042
- * lastUpdated: false
3043
- * ```
3044
- */
3045
- lastUpdated?: boolean | LastUpdatedConfig;
3046
- /**
3047
- * Estimated reading time shown at the top of docs pages.
3048
- *
3049
- * - `undefined` → disabled by default
3050
- * - `true` or `{ enabled: true }` → show a computed "{n} min read" label
3051
- * - `false` → hide it entirely
3052
- *
3053
- * @example
3054
- * ```ts
3055
- * readingTime: { enabled: true, wordsPerMinute: 220 }
3056
- * ```
3057
- */
3058
- readingTime?: boolean | ReadingTimeConfig;
3059
- /**
3060
- * AI-powered "Ask AI" chat for documentation.
3061
- *
3062
- * When enabled, the unified API route handler (`/api/docs`) accepts
3063
- * POST requests for AI chat. The handler uses RAG (Retrieval-Augmented
3064
- * Generation) — it searches relevant docs, builds context, and streams
3065
- * a response from an LLM.
3066
- *
3067
- * The API key defaults to `process.env.OPENAI_API_KEY`. For other providers,
3068
- * pass the key via `apiKey: process.env.YOUR_KEY`.
3069
- *
3070
- * @example
3071
- * ```ts
3072
- * // Enable with defaults (gpt-4o-mini, OPENAI_API_KEY)
3073
- * ai: { enabled: true }
3074
- *
3075
- * // Custom model + system prompt
3076
- * ai: {
3077
- * enabled: true,
3078
- * model: "gpt-4o",
3079
- * systemPrompt: "You are an expert on our SDK. Be concise.",
3080
- * }
3081
- *
3082
- * // Use a different provider (e.g. Groq)
3083
- * ai: {
3084
- * enabled: true,
3085
- * baseUrl: "https://api.groq.com/openai/v1",
3086
- * apiKey: process.env.GROQ_API_KEY,
3087
- * model: "llama-3.1-70b-versatile",
3088
- * }
3089
- * ```
3090
- */
3091
- ai?: AIConfig;
3092
- /**
3093
- * Sidebar ordering strategy.
3094
- *
3095
- * - `"alphabetical"` — sort pages alphabetically by folder name (default)
3096
- * - `"numeric"` — sort by frontmatter `order` field (lower first, unset pages last)
3097
- * - `OrderingItem[]` — explicit slug-based ordering with nested children
3098
- *
3099
- * @default "alphabetical"
3100
- *
3101
- * @example
3102
- * ```ts
3103
- * // Alphabetical (default)
3104
- * ordering: "alphabetical",
3105
- *
3106
- * // Use frontmatter `order: 1`, `order: 2`, etc.
3107
- * ordering: "numeric",
3108
- *
3109
- * // Explicit slug-based ordering
3110
- * ordering: [
3111
- * { slug: "installation" },
3112
- * { slug: "cli" },
3113
- * { slug: "configuration" },
3114
- * { slug: "themes", children: [
3115
- * { slug: "default" },
3116
- * { slug: "darksharp" },
3117
- * { slug: "pixel-border" },
3118
- * { slug: "creating-themes" },
3119
- * ]},
3120
- * { slug: "customization" },
3121
- * { slug: "reference" },
3122
- * ]
3123
- * ```
3124
- */
3125
- ordering?: "alphabetical" | "numeric" | OrderingItem[];
3126
- /**
3127
- * Auto-generate `/llms.txt` and `/llms-full.txt` routes for LLM-friendly
3128
- * documentation. Native static files at those routes take precedence, so
3129
- * `public/llms.txt` or SvelteKit `static/llms.txt` can override the
3130
- * generated output without extra config.
3131
- *
3132
- * @example
3133
- * ```ts
3134
- * llmsTxt: {
3135
- * baseUrl: "https://docs.example.com",
3136
- * }
3137
- * ```
3138
- *
3139
- * @see https://llmstxt.org
3140
- */
3141
- llmsTxt?: boolean | LlmsTxtConfig;
3142
- /**
3143
- * Generated XML and Markdown sitemaps for crawlers, agents, and static export.
3144
- *
3145
- * Enabled by default. Set `sitemap: false` to opt out.
3146
- *
3147
- * @example
3148
- * ```ts
3149
- * sitemap: true
3150
- *
3151
- * sitemap: {
3152
- * routePrefix: "/docs",
3153
- * baseUrl: "https://docs.example.com",
3154
- * }
3155
- * ```
3156
- */
3157
- sitemap?: boolean | DocsSitemapConfig;
3158
- /**
3159
- * Generated robots.txt policy for docs and agent-readable routes.
3160
- *
3161
- * Served by the runtime by default when no static `robots.txt` exists. Use
3162
- * `docs robots generate` for static export or when you want to append to an
3163
- * existing file.
3164
- *
3165
- * @example
3166
- * ```ts
3167
- * robots: {
3168
- * baseUrl: "https://docs.example.com",
3169
- * ai: "allow",
3170
- * }
3171
- * ```
3172
- */
3173
- robots?: boolean | DocsRobotsConfig;
3174
- /**
3175
- * Generated changelog pages backed by date-folder MDX entries inside the docs
3176
- * content tree.
3177
- *
3178
- * Entry structure:
3179
- * `docs/changelog/2026-03-04/page.mdx`
3180
- *
3181
- * With `entry: "docs"` and `path: "changelogs"`, the public pages render
3182
- * under the docs layout at `/docs/changelogs`.
3183
- *
3184
- * Required frontmatter:
3185
- * - `title`
3186
- * - `description`
3187
- *
3188
- * @example
3189
- * ```ts
3190
- * changelog: {
3191
- * enabled: true,
3192
- * path: "changelogs",
3193
- * contentDir: "changelog",
3194
- * title: "Changelogs",
3195
- * description: "Latest product updates and release notes.",
3196
- * }
3197
- * ```
3198
- */
3199
- changelog?: boolean | ChangelogConfig;
3200
- /**
3201
- * Generated API reference pages from framework route conventions or a hosted
3202
- * OpenAPI JSON document.
3203
- *
3204
- * @example
3205
- * ```ts
3206
- * apiReference: {
3207
- * enabled: true,
3208
- * path: "api-reference",
3209
- * routeRoot: "api",
3210
- * }
3211
- * ```
3212
- *
3213
- * @example
3214
- * ```ts
3215
- * apiReference: {
3216
- * enabled: true,
3217
- * specUrl: "https://example.com/openapi.json",
3218
- * }
3219
- * ```
3220
- */
3221
- apiReference?: boolean | ApiReferenceConfig;
3222
- /**
3223
- * Agent-oriented configuration, including defaults for `docs agent compact`.
3224
- */
3225
- agent?: DocsAgentConfig;
3226
- /**
3227
- * Docs Review checks changed docs files in CI/local runs and can auto-create
3228
- * a GitHub Actions workflow during dev/build startup.
3229
- *
3230
- * - omitted or `true` → enabled with warn-mode CI and an 80 score threshold
3231
- * - `false` → disable review and workflow generation
3232
- *
3233
- * @example
3234
- * ```ts
3235
- * review: {
3236
- * ci: { mode: "block" },
3237
- * score: { threshold: 90 },
3238
- * }
3239
- * ```
3240
- */
3241
- review?: boolean | DocsReviewConfig;
3242
- /** SEO metadata - separate from theme */
3243
- metadata?: DocsMetadata;
3244
- /** Open Graph image handling */
3245
- og?: OGConfig;
3246
- }
3247
- //#endregion
3248
- export { DocsCodeBlocksConfig as $, DocsTelemetryFramework as $t, DocsAgentGoldenTaskExpectation as A, ResolvedDocsRelatedLink as An, DocsReviewRulesConfig as At, DocsAnalyticsSource as B, TypesenseDocsSearchConfig as Bn, DocsSearchDocument as Bt, DocsAgentEvaluationsConfig as C, PageAgentVerification as Cn, DocsObservabilityConfig as Ct, DocsAgentGoldenExampleVerification as D, PageTwitter as Dn, DocsReviewCiConfig as Dt, DocsAgentGoldenAnswerExpectation as E, PageSidebarFrontmatter as En, DocsRelatedItem as Et, DocsAnalyticsConfig as F, SidebarNode as Fn, DocsSearchAdapter as Ft, DocsAskAIFeedbackMessage as G, DocsSearchSourcePage as Gt, DocsAskAIActionType as H, UIConfig as Hn, DocsSearchQuery as Ht, DocsAnalyticsEvent as I, SidebarPageNode as In, DocsSearchAdapterContext as It, DocsCloudApiKeyConfig as J, DocsTelemetryConfig as Jt, DocsAskAIFeedbackValue as K, DocsSitemapConfig as Kt, DocsAnalyticsEventInput as L, SidebarTree as Ln, DocsSearchAdapterFactory as Lt, DocsAgentTraceEventInput as M, SidebarConfig as Mn, DocsReviewSeverity as Mt, DocsAgentTraceEventType as N, SidebarFolderIndexBehavior as Nn, DocsRobotsConfig as Nt, DocsAgentGoldenExpectedExample as O, ReadingTimeConfig as On, DocsReviewCiMode as Ot, DocsAgentTraceStatus as P, SidebarFolderNode as Pn, DocsRobotsRule as Pt, DocsCloudPublishConfig as Q, DocsTelemetryFeatures as Qt, DocsAnalyticsEventType as R, SimpleDocsSearchConfig as Rn, DocsSearchChunkingConfig as Rt, DocsAgentEvaluationTaskInput as S, PageAgentFrontmatter as Sn, DocsNav as St, DocsAgentFeedbackData as T, PageOpenGraph as Tn, DocsObservabilityEventInput as Tt, DocsAskAIFeedbackConfig as U, DocsSearchResult as Ut, DocsAskAIActionData as V, TypographyConfig as Vn, DocsSearchEmbeddingsConfig as Vt, DocsAskAIFeedbackData as W, DocsSearchResultType as Wt, DocsCloudFeatureConfig as X, DocsTelemetryEventInput as Xt, DocsCloudConfig as Y, DocsTelemetryEvent as Yt, DocsCloudPreviewConfig as Z, DocsTelemetryEventType as Zt, DocsAgentEvaluationAnswerRequest as _, OrderingItem as _n, DocsMcpCorsConfig as _t, ApiReferenceRenderer as a, LlmsTxtConfig as an, DocsCodeBlocksValidationMode as at, DocsAgentEvaluationSourceReference as b, PageAgentCommand as bn, DocsMcpToolsConfig as bt, ChangelogFrontmatter as c, LlmsTxtSectionConfig as cn, DocsFeedbackData as ct, CopyMarkdownFormat as d, OpenDocsConfig as dn, DocsMcpAllowedOrigins as dt, DocsTheme as en, DocsCodeBlocksPlannerConfig as et, CustomDocsSearchConfig as f, OpenDocsProvider as fn, DocsMcpAuthPrincipal as ft, DocsAgentEvaluationAnswerProvider as g, OpenGraphImage as gn, DocsMcpConfig as gt, DocsAgentEvaluationAnswerInput as h, OpenDocsTarget as hn, DocsMcpAuthenticateResult as ht, ApiReferenceConfig as i, LastUpdatedConfig as in, DocsCodeBlocksValidateConfig as it, DocsAgentGoldenTaskFilters as j, SidebarComponentProps as jn, DocsReviewScoreConfig as jt, DocsAgentGoldenTask as k, ReadingTimeFormat as kn, DocsReviewConfig as kt, CodeBlockCopyData as l, McpDocsSearchConfig as ln, DocsFeedbackValue as lt, DocsAgentConfig as m, OpenDocsProviderId as mn, DocsMcpAuthenticateContext as mt, AgentFeedbackConfig as n, FontStyle as nn, DocsCodeBlocksRunnerConfig as nt, BreadcrumbConfig as o, LlmsTxtMaxCharsConfig as on, DocsCodeBlocksValidationPolicy as ot, DocsAgentCompactConfig as p, OpenDocsProviderConfig as pn, DocsMcpAuthenticate as pt, DocsAskAIMcpConfig as q, DocsTelemetryAgentSurface as qt, AlgoliaDocsSearchConfig as r, GithubConfig as rn, DocsCodeBlocksRunnerProvider as rt, ChangelogConfig as s, LlmsTxtMaxCharsMode as sn, DocsConfig as st, AIConfig as t, FeedbackConfig as tn, DocsCodeBlocksPlannerProvider as tt, CopyMarkdownConfig as u, OGConfig as un, DocsI18nConfig as ut, DocsAgentEvaluationAnswerResult as v, PageActionsConfig as vn, DocsMcpOriginContext as vt, DocsAgentFeedbackContext as w, PageFrontmatter as wn, DocsObservabilityEvent as wt, DocsAgentEvaluationSurface as x, PageAgentFailureMode as xn, DocsMetadata as xt, DocsAgentEvaluationAnswerRunner as y, PageAgentAppliesTo as yn, DocsMcpSecurityConfig as yt, DocsAnalyticsInput as z, ThemeToggleConfig as zn, DocsSearchConfig as zt };