@farming-labs/docs 0.1.17 → 0.1.18
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/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as ThemeToggleConfig, A as DocsTheme, B as OpenGraphImage, C as DocsSearchConfig, D as DocsSearchResult, E as DocsSearchQuery, F as LlmsTxtConfig, G as PageTwitter, H as PageActionsConfig, I as McpDocsSearchConfig, J as SidebarFolderNode, K as SidebarComponentProps, L as OGConfig, M as FontStyle, N as GithubConfig, O as DocsSearchResultType, P as LastUpdatedConfig, Q as SimpleDocsSearchConfig, R as OpenDocsConfig, S as DocsSearchChunkingConfig, T as DocsSearchEmbeddingsConfig, U as PageFrontmatter, V as OrderingItem, W as PageOpenGraph, X as SidebarPageNode, Y as SidebarNode, Z as SidebarTree, _ as DocsMetadata, a as BreadcrumbConfig, b as DocsSearchAdapterContext, c as CodeBlockCopyData, d as DocsConfig, et as TypesenseDocsSearchConfig, f as DocsFeedbackData, g as DocsMcpToolsConfig, h as DocsMcpConfig, i as ApiReferenceRenderer, j as FeedbackConfig, k as DocsSearchSourcePage, l as CopyMarkdownConfig, m as DocsI18nConfig, n as AlgoliaDocsSearchConfig, nt as UIConfig, o as ChangelogConfig, p as DocsFeedbackValue, q as SidebarConfig, r as ApiReferenceConfig, s as ChangelogFrontmatter, t as AIConfig, tt as TypographyConfig, u as CustomDocsSearchConfig, v as DocsNav, w as DocsSearchDocument, x as DocsSearchAdapterFactory, y as DocsSearchAdapter, z as OpenDocsProvider } from "./types-
|
|
2
|
-
import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-
|
|
1
|
+
import { $ as ThemeToggleConfig, A as DocsTheme, B as OpenGraphImage, C as DocsSearchConfig, D as DocsSearchResult, E as DocsSearchQuery, F as LlmsTxtConfig, G as PageTwitter, H as PageActionsConfig, I as McpDocsSearchConfig, J as SidebarFolderNode, K as SidebarComponentProps, L as OGConfig, M as FontStyle, N as GithubConfig, O as DocsSearchResultType, P as LastUpdatedConfig, Q as SimpleDocsSearchConfig, R as OpenDocsConfig, S as DocsSearchChunkingConfig, T as DocsSearchEmbeddingsConfig, U as PageFrontmatter, V as OrderingItem, W as PageOpenGraph, X as SidebarPageNode, Y as SidebarNode, Z as SidebarTree, _ as DocsMetadata, a as BreadcrumbConfig, b as DocsSearchAdapterContext, c as CodeBlockCopyData, d as DocsConfig, et as TypesenseDocsSearchConfig, f as DocsFeedbackData, g as DocsMcpToolsConfig, h as DocsMcpConfig, i as ApiReferenceRenderer, j as FeedbackConfig, k as DocsSearchSourcePage, l as CopyMarkdownConfig, m as DocsI18nConfig, n as AlgoliaDocsSearchConfig, nt as UIConfig, o as ChangelogConfig, p as DocsFeedbackValue, q as SidebarConfig, r as ApiReferenceConfig, s as ChangelogFrontmatter, t as AIConfig, tt as TypographyConfig, u as CustomDocsSearchConfig, v as DocsNav, w as DocsSearchDocument, x as DocsSearchAdapterFactory, y as DocsSearchAdapter, z as OpenDocsProvider } from "./types-Du01bck0.mjs";
|
|
2
|
+
import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-CzTO1EMx.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/define-docs.d.ts
|
|
5
5
|
/**
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as DocsSearchConfig, V as OrderingItem, h as DocsMcpConfig } from "./types-
|
|
1
|
+
import { C as DocsSearchConfig, V as OrderingItem, h as DocsMcpConfig } from "./types-Du01bck0.mjs";
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
|
@@ -12,6 +12,8 @@ interface DocsMcpPage {
|
|
|
12
12
|
rawContent?: string;
|
|
13
13
|
agentContent?: string;
|
|
14
14
|
agentRawContent?: string;
|
|
15
|
+
agentFallbackContent?: string;
|
|
16
|
+
agentFallbackRawContent?: string;
|
|
15
17
|
}
|
|
16
18
|
interface DocsMcpPageNode {
|
|
17
19
|
type: "page";
|
package/dist/mcp.mjs
CHANGED
|
@@ -30,7 +30,7 @@ function normalizeDocsMcpRoute(route) {
|
|
|
30
30
|
return normalized !== "/" ? normalized.replace(/\/+$/, "") : DEFAULT_MCP_ROUTE;
|
|
31
31
|
}
|
|
32
32
|
function resolveDocsMcpConfig(mcp, defaults = {}) {
|
|
33
|
-
if (
|
|
33
|
+
if (mcp === false) return {
|
|
34
34
|
enabled: false,
|
|
35
35
|
route: normalizeDocsMcpRoute(defaults.defaultRoute),
|
|
36
36
|
name: defaults.defaultName ?? DEFAULT_MCP_NAME,
|
|
@@ -42,7 +42,7 @@ function resolveDocsMcpConfig(mcp, defaults = {}) {
|
|
|
42
42
|
getNavigation: true
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
const config = typeof mcp === "object" ? mcp : {};
|
|
45
|
+
const config = mcp && typeof mcp === "object" ? mcp : {};
|
|
46
46
|
return {
|
|
47
47
|
enabled: typeof mcp === "boolean" ? mcp : config.enabled ?? true,
|
|
48
48
|
route: normalizeDocsMcpRoute(config.route ?? defaults.defaultRoute),
|
|
@@ -185,9 +185,9 @@ function createDocsMcpHttpHandler(options) {
|
|
|
185
185
|
defaultName: options.defaultName ?? options.source.siteTitle ?? DEFAULT_MCP_NAME,
|
|
186
186
|
defaultVersion: options.defaultVersion
|
|
187
187
|
}).enabled) return {
|
|
188
|
-
GET: async () => createJsonErrorResponse(404, "MCP is
|
|
189
|
-
POST: async () => createJsonErrorResponse(404, "MCP is
|
|
190
|
-
DELETE: async () => createJsonErrorResponse(404, "MCP is
|
|
188
|
+
GET: async () => createJsonErrorResponse(404, "MCP is disabled. Remove `mcp: false` or set `mcp: { enabled: true }` in docs.config to enable it again."),
|
|
189
|
+
POST: async () => createJsonErrorResponse(404, "MCP is disabled. Remove `mcp: false` or set `mcp: { enabled: true }` in docs.config to enable it again."),
|
|
190
|
+
DELETE: async () => createJsonErrorResponse(404, "MCP is disabled. Remove `mcp: false` or set `mcp: { enabled: true }` in docs.config to enable it again.")
|
|
191
191
|
};
|
|
192
192
|
const sessions = /* @__PURE__ */ new Map();
|
|
193
193
|
async function createSession() {
|
|
@@ -252,6 +252,53 @@ function normalizePathSegment(value) {
|
|
|
252
252
|
function titleize(value) {
|
|
253
253
|
return value.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
254
254
|
}
|
|
255
|
+
function resolveAgentMdxContent(content, audience) {
|
|
256
|
+
const lines = content.split("\n");
|
|
257
|
+
const output = [];
|
|
258
|
+
let fenceMarker = null;
|
|
259
|
+
let agentDepth = 0;
|
|
260
|
+
for (const line of lines) {
|
|
261
|
+
const trimmed = line.trim();
|
|
262
|
+
const fenceMatch = trimmed.match(/^(`{3,}|~{3,})/);
|
|
263
|
+
if (fenceMatch) {
|
|
264
|
+
if (!fenceMarker) fenceMarker = fenceMatch[1];
|
|
265
|
+
else if (trimmed.startsWith(fenceMarker)) fenceMarker = null;
|
|
266
|
+
if (audience === "agent" || agentDepth === 0) output.push(line);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (!fenceMarker) {
|
|
270
|
+
if (/^<Agent(?:\s[^>]*)?\/>$/.test(trimmed)) continue;
|
|
271
|
+
const singleLineMatch = line.match(/^(\s*)<Agent(?:\s[^>]*)?>([\s\S]*?)<\/Agent>\s*$/);
|
|
272
|
+
if (singleLineMatch) {
|
|
273
|
+
if (audience === "agent" && singleLineMatch[2]) output.push(`${singleLineMatch[1]}${singleLineMatch[2]}`);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (line.match(/^(\s*)<Agent(?:\s[^>]*)?>\s*$/)) {
|
|
277
|
+
agentDepth += 1;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const openWithContentMatch = line.match(/^(\s*)<Agent(?:\s[^>]*)?>(.*)$/);
|
|
281
|
+
if (openWithContentMatch) {
|
|
282
|
+
agentDepth += 1;
|
|
283
|
+
if (audience === "agent" && openWithContentMatch[2]) output.push(`${openWithContentMatch[1]}${openWithContentMatch[2]}`);
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
const closeWithContentMatch = line.match(/^(.*)<\/Agent>\s*$/);
|
|
287
|
+
if (closeWithContentMatch && agentDepth > 0) {
|
|
288
|
+
if (audience === "agent" && closeWithContentMatch[1]) output.push(closeWithContentMatch[1]);
|
|
289
|
+
agentDepth = Math.max(0, agentDepth - 1);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (/^<\/Agent>\s*$/.test(trimmed) && agentDepth > 0) {
|
|
293
|
+
agentDepth = Math.max(0, agentDepth - 1);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (agentDepth > 0 && audience === "human") continue;
|
|
298
|
+
output.push(line);
|
|
299
|
+
}
|
|
300
|
+
return output.join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
301
|
+
}
|
|
255
302
|
function stripMarkdownForMcp(content) {
|
|
256
303
|
return content.replace(/^(import|export)\s.*$/gm, "").replace(/<[^>]+\/>/g, "").replace(/<\/?[A-Z][^>]*>/g, "").replace(/<\/?[a-z][^>]*>/g, "").replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/^#{1,6}\s+/gm, "").replace(/(\*{1,3}|_{1,3})(.*?)\1/g, "$2").replace(/```[\s\S]*?```/g, "").replace(/`([^`]+)`/g, "$1").replace(/^>\s+/gm, "").replace(/^[-*_]{3,}\s*$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
257
304
|
}
|
|
@@ -269,6 +316,9 @@ function scanFilesystemDocsPages(contentDirAbs, entry) {
|
|
|
269
316
|
if (name === "agent.md") continue;
|
|
270
317
|
if (!name.endsWith(".md") && !name.endsWith(".mdx") && !name.endsWith(".svx")) continue;
|
|
271
318
|
const { data, content } = matter(fs.readFileSync(full, "utf-8"));
|
|
319
|
+
const humanRawContent = resolveAgentMdxContent(content, "human");
|
|
320
|
+
const pageAgentRawContent = resolveAgentMdxContent(content, "agent");
|
|
321
|
+
const pageAgentContent = pageAgentRawContent !== humanRawContent ? stripMarkdownForMcp(pageAgentRawContent) : void 0;
|
|
272
322
|
const baseName = name.replace(/\.(md|mdx|svx)$/, "");
|
|
273
323
|
const isIndex = baseName === "index" || baseName === "page" || baseName === "+page";
|
|
274
324
|
const slug = isIndex ? slugParts.join("/") : [...slugParts, baseName].join("/");
|
|
@@ -281,10 +331,12 @@ function scanFilesystemDocsPages(contentDirAbs, entry) {
|
|
|
281
331
|
title,
|
|
282
332
|
description: data.description,
|
|
283
333
|
icon: data.icon,
|
|
284
|
-
content: stripMarkdownForMcp(
|
|
285
|
-
rawContent:
|
|
286
|
-
|
|
287
|
-
|
|
334
|
+
content: stripMarkdownForMcp(humanRawContent),
|
|
335
|
+
rawContent: humanRawContent,
|
|
336
|
+
agentFallbackContent: pageAgentContent,
|
|
337
|
+
agentFallbackRawContent: pageAgentRawContent !== humanRawContent ? pageAgentRawContent : void 0,
|
|
338
|
+
order: typeof data.order === "number" ? data.order : Number.POSITIVE_INFINITY,
|
|
339
|
+
...agentDoc
|
|
288
340
|
});
|
|
289
341
|
}
|
|
290
342
|
}
|
|
@@ -407,8 +459,12 @@ function toSearchSourcePages(pages) {
|
|
|
407
459
|
return pages.map((page) => ({
|
|
408
460
|
title: page.title,
|
|
409
461
|
url: page.url,
|
|
410
|
-
content: page.content,
|
|
411
|
-
rawContent: page.rawContent,
|
|
462
|
+
content: page.agentContent ?? page.agentFallbackContent ?? page.content,
|
|
463
|
+
rawContent: page.agentRawContent ?? page.agentFallbackRawContent ?? page.rawContent,
|
|
464
|
+
agentContent: page.agentContent,
|
|
465
|
+
agentRawContent: page.agentRawContent,
|
|
466
|
+
agentFallbackContent: page.agentFallbackContent,
|
|
467
|
+
agentFallbackRawContent: page.agentFallbackRawContent,
|
|
412
468
|
description: page.description
|
|
413
469
|
}));
|
|
414
470
|
}
|
|
@@ -468,7 +524,7 @@ function renderPageDocument(page) {
|
|
|
468
524
|
if (page.agentRawContent !== void 0) return page.agentRawContent;
|
|
469
525
|
const lines = [`# ${page.title}`, `URL: ${page.url}`];
|
|
470
526
|
if (page.description) lines.push(`Description: ${page.description}`);
|
|
471
|
-
lines.push("", page.rawContent ?? page.content);
|
|
527
|
+
lines.push("", page.agentFallbackRawContent ?? page.rawContent ?? page.content);
|
|
472
528
|
return lines.join("\n");
|
|
473
529
|
}
|
|
474
530
|
function renderNavigationTree(tree) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as DocsSearchConfig, D as DocsSearchResult, I as McpDocsSearchConfig, S as DocsSearchChunkingConfig, et as TypesenseDocsSearchConfig, k as DocsSearchSourcePage, n as AlgoliaDocsSearchConfig, u as CustomDocsSearchConfig, w as DocsSearchDocument, x as DocsSearchAdapterFactory, y as DocsSearchAdapter } from "./types-
|
|
1
|
+
import { C as DocsSearchConfig, D as DocsSearchResult, I as McpDocsSearchConfig, S as DocsSearchChunkingConfig, et as TypesenseDocsSearchConfig, k as DocsSearchSourcePage, n as AlgoliaDocsSearchConfig, u as CustomDocsSearchConfig, w as DocsSearchDocument, x as DocsSearchAdapterFactory, y as DocsSearchAdapter } from "./types-Du01bck0.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/search.d.ts
|
|
4
4
|
declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig): DocsSearchDocument[];
|
package/dist/server.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as DocsSearchConfig, D as DocsSearchResult, E as DocsSearchQuery, I as McpDocsSearchConfig, b as DocsSearchAdapterContext, d as DocsConfig, i as ApiReferenceRenderer, k as DocsSearchSourcePage, w as DocsSearchDocument, x as DocsSearchAdapterFactory, y as DocsSearchAdapter } from "./types-
|
|
2
|
-
import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-
|
|
1
|
+
import { C as DocsSearchConfig, D as DocsSearchResult, E as DocsSearchQuery, I as McpDocsSearchConfig, b as DocsSearchAdapterContext, d as DocsConfig, i as ApiReferenceRenderer, k as DocsSearchSourcePage, w as DocsSearchDocument, x as DocsSearchAdapterFactory, y as DocsSearchAdapter } from "./types-Du01bck0.mjs";
|
|
2
|
+
import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-CzTO1EMx.mjs";
|
|
3
3
|
import { DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/api-reference.d.ts
|
|
@@ -621,6 +621,10 @@ interface DocsSearchSourcePage {
|
|
|
621
621
|
content: string;
|
|
622
622
|
description?: string;
|
|
623
623
|
rawContent?: string;
|
|
624
|
+
agentContent?: string;
|
|
625
|
+
agentRawContent?: string;
|
|
626
|
+
agentFallbackContent?: string;
|
|
627
|
+
agentFallbackRawContent?: string;
|
|
624
628
|
type?: "page" | "api" | "code" | "changelog";
|
|
625
629
|
locale?: string;
|
|
626
630
|
framework?: string;
|
|
@@ -1517,9 +1521,10 @@ interface DocsConfig {
|
|
|
1517
1521
|
/**
|
|
1518
1522
|
* Built-in MCP server for agent/assistant access to your docs content.
|
|
1519
1523
|
*
|
|
1524
|
+
* - omitted → enable the default MCP surface at `/api/docs/mcp`
|
|
1520
1525
|
* - `true` → enable the default MCP surface at `/api/docs/mcp`
|
|
1521
1526
|
* - `{ route: "/api/docs/mcp" }` → enable with explicit route/config
|
|
1522
|
-
* - `false` or
|
|
1527
|
+
* - `false` or `{ enabled: false }` → disable MCP explicitly
|
|
1523
1528
|
*/
|
|
1524
1529
|
mcp?: boolean | DocsMcpConfig;
|
|
1525
1530
|
/**
|