blodemd 0.0.13 → 0.0.15

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.
Files changed (136) hide show
  1. package/README.md +1 -1
  2. package/dev-server/lib/local-runtime.tsx +12 -15
  3. package/dev-server/package.json +5 -1
  4. package/dist/cli.mjs +1211 -983
  5. package/dist/cli.mjs.map +1 -1
  6. package/docs/app/globals.css +1 -1
  7. package/docs/components/api/api-playground.tsx +2 -5
  8. package/docs/components/api/api-reference.tsx +29 -3
  9. package/docs/components/docs/contextual-menu.tsx +37 -33
  10. package/docs/components/docs/copy-page-menu.tsx +18 -0
  11. package/docs/components/docs/doc-header.tsx +4 -1
  12. package/docs/components/docs/doc-shell.tsx +48 -18
  13. package/docs/components/docs/doc-sidebar.tsx +131 -89
  14. package/docs/components/docs/doc-toc.tsx +1 -0
  15. package/docs/components/docs/mobile-nav.tsx +72 -68
  16. package/docs/components/docs/sidebar-active-highlight.tsx +34 -0
  17. package/docs/components/docs/sidebar-scroll-area.tsx +9 -4
  18. package/docs/components/git/repo-picker.tsx +5 -2
  19. package/docs/components/mdx/index.tsx +31 -21
  20. package/docs/components/posthog-provider.tsx +42 -0
  21. package/docs/components/tenant-analytics.tsx +49 -0
  22. package/docs/components/third-parties.tsx +4 -1
  23. package/docs/components/ui/copy-button.tsx +16 -2
  24. package/docs/components/ui/search-dialog.tsx +431 -0
  25. package/docs/components/ui/search.tsx +44 -427
  26. package/docs/components/web-mcp.tsx +115 -0
  27. package/docs/lib/agent-skills.ts +48 -0
  28. package/docs/lib/config.ts +4 -5
  29. package/docs/lib/docs-collection.ts +7 -22
  30. package/docs/lib/docs-runtime.tsx +160 -10
  31. package/docs/lib/llms-full.ts +82 -0
  32. package/docs/lib/marketing-markdown.ts +79 -0
  33. package/docs/lib/marketing-site.ts +31 -0
  34. package/docs/lib/mdx.ts +17 -6
  35. package/docs/lib/routes.ts +19 -3
  36. package/docs/lib/shiki.ts +4 -0
  37. package/docs/lib/tenancy.ts +15 -2
  38. package/docs/lib/tenant-headers.ts +29 -0
  39. package/docs/lib/tenant-static.ts +73 -99
  40. package/package.json +8 -5
  41. package/packages/@repo/common/package.json +1 -1
  42. package/packages/@repo/contracts/dist/analytics.d.ts +21 -0
  43. package/packages/@repo/contracts/dist/analytics.d.ts.map +1 -0
  44. package/packages/@repo/contracts/dist/analytics.js +18 -0
  45. package/packages/@repo/contracts/dist/deployment.js +1 -1
  46. package/packages/@repo/contracts/dist/git.js +2 -2
  47. package/packages/@repo/contracts/dist/ids.d.ts.map +1 -1
  48. package/packages/@repo/contracts/dist/ids.js +2 -1
  49. package/packages/@repo/contracts/dist/index.d.ts +1 -0
  50. package/packages/@repo/contracts/dist/index.d.ts.map +1 -1
  51. package/packages/@repo/contracts/dist/index.js +1 -0
  52. package/packages/@repo/contracts/dist/project.d.ts +18 -1
  53. package/packages/@repo/contracts/dist/project.d.ts.map +1 -1
  54. package/packages/@repo/contracts/dist/project.js +3 -1
  55. package/packages/@repo/contracts/dist/tenant.d.ts +36 -0
  56. package/packages/@repo/contracts/dist/tenant.d.ts.map +1 -1
  57. package/packages/@repo/contracts/dist/tenant.js +2 -0
  58. package/packages/@repo/contracts/package.json +1 -1
  59. package/packages/@repo/contracts/src/analytics.ts +33 -0
  60. package/packages/@repo/contracts/src/deployment.ts +1 -1
  61. package/packages/@repo/contracts/src/git.ts +2 -2
  62. package/packages/@repo/contracts/src/ids.ts +2 -1
  63. package/packages/@repo/contracts/src/index.ts +1 -0
  64. package/packages/@repo/contracts/src/project.ts +3 -1
  65. package/packages/@repo/contracts/src/tenant.ts +2 -0
  66. package/packages/@repo/models/dist/docs-config.d.ts +0 -198
  67. package/packages/@repo/models/dist/docs-config.d.ts.map +1 -1
  68. package/packages/@repo/models/dist/docs-config.js +3 -2
  69. package/packages/@repo/models/dist/tenant.d.ts +12 -0
  70. package/packages/@repo/models/dist/tenant.d.ts.map +1 -1
  71. package/packages/@repo/models/package.json +1 -1
  72. package/packages/@repo/models/src/docs-config.ts +3 -3
  73. package/packages/@repo/models/src/tenant.ts +15 -0
  74. package/packages/@repo/prebuild/dist/openapi.d.ts.map +1 -1
  75. package/packages/@repo/prebuild/dist/openapi.js +32 -4
  76. package/packages/@repo/prebuild/package.json +1 -1
  77. package/packages/@repo/prebuild/src/openapi.ts +42 -4
  78. package/packages/@repo/previewing/dist/blob-source.d.ts.map +1 -1
  79. package/packages/@repo/previewing/dist/blob-source.js +18 -5
  80. package/packages/@repo/previewing/dist/config-loader.d.ts +134 -0
  81. package/packages/@repo/previewing/dist/config-loader.d.ts.map +1 -0
  82. package/packages/@repo/previewing/dist/config-loader.js +231 -0
  83. package/packages/@repo/previewing/dist/constants.d.ts +15 -0
  84. package/packages/@repo/previewing/dist/constants.d.ts.map +1 -0
  85. package/packages/@repo/previewing/dist/constants.js +14 -0
  86. package/packages/@repo/previewing/dist/content-index.d.ts +7 -0
  87. package/packages/@repo/previewing/dist/content-index.d.ts.map +1 -0
  88. package/packages/@repo/previewing/dist/content-index.js +291 -0
  89. package/packages/@repo/previewing/dist/index.d.ts +13 -121
  90. package/packages/@repo/previewing/dist/index.d.ts.map +1 -1
  91. package/packages/@repo/previewing/dist/index.js +11 -1003
  92. package/packages/@repo/previewing/dist/markdown/agent-markdown.d.ts +3 -0
  93. package/packages/@repo/previewing/dist/markdown/agent-markdown.d.ts.map +1 -0
  94. package/packages/@repo/previewing/dist/markdown/agent-markdown.js +176 -0
  95. package/packages/@repo/previewing/dist/markdown/format.d.ts +8 -0
  96. package/packages/@repo/previewing/dist/markdown/format.d.ts.map +1 -0
  97. package/packages/@repo/previewing/dist/markdown/format.js +43 -0
  98. package/packages/@repo/previewing/dist/markdown/links.d.ts +3 -0
  99. package/packages/@repo/previewing/dist/markdown/links.d.ts.map +1 -0
  100. package/packages/@repo/previewing/dist/markdown/links.js +31 -0
  101. package/packages/@repo/previewing/dist/openapi-pages.d.ts +7 -0
  102. package/packages/@repo/previewing/dist/openapi-pages.d.ts.map +1 -0
  103. package/packages/@repo/previewing/dist/openapi-pages.js +200 -0
  104. package/packages/@repo/previewing/dist/search-index.d.ts +4 -0
  105. package/packages/@repo/previewing/dist/search-index.d.ts.map +1 -0
  106. package/packages/@repo/previewing/dist/search-index.js +23 -0
  107. package/packages/@repo/previewing/dist/serialization.d.ts +13 -0
  108. package/packages/@repo/previewing/dist/serialization.d.ts.map +1 -0
  109. package/packages/@repo/previewing/dist/serialization.js +108 -0
  110. package/packages/@repo/previewing/dist/toc-index.d.ts +5 -0
  111. package/packages/@repo/previewing/dist/toc-index.d.ts.map +1 -0
  112. package/packages/@repo/previewing/dist/toc-index.js +53 -0
  113. package/packages/@repo/previewing/dist/types.d.ts +92 -0
  114. package/packages/@repo/previewing/dist/types.d.ts.map +1 -0
  115. package/packages/@repo/previewing/dist/types.js +1 -0
  116. package/packages/@repo/previewing/dist/utility-index.d.ts +7 -0
  117. package/packages/@repo/previewing/dist/utility-index.d.ts.map +1 -0
  118. package/packages/@repo/previewing/dist/utility-index.js +201 -0
  119. package/packages/@repo/previewing/package.json +1 -1
  120. package/packages/@repo/previewing/src/blob-source.ts +20 -5
  121. package/packages/@repo/previewing/src/config-loader.ts +316 -0
  122. package/packages/@repo/previewing/src/constants.ts +16 -0
  123. package/packages/@repo/previewing/src/content-index.ts +384 -0
  124. package/packages/@repo/previewing/src/index.ts +69 -1515
  125. package/packages/@repo/previewing/src/markdown/agent-markdown.ts +254 -0
  126. package/packages/@repo/previewing/src/markdown/format.ts +63 -0
  127. package/packages/@repo/previewing/src/markdown/links.ts +46 -0
  128. package/packages/@repo/previewing/src/openapi-pages.ts +319 -0
  129. package/packages/@repo/previewing/src/search-index.ts +38 -0
  130. package/packages/@repo/previewing/src/serialization.ts +191 -0
  131. package/packages/@repo/previewing/src/toc-index.ts +72 -0
  132. package/packages/@repo/previewing/src/types.ts +105 -0
  133. package/packages/@repo/previewing/src/utility-index.ts +304 -0
  134. package/packages/@repo/validation/package.json +1 -1
  135. package/scripts/repo-packages.mjs +8 -0
  136. package/docs/components/ui/site-footer.tsx +0 -41
