@farming-labs/docs 0.1.73 → 0.1.75
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-D94TCE7Q.mjs → agent-CHLNeC5o.mjs} +4 -4
- package/dist/{agent-C3PhBE3t.mjs → agent-CbX-9Z0z.mjs} +35 -5
- package/dist/cli/index.mjs +30 -8
- package/dist/{dev-BQIDeAoL.mjs → dev-B_Pd2iNL.mjs} +2 -2
- package/dist/{doctor-BFq5YKLg.mjs → doctor-DRhAgUqi.mjs} +6 -6
- package/dist/index.d.mts +28 -4
- package/dist/index.mjs +4 -3
- package/dist/{init-BFhnsS7P.mjs → init-B0oTzLXb.mjs} +2 -2
- package/dist/{mcp-DaNntgC6.mjs → mcp-BPW62uf-.mjs} +3 -3
- package/dist/mcp.d.mts +3 -1
- package/dist/mcp.mjs +9 -4
- package/dist/search-D6uAGmiH.d.mts +196 -0
- package/dist/{search-BzavsA3i.mjs → search-DD2SP_hD.mjs} +3 -3
- package/dist/{search-DBZ6Tkij.mjs → search-kP0mAXCp.mjs} +13 -1
- package/dist/server.d.mts +6 -3
- package/dist/server.mjs +4 -3
- package/dist/sitemap-Buobvabq.mjs +244 -0
- package/dist/sitemap-DCR8tuA7.mjs +240 -0
- package/dist/{prompt-utils-8nmFLQVH.mjs → sitemap-server-B370zkEo.mjs} +16 -2
- package/dist/{templates-BLSQ8EwL.mjs → templates-BlouROIq.mjs} +8 -8
- package/dist/{types-D-OvczD4.d.mts → types-OAHZJ7NI.d.mts} +111 -5
- package/dist/{upgrade-CA_OE7wL.mjs → upgrade-upRj5Fw-.mjs} +1 -1
- package/package.json +1 -1
- package/dist/search-DSKaQ2JH.d.mts +0 -88
- /package/dist/{config-Si-yUfM_.mjs → config-C7sUsMkm.mjs} +0 -0
- /package/dist/{utils-DSMXVnEu.mjs → utils-l0lcezN8.mjs} +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import "./search-kP0mAXCp.mjs";
|
|
2
|
+
import { a as buildDocsSitemapManifest, c as renderDocsSitemapMarkdown, l as renderDocsSitemapXml, u as resolveDocsSitemapConfig } from "./sitemap-Buobvabq.mjs";
|
|
3
|
+
import "./sitemap-server-B370zkEo.mjs";
|
|
4
|
+
import { createFilesystemDocsMcpSource } from "./mcp.mjs";
|
|
5
|
+
import "./server.mjs";
|
|
6
|
+
import { c as readNavTitle, d as readTopLevelStringProperty, f as resolveDocsConfigPath, i as loadDocsConfigModule, o as readBooleanProperty, p as resolveDocsContentDir, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-C7sUsMkm.mjs";
|
|
7
|
+
import { t as detectFramework } from "./utils-l0lcezN8.mjs";
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import pc from "picocolors";
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
|
|
13
|
+
//#region src/cli/sitemap.ts
|
|
14
|
+
function normalizePathSegment(value) {
|
|
15
|
+
return value.replace(/^\/+|\/+$/g, "");
|
|
16
|
+
}
|
|
17
|
+
function parseInlineFlag(arg) {
|
|
18
|
+
const [rawKey, value] = arg.slice(2).split("=", 2);
|
|
19
|
+
return {
|
|
20
|
+
key: rawKey.trim(),
|
|
21
|
+
value
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function parseSitemapGenerateArgs(argv) {
|
|
25
|
+
const parsed = {};
|
|
26
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
27
|
+
const arg = argv[index];
|
|
28
|
+
if (arg === "--help" || arg === "-h") {
|
|
29
|
+
parsed.help = true;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (arg === "--public") {
|
|
33
|
+
parsed.public = true;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (arg === "--manifest-only") {
|
|
37
|
+
parsed.manifestOnly = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (arg === "--check") {
|
|
41
|
+
parsed.check = true;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (arg.startsWith("--config=")) {
|
|
45
|
+
const value = parseInlineFlag(arg).value;
|
|
46
|
+
if (!value) throw new Error("Missing value for --config.");
|
|
47
|
+
parsed.configPath = value;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (arg === "--config") {
|
|
51
|
+
const value = argv[index + 1];
|
|
52
|
+
if (!value || value.startsWith("--")) throw new Error("Missing value for --config.");
|
|
53
|
+
parsed.configPath = value;
|
|
54
|
+
index += 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`Unknown sitemap generate flag: ${arg}.`);
|
|
58
|
+
}
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
function readLlmsBaseUrlFromConfig(content, config) {
|
|
62
|
+
if (config?.llmsTxt && typeof config.llmsTxt === "object") return config.llmsTxt.baseUrl;
|
|
63
|
+
const block = extractNestedObjectLiteral(content, ["llmsTxt"]);
|
|
64
|
+
return block ? readStringProperty(block, "baseUrl") : void 0;
|
|
65
|
+
}
|
|
66
|
+
function readSitemapConfigFromStatic(content) {
|
|
67
|
+
if (/\bsitemap\s*:\s*false/.test(content)) return false;
|
|
68
|
+
if (/\bsitemap\s*:\s*true/.test(content)) return true;
|
|
69
|
+
const block = extractNestedObjectLiteral(content, ["sitemap"]);
|
|
70
|
+
if (!block) return void 0;
|
|
71
|
+
return {
|
|
72
|
+
enabled: readBooleanProperty(block, "enabled") ?? true,
|
|
73
|
+
routePrefix: readStringProperty(block, "routePrefix"),
|
|
74
|
+
baseUrl: readStringProperty(block, "baseUrl"),
|
|
75
|
+
manifestPath: readStringProperty(block, "manifestPath")
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function resolveConfiguredSitemap(content, config) {
|
|
79
|
+
if (config?.sitemap !== void 0) return config.sitemap;
|
|
80
|
+
return readSitemapConfigFromStatic(content) ?? true;
|
|
81
|
+
}
|
|
82
|
+
function formatDateOnly(value) {
|
|
83
|
+
const parsed = new Date(value);
|
|
84
|
+
if (Number.isNaN(parsed.getTime())) return void 0;
|
|
85
|
+
return parsed.toISOString().slice(0, 10);
|
|
86
|
+
}
|
|
87
|
+
function gitLastCommitDate(rootDir, sourcePath) {
|
|
88
|
+
if (!sourcePath) return void 0;
|
|
89
|
+
try {
|
|
90
|
+
return formatDateOnly(execFileSync("git", [
|
|
91
|
+
"log",
|
|
92
|
+
"-1",
|
|
93
|
+
"--format=%cI",
|
|
94
|
+
"--",
|
|
95
|
+
sourcePath
|
|
96
|
+
], {
|
|
97
|
+
cwd: rootDir,
|
|
98
|
+
encoding: "utf-8",
|
|
99
|
+
stdio: [
|
|
100
|
+
"ignore",
|
|
101
|
+
"pipe",
|
|
102
|
+
"ignore"
|
|
103
|
+
]
|
|
104
|
+
}).trim());
|
|
105
|
+
} catch {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function fileModifiedDate(rootDir, sourcePath) {
|
|
110
|
+
if (!sourcePath) return void 0;
|
|
111
|
+
const fullPath = path.isAbsolute(sourcePath) ? sourcePath : path.join(rootDir, sourcePath);
|
|
112
|
+
if (!existsSync(fullPath)) return void 0;
|
|
113
|
+
try {
|
|
114
|
+
return statSync(fullPath).mtime.toISOString().slice(0, 10);
|
|
115
|
+
} catch {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function writeIfChanged(filePath, content, check) {
|
|
120
|
+
if ((existsSync(filePath) ? readFileSync(filePath, "utf-8") : void 0) === content) return false;
|
|
121
|
+
if (check) return true;
|
|
122
|
+
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
123
|
+
writeFileSync(filePath, content, "utf-8");
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
function readExistingManifest(filePath) {
|
|
127
|
+
if (!existsSync(filePath)) return void 0;
|
|
128
|
+
try {
|
|
129
|
+
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
130
|
+
} catch {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function comparableManifest(manifest) {
|
|
135
|
+
return {
|
|
136
|
+
...manifest,
|
|
137
|
+
generatedAt: ""
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function preserveGeneratedAtWhenUnchanged(manifest, existing) {
|
|
141
|
+
if (!existing?.generatedAt) return manifest;
|
|
142
|
+
if (JSON.stringify(comparableManifest(manifest)) !== JSON.stringify(comparableManifest(existing))) return manifest;
|
|
143
|
+
return {
|
|
144
|
+
...manifest,
|
|
145
|
+
generatedAt: existing.generatedAt
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function resolvePublicDir(rootDir) {
|
|
149
|
+
if (detectFramework(rootDir) === "sveltekit") return path.join(rootDir, "static");
|
|
150
|
+
return path.join(rootDir, "public");
|
|
151
|
+
}
|
|
152
|
+
function publicFilePath(rootDir, route) {
|
|
153
|
+
return path.join(resolvePublicDir(rootDir), route.replace(/^\/+/, ""));
|
|
154
|
+
}
|
|
155
|
+
async function generateSitemap(options = {}) {
|
|
156
|
+
const rootDir = process.cwd();
|
|
157
|
+
const loadedConfigModule = await loadDocsConfigModule(rootDir, options.configPath);
|
|
158
|
+
const configContent = readFileSync(loadedConfigModule?.path ?? resolveDocsConfigPath(rootDir, options.configPath), "utf-8");
|
|
159
|
+
const config = loadedConfigModule?.config;
|
|
160
|
+
const entry = normalizePathSegment(config?.entry ?? readTopLevelStringProperty(configContent, "entry") ?? "docs") || "docs";
|
|
161
|
+
const contentDir = typeof config?.contentDir === "string" ? config.contentDir : resolveDocsContentDir(rootDir, configContent, entry);
|
|
162
|
+
const siteTitle = typeof config?.nav?.title === "string" ? config.nav.title : readNavTitle(configContent) ?? "Documentation";
|
|
163
|
+
const sitemapInput = resolveConfiguredSitemap(configContent, config);
|
|
164
|
+
if (sitemapInput === false) throw new Error("Sitemap generation is disabled by `sitemap: false`.");
|
|
165
|
+
const sitemap = resolveDocsSitemapConfig(sitemapInput, { baseUrl: (typeof sitemapInput === "object" ? sitemapInput.baseUrl : void 0) ?? readLlmsBaseUrlFromConfig(configContent, config) });
|
|
166
|
+
const source = createFilesystemDocsMcpSource({
|
|
167
|
+
rootDir,
|
|
168
|
+
entry,
|
|
169
|
+
contentDir,
|
|
170
|
+
siteTitle,
|
|
171
|
+
ordering: config?.ordering
|
|
172
|
+
});
|
|
173
|
+
const pages = await Promise.resolve(source.getPages());
|
|
174
|
+
if (pages.length === 0) throw new Error(`No docs content was found under ${contentDir}.`);
|
|
175
|
+
const builtManifest = buildDocsSitemapManifest({
|
|
176
|
+
pages,
|
|
177
|
+
entry,
|
|
178
|
+
siteTitle,
|
|
179
|
+
baseUrl: sitemap.baseUrl,
|
|
180
|
+
resolveLastmod(page) {
|
|
181
|
+
const gitDate = gitLastCommitDate(rootDir, page.sourcePath);
|
|
182
|
+
if (gitDate) return {
|
|
183
|
+
lastmod: gitDate,
|
|
184
|
+
lastmodSource: "git"
|
|
185
|
+
};
|
|
186
|
+
const fsDate = fileModifiedDate(rootDir, page.sourcePath);
|
|
187
|
+
if (fsDate) return {
|
|
188
|
+
lastmod: fsDate,
|
|
189
|
+
lastmodSource: "filesystem"
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
const manifestPath = path.resolve(rootDir, sitemap.manifestPath);
|
|
194
|
+
const manifest = preserveGeneratedAtWhenUnchanged(builtManifest, readExistingManifest(manifestPath));
|
|
195
|
+
const manifestChanged = writeIfChanged(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, options.check === true);
|
|
196
|
+
const shouldWritePublic = options.manifestOnly !== true;
|
|
197
|
+
const publicWrites = [];
|
|
198
|
+
if (shouldWritePublic) {
|
|
199
|
+
const xml = renderDocsSitemapXml(manifest, {
|
|
200
|
+
baseUrl: sitemap.baseUrl,
|
|
201
|
+
includeLastmod: sitemap.xml.includeLastmod
|
|
202
|
+
});
|
|
203
|
+
const markdown = renderDocsSitemapMarkdown(manifest, {
|
|
204
|
+
baseUrl: sitemap.baseUrl,
|
|
205
|
+
includeDescriptions: sitemap.markdown.includeDescriptions,
|
|
206
|
+
includeLastmod: sitemap.markdown.includeLastmod,
|
|
207
|
+
linkTarget: sitemap.markdown.linkTarget
|
|
208
|
+
});
|
|
209
|
+
if (sitemap.xml.enabled) {
|
|
210
|
+
const filePath = publicFilePath(rootDir, sitemap.xml.route);
|
|
211
|
+
if (writeIfChanged(filePath, xml, options.check === true)) publicWrites.push(filePath);
|
|
212
|
+
}
|
|
213
|
+
if (sitemap.markdown.enabled) for (const route of [sitemap.markdown.route, sitemap.markdown.wellKnownRoute]) {
|
|
214
|
+
const filePath = publicFilePath(rootDir, route);
|
|
215
|
+
if (writeIfChanged(filePath, markdown, options.check === true)) publicWrites.push(filePath);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (options.check && (manifestChanged || publicWrites.length > 0)) throw new Error("Sitemap output is stale. Run `docs sitemap generate` to update it.");
|
|
219
|
+
console.log(pc.green(`Generated sitemap manifest for ${manifest.pages.length} page(s).`));
|
|
220
|
+
console.log(pc.dim(path.relative(rootDir, manifestPath)));
|
|
221
|
+
for (const filePath of publicWrites) console.log(pc.dim(path.relative(rootDir, filePath)));
|
|
222
|
+
}
|
|
223
|
+
function printSitemapGenerateHelp() {
|
|
224
|
+
console.log(`
|
|
225
|
+
${pc.bold("docs sitemap generate")} — Generate sitemap metadata and static sitemap files.
|
|
226
|
+
|
|
227
|
+
${pc.dim("Usage:")}
|
|
228
|
+
pnpm exec docs ${pc.cyan("sitemap generate")}
|
|
229
|
+
|
|
230
|
+
${pc.dim("Options:")}
|
|
231
|
+
${pc.cyan("--config <path>")} Use a custom docs config path instead of ${pc.dim("docs.config.ts[x]")}
|
|
232
|
+
${pc.cyan("--public")} Explicitly write public sitemap.xml and sitemap.md files
|
|
233
|
+
${pc.cyan("--manifest-only")} Only write the internal sitemap manifest
|
|
234
|
+
${pc.cyan("--check")} Fail if generated output is stale
|
|
235
|
+
${pc.cyan("-h, --help")} Show this help message
|
|
236
|
+
`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
240
|
+
export { generateSitemap, parseSitemapGenerateArgs, printSitemapGenerateHelp };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { u as resolveDocsSitemapConfig } from "./sitemap-Buobvabq.mjs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
|
-
import { basename, join, relative } from "node:path";
|
|
4
|
+
import path, { basename, join, relative } from "node:path";
|
|
4
5
|
import { getHtmlDocument } from "@scalar/core/libs/html-rendering";
|
|
5
6
|
|
|
6
7
|
//#region src/api-reference.ts
|
|
@@ -983,4 +984,17 @@ function sanitizePromptText(text) {
|
|
|
983
984
|
}
|
|
984
985
|
|
|
985
986
|
//#endregion
|
|
986
|
-
|
|
987
|
+
//#region src/sitemap-server.ts
|
|
988
|
+
function readDocsSitemapManifest(rootDir, sitemap) {
|
|
989
|
+
const resolved = resolveDocsSitemapConfig(sitemap);
|
|
990
|
+
const manifestPath = path.resolve(rootDir, resolved.manifestPath);
|
|
991
|
+
if (!existsSync(manifestPath)) return null;
|
|
992
|
+
try {
|
|
993
|
+
return JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
994
|
+
} catch {
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
//#endregion
|
|
1000
|
+
export { resolveApiReferenceRenderer as _, resolvePromptProviderChoices as a, serializeDocsIconRegistry as c, buildApiReferenceHtmlDocumentAsync as d, buildApiReferenceOpenApiDocument as f, resolveApiReferenceConfig as g, buildApiReferenceScalarCss as h, parsePromptStringArray as i, serializeOpenDocsProviders as l, buildApiReferencePageTitle as m, DEFAULT_PROMPT_PROVIDER_TEMPLATES as n, sanitizePromptText as o, buildApiReferenceOpenApiDocumentAsync as p, normalizePromptProviderName as r, serializeDocsIcon as s, readDocsSitemapManifest as t, buildApiReferenceHtmlDocument as u };
|
|
@@ -847,7 +847,7 @@ export const Route = createFileRoute("${entryUrl}/$")({
|
|
|
847
847
|
handlers: {
|
|
848
848
|
GET: async ({ request }) => {
|
|
849
849
|
const url = new URL(request.url);
|
|
850
|
-
if (isDocsPublicGetRequest(${JSON.stringify(opts.entry)}, url, request)) {
|
|
850
|
+
if (isDocsPublicGetRequest(${JSON.stringify(opts.entry)}, url, request, { sitemap: docsConfig.sitemap })) {
|
|
851
851
|
return docsServer.GET({ request });
|
|
852
852
|
}
|
|
853
853
|
return undefined;
|
|
@@ -923,7 +923,7 @@ async function handlePublicDocsRequest(request: Request) {
|
|
|
923
923
|
});
|
|
924
924
|
}
|
|
925
925
|
|
|
926
|
-
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, url, request)) {
|
|
926
|
+
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, url, request, { sitemap: docsConfig.sitemap })) {
|
|
927
927
|
return docsServer.GET({ request });
|
|
928
928
|
}
|
|
929
929
|
|
|
@@ -1263,7 +1263,7 @@ import { createDocsServer } from "@farming-labs/svelte/server";
|
|
|
1263
1263
|
import config from "${svelteServerConfigImport(cfg.useAlias)}";
|
|
1264
1264
|
|
|
1265
1265
|
// preload for production
|
|
1266
|
-
const contentFiles = import.meta.glob(["/${cfg.entry ?? "docs"}/**/*.{md,mdx,svx}", "/skill.md"], {
|
|
1266
|
+
const contentFiles = import.meta.glob(["/${cfg.entry ?? "docs"}/**/*.{md,mdx,svx}", "/skill.md", "/.farming-labs/sitemap-manifest.json"], {
|
|
1267
1267
|
query: "?raw",
|
|
1268
1268
|
import: "default",
|
|
1269
1269
|
eager: true,
|
|
@@ -1342,7 +1342,7 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|
|
1342
1342
|
});
|
|
1343
1343
|
}
|
|
1344
1344
|
|
|
1345
|
-
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, event.url, event.request)) {
|
|
1345
|
+
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, event.url, event.request, { sitemap: config.sitemap })) {
|
|
1346
1346
|
return GET({ url: event.url, request: event.request });
|
|
1347
1347
|
}
|
|
1348
1348
|
|
|
@@ -1390,7 +1390,7 @@ const docsPublicHandle: Handle = async ({ event, resolve }) => {
|
|
|
1390
1390
|
});
|
|
1391
1391
|
}
|
|
1392
1392
|
|
|
1393
|
-
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, event.url, event.request)) {
|
|
1393
|
+
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, event.url, event.request, { sitemap: config.sitemap })) {
|
|
1394
1394
|
return docsGET({ url: event.url, request: event.request });
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
@@ -1667,7 +1667,7 @@ function astroDocsServerTemplate(cfg) {
|
|
|
1667
1667
|
import { createDocsServer } from "@farming-labs/astro/server";
|
|
1668
1668
|
import config from "${astroServerConfigImport(cfg.useAlias)}";
|
|
1669
1669
|
|
|
1670
|
-
const contentFiles = import.meta.glob(["/${cfg.entry ?? "docs"}/**/*.{md,mdx}", "/skill.md"], {
|
|
1670
|
+
const contentFiles = import.meta.glob(["/${cfg.entry ?? "docs"}/**/*.{md,mdx}", "/skill.md", "/.farming-labs/sitemap-manifest.json"], {
|
|
1671
1671
|
query: "?raw",
|
|
1672
1672
|
import: "default",
|
|
1673
1673
|
eager: true,
|
|
@@ -1806,7 +1806,7 @@ export const onRequest: MiddlewareHandler = async (context, next) => {
|
|
|
1806
1806
|
});
|
|
1807
1807
|
}
|
|
1808
1808
|
|
|
1809
|
-
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, context.url, context.request)) {
|
|
1809
|
+
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, context.url, context.request, { sitemap: config.sitemap })) {
|
|
1810
1810
|
return GET({ request: context.request });
|
|
1811
1811
|
}
|
|
1812
1812
|
|
|
@@ -1854,7 +1854,7 @@ const docsPublicMiddleware: MiddlewareHandler = async (context, next) => {
|
|
|
1854
1854
|
});
|
|
1855
1855
|
}
|
|
1856
1856
|
|
|
1857
|
-
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, context.url, context.request)) {
|
|
1857
|
+
if ((method === "GET" || method === "HEAD") && isDocsPublicGetRequest(docsEntry, context.url, context.request, { sitemap: config.sitemap })) {
|
|
1858
1858
|
return docsGET({ request: context.request });
|
|
1859
1859
|
}
|
|
1860
1860
|
|
|
@@ -758,6 +758,71 @@ interface LlmsTxtConfig {
|
|
|
758
758
|
*/
|
|
759
759
|
siteDescription?: string;
|
|
760
760
|
}
|
|
761
|
+
interface SitemapXmlConfig {
|
|
762
|
+
/**
|
|
763
|
+
* Whether to expose the XML sitemap route.
|
|
764
|
+
* @default true
|
|
765
|
+
*/
|
|
766
|
+
enabled?: boolean;
|
|
767
|
+
/**
|
|
768
|
+
* Include per-page `<lastmod>` entries when a reliable page date is available.
|
|
769
|
+
* @default true
|
|
770
|
+
*/
|
|
771
|
+
includeLastmod?: boolean;
|
|
772
|
+
}
|
|
773
|
+
interface SitemapMarkdownConfig {
|
|
774
|
+
/**
|
|
775
|
+
* Whether to expose the Markdown sitemap route.
|
|
776
|
+
* @default true
|
|
777
|
+
*/
|
|
778
|
+
enabled?: boolean;
|
|
779
|
+
/**
|
|
780
|
+
* Include page descriptions in the Markdown sitemap.
|
|
781
|
+
* @default true
|
|
782
|
+
*/
|
|
783
|
+
includeDescriptions?: boolean;
|
|
784
|
+
/**
|
|
785
|
+
* Include per-page freshness dates in the Markdown sitemap.
|
|
786
|
+
* @default true
|
|
787
|
+
*/
|
|
788
|
+
includeLastmod?: boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Which URL each Markdown list item should primarily link to.
|
|
791
|
+
* @default "both"
|
|
792
|
+
*/
|
|
793
|
+
linkTarget?: "html" | "markdown" | "both";
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Configuration for generated `/sitemap.xml`, `/sitemap.md`, and
|
|
797
|
+
* `/.well-known/sitemap.md` routes.
|
|
798
|
+
*/
|
|
799
|
+
interface DocsSitemapConfig {
|
|
800
|
+
/**
|
|
801
|
+
* Whether to enable sitemap routes.
|
|
802
|
+
* @default true when `sitemap` is an object
|
|
803
|
+
*/
|
|
804
|
+
enabled?: boolean;
|
|
805
|
+
/**
|
|
806
|
+
* Optional route prefix. For example, `"/docs"` generates
|
|
807
|
+
* `/docs/sitemap.xml`, `/docs/sitemap.md`, and `/docs/.well-known/sitemap.md`.
|
|
808
|
+
* @default ""
|
|
809
|
+
*/
|
|
810
|
+
routePrefix?: string;
|
|
811
|
+
/**
|
|
812
|
+
* Public site URL used to build absolute XML sitemap URLs.
|
|
813
|
+
* Falls back to the request origin at runtime or llmsTxt.baseUrl in the CLI.
|
|
814
|
+
*/
|
|
815
|
+
baseUrl?: string;
|
|
816
|
+
/**
|
|
817
|
+
* Internal generated manifest path.
|
|
818
|
+
* @default ".farming-labs/sitemap-manifest.json"
|
|
819
|
+
*/
|
|
820
|
+
manifestPath?: string;
|
|
821
|
+
/** XML sitemap options. */
|
|
822
|
+
xml?: boolean | SitemapXmlConfig;
|
|
823
|
+
/** Markdown sitemap options. */
|
|
824
|
+
markdown?: boolean | SitemapMarkdownConfig;
|
|
825
|
+
}
|
|
761
826
|
/**
|
|
762
827
|
* Tool-level toggles for the built-in MCP server.
|
|
763
828
|
*
|
|
@@ -808,6 +873,9 @@ interface DocsSearchSourcePage {
|
|
|
808
873
|
content: string;
|
|
809
874
|
description?: string;
|
|
810
875
|
related?: ResolvedDocsRelatedLink[];
|
|
876
|
+
sourcePath?: string;
|
|
877
|
+
lastModified?: string;
|
|
878
|
+
lastmod?: string;
|
|
811
879
|
rawContent?: string;
|
|
812
880
|
agentContent?: string;
|
|
813
881
|
agentRawContent?: string;
|
|
@@ -936,6 +1004,9 @@ interface McpDocsSearchConfig {
|
|
|
936
1004
|
maxResults?: number;
|
|
937
1005
|
chunking?: DocsSearchChunkingConfig;
|
|
938
1006
|
}
|
|
1007
|
+
type DocsAskAIMcpConfig = Omit<McpDocsSearchConfig, "provider"> & {
|
|
1008
|
+
provider?: "mcp";
|
|
1009
|
+
};
|
|
939
1010
|
interface CustomDocsSearchConfig {
|
|
940
1011
|
provider: "custom";
|
|
941
1012
|
enabled?: boolean;
|
|
@@ -1051,7 +1122,7 @@ interface DocsAskAIFeedbackData {
|
|
|
1051
1122
|
}
|
|
1052
1123
|
interface DocsAskAIFeedbackConfig {
|
|
1053
1124
|
/**
|
|
1054
|
-
* Whether to show
|
|
1125
|
+
* Whether to show the copy, like, and dislike action row after each completed Ask AI answer.
|
|
1055
1126
|
* @default true
|
|
1056
1127
|
*/
|
|
1057
1128
|
enabled?: boolean;
|
|
@@ -1290,6 +1361,27 @@ interface AIConfig {
|
|
|
1290
1361
|
* @default 5
|
|
1291
1362
|
*/
|
|
1292
1363
|
maxResults?: number;
|
|
1364
|
+
/**
|
|
1365
|
+
* Route Ask AI retrieval through the configured MCP `search_docs` tool.
|
|
1366
|
+
*
|
|
1367
|
+
* - `true` uses the MCP server this docs site already exposes at `mcp.route`
|
|
1368
|
+
* (default `/api/docs/mcp`)
|
|
1369
|
+
* - an object can point Ask AI at another Streamable HTTP MCP endpoint
|
|
1370
|
+
*
|
|
1371
|
+
* This only affects Ask AI retrieval. The normal docs search API still uses
|
|
1372
|
+
* the top-level `search` config.
|
|
1373
|
+
*
|
|
1374
|
+
* @default false
|
|
1375
|
+
*
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```ts
|
|
1378
|
+
* ai: {
|
|
1379
|
+
* enabled: true,
|
|
1380
|
+
* useMcp: true,
|
|
1381
|
+
* }
|
|
1382
|
+
* ```
|
|
1383
|
+
*/
|
|
1384
|
+
useMcp?: boolean | DocsAskAIMcpConfig;
|
|
1293
1385
|
/**
|
|
1294
1386
|
* Pre-filled suggested questions shown in the AI chat when empty.
|
|
1295
1387
|
* When a user clicks one, it fills the input and submits automatically.
|
|
@@ -1399,10 +1491,10 @@ interface AIConfig {
|
|
|
1399
1491
|
name: string;
|
|
1400
1492
|
}) => unknown;
|
|
1401
1493
|
/**
|
|
1402
|
-
*
|
|
1494
|
+
* Copy, like, and dislike action row for generated Ask AI answers.
|
|
1403
1495
|
*
|
|
1404
|
-
* Set to `false` to hide the
|
|
1405
|
-
* and receive callback payloads
|
|
1496
|
+
* Set to `false` to hide the row. Pass an object to customize rating labels
|
|
1497
|
+
* and receive legacy like/dislike callback payloads.
|
|
1406
1498
|
*
|
|
1407
1499
|
* @default true
|
|
1408
1500
|
*
|
|
@@ -2134,6 +2226,20 @@ interface DocsConfig {
|
|
|
2134
2226
|
* @see https://llmstxt.org
|
|
2135
2227
|
*/
|
|
2136
2228
|
llmsTxt?: boolean | LlmsTxtConfig;
|
|
2229
|
+
/**
|
|
2230
|
+
* Generated XML and Markdown sitemaps for crawlers, agents, and static export.
|
|
2231
|
+
*
|
|
2232
|
+
* @example
|
|
2233
|
+
* ```ts
|
|
2234
|
+
* sitemap: true
|
|
2235
|
+
*
|
|
2236
|
+
* sitemap: {
|
|
2237
|
+
* routePrefix: "/docs",
|
|
2238
|
+
* baseUrl: "https://docs.example.com",
|
|
2239
|
+
* }
|
|
2240
|
+
* ```
|
|
2241
|
+
*/
|
|
2242
|
+
sitemap?: boolean | DocsSitemapConfig;
|
|
2137
2243
|
/**
|
|
2138
2244
|
* Generated changelog pages backed by date-folder MDX entries inside the docs
|
|
2139
2245
|
* content tree.
|
|
@@ -2192,4 +2298,4 @@ interface DocsConfig {
|
|
|
2192
2298
|
og?: OGConfig;
|
|
2193
2299
|
}
|
|
2194
2300
|
//#endregion
|
|
2195
|
-
export {
|
|
2301
|
+
export { DocsSitemapConfig as $, DocsConfig as A, UIConfig as At, DocsObservabilityEventInput as B, DocsAskAIActionData as C, SidebarNode as Ct, DocsAskAIFeedbackMessage as D, ThemeToggleConfig as Dt, DocsAskAIFeedbackData as E, SimpleDocsSearchConfig as Et, DocsMcpToolsConfig as F, DocsSearchChunkingConfig as G, DocsSearchAdapter as H, DocsMetadata as I, DocsSearchEmbeddingsConfig as J, DocsSearchConfig as K, DocsNav as L, DocsFeedbackValue as M, DocsI18nConfig as N, DocsAskAIFeedbackValue as O, TypesenseDocsSearchConfig as Ot, DocsMcpConfig as P, DocsSearchSourcePage as Q, DocsObservabilityConfig as R, DocsAnalyticsSource as S, SidebarFolderNode as St, DocsAskAIFeedbackConfig as T, SidebarTree as Tt, DocsSearchAdapterContext as U, DocsRelatedItem as V, DocsSearchAdapterFactory as W, DocsSearchResult as X, DocsSearchQuery as Y, DocsSearchResultType as Z, DocsAnalyticsConfig as _, ReadingTimeConfig as _t, ApiReferenceRenderer as a, LlmsTxtConfig as at, DocsAnalyticsEventType as b, SidebarConfig as bt, ChangelogFrontmatter as c, OpenDocsConfig as ct, CustomDocsSearchConfig as d, OrderingItem as dt, DocsTheme as et, DocsAgentFeedbackContext as f, PageActionsConfig as ft, DocsAgentTraceStatus as g, PageTwitter as gt, DocsAgentTraceEventType as h, PageSidebarFrontmatter as ht, ApiReferenceConfig as i, LastUpdatedConfig as it, DocsFeedbackData as j, DocsAskAIMcpConfig as k, TypographyConfig as kt, CodeBlockCopyData as l, OpenDocsProvider as lt, DocsAgentTraceEventInput as m, PageOpenGraph as mt, AgentFeedbackConfig as n, FontStyle as nt, BreadcrumbConfig as o, McpDocsSearchConfig as ot, DocsAgentFeedbackData as p, PageFrontmatter as pt, DocsSearchDocument as q, AlgoliaDocsSearchConfig as r, GithubConfig as rt, ChangelogConfig as s, OGConfig as st, AIConfig as t, FeedbackConfig as tt, CopyMarkdownConfig as u, OpenGraphImage as ut, DocsAnalyticsEvent as v, ResolvedDocsRelatedLink as vt, DocsAskAIActionType as w, SidebarPageNode as wt, DocsAnalyticsInput as x, SidebarFolderIndexBehavior as xt, DocsAnalyticsEventInput as y, SidebarComponentProps as yt, DocsObservabilityEvent as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as installCommand, i as detectPackageManagerFromLockfile, o as exec, s as fileExists, t as detectFramework } from "./utils-
|
|
1
|
+
import { c as installCommand, i as detectPackageManagerFromLockfile, o as exec, s as fileExists, t as detectFramework } from "./utils-l0lcezN8.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
import * as p from "@clack/prompts";
|
package/package.json
CHANGED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Et as TypesenseDocsSearchConfig, G as DocsSearchConfig, K as DocsSearchDocument, L as DocsObservabilityConfig, R as DocsObservabilityEvent, U as DocsSearchAdapterFactory, V as DocsSearchAdapter, W as DocsSearchChunkingConfig, Y as DocsSearchResult, Z as DocsSearchSourcePage, _ as DocsAnalyticsConfig, d as CustomDocsSearchConfig, it as McpDocsSearchConfig, m as DocsAgentTraceEventInput, r as AlgoliaDocsSearchConfig, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsObservabilityEventInput } from "./types-D-OvczD4.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/cloud-analytics.d.ts
|
|
4
|
-
interface DocsCloudAnalyticsOptions {
|
|
5
|
-
enabled?: boolean;
|
|
6
|
-
console?: DocsAnalyticsConfig["console"];
|
|
7
|
-
includeInputs?: boolean;
|
|
8
|
-
projectId?: string;
|
|
9
|
-
apiKey?: string;
|
|
10
|
-
}
|
|
11
|
-
declare function createDocsCloudAnalytics(options?: DocsCloudAnalyticsOptions): DocsAnalyticsConfig;
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/analytics.d.ts
|
|
14
|
-
declare const DOCS_AGENT_TRACE_EVENT_TYPES: readonly ["run.start", "run.end", "run.error", "user.input", "prompt.build", "retrieval.query", "retrieval.result", "retrieval.error", "model.call", "model.response", "model.stream", "model.error", "tool.call", "tool.result", "tool.error", "retry", "timeout", "error", "agent.final"];
|
|
15
|
-
interface DocsAgentTraceContext {
|
|
16
|
-
traceId: string;
|
|
17
|
-
name: string;
|
|
18
|
-
startedAt: string;
|
|
19
|
-
startedMs: number;
|
|
20
|
-
}
|
|
21
|
-
interface ResolvedDocsAnalyticsConfig {
|
|
22
|
-
enabled: boolean;
|
|
23
|
-
console: false | "log" | "info" | "debug";
|
|
24
|
-
includeInputs: boolean;
|
|
25
|
-
onEvent?: (event: DocsAnalyticsEvent) => void | Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
interface ResolvedDocsObservabilityConfig {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
console: false | "log" | "info" | "debug";
|
|
30
|
-
includeInputs: boolean;
|
|
31
|
-
onEvent?: (event: DocsObservabilityEvent) => void | Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
declare function createDocsAgentTraceId(prefix?: string): string;
|
|
34
|
-
declare function createDocsAgentTraceContext(name?: string): DocsAgentTraceContext;
|
|
35
|
-
declare function resolveDocsAnalyticsConfig(analytics?: boolean | DocsAnalyticsConfig): ResolvedDocsAnalyticsConfig;
|
|
36
|
-
declare function resolveDocsObservabilityConfig(observability?: boolean | DocsObservabilityConfig): ResolvedDocsObservabilityConfig;
|
|
37
|
-
declare function emitDocsAnalyticsEvent(analytics: boolean | DocsAnalyticsConfig | undefined, event: DocsAnalyticsEventInput): Promise<void>;
|
|
38
|
-
declare function emitDocsObservabilityEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsObservabilityEventInput): Promise<void>;
|
|
39
|
-
declare function emitDocsAgentTraceEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsAgentTraceEventInput): Promise<void>;
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/search.d.ts
|
|
42
|
-
interface DocsAskAIContextResult extends DocsSearchResult {
|
|
43
|
-
title: string;
|
|
44
|
-
contextContent: string;
|
|
45
|
-
}
|
|
46
|
-
interface DocsAskAIContext {
|
|
47
|
-
context: string;
|
|
48
|
-
results: DocsAskAIContextResult[];
|
|
49
|
-
searchResults: DocsSearchResult[];
|
|
50
|
-
packageHints: DocsAskAIPackageHints;
|
|
51
|
-
}
|
|
52
|
-
interface DocsAskAIPackageHints {
|
|
53
|
-
packages: string[];
|
|
54
|
-
imports: string[];
|
|
55
|
-
installCommands: string[];
|
|
56
|
-
}
|
|
57
|
-
declare function inferDocsAskAIPackageHints(content: string): DocsAskAIPackageHints;
|
|
58
|
-
declare function formatDocsAskAIPackageHints(hints: DocsAskAIPackageHints, packageName?: string): string | undefined;
|
|
59
|
-
declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig): DocsSearchDocument[];
|
|
60
|
-
declare function createSimpleSearchAdapter(): DocsSearchAdapter;
|
|
61
|
-
declare function createTypesenseSearchAdapter(config: TypesenseDocsSearchConfig): DocsSearchAdapter;
|
|
62
|
-
declare function resolveSearchRequestConfig(search: boolean | DocsSearchConfig | undefined, requestUrl?: string): boolean | DocsSearchConfig | undefined;
|
|
63
|
-
declare function createMcpSearchAdapter(config: McpDocsSearchConfig): DocsSearchAdapter;
|
|
64
|
-
declare function createAlgoliaSearchAdapter(config: AlgoliaDocsSearchConfig): DocsSearchAdapter;
|
|
65
|
-
declare function performDocsSearch(options: {
|
|
66
|
-
pages: DocsSearchSourcePage[];
|
|
67
|
-
query: string;
|
|
68
|
-
search?: boolean | DocsSearchConfig;
|
|
69
|
-
locale?: string;
|
|
70
|
-
pathname?: string;
|
|
71
|
-
siteTitle?: string;
|
|
72
|
-
limit?: number;
|
|
73
|
-
}): Promise<DocsSearchResult[]>;
|
|
74
|
-
declare function buildDocsAskAIContext(options: {
|
|
75
|
-
pages: DocsSearchSourcePage[];
|
|
76
|
-
query: string;
|
|
77
|
-
search?: boolean | DocsSearchConfig;
|
|
78
|
-
locale?: string;
|
|
79
|
-
pathname?: string;
|
|
80
|
-
siteTitle?: string;
|
|
81
|
-
baseUrl?: string;
|
|
82
|
-
limit?: number;
|
|
83
|
-
maxContextChars?: number;
|
|
84
|
-
maxResultChars?: number;
|
|
85
|
-
}): Promise<DocsAskAIContext>;
|
|
86
|
-
declare function createCustomSearchAdapter(adapter: DocsSearchAdapter | DocsSearchAdapterFactory): CustomDocsSearchConfig;
|
|
87
|
-
//#endregion
|
|
88
|
-
export { DocsCloudAnalyticsOptions as C, resolveDocsObservabilityConfig as S, createDocsAgentTraceId as _, createMcpSearchAdapter as a, emitDocsObservabilityEvent as b, formatDocsAskAIPackageHints as c, resolveSearchRequestConfig as d, DOCS_AGENT_TRACE_EVENT_TYPES as f, createDocsAgentTraceContext as g, ResolvedDocsObservabilityConfig as h, createCustomSearchAdapter as i, inferDocsAskAIPackageHints as l, ResolvedDocsAnalyticsConfig as m, buildDocsSearchDocuments as n, createSimpleSearchAdapter as o, DocsAgentTraceContext as p, createAlgoliaSearchAdapter as r, createTypesenseSearchAdapter as s, buildDocsAskAIContext as t, performDocsSearch as u, emitDocsAgentTraceEvent as v, createDocsCloudAnalytics as w, resolveDocsAnalyticsConfig as x, emitDocsAnalyticsEvent as y };
|
|
File without changes
|
|
File without changes
|