@farming-labs/docs 0.1.115 → 0.1.116

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.
@@ -83,7 +83,7 @@ async function main() {
83
83
  const { dev } = await import("../dev-FC6Fh7nT.mjs");
84
84
  await dev(devOptions);
85
85
  } else if (parsedCommand.command === "mcp") {
86
- const { runMcp } = await import("../mcp-Cv95rruE.mjs");
86
+ const { runMcp } = await import("../mcp-aGYzIAb_.mjs");
87
87
  await runMcp(mcpOptions);
88
88
  } else if (parsedCommand.command === "agent" && subcommand === "compact") {
89
89
  const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-D8DpCgt_.mjs");
@@ -114,7 +114,7 @@ async function main() {
114
114
  printAgentsGenerateHelp();
115
115
  process.exit(1);
116
116
  } else if (parsedCommand.command === "doctor") {
117
- const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-CgCcBScE.mjs");
117
+ const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-Cey7sqh9.mjs");
118
118
  const doctorOptions = parseDoctorArgs(args.slice(1));
119
119
  if (doctorOptions.help) {
120
120
  printDoctorHelp();
@@ -955,7 +955,8 @@ async function probeMcpRoute(baseUrl, route) {
955
955
  "list_pages",
956
956
  "get_navigation",
957
957
  "search_docs",
958
- "read_page"
958
+ "read_page",
959
+ "get_code_examples"
959
960
  ].filter((tool) => !toolNames.includes(tool));
960
961
  if (missingTools.length > 0) return {
961
962
  ok: false,
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as DocsSearchResultType, A as DocsConfig, At as SidebarFolderNode, B as DocsObservabilityEventInput, C as DocsAskAIActionData, Ct as PageSidebarFrontmatter, D as DocsAskAIFeedbackMessage, Dt as SidebarComponentProps, E as DocsAskAIFeedbackData, Et as ResolvedDocsRelatedLink, F as DocsMcpToolsConfig, Ft as ThemeToggleConfig, G as DocsSearchAdapterContext, H as DocsRobotsConfig, I as DocsMetadata, It as TypesenseDocsSearchConfig, J as DocsSearchConfig, K as DocsSearchAdapterFactory, L as DocsNav, Lt as TypographyConfig, M as DocsFeedbackValue, Mt as SidebarPageNode, N as DocsI18nConfig, Nt as SidebarTree, O as DocsAskAIFeedbackValue, Ot as SidebarConfig, P as DocsMcpConfig, Pt as SimpleDocsSearchConfig, Q as DocsSearchResult, R as DocsObservabilityConfig, Rt as UIConfig, S as DocsAnalyticsSource, St as PageOpenGraph, T as DocsAskAIFeedbackConfig, Tt as ReadingTimeConfig, U as DocsRobotsRule, V as DocsRelatedItem, W as DocsSearchAdapter, X as DocsSearchEmbeddingsConfig, Y as DocsSearchDocument, Z as DocsSearchQuery, _ as DocsAnalyticsConfig, _t as OpenDocsTarget, a as ApiReferenceRenderer, at as GithubConfig, b as DocsAnalyticsEventType, bt as PageActionsConfig, c as ChangelogFrontmatter, ct as LlmsTxtMaxCharsConfig, d as CustomDocsSearchConfig, dt as McpDocsSearchConfig, et as DocsSearchSourcePage, f as DocsAgentFeedbackContext, ft as OGConfig, g as DocsAgentTraceStatus, gt as OpenDocsProviderId, h as DocsAgentTraceEventType, ht as OpenDocsProviderConfig, i as ApiReferenceConfig, it as FontStyle, j as DocsFeedbackData, jt as SidebarNode, k as DocsAskAIMcpConfig, kt as SidebarFolderIndexBehavior, l as CodeBlockCopyData, lt as LlmsTxtMaxCharsMode, m as DocsAgentTraceEventInput, mt as OpenDocsProvider, n as AgentFeedbackConfig, nt as DocsTheme, o as BreadcrumbConfig, ot as LastUpdatedConfig, p as DocsAgentFeedbackData, pt as OpenDocsConfig, q as DocsSearchChunkingConfig, r as AlgoliaDocsSearchConfig, rt as FeedbackConfig, s as ChangelogConfig, st as LlmsTxtConfig, t as AIConfig, tt as DocsSitemapConfig, u as CopyMarkdownConfig, ut as LlmsTxtSectionConfig, v as DocsAnalyticsEvent, vt as OpenGraphImage, w as DocsAskAIActionType, wt as PageTwitter, x as DocsAnalyticsInput, xt as PageFrontmatter, y as DocsAnalyticsEventInput, yt as OrderingItem, z as DocsObservabilityEvent } from "./types-Zk0mIMGI.mjs";
2
- import { $ as emitDocsAgentTraceEvent, A as toDocsSitemapMarkdownUrl, C as createDocsSitemapResponse, D as resolveDocsSitemapConfig, E as renderDocsSitemapXml, F as PromptAction, I as PromptProviderChoice, J as DocsAgentTraceContext, L as SerializeOpenDocsProviderOptions, O as resolveDocsSitemapPageLastmod, Q as createDocsAgentTraceId, R as SerializedOpenDocsProvider, S as buildDocsSitemapManifest, T as renderDocsSitemapMarkdown, X as ResolvedDocsObservabilityConfig, Y as ResolvedDocsAnalyticsConfig, Z as createDocsAgentTraceContext, _ as DocsSitemapFormat, a as createMcpSearchAdapter, at as createDocsCloudAnalytics, b as DocsSitemapPageInput, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, et as emitDocsAnalyticsEvent, f as resolveSearchRequestConfig, g as DEFAULT_SITEMAP_XML_ROUTE, h as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, i as createCustomSearchAdapter, it as DocsCloudAnalyticsOptions, k as resolveDocsSitemapRequest, l as inferDocsAskAIPackageHints, m as DEFAULT_SITEMAP_MD_ROUTE, n as buildDocsSearchDocuments, nt as resolveDocsAnalyticsConfig, o as createSimpleSearchAdapter, p as DEFAULT_SITEMAP_MANIFEST_PATH, q as DOCS_AGENT_TRACE_EVENT_TYPES, r as createAlgoliaSearchAdapter, rt as resolveDocsObservabilityConfig, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, tt as emitDocsObservabilityEvent, u as performDocsSearch, v as DocsSitemapManifest, w as readDocsSitemapManifestFromContentMap, x as DocsSitemapResolvedConfig, y as DocsSitemapManifestPage } from "./search-DjVbXEmb.mjs";
1
+ import { $ as DocsSearchResultType, A as DocsConfig, At as SidebarFolderNode, B as DocsObservabilityEventInput, C as DocsAskAIActionData, Ct as PageSidebarFrontmatter, D as DocsAskAIFeedbackMessage, Dt as SidebarComponentProps, E as DocsAskAIFeedbackData, Et as ResolvedDocsRelatedLink, F as DocsMcpToolsConfig, Ft as ThemeToggleConfig, G as DocsSearchAdapterContext, H as DocsRobotsConfig, I as DocsMetadata, It as TypesenseDocsSearchConfig, J as DocsSearchConfig, K as DocsSearchAdapterFactory, L as DocsNav, Lt as TypographyConfig, M as DocsFeedbackValue, Mt as SidebarPageNode, N as DocsI18nConfig, Nt as SidebarTree, O as DocsAskAIFeedbackValue, Ot as SidebarConfig, P as DocsMcpConfig, Pt as SimpleDocsSearchConfig, Q as DocsSearchResult, R as DocsObservabilityConfig, Rt as UIConfig, S as DocsAnalyticsSource, St as PageOpenGraph, T as DocsAskAIFeedbackConfig, Tt as ReadingTimeConfig, U as DocsRobotsRule, V as DocsRelatedItem, W as DocsSearchAdapter, X as DocsSearchEmbeddingsConfig, Y as DocsSearchDocument, Z as DocsSearchQuery, _ as DocsAnalyticsConfig, _t as OpenDocsTarget, a as ApiReferenceRenderer, at as GithubConfig, b as DocsAnalyticsEventType, bt as PageActionsConfig, c as ChangelogFrontmatter, ct as LlmsTxtMaxCharsConfig, d as CustomDocsSearchConfig, dt as McpDocsSearchConfig, et as DocsSearchSourcePage, f as DocsAgentFeedbackContext, ft as OGConfig, g as DocsAgentTraceStatus, gt as OpenDocsProviderId, h as DocsAgentTraceEventType, ht as OpenDocsProviderConfig, i as ApiReferenceConfig, it as FontStyle, j as DocsFeedbackData, jt as SidebarNode, k as DocsAskAIMcpConfig, kt as SidebarFolderIndexBehavior, l as CodeBlockCopyData, lt as LlmsTxtMaxCharsMode, m as DocsAgentTraceEventInput, mt as OpenDocsProvider, n as AgentFeedbackConfig, nt as DocsTheme, o as BreadcrumbConfig, ot as LastUpdatedConfig, p as DocsAgentFeedbackData, pt as OpenDocsConfig, q as DocsSearchChunkingConfig, r as AlgoliaDocsSearchConfig, rt as FeedbackConfig, s as ChangelogConfig, st as LlmsTxtConfig, t as AIConfig, tt as DocsSitemapConfig, u as CopyMarkdownConfig, ut as LlmsTxtSectionConfig, v as DocsAnalyticsEvent, vt as OpenGraphImage, w as DocsAskAIActionType, wt as PageTwitter, x as DocsAnalyticsInput, xt as PageFrontmatter, y as DocsAnalyticsEventInput, yt as OrderingItem, z as DocsObservabilityEvent } from "./types-qqx8SjH4.mjs";
2
+ import { $ as emitDocsAgentTraceEvent, A as toDocsSitemapMarkdownUrl, C as createDocsSitemapResponse, D as resolveDocsSitemapConfig, E as renderDocsSitemapXml, F as PromptAction, I as PromptProviderChoice, J as DocsAgentTraceContext, L as SerializeOpenDocsProviderOptions, O as resolveDocsSitemapPageLastmod, Q as createDocsAgentTraceId, R as SerializedOpenDocsProvider, S as buildDocsSitemapManifest, T as renderDocsSitemapMarkdown, X as ResolvedDocsObservabilityConfig, Y as ResolvedDocsAnalyticsConfig, Z as createDocsAgentTraceContext, _ as DocsSitemapFormat, a as createMcpSearchAdapter, at as createDocsCloudAnalytics, b as DocsSitemapPageInput, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, et as emitDocsAnalyticsEvent, f as resolveSearchRequestConfig, g as DEFAULT_SITEMAP_XML_ROUTE, h as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, i as createCustomSearchAdapter, it as DocsCloudAnalyticsOptions, k as resolveDocsSitemapRequest, l as inferDocsAskAIPackageHints, m as DEFAULT_SITEMAP_MD_ROUTE, n as buildDocsSearchDocuments, nt as resolveDocsAnalyticsConfig, o as createSimpleSearchAdapter, p as DEFAULT_SITEMAP_MANIFEST_PATH, q as DOCS_AGENT_TRACE_EVENT_TYPES, r as createAlgoliaSearchAdapter, rt as resolveDocsObservabilityConfig, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, tt as emitDocsObservabilityEvent, u as performDocsSearch, v as DocsSitemapManifest, w as readDocsSitemapManifestFromContentMap, x as DocsSitemapResolvedConfig, y as DocsSitemapManifestPage } from "./search-DYPyHTz_.mjs";
3
3
  import { DocsMcpPage, DocsMcpResolvedConfig } from "./mcp.mjs";
4
4
 
5
5
  //#region src/define-docs.d.ts
@@ -601,6 +601,7 @@ declare function buildDocsAgentDiscoverySpec({
601
601
  readPage: boolean;
602
602
  searchDocs: boolean;
603
603
  getNavigation: boolean;
604
+ getCodeExamples: boolean;
604
605
  };
605
606
  };
606
607
  feedback: {
@@ -38,7 +38,8 @@ function readMcpConfig(content) {
38
38
  listPages: readBooleanProperty(block, "listPages"),
39
39
  readPage: readBooleanProperty(block, "readPage"),
40
40
  searchDocs: readBooleanProperty(block, "searchDocs"),
41
- getNavigation: readBooleanProperty(block, "getNavigation")
41
+ getNavigation: readBooleanProperty(block, "getNavigation"),
42
+ getCodeExamples: readBooleanProperty(block, "getCodeExamples")
42
43
  }
43
44
  };
44
45
  }
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { J as DocsSearchConfig, P as DocsMcpConfig, R as DocsObservabilityConfig, _ as DocsAnalyticsConfig, et as DocsSearchSourcePage, yt as OrderingItem } from "./types-Zk0mIMGI.mjs";
1
+ import { J as DocsSearchConfig, P as DocsMcpConfig, R as DocsObservabilityConfig, _ as DocsAnalyticsConfig, et as DocsSearchSourcePage, yt as OrderingItem } from "./types-qqx8SjH4.mjs";
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
 
4
4
  //#region src/mcp.d.ts
@@ -18,6 +18,24 @@ interface DocsMcpPage {
18
18
  agentFallbackContent?: string;
19
19
  agentFallbackRawContent?: string;
20
20
  }
21
+ interface DocsMcpCodeExample {
22
+ id: string;
23
+ page: {
24
+ slug: string;
25
+ url: string;
26
+ title: string;
27
+ description?: string;
28
+ sourcePath?: string;
29
+ lastModified?: string;
30
+ };
31
+ language?: string;
32
+ title?: string;
33
+ framework?: string;
34
+ packageManager?: string;
35
+ runnable: boolean;
36
+ meta: Record<string, string | boolean>;
37
+ code: string;
38
+ }
21
39
  interface DocsMcpPageNode {
22
40
  type: "page";
23
41
  name: string;
@@ -53,6 +71,7 @@ interface DocsMcpResolvedConfig {
53
71
  readPage: boolean;
54
72
  searchDocs: boolean;
55
73
  getNavigation: boolean;
74
+ getCodeExamples: boolean;
56
75
  };
57
76
  }
58
77
  interface DocsMcpHttpHandlers {
@@ -93,4 +112,4 @@ declare function createDocsMcpServer(options: CreateDocsMcpServerOptions): Promi
93
112
  declare function createDocsMcpHttpHandler(options: CreateDocsMcpServerOptions): DocsMcpHttpHandlers;
94
113
  declare function runDocsMcpStdio(options: CreateDocsMcpServerOptions): Promise<void>;
95
114
  //#endregion
96
- export { DocsMcpFolderNode, DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpPageNode, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio };
115
+ export { DocsMcpCodeExample, DocsMcpFolderNode, DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpPageNode, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio };
package/dist/mcp.mjs CHANGED
@@ -24,6 +24,16 @@ const readPageInputSchema = z.object({
24
24
  });
25
25
  const listPagesInputSchema = z.object({ locale: z.string().min(1).optional() });
26
26
  const getNavigationInputSchema = z.object({ locale: z.string().min(1).optional() });
27
+ const getCodeExamplesInputSchema = z.object({
28
+ query: z.string().trim().min(1).optional(),
29
+ path: z.string().min(1).optional(),
30
+ framework: z.string().trim().min(1).optional(),
31
+ packageManager: z.string().trim().min(1).optional(),
32
+ language: z.string().trim().min(1).optional(),
33
+ runnable: z.boolean().optional(),
34
+ limit: z.number().int().min(1).max(50).optional(),
35
+ locale: z.string().min(1).optional()
36
+ });
27
37
  function normalizeDocsMcpRoute(route) {
28
38
  if (!route || route.trim().length === 0) return DEFAULT_MCP_ROUTE;
29
39
  const normalized = `/${route}`.replace(/\/+/g, "/");
@@ -39,7 +49,8 @@ function resolveDocsMcpConfig(mcp, defaults = {}) {
39
49
  listPages: true,
40
50
  readPage: true,
41
51
  searchDocs: true,
42
- getNavigation: true
52
+ getNavigation: true,
53
+ getCodeExamples: true
43
54
  }
44
55
  };
45
56
  const config = mcp && typeof mcp === "object" ? mcp : {};
@@ -52,7 +63,8 @@ function resolveDocsMcpConfig(mcp, defaults = {}) {
52
63
  listPages: config.tools?.listPages ?? true,
53
64
  readPage: config.tools?.readPage ?? true,
54
65
  searchDocs: config.tools?.searchDocs ?? true,
55
- getNavigation: config.tools?.getNavigation ?? true
66
+ getNavigation: config.tools?.getNavigation ?? true,
67
+ getCodeExamples: config.tools?.getCodeExamples ?? true
56
68
  }
57
69
  };
58
70
  }
@@ -350,6 +362,103 @@ async function createDocsMcpServer(options) {
350
362
  throw error;
351
363
  }
352
364
  });