@@ -1,1005 +1,13 @@
1
- import path from "node:path";
2
- import { ensureArray, normalizePath, slugify } from "@repo/common";
3
- import { PageModeSchema } from "@repo/models";
4
- import { extractOpenApiOperations, openApiIdentifier, openApiSlug, parseOpenApiSpec, } from "@repo/prebuild";
5
- import { validateDocsConfig, validateFrontmatter, validateSiteConfig, } from "@repo/validation";
6
- import YAML from "yaml";
7
1
  export { BlobContentSource, createBlobSource } from "./blob-source.js";
2
+ export { getDocsCollection, getDocsCollectionWithNavigation, getDocsNavigation, loadSiteConfig, } from "./config-loader.js";
3
+ export { LEGACY_PROJECT_NAME_FALLBACK_WARNING, PREBUILT_INDEX_PATH, PREBUILT_OPENAPI_INDEX_PATH, PREBUILT_SEARCH_INDEX_PATH, PREBUILT_TOC_INDEX_PATH, PREBUILT_UTILITY_INDEX_PATH, PREBUILT_UTILITY_LLMS_FULL_PATH, PREBUILT_UTILITY_LLMS_PATH, PREBUILT_UTILITY_LLMS_SEGMENT_PREFIX, PREBUILT_UTILITY_SITEMAP_PATH, PREBUILT_UTILITY_SKILLS_INDEX_PATH, PREBUILT_UTILITY_SKILLS_MD_PREFIX, UTILITY_DOCS_ROOT_TOKEN, } from "./constants.js";
4
+ export { buildContentIndex, buildPageMetadataMap } from "./content-index.js";
8
5
  export { createFsSource, FsContentSource } from "./fs-source.js";
