@farming-labs/theme 0.2.74 → 0.2.77
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 +32 -23
- package/package.json +2 -2
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_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,
|
|
8
|
-
import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest,
|
|
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, resolveDocsSearchError, resolveDocsSearchRequest, resolveDocsSitemapConfig, resolveDocsStandardsDiscoveryRequest, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent, stripGeneratedAgentProvenance } from "@farming-labs/docs";
|
|
8
|
+
import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceOpenApiDiscovery, resolveConfiguredAgentSkills, resolveDocsMcpConfig } from "@farming-labs/docs/server";
|
|
9
9
|
|
|
10
10
|
//#region src/docs-api.ts
|
|
11
11
|
/**
|
|
@@ -197,18 +197,6 @@ function isRobotsDiscoveryEnabled(robots) {
|
|
|
197
197
|
function isApiReferenceOpenApiRequest(url) {
|
|
198
198
|
return url.searchParams.get("format")?.trim() === "openapi";
|
|
199
199
|
}
|
|
200
|
-
function resolveApiReferenceOpenApiDiscovery(value) {
|
|
201
|
-
const apiReference = resolveApiReferenceConfig(value);
|
|
202
|
-
if (!apiReference.enabled) return { enabled: false };
|
|
203
|
-
return {
|
|
204
|
-
enabled: true,
|
|
205
|
-
url: `${DEFAULT_DOCS_API_ROUTE}?format=openapi`,
|
|
206
|
-
urlSource: "default",
|
|
207
|
-
source: apiReference.specUrl ? "configured" : "generated",
|
|
208
|
-
specUrl: apiReference.specUrl,
|
|
209
|
-
apiReferencePath: `/${apiReference.path}`
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
200
|
function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp, feedback, llms, sitemap, robots, openapi, publishedSkills = [], agentCard }) {
|
|
213
201
|
const normalizedEntry = normalizePathSegment(entry) || "docs";
|
|
214
202
|
const localesEnabled = i18n !== null;
|
|
@@ -426,6 +414,10 @@ function buildAgentSpec({ origin, entry, apiRoute, apiCatalog, i18n, search, mcp
|
|
|
426
414
|
"tags"
|
|
427
415
|
],
|
|
428
416
|
warningsField: "warnings",
|
|
417
|
+
cursorParam: "cursor",
|
|
418
|
+
nextCursorField: "nextCursor",
|
|
419
|
+
hasMoreField: "hasMore",
|
|
420
|
+
totalField: "total",
|
|
429
421
|
defaultAudience: "human",
|
|
430
422
|
supportedAudiences: ["human", "agent"]
|
|
431
423
|
},
|
|
@@ -742,6 +734,7 @@ function readMcpConfig(root, options = {}) {
|
|
|
742
734
|
tools: {
|
|
743
735
|
listDocs: readBooleanFromBlock(block, "listDocs"),
|
|
744
736
|
listPages: readBooleanFromBlock(block, "listPages"),
|
|
737
|
+
listPageSections: readBooleanFromBlock(block, "listPageSections"),
|
|
745
738
|
listTasks: readBooleanFromBlock(block, "listTasks"),
|
|
746
739
|
readTask: readBooleanFromBlock(block, "readTask"),
|
|
747
740
|
readPage: readBooleanFromBlock(block, "readPage"),
|
|
@@ -2461,8 +2454,10 @@ function readApiReferenceConfig(root) {
|
|
|
2461
2454
|
const pathMatch = block.match(/path\s*:\s*["']([^"']+)["']/);
|
|
2462
2455
|
const routeRootMatch = block.match(/routeRoot\s*:\s*["']([^"']+)["']/);
|
|
2463
2456
|
const specUrlMatch = block.match(/specUrl\s*:\s*["']([^"']+)["']/);
|
|
2457
|
+
const catalogTargetsMatch = block.match(/catalogTargets\s*:\s*\[([\s\S]*?)\]/);
|
|
2464
2458
|
const rendererMatch = block.match(/renderer\s*:\s*["'](fumadocs|scalar)["']/);
|
|
2465
2459
|
const excludeMatch = block.match(/exclude\s*:\s*\[([\s\S]*?)\]/);
|
|
2460
|
+
const catalogTargets = catalogTargetsMatch?.[1] === void 0 ? void 0 : Array.from(catalogTargetsMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
|
|
2466
2461
|
const exclude = excludeMatch?.[1] === void 0 ? void 0 : Array.from(excludeMatch[1].matchAll(/["']([^"']+)["']/g)).map((match) => match[1]).filter(Boolean);
|
|
2467
2462
|
const renderer = rendererMatch?.[1] === "fumadocs" || rendererMatch?.[1] === "scalar" ? rendererMatch[1] : void 0;
|
|
2468
2463
|
return {
|
|
@@ -2470,6 +2465,7 @@ function readApiReferenceConfig(root) {
|
|
|
2470
2465
|
path: pathMatch?.[1],
|
|
2471
2466
|
routeRoot: routeRootMatch?.[1],
|
|
2472
2467
|
specUrl: specUrlMatch?.[1],
|
|
2468
|
+
catalogTargets,
|
|
2473
2469
|
renderer,
|
|
2474
2470
|
exclude
|
|
2475
2471
|
};
|
|
@@ -3165,8 +3161,15 @@ function createDocsAPI(options) {
|
|
|
3165
3161
|
}
|
|
3166
3162
|
const query = url.searchParams.get("query")?.trim();
|
|
3167
3163
|
const audience = resolveDocsSearchAudience(url.searchParams.get("audience"));
|
|
3168
|
-
|
|
3169
|
-
|
|
3164
|
+
let searchRequest;
|
|
3165
|
+
try {
|
|
3166
|
+
searchRequest = resolveDocsSearchRequest(url.searchParams);
|
|
3167
|
+
} catch (error) {
|
|
3168
|
+
const searchError = resolveDocsSearchError(error);
|
|
3169
|
+
if (!searchError) throw error;
|
|
3170
|
+
return Response.json({ error: searchError }, { status: 400 });
|
|
3171
|
+
}
|
|
3172
|
+
const { filters, structured, cursor, limit } = searchRequest;
|
|
3170
3173
|
if (!query && !structured) return new Response("[]", { headers: { "Content-Type": "application/json" } });
|
|
3171
3174
|
const searchOptions = {
|
|
3172
3175
|
pages: getIndexes(ctx),
|
|
@@ -3178,19 +3181,25 @@ function createDocsAPI(options) {
|
|
|
3178
3181
|
pathname: url.searchParams.get("pathname") ?? void 0,
|
|
3179
3182
|
siteTitle: llmsConfig.siteTitle ?? "Documentation",
|
|
3180
3183
|
baseUrl: markdownMetadataBaseUrl || url.origin,
|
|
3181
|
-
syncBaseUrl: markdownMetadataBaseUrl ?? null
|
|
3184
|
+
syncBaseUrl: markdownMetadataBaseUrl ?? null,
|
|
3185
|
+
cursor,
|
|
3186
|
+
limit
|
|
3182
3187
|
};
|
|
3183
|
-
if (!query) {
|
|
3184
|
-
const searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : [];
|
|
3185
|
-
return new Response(JSON.stringify(searchResponse), { headers: { "Content-Type": "application/json" } });
|
|
3186
|
-
}
|
|
3187
3188
|
const searchStartedAt = Date.now();
|
|
3188
|
-
|
|
3189
|
+
let searchResponse;
|
|
3190
|
+
try {
|
|
3191
|
+
searchResponse = structured ? await performDocsSearchWithMetadata(searchOptions) : query ? await performDocsSearch(searchOptions) : [];
|
|
3192
|
+
} catch (error) {
|
|
3193
|
+
const searchError = resolveDocsSearchError(error);
|
|
3194
|
+
if (!searchError) throw error;
|
|
3195
|
+
return Response.json({ error: searchError }, { status: 400 });
|
|
3196
|
+
}
|
|
3197
|
+
if (!query) return Response.json(searchResponse);
|
|
3189
3198
|
const resultCount = Array.isArray(searchResponse) ? searchResponse.length : searchResponse.resultCount;
|
|
3190
3199
|
await emitDocsAnalyticsEvent(analytics, {
|
|
3191
3200
|
type: "api_search",
|
|
3192
3201
|
source: "server",
|
|
3193
|
-
url:
|
|
3202
|
+
url: `${url.origin}${url.pathname}`,
|
|
3194
3203
|
path: url.pathname,
|
|
3195
3204
|
locale: ctx.locale,
|
|
3196
3205
|
input: { query },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.77",
|
|
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.77"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"@farming-labs/docs": ">=0.0.1",
|