@vite-hub/docs 0.0.0 → 0.4.1

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 (115) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +456 -0
  3. package/dist/agent-copy-xPaWye_g.js +33 -0
  4. package/dist/assistant-pages-BN7hNsSZ.js +37 -0
  5. package/dist/assistant-shared-CWIKRtBv.d.ts +28 -0
  6. package/dist/assistant-shared-WzButktj.js +113 -0
  7. package/dist/assistant-worker.d.ts +11 -0
  8. package/dist/assistant-worker.js +16 -0
  9. package/dist/assistant.d.ts +14 -0
  10. package/dist/assistant.js +19 -0
  11. package/dist/content-CPZGnn3S.js +141 -0
  12. package/dist/draft-BjWmaiLn.js +45 -0
  13. package/dist/error-diagnostics-B_ZOy7kF.js +93 -0
  14. package/dist/files-UY4h1_36.js +38 -0
  15. package/dist/index.d.ts +28 -0
  16. package/dist/index.js +27 -0
  17. package/dist/link-checker-redirects.d.ts +13 -0
  18. package/dist/link-checker-redirects.js +25 -0
  19. package/dist/manifest-CMoxcwPm.d.ts +80 -0
  20. package/dist/manifest-ZdxLrcvt.js +434 -0
  21. package/dist/markdown-DUWnEMPp.js +378 -0
  22. package/dist/navigation.d.ts +283 -0
  23. package/dist/navigation.js +519 -0
  24. package/dist/nuxt-CAGpKl_-.d.ts +241 -0
  25. package/dist/nuxt.d.ts +3 -0
  26. package/dist/nuxt.js +1868 -0
  27. package/dist/page-Dx2JD3y1.d.ts +74 -0
  28. package/dist/page-GPt09oex.js +82 -0
  29. package/dist/primitive-rail.d.ts +110 -0
  30. package/dist/primitive-rail.js +289 -0
  31. package/dist/raw-BChwipz_.js +857 -0
  32. package/dist/redirects-CmR1yu5A.js +74 -0
  33. package/dist/runtime/app/app.vue +11 -0
  34. package/dist/runtime/app/assistant/DocsAssistant.vue +81 -0
  35. package/dist/runtime/app/assistant/DocsAssistantOff.vue +8 -0
  36. package/dist/runtime/app/assistant/DocsAssistantPanel.vue +322 -0
  37. package/dist/runtime/app/components/AppHeader.vue +368 -0
  38. package/dist/runtime/app/components/AppSearch.vue +68 -0
  39. package/dist/runtime/app/components/DocsAppShell.vue +62 -0
  40. package/dist/runtime/app/components/DocsArticle.vue +184 -0
  41. package/dist/runtime/app/components/DocsAsideFooter.vue +94 -0
  42. package/dist/runtime/app/components/DocsAsideLeftBody.vue +584 -0
  43. package/dist/runtime/app/components/DocsAsideLeftTop.vue +132 -0
  44. package/dist/runtime/app/components/DocsBrandMark.vue +52 -0
  45. package/dist/runtime/app/components/DocsCatalogFooter.vue +129 -0
  46. package/dist/runtime/app/components/DocsCodePanel.vue +388 -0
  47. package/dist/runtime/app/components/DocsCodePre.vue +120 -0
  48. package/dist/runtime/app/components/DocsHeaderActions.vue +4 -0
  49. package/dist/runtime/app/components/DocsLanding.vue +83 -0
  50. package/dist/runtime/app/components/DocsMarkdown.vue +64 -0
  51. package/dist/runtime/app/components/DocsPage.vue +149 -0
  52. package/dist/runtime/app/components/DocsPageCredits.vue +41 -0
  53. package/dist/runtime/app/components/DocsPageHeaderLinks.vue +120 -0
  54. package/dist/runtime/app/components/DocsRail.vue +239 -0
  55. package/dist/runtime/app/components/DocsSidebarStrip.vue +81 -0
  56. package/dist/runtime/app/components/DocsSidebars.vue +63 -0
  57. package/dist/runtime/app/components/OgImage/DocsPage.takumi.vue +33 -0
  58. package/dist/runtime/app/components/content/AgentOnly.vue +9 -0
  59. package/dist/runtime/app/components/content/CodeTree.vue +203 -0
  60. package/dist/runtime/app/components/content/ComarkHtml.vue +31 -0
  61. package/dist/runtime/app/components/content/Correct.vue +17 -0
  62. package/dist/runtime/app/components/content/Example.vue +260 -0
  63. package/dist/runtime/app/components/content/ExamplePreview.vue +6 -0
  64. package/dist/runtime/app/components/content/Examples.vue +71 -0
  65. package/dist/runtime/app/components/content/Incorrect.vue +17 -0
  66. package/dist/runtime/app/components/content/McpClient.vue +170 -0
  67. package/dist/runtime/app/components/content/McpInstall.vue +238 -0
  68. package/dist/runtime/app/components/content/PageList.vue +206 -0
  69. package/dist/runtime/app/components/content/ProductFeatureItem.vue +43 -0
  70. package/dist/runtime/app/components/content/ProductFeatures.vue +17 -0
  71. package/dist/runtime/app/components/content/TutorialStep.vue +39 -0
  72. package/dist/runtime/app/composables/docs-assistant-problem.ts +59 -0
  73. package/dist/runtime/app/composables/docs-theme.ts +15 -0
  74. package/dist/runtime/app/composables/docs.ts +83 -0
  75. package/dist/runtime/app/composables/headerActions.ts +6 -0
  76. package/dist/runtime/app/composables/icons.ts +14 -0
  77. package/dist/runtime/app/composables/seo.ts +64 -0
  78. package/dist/runtime/app/composables/tutorial.ts +40 -0
  79. package/dist/runtime/app/composables/useDocsAssistant.ts +17 -0
  80. package/dist/runtime/app/error.vue +88 -0
  81. package/dist/runtime/app/layouts/default.vue +7 -0
  82. package/dist/runtime/app/layouts/docs.vue +104 -0
  83. package/dist/runtime/app/middleware/docs-layout.ts +23 -0
  84. package/dist/runtime/app/pages/docs-page.vue +3 -0
  85. package/dist/runtime/app/plugins/comark-css.ts +14 -0
  86. package/dist/runtime/app/plugins/icon-stroke.ts +12 -0
  87. package/dist/runtime/app/plugins/theme-color.ts +18 -0
  88. package/dist/runtime/app/utils/docs-theme.ts +43 -0
  89. package/dist/runtime/app/utils/file-tree.ts +40 -0
  90. package/dist/runtime/server/llms.d.ts +6 -0
  91. package/dist/runtime/server/llms.js +7 -0
  92. package/dist/runtime/server/markdown.d.ts +10 -0
  93. package/dist/runtime/server/markdown.js +11 -0
  94. package/dist/runtime/server/mcp.d.ts +6 -0
  95. package/dist/runtime/server/mcp.js +7 -0
  96. package/dist/runtime/server/page.d.ts +7 -0
  97. package/dist/runtime/server/page.js +27 -0
  98. package/dist/runtime/server/raw.d.ts +10 -0
  99. package/dist/runtime/server/raw.js +23 -0
  100. package/dist/runtime/server/search.d.ts +6 -0
  101. package/dist/runtime/server/search.js +32 -0
  102. package/dist/runtime/server/sitemap.d.ts +6 -0
  103. package/dist/runtime/server/sitemap.js +52 -0
  104. package/dist/runtime/server/trailing-slash.d.ts +10 -0
  105. package/dist/runtime/server/trailing-slash.js +28 -0
  106. package/dist/runtime/theme/design.css +464 -0
  107. package/dist/schema-DwpXW0VZ.js +98 -0
  108. package/dist/server.d.ts +15 -0
  109. package/dist/server.js +5 -0
  110. package/dist/theme-BXyu4uFL.d.ts +32 -0
  111. package/dist/theme-DzC8LtMH.js +237 -0
  112. package/dist/theme.d.ts +2 -0
  113. package/dist/theme.js +2 -0
  114. package/dist/types-BhG6vGfG.d.ts +212 -0
  115. package/package.json +144 -1
