@farming-labs/theme 0.1.29 → 0.1.32

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 CHANGED
@@ -34,6 +34,12 @@ const FILE_EXTS = [
34
34
  ];
35
35
  const DEFAULT_DOCS_API_ROUTE = "/api/docs";
36
36
  const DEFAULT_AGENT_SPEC_ROUTE = "/api/docs/agent/spec";
37
+ const DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE = "/.well-known/agent";
38
+ const DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE = "/.well-known/agent.json";
39
+ const DEFAULT_LLMS_TXT_ROUTE = "/llms.txt";
40
+ const DEFAULT_LLMS_FULL_TXT_ROUTE = "/llms-full.txt";
41
+ const DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE = "/.well-known/llms.txt";
42
+ const DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE = "/.well-known/llms-full.txt";
37
43
  const DEFAULT_AGENT_FEEDBACK_ROUTE = "/api/docs/agent/feedback";
38
44
  const DEFAULT_AGENT_FEEDBACK_PAYLOAD_SCHEMA = {
39
45
  type: "object",
@@ -147,7 +153,8 @@ function resolveAgentFeedbackRequest(url, feedback) {
147
153
  }
148
154
  function resolveAgentSpecRequest(url) {
149
155
  if (url.searchParams.get("agent")?.trim() === "spec") return true;
150
- return normalizeUrlPath(url.pathname) === DEFAULT_AGENT_SPEC_ROUTE;
156
+ const pathname = normalizeUrlPath(url.pathname);
157
+ return pathname === DEFAULT_AGENT_SPEC_ROUTE || pathname === DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE || pathname === DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE;
151
158
  }
152
159
  function isSearchEnabled(search) {
153
160
  if (search === false) return false;
@@ -189,10 +196,15 @@ function buildAgentSpec({ origin, entry, i18n, search, mcp, feedback, llms }) {
189
196
  api: {
190
197
  docs: DEFAULT_DOCS_API_ROUTE,
191
198
  agentSpec: DEFAULT_AGENT_SPEC_ROUTE,
199
+ agentSpecDefault: DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE,
200
+ agentSpecFallback: DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE,
201
+ agentSpecWellKnown: DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE,
202
+ agentSpecWellKnownJson: DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE,
192
203
  agentSpecQuery: `${DEFAULT_DOCS_API_ROUTE}?agent=spec`
193
204
  },
194
205
  markdown: {
195
206
  enabled: true,
207
+ acceptHeader: "text/markdown",
196
208
  pagePattern: `/${normalizedEntry}/{slug}.md`,
197
209
  rootPage: `/${normalizedEntry}.md`,
198
210
  apiPattern: `${DEFAULT_DOCS_API_ROUTE}?format=markdown&path={slug}`,
@@ -204,8 +216,14 @@ function buildAgentSpec({ origin, entry, i18n, search, mcp, feedback, llms }) {
204
216
  },
205
217
  llms: {
206
218
  enabled: llms.enabled,
219
+ defaultTxt: DEFAULT_LLMS_TXT_ROUTE,
220
+ defaultFull: DEFAULT_LLMS_FULL_TXT_ROUTE,
207
221
  txt: `${DEFAULT_DOCS_API_ROUTE}?format=llms`,
208
- full: `${DEFAULT_DOCS_API_ROUTE}?format=llms-full`
222
+ full: `${DEFAULT_DOCS_API_ROUTE}?format=llms-full`,
223
+ publicTxt: DEFAULT_LLMS_TXT_ROUTE,
224
+ publicFull: DEFAULT_LLMS_FULL_TXT_ROUTE,
225
+ wellKnownTxt: DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE,
226
+ wellKnownFull: DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE
209
227
  },
210
228
  search: {
211
229
  enabled: searchEnabled,
@@ -741,15 +759,39 @@ function findDocsMcpPage(entry, pages, requestedPath) {
741
759
  for (const page of pages) if (normalizePathSegment(page.slug) === normalizedSlug) return page;
742
760
  return null;
743
761
  }
744
- function resolveMarkdownRequest(entry, url) {
762
+ function acceptsMarkdown(request) {
763
+ const accept = request.headers.get("accept");
764
+ if (!accept) return false;
765
+ return accept.split(",").map((value) => value.trim()).some((value) => {
766
+ const [mediaType, ...params] = value.split(";").map((part) => part.trim().toLowerCase());
767
+ if (mediaType !== "text/markdown") return false;
768
+ const qualityParam = params.find((param) => param.split("=", 1)[0]?.trim() === "q");
769
+ if (!qualityParam) return true;
770
+ const qualityValue = qualityParam.slice(qualityParam.indexOf("=") + 1).trim();
771
+ const quality = Number.parseFloat(qualityValue);
772
+ return Number.isFinite(quality) ? quality > 0 : true;
773
+ });
774
+ }
775
+ function resolveMarkdownRequest(entry, url, request) {
745
776
  if (url.searchParams.get("format")?.trim() === "markdown") return { requestedPath: url.searchParams.get("path")?.trim() ?? "" };
746
777
  const pathname = normalizeUrlPath(url.pathname);
747
778
  const normalizedEntry = `/${normalizePathSegment(entry)}`;
748
779
  if (pathname === `${normalizedEntry}.md`) return { requestedPath: "" };
749
780
  const slugPrefix = `${normalizedEntry}/`;
750
781
  if (pathname.startsWith(slugPrefix) && pathname.endsWith(".md")) return { requestedPath: pathname.slice(slugPrefix.length, -3) };
782
+ if (acceptsMarkdown(request)) {
783
+ if (pathname === normalizedEntry) return { requestedPath: "" };
784
+ if (pathname.startsWith(slugPrefix)) return { requestedPath: pathname.slice(slugPrefix.length) };
785
+ }
751
786
  return null;
752
787
  }
788
+ function resolveLlmsTxtFormat(url) {
789
+ const pathname = normalizeUrlPath(url.pathname);
790
+ if (pathname === DEFAULT_LLMS_TXT_ROUTE || pathname === DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE) return "llms";
791
+ if (pathname === DEFAULT_LLMS_FULL_TXT_ROUTE || pathname === DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE) return "llms-full";
792
+ const format = url.searchParams.get("format");
793
+ return format === "llms" || format === "llms-full" ? format : null;
794
+ }
753
795
  function renderMarkdownDocument(page) {
754
796
  if ("agentRawContent" in page && page.agentRawContent !== void 0) return page.agentRawContent;
755
797
  const lines = [`# ${page.title}`, `URL: ${page.url}`];
@@ -1054,7 +1096,7 @@ function createDocsAPI(options) {
1054
1096
  "X-Robots-Tag": "noindex"
1055
1097
  } });
1056
1098
  }
1057
- const markdownRequest = resolveMarkdownRequest(entry, url);
1099
+ const markdownRequest = resolveMarkdownRequest(entry, url, request);
1058
1100
  if (markdownRequest) {
1059
1101
  const document = await getMarkdownDocument(ctx, markdownRequest.requestedPath);
1060
1102
  if (!document) return new Response("Not Found", {
@@ -1070,12 +1112,12 @@ function createDocsAPI(options) {
1070
1112
  "X-Robots-Tag": "noindex"
1071
1113
  } });
1072
1114
  }
1073
- const format = url.searchParams.get("format");
1074
- if (format === "llms") return new Response(getLlmsContent(ctx).llmsTxt, { headers: {
1115
+ const llmsFormat = resolveLlmsTxtFormat(url);
1116
+ if (llmsFormat === "llms") return new Response(getLlmsContent(ctx).llmsTxt, { headers: {
1075
1117
  "Content-Type": "text/plain; charset=utf-8",
1076
1118
  "Cache-Control": "public, max-age=3600"
1077
1119
  } });
1078
- if (format === "llms-full") return new Response(getLlmsContent(ctx).llmsFullTxt, { headers: {
1120
+ if (llmsFormat === "llms-full") return new Response(getLlmsContent(ctx).llmsFullTxt, { headers: {
1079
1121
  "Content-Type": "text/plain; charset=utf-8",
1080
1122
  "Cache-Control": "public, max-age=3600"
1081
1123
  } });
package/dist/index.d.mts CHANGED
@@ -11,9 +11,10 @@ import { DocsFeedback, DocsFeedbackProps } from "./docs-feedback.mjs";
11
11
  import { PageActions } from "./page-actions.mjs";
12
12
  import { withLangInUrl } from "./i18n.mjs";
13
13
  import { HoverLink, HoverLinkProps } from "./hover-link.mjs";
14
+ import { Agent } from "./mdx.mjs";
14
15
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
15
16
  import { AIConfig, BreadcrumbConfig, ChangelogConfig, ChangelogFrontmatter, CopyMarkdownConfig, DocsConfig, DocsFeedbackData, DocsFeedbackValue, DocsMetadata, DocsNav, DocsTheme, FeedbackConfig, FontStyle, OGConfig, OpenDocsConfig, OpenDocsProvider, PageActionsConfig, PageFrontmatter, SidebarConfig, ThemeToggleConfig, TypographyConfig, UIConfig, createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
16
17
  import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
17
18
  import { Tab, Tabs } from "fumadocs-ui/components/tabs";
18
19
  import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "fumadocs-ui/components/codeblock";
19
- export { type AIConfig, type BreadcrumbConfig, type ChangelogConfig, type ChangelogFrontmatter, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CommandGridUIDefaults, ConcreteUIDefaults, type CopyMarkdownConfig, DocsBody, DocsClientHooks, DocsCommandSearch, type DocsConfig, DocsFeedback, type DocsFeedbackData, type DocsFeedbackProps, type DocsFeedbackValue, DocsLayout, type DocsMetadata, type DocsNav, DocsPage, DocsPageClient, type DocsTheme, type FeedbackConfig, type FontStyle, DefaultUIDefaults as FumadocsUIDefaults, HardlineUIDefaults, HoverLink, type HoverLinkProps, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, PageActions, type PageActionsConfig, type PageFrontmatter, Pre, RootProvider, type SidebarConfig, Tab, Tabs, type ThemeToggleConfig, type TypographyConfig, type UIConfig, commandGrid, concrete, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, hardline, withLangInUrl };
20
+ export { type AIConfig, Agent, type BreadcrumbConfig, type ChangelogConfig, type ChangelogFrontmatter, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CommandGridUIDefaults, ConcreteUIDefaults, type CopyMarkdownConfig, DocsBody, DocsClientHooks, DocsCommandSearch, type DocsConfig, DocsFeedback, type DocsFeedbackData, type DocsFeedbackProps, type DocsFeedbackValue, DocsLayout, type DocsMetadata, type DocsNav, DocsPage, DocsPageClient, type DocsTheme, type FeedbackConfig, type FontStyle, DefaultUIDefaults as FumadocsUIDefaults, HardlineUIDefaults, HoverLink, type HoverLinkProps, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, PageActions, type PageActionsConfig, type PageFrontmatter, Pre, RootProvider, type SidebarConfig, Tab, Tabs, type ThemeToggleConfig, type TypographyConfig, type UIConfig, commandGrid, concrete, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, hardline, withLangInUrl };
package/dist/index.mjs CHANGED
@@ -11,10 +11,11 @@ import { ConcreteUIDefaults, concrete } from "./concrete/index.mjs";
11
11
  import { HardlineUIDefaults, hardline } from "./hardline/index.mjs";
12
12
  import { DocsClientHooks } from "./docs-client-hooks.mjs";
13
13
  import { HoverLink } from "./hover-link.mjs";
14
+ import { Agent } from "./mdx.mjs";
14
15
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
15
16
  import { createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
16
17
  import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
17
18
  import { Tab, Tabs } from "fumadocs-ui/components/tabs";
18
19
  import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "fumadocs-ui/components/codeblock";
19
20
 
20
- export { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CommandGridUIDefaults, ConcreteUIDefaults, DocsBody, DocsClientHooks, DocsCommandSearch, DocsFeedback, DocsLayout, DocsPage, DocsPageClient, DefaultUIDefaults as FumadocsUIDefaults, HardlineUIDefaults, HoverLink, PageActions, Pre, RootProvider, Tab, Tabs, commandGrid, concrete, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, hardline, withLangInUrl };
21
+ export { Agent, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CommandGridUIDefaults, ConcreteUIDefaults, DocsBody, DocsClientHooks, DocsCommandSearch, DocsFeedback, DocsLayout, DocsPage, DocsPageClient, DefaultUIDefaults as FumadocsUIDefaults, HardlineUIDefaults, HoverLink, PageActions, Pre, RootProvider, Tab, Tabs, commandGrid, concrete, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, hardline, withLangInUrl };
package/dist/mdx.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { HoverLink } from "./hover-link.mjs";
2
1
  import { MDXImg } from "./mdx-img.mjs";
2
+ import { HoverLink } from "./hover-link.mjs";
3
3
  import React from "react";
4
4
  import { CodeBlockCopyData, DocsTheme } from "@farming-labs/docs";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
package/dist/mdx.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { HoverLink } from "./hover-link.mjs";
2
1
  import { MDXImg } from "./mdx-img.mjs";
3
2
  import { createPreWithCopyCallback } from "./code-block-copy-wrapper.mjs";
3
+ import { HoverLink } from "./hover-link.mjs";
4
4
  import React from "react";
5
5
  import { Tab, Tabs } from "fumadocs-ui/components/tabs";
6
6
  import defaultMdxComponents from "fumadocs-ui/mdx";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.1.29",
3
+ "version": "0.1.32",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -133,7 +133,7 @@
133
133
  "tsdown": "^0.20.3",
134
134
  "typescript": "^5.9.3",
135
135
  "vitest": "^3.2.4",
136
- "@farming-labs/docs": "0.1.29"
136
+ "@farming-labs/docs": "0.1.32"
137
137
  },
138
138
  "peerDependencies": {
139
139
  "@farming-labs/docs": ">=0.0.1",