@farming-labs/theme 0.2.72 → 0.2.74
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.d.mts +2 -0
- package/dist/docs-api.mjs +31 -23
- package/package.json +2 -2
package/dist/docs-api.d.mts
CHANGED
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_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
|
|
@@ -223,7 +223,7 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
|
|
|
223
223
|
return {
|
|
224
224
|
$schema: DOCS_AGENT_MANIFEST_SCHEMA_URI,
|
|
225
225
|
format: DOCS_AGENT_MANIFEST_FORMAT,
|
|
226
|
-
version:
|
|
226
|
+
version: DOCS_AGENT_MANIFEST_VERSION,
|
|
227
227
|
name: "@farming-labs/docs",
|
|
228
228
|
baseUrl: origin,
|
|
229
229
|
site: {
|
|
@@ -970,12 +970,17 @@ function readAudienceAgentDoc(dir) {
|
|
|
970
970
|
const agentRawContent = resolveDocsAudienceMdxContent(content, "agent");
|
|
971
971
|
return {
|
|
972
972
|
agentContent: stripMdx(agentRawContent),
|
|
973
|
-
agentRawContent
|
|
973
|
+
agentRawContent,
|
|
974
|
+
agentLastModified: fs.statSync(agentPath).mtime.toISOString()
|
|
974
975
|
};
|
|
975
976
|
} catch {
|
|
976
977
|
return;
|
|
977
978
|
}
|
|
978
979
|
}
|
|
980
|
+
function normalizeFrontmatterLastmod(value) {
|
|
981
|
+
if (typeof value === "string") return value;
|
|
982
|
+
return value instanceof Date && Number.isFinite(value.getTime()) ? value.toISOString() : void 0;
|
|
983
|
+
}
|
|
979
984
|
function scanDocsDir(docsDir, entry, locale, excludedDirs = [], publicPath = `/${normalizePathSegment(entry) || "docs"}`) {
|
|
980
985
|
const indexes = [];
|
|
981
986
|
function isExcluded(dir) {
|
|
@@ -1014,6 +1019,7 @@ function scanDocsDir(docsDir, entry, locale, excludedDirs = [], publicPath = `/$
|
|
|
1014
1019
|
agentFallbackRawContent: agentRawContent !== rawContent ? agentRawContent : void 0,
|
|
1015
1020
|
url,
|
|
1016
1021
|
sourcePath: pageSource.replace(/\\/g, "/"),
|
|
1022
|
+
lastmod: normalizeFrontmatterLastmod(data.lastmod),
|
|
1017
1023
|
lastModified: fs.statSync(pageSource).mtime.toISOString(),
|
|
1018
1024
|
locale,
|
|
1019
1025
|
framework,
|
|
@@ -1080,6 +1086,9 @@ function scanChangelogDir(changelogDir, entryPath, changelogPath, locale, public
|
|
|
1080
1086
|
rawContent,
|
|
1081
1087
|
agentFallbackRawContent: agentRawContent !== rawContent ? agentRawContent : void 0,
|
|
1082
1088
|
url,
|
|
1089
|
+
sourcePath: pagePath.replace(/\\/g, "/"),
|
|
1090
|
+
lastmod: normalizeFrontmatterLastmod(data.lastmod),
|
|
1091
|
+
lastModified: fs.statSync(pagePath).mtime.toISOString(),
|
|
1083
1092
|
locale,
|
|
1084
1093
|
type: "changelog",
|
|
1085
1094
|
version: typeof data.version === "string" ? data.version : void 0,
|
|
@@ -2038,7 +2047,8 @@ async function handleAskAI(request, indexes, aiConfig, cloudConfig, search, anal
|
|
|
2038
2047
|
locale: analyticsContext.locale,
|
|
2039
2048
|
pathname: url.searchParams.get("pathname") ?? void 0,
|
|
2040
2049
|
siteTitle: "Documentation",
|
|
2041
|
-
baseUrl: url.origin,
|
|
2050
|
+
baseUrl: analyticsContext.syncBaseUrl || url.origin,
|
|
2051
|
+
syncBaseUrl: analyticsContext.syncBaseUrl,
|
|
2042
2052
|
limit: maxResults
|
|
2043
2053
|
});
|
|
2044
2054
|
const scored = retrieval.results;
|
|
@@ -2716,7 +2726,7 @@ function createDocsAPI(options) {
|
|
|
2716
2726
|
origin,
|
|
2717
2727
|
sitemap: sitemapConfig
|
|
2718
2728
|
}),
|
|
2719
|
-
lastModified: page
|
|
2729
|
+
lastModified: resolveDocsRetrievalLastModified(page, "agent")
|
|
2720
2730
|
};
|
|
2721
2731
|
}
|
|
2722
2732
|
const fallbackPage = getIndexes(ctx).find((page) => {
|
|
@@ -2729,7 +2739,7 @@ function createDocsAPI(options) {
|
|
|
2729
2739
|
origin,
|
|
2730
2740
|
sitemap: sitemapConfig
|
|
2731
2741
|
}),
|
|
2732
|
-
lastModified: fallbackPage
|
|
2742
|
+
lastModified: resolveDocsRetrievalLastModified(fallbackPage, "agent")
|
|
2733
2743
|
};
|
|
2734
2744
|
const requestedSlug = normalizePublicDocsSlug(ctx, normalizedPublicRequest);
|
|
2735
2745
|
for (const page of getIndexes(ctx)) if (normalizePublicDocsSlug(ctx, page.url) === requestedSlug) return {
|
|
@@ -2738,7 +2748,7 @@ function createDocsAPI(options) {
|
|
|
2738
2748
|
origin,
|
|
2739
2749
|
sitemap: sitemapConfig
|
|
2740
2750
|
}),
|
|
2741
|
-
lastModified: page
|
|
2751
|
+
lastModified: resolveDocsRetrievalLastModified(page, "agent")
|
|
2742
2752
|
};
|
|
2743
2753
|
return null;
|
|
2744
2754
|
}
|
|
@@ -3157,30 +3167,24 @@ function createDocsAPI(options) {
|
|
|
3157
3167
|
const audience = resolveDocsSearchAudience(url.searchParams.get("audience"));
|
|
3158
3168
|
const filters = resolveDocsSearchFilters(url.searchParams);
|
|
3159
3169
|
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();
|
|
3170
|
+
if (!query && !structured) return new Response("[]", { headers: { "Content-Type": "application/json" } });
|
|
3173
3171
|
const searchOptions = {
|
|
3174
3172
|
pages: getIndexes(ctx),
|
|
3175
|
-
query,
|
|
3173
|
+
query: query ?? "",
|
|
3176
3174
|
search: resolveSearchRequestConfig(searchConfig, request.url),
|
|
3177
3175
|
audience,
|
|
3178
3176
|
filters,
|
|
3179
3177
|
locale: ctx.locale,
|
|
3180
3178
|
pathname: url.searchParams.get("pathname") ?? void 0,
|
|
3181
3179
|
siteTitle: llmsConfig.siteTitle ?? "Documentation",
|
|
3182
|
-
baseUrl: markdownMetadataBaseUrl || url.origin
|
|
3180
|
+
baseUrl: markdownMetadataBaseUrl || url.origin,
|
|
3181
|
+
syncBaseUrl: markdownMetadataBaseUrl ?? null
|
|
3183
3182
|
};
|
|
3183
|
+
if (!query) {
|
|
3184
|
+
const searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : [];
|
|
3185
|
+
return new Response(JSON.stringify(searchResponse), { headers: { "Content-Type": "application/json" } });
|
|
3186
|
+
}
|
|
3187
|
+
const searchStartedAt = Date.now();
|
|
3184
3188
|
const searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : await performDocsSearch(searchOptions);
|
|
3185
3189
|
const resultCount = Array.isArray(searchResponse) ? searchResponse.length : searchResponse.resultCount;
|
|
3186
3190
|
await emitDocsAnalyticsEvent(analytics, {
|
|
@@ -3299,7 +3303,10 @@ function createDocsAPI(options) {
|
|
|
3299
3303
|
mcpEnabled: mcpConfig.enabled,
|
|
3300
3304
|
mcpSearchEnabled: mcpConfig.tools.searchDocs,
|
|
3301
3305
|
requestUrl: request.url
|
|
3302
|
-
}), analytics, observability, {
|
|
3306
|
+
}), analytics, observability, {
|
|
3307
|
+
locale: ctx.locale,
|
|
3308
|
+
syncBaseUrl: markdownMetadataBaseUrl ?? null
|
|
3309
|
+
});
|
|
3303
3310
|
}
|
|
3304
3311
|
};
|
|
3305
3312
|
return {
|
|
@@ -3342,6 +3349,7 @@ function createDocsMCPAPI(options = {}) {
|
|
|
3342
3349
|
entry,
|
|
3343
3350
|
contentDir,
|
|
3344
3351
|
siteTitle: navTitle,
|
|
3352
|
+
baseUrl: options.baseUrl?.trim() || resolveDocsMetadataBaseUrl(options) || void 0,
|
|
3345
3353
|
ordering: options.ordering
|
|
3346
3354
|
}),
|
|
3347
3355
|
async getSkills() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.74",
|
|
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.
|
|
151
|
+
"@farming-labs/docs": "0.2.74"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"@farming-labs/docs": ">=0.0.1",
|