@farming-labs/theme 0.2.73 → 0.2.75

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.
@@ -87,6 +87,8 @@ interface DocsMCPAPIOptions {
87
87
  rootDir?: string;
88
88
  entry?: string;
89
89
  contentDir?: string;
90
+ /** Canonical public docs origin used in retrieval provenance. */
91
+ baseUrl?: string;
90
92
  nav?: {
91
93
  title?: unknown;
92
94
  };
package/dist/docs-api.mjs CHANGED
@@ -4,7 +4,7 @@ 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_MARKDOWN_SECTION_INDEX_FORMAT, acceptsDocsMarkdown, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsDiagnosticsRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, performDocsSearch, performDocsSearchWithMetadata, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsSearchAudience, resolveDocsSearchFilters, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance } from "@farming-labs/docs";
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_MARKDOWN_SECTION_INDEX_FORMAT, acceptsDocsMarkdown, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsStandardsDiscoveryResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, getDocsLlmsTxtMaxCharsIssue, getDocsMcpProtectedResourceMetadataRoutes, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsDiagnosticsRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, performDocsSearch, performDocsSearchWithMetadata, renderDocsLlmsTxt, renderDocsMarkdownDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentContractMcpTools, resolveDocsAudienceMdxContent, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMetadataBaseUrl, resolveDocsPublishedAgentSkill, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsSearchAudience, resolveDocsSearchFilters, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance } from "@farming-labs/docs";
8
8
  import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/server";
9
9
 
10
10
  //#region src/docs-api.ts
