@farming-labs/theme 0.1.73 → 0.1.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 -1
- package/dist/docs-api.mjs +11 -2
- package/package.json +2 -2
package/dist/docs-api.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangelogConfig, DocsAnalyticsConfig, DocsI18nConfig, DocsMcpConfig, DocsObservabilityConfig, DocsSearchConfig, FeedbackConfig, OrderingItem } from "@farming-labs/docs";
|
|
1
|
+
import { ChangelogConfig, DocsAnalyticsConfig, DocsAskAIMcpConfig, DocsI18nConfig, DocsMcpConfig, DocsObservabilityConfig, DocsSearchConfig, FeedbackConfig, OrderingItem } from "@farming-labs/docs";
|
|
2
2
|
|
|
3
3
|
//#region src/docs-api.d.ts
|
|
4
4
|
interface AIProviderConfig {
|
|
@@ -28,6 +28,7 @@ interface AIOptions {
|
|
|
28
28
|
/** Default apiKey when no per-model provider is configured. */
|
|
29
29
|
apiKey?: string;
|
|
30
30
|
maxResults?: number;
|
|
31
|
+
useMcp?: boolean | DocsAskAIMcpConfig;
|
|
31
32
|
}
|
|
32
33
|
interface DocsAPIOptions {
|
|
33
34
|
rootDir?: string;
|
package/dist/docs-api.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { getNextAppDir } from "./get-app-dir.mjs";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import matter from "gray-matter";
|
|
6
|
-
import { buildDocsAskAIContext, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, normalizeDocsRelated, performDocsSearch, renderDocsRelatedMarkdownLines, resolveChangelogConfig, resolveDocsI18n, resolveDocsLocale, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig } from "@farming-labs/docs";
|
|
6
|
+
import { buildDocsAskAIContext, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, normalizeDocsRelated, performDocsSearch, renderDocsRelatedMarkdownLines, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsI18n, resolveDocsLocale, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig } from "@farming-labs/docs";
|
|
7
7
|
import { createDocsMcpHttpHandler, createFilesystemDocsMcpSource, resolveDocsMcpConfig } from "@farming-labs/docs/server";
|
|
8
8
|
|
|
9
9
|
//#region src/docs-api.ts
|
|
@@ -413,6 +413,7 @@ function readAIConfig(root) {
|
|
|
413
413
|
const baseUrlMatch = content.match(/ai\s*:\s*\{[^}]*baseUrl\s*:\s*["']([^"']+)["']/s);
|
|
414
414
|
const apiKeyMatch = content.match(/ai\s*:\s*\{[^}]*apiKey\s*:\s*process\.env\.(\w+)/s);
|
|
415
415
|
const maxResultsMatch = content.match(/ai\s*:\s*\{[^}]*maxResults\s*:\s*(\d+)/s);
|
|
416
|
+
const useMcpMatch = content.match(/ai\s*:\s*\{[^}]*useMcp\s*:\s*(true|false)/s);
|
|
416
417
|
const systemPromptMatch = content.match(/ai\s*:\s*\{[^}]*systemPrompt\s*:\s*["'`]([^"'`]+)["'`]/s);
|
|
417
418
|
const packageNameMatch = content.match(/ai\s*:\s*\{[^}]*packageName\s*:\s*["'`]([^"'`]+)["'`]/s);
|
|
418
419
|
const docsUrlMatch = content.match(/ai\s*:\s*\{[^}]*docsUrl\s*:\s*["'`]([^"'`]+)["'`]/s);
|
|
@@ -422,6 +423,7 @@ function readAIConfig(root) {
|
|
|
422
423
|
baseUrl: baseUrlMatch?.[1],
|
|
423
424
|
apiKey: apiKeyMatch?.[1] ? process.env[apiKeyMatch[1]] : void 0,
|
|
424
425
|
maxResults: maxResultsMatch ? parseInt(maxResultsMatch[1], 10) : void 0,
|
|
426
|
+
useMcp: useMcpMatch ? useMcpMatch[1] === "true" : void 0,
|
|
425
427
|
systemPrompt: systemPromptMatch?.[1],
|
|
426
428
|
packageName: packageNameMatch?.[1],
|
|
427
429
|
docsUrl: docsUrlMatch?.[1]
|
|
@@ -1901,7 +1903,14 @@ function createDocsAPI(options) {
|
|
|
1901
1903
|
return Response.json({ error: "AI is not enabled. Set `ai: { enabled: true }` in your docs.config to enable it." }, { status: 404 });
|
|
1902
1904
|
}
|
|
1903
1905
|
const ctx = resolveContextFromRequest(request);
|
|
1904
|
-
return handleAskAI(request, getIndexes(ctx), aiConfig,
|
|
1906
|
+
return handleAskAI(request, getIndexes(ctx), aiConfig, resolveAskAISearchRequestConfig({
|
|
1907
|
+
search: searchConfig,
|
|
1908
|
+
useMcp: aiConfig.useMcp,
|
|
1909
|
+
mcpEndpoint: mcpConfig.route,
|
|
1910
|
+
mcpEnabled: mcpConfig.enabled,
|
|
1911
|
+
mcpSearchEnabled: mcpConfig.tools.searchDocs,
|
|
1912
|
+
requestUrl: request.url
|
|
1913
|
+
}), analytics, observability, { locale: ctx.locale });
|
|
1905
1914
|
}
|
|
1906
1915
|
};
|
|
1907
1916
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"tsdown": "^0.20.3",
|
|
140
140
|
"typescript": "^5.9.3",
|
|
141
141
|
"vitest": "^3.2.4",
|
|
142
|
-
"@farming-labs/docs": "0.1.
|
|
142
|
+
"@farming-labs/docs": "0.1.74"
|
|
143
143
|
},
|
|
144
144
|
"peerDependencies": {
|
|
145
145
|
"@farming-labs/docs": ">=0.0.1",
|