@@ -0,0 +1,113 @@
1
+ import { docsAppPath } from "./navigation.js";
2
+ import { rateLimit } from "@vite-hub/agent/capabilities";
3
+ import { defineAgent } from "@vite-hub/agent";
4
+ import { webChat } from "@vite-hub/agent/channels";
5
+ import { createRateLimiter } from "@vite-hub/rate-limit";
6
+ import { memoryRateLimitDriver } from "@vite-hub/rate-limit/drivers/memory";
7
+ import { custom } from "@vite-hub/workspace";
8
+ //#region src/assistant-shared.ts
9
+ /** Invocation context key that holds the path of the page the reader has open. */
10
+ const docsPageContextKey = "docsPage";
11
+ const docsRules = `You answer questions from readers of this documentation site.
12
+
13
+ The pages of the site are Markdown files in the \`pages\` folder of your working directory. Search and read them with read-only shell commands such as \`rg\`, \`ls\`, and \`cat\` before you answer.
14
+
15
+ A page URL is its file path without \`pages\` and \`.md\`. An \`index.md\` file is the URL of its folder. For example, \`pages/docs/guide/setup.md\` is \`/docs/guide/setup\`, and \`pages/docs/guide/index.md\` is \`/docs/guide\`. Apply the site's app base, when specified below, to every page link.
16
+
17
+ - Answer only from these pages. Do not use what you know about the product from other sources.
18
+ - Link each page that you used, as a Markdown link to its URL, for example [Setup](/docs/guide/setup).
19
+ - If the pages do not answer the question, say that the documentation does not cover it. Do not guess.
20
+ - Keep answers short and concrete. Put code in fenced code blocks.
21
+ - Do not change files. Do not run commands that do not read the pages.
22
+
23
+ {{{ instructions }}}`;
24
+ /** Page paths only: the value goes into the instructions, so it must not carry Markdown or template syntax. */
25
+ const pagePathPattern = /^\/[\w\-./~%]{0,299}$/;
26
+ /** Returns the page path from a chat request body, or an empty string when it is missing or not a plain path. */
27
+ function docsPageFromBody(body) {
28
+ const page = body.page;
29
+ return typeof page === "string" && pagePathPattern.test(page) && !page.includes("..") ? page : "";
30
+ }
31
+ function currentPageInstructions({ context }) {
32
+ const page = context.get(docsPageContextKey);
33
+ const appBase = context.get("docsAppBase");
34
+ return [typeof appBase === "string" && appBase !== "/" ? `Prefix every page link with ${appBase}, for example [Setup](${docsAppPath("/docs/guide/setup", appBase)}). The reader's page path below is relative to this app base.` : "", typeof page === "string" && page ? `The reader has the page ${page} open. When the question is not clear, answer for that page first.` : ""].filter(Boolean).join("\n\n") || void 0;
35
+ }
36
+ /**
37
+ * The assistant's question limit, with the id `docs-rate-limit` that replaces the default one. Counters live in process
38
+ * memory: they reset on restart and do not span processes.
39
+ */
40
+ function docsRateLimit(options = {}) {
41
+ return rateLimit({
42
+ id: "docs-rate-limit",
43
+ identity: options.identity ?? (() => "site"),
44
+ trustedIpHeaders: options.trustedIpHeaders,
45
+ limiter: createRateLimiter({
46
+ driver: memoryRateLimitDriver(),
47
+ enforcement: "strict",
48
+ limit: options.limit ?? 30,
49
+ name: "docs-assistant",
50
+ window: options.window ?? "1h"
51
+ }),
52
+ message: "The docs assistant reached its limit of questions for now. Try again later."
53
+ });
54
+ }
55
+ /** The model of the Worker build. A model ID from the ChatGPT plan catalog: `vitehub connections models chatgpt`. */
56
+ const docsAssistantModel = "gpt-6.1-sol";
57
+ /**
58
+ * The pages Source: every page of the docs site, read from the same manifest and files as the site's Content. It covers
59
+ * `docs.dir` and `docs.sources`, and lays each page out at its URL path, as the docs rules expect. The Workspace reads it
60
+ * for each Invocation (`lazy`, no cache), so a page that development adds shows at once, and a Worker reads the pages
61
+ * that the docs build packed, with no second copy. It loads the docs server modules on the first read, so the Agent
62
+ * needs the `@vite-hub/docs` Nuxt module.
63
+ */
64
+ function docsPagesSource() {
65
+ return custom({
66
+ name: "docs-pages",
67
+ materialize: "lazy",
68
+ cache: false,
69
+ getKeys: async () => (await import("./assistant-pages-BN7hNsSZ.js")).listDocsAssistantPagePaths(),
70
+ getItem: async (key) => ({
71
+ key,
72
+ content: await (await import("./assistant-pages-BN7hNsSZ.js")).readDocsAssistantPage(key),
73
+ mediaType: "text/markdown"
74
+ })
75
+ });
76
+ }
77
+ /** The docs rules, the developer's instructions in their place, and the reader's page. */
78
+ const docsInstructions = { template: [docsRules, currentPageInstructions] };
79
+ /**
80
+ * The parts of the docs assistant that do not depend on the host: a read-only Workspace with the pages of the docs site,
81
+ * the `web` Chat Channel with the reader's current page, a site-wide rate limit, and Driver capacity.
82
+ */
83
+ function defineDocsAssistant(driver, capabilities = []) {
84
+ return defineAgent({
85
+ description: "Answers reader questions from the documentation pages.",
86
+ driver,
87
+ workspace: {
88
+ mode: "read",
89
+ sourceRootDir: process.cwd(),
90
+ sources: { pages: docsPagesSource() }
91
+ },
92
+ channels: { web: webChat({ route: { admission: { context: ({ body }) => {
93
+ const appBase = docsPageFromBody({ page: Reflect.get(body, "appBase") });
94
+ return { context: {
95
+ [docsPageContextKey]: docsPageFromBody(body),
96
+ ...appBase && appBase !== "/" && !appBase.startsWith("//") ? { docsAppBase: appBase } : {}
97
+ } };
98
+ } } } }) },
99
+ capabilities: [docsRateLimit(), ...capabilities],
100
+ budget: {
101
+ tokens: 2e5,
102
+ capacity: {
103
+ concurrency: 2,
104
+ queue: {
105
+ maxPending: 8,
106
+ timeout: 12e4
107
+ }
108
+ }
109
+ }
110
+ });
111
+ }
112
+ //#endregion
113
+ export { docsPageFromBody as a, docsPageContextKey as i, docsAssistantModel as n, docsRateLimit as o, docsInstructions as r, defineDocsAssistant as t };
@@ -0,0 +1,11 @@
1
+ import { i as docsRateLimit, n as docsPageContextKey, r as docsPageFromBody, t as DocsRateLimitOptions } from "./assistant-shared-CWIKRtBv.js";
2
+ import { WorkspaceAgentDefinition } from "@vite-hub/agent";
3
+ //#region src/assistant-worker.d.ts
4
+ /**
5
+ * The docs assistant in a Worker build: the `docsAssistant` of Node.js with a model-backed Driver on the same ChatGPT
6
+ * plan, because a Worker cannot start Codex. The model reads the pages with the read-only Workspace shell, which
7
+ * Codex does not need: it has its own.
8
+ */
9
+ export declare const docsAssistant: WorkspaceAgentDefinition;
10
+ //#endregion
11
+ export { type DocsRateLimitOptions, docsPageContextKey, docsPageFromBody, docsRateLimit };
@@ -0,0 +1,16 @@
1
+ import { a as docsPageFromBody, i as docsPageContextKey, n as docsAssistantModel, o as docsRateLimit, r as docsInstructions, t as defineDocsAssistant } from "./assistant-shared-WzButktj.js";
2
+ import { workspaceShell } from "@vite-hub/agent/capabilities";
3
+ import { chatgpt } from "@vite-hub/gateways";
4
+ //#region src/assistant-worker.ts
5
+ /**
6
+ * The docs assistant in a Worker build: the `docsAssistant` of Node.js with a model-backed Driver on the same ChatGPT
7
+ * plan, because a Worker cannot start Codex. The model reads the pages with the read-only Workspace shell, which
8
+ * Codex does not need: it has its own.
9
+ */
10
+ const docsAssistant = defineDocsAssistant({
11
+ model: docsAssistantModel,
12
+ gateway: chatgpt(),
13
+ instructions: docsInstructions
14
+ }, [workspaceShell()]);
15
+ //#endregion
16
+ export { docsAssistant, docsPageContextKey, docsPageFromBody, docsRateLimit };
@@ -0,0 +1,14 @@
1
+ import { i as docsRateLimit, n as docsPageContextKey, r as docsPageFromBody, t as DocsRateLimitOptions } from "./assistant-shared-CWIKRtBv.js";
2
+ import { WorkspaceAgentDefinition } from "@vite-hub/agent";
3
+ //#region src/assistant.d.ts
4
+ /**
5
+ * The docs assistant: a ViteHub Agent that answers from the site's Markdown pages, on the site owner's ChatGPT plan
6
+ * through the `chatgpt` Connection, so no API key is needed.
7
+ *
8
+ * On Node.js it runs Codex, which reads the pages with shell commands. A Worker build gets the same Agent with a
9
+ * model-backed Driver on the same plan, because a Worker cannot start Codex. Extend it with
10
+ * `defineAgent({ extends: docsAssistant, ... })` to change any part.
11
+ */
12
+ export declare const docsAssistant: WorkspaceAgentDefinition;
13
+ //#endregion
14
+ export { type DocsRateLimitOptions, docsPageContextKey, docsPageFromBody, docsRateLimit };
@@ -0,0 +1,19 @@
1
+ import { a as docsPageFromBody, i as docsPageContextKey, o as docsRateLimit, r as docsInstructions, t as defineDocsAssistant } from "./assistant-shared-WzButktj.js";
2
+ import { chatgpt } from "@vite-hub/gateways";
3
+ import { codexDriver } from "@vite-hub/agent";
4
+ //#region src/assistant.ts
5
+ /**
6
+ * The docs assistant: a ViteHub Agent that answers from the site's Markdown pages, on the site owner's ChatGPT plan
7
+ * through the `chatgpt` Connection, so no API key is needed.
8
+ *
9
+ * On Node.js it runs Codex, which reads the pages with shell commands. A Worker build gets the same Agent with a
10
+ * model-backed Driver on the same plan, because a Worker cannot start Codex. Extend it with
11
+ * `defineAgent({ extends: docsAssistant, ... })` to change any part.
12
+ */
13
+ const docsAssistant = defineDocsAssistant(codexDriver({
14
+ gateway: chatgpt(),
15
+ permissions: "allow-edits-unattended",
16
+ instructions: docsInstructions
17
+ }));
18
+ //#endregion
19
+ export { docsAssistant, docsPageContextKey, docsPageFromBody, docsRateLimit };
@@ -0,0 +1,141 @@
1
+ import { docsManifestPages, docsRawPath, findDocsPage } from "./navigation.js";
2
+ import { n as docsAgentPages, r as docsContentSource, t as docsAgentCopy } from "./agent-copy-xPaWye_g.js";
3
+ import { i as docsMarkdown, n as docsDocumentOf, r as docsImageSizes, t as createDocsParser } from "./markdown-DUWnEMPp.js";
4
+ import { n as readDocsFile } from "./files-UY4h1_36.js";
5
+ import "node:module";
6
+ import { defu } from "defu";
7
+ import { contentSource, defineContent } from "@vite-hub/content";
8
+ import agent from "#docs/agent";
9
+ import manifest from "#docs/manifest";
10
+ import { useRuntimeConfig } from "nitro/runtime-config";
11
+ import examples from "#docs/example-sources";
12
+ import imageSizes from "#docs/image-sizes";
13
+ import parser, { githubRepo } from "#docs/parser";
14
+ //#region \0rolldown/runtime.js
15
+ var __defProp = Object.defineProperty;
16
+ var __exportAll = (all, no_symbols) => {
17
+ let target = {};
18
+ for (var name in all) __defProp(target, name, {
19
+ get: all[name],
20
+ enumerable: true
21
+ });
22
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
23
+ return target;
24
+ };
25
+ //#endregion
26
+ //#region src/runtime/documents.ts
27
+ const references = githubRepo ? { github: { references: { repo: githubRepo } } } : {};
28
+ /**
29
+ * The one parser configuration of the site. The runtime Content of the page route and search, drafts, and credits parse
30
+ * with it. The images of the app's `public/` folder get their size after the site's own plugins.
31
+ */
32
+ const docsParserOptions = {
33
+ exampleSources: examples,
34
+ ...parser,
35
+ comarkUi: defu(parser.comarkUi, references),
36
+ plugins: [...parser.plugins ?? [], docsImageSizes(imageSizes)]
37
+ };
38
+ const parseDocsDocument = createDocsParser(docsParserOptions);
39
+ //#endregion
40
+ //#region src/runtime/content.ts
41
+ var content_exports = /* @__PURE__ */ __exportAll({
42
+ docsContent: () => docsContent,
43
+ readDocsPage: () => readDocsPage,
44
+ readDocsRawCopy: () => readDocsRawCopy
45
+ });
46
+ /** One docs folder as a Content Source, from the production bundle or development server assets. */
47
+ function bundledPages(base) {
48
+ const read = (key) => readDocsFile(base, key);
49
+ return {
50
+ keys: async () => docsManifestPages(manifest).filter((page) => (page.source ?? "docs") === base).map((page) => page.file),
51
+ getItem: async (key) => await read(key) ?? "",
52
+ getItemRaw: read
53
+ };
54
+ }
55
+ let content;
56
+ /** The agent copy of a page from its file. The `rawMarkdown` option runs at build time, and the build keeps each page that it changed. */
57
+ async function docsPageCopy(page, text, siteUrl) {
58
+ const rewritten = await readDocsFile("docs-agent", `${docsContentSource(page)}/${page.file}`);
59
+ return docsAgentCopy(manifest, page, rewritten === null ? text : String(rewritten), siteUrl);
60
+ }
61
+ /**
62
+ * The agent copy at a raw path such as `/raw/docs/kv.md`, or null. Content finds a Source page by its URL only after it lists every file,
63
+ * which costs a cold Worker about 250 ms on a large site. The manifest knows the file of each URL, so this reads the
64
+ * one file and renders it with the copy that Content serves in `llms-full.txt` and the MCP server.
65
+ */
66
+ async function readDocsRawCopy(rawPath) {
67
+ const path = rawPath.replace(/^\/raw/, "").replace(/\.md$/, "");
68
+ const found = findDocsPage(manifest, path === "/index" ? "/" : path);
69
+ if (!found || docsRawPath(found.page.path) !== rawPath) return null;
70
+ const config = useRuntimeConfig().public.docs;
71
+ const text = await readDocsFile(found.page.source ?? "docs", found.page.file);
72
+ if (text === null) return null;
73
+ const copy = await docsPageCopy(found.page, String(text), `${config.site.url}${config.appBase.replace(/\/+$/, "")}`);
74
+ return `${copy.markdown}${copy.footer}`;
75
+ }
76
+ /**
77
+ * The docs pages as Content, parsed with the site's parser. The first read creates it. Each page has its URL from the
78
+ * manifest, so Content serves the agent files: the `/raw/<page>.md` copies, `llms.txt`, `llms-full.txt`, `sitemap.md`,
79
+ * the sitemap pages, and the MCP server.
80
+ */
81
+ function docsContent() {
82
+ const config = useRuntimeConfig().public.docs;
83
+ const siteUrl = `${config.site.url}${config.appBase.replace(/\/+$/, "")}`;
84
+ if (content?.siteUrl === siteUrl) return content.runtime;
85
+ const pages = docsAgentPages(manifest);
86
+ const assets = new Map(docsManifestPages(manifest).map((page) => [docsContentSource(page), page.source ?? "docs"]));
87
+ const sources = Object.fromEntries([...assets].map(([name, base]) => {
88
+ const byKey = pages.get(name) ?? /* @__PURE__ */ new Map();
89
+ return [name, contentSource(bundledPages(base), {
90
+ url: ({ key }) => key === void 0 ? null : byKey.get(key)?.path ?? null,
91
+ label: "Docs",
92
+ seo: ({ key }) => {
93
+ const page = key === void 0 ? void 0 : byKey.get(key);
94
+ return page && {
95
+ title: page.sourceTitle,
96
+ ...page.description ? { description: page.description } : {},
97
+ ...page.seo?.index === false ? { noindex: true } : {}
98
+ };
99
+ },
100
+ markdown: async ({ key, text }) => {
101
+ const page = byKey.get(key);
102
+ return page ? await docsPageCopy(page, text, siteUrl) : null;
103
+ }
104
+ })];
105
+ }));
106
+ const runtime = defineContent({
107
+ route: false,
108
+ live: false,
109
+ markdown: docsMarkdown(docsParserOptions),
110
+ sources,
111
+ seo: {
112
+ ...config.site.url ? { site: siteUrl } : {},
113
+ sitemap: true,
114
+ markdown: {
115
+ prefix: "/raw",
116
+ pages: config.markdownPages
117
+ },
118
+ llms: {
119
+ title: config.site.name,
120
+ ...config.site.description ? { description: config.site.description } : {},
121
+ ...agent.llms
122
+ },
123
+ mcp: config.mcp ? { name: config.mcp.name } : false
124
+ }
125
+ });
126
+ content = {
127
+ runtime,
128
+ siteUrl
129
+ };
130
+ return runtime;
131
+ }
132
+ /**
133
+ * The parsed body of a page through `content.get()`, or null when its file is gone. The page route and search both read
134
+ * here, so a page parses once per server. Development parses on each read.
135
+ */
136
+ async function readDocsPage(page) {
137
+ const document = await docsContent().get(`${docsContentSource(page)}/${page.file}`, { fresh: import.meta.dev });
138
+ return document ? docsDocumentOf(document) : null;
139
+ }
140
+ //#endregion
141
+ export { parseDocsDocument as a, readDocsRawCopy as i, docsContent as n, readDocsPage as r, content_exports as t };
@@ -0,0 +1,45 @@
1
+ import { docsSectionForPath, findDocsPage, normalizeDocsPath } from "./navigation.js";
2
+ import { i as docsPageSchema, t as docsFrontmatter } from "./schema-DwpXW0VZ.js";
3
+ import { i as docsPageResponse, n as docsPageOf } from "./page-GPt09oex.js";
4
+ //#region src/draft.ts
5
+ /**
6
+ * The draft of the page at `path`, parsed like a published page, or null when the request shows the published file.
7
+ * A preview frame shows the draft of its one document, also before the page is published. A preview cookie shows the
8
+ * draft that Content resolves for the URL.
9
+ */
10
+ async function docsDraftResponse(content, manifest, path, parse) {
11
+ const normalized = normalizeDocsPath(path);
12
+ const draft = await readDraft(content, normalized);
13
+ if (!draft) return null;
14
+ const published = findDocsPage(manifest, normalized);
15
+ const section = published?.section ?? (normalized === manifest.root?.path ? null : docsSectionForPath(manifest, normalized));
16
+ const result = docsPageSchema.safeParse(docsFrontmatter(draft.data));
17
+ const at = {
18
+ id: published?.page.id ?? pageId(manifest, normalized, section?.path),
19
+ path: normalized,
20
+ file: `${draft.id}.md`
21
+ };
22
+ const page = result.success ? docsPageOf(result.data, at) : published?.page;
23
+ if (!page) return null;
24
+ return docsPageResponse(manifest, {
25
+ page,
26
+ section
27
+ }, await parse(draft.body ?? ""), page.credits ? await parse(page.credits) : null);
28
+ }
29
+ async function readDraft(content, path) {
30
+ const frame = content.preview.frame();
31
+ if (frame) {
32
+ const document = await content.collection(frame.collection).get(frame.id);
33
+ return typeof document?.url === "string" && normalizeDocsPath(document.url) === path ? document : null;
34
+ }
35
+ const found = await content.resolve(path);
36
+ return found ? await content.collection(found.collection).get(found.id) : null;
37
+ }
38
+ /** The id that the manifest gives a page at `path`: its path inside its section, `index` for an overview or the root. */
39
+ function pageId(manifest, path, section) {
40
+ if (path === manifest.root?.path) return "index";
41
+ if (!section) return "";
42
+ return path === section ? "index" : path.slice(section.length + 1);
43
+ }
44
+ //#endregion
45
+ export { docsDraftResponse };
@@ -0,0 +1,93 @@
1
+ import { defineDiagnostics } from "nostics";
2
+ //#region src/error-diagnostics.ts
3
+ const docsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
4
+ docsBase: "https://vitehub.dev/docs/docs-site/diagnostics",
5
+ codes: {
6
+ DOCS_ASSISTANT_AGENTS_MISSING: {
7
+ why: ({ agent }) => `[@vite-hub/docs] docs.assistant needs ViteHub Agents to answer from the "${agent}" Agent.`,
8
+ fix: "Add `vite-hub/nuxt` to modules and set `vitehub: { agent: true, connections: true }` in nuxt.config.ts, or set `docs: { assistant: false }`."
9
+ },
10
+ DOCS_ASSISTANT_PAGE_MISSING: {
11
+ why: ({ path }) => `[@vite-hub/docs] The docs assistant's Workspace has no page at ${path}. The pages changed after the Workspace listed them.`,
12
+ fix: "Ask the question again. The next Invocation lists the current pages."
13
+ },
14
+ DOCS_COMMENTS_DATABASE_OFF: {
15
+ why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which keeps threads in the Database, but vitehub sets database: false.",
16
+ fix: "Remove `database: false` from the `vitehub` options in nuxt.config.ts, or set `docs: { comments: false }`."
17
+ },
18
+ DOCS_COMMENTS_PACKAGE_MISSING: {
19
+ why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which needs @vite-hub/comments.",
20
+ fix: "Run `pnpm add @vite-hub/comments`, or set `docs: { comments: false }` in nuxt.config.ts."
21
+ },
22
+ DOCS_COMMENTS_VITEHUB_MISSING: {
23
+ why: "[@vite-hub/docs] docs.comments needs vite-hub/nuxt, which keeps the threads in a ViteHub Database.",
24
+ fix: "Add `vite-hub/nuxt` to modules in nuxt.config.ts, or set `docs: { comments: false }`."
25
+ },
26
+ DOCS_CONTENT_INVALID: {
27
+ why: ({ details, file }) => `Invalid docs frontmatter in ${file}: ${details}`,
28
+ fix: "Fix the field that the message names in the page frontmatter or the `.navigation.yml` file. The schemas are `docsPageSchema` and `docsSectionSchema` from `@vite-hub/docs`."
29
+ },
30
+ DOCS_EXAMPLE_MISSING: {
31
+ why: ({ name }) => `::example names "${name}", but the examples folder has no ${name}.vue.`,
32
+ fix: "Add the component that the message names to the examples folder of the docs, or correct the `name` of the `::example` block."
33
+ },
34
+ DOCS_LINKS_BROKEN: {
35
+ why: ({ problems }) => `Broken docs links:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
36
+ fix: "Fix each link that the message lists in the page that it names, or add the target to `checkDocsLinks({ excludeLinks })` when it is served outside the docs output."
37
+ },
38
+ DOCS_OUTPUT_MISSING: {
39
+ why: ({ root }) => `Docs output does not exist: ${root}`,
40
+ fix: "Build the docs site first, or pass `checkDocsLinks({ dir })` the folder that the build writes."
41
+ },
42
+ DOCS_REDIRECTS_BROKEN: {
43
+ why: ({ problems }) => `Docs redirects break links:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
44
+ fix: "Point each redirect route rule that the message lists to a docs page, or remove the rule when the page that it hides still exists."
45
+ },
46
+ DOCS_SEO_DESCRIPTION_INVALID: {
47
+ why: ({ problems }) => `Docs pages have no description, one of the wrong length, or the description of another page:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
48
+ fix: "Set `description` in the frontmatter of each page that the message lists, with 70 to 160 characters, and give each page its own."
49
+ },
50
+ DOCS_SEO_FAILED: {
51
+ why: ({ problems }) => `Docs pages fail the search checks:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
52
+ fix: "Fix each page that the message lists, or set `docs: { seoAudit: \"warn\" }` to report them as hints in `.vitehub/hints.json` without stopping the build."
53
+ },
54
+ DOCS_SEO_HEADINGS_INVALID: {
55
+ why: ({ problems }) => `Docs pages have headings that search engines flag:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
56
+ fix: "Give each page that the message lists one `h1`, and go down one heading level at a time, such as `##` and then `###`."
57
+ },
58
+ DOCS_SEO_HTML_TOO_LARGE: {
59
+ why: ({ problems }) => `Docs pages have more HTML than the 2 MB that Googlebot reads:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
60
+ fix: "Split each page that the message lists, or show long lists with a component that renders less markup than a Markdown table."
61
+ },
62
+ DOCS_SEO_LINK_NOT_PAGE: {
63
+ why: ({ problems }) => `Docs pages link to a redirect or to an endpoint, not to a page:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
64
+ fix: "Link to the page that the redirect goes to. Write the URL of an endpoint, such as `/mcp`, as code instead of a link."
65
+ },
66
+ DOCS_SEO_OPEN_GRAPH_INCOMPLETE: {
67
+ why: ({ problems }) => `Docs pages have incomplete Open Graph tags, so their share previews are incomplete:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
68
+ fix: "Set the head of each page that the message lists with `useDocsSeo()`. A page that writes its own head must set `og:title`, `og:type`, `og:image`, and `og:url`."
69
+ },
70
+ DOCS_SEO_PAGE_THIN: {
71
+ why: ({ problems }) => `Docs pages have fewer than 150 words, and site audits call them thin content:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
72
+ fix: "Write at least 150 words on each page that the message lists, or merge it into a related page."
73
+ },
74
+ DOCS_SEO_PAGE_UNLINKED: {
75
+ why: ({ problems }) => `No other page links to these docs pages, so crawlers find them only in the sitemap:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
76
+ fix: "Link each page that the message lists from the navigation, the footer, or a related page."
77
+ },
78
+ DOCS_SEO_SITEMAP_NOT_PAGE: {
79
+ why: ({ problems }) => `The sitemap lists URLs that are not prerendered pages:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
80
+ fix: "Remove each URL that the message lists from the sitemap, list the page that it redirects to, or make it a page."
81
+ },
82
+ DOCS_SEO_TITLE_INVALID: {
83
+ why: ({ problems }) => `Docs pages have no title, one of the wrong length, or the title of another page:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
84
+ fix: "Set `title` in the frontmatter of each page that the message lists, with 10 to 60 characters, and give each page its own. Use `seo.title` when the heading must stay."
85
+ },
86
+ DOCS_SOURCE_MOUNT_INVALID: {
87
+ why: ({ mount }) => `Invalid docs source mount: ${mount}`,
88
+ fix: "Set the `mount` of the docs source to a URL path such as `/guide`, without `.`, `..`, `?`, `#`, or backslash segments."
89
+ }
90
+ }
91
+ });
92
+ //#endregion
93
+ export { docsErrorDiagnostics as t };
@@ -0,0 +1,38 @@
1
+ import files from "#docs/files";
2
+ //#region src/runtime/files.ts
3
+ const decoder = new TextDecoder();
4
+ let unpacked;
5
+ async function unpack(base64) {
6
+ const zlib = globalThis.process?.getBuiltinModule?.("node:zlib");
7
+ const buffer = globalThis.process?.getBuiltinModule?.("node:buffer");
8
+ if (zlib && buffer) {
9
+ const bytes = zlib.gunzipSync(buffer.Buffer.from(base64, "base64"));
10
+ return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
11
+ }
12
+ const binary = atob(base64);
13
+ const gzip = new Uint8Array(binary.length);
14
+ for (let index = 0; index < binary.length; index++) gzip[index] = binary.charCodeAt(index);
15
+ return new Uint8Array(await new Response(new Response(gzip).body.pipeThrough(new DecompressionStream("gzip"))).arrayBuffer());
16
+ }
17
+ function packedFileRange(index, store, file) {
18
+ const ranges = Object.hasOwn(index, store) ? index[store] : void 0;
19
+ return ranges && Object.hasOwn(ranges, file) ? ranges[file] : void 0;
20
+ }
21
+ function hasDocsFile(store, file) {
22
+ return "read" in files ? files.has(store, file) : packedFileRange(files.index, store, file) !== void 0;
23
+ }
24
+ /**
25
+ * A Markdown file of a docs store: a content folder (`docs`, `docs-1`, ...) or the raw copies (`docs-raw`), or null.
26
+ * A production build packs every file into one module. Nitro server assets would add one module per file, and
27
+ * Cloudflare rejects a Worker upload with more than 5,000 modules. Development loads each file through Vite.
28
+ * Nitro gives no build warning for that limit (https://github.com/nitrojs/nitro/issues/5149).
29
+ */
30
+ async function readDocsFile(store, file) {
31
+ if ("read" in files) return await files.read(store, file);
32
+ const range = packedFileRange(files.index, store, file);
33
+ if (!range) return null;
34
+ const bytes = await (unpacked ??= unpack(files.packed));
35
+ return decoder.decode(bytes.subarray(range[0], range[1]));
36
+ }
37
+ //#endregion
38
+ export { readDocsFile as n, hasDocsFile as t };
@@ -0,0 +1,28 @@
1
+ import { a as DocsSection, c as DocsPageFile, d as DocsSectionFile, f as docsLayouts, g as expandDottedKeys, h as docsSectionSchema, i as DocsSearchSection, l as DocsPageFrontmatter, m as docsPageSchema, n as DocsManifest, o as DocsTocLink, p as docsPageFields, r as DocsPage, s as DocsLayout, t as DocsAppPage, u as DocsPageNavigation } from "./types-BhG6vGfG.js";
2
+ import { i as DocsDocument, n as DocsPageResponse, t as DocsPageLink } from "./page-Dx2JD3y1.js";
3
+ import { a as DocsPublicConfig, n as DocsLogo, o as DocsSiteOptions, r as DocsModuleOptions, s as DocsStartOptions } from "./nuxt-CAGpKl_-.js";
4
+ import { i as DocsSourceInput, r as DocsSource, t as DocsContentSource } from "./manifest-CMoxcwPm.js";
5
+ import { DocsCatalogGroup, DocsGroup, DocsIcons, DocsLink, DocsMarkdownLinks, DocsPanelLoaders, DocsRailEntry, DocsSidebarGroup, DocsSidebarSection, DocsSidebarSectionBlock, docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
6
+ import { ContentLabel, DocumentsDefinition } from "@vite-hub/content";
7
+ //#region src/collection.d.ts
8
+ interface DocsCollectionOptions {
9
+ /**
10
+ * Glob of the Markdown pages in the Content Workspace, such as `content/**\/*.md`. The folder before the first
11
+ * wildcard must be the content folder of the docs module, so that page URLs match the site. Defaults to
12
+ * `content/**\/*.md`, the module's default `dir`.
13
+ */
14
+ path?: string;
15
+ /** Name of the collection in the Console. Defaults to `{ singular: "Page", plural: "Docs" }`. */
16
+ label?: string | ContentLabel;
17
+ }
18
+ /**
19
+ * A Content collection over the docs Markdown pages, so the Console edits, previews, and publishes them. Its fields are
20
+ * the page frontmatter, and each document's URL is the page URL: `content/docs/kv/index.md` is `/docs/kv`.
21
+ *
22
+ * @example
23
+ * // server/content.ts
24
+ * export default defineContent({ extends: cms, collections: { docs: docsCollection() } })
25
+ */
26
+ export declare function docsCollection(options?: DocsCollectionOptions): DocumentsDefinition<typeof docsPageFields>;
27
+ //#endregion
28
+ export { type DocsAppPage, type DocsCatalogGroup, type DocsCollectionOptions, type DocsContentSource, type DocsDocument, type DocsGroup, type DocsIcons, type DocsLayout, type DocsLink, type DocsLogo, type DocsManifest, type DocsMarkdownLinks, type DocsModuleOptions, type DocsPage, type DocsPageFile, type DocsPageFrontmatter, type DocsPageLink, type DocsPageNavigation, type DocsPageResponse, type DocsPanelLoaders, type DocsPublicConfig, type DocsRailEntry, type DocsSearchSection, type DocsSection, type DocsSectionFile, type DocsSidebarGroup, type DocsSidebarSection, type DocsSidebarSectionBlock, type DocsSiteOptions, type DocsSource, type DocsSourceInput, type DocsStartOptions, type DocsTocLink, docsCatalog, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, normalizeDocsBase, normalizeDocsPath };
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
2
+ import { a as docsSectionSchema, i as docsPageSchema, n as docsLayouts, o as expandDottedKeys, r as docsPageFields } from "./schema-DwpXW0VZ.js";
3
+ import { r as docsPagePath } from "./page-GPt09oex.js";
4
+ import { documents } from "@vite-hub/content/collections";
5
+ //#region src/collection.ts
6
+ /**
7
+ * A Content collection over the docs Markdown pages, so the Console edits, previews, and publishes them. Its fields are
8
+ * the page frontmatter, and each document's URL is the page URL: `content/docs/kv/index.md` is `/docs/kv`.
9
+ *
10
+ * @example
11
+ * // server/content.ts
12
+ * export default defineContent({ extends: cms, collections: { docs: docsCollection() } })
13
+ */
14
+ function docsCollection(options = {}) {
15
+ return documents({
16
+ path: options.path ?? "content/**/*.md",
17
+ fields: docsPageFields,
18
+ label: options.label ?? {
19
+ singular: "Page",
20
+ plural: "Docs"
21
+ },
22
+ titleField: "title",
23
+ url: ({ id }) => docsPagePath(id)
24
+ });
25
+ }
26
+ //#endregion
27
+ export { docsCatalog, docsCollection, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, normalizeDocsBase, normalizeDocsPath };
@@ -0,0 +1,13 @@
1
+ //#region src/link-checker-redirects.d.ts
2
+ /**
3
+ * The link checker reads its options once, when Nuxt installs it, and reports every link to a redirect. The docs module
4
+ * installs this module just before it, after the app's modules have added their route rules, so a link to a redirect
5
+ * route rule passes. The docs module checks where each redirect goes instead.
6
+ * Upstream: the late `excludeLinks` (https://github.com/harlan-zw/nuxt-link-checker/issues/143) and the unchecked
7
+ * redirect target (https://github.com/harlan-zw/nuxt-link-checker/pull/142).
8
+ */
9
+ declare const linkCheckerRedirects: {
10
+ (inlineOptions: Record<string, never>, nuxt: never): unknown;
11
+ };
12
+ //#endregion
13
+ export { linkCheckerRedirects as default };
@@ -0,0 +1,25 @@
1
+ import { docsAppPath } from "./navigation.js";
2
+ import { r as docsRedirects } from "./redirects-CmR1yu5A.js";
3
+ import { defineNuxtModule } from "@nuxt/kit";
4
+ //#region src/link-checker-redirects.ts
5
+ /**
6
+ * The link checker reads its options once, when Nuxt installs it, and reports every link to a redirect. The docs module
7
+ * installs this module just before it, after the app's modules have added their route rules, so a link to a redirect
8
+ * route rule passes. The docs module checks where each redirect goes instead.
9
+ * Upstream: the late `excludeLinks` (https://github.com/harlan-zw/nuxt-link-checker/issues/143) and the unchecked
10
+ * redirect target (https://github.com/harlan-zw/nuxt-link-checker/pull/142).
11
+ */
12
+ const linkCheckerRedirects = defineNuxtModule({
13
+ meta: { name: "@vite-hub/docs/link-checker-redirects" },
14
+ setup(_options, nuxt) {
15
+ const options = nuxt.options;
16
+ const linkChecker = options.linkChecker ??= {};
17
+ const redirects = docsRedirects({
18
+ ...options.nitro.routeRules,
19
+ ...options.routeRules
20
+ }).filter((redirect) => redirect.to.startsWith("/") && !redirect.to.startsWith("//"));
21
+ linkChecker.excludeLinks = [...linkChecker.excludeLinks ?? [], ...redirects.map((redirect) => docsAppPath(redirect.from, options.app.baseURL))];
22
+ }
23
+ });
24
+ //#endregion
25
+ export { linkCheckerRedirects as default };