9
- export const PREBUILT_INDEX_PATH = "_content-index.json";
10
- export const PREBUILT_OPENAPI_INDEX_PATH = "_openapi-index.json";
11
- export const PREBUILT_SEARCH_INDEX_PATH = "_search-index.json";
12
- export const PREBUILT_TOC_INDEX_PATH = "_toc-index.json";
13
- export const PREBUILT_UTILITY_INDEX_PATH = "_utility-index.json";
14
- export const PREBUILT_UTILITY_SITEMAP_PATH = "_utility/sitemap.xml";
15
- export const PREBUILT_UTILITY_LLMS_PATH = "_utility/llms.txt";
16
- export const PREBUILT_UTILITY_LLMS_FULL_PATH = "_utility/llms-full.txt";
17
- export const PREBUILT_UTILITY_SKILLS_INDEX_PATH = "_utility/skills-index.json";
18
- export const PREBUILT_UTILITY_SKILLS_MD_PREFIX = "_utility/skills/";
19
- export const UTILITY_DOCS_ROOT_TOKEN = "__BLODEMD_DOCS_ROOT__";
20
- export const LEGACY_PROJECT_NAME_FALLBACK_WARNING = "docs.json.slug is recommended. Falling back to docs.json.name as the deployment slug is deprecated.";
21
- const validModes = new Set(PageModeSchema.options);
22
- export const buildPageMetadataMap = (index) => {
23
- const map = new Map();
24
- for (const entry of index.entries) {
25
- if (entry.kind !== "entry") {
26
- continue;
27
- }
28
- const fm = entry.frontmatter;
29
- const meta = {
30
- title: entry.title,
31
- };
32
- const hasFields = true;
33
- if (typeof fm.sidebarTitle === "string") {
34
- meta.sidebarTitle = fm.sidebarTitle;
35
- }
36
- if (typeof fm.icon === "string") {
37
- meta.icon = fm.icon;
38
- }
39
- if (typeof fm.iconType === "string") {
40
- meta.iconType = fm.iconType;
41
- }
42
- if (typeof fm.tag === "string") {
43
- meta.tag = fm.tag;
44
- }
45
- if (typeof fm.hidden === "boolean") {
46
- meta.hidden = fm.hidden;
47
- }
48
- if (typeof fm.deprecated === "boolean") {
49
- meta.deprecated = fm.deprecated;
50
- }
51
- if (typeof fm.url === "string") {
52
- meta.url = fm.url;
53
- }
54
- if (typeof fm.mode === "string" && validModes.has(fm.mode)) {
55
- meta.mode = fm.mode;
56
- }
57
- if (typeof fm.noindex === "boolean") {
58
- meta.noindex = fm.noindex;
59
- }
60
- if (typeof fm.hideFooterPagination === "boolean") {
61
- meta.hideFooterPagination = fm.hideFooterPagination;
62
- }
63
- if (typeof fm.hideApiMarker === "boolean") {
64
- meta.hideApiMarker = fm.hideApiMarker;
65
- }
66
- if (Array.isArray(fm.keywords)) {
67
- meta.keywords = fm.keywords;
68
- }
69
- if (hasFields) {
70
- map.set(entry.slug, meta);
71
- }
72
- }
73
- return map;
74
- };
75
- const DOCS_CONFIG_FILE = "docs.json";
76
- const DOC_FILE_EXTENSION_REGEX = /\.(mdx|md)$/;
77
- const FRONTMATTER_REGEX = /^---\s*\n([\s\S]*?)\n---\s*\n?/;
78
- const INDEX_SUFFIX = "/index";
79
- const titleFromSlug = (slug) => {
80
- const clean = slug.replaceAll("-", " ").split("/").pop() ?? slug;
81
- if (clean === "index") {
82
- return "Overview";
83
- }
84
- return clean.replaceAll(/\b\w/g, (char) => char.toUpperCase());
85
- };
86
- const parseFrontmatter = (source) => {
87
- const match = FRONTMATTER_REGEX.exec(source);
88
- if (!match) {
89
- return { body: source, frontmatter: {} };
90
- }
91
- const raw = match[1] ?? "";
92
- const data = YAML.parse(raw) ?? {};
93
- const body = source.slice(match[0].length);
94
- return { body, frontmatter: data };
95
- };
96
- const slugFromFile = (relativePath) => {
97
- const clean = normalizePath(relativePath);
98
- const withoutExt = clean.replace(DOC_FILE_EXTENSION_REGEX, "");
99
- if (withoutExt.endsWith(INDEX_SUFFIX)) {
100
- const trimmed = withoutExt.slice(0, -INDEX_SUFFIX.length);
101
- return trimmed.length ? trimmed : "index";
102
- }
103
- return withoutExt.length ? withoutExt : "index";
104
- };
105
- const defaultLinkLabel = (input) => {
106
- if (input.label) {
107
- return input.label;
108
- }
109
- if (input.type === "github") {
110
- return "GitHub";
111
- }
112
- if (input.type === "discord") {
113
- return "Discord";
114
- }
115
- try {
116
- return new URL(input.href).hostname;
117
- }
118
- catch {
119
- return input.href;
120
- }
121
- };
122
- // oxlint-disable-next-line eslint/complexity
123
- const mapDocsConfig = (docs) => {
124
- const navigation = {
125
- global: docs.navbar?.links?.length || docs.navigation.global?.anchors?.length
126
- ? {
127
- anchors: docs.navigation.global?.anchors?.map((anchor) => ({
128
- href: anchor.href,
129
- label: anchor.anchor,
130
- })),
131
- links: docs.navbar?.links?.map((link) => ({
132
- href: link.href,
133
- label: defaultLinkLabel(link),
134
- })),
135
- }
136
- : undefined,
137
- groups: docs.navigation.groups?.map((group) => ({
138
- expanded: group.expanded,
139
- group: group.group,
140
- hidden: group.hidden,
141
- pages: group.root
142
- ? [
143
- group.root,
144
- ...(group.pages ?? []).filter((page) => page !== group.root),
145
- ]
146
- : group.pages,
147
- })),
148
- languages: docs.navigation.languages?.map((language) => ({
149
- label: language.language,
150
- locale: language.language,
151
- url: language.href,
152
- })),
153
- pages: docs.navigation.pages,
154
- tabs: docs.navigation.tabs?.map((tab) => ({
155
- groups: tab.groups?.map((group) => ({
156
- expanded: group.expanded,
157
- group: group.group,
158
- hidden: group.hidden,
159
- pages: group.root
160
- ? [
161
- group.root,
162
- ...(group.pages ?? []).filter((page) => page !== group.root),
163
- ]
164
- : group.pages,
165
- })),
166
- href: tab.href,
167
- icon: tab.icon,
168
- label: tab.tab,
169
- pages: tab.pages,
170
- })),
171
- versions: docs.navigation.versions?.map((version) => ({
172
- label: version.version,
173
- url: version.href,
174
- })),
175
- };
176
- return {
177
- collections: [
178
- {
179
- id: "docs",
180
- navigation,
181
- openapi: docs.api?.openapi,
182
- root: "",
183
- type: "docs",
184
- },
185
- ],
186
- contextual: docs.contextual,
187
- description: docs.description,
188
- favicon: typeof docs.favicon === "string" ? docs.favicon : docs.favicon?.light,
189
- features: {
190
- rightToc: true,
191
- search: true,
192
- themeToggle: docs.appearance?.strict !== true,
193
- toc: true,
194
- },
195
- logo: docs.logo
196
- ? {
197
- dark: typeof docs.logo === "string" ? docs.logo : docs.logo.dark,
198
- href: typeof docs.logo === "string" ? undefined : docs.logo.href,
199
- light: typeof docs.logo === "string" ? docs.logo : docs.logo.light,
200
- }
201
- : undefined,
202
- name: docs.name,
203
- navigation,
204
- openapiProxy: {
205
- enabled: docs.api?.playground?.proxy !== false &&
206
- Boolean(docs.api?.openapi || docs.api?.asyncapi),
207
- },
208
- seo: docs.seo,
209
- slug: docs.slug,
210
- };
211
- };
212
- const getProjectWarnings = (config) => config.slug ? [] : [LEGACY_PROJECT_NAME_FALLBACK_WARNING];
213
- const readJsonConfig = async (source, relativePath) => JSON.parse(await source.readFile(relativePath));
214
- const normalizeRefPath = (baseDirectory, reference) => {
215
- if (reference.startsWith("/") ||
216
- reference.startsWith("\\") ||
217
- reference.startsWith("http://") ||
218
- reference.startsWith("https://")) {
219
- throw new Error(`Invalid $ref "${reference}". Only relative JSON files are supported.`);
220
- }
221
- const normalized = normalizePath(path.posix.join(baseDirectory, reference));
222
- if (!normalized ||
223
- normalized === "." ||
224
- normalized.startsWith("../") ||
225
- normalized.includes("/../")) {
226
- throw new Error(`Invalid $ref "${reference}".`);
227
- }
228
- return normalized;
229
- };
230
- const resolveJsonRefs = async (source, value, baseDirectory, seen) => {
231
- if (Array.isArray(value)) {
232
- return await Promise.all(value.map((item) => resolveJsonRefs(source, item, baseDirectory, seen)));
233
- }
234
- if (!value || typeof value !== "object") {
235
- return value;
236
- }
237
- const record = value;
238
- const reference = record.$ref;
239
- if (typeof reference === "string") {
240
- const resolvedPath = normalizeRefPath(baseDirectory, reference);
241
- if (seen.has(resolvedPath)) {
242
- throw new Error(`Circular $ref detected for "${resolvedPath}".`);
243
- }
244
- const nextSeen = new Set(seen);
245
- // oxlint-disable-next-line eslint-plugin-unicorn/no-immediate-mutation
246
- nextSeen.add(resolvedPath);
247
- const referenced = await readJsonConfig(source, resolvedPath);
248
- const referencedValue = await resolveJsonRefs(source, referenced, path.posix.dirname(resolvedPath) === "."
249
- ? ""
250
- : normalizePath(path.posix.dirname(resolvedPath)), nextSeen);
251
- const siblingEntries = Object.entries(record).filter(([key]) => key !== "$ref");
252
- if (!siblingEntries.length ||
253
- !referencedValue ||
254
- typeof referencedValue !== "object" ||
255
- Array.isArray(referencedValue)) {
256
- return referencedValue;
257
- }
258
- const siblingValue = await resolveJsonRefs(source, Object.fromEntries(siblingEntries), baseDirectory, seen);
259
- return {
260
- ...referencedValue,
261
- ...siblingValue,
262
- };
263
- }
264
- const resolvedEntries = await Promise.all(Object.entries(record).map(async ([key, entryValue]) => [
265
- key,
266
- await resolveJsonRefs(source, entryValue, baseDirectory, seen),
267
- ]));
268
- return Object.fromEntries(resolvedEntries);
269
- };
270
- const readResolvedJsonConfig = async (source, relativePath) => await resolveJsonRefs(source, await readJsonConfig(source, relativePath), path.posix.dirname(relativePath) === "."
271
- ? ""
272
- : normalizePath(path.posix.dirname(relativePath)), new Set([relativePath]));
273
- const loadDocsConfig = async (source) => {
274
- if (!(await source.exists(DOCS_CONFIG_FILE))) {
275
- return null;
276
- }
277
- try {
278
- const parsed = await readResolvedJsonConfig(source, DOCS_CONFIG_FILE);
279
- // Try SiteConfig format first (has collections, theme, colors, etc.)
280
- const siteResult = validateSiteConfig(parsed);
281
- if (siteResult.success) {
282
- return {
283
- config: siteResult.data,
284
- ok: true,
285
- warnings: getProjectWarnings(siteResult.data),
286
- };
287
- }
288
- // Fall back to DocsConfig format (Mintlify-compatible) and map to SiteConfig
289
- const docsResult = validateDocsConfig(parsed);
290
- if (docsResult.success) {
291
- return {
292
- config: mapDocsConfig(docsResult.data),
293
- ok: true,
294
- warnings: getProjectWarnings(docsResult.data),
295
- };
296
- }
297
- return { errors: docsResult.errors, ok: false };
298
- }
299
- catch (error) {
300
- return {
301
- errors: [
302
- error instanceof Error
303
- ? error.message
304
- : `Failed to load ${DOCS_CONFIG_FILE}`,
305
- ],
306
- ok: false,
307
- };
308
- }
309
- };
310
- export const loadSiteConfig = async (source) => {
311
- const docsConfig = await loadDocsConfig(source);
312
- if (docsConfig) {
313
- return docsConfig;
314
- }
315
- return {
316
- errors: [`${DOCS_CONFIG_FILE} not found.`],
317
- ok: false,
318
- };
319
- };
320
- export const loadContentSource = async (source, relativePath) => await source.readFile(relativePath);
321
- const listContentFiles = async (source, directory) => {
322
- const files = await source.listFiles(directory);
323
- return files.filter((file) => DOC_FILE_EXTENSION_REGEX.test(file));
324
- };
325
- const sortDefaults = {
326
- blog: { direction: "desc", field: "date" },
327
- courses: { direction: "asc", field: "order" },
328
- docs: { direction: "asc", field: "title" },
329
- forms: { direction: "asc", field: "title" },
330
- notes: { direction: "desc", field: "date" },
331
- products: { direction: "asc", field: "title" },
332
- sheets: { direction: "asc", field: "title" },
333
- site: { direction: "asc", field: "title" },
334
- slides: { direction: "asc", field: "title" },
335
- todos: { direction: "desc", field: "date" },
336
- };
337
- const normalizeSortValue = (value) => {
338
- if (typeof value === "number") {
339
- return value;
340
- }
341
- if (typeof value === "string") {
342
- const timestamp = Date.parse(value);
343
- if (!Number.isNaN(timestamp)) {
344
- return timestamp;
345
- }
346
- return value.toLowerCase();
347
- }
348
- return null;
349
- };
350
- const compareValues = (a, b, direction) => {
351
- const left = normalizeSortValue(a);
352
- const right = normalizeSortValue(b);
353
- if (left === null && right === null) {
354
- return 0;
355
- }
356
- if (left === null) {
357
- return 1;
358
- }
359
- if (right === null) {
360
- return -1;
361
- }
362
- const multiplier = direction === "desc" ? -1 : 1;
363
- if (typeof left === "number" && typeof right === "number") {
364
- return (left - right) * multiplier;
365
- }
366
- if (left < right) {
367
- return -1 * multiplier;
368
- }
369
- if (left > right) {
370
- return 1 * multiplier;
371
- }
372
- return 0;
373
- };
374
- const autoIndexTypes = new Set([
375
- "blog",
376
- "courses",
377
- "products",
378
- "notes",
379
- "forms",
380
- "sheets",
381
- "slides",
382
- "todos",
383
- ]);
384
- const getCollectionIndex = (collection, slugPrefix) => {
385
- if (collection.index) {
386
- return collection.index;
387
- }
388
- if (autoIndexTypes.has(collection.type)) {
389
- const slug = slugPrefix || collection.id;
390
- return {
391
- slug,
392
- title: titleFromSlug(slug),
393
- };
394
- }
395
- return null;
396
- };
397
- const addEntry = (entry, index, errors) => {
398
- if (index.bySlug.has(entry.slug)) {
399
- errors.push(`slug "${entry.slug}" is defined more than once`);
400
- return;
401
- }
402
- index.entries.push(entry);
403
- index.bySlug.set(entry.slug, entry);
404
- };
405
- const resolveEntrySlug = (relativeSlug, slugPrefix) => {
406
- if (!slugPrefix) {
407
- return relativeSlug;
408
- }
409
- if (relativeSlug === "index") {
410
- return slugPrefix;
411
- }
412
- return normalizePath(`${slugPrefix}/${relativeSlug}`);
413
- };
414
- const buildEntryFromFile = async ({ collection, errors, file, root, slugPrefix, source, }) => {
415
- const sourcePath = root
416
- ? normalizePath(path.join(root, file))
417
- : normalizePath(file);
418
- let entrySource = "";
419
- try {
420
- entrySource = await source.readFile(sourcePath);
421
- }
422
- catch (error) {
423
- errors.push(error instanceof Error ? error.message : `Failed to read ${sourcePath}`);
424
- return null;
425
- }
426
- const { frontmatter } = parseFrontmatter(entrySource);
427
- const frontmatterResult = validateFrontmatter(collection.type, frontmatter);
428
- if (!frontmatterResult.success) {
429
- for (const issue of frontmatterResult.errors) {
430
- errors.push(`${sourcePath}: ${issue}`);
431
- }
432
- }
433
- const resolvedFrontmatter = frontmatterResult.success
434
- ? frontmatterResult.data
435
- : frontmatter;
436
- const relativeSlug = slugFromFile(file);
437
- const slug = resolveEntrySlug(relativeSlug, slugPrefix);
438
- const title = typeof resolvedFrontmatter?.title === "string"
439
- ? resolvedFrontmatter.title
440
- : titleFromSlug(slug);
441
- const description = typeof resolvedFrontmatter?.description === "string"
442
- ? resolvedFrontmatter.description
443
- : undefined;
444
- const hidden = typeof resolvedFrontmatter?.hidden === "boolean"
445
- ? resolvedFrontmatter.hidden
446
- : undefined;
447
- return {
448
- collectionId: collection.id,
449
- description,
450
- frontmatter: resolvedFrontmatter,
451
- hidden: hidden || undefined,
452
- kind: "entry",
453
- relativePath: sourcePath,
454
- slug,
455
- sourcePath,
456
- title,
457
- type: collection.type,
458
- };
459
- };
460
- export const buildContentIndex = async (source, config) => {
461
- const errors = [];
462
- const index = {
463
- byCollection: new Map(),
464
- bySlug: new Map(),
465
- entries: [],
466
- errors,
467
- };
468
- for (const collection of config.collections) {
469
- const root = normalizePath(collection.root ?? "");
470
- const slugPrefix = normalizePath(collection.slugPrefix ?? "");
471
- let files = [];
472
- try {
473
- files = await listContentFiles(source, root);
474
- }
475
- catch (error) {
476
- errors.push(error instanceof Error ? error.message : `Failed to read ${root || "."}`);
477
- continue;
478
- }
479
- const collectionEntries = [];
480
- const resolvedEntries = await Promise.all(files.map(async (file) => await buildEntryFromFile({
481
- collection,
482
- errors,
483
- file,
484
- root,
485
- slugPrefix,
486
- source,
487
- })));
488
- for (const entry of resolvedEntries) {
489
- if (!entry) {
490
- continue;
491
- }
492
- collectionEntries.push(entry);
493
- addEntry(entry, index, errors);
494
- }
495
- const sortConfig = {
496
- ...sortDefaults[collection.type],
497
- ...collection.sort,
498
- };
499
- const sortField = sortConfig.field ?? "title";
500
- const sortDirection = sortConfig.direction ?? "asc";
501
- collectionEntries.sort((left, right) => {
502
- const leftValue = left.kind === "entry"
503
- ? left.frontmatter[sortField]
504
- : undefined;
505
- const rightValue = right.kind === "entry"
506
- ? right.frontmatter[sortField]
507
- : undefined;
508
- return compareValues(leftValue, rightValue, sortDirection);
509
- });
510
- index.byCollection.set(collection.id, collectionEntries);
511
- const collectionIndex = getCollectionIndex(collection, slugPrefix);
512
- if (collectionIndex) {
513
- const indexEntry = {
514
- collectionId: collection.id,
515
- description: collectionIndex.description,
516
- kind: "index",
517
- slug: collectionIndex.slug,
518
- title: collectionIndex.title ?? titleFromSlug(collectionIndex.slug),
519
- type: collection.type,
520
- };
521
- addEntry(indexEntry, index, errors);
522
- }
523
- }
524
- return index;
525
- };
526
- const NEWLINE_REGEX = /\r?\n/;
527
- const HEADING_REGEX = /^(#{2,4})\s+(.*)$/;
528
- const LEADING_H1_REGEX = /^#\s+([^\r\n]+)(?:\r?\n(?:\r?\n)?)?/;
529
- export const extractToc = (source) => {
530
- const withoutCode = source.replaceAll(/```[\s\S]*?```/g, "");
531
- const lines = withoutCode.split(NEWLINE_REGEX);
532
- const toc = [];
533
- for (const line of lines) {
534
- const match = HEADING_REGEX.exec(line.trim());
535
- if (!match) {
536
- continue;
537
- }
538
- const [, hashes = "", heading = ""] = match;
539
- if (!(hashes && heading)) {
540
- continue;
541
- }
542
- toc.push({
543
- id: slugify(heading.trim()),
544
- level: hashes.length,
545
- title: heading.trim(),
546
- });
547
- }
548
- return toc;
549
- };
550
- const stripMatchingLeadingH1 = (source, title) => {
551
- const trimmed = source.trimStart();
552
- const match = LEADING_H1_REGEX.exec(trimmed);
553
- if (!match) {
554
- return trimmed.trim();
555
- }
556
- const [headingLine = "", headingTitle = ""] = match;
557
- if (slugify(headingTitle) !== slugify(title)) {
558
- return trimmed.trim();
559
- }
560
- return trimmed.slice(headingLine.length).trim();
561
- };
562
- export const formatMarkdownPage = (title, source) => {
563
- const content = stripMatchingLeadingH1(source, title);
564
- if (!content) {
565
- return `# ${title}`;
566
- }
567
- return `# ${title}\n\n${content}`;
568
- };
569
- export const formatMarkdownPageSection = (title, url, source) => {
570
- const content = stripMatchingLeadingH1(source, title);
571
- if (!content) {
572
- return `# ${title} (${url})`;
573
- }
574
- return `# ${title} (${url})\n\n${content}`;
575
- };
576
- const shouldIncludeSearchEntry = (entry, pageMetadataMap, config) => {
577
- const pageMeta = pageMetadataMap.get(entry.slug);
578
- if (pageMeta?.hidden || pageMeta?.noindex) {
579
- return false;
580
- }
581
- if (config.seo?.indexing !== "all" &&
582
- entry.kind === "entry" &&
583
- entry.hidden === true) {
584
- return false;
585
- }
586
- return true;
587
- };
588
- const stripFrontmatter = (source) => parseFrontmatter(source).body.trim();
589
- const getDocsCollection = (config) => config.collections.find((collection) => collection.type === "docs");
590
- const getDocsNavigation = (config) => getDocsCollection(config)?.navigation ?? config.navigation;
591
- const getDocsCollectionWithNavigation = (config) => {
592
- const docsCollection = getDocsCollection(config);
593
- const docsNavigation = getDocsNavigation(config);
594
- return docsCollection &&
595
- docsNavigation &&
596
- docsCollection.navigation !== docsNavigation
597
- ? { ...docsCollection, navigation: docsNavigation }
598
- : docsCollection;
599
- };
600
- const getOpenApiSourceKey = (source) => `${source.source}::${source.directory ?? ""}::${(source.include ?? []).join("|")}`;
601
- const toOpenApiSourceObject = (value) => {
602
- if (typeof value === "string") {
603
- return { source: value };
604
- }
605
- return value;
606
- };
607
- const collectOpenApiSources = (collection) => {
608
- const sources = [];
609
- for (const item of ensureArray(collection?.openapi)) {
610
- if (!item) {
611
- continue;
612
- }
613
- sources.push(toOpenApiSourceObject(item));
614
- }
615
- const groups = collection?.navigation?.groups ?? [];
616
- for (const group of groups) {
617
- if (!group.openapi) {
618
- continue;
619
- }
620
- sources.push(toOpenApiSourceObject(group.openapi));
621
- }
622
- const seen = new Set();
623
- return sources.filter((source) => {
624
- const key = getOpenApiSourceKey(source);
625
- if (seen.has(key)) {
626
- return false;
627
- }
628
- seen.add(key);
629
- return true;
630
- });
631
- };
632
- const formatOpenApiPageContent = (operation) => {
633
- const parts = [`Method: ${operation.method}`, `Path: ${operation.path}`];
634
- if (operation.description) {
635
- parts.push(operation.description);
636
- }
637
- if (operation.tags.length) {
638
- parts.push(`Tags: ${operation.tags.join(", ")}`);
639
- }
640
- if (operation.parameters.length) {
641
- parts.push(`Parameters:\n${JSON.stringify(operation.parameters, null, 2)}`);
642
- }
643
- if (operation.requestBody) {
644
- parts.push(`Request Body:\n${JSON.stringify(operation.requestBody, null, 2)}`);
645
- }
646
- if (operation.responses) {
647
- parts.push(`Responses:\n${JSON.stringify(operation.responses, null, 2)}`);
648
- }
649
- return parts.join("\n\n");
650
- };
651
- const getGroupedOpenApiSourceKey = (source) => getOpenApiSourceKey(toOpenApiSourceObject(source));
652
- const collectUtilityOpenApiPages = (pagesByIdentifier, pagesBySource, operations, directory, openApiSource, slugPrefix) => {
653
- const sourceKey = getOpenApiSourceKey(openApiSource);
654
- const includeIdentifiers = openApiSource.include?.length
655
- ? new Set(openApiSource.include)
656
- : null;
657
- for (const operation of operations) {
658
- const identifier = openApiIdentifier(operation.method, operation.path);
659
- if (includeIdentifiers && !includeIdentifiers.has(identifier)) {
660
- continue;
661
- }
662
- const baseSlug = normalizePath(openApiSlug(operation.method, operation.path, directory));
663
- const slug = slugPrefix
664
- ? normalizePath(`${slugPrefix}/${baseSlug}`)
665
- : baseSlug;
666
- const page = {
667
- content: formatOpenApiPageContent(operation),
668
- description: operation.description,
669
- identifier,
670
- slug,
671
- sourceKey,
672
- title: operation.summary ?? identifier,
673
- };
674
- pagesByIdentifier.set(identifier, page);
675
- if (!pagesBySource.has(sourceKey)) {
676
- pagesBySource.set(sourceKey, []);
677
- }
678
- pagesBySource.get(sourceKey)?.push(page);
679
- }
680
- };
681
- const addUtilityPagesFromSourceKey = (pages, pagesBySource, sourceKey) => {
682
- for (const page of pagesBySource.get(sourceKey) ?? []) {
683
- pages.set(page.slug, page);
684
- }
685
- };
686
- const addReferencedUtilityPages = (pages, pagesByIdentifier, pageReferences, hiddenPages, groupHidden = false) => {
687
- for (const pageReference of pageReferences ?? []) {
688
- if (groupHidden || hiddenPages.has(pageReference)) {
689
- continue;
690
- }
691
- const page = pagesByIdentifier.get(pageReference);
692
- if (page) {
693
- pages.set(page.slug, page);
694
- }
695
- }
696
- };
697
- const buildUtilityOpenApiPages = async (config, collection, source) => {
698
- if (!collection || collection.type !== "docs") {
699
- return [];
700
- }
701
- const docsNavigation = getDocsNavigation(config);
702
- const hiddenPages = new Set(docsNavigation?.hidden);
703
- const slugPrefix = normalizePath(collection.slugPrefix ?? "");
704
- const byIdentifier = new Map();
705
- const bySource = new Map();
706
- const pages = new Map();
707
- const sources = collectOpenApiSources(collection);
708
- const resolved = await Promise.all(sources.map(async (item) => {
709
- const rawSpec = await source.readFile(item.source);
710
- const spec = parseOpenApiSpec(rawSpec, item.source);
711
- const directory = item.directory ?? "api";
712
- const { operations } = extractOpenApiOperations(spec, directory);
713
- return { directory, operations, source: item };
714
- }));
715
- for (const { directory, operations, source: openApiSource } of resolved) {
716
- collectUtilityOpenApiPages(byIdentifier, bySource, operations, directory, openApiSource, slugPrefix);
717
- }
718
- for (const openApiSource of ensureArray(collection.openapi)) {
719
- if (!openApiSource) {
720
- continue;
721
- }
722
- addUtilityPagesFromSourceKey(pages, bySource, getGroupedOpenApiSourceKey(openApiSource));
723
- }
724
- for (const group of docsNavigation?.groups ?? []) {
725
- const groupHidden = group.hidden === true;
726
- addReferencedUtilityPages(pages, byIdentifier, group.pages, hiddenPages, groupHidden);
727
- if (groupHidden || !group.openapi) {
728
- continue;
729
- }
730
- addUtilityPagesFromSourceKey(pages, bySource, getGroupedOpenApiSourceKey(group.openapi));
731
- }
732
- addReferencedUtilityPages(pages, byIdentifier, docsNavigation?.pages, hiddenPages);
733
- return [...pages.values()];
734
- };
735
- export const buildSearchIndex = (index, config, utilityIndex) => {
736
- const pageMetadataMap = buildPageMetadataMap(index);
737
- const items = new Map();
738
- for (const page of utilityIndex?.pages ?? []) {
739
- items.set(page.slug, {
740
- path: page.slug,
741
- title: page.title,
742
- });
743
- }
744
- for (const entry of index.entries) {
745
- if (!shouldIncludeSearchEntry(entry, pageMetadataMap, config)) {
746
- continue;
747
- }
748
- const pageMeta = pageMetadataMap.get(entry.slug);
749
- items.set(entry.slug, {
750
- href: pageMeta?.url,
751
- path: entry.slug,
752
- title: pageMeta?.sidebarTitle ?? entry.title,
753
- });
754
- }
755
- return [...items.values()];
756
- };
757
- export const buildUtilityIndex = async (index, source, config) => {
758
- const pageMetadataMap = buildPageMetadataMap(index);
759
- const pages = new Map();
760
- for (const entry of index.entries) {
761
- if (entry.kind !== "entry") {
762
- continue;
763
- }
764
- if (!shouldIncludeSearchEntry(entry, pageMetadataMap, config)) {
765
- continue;
766
- }
767
- const rawContent = await source.readFile(entry.relativePath);
768
- pages.set(entry.slug, {
769
- content: stripFrontmatter(rawContent),
770
- description: entry.description,
771
- slug: entry.slug,
772
- title: entry.title,
773
- });
774
- }
775
- for (const page of await buildUtilityOpenApiPages(config, getDocsCollectionWithNavigation(config), source)) {
776
- pages.set(page.slug, page);
777
- }
778
- const sortedPages = [...pages.values()];
779
- // oxlint-disable-next-line eslint-plugin-unicorn/no-array-sort
780
- sortedPages.sort((left, right) => left.slug.localeCompare(right.slug));
781
- return {
782
- description: config.description,
783
- name: config.name,
784
- pages: sortedPages,
785
- slug: config.slug,
786
- };
787
- };
788
- const toUtilityDocPath = (value) => {
789
- const clean = normalizePath(value);
790
- if (!clean || clean === "index") {
791
- return "/";
792
- }
793
- return `/${clean}`;
794
- };
795
- const toUtilityTemplatedDocUrl = (value) => `${UTILITY_DOCS_ROOT_TOKEN}${toUtilityDocPath(value)}`;
796
- export const getPrebuiltUtilityLlmPagePath = (slug) => {
797
- const normalized = normalizePath(slug);
798
- return `_utility/llms-pages/${normalized || "index"}.mdx`;
799
- };
800
- export const buildUtilityArtifacts = (index) => {
801
- const llmsLines = [
802
- `# ${index.name}`,
803
- index.description ? `> ${index.description}` : null,
804
- "",
805
- `Sitemap: ${toUtilityTemplatedDocUrl("sitemap.xml")}`,
806
- `Skills: ${UTILITY_DOCS_ROOT_TOKEN}/.well-known/skills/index.json`,
807
- "",
808
- "## Docs",
809
- ...index.pages.map((page) => {
810
- const description = page.description ? `: ${page.description}` : "";
811
- return `- [${page.title}](${toUtilityTemplatedDocUrl(page.slug)})${description}`;
812
- }),
813
- ];
814
- const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
815
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
816
- ${index.pages
817
- .map((page) => ` <url><loc>${toUtilityTemplatedDocUrl(page.slug)}</loc></url>`)
818
- .join("\n")}
819
- </urlset>`;
820
- const llmsFull = index.pages
821
- .map((page) => formatMarkdownPageSection(page.title, toUtilityTemplatedDocUrl(page.slug), page.content))
822
- .join("\n\n");
823
- const skillSlug = index.slug ?? slugify(index.name);
824
- const skillDescription = `${index.name} documentation. ${index.description ?? ""}`.trim();
825
- const skillsIndex = JSON.stringify({
826
- skills: [
827
- {
828
- description: skillDescription,
829
- files: ["SKILL.md"],
830
- name: skillSlug,
831
- },
832
- ],
833
- }, null, 2);
834
- const topPages = index.pages.slice(0, 20);
835
- const skillMdLines = [
836
- "---",
837
- `name: ${skillSlug}`,
838
- `description: ${skillDescription} Use when working with ${index.name}, answering questions about its features, or helping users follow its guides.`,
839
- "---",
840
- "",
841
- `# ${index.name}`,
842
- "",
843
- index.description ? `${index.description}\n` : "",
844
- "## Documentation",
845
- "",
846
- `- Full docs index: ${UTILITY_DOCS_ROOT_TOKEN}/llms.txt`,
847
- `- Complete docs content: ${UTILITY_DOCS_ROOT_TOKEN}/llms-full.txt`,
848
- "- Append `.md` to any page URL for raw markdown",
849
- "",
850
- "## Key Pages",
851
- "",
852
- ...topPages.map((page) => {
853
- const desc = page.description ? ` - ${page.description}` : "";
854
- return `- [${page.title}](${toUtilityTemplatedDocUrl(page.slug)})${desc}`;
855
- }),
856
- ];
857
- return [
858
- {
859
- content: sitemap,
860
- contentType: "application/xml; charset=utf-8",
861
- path: PREBUILT_UTILITY_SITEMAP_PATH,
862
- },
863
- {
864
- content: llmsLines.filter((line) => line !== null).join("\n"),
865
- contentType: "text/plain; charset=utf-8",
866
- path: PREBUILT_UTILITY_LLMS_PATH,
867
- },
868
- {
869
- content: llmsFull,
870
- contentType: "text/plain; charset=utf-8",
871
- path: PREBUILT_UTILITY_LLMS_FULL_PATH,
872
- },
873
- {
874
- content: skillsIndex,
875
- contentType: "application/json; charset=utf-8",
876
- path: PREBUILT_UTILITY_SKILLS_INDEX_PATH,
877
- },
878
- {
879
- content: skillMdLines.filter((line) => line !== null).join("\n"),
880
- contentType: "text/markdown; charset=utf-8",
881
- path: `${PREBUILT_UTILITY_SKILLS_MD_PREFIX}${skillSlug}/SKILL.md`,
882
- },
883
- ...index.pages.map((page) => ({
884
- content: formatMarkdownPage(page.title, page.content),
885
- contentType: "text/markdown; charset=utf-8",
886
- path: getPrebuiltUtilityLlmPagePath(page.slug),
887
- })),
888
- ];
889
- };
890
- export const buildTocIndex = async (index, source) => {
891
- const itemsBySlug = new Map();
892
- for (const entry of index.entries) {
893
- if (entry.kind !== "entry") {
894
- continue;
895
- }
896
- const rawContent = await source.readFile(entry.relativePath);
897
- itemsBySlug.set(entry.slug, extractToc(rawContent));
898
- }
899
- return itemsBySlug;
900
- };
901
- export const serializeContentIndex = (index) => JSON.stringify({
902
- collections: Object.fromEntries(index.byCollection),
903
- entries: index.entries,
904
- version: 1,
905
- });
906
- export const serializeOpenApiIndex = (entries) => JSON.stringify({
907
- entries,
908
- version: 1,
909
- });
910
- export const loadPrebuiltContentIndex = async (source) => {
911
- try {
912
- const raw = await source.readFile(PREBUILT_INDEX_PATH);
913
- const data = JSON.parse(raw);
914
- if (data.version !== 1 || !Array.isArray(data.entries)) {
915
- return null;
916
- }
917
- const bySlug = new Map();
918
- const byCollection = new Map();
919
- for (const entry of data.entries) {
920
- bySlug.set(entry.slug, entry);
921
- }
922
- for (const [collectionId, entries] of Object.entries(data.collections ?? {})) {
923
- byCollection.set(collectionId, entries);
924
- }
925
- return {
926
- byCollection,
927
- bySlug,
928
- entries: data.entries,
929
- errors: [],
930
- };
931
- }
932
- catch {
933
- return null;
934
- }
935
- };
936
- export const loadPrebuiltOpenApiIndex = async (source) => {
937
- try {
938
- const raw = await source.readFile(PREBUILT_OPENAPI_INDEX_PATH);
939
- const data = JSON.parse(raw);
940
- if (data.version !== 1 || !Array.isArray(data.entries)) {
941
- return null;
942
- }
943
- return data.entries;
944
- }
945
- catch {
946
- return null;
947
- }
948
- };
949
- export const serializeSearchIndex = (items) => JSON.stringify({
950
- items,
951
- version: 1,
952
- });
953
- export const loadPrebuiltSearchIndex = async (source) => {
954
- try {
955
- const raw = await source.readFile(PREBUILT_SEARCH_INDEX_PATH);
956
- const data = JSON.parse(raw);
957
- if (data.version !== 1 || !Array.isArray(data.items)) {
958
- return null;
959
- }
960
- return data.items;
961
- }
962
- catch {
963
- return null;
964
- }
965
- };
966
- export const serializeTocIndex = (itemsBySlug) => JSON.stringify({
967
- itemsBySlug: Object.fromEntries(itemsBySlug),
968
- version: 1,
969
- });
970
- export const loadPrebuiltTocIndex = async (source) => {
971
- try {
972
- const raw = await source.readFile(PREBUILT_TOC_INDEX_PATH);
973
- const data = JSON.parse(raw);
974
- if (data.version !== 1 || typeof data.itemsBySlug !== "object") {
975
- return null;
976
- }
977
- return new Map(Object.entries(data.itemsBySlug ?? {}));
978
- }
979
- catch {
980
- return null;
981
- }
982
- };
983
- export const serializeUtilityIndex = (index) => JSON.stringify({
984
- ...index,
985
- version: 1,
986
- });
987
- export const loadPrebuiltUtilityIndex = async (source) => {
988
- try {
989
- const raw = await source.readFile(PREBUILT_UTILITY_INDEX_PATH);
990
- const data = JSON.parse(raw);
991
- if (data.version !== 1 ||
992
- typeof data.name !== "string" ||
993
- !Array.isArray(data.pages)) {
994
- return null;
995
- }
996
- return {
997
- description: data.description,
998
- name: data.name,
999
- pages: data.pages,
1000
- };
1001
- }
1002
- catch {
1003
- return null;
1004
- }
1005
- };
6
+ export { prepareLlmsFullContent, toAgentMarkdown, } from "./markdown/agent-markdown.js";
7
+ export { formatMarkdownPage, formatMarkdownPageSection, stripFrontmatter, } from "./markdown/format.js";
8
+ export { absolutiseInternalLinks, sanitizePlaceholderUrls, } from "./markdown/links.js";
9
+ export { formatOpenApiPageContent } from "./openapi-pages.js";
10
+ export { buildSearchIndex } from "./search-index.js";
11
+ export { loadPrebuiltContentIndex, loadPrebuiltOpenApiIndex, loadPrebuiltSearchIndex, loadPrebuiltTocIndex, loadPrebuiltUtilityIndex, serializeContentIndex, serializeOpenApiIndex, serializeSearchIndex, serializeTocIndex, serializeUtilityIndex, } from "./serialization.js";
12
+ export { buildTocIndex, extractToc } from "./toc-index.js";
13
+ export { buildUtilityArtifacts, buildUtilityIndex, getPrebuiltUtilityLlmPagePath, } from "./utility-index.js";