@farming-labs/next 0.1.32 → 0.1.34
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/config.mjs +21 -10
- package/package.json +3 -3
package/dist/config.mjs
CHANGED
|
@@ -150,6 +150,9 @@ const DEFAULT_AGENT_SPEC_ROUTE = "/api/docs/agent/spec";
|
|
|
150
150
|
const DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE = "/.well-known/agent";
|
|
151
151
|
const DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE = "/.well-known/agent.json";
|
|
152
152
|
const DEFAULT_AGENT_FEEDBACK_ROUTE = "/api/docs/agent/feedback";
|
|
153
|
+
const DEFAULT_MCP_ROUTE = "/api/docs/mcp";
|
|
154
|
+
const DEFAULT_MCP_PUBLIC_ROUTE = "/mcp";
|
|
155
|
+
const DEFAULT_MCP_WELL_KNOWN_ROUTE = "/.well-known/mcp";
|
|
153
156
|
const DEFAULT_LLMS_TXT_ROUTE = "/llms.txt";
|
|
154
157
|
const DEFAULT_LLMS_FULL_TXT_ROUTE = "/llms-full.txt";
|
|
155
158
|
const DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE = "/.well-known/llms.txt";
|
|
@@ -636,11 +639,11 @@ function readMcpConfig(root) {
|
|
|
636
639
|
const content = readFileSync(configPath, "utf-8");
|
|
637
640
|
if (content.match(/mcp\s*:\s*false/)) return {
|
|
638
641
|
enabled: false,
|
|
639
|
-
route:
|
|
642
|
+
route: DEFAULT_MCP_ROUTE
|
|
640
643
|
};
|
|
641
644
|
if (content.match(/mcp\s*:\s*true/)) return {
|
|
642
645
|
enabled: true,
|
|
643
|
-
route:
|
|
646
|
+
route: DEFAULT_MCP_ROUTE
|
|
644
647
|
};
|
|
645
648
|
const block = extractObjectLiteral(content, "mcp");
|
|
646
649
|
if (!block) continue;
|
|
@@ -648,23 +651,23 @@ function readMcpConfig(root) {
|
|
|
648
651
|
const routeMatch = block.match(/route\s*:\s*["']([^"']+)["']/);
|
|
649
652
|
return {
|
|
650
653
|
enabled: enabledMatch ? enabledMatch[1] !== "false" : true,
|
|
651
|
-
route: normalizeRoutePath(routeMatch?.[1] ??
|
|
654
|
+
route: normalizeRoutePath(routeMatch?.[1] ?? DEFAULT_MCP_ROUTE)
|
|
652
655
|
};
|
|
653
656
|
} catch {
|
|
654
657
|
return {
|
|
655
658
|
enabled: true,
|
|
656
|
-
route:
|
|
659
|
+
route: DEFAULT_MCP_ROUTE
|
|
657
660
|
};
|
|
658
661
|
}
|
|
659
662
|
}
|
|
660
663
|
return {
|
|
661
664
|
enabled: true,
|
|
662
|
-
route:
|
|
665
|
+
route: DEFAULT_MCP_ROUTE
|
|
663
666
|
};
|
|
664
667
|
}
|
|
665
668
|
function normalizeRoutePath(route) {
|
|
666
669
|
const normalized = `/${route}`.replace(/\/+/g, "/");
|
|
667
|
-
return normalized !== "/" ? normalized.replace(/\/+$/, "") :
|
|
670
|
+
return normalized !== "/" ? normalized.replace(/\/+$/, "") : DEFAULT_MCP_ROUTE;
|
|
668
671
|
}
|
|
669
672
|
function normalizeAgentFeedbackRoute(route, fallback = DEFAULT_AGENT_FEEDBACK_ROUTE) {
|
|
670
673
|
if (!route || route.trim().length === 0) return fallback;
|
|
@@ -771,6 +774,13 @@ function buildLlmsTxtRewrites() {
|
|
|
771
774
|
}
|
|
772
775
|
];
|
|
773
776
|
}
|
|
777
|
+
function buildMcpRewrites(config) {
|
|
778
|
+
if (!config.enabled) return [];
|
|
779
|
+
return [DEFAULT_MCP_PUBLIC_ROUTE, DEFAULT_MCP_WELL_KNOWN_ROUTE].filter((source) => source !== config.route).map((source) => ({
|
|
780
|
+
source,
|
|
781
|
+
destination: config.route
|
|
782
|
+
}));
|
|
783
|
+
}
|
|
774
784
|
function buildAgentFeedbackRewrites(config) {
|
|
775
785
|
if (!config.enabled) return [];
|
|
776
786
|
return [{
|
|
@@ -792,9 +802,10 @@ function dedupeRewrites(rewrites) {
|
|
|
792
802
|
}
|
|
793
803
|
return result;
|
|
794
804
|
}
|
|
795
|
-
function mergeDocsMarkdownRewrites(entry, agentFeedback, result) {
|
|
805
|
+
function mergeDocsMarkdownRewrites(entry, mcp, agentFeedback, result) {
|
|
796
806
|
const autoRewrites = [
|
|
797
807
|
...buildAgentSpecRewrites(),
|
|
808
|
+
...buildMcpRewrites(mcp),
|
|
798
809
|
...buildLlmsTxtRewrites(),
|
|
799
810
|
...buildDocsMarkdownRewrites(entry),
|
|
800
811
|
...buildAgentFeedbackRewrites(agentFeedback)
|
|
@@ -834,7 +845,7 @@ function withDocs(nextConfig = {}) {
|
|
|
834
845
|
}
|
|
835
846
|
const mcp = readMcpConfig(root);
|
|
836
847
|
const docsMcpRouteDir = join(root, appDir, "api", "docs", "mcp");
|
|
837
|
-
if (mcp.enabled && mcp.route ===
|
|
848
|
+
if (mcp.enabled && mcp.route === DEFAULT_MCP_ROUTE && !isStaticExport && !hasFile(docsMcpRouteDir, "route")) {
|
|
838
849
|
mkdirSync(docsMcpRouteDir, { recursive: true });
|
|
839
850
|
writeFileSync(join(docsMcpRouteDir, "route.ts"), DOCS_MCP_ROUTE_TEMPLATE);
|
|
840
851
|
}
|
|
@@ -985,13 +996,13 @@ function withDocs(nextConfig = {}) {
|
|
|
985
996
|
if (!isStaticExport) {
|
|
986
997
|
const existingRewrites = nextConfig.rewrites;
|
|
987
998
|
nextConfig.rewrites = async () => {
|
|
988
|
-
return mergeDocsMarkdownRewrites(entry, agentFeedback, typeof existingRewrites === "function" ? await existingRewrites() : existingRewrites);
|
|
999
|
+
return mergeDocsMarkdownRewrites(entry, mcp, agentFeedback, typeof existingRewrites === "function" ? await existingRewrites() : existingRewrites);
|
|
989
1000
|
};
|
|
990
1001
|
}
|
|
991
1002
|
nextConfig.outputFileTracingIncludes = {
|
|
992
1003
|
...existingTracingIncludes,
|
|
993
1004
|
"/api/docs": [...new Set([...existingTracingIncludes["/api/docs"] ?? [], docsTraceGlob])],
|
|
994
|
-
|
|
1005
|
+
[DEFAULT_MCP_ROUTE]: [...new Set([...existingTracingIncludes[DEFAULT_MCP_ROUTE] ?? [], docsTraceGlob])]
|
|
995
1006
|
};
|
|
996
1007
|
return withMDX(nextConfig);
|
|
997
1008
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"tsdown": "^0.20.3",
|
|
96
96
|
"typescript": "^5.9.3",
|
|
97
97
|
"vitest": "^3.2.4",
|
|
98
|
-
"@farming-labs/
|
|
99
|
-
"@farming-labs/
|
|
98
|
+
"@farming-labs/docs": "0.1.34",
|
|
99
|
+
"@farming-labs/theme": "0.1.34"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"@farming-labs/docs": ">=0.0.1",
|