@farming-labs/theme 0.2.114 → 0.2.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.
@@ -82,6 +82,8 @@ interface DocsAPIOptions {
82
82
  agent?: DocsConfig["agent"];
83
83
  /** @internal Build-time Agent Skills snapshot supplied by framework adapters. */
84
84
  _preloadedAgentSkills?: readonly DocsPublishedAgentSkill[];
85
+ /** @internal Build-time root document snapshot (skill.md, AGENTS.md, AGENT.md) supplied by framework adapters. */
86
+ _preloadedRootDocuments?: Readonly<Record<string, string>>;
85
87
  }
86
88
  interface DocsMCPAPIOptions {
87
89
  rootDir?: string;
@@ -103,6 +105,8 @@ interface DocsMCPAPIOptions {
103
105
  feedback?: DocsConfig["feedback"];
104
106
  /** @internal Build-time Agent Skills snapshot supplied by framework adapters. */
105
107
  _preloadedAgentSkills?: readonly DocsPublishedAgentSkill[];
108
+ /** @internal Build-time root document snapshot (skill.md, AGENTS.md, AGENT.md) supplied by framework adapters. */
109
+ _preloadedRootDocuments?: Readonly<Record<string, string>>;
106
110
  }
107
111
  type LlmsTxtOptions = LlmsTxtConfig;
108
112
  /**
package/dist/docs-api.mjs CHANGED
@@ -4,8 +4,8 @@ import { BoundedRouteCache } from "./bounded-route-cache.mjs";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import matter from "gray-matter";
7
- import { DEFAULT_A2A_AGENT_CARD_ROUTE, DEFAULT_AGENT_SKILLS_ARCHIVE_ROUTE_PATTERN, DEFAULT_AGENT_SKILLS_INDEX_ROUTE, DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, DEFAULT_API_CATALOG_ROUTE, DEFAULT_LEGACY_SKILLS_INDEX_ROUTE, DEFAULT_SITEMAP_MD_DOCS_ROUTE, DOCS_AGENT_MANIFEST_FORMAT, DOCS_AGENT_MANIFEST_SCHEMA_URI, DOCS_AGENT_MANIFEST_VERSION, DOCS_CONTENT_CHANGES_FORMAT, DOCS_CONTENT_CHANGES_RESPONSE_VALUE, DOCS_MARKDOWN_SECTION_INDEX_FORMAT, acceptsDocsMarkdown, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, buildDocsSearchFacets, compactDocsAgentDiscoverySpec, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCacheableResponse, createDocsContentChangeFeed, createDocsContentChangesHttpResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsContentChangesRequest, isDocsDiagnosticsRequest, normalizeDocsOkfTrustMetadataInput, normalizeDocsRelated, normalizePageAgentFrontmatter, performDocsSearch, performDocsSearchWithMetadata, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsContentChangesConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance } from "@farming-labs/docs";
8
- import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/server";
7
+ import { DEFAULT_A2A_AGENT_CARD_ROUTE, DEFAULT_AGENT_SKILLS_ARCHIVE_ROUTE_PATTERN, DEFAULT_AGENT_SKILLS_INDEX_ROUTE, DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, DEFAULT_API_CATALOG_ROUTE, DEFAULT_LEGACY_SKILLS_INDEX_ROUTE, DEFAULT_SITEMAP_MD_DOCS_ROUTE, DOCS_AGENT_MANIFEST_FORMAT, DOCS_AGENT_MANIFEST_SCHEMA_URI, DOCS_AGENT_MANIFEST_VERSION, DOCS_CONTENT_CHANGES_FORMAT, DOCS_CONTENT_CHANGES_RESPONSE_VALUE, DOCS_MARKDOWN_SECTION_INDEX_FORMAT, acceptsDocsMarkdown, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, buildDocsSearchFacets, compactDocsAgentDiscoverySpec, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCacheableResponse, createDocsContentChangeFeed, createDocsContentChangesHttpResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsContentChangesRequest, isDocsDiagnosticsRequest, normalizeDocsOkfTrustMetadataInput, normalizeDocsRelated, normalizePageAgentFrontmatter, performDocsSearch, performDocsSearchWithMetadata, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsContentChangesConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance, withDocsOpenApiOperationCounts } from "@farming-labs/docs";
8
+ import { buildApiReferenceOpenApiDocumentAsync, buildApiReferenceOperationPagesAsync, createApiReferenceOperationMarkdownResponse, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/server";
9
9
 
10
10
  //#region src/docs-api.ts
11
11
  /**
@@ -396,6 +396,10 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, con
396
396
  source: openapi.source ?? null,
397
397
  specUrl: openapi.specUrl ?? null,
398
398
  apiReferencePath: openapi.apiReferencePath ?? null,
399
+ versions: openapi.versions?.map((version) => ({
400
+ ...version,
401
+ url: `${apiRoute}?format=openapi&version=${encodeURIComponent(version.id)}`
402
+ })) ?? [],
399
403
  format: "OpenAPI 3.1"
400
404
  },
401
405
  search: {
@@ -1451,7 +1455,7 @@ function renderAgentsDocument({ origin, entry, apiRoute, apiCatalog, search, con
1451
1455
  lines.push("", "## Framework Maintenance", "- For @farming-labs/docs projects, keep the framework package current before debugging missing agent surfaces.", "", "```sh", "npx @farming-labs/docs@latest upgrade --latest", "```", "", "- For framework setup, configuration, CLI, Ask AI, page actions, or theme work, install the reusable Skills pack:", "", "```sh", "npx skills add farming-labs/docs", "```");
1452
1456
  return lines.join("\n");
1453
1457
  }
1454
- function createRootDocumentReader(rootDir, fileNames) {
1458
+ function createRootDocumentReader(rootDir, fileNames, preloadedDocuments) {
1455
1459
  let cached;
1456
1460
  return function readRootDocument() {
1457
1461
  for (const fileName of fileNames) {
@@ -1479,6 +1483,10 @@ function createRootDocumentReader(rootDir, fileNames) {
1479
1483
  }
1480
1484
  }
1481
1485
  cached = void 0;
1486
+ if (preloadedDocuments) for (const fileName of fileNames) {
1487
+ const content = preloadedDocuments[fileName];
1488
+ if (typeof content === "string") return content;
1489
+ }
1482
1490
  return null;
1483
1491
  };
1484
1492
  }
@@ -2507,11 +2515,11 @@ function readApiReferenceConfig(root) {
2507
2515
  const routeRootMatch = block.match(/routeRoot\s*:\s*["']([^"']+)["']/);
2508
2516
  const specUrlMatch = block.match(/specUrl\s*:\s*["']([^"']+)["']/);
2509
2517
  const catalogTargetsMatch = block.match(/catalogTargets\s*:\s*\[([\s\S]*?)\]/);
2510
- const rendererMatch = block.match(/renderer\s*:\s*["'](fumadocs|scalar)["']/);
2518
+ const rendererMatch = block.match(/renderer\s*:\s*["'](farming-labs|fumadocs|scalar)["']/);
2511
2519
  const excludeMatch = block.match(/exclude\s*:\s*\[([\s\S]*?)\]/);
2512
2520
  const catalogTargets = catalogTargetsMatch?.[1] === void 0 ? void 0 : Array.from(catalogTargetsMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
2513
2521
  const exclude = excludeMatch?.[1] === void 0 ? void 0 : Array.from(excludeMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
2514
- const renderer = rendererMatch?.[1] === "fumadocs" || rendererMatch?.[1] === "scalar" ? rendererMatch[1] : void 0;
2522
+ const renderer = rendererMatch?.[1] === "farming-labs" || rendererMatch?.[1] === "fumadocs" || rendererMatch?.[1] === "scalar" ? rendererMatch[1] : void 0;
2515
2523
  return {
2516
2524
  enabled: enabledMatch ? enabledMatch[1] === "true" : true,
2517
2525
  path: pathMatch?.[1],
@@ -2555,8 +2563,8 @@ function generateLlmsTxt(indexes, options) {
2555
2563
  */
2556
2564
  function createDocsAPI(options) {
2557
2565
  const root = options?.rootDir ?? process.cwd();
2558
- const readRootSkillDocument = createRootDocumentReader(root, ["skill.md"]);
2559
- const readRootAgentsDocument = createRootDocumentReader(root, ["AGENTS.md", "AGENT.md"]);
2566
+ const readRootSkillDocument = createRootDocumentReader(root, ["skill.md"], options?._preloadedRootDocuments);
2567
+ const readRootAgentsDocument = createRootDocumentReader(root, ["AGENTS.md", "AGENT.md"], options?._preloadedRootDocuments);
2560
2568
  let publishedAgentSkills;
2561
2569
  function getPublishedAgentSkills() {
2562
2570
  if (!publishedAgentSkills) publishedAgentSkills = Array.isArray(options?._preloadedAgentSkills) ? Promise.resolve([...options._preloadedAgentSkills]) : resolveConfiguredAgentSkills(options?.agent?.skills, { rootDir: root });
@@ -2733,6 +2741,7 @@ function createDocsAPI(options) {
2733
2741
  };
2734
2742
  }
2735
2743
  const indexesByLocale = /* @__PURE__ */ new Map();
2744
+ const apiOperationPagesByLocale = /* @__PURE__ */ new Map();
2736
2745
  const llmsCache = new BoundedRouteCache(MAX_LLMS_CACHE_ROUTES_PER_LOCALE);
2737
2746
  const generatedAgentsCache = new BoundedRouteCache(MAX_LLMS_CACHE_ROUTES_PER_LOCALE);
2738
2747
  const generatedSkillCache = new BoundedRouteCache(MAX_LLMS_CACHE_ROUTES_PER_LOCALE);
@@ -2756,6 +2765,19 @@ function createDocsAPI(options) {
2756
2765
  indexesByLocale.set(key, next);
2757
2766
  return next;
2758
2767
  }
2768
+ function getApiOperationSearchPages(ctx, baseUrl) {
2769
+ const key = `${ctx.locale ?? "__default__"}\0${baseUrl}`;
2770
+ const cached = apiOperationPagesByLocale.get(key);
2771
+ if (cached) return cached;
2772
+ const next = buildApiReferenceOperationPagesAsync(apiReferenceDocsConfig, {
2773
+ framework: "next",
2774
+ rootDir: root,
2775
+ baseUrl,
2776
+ locale: ctx.locale
2777
+ });
2778
+ apiOperationPagesByLocale.set(key, next);
2779
+ return next;
2780
+ }
2759
2781
  function getMarkdownSources(ctx) {
2760
2782
  const key = ctx.locale ?? "__default__";
2761
2783
  const cached = markdownSourcesByLocale.get(key);
@@ -2814,10 +2836,12 @@ function createDocsAPI(options) {
2814
2836
  };
2815
2837
  return null;
2816
2838
  }
2817
- function getLlmsContent(ctx, apiRoute) {
2818
- const cached = llmsCache.get(ctx.locale, apiRoute);
2839
+ async function getLlmsContent(ctx, apiRoute, baseUrl) {
2840
+ const cacheKey = `${apiRoute}\0${baseUrl}`;
2841
+ const cached = llmsCache.get(ctx.locale, cacheKey);
2819
2842
  if (cached) return cached;
2820
- const next = generateLlmsTxt(getIndexes(ctx), {
2843
+ const operationPages = await getApiOperationSearchPages(ctx, baseUrl);
2844
+ const next = generateLlmsTxt([...getIndexes(ctx), ...operationPages], {
2821
2845
  siteTitle: llmsConfig.siteTitle ?? "Documentation",
2822
2846
  siteDescription: llmsConfig.siteDescription,
2823
2847
  baseUrl: llmsConfig.baseUrl ?? "",
@@ -2825,9 +2849,9 @@ function createDocsAPI(options) {
2825
2849
  maxChars: llmsConfig.maxChars,
2826
2850
  sections: llmsConfig.sections,
2827
2851
  apiCatalog: apiCatalogEnabled,
2828
- openapi: openapiDiscovery
2852
+ openapi: withDocsOpenApiOperationCounts(openapiDiscovery, operationPages)
2829
2853
  });
2830
- llmsCache.set(ctx.locale, apiRoute, next);
2854
+ llmsCache.set(ctx.locale, cacheKey, next);
2831
2855
  return next;
2832
2856
  }
2833
2857
  function getGeneratedAgentsDocument(origin, apiRoute) {
@@ -2873,13 +2897,14 @@ function createDocsAPI(options) {
2873
2897
  generatedSkillCache.set(void 0, cacheKey, next);
2874
2898
  return next;
2875
2899
  }
2876
- async function resolveStandardsResponse(request, url) {
2900
+ async function resolveStandardsResponse(request, url, ctx) {
2877
2901
  const apiRoute = resolveDocsRequestApiRoute(url, configuredApiRouteInput);
2878
2902
  const resolved = resolveDocsStandardsDiscoveryRequest(url, { apiRoute });
2879
2903
  if (!resolved) return null;
2880
2904
  const method = request.method.toUpperCase();
2881
2905
  const needsSkill = (method === "GET" || method === "HEAD") && resolved.kind !== "api-catalog";
2882
2906
  const fallbackSkillDocument = needsSkill ? getGeneratedSkillDocument(url.origin, apiRoute) : "";
2907
+ const operationPages = ctx && resolved.kind === "api-catalog" ? await getApiOperationSearchPages(ctx, markdownMetadataBaseUrl || url.origin) : [];
2883
2908
  return createDocsStandardsDiscoveryResponse({
2884
2909
  request,
2885
2910
  preferredSkillDocument: needsSkill ? readRootSkillDocument() : null,
@@ -2899,7 +2924,7 @@ function createDocsAPI(options) {
2899
2924
  llms: llmsConfig,
2900
2925
  sitemap: sitemapConfig,
2901
2926
  robots: robotsConfig,
2902
- openapi: openapiDiscovery,
2927
+ openapi: resolved.kind === "api-catalog" ? withDocsOpenApiOperationCounts(openapiDiscovery, operationPages) : openapiDiscovery,
2903
2928
  markdown: {
2904
2929
  acceptHeader: true,
2905
2930
  signatureAgentHeader: true
@@ -2932,7 +2957,7 @@ function createDocsAPI(options) {
2932
2957
  "Cache-Control": "public, max-age=0, s-maxage=3600",
2933
2958
  "X-Robots-Tag": "noindex"
2934
2959
  } });
2935
- const standardsResponse = await resolveStandardsResponse(request, url);
2960
+ const standardsResponse = await resolveStandardsResponse(request, url, ctx);
2936
2961
  if (standardsResponse) return standardsResponse;
2937
2962
  if (resolveAgentSpecRequest(url)) {
2938
2963
  await emitDocsAnalyticsEvent(analytics, {
@@ -2946,6 +2971,7 @@ function createDocsAPI(options) {
2946
2971
  method: requestMethod
2947
2972
  }
2948
2973
  });
2974
+ const operationPages = await getApiOperationSearchPages(ctx, markdownMetadataBaseUrl || url.origin);
2949
2975
  const fullSpec = buildAgentSpec({
2950
2976
  origin: url.origin,
2951
2977
  entry,
@@ -2959,7 +2985,7 @@ function createDocsAPI(options) {
2959
2985
  llms: llmsConfig,
2960
2986
  sitemap: sitemapConfig,
2961
2987
  robots: robotsConfig,
2962
- openapi: openapiDiscovery,
2988
+ openapi: withDocsOpenApiOperationCounts(openapiDiscovery, operationPages),
2963
2989
  publishedSkills: [await resolveDocsPublishedAgentSkill({
2964
2990
  preferredDocument: readRootSkillDocument(),
2965
2991
  fallbackDocument: getGeneratedSkillDocument(url.origin, requestApiRoute)
@@ -3012,7 +3038,8 @@ function createDocsAPI(options) {
3012
3038
  const document = await buildApiReferenceOpenApiDocumentAsync(apiReferenceDocsConfig, {
3013
3039
  framework: "next",
3014
3040
  rootDir: root,
3015
- baseUrl: url.origin
3041
+ baseUrl: url.origin,
3042
+ version: url.searchParams.get("version")?.trim() || void 0
3016
3043
  });
3017
3044
  return new Response(JSON.stringify(document, null, 2), { headers: {
3018
3045
  "Content-Type": "application/json; charset=utf-8",
@@ -3110,6 +3137,20 @@ function createDocsAPI(options) {
3110
3137
  manifest: readDocsSitemapManifest(root, sitemapConfig)
3111
3138
  });
3112
3139
  if (sitemapResponse) return sitemapResponse;
3140
+ const operationMarkdownResponse = await createApiReferenceOperationMarkdownResponse(apiReferenceDocsConfig, {
3141
+ request,
3142
+ framework: "next",
3143
+ rootDir: root,
3144
+ baseUrl: url.origin,
3145
+ origin: markdownMetadataBaseUrl || url.origin,
3146
+ locale: ctx.locale,
3147
+ apiRoute: requestApiRoute,
3148
+ pages: getIndexes(ctx).map((page) => withPublicDocsUrl(page, ctx)),
3149
+ operationPages: () => getApiOperationSearchPages(ctx, markdownMetadataBaseUrl || url.origin),
3150
+ sitemap: sitemapConfig,
3151
+ okf: options?.agent?.okf
3152
+ });
3153
+ if (operationMarkdownResponse) return operationMarkdownResponse;
3113
3154
  const markdownRequest = resolveMarkdownRequest(entry, url, request) ?? resolvePublicMarkdownRequest(entry, docsPath, url, request);
3114
3155
  if (markdownRequest) {
3115
3156
  const markdownOrigin = markdownMetadataBaseUrl || url.origin;
@@ -3212,7 +3253,7 @@ function createDocsAPI(options) {
3212
3253
  "X-Robots-Tag": "noindex"
3213
3254
  }
3214
3255
  });
3215
- const selected = selectDocsLlmsTxtContent(getLlmsContent(ctx, requestApiRoute), llmsRequest);
3256
+ const selected = selectDocsLlmsTxtContent(await getLlmsContent(ctx, requestApiRoute, markdownMetadataBaseUrl || url.origin), llmsRequest);
3216
3257
  if (!selected) return new Response("Not Found", {
3217
3258
  status: 404,
3218
3259
  headers: {
@@ -3263,8 +3304,9 @@ function createDocsAPI(options) {
3263
3304
  }
3264
3305
  const { filters, structured, explain, facets, facet, cursor, limit } = searchRequest;
3265
3306
  if (!query && !structured && !facets) return new Response("[]", { headers: { "Content-Type": "application/json" } });
3307
+ const operationPages = await getApiOperationSearchPages(ctx, markdownMetadataBaseUrl || url.origin);
3266
3308
  const searchOptions = {
3267
- pages: getIndexes(ctx),
3309
+ pages: [...getIndexes(ctx), ...operationPages],
3268
3310
  query: query ?? "",
3269
3311
  search: resolveSearchRequestConfig(searchConfig, request.url, { localMcp: rawMcpConfig }),
3270
3312
  audience,
@@ -3400,7 +3442,8 @@ function createDocsAPI(options) {
3400
3442
  return Response.json({ error: "AI is not enabled. Set `ai: { enabled: true }` in your docs.config to enable it." }, { status: 404 });
3401
3443
  }
3402
3444
  const ctx = resolveContextFromRequest(request);
3403
- return handleAskAI(request, getIndexes(ctx), aiConfig, cloudConfig, resolveAskAISearchRequestConfig({
3445
+ const operationPages = await getApiOperationSearchPages(ctx, markdownMetadataBaseUrl || url.origin);
3446
+ return handleAskAI(request, [...getIndexes(ctx), ...operationPages], aiConfig, cloudConfig, resolveAskAISearchRequestConfig({
3404
3447
  search: searchConfig,
3405
3448
  useMcp: aiConfig.useMcp,
3406
3449
  mcpEndpoint: mcpConfig.route,
@@ -3436,7 +3479,7 @@ function createDocsAPI(options) {
3436
3479
  */
3437
3480
  function createDocsMCPAPI(options = {}) {
3438
3481
  const rootDir = options.rootDir ?? process.cwd();
3439
- const readRootSkillDocument = createRootDocumentReader(rootDir, ["skill.md"]);
3482
+ const readRootSkillDocument = createRootDocumentReader(rootDir, ["skill.md"], options._preloadedRootDocuments);
3440
3483
  const entry = options.entry ?? readEntry(rootDir);
3441
3484
  const appDir = getNextAppDir(rootDir);
3442
3485
  const contentDir = options.contentDir ?? path.join(appDir, entry);
@@ -3465,9 +3508,26 @@ function createDocsMCPAPI(options = {}) {
3465
3508
  }), ...configured];
3466
3509
  }
3467
3510
  };
3511
+ const apiReferenceBaseUrl = options.baseUrl?.trim() || resolveDocsMetadataBaseUrl(options) || void 0;
3512
+ const apiOperationPagesByBaseUrl = /* @__PURE__ */ new Map();
3513
+ function getApiOperationPages(baseUrl) {
3514
+ const key = baseUrl ?? "__default__";
3515
+ const cached = apiOperationPagesByBaseUrl.get(key);
3516
+ if (cached) return cached;
3517
+ const pages = buildApiReferenceOperationPagesAsync(options, {
3518
+ framework: "next",
3519
+ rootDir,
3520
+ baseUrl
3521
+ });
3522
+ apiOperationPagesByBaseUrl.set(key, pages);
3523
+ return pages;
3524
+ }
3468
3525
  const mcpApiReference = resolveApiReferenceConfig(options.apiReference).mcp;
3469
3526
  const handlers = createDocsMcpHttpHandler({
3470
3527
  source,
3528
+ apiReference: { getPages(_locale, context) {
3529
+ return getApiOperationPages(apiReferenceBaseUrl || (context?.request ? new URL(context.request.url).origin : void 0));
3530
+ } },
3471
3531
  mcp: mcpConfig,
3472
3532
  okf: options.agent?.okf,
3473
3533
  openapi: mcpApiReference ? {
@@ -3475,7 +3535,7 @@ function createDocsMCPAPI(options = {}) {
3475
3535
  document: () => buildApiReferenceOpenApiDocumentAsync(options, {
3476
3536
  framework: "next",
3477
3537
  rootDir,
3478
- baseUrl: options.baseUrl?.trim() || resolveDocsMetadataBaseUrl(options) || void 0
3538
+ baseUrl: apiReferenceBaseUrl
3479
3539
  })
3480
3540
  } : void 0,
3481
3541
  contentChanges: options.agent?.contentChanges,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.2.114",
3
+ "version": "0.2.116",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -161,7 +161,7 @@
161
161
  "tsdown": "^0.20.3",
162
162
  "typescript": "^5.9.3",
163
163
  "vitest": "^4.1.8",
164
- "@farming-labs/docs": "0.2.114"
164
+ "@farming-labs/docs": "0.2.116"
165
165
  },
166
166
  "peerDependencies": {
167
167
  "@farming-labs/docs": ">=0.0.1",