@farming-labs/docs 0.1.59 → 0.1.60
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/{agent-3gfGIRgr.mjs → agent-BQCfaA1j.mjs} +1 -1
- package/dist/cli/index.mjs +26 -8
- package/dist/dev-VD41gGZC.mjs +1289 -0
- package/dist/{doctor-_pzgvY8k.mjs → doctor-DraU0BVq.mjs} +3 -3
- package/dist/index.d.mts +2 -2
- package/dist/init-CcgI3D7-.mjs +1162 -0
- package/dist/{mcp-DSCLcG0O.mjs → mcp-BANLcwQ0.mjs} +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/{prompt-utils-CbtKaiIU.mjs → prompt-utils-8nmFLQVH.mjs} +82 -6
- package/dist/{search-DFCYC33M.mjs → search-CLoh315v.mjs} +1 -1
- package/dist/{search-DWkWwsU5.d.mts → search-COePaQmH.d.mts} +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.mjs +1 -1
- package/dist/{init-C1tsFxXo.mjs → templates-2M1vfnf-.mjs} +5 -1164
- package/dist/{upgrade-a185_G5A.mjs → upgrade-CA_OE7wL.mjs} +1 -1
- package/package.json +1 -1
- /package/dist/{types-bAjvrTGU.d.mts → types-G-xf-4_c.d.mts} +0 -0
- /package/dist/{utils-CpTFbAiS.mjs → utils-DSMXVnEu.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./prompt-utils-
|
|
1
|
+
import "./prompt-utils-8nmFLQVH.mjs";
|
|
2
2
|
import { createFilesystemDocsMcpSource, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
|
|
3
3
|
import "./server.mjs";
|
|
4
4
|
import { c as readNavTitle, f as resolveDocsConfigPath, n as extractObjectLiteral, o as readBooleanProperty, p as resolveDocsContentDir, u as readStringProperty } from "./config-Si-yUfM_.mjs";
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DocsSearchConfig, G as OrderingItem, N as DocsSearchSourcePage, v as DocsMcpConfig } from "./types-
|
|
1
|
+
import { D as DocsSearchConfig, G as OrderingItem, N as DocsSearchSourcePage, v as DocsMcpConfig } from "./types-G-xf-4_c.mjs";
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
|
@@ -61,6 +61,9 @@ function normalizeRemoteSpecUrl(value) {
|
|
|
61
61
|
if (!trimmed) return void 0;
|
|
62
62
|
return trimmed;
|
|
63
63
|
}
|
|
64
|
+
function isRequestRelativeSpecUrl(value) {
|
|
65
|
+
return typeof value === "string" && value.startsWith("/");
|
|
66
|
+
}
|
|
64
67
|
function buildApiReferencePageTitle(config, title = "API Reference") {
|
|
65
68
|
const template = config.metadata?.titleTemplate;
|
|
66
69
|
if (!template) return title;
|
|
@@ -426,18 +429,18 @@ function relativeLuminance([r, g, b]) {
|
|
|
426
429
|
function buildApiReferenceOpenApiDocument(config, options) {
|
|
427
430
|
if (resolveApiReferenceConfig(config.apiReference).specUrl) return buildUnavailableOpenApiDocument(config, `Remote OpenAPI specs require the async API reference builder. Use the framework route helper or buildApiReferenceOpenApiDocumentAsync().`);
|
|
428
431
|
const routes = buildApiReferenceRoutes(config, options);
|
|
429
|
-
return buildOpenApiDocumentFromRoutes(config, options.framework, routes);
|
|
432
|
+
return buildOpenApiDocumentFromRoutes(config, options.framework, routes, options.baseUrl);
|
|
430
433
|
}
|
|
431
434
|
async function buildApiReferenceOpenApiDocumentAsync(config, options) {
|
|
432
435
|
const apiReference = resolveApiReferenceConfig(config.apiReference);
|
|
433
436
|
if (!apiReference.specUrl) return buildApiReferenceOpenApiDocument(config, options);
|
|
434
437
|
try {
|
|
435
|
-
return normalizeRemoteOpenApiDocument(await fetchRemoteOpenApiDocument(apiReference.specUrl, options.baseUrl), config);
|
|
438
|
+
return normalizeRemoteOpenApiDocument(await fetchRemoteOpenApiDocument(apiReference.specUrl, options.baseUrl), config, options.baseUrl);
|
|
436
439
|
} catch (error) {
|
|
437
440
|
return buildUnavailableOpenApiDocument(config, `Unable to load the remote OpenAPI JSON. ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
438
441
|
}
|
|
439
442
|
}
|
|
440
|
-
function buildOpenApiDocumentFromRoutes(config, framework, routes) {
|
|
443
|
+
function buildOpenApiDocumentFromRoutes(config, framework, routes, baseUrl) {
|
|
441
444
|
const tags = Array.from(new Set(routes.map((route) => route.tag))).map((name) => ({
|
|
442
445
|
name,
|
|
443
446
|
description: `${name} endpoints`
|
|
@@ -449,7 +452,7 @@ function buildOpenApiDocumentFromRoutes(config, framework, routes) {
|
|
|
449
452
|
description: config.metadata?.description ?? `Generated API reference for ${framework}.`,
|
|
450
453
|
version: "0.0.0"
|
|
451
454
|
},
|
|
452
|
-
servers: [{ url: "/" }],
|
|
455
|
+
servers: [{ url: baseUrl ?? "/" }],
|
|
453
456
|
tags,
|
|
454
457
|
paths: buildOpenApiPaths(routes)
|
|
455
458
|
};
|
|
@@ -504,8 +507,12 @@ async function fetchRemoteOpenApiDocument(specUrl, baseUrl) {
|
|
|
504
507
|
if (!("openapi" in parsed) && !("swagger" in parsed)) throw new Error("The remote JSON does not look like an OpenAPI document.");
|
|
505
508
|
return parsed;
|
|
506
509
|
}
|
|
507
|
-
function normalizeRemoteOpenApiDocument(document, config) {
|
|
510
|
+
function normalizeRemoteOpenApiDocument(document, config, baseUrl) {
|
|
511
|
+
const apiReference = resolveApiReferenceConfig(config.apiReference);
|
|
508
512
|
const info = document.info && typeof document.info === "object" && !Array.isArray(document.info) ? document.info : {};
|
|
513
|
+
const normalizedPaths = normalizeRemoteOpenApiPaths(document.paths);
|
|
514
|
+
const normalizedTags = normalizeRemoteOpenApiTags(document.tags, normalizedPaths);
|
|
515
|
+
const normalizedServers = isRequestRelativeSpecUrl(apiReference.specUrl) ? [{ url: baseUrl ?? "/" }] : document.servers;
|
|
509
516
|
return {
|
|
510
517
|
...document,
|
|
511
518
|
info: {
|
|
@@ -513,9 +520,78 @@ function normalizeRemoteOpenApiDocument(document, config) {
|
|
|
513
520
|
version: "0.0.0",
|
|
514
521
|
...info,
|
|
515
522
|
description: typeof info.description === "string" && info.description.trim() ? info.description : config.metadata?.description
|
|
516
|
-
}
|
|
523
|
+
},
|
|
524
|
+
servers: normalizedServers,
|
|
525
|
+
paths: normalizedPaths,
|
|
526
|
+
tags: normalizedTags
|
|
517
527
|
};
|
|
518
528
|
}
|
|
529
|
+
function normalizeRemoteOpenApiPaths(value) {
|
|
530
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
531
|
+
const paths = value;
|
|
532
|
+
const normalized = {};
|
|
533
|
+
for (const [routePath, pathItem] of Object.entries(paths)) {
|
|
534
|
+
if (!pathItem || typeof pathItem !== "object" || Array.isArray(pathItem)) continue;
|
|
535
|
+
const normalizedPathItem = { ...pathItem };
|
|
536
|
+
for (const method of [
|
|
537
|
+
"get",
|
|
538
|
+
"post",
|
|
539
|
+
"put",
|
|
540
|
+
"patch",
|
|
541
|
+
"delete",
|
|
542
|
+
"options",
|
|
543
|
+
"head"
|
|
544
|
+
]) {
|
|
545
|
+
const operation = normalizedPathItem[method];
|
|
546
|
+
if (!operation || typeof operation !== "object" || Array.isArray(operation)) continue;
|
|
547
|
+
const operationRecord = operation;
|
|
548
|
+
const tags = Array.isArray(operationRecord.tags) ? operationRecord.tags.filter((tag) => typeof tag === "string" && tag.trim().length > 0) : [];
|
|
549
|
+
normalizedPathItem[method] = {
|
|
550
|
+
...operationRecord,
|
|
551
|
+
tags: tags.length > 0 ? tags : [inferRemoteOpenApiTag(routePath)]
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
normalized[routePath] = normalizedPathItem;
|
|
555
|
+
}
|
|
556
|
+
return normalized;
|
|
557
|
+
}
|
|
558
|
+
function inferRemoteOpenApiTag(routePath) {
|
|
559
|
+
return humanizeSegment(routePath.split("/").filter(Boolean).find((value) => !value.startsWith("{")) ?? "general");
|
|
560
|
+
}
|
|
561
|
+
function normalizeRemoteOpenApiTags(value, paths) {
|
|
562
|
+
const existingTags = Array.isArray(value) ? value.filter((tag) => !!tag && typeof tag === "object") : [];
|
|
563
|
+
const tagsByName = /* @__PURE__ */ new Map();
|
|
564
|
+
for (const tag of existingTags) {
|
|
565
|
+
const name = typeof tag.name === "string" && tag.name.trim() ? tag.name.trim() : void 0;
|
|
566
|
+
if (!name) continue;
|
|
567
|
+
tagsByName.set(name, tag);
|
|
568
|
+
}
|
|
569
|
+
if (paths) for (const pathItem of Object.values(paths)) for (const method of [
|
|
570
|
+
"get",
|
|
571
|
+
"post",
|
|
572
|
+
"put",
|
|
573
|
+
"patch",
|
|
574
|
+
"delete",
|
|
575
|
+
"options",
|
|
576
|
+
"head"
|
|
577
|
+
]) {
|
|
578
|
+
const operation = pathItem[method];
|
|
579
|
+
if (!operation || typeof operation !== "object" || Array.isArray(operation)) continue;
|
|
580
|
+
const tags = Array.isArray(operation.tags) ? operation.tags : [];
|
|
581
|
+
for (const tag of tags) {
|
|
582
|
+
if (typeof tag !== "string" || !tag.trim()) continue;
|
|
583
|
+
if (!tagsByName.has(tag)) tagsByName.set(tag, {
|
|
584
|
+
name: tag,
|
|
585
|
+
description: `${tag} endpoints`
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (tagsByName.size === 0) return [{
|
|
590
|
+
name: "General",
|
|
591
|
+
description: "General endpoints"
|
|
592
|
+
}];
|
|
593
|
+
return Array.from(tagsByName.values());
|
|
594
|
+
}
|
|
519
595
|
function buildUnavailableOpenApiDocument(config, description) {
|
|
520
596
|
return {
|
|
521
597
|
openapi: "3.1.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, t as buildDocsSearchDocuments } from "./search-Cu_pxL8o.mjs";
|
|
2
|
-
import "./prompt-utils-
|
|
2
|
+
import "./prompt-utils-8nmFLQVH.mjs";
|
|
3
3
|
import { createFilesystemDocsMcpSource } from "./mcp.mjs";
|
|
4
4
|
import "./server.mjs";
|
|
5
5
|
import { a as loadProjectEnv, d as readTopLevelStringProperty, f as resolveDocsConfigPath, p as resolveDocsContentDir } from "./config-Si-yUfM_.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, E as DocsSearchChunkingConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, ct as TypesenseDocsSearchConfig, d as CustomDocsSearchConfig, j as DocsSearchResult, r as AlgoliaDocsSearchConfig } from "./types-
|
|
1
|
+
import { B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, E as DocsSearchChunkingConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, ct as TypesenseDocsSearchConfig, d as CustomDocsSearchConfig, j as DocsSearchResult, r as AlgoliaDocsSearchConfig } from "./types-G-xf-4_c.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,6 +1,6 @@
|
|
|
1
|
-
import { A as DocsSearchQuery, B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, U as OpenDocsProvider, a as ApiReferenceRenderer, j as DocsSearchResult, m as DocsConfig, w as DocsSearchAdapterContext } from "./types-
|
|
1
|
+
import { A as DocsSearchQuery, B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, U as OpenDocsProvider, a as ApiReferenceRenderer, j as DocsSearchResult, m as DocsConfig, w as DocsSearchAdapterContext } from "./types-G-xf-4_c.mjs";
|
|
2
2
|
import { DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
|
|
3
|
-
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-
|
|
3
|
+
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-COePaQmH.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/api-reference.d.ts
|
|
6
6
|
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
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-Cu_pxL8o.mjs";
|
|
2
|
-
import { a as sanitizePromptText, c as serializeOpenDocsProviders, d as buildApiReferenceOpenApiDocument, f as buildApiReferenceOpenApiDocumentAsync, g as resolveApiReferenceRenderer, h as resolveApiReferenceConfig, i as resolvePromptProviderChoices, l as buildApiReferenceHtmlDocument, m as buildApiReferenceScalarCss, n as normalizePromptProviderName, o as serializeDocsIcon, p as buildApiReferencePageTitle, r as parsePromptStringArray, s as serializeDocsIconRegistry, t as DEFAULT_PROMPT_PROVIDER_TEMPLATES, u as buildApiReferenceHtmlDocumentAsync } from "./prompt-utils-
|
|
2
|
+
import { a as sanitizePromptText, c as serializeOpenDocsProviders, d as buildApiReferenceOpenApiDocument, f as buildApiReferenceOpenApiDocumentAsync, g as resolveApiReferenceRenderer, h as resolveApiReferenceConfig, i as resolvePromptProviderChoices, l as buildApiReferenceHtmlDocument, m as buildApiReferenceScalarCss, n as normalizePromptProviderName, o as serializeDocsIcon, p as buildApiReferencePageTitle, r as parsePromptStringArray, s as serializeDocsIconRegistry, t as DEFAULT_PROMPT_PROVIDER_TEMPLATES, u as buildApiReferenceHtmlDocumentAsync } from "./prompt-utils-8nmFLQVH.mjs";
|
|
3
3
|
import { createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
|
|
4
4
|
|
|
5
5
|
export { DEFAULT_PROMPT_PROVIDER_TEMPLATES, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsSearchDocuments, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, resolveApiReferenceConfig, resolveApiReferenceRenderer, resolveDocsMcpConfig, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProviders };
|