@farming-labs/theme 0.2.122 → 0.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/docs-api.mjs CHANGED
@@ -3,7 +3,7 @@ import { getNextAppDir } from "./get-app-dir.mjs";
3
3
  import { BoundedRouteCache } from "./bounded-route-cache.mjs";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
- 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, parseDocsAgentFeedbackData, performDocsSearch, performDocsSearchWithMetadata, readDocsJsonBody, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsContentChangesConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveDocsSitemapConfig, resolveDocsSitemapPageLastmod, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance, withDocsOpenApiOperationCounts } from "@farming-labs/docs";
6
+ 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, createDocsSitemapLastmodResolver, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsContentChangesRequest, isDocsDiagnosticsRequest, normalizeDocsOkfTrustMetadataInput, normalizeDocsRelated, normalizePageAgentFrontmatter, parseDocsAgentFeedbackData, performDocsSearch, performDocsSearchWithMetadata, readDocsJsonBody, 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";
7
7
  import { buildApiReferenceOpenApiDocumentAsync, buildApiReferenceOperationPagesAsync, createApiReferenceOperationMarkdownResponse, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/runtime";
8
8
  import matter from "gray-matter";
9
9
 
@@ -35,6 +35,35 @@ const FILE_EXTS = [
35
35
  "jsx",
36
36
  "js"
37
37
  ];
38
+ /** One lazy filesystem snapshot per handler factory, including missing/unreadable files. */
39
+ function createDocsConfigReader(root) {
40
+ const files = /* @__PURE__ */ new Map();
41
+ return (extension) => {
42
+ let result = files.get(extension);
43
+ if (!result) {
44
+ const configPath = path.join(
45
+ /* turbopackIgnore: true */
46
+ root,
47
+ `docs.config.${extension}`
48
+ );
49
+ try {
50
+ result = { content: fs.existsSync(
51
+ /* turbopackIgnore: true */
52
+ configPath
53
+ ) ? fs.readFileSync(
54
+ /* turbopackIgnore: true */
55
+ configPath,
56
+ "utf-8"
57
+ ) : void 0 };
58
+ } catch (error) {
59
+ result = { error };
60
+ }
61
+ files.set(extension, result);
62
+ }
63
+ if ("error" in result) throw result.error;
64
+ return result.content;
65
+ };
66
+ }
38
67
  const DEFAULT_DOCS_API_ROUTE = "/api/docs";
39
68
  const MAX_LLMS_CACHE_ROUTES_PER_LOCALE = 8;
40
69
  const DEFAULT_DOCS_CLOUD_API_BASE_URL = "https://api.farming-labs.dev";
@@ -46,8 +75,8 @@ const DEFAULT_MCP_PUBLIC_ROUTE = "/mcp";
46
75
  const DEFAULT_MCP_WELL_KNOWN_ROUTE = "/.well-known/mcp";
47
76
  const DEFAULT_LLMS_TXT_ROUTE = "/llms.txt";
48
77
  const DEFAULT_LLMS_FULL_TXT_ROUTE = "/llms-full.txt";
49
- function withSitemapLastModified(page, manifest) {
50
- const lastmod = resolveDocsSitemapPageLastmod(manifest, page.url);
78
+ function withSitemapLastModified(page, resolveLastmod) {
79
+ const lastmod = resolveLastmod(page.url);
51
80
  if (!lastmod) return page;
52
81
  const lastModified = `${lastmod}T00:00:00.000Z`;
53
82
  const hasExplicitAgentSource = page.agentRawContent !== void 0 || page.agentContent !== void 0;
@@ -629,195 +658,128 @@ function validateAgentFeedbackPayload(value, schema, valuePath = "payload") {
629
658
  return;
630
659
  }
631
660
  }
632
- function readEntry(root) {
633
- for (const ext of FILE_EXTS) {
634
- const configPath = path.join(
635
- /* turbopackIgnore: true */
636
- root,
637
- `docs.config.${ext}`
638
- );
639
- if (fs.existsSync(
640
- /* turbopackIgnore: true */
641
- configPath
642
- )) try {
643
- const match = fs.readFileSync(
644
- /* turbopackIgnore: true */
645
- configPath,
646
- "utf-8"
647
- ).match(/entry\s*:\s*["']([^"']+)["']/);
648
- if (match) return match[1];
649
- } catch {}
650
- }
661
+ function readEntry(readConfig) {
662
+ for (const ext of FILE_EXTS) try {
663
+ const content = readConfig(ext);
664
+ if (content === void 0) continue;
665
+ const match = content.match(/entry\s*:\s*["']([^"']+)["']/);
666
+ if (match) return match[1];
667
+ } catch {}
651
668
  return "docs";
652
669
  }
653
- function readI18nConfig(root) {
654
- for (const ext of FILE_EXTS) {
655
- const configPath = path.join(
656
- /* turbopackIgnore: true */
657
- root,
658
- `docs.config.${ext}`
659
- );
660
- if (!fs.existsSync(
661
- /* turbopackIgnore: true */
662
- configPath
663
- )) continue;
664
- try {
665
- const content = fs.readFileSync(
666
- /* turbopackIgnore: true */
667
- configPath,
668
- "utf-8"
669
- );
670
- if (!content.includes("i18n")) continue;
671
- const localesMatch = content.match(/i18n\s*:\s*\{[\s\S]*?locales\s*:\s*\[([^\]]+)\]/);
672
- if (!localesMatch) continue;
673
- const locales = localesMatch[1].split(",").map((l) => l.trim().replace(/^['"`]|['"`]$/g, "")).filter(Boolean);
674
- if (locales.length === 0) continue;
675
- return {
676
- locales,
677
- defaultLocale: content.match(/i18n\s*:\s*\{[\s\S]*?defaultLocale\s*:\s*["']([^"']+)["']/)?.[1]
678
- };
679
- } catch {}
680
- }
670
+ function readI18nConfig(readConfig) {
671
+ for (const ext of FILE_EXTS) try {
672
+ const content = readConfig(ext);
673
+ if (content === void 0) continue;
674
+ if (!content.includes("i18n")) continue;
675
+ const localesMatch = content.match(/i18n\s*:\s*\{[\s\S]*?locales\s*:\s*\[([^\]]+)\]/);
676
+ if (!localesMatch) continue;
677
+ const locales = localesMatch[1].split(",").map((l) => l.trim().replace(/^['"`]|['"`]$/g, "")).filter(Boolean);
678
+ if (locales.length === 0) continue;
679
+ return {
680
+ locales,
681
+ defaultLocale: content.match(/i18n\s*:\s*\{[\s\S]*?defaultLocale\s*:\s*["']([^"']+)["']/)?.[1]
682
+ };
683
+ } catch {}
681
684
  return null;
682
685
  }
683
686
  /**
684
687
  * Read AI config from docs.config by parsing the file for the `ai` block.
685
688
  * This avoids importing the config (which may use JSX/React).
686
689
  */
687
- function readAIConfig(root) {
688
- for (const ext of FILE_EXTS) {
689
- const configPath = path.join(
690
- /* turbopackIgnore: true */
691
- root,
692
- `docs.config.${ext}`
693
- );
694
- if (fs.existsSync(
695
- /* turbopackIgnore: true */
696
- configPath
697
- )) try {
698
- const content = fs.readFileSync(
699
- /* turbopackIgnore: true */
700
- configPath,
701
- "utf-8"
702
- );
703
- if (!content.includes("ai:") && !content.includes("ai :")) return {};
704
- const enabledMatch = content.match(/ai\s*:\s*\{[^}]*enabled\s*:\s*(true|false)/s);
705
- if (enabledMatch && enabledMatch[1] === "false") return {};
706
- const providerMatch = content.match(/ai\s*:\s*\{[^}]*provider\s*:\s*["']([^"']+)["']/s);
707
- const modelMatch = content.match(/ai\s*:\s*\{[^}]*model\s*:\s*["']([^"']+)["']/s);
708
- const baseUrlMatch = content.match(/ai\s*:\s*\{[^}]*baseUrl\s*:\s*["']([^"']+)["']/s);
709
- const apiKeyMatch = content.match(/ai\s*:\s*\{[^}]*apiKey\s*:\s*process\.env\.(\w+)/s);
710
- const maxResultsMatch = content.match(/ai\s*:\s*\{[^}]*maxResults\s*:\s*(\d+)/s);
711
- const useMcpMatch = content.match(/ai\s*:\s*\{[^}]*useMcp\s*:\s*(true|false)/s);
712
- const streamMatch = content.match(/ai\s*:\s*\{[^}]*stream\s*:\s*(true|false)/s);
713
- const systemPromptMatch = content.match(/ai\s*:\s*\{[^}]*systemPrompt\s*:\s*["'`]([^"'`]+)["'`]/s);
714
- const packageNameMatch = content.match(/ai\s*:\s*\{[^}]*packageName\s*:\s*["'`]([^"'`]+)["'`]/s);
715
- const docsUrlMatch = content.match(/ai\s*:\s*\{[^}]*docsUrl\s*:\s*["'`]([^"'`]+)["'`]/s);
716
- return {
717
- enabled: true,
718
- provider: providerMatch?.[1],
719
- model: modelMatch?.[1],
720
- baseUrl: baseUrlMatch?.[1],
721
- apiKey: apiKeyMatch?.[1] ? process.env[apiKeyMatch[1]] : void 0,
722
- maxResults: maxResultsMatch ? parseInt(maxResultsMatch[1], 10) : void 0,
723
- useMcp: useMcpMatch ? useMcpMatch[1] === "true" : void 0,
724
- stream: streamMatch ? streamMatch[1] === "true" : void 0,
725
- systemPrompt: systemPromptMatch?.[1],
726
- packageName: packageNameMatch?.[1],
727
- docsUrl: docsUrlMatch?.[1]
728
- };
729
- } catch {}
730
- }
690
+ function readAIConfig(readConfig) {
691
+ for (const ext of FILE_EXTS) try {
692
+ const content = readConfig(ext);
693
+ if (content === void 0) continue;
694
+ if (!content.includes("ai:") && !content.includes("ai :")) return {};
695
+ const enabledMatch = content.match(/ai\s*:\s*\{[^}]*enabled\s*:\s*(true|false)/s);
696
+ if (enabledMatch && enabledMatch[1] === "false") return {};
697
+ const providerMatch = content.match(/ai\s*:\s*\{[^}]*provider\s*:\s*["']([^"']+)["']/s);
698
+ const modelMatch = content.match(/ai\s*:\s*\{[^}]*model\s*:\s*["']([^"']+)["']/s);
699
+ const baseUrlMatch = content.match(/ai\s*:\s*\{[^}]*baseUrl\s*:\s*["']([^"']+)["']/s);
700
+ const apiKeyMatch = content.match(/ai\s*:\s*\{[^}]*apiKey\s*:\s*process\.env\.(\w+)/s);
701
+ const maxResultsMatch = content.match(/ai\s*:\s*\{[^}]*maxResults\s*:\s*(\d+)/s);
702
+ const useMcpMatch = content.match(/ai\s*:\s*\{[^}]*useMcp\s*:\s*(true|false)/s);
703
+ const streamMatch = content.match(/ai\s*:\s*\{[^}]*stream\s*:\s*(true|false)/s);
704
+ const systemPromptMatch = content.match(/ai\s*:\s*\{[^}]*systemPrompt\s*:\s*["'`]([^"'`]+)["'`]/s);
705
+ const packageNameMatch = content.match(/ai\s*:\s*\{[^}]*packageName\s*:\s*["'`]([^"'`]+)["'`]/s);
706
+ const docsUrlMatch = content.match(/ai\s*:\s*\{[^}]*docsUrl\s*:\s*["'`]([^"'`]+)["'`]/s);
707
+ return {
708
+ enabled: true,
709
+ provider: providerMatch?.[1],
710
+ model: modelMatch?.[1],
711
+ baseUrl: baseUrlMatch?.[1],
712
+ apiKey: apiKeyMatch?.[1] ? process.env[apiKeyMatch[1]] : void 0,
713
+ maxResults: maxResultsMatch ? parseInt(maxResultsMatch[1], 10) : void 0,
714
+ useMcp: useMcpMatch ? useMcpMatch[1] === "true" : void 0,
715
+ stream: streamMatch ? streamMatch[1] === "true" : void 0,
716
+ systemPrompt: systemPromptMatch?.[1],
717
+ packageName: packageNameMatch?.[1],
718
+ docsUrl: docsUrlMatch?.[1]
719
+ };
720
+ } catch {}
731
721
  return {};
732
722
  }
733
- function readCloudConfig(root) {
734
- for (const ext of FILE_EXTS) {
735
- const configPath = path.join(
736
- /* turbopackIgnore: true */
737
- root,
738
- `docs.config.${ext}`
739
- );
740
- if (!fs.existsSync(
741
- /* turbopackIgnore: true */
742
- configPath
743
- )) continue;
744
- try {
745
- const content = fs.readFileSync(
746
- /* turbopackIgnore: true */
747
- configPath,
748
- "utf-8"
749
- );
750
- const sanitized = stripCommentsAndStrings(content);
751
- const configObject = extractRootConfigObject(content, sanitized);
752
- const cloudBlock = extractObjectLiteral(configObject?.content ?? content, configObject?.sanitized ?? sanitized, "cloud");
753
- if (!cloudBlock) continue;
754
- const cloudBlockSanitized = stripCommentsAndStrings(cloudBlock);
755
- const apiKeyBlock = extractObjectLiteral(cloudBlock, cloudBlockSanitized, "apiKey");
756
- const apiKeyEnv = apiKeyBlock ? readStringFromBlock(apiKeyBlock, "env") : void 0;
757
- const apiRoute = readTopLevelString(cloudBlock, cloudBlockSanitized, "apiRoute");
758
- return {
759
- ...apiKeyEnv ? { apiKey: { env: apiKeyEnv } } : {},
760
- ...apiRoute ? { apiRoute } : {}
761
- };
762
- } catch {}
763
- }
723
+ function readCloudConfig(readConfig) {
724
+ for (const ext of FILE_EXTS) try {
725
+ const content = readConfig(ext);
726
+ if (content === void 0) continue;
727
+ const sanitized = stripCommentsAndStrings(content);
728
+ const configObject = extractRootConfigObject(content, sanitized);
729
+ const cloudBlock = extractObjectLiteral(configObject?.content ?? content, configObject?.sanitized ?? sanitized, "cloud");
730
+ if (!cloudBlock) continue;
731
+ const cloudBlockSanitized = stripCommentsAndStrings(cloudBlock);
732
+ const apiKeyBlock = extractObjectLiteral(cloudBlock, cloudBlockSanitized, "apiKey");
733
+ const apiKeyEnv = apiKeyBlock ? readStringFromBlock(apiKeyBlock, "env") : void 0;
734
+ const apiRoute = readTopLevelString(cloudBlock, cloudBlockSanitized, "apiRoute");
735
+ return {
736
+ ...apiKeyEnv ? { apiKey: { env: apiKeyEnv } } : {},
737
+ ...apiRoute ? { apiRoute } : {}
738
+ };
739
+ } catch {}
764
740
  }
765
741
  const MCP_RUNTIME_SECURITY_CONFIG_ERROR = "MCP security is configured in docs.config, but createDocsMCPAPI cannot load executable security callbacks from source text. Import the live config and call createDocsMCPAPI(docsConfig), or pass an explicit mcp.security.authenticate callback. Refusing to create a public MCP endpoint.";
766
742
  var McpRuntimeSecurityConfigError = class extends Error {};
767
- function readMcpConfig(root, options = {}) {
768
- for (const ext of FILE_EXTS) {
769
- const configPath = path.join(
770
- /* turbopackIgnore: true */
771
- root,
772
- `docs.config.${ext}`
773
- );
774
- if (!fs.existsSync(
775
- /* turbopackIgnore: true */
776
- configPath
777
- )) continue;
778
- try {
779
- const content = fs.readFileSync(
780
- /* turbopackIgnore: true */
781
- configPath,
782
- "utf-8"
783
- );
784
- const sanitized = stripCommentsAndStrings(content);
785
- const configObject = extractRootConfigObject(content, sanitized);
786
- const scopedContent = configObject?.content ?? content;
787
- const scopedSanitized = configObject?.sanitized ?? sanitized;
788
- const booleanValue = readTopLevelBoolean(scopedSanitized, "mcp");
789
- if (booleanValue !== void 0) return booleanValue;
790
- const block = extractObjectLiteral(scopedContent, scopedSanitized, "mcp");
791
- if (!block) continue;
792
- if (options.rejectRuntimeSecurity) {
793
- const blockSanitized = stripCommentsAndStrings(block);
794
- const hasSecurity = findTopLevelPropertyIndex(blockSanitized, "security") !== -1;
795
- const hasAuthenticate = findTopLevelPropertyIndex(blockSanitized, "authenticate") !== -1;
796
- if (hasSecurity || hasAuthenticate) throw new McpRuntimeSecurityConfigError(MCP_RUNTIME_SECURITY_CONFIG_ERROR);
797
- }
798
- return {
799
- enabled: readBooleanFromBlock(block, "enabled"),
800
- route: readStringFromBlock(block, "route"),
801
- name: readStringFromBlock(block, "name"),
802
- version: readStringFromBlock(block, "version"),
803
- prompts: readBooleanFromBlock(block, "prompts"),
804
- tools: {
805
- listDocs: readBooleanFromBlock(block, "listDocs"),
806
- listPages: readBooleanFromBlock(block, "listPages"),
807
- listPageSections: readBooleanFromBlock(block, "listPageSections"),
808
- listTasks: readBooleanFromBlock(block, "listTasks"),
809
- readTask: readBooleanFromBlock(block, "readTask"),
810
- readPage: readBooleanFromBlock(block, "readPage"),
811
- searchDocs: readBooleanFromBlock(block, "searchDocs"),
812
- getNavigation: readBooleanFromBlock(block, "getNavigation"),
813
- getCodeExamples: readBooleanFromBlock(block, "getCodeExamples"),
814
- getConfigSchema: readBooleanFromBlock(block, "getConfigSchema"),
815
- getContext: readBooleanFromBlock(block, "getContext")
816
- }
817
- };
818
- } catch (error) {
819
- if (error instanceof McpRuntimeSecurityConfigError) throw error;
743
+ function readMcpConfig(readConfig, options = {}) {
744
+ for (const ext of FILE_EXTS) try {
745
+ const content = readConfig(ext);
746
+ if (content === void 0) continue;
747
+ const sanitized = stripCommentsAndStrings(content);
748
+ const configObject = extractRootConfigObject(content, sanitized);
749
+ const scopedContent = configObject?.content ?? content;
750
+ const scopedSanitized = configObject?.sanitized ?? sanitized;
751
+ const booleanValue = readTopLevelBoolean(scopedSanitized, "mcp");
752
+ if (booleanValue !== void 0) return booleanValue;
753
+ const block = extractObjectLiteral(scopedContent, scopedSanitized, "mcp");
754
+ if (!block) continue;
755
+ if (options.rejectRuntimeSecurity) {
756
+ const blockSanitized = stripCommentsAndStrings(block);
757
+ const hasSecurity = findTopLevelPropertyIndex(blockSanitized, "security") !== -1;
758
+ const hasAuthenticate = findTopLevelPropertyIndex(blockSanitized, "authenticate") !== -1;
759
+ if (hasSecurity || hasAuthenticate) throw new McpRuntimeSecurityConfigError(MCP_RUNTIME_SECURITY_CONFIG_ERROR);
820
760
  }
761
+ return {
762
+ enabled: readBooleanFromBlock(block, "enabled"),
763
+ route: readStringFromBlock(block, "route"),
764
+ name: readStringFromBlock(block, "name"),
765
+ version: readStringFromBlock(block, "version"),
766
+ prompts: readBooleanFromBlock(block, "prompts"),
767
+ tools: {
768
+ listDocs: readBooleanFromBlock(block, "listDocs"),
769
+ listPages: readBooleanFromBlock(block, "listPages"),
770
+ listPageSections: readBooleanFromBlock(block, "listPageSections"),
771
+ listTasks: readBooleanFromBlock(block, "listTasks"),
772
+ readTask: readBooleanFromBlock(block, "readTask"),
773
+ readPage: readBooleanFromBlock(block, "readPage"),
774
+ searchDocs: readBooleanFromBlock(block, "searchDocs"),
775
+ getNavigation: readBooleanFromBlock(block, "getNavigation"),
776
+ getCodeExamples: readBooleanFromBlock(block, "getCodeExamples"),
777
+ getConfigSchema: readBooleanFromBlock(block, "getConfigSchema"),
778
+ getContext: readBooleanFromBlock(block, "getContext")
779
+ }
780
+ };
781
+ } catch (error) {
782
+ if (error instanceof McpRuntimeSecurityConfigError) throw error;
821
783
  }
822
784
  }
823
785
  function readStringFromBlock(block, key) {
@@ -1396,26 +1358,13 @@ function withPublicDocsUrl(page, ctx) {
1396
1358
  url
1397
1359
  };
1398
1360
  }
1399
- function readDocsPath(root) {
1400
- for (const ext of FILE_EXTS) {
1401
- const configPath = path.join(
1402
- /* turbopackIgnore: true */
1403
- root,
1404
- `docs.config.${ext}`
1405
- );
1406
- if (!fs.existsSync(
1407
- /* turbopackIgnore: true */
1408
- configPath
1409
- )) continue;
1410
- try {
1411
- const match = fs.readFileSync(
1412
- /* turbopackIgnore: true */
1413
- configPath,
1414
- "utf-8"
1415
- ).match(/docsPath\s*:\s*["']([^"']*)["']/);
1416
- if (match) return match[1];
1417
- } catch {}
1418
- }
1361
+ function readDocsPath(readConfig) {
1362
+ for (const ext of FILE_EXTS) try {
1363
+ const content = readConfig(ext);
1364
+ if (content === void 0) continue;
1365
+ const match = content.match(/docsPath\s*:\s*["']([^"']*)["']/);
1366
+ if (match) return match[1];
1367
+ } catch {}
1419
1368
  }
1420
1369
  function resolvePublicMarkdownRequest(entry, docsPath, url, request) {
1421
1370
  if (docsPath === `/${normalizePathSegment(entry)}`) return null;
@@ -2549,54 +2498,41 @@ async function handleAskAI(request, indexes, aiConfig, cloudConfig, search, anal
2549
2498
  Connection: "keep-alive"
2550
2499
  } });
2551
2500
  }
2552
- function readLlmsTxtConfig(root) {
2553
- for (const ext of FILE_EXTS) {
2554
- const configPath = path.join(
2555
- /* turbopackIgnore: true */
2556
- root,
2557
- `docs.config.${ext}`
2558
- );
2559
- if (fs.existsSync(
2560
- /* turbopackIgnore: true */
2561
- configPath
2562
- )) try {
2563
- const content = fs.readFileSync(
2564
- /* turbopackIgnore: true */
2565
- configPath,
2566
- "utf-8"
2567
- );
2568
- const sanitized = stripCommentsAndStrings(content);
2569
- const configObject = extractRootConfigObject(content, sanitized);
2570
- const scopedContent = configObject?.content ?? content;
2571
- const scopedSanitized = configObject?.sanitized ?? sanitized;
2572
- const navBlock = extractObjectLiteral(scopedContent, scopedSanitized, "nav");
2573
- const navTitle = navBlock ? readTopLevelString(navBlock, stripCommentsAndStrings(navBlock), "title") : void 0;
2574
- const llmsTxtBoolean = readTopLevelBoolean(scopedSanitized, "llmsTxt");
2575
- if (llmsTxtBoolean === true) return {
2576
- enabled: true,
2577
- siteTitle: navTitle
2578
- };
2579
- if (llmsTxtBoolean === false) return { enabled: false };
2580
- const llmsTxtBlock = extractObjectLiteral(scopedContent, scopedSanitized, "llmsTxt");
2581
- if (!llmsTxtBlock) return {
2582
- enabled: true,
2583
- siteTitle: navTitle
2584
- };
2585
- const llmsTxtSanitized = stripCommentsAndStrings(llmsTxtBlock);
2586
- if (readTopLevelBoolean(llmsTxtSanitized, "enabled") === false) return { enabled: false };
2587
- const apiCatalog = readTopLevelBoolean(llmsTxtSanitized, "apiCatalog");
2588
- const baseUrl = readTopLevelString(llmsTxtBlock, llmsTxtSanitized, "baseUrl");
2589
- const siteTitle = readTopLevelString(llmsTxtBlock, llmsTxtSanitized, "siteTitle");
2590
- const siteDescription = readTopLevelString(llmsTxtBlock, llmsTxtSanitized, "siteDescription");
2591
- return {
2592
- enabled: true,
2593
- apiCatalog,
2594
- baseUrl,
2595
- siteTitle: siteTitle ?? navTitle,
2596
- siteDescription
2597
- };
2598
- } catch {}
2599
- }
2501
+ function readLlmsTxtConfig(readConfig) {
2502
+ for (const ext of FILE_EXTS) try {
2503
+ const content = readConfig(ext);
2504
+ if (content === void 0) continue;
2505
+ const sanitized = stripCommentsAndStrings(content);
2506
+ const configObject = extractRootConfigObject(content, sanitized);
2507
+ const scopedContent = configObject?.content ?? content;
2508
+ const scopedSanitized = configObject?.sanitized ?? sanitized;
2509
+ const navBlock = extractObjectLiteral(scopedContent, scopedSanitized, "nav");
2510
+ const navTitle = navBlock ? readTopLevelString(navBlock, stripCommentsAndStrings(navBlock), "title") : void 0;
2511
+ const llmsTxtBoolean = readTopLevelBoolean(scopedSanitized, "llmsTxt");
2512
+ if (llmsTxtBoolean === true) return {
2513
+ enabled: true,
2514
+ siteTitle: navTitle
2515
+ };
2516
+ if (llmsTxtBoolean === false) return { enabled: false };
2517
+ const llmsTxtBlock = extractObjectLiteral(scopedContent, scopedSanitized, "llmsTxt");
2518
+ if (!llmsTxtBlock) return {
2519
+ enabled: true,
2520
+ siteTitle: navTitle
2521
+ };
2522
+ const llmsTxtSanitized = stripCommentsAndStrings(llmsTxtBlock);
2523
+ if (readTopLevelBoolean(llmsTxtSanitized, "enabled") === false) return { enabled: false };
2524
+ const apiCatalog = readTopLevelBoolean(llmsTxtSanitized, "apiCatalog");
2525
+ const baseUrl = readTopLevelString(llmsTxtBlock, llmsTxtSanitized, "baseUrl");
2526
+ const siteTitle = readTopLevelString(llmsTxtBlock, llmsTxtSanitized, "siteTitle");
2527
+ const siteDescription = readTopLevelString(llmsTxtBlock, llmsTxtSanitized, "siteDescription");
2528
+ return {
2529
+ enabled: true,
2530
+ apiCatalog,
2531
+ baseUrl,
2532
+ siteTitle: siteTitle ?? navTitle,
2533
+ siteDescription
2534
+ };
2535
+ } catch {}
2600
2536
  return { enabled: true };
2601
2537
  }
2602
2538
  function resolveLlmsTxtConfig(input, fallback) {
@@ -2611,121 +2547,79 @@ function resolveLlmsTxtConfig(input, fallback) {
2611
2547
  enabled: input.enabled ?? true
2612
2548
  };
2613
2549
  }
2614
- function readSitemapConfig(root) {
2615
- for (const ext of FILE_EXTS) {
2616
- const configPath = path.join(
2617
- /* turbopackIgnore: true */
2618
- root,
2619
- `docs.config.${ext}`
2620
- );
2621
- if (!fs.existsSync(
2622
- /* turbopackIgnore: true */
2623
- configPath
2624
- )) continue;
2625
- try {
2626
- const content = fs.readFileSync(
2627
- /* turbopackIgnore: true */
2628
- configPath,
2629
- "utf-8"
2630
- );
2631
- if (!content.includes("sitemap")) return void 0;
2632
- if (/sitemap\s*:\s*false/.test(content)) return false;
2633
- if (/sitemap\s*:\s*true/.test(content)) return true;
2634
- const sitemapBlock = content.match(/sitemap\s*:\s*\{([\s\S]*?)\n\s*\}/)?.[1] ?? "";
2635
- const routePrefix = sitemapBlock.match(/routePrefix\s*:\s*["']([^"']+)["']/)?.[1];
2636
- const baseUrl = sitemapBlock.match(/baseUrl\s*:\s*["']([^"']+)["']/)?.[1];
2637
- const manifestPath = sitemapBlock.match(/manifestPath\s*:\s*["']([^"']+)["']/)?.[1];
2638
- const enabledMatch = sitemapBlock.match(/enabled\s*:\s*(true|false)/);
2639
- return {
2640
- enabled: enabledMatch ? enabledMatch[1] === "true" : true,
2641
- routePrefix,
2642
- baseUrl,
2643
- manifestPath
2644
- };
2645
- } catch {
2646
- return;
2647
- }
2550
+ function readSitemapConfig(readConfig) {
2551
+ for (const ext of FILE_EXTS) try {
2552
+ const content = readConfig(ext);
2553
+ if (content === void 0) continue;
2554
+ if (!content.includes("sitemap")) return void 0;
2555
+ if (/sitemap\s*:\s*false/.test(content)) return false;
2556
+ if (/sitemap\s*:\s*true/.test(content)) return true;
2557
+ const sitemapBlock = content.match(/sitemap\s*:\s*\{([\s\S]*?)\n\s*\}/)?.[1] ?? "";
2558
+ const routePrefix = sitemapBlock.match(/routePrefix\s*:\s*["']([^"']+)["']/)?.[1];
2559
+ const baseUrl = sitemapBlock.match(/baseUrl\s*:\s*["']([^"']+)["']/)?.[1];
2560
+ const manifestPath = sitemapBlock.match(/manifestPath\s*:\s*["']([^"']+)["']/)?.[1];
2561
+ const enabledMatch = sitemapBlock.match(/enabled\s*:\s*(true|false)/);
2562
+ return {
2563
+ enabled: enabledMatch ? enabledMatch[1] === "true" : true,
2564
+ routePrefix,
2565
+ baseUrl,
2566
+ manifestPath
2567
+ };
2568
+ } catch {
2569
+ return;
2648
2570
  }
2649
2571
  }
2650
- function readRobotsConfig(root) {
2651
- for (const ext of FILE_EXTS) {
2652
- const configPath = path.join(
2653
- /* turbopackIgnore: true */
2654
- root,
2655
- `docs.config.${ext}`
2656
- );
2657
- if (!fs.existsSync(
2658
- /* turbopackIgnore: true */
2659
- configPath
2660
- )) continue;
2661
- try {
2662
- const content = fs.readFileSync(
2663
- /* turbopackIgnore: true */
2664
- configPath,
2665
- "utf-8"
2666
- );
2667
- if (!content.includes("robots")) return void 0;
2668
- if (/robots\s*:\s*false/.test(content)) return false;
2669
- if (/robots\s*:\s*true/.test(content)) return true;
2670
- const robotsBlock = content.match(/robots\s*:\s*\{([\s\S]*?)\n\s*\}/)?.[1] ?? "";
2671
- const enabledMatch = robotsBlock.match(/enabled\s*:\s*(true|false)/);
2672
- const pathMatch = robotsBlock.match(/path\s*:\s*["']([^"']+)["']/);
2673
- const baseUrlMatch = robotsBlock.match(/baseUrl\s*:\s*["']([^"']+)["']/);
2674
- const aiMatch = robotsBlock.match(/ai\s*:\s*["'](allow|disallow)["']/);
2675
- return {
2676
- enabled: enabledMatch ? enabledMatch[1] === "true" : true,
2677
- path: pathMatch?.[1],
2678
- baseUrl: baseUrlMatch?.[1],
2679
- ai: aiMatch?.[1]
2680
- };
2681
- } catch {
2682
- return;
2683
- }
2572
+ function readRobotsConfig(readConfig) {
2573
+ for (const ext of FILE_EXTS) try {
2574
+ const content = readConfig(ext);
2575
+ if (content === void 0) continue;
2576
+ if (!content.includes("robots")) return void 0;
2577
+ if (/robots\s*:\s*false/.test(content)) return false;
2578
+ if (/robots\s*:\s*true/.test(content)) return true;
2579
+ const robotsBlock = content.match(/robots\s*:\s*\{([\s\S]*?)\n\s*\}/)?.[1] ?? "";
2580
+ const enabledMatch = robotsBlock.match(/enabled\s*:\s*(true|false)/);
2581
+ const pathMatch = robotsBlock.match(/path\s*:\s*["']([^"']+)["']/);
2582
+ const baseUrlMatch = robotsBlock.match(/baseUrl\s*:\s*["']([^"']+)["']/);
2583
+ const aiMatch = robotsBlock.match(/ai\s*:\s*["'](allow|disallow)["']/);
2584
+ return {
2585
+ enabled: enabledMatch ? enabledMatch[1] === "true" : true,
2586
+ path: pathMatch?.[1],
2587
+ baseUrl: baseUrlMatch?.[1],
2588
+ ai: aiMatch?.[1]
2589
+ };
2590
+ } catch {
2591
+ return;
2684
2592
  }
2685
2593
  }
2686
- function readApiReferenceConfig(root) {
2687
- for (const ext of FILE_EXTS) {
2688
- const configPath = path.join(
2689
- /* turbopackIgnore: true */
2690
- root,
2691
- `docs.config.${ext}`
2692
- );
2693
- if (!fs.existsSync(
2694
- /* turbopackIgnore: true */
2695
- configPath
2696
- )) continue;
2697
- try {
2698
- const content = fs.readFileSync(
2699
- /* turbopackIgnore: true */
2700
- configPath,
2701
- "utf-8"
2702
- );
2703
- if (!content.includes("apiReference")) return void 0;
2704
- if (/apiReference\s*:\s*false/.test(content)) return false;
2705
- if (/apiReference\s*:\s*true/.test(content)) return true;
2706
- const block = content.match(/apiReference\s*:\s*\{([\s\S]*?)\n\s*\}/)?.[1] ?? "";
2707
- const enabledMatch = block.match(/enabled\s*:\s*(true|false)/);
2708
- const pathMatch = block.match(/path\s*:\s*["']([^"']+)["']/);
2709
- const routeRootMatch = block.match(/routeRoot\s*:\s*["']([^"']+)["']/);
2710
- const specUrlMatch = block.match(/specUrl\s*:\s*["']([^"']+)["']/);
2711
- const catalogTargetsMatch = block.match(/catalogTargets\s*:\s*\[([\s\S]*?)\]/);
2712
- const rendererMatch = block.match(/renderer\s*:\s*["'](farming-labs|fumadocs|scalar)["']/);
2713
- const excludeMatch = block.match(/exclude\s*:\s*\[([\s\S]*?)\]/);
2714
- const catalogTargets = catalogTargetsMatch?.[1] === void 0 ? void 0 : Array.from(catalogTargetsMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
2715
- const exclude = excludeMatch?.[1] === void 0 ? void 0 : Array.from(excludeMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
2716
- const renderer = rendererMatch?.[1] === "farming-labs" || rendererMatch?.[1] === "fumadocs" || rendererMatch?.[1] === "scalar" ? rendererMatch[1] : void 0;
2717
- return {
2718
- enabled: enabledMatch ? enabledMatch[1] === "true" : true,
2719
- path: pathMatch?.[1],
2720
- routeRoot: routeRootMatch?.[1],
2721
- specUrl: specUrlMatch?.[1],
2722
- catalogTargets,
2723
- renderer,
2724
- exclude
2725
- };
2726
- } catch {
2727
- return;
2728
- }
2594
+ function readApiReferenceConfig(readConfig) {
2595
+ for (const ext of FILE_EXTS) try {
2596
+ const content = readConfig(ext);
2597
+ if (content === void 0) continue;
2598
+ if (!content.includes("apiReference")) return void 0;
2599
+ if (/apiReference\s*:\s*false/.test(content)) return false;
2600
+ if (/apiReference\s*:\s*true/.test(content)) return true;
2601
+ const block = content.match(/apiReference\s*:\s*\{([\s\S]*?)\n\s*\}/)?.[1] ?? "";
2602
+ const enabledMatch = block.match(/enabled\s*:\s*(true|false)/);
2603
+ const pathMatch = block.match(/path\s*:\s*["']([^"']+)["']/);
2604
+ const routeRootMatch = block.match(/routeRoot\s*:\s*["']([^"']+)["']/);
2605
+ const specUrlMatch = block.match(/specUrl\s*:\s*["']([^"']+)["']/);
2606
+ const catalogTargetsMatch = block.match(/catalogTargets\s*:\s*\[([\s\S]*?)\]/);
2607
+ const rendererMatch = block.match(/renderer\s*:\s*["'](farming-labs|fumadocs|scalar)["']/);
2608
+ const excludeMatch = block.match(/exclude\s*:\s*\[([\s\S]*?)\]/);
2609
+ const catalogTargets = catalogTargetsMatch?.[1] === void 0 ? void 0 : Array.from(catalogTargetsMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
2610
+ const exclude = excludeMatch?.[1] === void 0 ? void 0 : Array.from(excludeMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
2611
+ const renderer = rendererMatch?.[1] === "farming-labs" || rendererMatch?.[1] === "fumadocs" || rendererMatch?.[1] === "scalar" ? rendererMatch[1] : void 0;
2612
+ return {
2613
+ enabled: enabledMatch ? enabledMatch[1] === "true" : true,
2614
+ path: pathMatch?.[1],
2615
+ routeRoot: routeRootMatch?.[1],
2616
+ specUrl: specUrlMatch?.[1],
2617
+ catalogTargets,
2618
+ renderer,
2619
+ exclude
2620
+ };
2621
+ } catch {
2622
+ return;
2729
2623
  }
2730
2624
  }
2731
2625
  function generateLlmsTxt(indexes, options) {
@@ -2757,6 +2651,7 @@ function generateLlmsTxt(indexes, options) {
2757
2651
  */
2758
2652
  function createDocsAPI(options) {
2759
2653
  const root = options?.rootDir ?? process.cwd();
2654
+ const readConfig = createDocsConfigReader(root);
2760
2655
  const readRootSkillDocument = createRootDocumentReader(root, ["skill.md"], options?._preloadedRootDocuments);
2761
2656
  const readRootAgentsDocument = createRootDocumentReader(root, ["AGENTS.md", "AGENT.md"], options?._preloadedRootDocuments);
2762
2657
  let publishedAgentSkills;
@@ -2764,8 +2659,8 @@ function createDocsAPI(options) {
2764
2659
  if (!publishedAgentSkills) publishedAgentSkills = Array.isArray(options?._preloadedAgentSkills) ? Promise.resolve([...options._preloadedAgentSkills]) : resolveConfiguredAgentSkills(options?.agent?.skills, { rootDir: root });
2765
2660
  return publishedAgentSkills;
2766
2661
  }
2767
- const entry = options?.entry ?? readEntry(root);
2768
- const docsPath = normalizeDocsPublicPath(options?.docsPath ?? readDocsPath(root), entry);
2662
+ const entry = options?.entry ?? readEntry(readConfig);
2663
+ const docsPath = normalizeDocsPublicPath(options?.docsPath ?? readDocsPath(readConfig), entry);
2769
2664
  const analytics = options?.analytics;
2770
2665
  const observability = options?.observability;
2771
2666
  const appDir = getNextAppDir(root);
@@ -2776,10 +2671,10 @@ function createDocsAPI(options) {
2776
2671
  );
2777
2672
  const changelogConfig = resolveChangelogConfig(options?.changelog);
2778
2673
  const agentFeedbackConfig = resolveAgentFeedbackConfig(options?.feedback);
2779
- const i18nConfig = options?.i18n ?? readI18nConfig(root);
2674
+ const i18nConfig = options?.i18n ?? readI18nConfig(readConfig);
2780
2675
  const i18n = resolveDocsI18n(i18nConfig);
2781
- const aiConfig = options?.ai ?? readAIConfig(root);
2782
- const cloudConfig = options?.cloud ?? readCloudConfig(root);
2676
+ const aiConfig = options?.ai ?? readAIConfig(readConfig);
2677
+ const cloudConfig = options?.cloud ?? readCloudConfig(readConfig);
2783
2678
  const configuredApiRouteInput = options?.apiRoute ?? cloudConfig?.apiRoute;
2784
2679
  const configuredApiRoute = normalizeDocsApiRoute(configuredApiRouteInput);
2785
2680
  const effectiveCloudConfig = options?.apiRoute !== void 0 || cloudConfig?.apiRoute !== void 0 ? {
@@ -2789,11 +2684,12 @@ function createDocsAPI(options) {
2789
2684
  const searchConfig = options?.search;
2790
2685
  const contentChangesConfig = resolveDocsContentChangesConfig(options?.agent?.contentChanges, { staticExport: options?.staticExport === true });
2791
2686
  const contentChangeFeed = createDocsContentChangeFeed(options?.agent?.contentChanges);
2792
- const llmsConfig = resolveLlmsTxtConfig(options?.llmsTxt, readLlmsTxtConfig(root));
2687
+ const llmsConfig = resolveLlmsTxtConfig(options?.llmsTxt, options?.llmsTxt === false ? { enabled: false } : readLlmsTxtConfig(readConfig));
2793
2688
  const apiCatalogEnabled = options?.apiCatalog ?? llmsConfig.apiCatalog ?? true;
2794
- const sitemapConfig = options?.sitemap ?? readSitemapConfig(root);
2689
+ const sitemapConfig = options?.sitemap ?? readSitemapConfig(readConfig);
2795
2690
  const sitemapManifest = readDocsSitemapManifest(root, sitemapConfig);
2796
- const robotsConfig = options?.robots ?? readRobotsConfig(root);
2691
+ const resolveLastmod = createDocsSitemapLastmodResolver(sitemapManifest);
2692
+ const robotsConfig = options?.robots ?? readRobotsConfig(readConfig);
2797
2693
  const markdownMetadataBaseUrl = resolveDocsMetadataBaseUrl({
2798
2694
  ...options,
2799
2695
  entry,
@@ -2802,14 +2698,14 @@ function createDocsAPI(options) {
2802
2698
  sitemap: sitemapConfig,
2803
2699
  robots: robotsConfig
2804
2700
  });
2805
- const apiReferenceConfig = options?.apiReference ?? readApiReferenceConfig(root);
2701
+ const apiReferenceConfig = options?.apiReference ?? readApiReferenceConfig(readConfig);
2806
2702
  const apiReferenceDocsConfig = {
2807
2703
  ...options,
2808
2704
  entry,
2809
2705
  apiReference: apiReferenceConfig
2810
2706
  };
2811
2707
  const openapiDiscovery = resolveApiReferenceOpenApiDiscovery(apiReferenceConfig);
2812
- const rawMcpConfig = options?.mcp ?? readMcpConfig(root);
2708
+ const rawMcpConfig = options?.mcp ?? readMcpConfig(readConfig);
2813
2709
  const mcpConfig = resolveDocsMcpConfig(rawMcpConfig, { defaultName: llmsConfig.siteTitle ?? "Documentation" });
2814
2710
  const discoveryLinkHeader = getDocsDiscoveryLinkHeader({
2815
2711
  includeApiCatalog: apiCatalogEnabled,
@@ -3001,7 +2897,7 @@ function createDocsAPI(options) {
3001
2897
  const changelogPages = ctx.changelogDirs.flatMap((dir) => scanChangelogDir(dir, ctx.entryPath, changelogConfig.path, ctx.locale, ctx.publicPath));
3002
2898
  next = [...next, ...changelogPages];
3003
2899
  }
3004
- const timestamped = next.map((page) => withSitemapLastModified(page, sitemapManifest));
2900
+ const timestamped = next.map((page) => withSitemapLastModified(page, resolveLastmod));
3005
2901
  indexesByLocale.set(key, timestamped);
3006
2902
  return timestamped;
3007
2903
  }
@@ -3042,7 +2938,7 @@ function createDocsAPI(options) {
3042
2938
  ) : docsDir)) return null;
3043
2939
  for (const source of getMarkdownSources(ctx)) {
3044
2940
  const resolvedPage = findDocsMcpPage(ctx.entryPath, await source.getPages(), requestedPath);
3045
- const page = resolvedPage ? withSitemapLastModified(resolvedPage, sitemapManifest) : void 0;
2941
+ const page = resolvedPage ? withSitemapLastModified(resolvedPage, resolveLastmod) : void 0;
3046
2942
  if (page) return {
3047
2943
  document: renderMarkdownDocument(withPublicDocsUrl(page, ctx), {
3048
2944
  llmsEnabled: llmsConfig.enabled,
@@ -3724,16 +3620,17 @@ function createDocsAPI(options) {
3724
3620
  */
3725
3621
  function createDocsMCPAPI(options = {}) {
3726
3622
  const rootDir = options.rootDir ?? process.cwd();
3623
+ const readConfig = createDocsConfigReader(rootDir);
3727
3624
  const readRootSkillDocument = createRootDocumentReader(rootDir, ["skill.md"], options._preloadedRootDocuments);
3728
- const entry = options.entry ?? readEntry(rootDir);
3625
+ const entry = options.entry ?? readEntry(readConfig);
3729
3626
  const appDir = getNextAppDir(rootDir);
3730
3627
  const contentDir = options.contentDir ?? path.join(
3731
3628
  /* turbopackIgnore: true */
3732
3629
  appDir,
3733
3630
  entry
3734
3631
  );
3735
- const mcpConfig = options.mcp ?? readMcpConfig(rootDir, { rejectRuntimeSecurity: true });
3736
- const sitemapManifest = readDocsSitemapManifest(rootDir, options.sitemap ?? readSitemapConfig(rootDir));
3632
+ const mcpConfig = options.mcp ?? readMcpConfig(readConfig, { rejectRuntimeSecurity: true });
3633
+ const resolveLastmod = createDocsSitemapLastmodResolver(readDocsSitemapManifest(rootDir, options.sitemap ?? readSitemapConfig(readConfig)));
3737
3634
  const contentChangeFeed = createDocsContentChangeFeed(options.agent?.contentChanges);
3738
3635
  const navTitle = typeof options.nav?.title === "string" && options.nav.title.trim().length > 0 ? options.nav.title : "Documentation";
3739
3636
  let configuredAgentSkills;
@@ -3752,7 +3649,7 @@ function createDocsMCPAPI(options = {}) {
3752
3649
  const source = {
3753
3650
  ...filesystemSource,
3754
3651
  async getPages() {
3755
- return (await filesystemSource.getPages()).map((page) => withSitemapLastModified(page, sitemapManifest));
3652
+ return (await filesystemSource.getPages()).map((page) => withSitemapLastModified(page, resolveLastmod));
3756
3653
  },
3757
3654
  async getSkills() {
3758
3655
  const configured = await getConfiguredAgentSkills();
@@ -16,7 +16,7 @@ import fs from "node:fs";
16
16
  import path from "node:path";
17
17
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
18
18
  import { Suspense, cloneElement, isValidElement } from "react";
19
- import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, normalizePageAgentFrontmatter, resolveChangelogConfig, resolveDocsAnalyticsConfig, resolveDocsAudienceMdxContent, resolveDocsMetadataBaseUrl, resolveDocsSitemapPageLastmod, resolvePageSidebarFolderIndexBehavior, toDocsMarkdownUrl } from "@farming-labs/docs";
19
+ import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, createDocsSitemapLastmodResolver, normalizePageAgentFrontmatter, resolveChangelogConfig, resolveDocsAnalyticsConfig, resolveDocsAudienceMdxContent, resolveDocsMetadataBaseUrl, resolvePageSidebarFolderIndexBehavior, toDocsMarkdownUrl } from "@farming-labs/docs";
20
20
  import { readDocsSitemapManifest } from "@farming-labs/docs/runtime";
21
21
  import { jsx, jsxs } from "react/jsx-runtime";
22
22
 
@@ -441,11 +441,12 @@ function cloneTree(tree) {
441
441
  children: tree.children.map(cloneNode)
442
442
  };
443
443
  }
444
- function resolveManifestLastmod(manifest, ctx, url) {
445
- return (ctx.locale ? resolveDocsSitemapPageLastmod(manifest, `${url}?lang=${encodeURIComponent(ctx.locale)}`) : void 0) ?? resolveDocsSitemapPageLastmod(manifest, url);
444
+ function resolveManifestLastmod(resolveLastmod, ctx, url) {
445
+ return (ctx.locale ? resolveLastmod(`${url}?lang=${encodeURIComponent(ctx.locale)}`) : void 0) ?? resolveLastmod(url);
446
446
  }
447
447
  /** Read each page once for all metadata, sharing the reader with navigation. */
448
448
  function buildPageMaps(config, ctx, reader, manifest, options) {
449
+ const resolveLastmod = createDocsSitemapLastmodResolver(manifest);
449
450
  const lastModifiedMap = {};
450
451
  const descriptionMap = {};
451
452
  const generatedTitleMap = {};
@@ -474,7 +475,7 @@ function buildPageMaps(config, ctx, reader, manifest, options) {
474
475
  const route = publicDocsRoute(ctx, slugParts);
475
476
  const title = typeof data.title === "string" ? data.title : slugParts.at(-1)?.replace(/-/g, " ") || "Documentation";
476
477
  const description = typeof data.description === "string" ? data.description : void 0;
477
- const manifestLastmod = resolveManifestLastmod(manifest, ctx, route);
478
+ const manifestLastmod = resolveManifestLastmod(resolveLastmod, ctx, route);
478
479
  if (config.theme?.name === "shadcn" && typeof data.title === "string" && !hasAuthoredPageTitle(content)) generatedTitleMap[route] = data.title;
479
480
  if (fileName === "page.mdx") {
480
481
  if (dateFormatter) lastModifiedMap[route] = dateFormatter.format(manifestLastmod ? /* @__PURE__ */ new Date(`${manifestLastmod}T00:00:00`) : modifiedAt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.2.122",
3
+ "version": "0.2.124",
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.122"
164
+ "@farming-labs/docs": "0.2.124"
165
165
  },
166
166
  "peerDependencies": {
167
167
  "@farming-labs/docs": ">=0.0.1",