@@ -742,6 +742,7 @@ function readMcpConfig(root, options = {}) {
742
742
  tools: {
743
743
  listDocs: readBooleanFromBlock(block, "listDocs"),
744
744
  listPages: readBooleanFromBlock(block, "listPages"),
745
+ listPageSections: readBooleanFromBlock(block, "listPageSections"),
745
746
  listTasks: readBooleanFromBlock(block, "listTasks"),
746
747
  readTask: readBooleanFromBlock(block, "readTask"),
747
748
  readPage: readBooleanFromBlock(block, "readPage"),
@@ -970,12 +971,17 @@ function readAudienceAgentDoc(dir) {
970
971
  const agentRawContent = resolveDocsAudienceMdxContent(content, "agent");
971
972
  return {
972
973
  agentContent: stripMdx(agentRawContent),
973
- agentRawContent
974
+ agentRawContent,
975
+ agentLastModified: fs.statSync(agentPath).mtime.toISOString()
974
976
  };
975
977
  } catch {
976
978
  return;
977
979
  }
978
980
  }
981
+ function normalizeFrontmatterLastmod(value) {
982
+ if (typeof value === "string") return value;
983
+ return value instanceof Date && Number.isFinite(value.getTime()) ? value.toISOString() : void 0;
984
+ }
979
985
  function scanDocsDir(docsDir, entry, locale, excludedDirs = [], publicPath = `/${normalizePathSegment(entry) || "docs"}`) {
980
986
  const indexes = [];
981
987
  function isExcluded(dir) {
@@ -1014,6 +1020,7 @@ function scanDocsDir(docsDir, entry, locale, excludedDirs = [], publicPath = `/$
1014
1020
  agentFallbackRawContent: agentRawContent !== rawContent ? agentRawContent : void 0,
1015
1021
  url,
1016
1022
  sourcePath: pageSource.replace(/\\/g, "/"),
1023
+ lastmod: normalizeFrontmatterLastmod(data.lastmod),
1017
1024
  lastModified: fs.statSync(pageSource).mtime.toISOString(),
1018
1025
  locale,
1019
1026
  framework,
@@ -1080,6 +1087,9 @@ function scanChangelogDir(changelogDir, entryPath, changelogPath, locale, public
1080
1087
  rawContent,
1081
1088
  agentFallbackRawContent: agentRawContent !== rawContent ? agentRawContent : void 0,
1082
1089
  url,
1090
+ sourcePath: pagePath.replace(/\\/g, "/"),
1091
+ lastmod: normalizeFrontmatterLastmod(data.lastmod),
1092
+ lastModified: fs.statSync(pagePath).mtime.toISOString(),
1083
1093
  locale,
1084
1094
  type: "changelog",
1085
1095
  version: typeof data.version === "string" ? data.version : void 0,
@@ -2038,7 +2048,8 @@ async function handleAskAI(request, indexes, aiConfig, cloudConfig, search, anal
2038
2048
  locale: analyticsContext.locale,
2039
2049
  pathname: url.searchParams.get("pathname") ?? void 0,
2040
2050
  siteTitle: "Documentation",
2041
- baseUrl: url.origin,
2051
+ baseUrl: analyticsContext.syncBaseUrl || url.origin,
2052
+ syncBaseUrl: analyticsContext.syncBaseUrl,
2042
2053
  limit: maxResults
2043
2054
  });
2044
2055
  const scored = retrieval.results;
@@ -2716,7 +2727,7 @@ function createDocsAPI(options) {
2716
2727
  origin,
2717
2728
  sitemap: sitemapConfig
2718
2729
  }),
2719
- lastModified: page.agentRawContent === void 0 ? page.lastModified : void 0
2730
+ lastModified: resolveDocsRetrievalLastModified(page, "agent")
2720
2731
  };
2721
2732
  }
2722
2733
  const fallbackPage = getIndexes(ctx).find((page) => {
@@ -2729,7 +2740,7 @@ function createDocsAPI(options) {
2729
2740
  origin,
2730
2741
  sitemap: sitemapConfig
2731
2742
  }),
2732
- lastModified: fallbackPage.agentRawContent === void 0 ? fallbackPage.lastModified : void 0
2743
+ lastModified: resolveDocsRetrievalLastModified(fallbackPage, "agent")
2733
2744
  };
2734
2745
  const requestedSlug = normalizePublicDocsSlug(ctx, normalizedPublicRequest);
2735
2746
  for (const page of getIndexes(ctx)) if (normalizePublicDocsSlug(ctx, page.url) === requestedSlug) return {
@@ -2738,7 +2749,7 @@ function createDocsAPI(options) {
2738
2749
  origin,
2739
2750
  sitemap: sitemapConfig
2740
2751
  }),
2741
- lastModified: page.agentRawContent === void 0 ? page.lastModified : void 0
2752
+ lastModified: resolveDocsRetrievalLastModified(page, "agent")
2742
2753
  };
2743
2754
  return null;
2744
2755
  }
@@ -3157,30 +3168,24 @@ function createDocsAPI(options) {
3157
3168
  const audience = resolveDocsSearchAudience(url.searchParams.get("audience"));
3158
3169
  const filters = resolveDocsSearchFilters(url.searchParams);
3159
3170
  const structured = url.searchParams.get("response") === "structured";
3160
- if (!query) {
3161
- const searchResponse = structured ? {
3162
- format: "docs-search.v1",
3163
- query: "",
3164
- audience,
3165
- filters,
3166
- resultCount: 0,
3167
- results: [],
3168
- warnings: []
3169
- } : [];
3170
- return new Response(JSON.stringify(searchResponse), { headers: { "Content-Type": "application/json" } });
3171
- }
3172
- const searchStartedAt = Date.now();
3171
+ if (!query && !structured) return new Response("[]", { headers: { "Content-Type": "application/json" } });
3173
3172
  const searchOptions = {
3174
3173
  pages: getIndexes(ctx),
3175
- query,
3174
+ query: query ?? "",
3176
3175
  search: resolveSearchRequestConfig(searchConfig, request.url),
3177
3176
  audience,
3178
3177
  filters,
3179
3178
  locale: ctx.locale,
3180
3179
  pathname: url.searchParams.get("pathname") ?? void 0,
3181
3180
  siteTitle: llmsConfig.siteTitle ?? "Documentation",
3182
- baseUrl: markdownMetadataBaseUrl || url.origin
3181
+ baseUrl: markdownMetadataBaseUrl || url.origin,
3182
+ syncBaseUrl: markdownMetadataBaseUrl ?? null
3183
3183
  };
3184
+ if (!query) {
3185
+ const searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : [];
3186
+ return new Response(JSON.stringify(searchResponse), { headers: { "Content-Type": "application/json" } });
3187
+ }
3188
+ const searchStartedAt = Date.now();
3184
3189
  const searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : await performDocsSearch(searchOptions);
3185
3190
  const resultCount = Array.isArray(searchResponse) ? searchResponse.length : searchResponse.resultCount;
3186
3191
  await emitDocsAnalyticsEvent(analytics, {
@@ -3299,7 +3304,10 @@ function createDocsAPI(options) {
3299
3304
  mcpEnabled: mcpConfig.enabled,
3300
3305
  mcpSearchEnabled: mcpConfig.tools.searchDocs,
3301
3306
  requestUrl: request.url
3302
- }), analytics, observability, { locale: ctx.locale });
3307
+ }), analytics, observability, {
3308
+ locale: ctx.locale,
3309
+ syncBaseUrl: markdownMetadataBaseUrl ?? null
3310
+ });
3303
3311
  }
3304
3312
  };
3305
3313
  return {
@@ -3342,6 +3350,7 @@ function createDocsMCPAPI(options = {}) {
3342
3350
  entry,
3343
3351
  contentDir,
3344
3352
  siteTitle: navTitle,
3353
+ baseUrl: options.baseUrl?.trim() || resolveDocsMetadataBaseUrl(options) || void 0,
3345
3354
  ordering: options.ordering
3346
3355
  }),
3347
3356
  async getSkills() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.2.73",
3
+ "version": "0.2.75",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -148,7 +148,7 @@
148
148
  "tsdown": "^0.20.3",
149
149
  "typescript": "^5.9.3",
150
150
  "vitest": "^4.1.8",
151
- "@farming-labs/docs": "0.2.73"
151
+ "@farming-labs/docs": "0.2.75"
152
152
  },
153
153
  "peerDependencies": {
154
154
  "@farming-labs/docs": ">=0.0.1",