365
+ if (resolved.tools.getCodeExamples) server.registerTool("get_code_examples", {
366
+ title: "Get docs code examples",
367
+ description: "Return fenced code examples from the docs with parsed metadata such as title, framework, packageManager, and runnable.",
368
+ inputSchema: getCodeExamplesInputSchema,
369
+ annotations: { readOnlyHint: true }
370
+ }, async ({ query, path: requestedPath, framework, packageManager, language, runnable, limit, locale }) => {
371
+ const startedAt = nowMs();
372
+ const resolvedLimit = limit ?? 25;
373
+ const trace = createDocsAgentTraceContext("mcp.tool.get_code_examples");
374
+ const callSpanId = createDocsAgentTraceId("span");
375
+ await emitDocsAgentTraceEvent(options.observability, {
376
+ type: "tool.call",
377
+ source: "mcp",
378
+ traceId: trace.traceId,
379
+ spanId: callSpanId,
380
+ name: "get_code_examples",
381
+ startedAt: trace.startedAt,
382
+ status: "started",
383
+ locale,
384
+ inputPreview: {
385
+ queryLength: query?.length,
386
+ path: requestedPath,
387
+ framework,
388
+ packageManager,
389
+ language,
390
+ runnable,
391
+ limit: resolvedLimit
392
+ },
393
+ metadata: { tool: "get_code_examples" }
394
+ });
395
+ try {
396
+ const pages = dedupePages(await options.source.getPages(locale));
397
+ const matchedPage = requestedPath ? findDocsPage(pages, requestedPath, options.source.entry) : null;
398
+ const examples = filterDocsCodeExamples((requestedPath ? matchedPage ? [matchedPage] : [] : pages).flatMap((page) => extractDocsMcpCodeExamples(page)), {
399
+ query,
400
+ framework,
401
+ packageManager,
402
+ language,
403
+ runnable,
404
+ limit: resolvedLimit
405
+ });
406
+ const elapsed = durationMs(startedAt);
407
+ await emitDocsAnalyticsEvent(options.analytics, {
408
+ type: "mcp_tool",
409
+ source: "mcp",
410
+ locale,
411
+ input: query ? { query } : void 0,
412
+ properties: {
413
+ tool: "get_code_examples",
414
+ queryLength: query?.length,
415
+ path: requestedPath,
416
+ framework,
417
+ packageManager,
418
+ language,
419
+ runnable,
420
+ limit: resolvedLimit,
421
+ resultCount: examples.length,
422
+ durationMs: elapsed
423
+ }
424
+ });
425
+ await emitDocsAgentTraceEvent(options.observability, {
426
+ type: "tool.result",
427
+ source: "mcp",
428
+ traceId: trace.traceId,
429
+ parentSpanId: callSpanId,
430
+ name: "get_code_examples",
431
+ startedAt: trace.startedAt,
432
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
433
+ durationMs: elapsed,
434
+ status: "success",
435
+ locale,
436
+ outputPreview: { resultCount: examples.length },
437
+ metadata: { tool: "get_code_examples" }
438
+ });
439
+ return { content: [{
440
+ type: "text",
441
+ text: JSON.stringify({ examples }, null, 2)
442
+ }] };
443
+ } catch (error) {
444
+ const elapsed = durationMs(startedAt);
445
+ await emitDocsAgentTraceEvent(options.observability, {
446
+ type: "tool.error",
447
+ source: "mcp",
448
+ traceId: trace.traceId,
449
+ parentSpanId: callSpanId,
450
+ name: "get_code_examples",
451
+ startedAt: trace.startedAt,
452
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
453
+ durationMs: elapsed,
454
+ status: "error",
455
+ locale,
456
+ outputPreview: { message: error instanceof Error ? error.message : "Unknown error" },
457
+ metadata: { tool: "get_code_examples" }
458
+ });
459
+ throw error;
460
+ }
461
+ });
353
462
  if (resolved.tools.readPage) server.registerTool("read_page", {
354
463
  title: "Read a docs page",
355
464
  description: "Read a documentation page by slug or URL path.",
@@ -905,6 +1014,123 @@ function toPageSummaries(pages) {
905
1014
  icon: page.icon
906
1015
  }));
907
1016
  }
1017
+ function extractDocsMcpCodeExamples(page) {
1018
+ const source = page.agentRawContent ?? page.agentFallbackRawContent ?? page.rawContent;
1019
+ if (!source) return [];
1020
+ const examples = [];
1021
+ const lines = source.split("\n");
1022
+ let index = 0;
1023
+ let openFence = null;
1024
+ for (const line of lines) {
1025
+ const trimmed = line.trim();
1026
+ if (!openFence) {
1027
+ const openMatch = trimmed.match(/^(`{3,}|~{3,})(.*)$/);
1028
+ if (!openMatch) continue;
1029
+ openFence = {
1030
+ marker: openMatch[1],
1031
+ info: openMatch[2]?.trim() ?? "",
1032
+ code: []
1033
+ };
1034
+ continue;
1035
+ }
1036
+ if (isClosingFence(trimmed, openFence.marker)) {
1037
+ const parsed = parseCodeFenceInfo(openFence.info);
1038
+ const meta = parsed.meta;
1039
+ const title = readStringMeta(meta, "title");
1040
+ const framework = readStringMeta(meta, "framework");
1041
+ const packageManager = readStringMeta(meta, "packageManager");
1042
+ const runnable = readBooleanMeta(meta, "runnable") ?? false;
1043
+ index += 1;
1044
+ examples.push({
1045
+ id: `${page.url}#code-${index}`,
1046
+ page: {
1047
+ slug: page.slug,
1048
+ url: page.url,
1049
+ title: page.title,
1050
+ description: page.description,
1051
+ sourcePath: page.sourcePath,
1052
+ lastModified: page.lastModified
1053
+ },
1054
+ language: parsed.language,
1055
+ title,
1056
+ framework,
1057
+ packageManager,
1058
+ runnable,
1059
+ meta,
1060
+ code: openFence.code.join("\n")
1061
+ });
1062
+ openFence = null;
1063
+ continue;
1064
+ }
1065
+ openFence.code.push(line);
1066
+ }
1067
+ return examples;
1068
+ }
1069
+ function filterDocsCodeExamples(examples, filters) {
1070
+ const query = filters.query?.toLowerCase();
1071
+ const framework = filters.framework?.toLowerCase();
1072
+ const packageManager = filters.packageManager?.toLowerCase();
1073
+ const language = filters.language?.toLowerCase();
1074
+ return examples.filter((example) => {
1075
+ if (framework && example.framework?.toLowerCase() !== framework) return false;
1076
+ if (packageManager && example.packageManager?.toLowerCase() !== packageManager) return false;
1077
+ if (language && example.language?.toLowerCase() !== language) return false;
1078
+ if (filters.runnable !== void 0 && example.runnable !== filters.runnable) return false;
1079
+ if (!query) return true;
1080
+ return getCodeExampleSearchText(example).toLowerCase().includes(query);
1081
+ }).slice(0, filters.limit);
1082
+ }
1083
+ function isClosingFence(trimmedLine, marker) {
1084
+ if (!trimmedLine.startsWith(marker)) return false;
1085
+ return trimmedLine.slice(marker.length).trim().length === 0;
1086
+ }
1087
+ function parseCodeFenceInfo(info) {
1088
+ const trimmed = info.trim();
1089
+ if (!trimmed) return { meta: {} };
1090
+ const firstToken = trimmed.match(/^(\S+)/)?.[1] ?? "";
1091
+ const language = firstToken && !firstToken.includes("=") ? firstToken : void 0;
1092
+ const attributeSource = language ? trimmed.slice(firstToken.length).trim() : trimmed;
1093
+ const meta = {};
1094
+ const attributePattern = /([A-Za-z_:][\w:.-]*)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"']+)))?/g;
1095
+ let match;
1096
+ while (match = attributePattern.exec(attributeSource)) {
1097
+ const key = match[1];
1098
+ meta[key] = match[2] ?? match[3] ?? match[4] ?? true;
1099
+ }
1100
+ return {
1101
+ language,
1102
+ meta
1103
+ };
1104
+ }
1105
+ function readStringMeta(meta, key) {
1106
+ const value = meta[key];
1107
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
1108
+ }
1109
+ function readBooleanMeta(meta, key) {
1110
+ const value = meta[key];
1111
+ if (typeof value === "boolean") return value;
1112
+ if (typeof value !== "string") return void 0;
1113
+ const normalized = value.trim().toLowerCase();
1114
+ if (!normalized || normalized === "true" || normalized === "1" || normalized === "yes") return true;
1115
+ if (normalized === "false" || normalized === "0" || normalized === "no") return false;
1116
+ return true;
1117
+ }
1118
+ function getCodeExampleSearchText(example) {
1119
+ return [
1120
+ example.id,
1121
+ example.page.slug,
1122
+ example.page.url,
1123
+ example.page.title,
1124
+ example.page.description,
1125
+ example.page.sourcePath,
1126
+ example.language,
1127
+ example.title,
1128
+ example.framework,
1129
+ example.packageManager,
1130
+ ...Object.entries(example.meta).map(([key, value]) => `${key} ${String(value)}`),
1131
+ example.code
1132
+ ].filter((value) => typeof value === "string").join("\n");
1133
+ }
908
1134
  function findDocsPage(pages, requestedPath, entry) {
909
1135
  const normalizedRequest = normalizeRequestedPath(requestedPath, entry);
910
1136
  for (const page of pages) if (normalizeUrlPath(page.url) === normalizedRequest) return page;
@@ -1,4 +1,4 @@
1
- import { B as DocsObservabilityEventInput, Et as ResolvedDocsRelatedLink, It as TypesenseDocsSearchConfig, J as DocsSearchConfig, K as DocsSearchAdapterFactory, Q as DocsSearchResult, R as DocsObservabilityConfig, W as DocsSearchAdapter, Y as DocsSearchDocument, _ as DocsAnalyticsConfig, _t as OpenDocsTarget, d as CustomDocsSearchConfig, dt as McpDocsSearchConfig, et as DocsSearchSourcePage, k as DocsAskAIMcpConfig, m as DocsAgentTraceEventInput, mt as OpenDocsProvider, q as DocsSearchChunkingConfig, r as AlgoliaDocsSearchConfig, tt as DocsSitemapConfig, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsObservabilityEvent } from "./types-Zk0mIMGI.mjs";
1
+ import { B as DocsObservabilityEventInput, Et as ResolvedDocsRelatedLink, It as TypesenseDocsSearchConfig, J as DocsSearchConfig, K as DocsSearchAdapterFactory, Q as DocsSearchResult, R as DocsObservabilityConfig, W as DocsSearchAdapter, Y as DocsSearchDocument, _ as DocsAnalyticsConfig, _t as OpenDocsTarget, d as CustomDocsSearchConfig, dt as McpDocsSearchConfig, et as DocsSearchSourcePage, k as DocsAskAIMcpConfig, m as DocsAgentTraceEventInput, mt as OpenDocsProvider, q as DocsSearchChunkingConfig, r as AlgoliaDocsSearchConfig, tt as DocsSitemapConfig, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsObservabilityEvent } from "./types-qqx8SjH4.mjs";
2
2
 
3
3
  //#region src/cloud-analytics.d.ts
4
4
  interface DocsCloudAnalyticsOptions {
package/dist/server.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as DocsConfig, B as DocsObservabilityEventInput, D as DocsAskAIFeedbackMessage, E as DocsAskAIFeedbackData, G as DocsSearchAdapterContext, J as DocsSearchConfig, K as DocsSearchAdapterFactory, O as DocsAskAIFeedbackValue, Q as DocsSearchResult, R as DocsObservabilityConfig, T as DocsAskAIFeedbackConfig, W as DocsSearchAdapter, Y as DocsSearchDocument, Z as DocsSearchQuery, _ as DocsAnalyticsConfig, a as ApiReferenceRenderer, dt as McpDocsSearchConfig, et as DocsSearchSourcePage, g as DocsAgentTraceStatus, h as DocsAgentTraceEventType, k as DocsAskAIMcpConfig, m as DocsAgentTraceEventInput, tt as DocsSitemapConfig, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsObservabilityEvent } from "./types-Zk0mIMGI.mjs";
2
- import { $ as emitDocsAgentTraceEvent, A as toDocsSitemapMarkdownUrl, B as parsePromptStringArray, C as createDocsSitemapResponse, D as resolveDocsSitemapConfig, E as renderDocsSitemapXml, F as PromptAction, G as serializeOpenDocsProvider, H as sanitizePromptText, I as PromptProviderChoice, J as DocsAgentTraceContext, K as serializeOpenDocsProviders, L as SerializeOpenDocsProviderOptions, M as DEFAULT_OPEN_DOCS_PROVIDER_IDS, N as DEFAULT_OPEN_DOCS_TARGET, O as resolveDocsSitemapPageLastmod, P as DEFAULT_PROMPT_PROVIDER_TEMPLATES, Q as createDocsAgentTraceId, R as SerializedOpenDocsProvider, S as buildDocsSitemapManifest, T as renderDocsSitemapMarkdown, U as serializeDocsIcon, V as resolvePromptProviderChoices, W as serializeDocsIconRegistry, X as ResolvedDocsObservabilityConfig, Y as ResolvedDocsAnalyticsConfig, Z as createDocsAgentTraceContext, _ as DocsSitemapFormat, a as createMcpSearchAdapter, at as createDocsCloudAnalytics, b as DocsSitemapPageInput, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, et as emitDocsAnalyticsEvent, f as resolveSearchRequestConfig, g as DEFAULT_SITEMAP_XML_ROUTE, h as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, i as createCustomSearchAdapter, it as DocsCloudAnalyticsOptions, j as DEFAULT_OPEN_DOCS_PROMPT, k as resolveDocsSitemapRequest, l as inferDocsAskAIPackageHints, m as DEFAULT_SITEMAP_MD_ROUTE, n as buildDocsSearchDocuments, nt as resolveDocsAnalyticsConfig, o as createSimpleSearchAdapter, p as DEFAULT_SITEMAP_MANIFEST_PATH, q as DOCS_AGENT_TRACE_EVENT_TYPES, r as createAlgoliaSearchAdapter, rt as resolveDocsObservabilityConfig, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, tt as emitDocsObservabilityEvent, u as performDocsSearch, v as DocsSitemapManifest, w as readDocsSitemapManifestFromContentMap, x as DocsSitemapResolvedConfig, y as DocsSitemapManifestPage, z as normalizePromptProviderName } from "./search-DjVbXEmb.mjs";
3
- import { DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
1
+ import { A as DocsConfig, B as DocsObservabilityEventInput, D as DocsAskAIFeedbackMessage, E as DocsAskAIFeedbackData, G as DocsSearchAdapterContext, J as DocsSearchConfig, K as DocsSearchAdapterFactory, O as DocsAskAIFeedbackValue, Q as DocsSearchResult, R as DocsObservabilityConfig, T as DocsAskAIFeedbackConfig, W as DocsSearchAdapter, Y as DocsSearchDocument, Z as DocsSearchQuery, _ as DocsAnalyticsConfig, a as ApiReferenceRenderer, dt as McpDocsSearchConfig, et as DocsSearchSourcePage, g as DocsAgentTraceStatus, h as DocsAgentTraceEventType, k as DocsAskAIMcpConfig, m as DocsAgentTraceEventInput, tt as DocsSitemapConfig, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsObservabilityEvent } from "./types-qqx8SjH4.mjs";
2
+ import { $ as emitDocsAgentTraceEvent, A as toDocsSitemapMarkdownUrl, B as parsePromptStringArray, C as createDocsSitemapResponse, D as resolveDocsSitemapConfig, E as renderDocsSitemapXml, F as PromptAction, G as serializeOpenDocsProvider, H as sanitizePromptText, I as PromptProviderChoice, J as DocsAgentTraceContext, K as serializeOpenDocsProviders, L as SerializeOpenDocsProviderOptions, M as DEFAULT_OPEN_DOCS_PROVIDER_IDS, N as DEFAULT_OPEN_DOCS_TARGET, O as resolveDocsSitemapPageLastmod, P as DEFAULT_PROMPT_PROVIDER_TEMPLATES, Q as createDocsAgentTraceId, R as SerializedOpenDocsProvider, S as buildDocsSitemapManifest, T as renderDocsSitemapMarkdown, U as serializeDocsIcon, V as resolvePromptProviderChoices, W as serializeDocsIconRegistry, X as ResolvedDocsObservabilityConfig, Y as ResolvedDocsAnalyticsConfig, Z as createDocsAgentTraceContext, _ as DocsSitemapFormat, a as createMcpSearchAdapter, at as createDocsCloudAnalytics, b as DocsSitemapPageInput, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, et as emitDocsAnalyticsEvent, f as resolveSearchRequestConfig, g as DEFAULT_SITEMAP_XML_ROUTE, h as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, i as createCustomSearchAdapter, it as DocsCloudAnalyticsOptions, j as DEFAULT_OPEN_DOCS_PROMPT, k as resolveDocsSitemapRequest, l as inferDocsAskAIPackageHints, m as DEFAULT_SITEMAP_MD_ROUTE, n as buildDocsSearchDocuments, nt as resolveDocsAnalyticsConfig, o as createSimpleSearchAdapter, p as DEFAULT_SITEMAP_MANIFEST_PATH, q as DOCS_AGENT_TRACE_EVENT_TYPES, r as createAlgoliaSearchAdapter, rt as resolveDocsObservabilityConfig, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, tt as emitDocsObservabilityEvent, u as performDocsSearch, v as DocsSitemapManifest, w as readDocsSitemapManifestFromContentMap, x as DocsSitemapResolvedConfig, y as DocsSitemapManifestPage, z as normalizePromptProviderName } from "./search-DYPyHTz_.mjs";
3
+ import { DocsMcpCodeExample, DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
4
4
 
5
5
  //#region src/api-reference.d.ts
6
6
  type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
@@ -55,4 +55,4 @@ declare function buildApiReferenceHtmlDocumentAsync(config: DocsConfig, options:
55
55
  //#region src/sitemap-server.d.ts
56
56
  declare function readDocsSitemapManifest(rootDir: string, sitemap?: boolean | DocsSitemapConfig): DocsSitemapManifest | null;
57
57
  //#endregion
58
- export { type ApiReferenceFramework, type ApiReferenceOpenApiDiscovery, type ApiReferenceRenderer, type ApiReferenceRoute, DEFAULT_API_REFERENCE_OPENAPI_ROUTE, DEFAULT_OPEN_DOCS_PROMPT, DEFAULT_OPEN_DOCS_PROVIDER_IDS, DEFAULT_OPEN_DOCS_TARGET, DEFAULT_PROMPT_PROVIDER_TEMPLATES, DEFAULT_SITEMAP_MANIFEST_PATH, DEFAULT_SITEMAP_MD_ROUTE, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, DEFAULT_SITEMAP_XML_ROUTE, DOCS_AGENT_TRACE_EVENT_TYPES, type DocsAgentTraceContext, type DocsAgentTraceEventInput, type DocsAgentTraceEventType, type DocsAgentTraceStatus, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsAskAIFeedbackConfig, type DocsAskAIFeedbackData, type DocsAskAIFeedbackMessage, type DocsAskAIFeedbackValue, type DocsAskAIMcpConfig, type DocsCloudAnalyticsOptions, type DocsMcpHttpHandlers, type DocsMcpNavigationNode, type DocsMcpNavigationTree, type DocsMcpPage, type DocsMcpResolvedConfig, type DocsMcpSource, type DocsObservabilityConfig, type DocsObservabilityEvent, type DocsObservabilityEventInput, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchQuery, type DocsSearchResult, type DocsSearchSourcePage, type DocsSitemapFormat, type DocsSitemapManifest, type DocsSitemapManifestPage, type DocsSitemapPageInput, type DocsSitemapResolvedConfig, type McpDocsSearchConfig, type PromptAction, type PromptProviderChoice, type ResolvedApiReferenceConfig, type ResolvedDocsAnalyticsConfig, type ResolvedDocsObservabilityConfig, type SerializeOpenDocsProviderOptions, type SerializedOpenDocsProvider, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsAskAIContext, buildDocsSearchDocuments, buildDocsSitemapManifest, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAnalytics, createDocsMcpHttpHandler, createDocsMcpServer, createDocsSitemapResponse, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, formatDocsAskAIPackageHints, inferDocsAskAIPackageHints, isApiReferenceOpenApiRequest, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, readDocsSitemapManifest, readDocsSitemapManifestFromContentMap, renderDocsSitemapMarkdown, renderDocsSitemapXml, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveApiReferenceRenderer, resolveAskAISearchRequestConfig, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolveDocsObservabilityConfig, resolveDocsSitemapConfig, resolveDocsSitemapPageLastmod, resolveDocsSitemapRequest, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProvider, serializeOpenDocsProviders, toDocsSitemapMarkdownUrl };
58
+ export { type ApiReferenceFramework, type ApiReferenceOpenApiDiscovery, type ApiReferenceRenderer, type ApiReferenceRoute, DEFAULT_API_REFERENCE_OPENAPI_ROUTE, DEFAULT_OPEN_DOCS_PROMPT, DEFAULT_OPEN_DOCS_PROVIDER_IDS, DEFAULT_OPEN_DOCS_TARGET, DEFAULT_PROMPT_PROVIDER_TEMPLATES, DEFAULT_SITEMAP_MANIFEST_PATH, DEFAULT_SITEMAP_MD_ROUTE, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, DEFAULT_SITEMAP_XML_ROUTE, DOCS_AGENT_TRACE_EVENT_TYPES, type DocsAgentTraceContext, type DocsAgentTraceEventInput, type DocsAgentTraceEventType, type DocsAgentTraceStatus, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsAskAIFeedbackConfig, type DocsAskAIFeedbackData, type DocsAskAIFeedbackMessage, type DocsAskAIFeedbackValue, type DocsAskAIMcpConfig, type DocsCloudAnalyticsOptions, type DocsMcpCodeExample, type DocsMcpHttpHandlers, type DocsMcpNavigationNode, type DocsMcpNavigationTree, type DocsMcpPage, type DocsMcpResolvedConfig, type DocsMcpSource, type DocsObservabilityConfig, type DocsObservabilityEvent, type DocsObservabilityEventInput, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchQuery, type DocsSearchResult, type DocsSearchSourcePage, type DocsSitemapFormat, type DocsSitemapManifest, type DocsSitemapManifestPage, type DocsSitemapPageInput, type DocsSitemapResolvedConfig, type McpDocsSearchConfig, type PromptAction, type PromptProviderChoice, type ResolvedApiReferenceConfig, type ResolvedDocsAnalyticsConfig, type ResolvedDocsObservabilityConfig, type SerializeOpenDocsProviderOptions, type SerializedOpenDocsProvider, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsAskAIContext, buildDocsSearchDocuments, buildDocsSitemapManifest, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAnalytics, createDocsMcpHttpHandler, createDocsMcpServer, createDocsSitemapResponse, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, formatDocsAskAIPackageHints, inferDocsAskAIPackageHints, isApiReferenceOpenApiRequest, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, readDocsSitemapManifest, readDocsSitemapManifestFromContentMap, renderDocsSitemapMarkdown, renderDocsSitemapXml, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveApiReferenceRenderer, resolveAskAISearchRequestConfig, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolveDocsObservabilityConfig, resolveDocsSitemapConfig, resolveDocsSitemapPageLastmod, resolveDocsSitemapRequest, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProvider, serializeOpenDocsProviders, toDocsSitemapMarkdownUrl };
@@ -987,6 +987,8 @@ interface DocsMcpToolsConfig {
987
987
  searchDocs?: boolean;
988
988
  /** Expose a `get_navigation` tool for the docs tree. */
989
989
  getNavigation?: boolean;
990
+ /** Expose a `get_code_examples` tool for fenced code blocks and their metadata. */
991
+ getCodeExamples?: boolean;
990
992
  }
991
993
  /**
992
994
  * Built-in MCP server configuration.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/docs",
3
- "version": "0.1.115",
3
+ "version": "0.1.116",
4
4
  "description": "Modern, flexible MDX-based docs framework — core types, config, and CLI",
5
5
  "keywords": [
6
6
  "docs",