doccupine 0.0.63 → 0.0.65

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 (94) hide show
  1. package/README.md +4 -3
  2. package/dist/lib/structures.js +4 -0
  3. package/dist/templates/app/api/rag/route.d.ts +1 -1
  4. package/dist/templates/app/api/rag/route.js +11 -4
  5. package/dist/templates/app/theme.d.ts +3 -1
  6. package/dist/templates/app/theme.js +17 -15
  7. package/dist/templates/components/Chat.d.ts +1 -1
  8. package/dist/templates/components/Chat.js +358 -161
  9. package/dist/templates/components/DocsSideBar.d.ts +1 -1
  10. package/dist/templates/components/DocsSideBar.js +45 -11
  11. package/dist/templates/components/LockBodyScroll.d.ts +1 -0
  12. package/dist/templates/components/LockBodyScroll.js +17 -0
  13. package/dist/templates/components/SideBar.d.ts +1 -1
  14. package/dist/templates/components/SideBar.js +15 -2
  15. package/dist/templates/components/layout/Accordion.d.ts +1 -1
  16. package/dist/templates/components/layout/Accordion.js +1 -1
  17. package/dist/templates/components/layout/ActionBar.d.ts +1 -1
  18. package/dist/templates/components/layout/ActionBar.js +17 -87
  19. package/dist/templates/components/layout/Callout.d.ts +1 -1
  20. package/dist/templates/components/layout/Callout.js +1 -1
  21. package/dist/templates/components/layout/Card.d.ts +1 -1
  22. package/dist/templates/components/layout/Card.js +26 -7
  23. package/dist/templates/components/layout/Code.d.ts +1 -1
  24. package/dist/templates/components/layout/Code.js +1 -1
  25. package/dist/templates/components/layout/Columns.d.ts +1 -1
  26. package/dist/templates/components/layout/Columns.js +1 -1
  27. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  28. package/dist/templates/components/layout/DocsComponents.js +40 -14
  29. package/dist/templates/components/layout/DocsNavigation.d.ts +1 -1
  30. package/dist/templates/components/layout/DocsNavigation.js +3 -2
  31. package/dist/templates/components/layout/Field.d.ts +1 -1
  32. package/dist/templates/components/layout/Field.js +1 -1
  33. package/dist/templates/components/layout/Footer.d.ts +1 -1
  34. package/dist/templates/components/layout/Footer.js +28 -6
  35. package/dist/templates/components/layout/Header.d.ts +1 -1
  36. package/dist/templates/components/layout/Header.js +10 -12
  37. package/dist/templates/components/layout/SharedStyles.d.ts +1 -1
  38. package/dist/templates/components/layout/SharedStyles.js +26 -2
  39. package/dist/templates/components/layout/StaticLinks.d.ts +1 -1
  40. package/dist/templates/components/layout/StaticLinks.js +7 -3
  41. package/dist/templates/components/layout/Steps.d.ts +1 -1
  42. package/dist/templates/components/layout/Steps.js +7 -2
  43. package/dist/templates/components/layout/Tabs.d.ts +1 -1
  44. package/dist/templates/components/layout/Tabs.js +2 -2
  45. package/dist/templates/components/layout/Update.d.ts +1 -1
  46. package/dist/templates/components/layout/Update.js +1 -1
  47. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  48. package/dist/templates/mdx/ai-assistant.mdx.js +8 -0
  49. package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
  50. package/dist/templates/mdx/callouts.mdx.js +6 -2
  51. package/dist/templates/mdx/cards.mdx.d.ts +1 -1
  52. package/dist/templates/mdx/cards.mdx.js +19 -3
  53. package/dist/templates/mdx/columns.mdx.d.ts +1 -1
  54. package/dist/templates/mdx/columns.mdx.js +2 -2
  55. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  56. package/dist/templates/mdx/commands.mdx.js +10 -2
  57. package/dist/templates/mdx/components.mdx.d.ts +1 -0
  58. package/dist/templates/mdx/components.mdx.js +56 -0
  59. package/dist/templates/mdx/deployment.mdx.d.ts +1 -1
  60. package/dist/templates/mdx/deployment.mdx.js +1 -1
  61. package/dist/templates/mdx/globals.mdx.d.ts +1 -1
  62. package/dist/templates/mdx/globals.mdx.js +5 -0
  63. package/dist/templates/mdx/index.mdx.d.ts +1 -1
  64. package/dist/templates/mdx/index.mdx.js +5 -5
  65. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  66. package/dist/templates/mdx/model-context-protocol.mdx.js +2 -2
  67. package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
  68. package/dist/templates/mdx/navigation.mdx.js +1 -1
  69. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  70. package/dist/templates/mdx/platform/ai-assistant.mdx.js +20 -0
  71. package/dist/templates/mdx/platform/external-links.mdx.d.ts +1 -1
  72. package/dist/templates/mdx/platform/external-links.mdx.js +2 -0
  73. package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
  74. package/dist/templates/mdx/platform/fonts-settings.mdx.js +8 -5
  75. package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
  76. package/dist/templates/mdx/platform/index.mdx.js +10 -1
  77. package/dist/templates/mdx/platform/site-settings.mdx.d.ts +1 -1
  78. package/dist/templates/mdx/platform/site-settings.mdx.js +4 -4
  79. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  80. package/dist/templates/mdx/sections.mdx.js +2 -2
  81. package/dist/templates/mdx/steps.mdx.d.ts +1 -1
  82. package/dist/templates/mdx/steps.mdx.js +4 -0
  83. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  84. package/dist/templates/mdx/tabs.mdx.js +1 -1
  85. package/dist/templates/package.js +5 -5
  86. package/dist/templates/services/llm/types.d.ts +1 -1
  87. package/dist/templates/services/llm/types.js +1 -1
  88. package/dist/templates/services/mcp/server.d.ts +1 -1
  89. package/dist/templates/services/mcp/server.js +1 -1
  90. package/dist/templates/services/mcp/tools.d.ts +1 -1
  91. package/dist/templates/services/mcp/tools.js +1 -5
  92. package/dist/templates/utils/config.d.ts +1 -1
  93. package/dist/templates/utils/config.js +1 -1
  94. package/package.json +1 -1
@@ -36,9 +36,12 @@ Font settings are stored in \`fonts.json\` at the root of your repository. Here'
36
36
 
37
37
  \`\`\`json
38
38
  {
39
- "type": "google",
40
- "name": "Inter",
41
- "weights": [400, 500, 600, 700],
42
- "subsets": ["latin"]
39
+ "googleFont": {
40
+ "fontName": "Inter",
41
+ "subsets": ["latin"],
42
+ "weight": ["400", "500", "600", "700"]
43
+ }
43
44
  }
44
- \`\`\``;
45
+ \`\`\`
46
+
47
+ See the [Fonts](/fonts) page for the full configuration format, including local font support.`;
@@ -1 +1 @@
1
- export declare const platformIndexMdxTemplate = "---\ntitle: \"Platform Overview\"\ndescription: \"Learn how to use the Doccupine platform to create, customize, and deploy documentation websites.\"\ndate: \"2026-02-19\"\ncategory: \"Getting Started\"\ncategoryOrder: 0\norder: 0\nsection: \"Platform\"\n---\n# Platform Overview\nThe Doccupine platform gives you everything you need to create, customize, and host beautiful documentation websites - all from your browser. No local setup, no CI pipelines, no infrastructure to manage.\n\n## What you get\n- **Browser-based editor** for writing and managing your documentation files\n- **One-click publishing** that commits to GitHub and deploys automatically\n- **Visual configuration** for themes, navigation, fonts, links, and more\n- **Custom domains** with automatic HTTPS\n- **AI assistant** built into every deployed site\n- **Team collaboration** with role-based access control\n\n## How it works\nDoccupine connects two core pieces behind the scenes:\n\n1. **GitHub** stores your documentation source files in a Git repository\n2. **Doccupine** builds, hosts, and serves your site globally - plus provides a dashboard for editing, configuring, and managing your project\n\nYou write MDX files, configure your site through visual settings pages, and hit Publish. Doccupine handles the rest.\n\n## Getting started\n\n1. **Sign up** at Doccupine and start your free 30-day trial - no credit card required.\n2. **Create a project** from the dashboard. Choose between a managed repository or connecting your own GitHub account.\n3. **Edit your docs** using the built-in file explorer and editor.\n4. **Configure your site** through the settings pages - theme, navigation, fonts, and more.\n5. **Publish** your changes with a single click.\n\n<Callout type=\"success\">\n Your documentation site is live the moment you create a project. Doccupine deploys a starter site automatically so you can see results immediately.\n</Callout>\n\n## Dashboard\nAfter signing in, the dashboard shows all your projects. You'll see two sections:\n\n- **Your Projects** - documentation sites you own, plus a button to create new ones\n- **Shared Projects** - sites that other users have invited you to collaborate on\n\nClick any project card to open it and start working.";
1
+ export declare const platformIndexMdxTemplate = "---\ntitle: \"Platform Overview\"\ndescription: \"Learn how to use the Doccupine platform to create, customize, and deploy documentation websites.\"\ndate: \"2026-02-19\"\ncategory: \"Getting Started\"\ncategoryOrder: 0\norder: 0\nsection: \"Platform\"\n---\n# Platform Overview\nThe Doccupine platform gives you everything you need to create, customize, and host beautiful documentation websites - all from your browser. No local setup, no CI pipelines, no infrastructure to manage.\n\n## What you get\n- **Browser-based editor** for writing and managing your documentation files\n- **One-click publishing** that commits to GitHub and deploys automatically\n- **Visual configuration** for themes, navigation, fonts, links, and more\n- **Custom domains** with automatic HTTPS\n- **AI assistant** built into every deployed site\n- **Team collaboration** with role-based access control\n\n## How it works\nDoccupine connects two core pieces behind the scenes:\n\n1. **GitHub** stores your documentation source files in a Git repository\n2. **Doccupine** builds, hosts, and serves your site globally - plus provides a dashboard for editing, configuring, and managing your project\n\nYou write MDX files, configure your site through visual settings pages, and hit Publish. Doccupine handles the rest.\n\n## Getting started\n\n1. **Sign up** at Doccupine and start your free 30-day trial - no credit card required.\n2. **Create a project** from the dashboard. Choose between a managed repository or connecting your own GitHub account.\n3. **Edit your docs** using the built-in file explorer and editor.\n4. **Configure your site** through the settings pages - theme, navigation, fonts, and more.\n5. **Publish** your changes with a single click.\n\n<Callout type=\"success\">\n Your documentation site is live the moment you create a project. Doccupine deploys a starter site automatically so you can see results immediately.\n</Callout>\n\n## Dashboard\nAfter signing in, the dashboard shows all your projects. You'll see two sections:\n\n- **Your Projects** - documentation sites you own, plus a button to create new ones\n- **Shared Projects** - sites that other users have invited you to collaborate on\n\nClick any project card to open it and start working.\n\n<Columns cols={2}>\n <Card title=\"Sign Up\" icon=\"user-plus\" href=\"https://doccupine.com/sign-up\">\n Create your free account and start building documentation in minutes.\n </Card>\n <Card title=\"Sign In\" icon=\"log-in\" href=\"https://doccupine.com/sign-in\">\n Already have an account? Sign in to your dashboard.\n </Card>\n</Columns>";
@@ -44,4 +44,13 @@ After signing in, the dashboard shows all your projects. You'll see two sections
44
44
  - **Your Projects** - documentation sites you own, plus a button to create new ones
45
45
  - **Shared Projects** - sites that other users have invited you to collaborate on
46
46
 
47
- Click any project card to open it and start working.`;
47
+ Click any project card to open it and start working.
48
+
49
+ <Columns cols={2}>
50
+ <Card title="Sign Up" icon="user-plus" href="https://doccupine.com/sign-up">
51
+ Create your free account and start building documentation in minutes.
52
+ </Card>
53
+ <Card title="Sign In" icon="log-in" href="https://doccupine.com/sign-in">
54
+ Already have an account? Sign in to your dashboard.
55
+ </Card>
56
+ </Columns>`;
@@ -1 +1 @@
1
- export declare const platformSiteSettingsMdxTemplate = "---\ntitle: \"Site Settings\"\ndescription: \"Configure your documentation site's name, description, favicon, and preview image.\"\ndate: \"2026-02-19\"\ncategory: \"Configuration\"\ncategoryOrder: 2\norder: 0\nsection: \"Platform\"\n---\n# Site Settings\nThe Site settings page lets you configure the core metadata for your documentation site. These values are stored in `config.json` at the root of your repository.\n\n## Fields\n\n### Name\nThe name of your documentation site. This appears in the site header and browser tab title.\n\n### Description\nA short description of your documentation. Used in meta tags for search engine optimization and social media previews.\n\n### Favicon\nUpload a favicon image that appears in browser tabs. Supported formats include PNG, ICO, and SVG. Use the file upload button to select an image from your computer.\n\n### Preview image\nUpload an image used for social media and OpenGraph previews. This is the image that appears when your documentation URL is shared on platforms like Twitter, Slack, or Discord.\n\n<Callout type=\"note\">\n Changes to site settings are staged as pending changes, just like file edits. Click **Publish** to commit them to your repository and trigger a deploy.\n</Callout>\n\n## How it works\nBehind the scenes, the Site settings page reads and writes `config.json` in your repository. You can also edit this file directly in the file editor if you prefer.\n\n```json\n{\n \"name\": \"My Documentation\",\n \"description\": \"Documentation for my project\",\n \"favicon\": \"/favicon.png\",\n \"previewImage\": \"/preview.png\"\n}\n```";
1
+ export declare const platformSiteSettingsMdxTemplate = "---\ntitle: \"Site Settings\"\ndescription: \"Configure your documentation site's name, description, icon, and image.\"\ndate: \"2026-02-19\"\ncategory: \"Configuration\"\ncategoryOrder: 2\norder: 0\nsection: \"Platform\"\n---\n# Site Settings\nThe Site settings page lets you configure the core metadata for your documentation site. These values are stored in `config.json` at the root of your repository.\n\n## Fields\n\n### Name\nThe name of your documentation site. This appears in the site header and browser tab title.\n\n### Description\nA short description of your documentation. Used in meta tags for search engine optimization and social media previews.\n\n### Favicon\nUpload a favicon image that appears in browser tabs. Supported formats include PNG, ICO, and SVG. Use the file upload button to select an image from your computer.\n\n### Preview image\nUpload an image used for social media and OpenGraph previews. This is the image that appears when your documentation URL is shared on platforms like Twitter, Slack, or Discord.\n\n<Callout type=\"note\">\n Changes to site settings are staged as pending changes, just like file edits. Click **Publish** to commit them to your repository and trigger a deploy.\n</Callout>\n\n## How it works\nBehind the scenes, the Site settings page reads and writes `config.json` in your repository. You can also edit this file directly in the file editor if you prefer. See the [Globals](/globals) page for the full configuration reference.\n\n```json\n{\n \"name\": \"My Documentation\",\n \"description\": \"Documentation for my project\",\n \"icon\": \"/favicon.png\",\n \"image\": \"/preview.png\"\n}\n```";
@@ -1,6 +1,6 @@
1
1
  export const platformSiteSettingsMdxTemplate = `---
2
2
  title: "Site Settings"
3
- description: "Configure your documentation site's name, description, favicon, and preview image."
3
+ description: "Configure your documentation site's name, description, icon, and image."
4
4
  date: "2026-02-19"
5
5
  category: "Configuration"
6
6
  categoryOrder: 2
@@ -29,13 +29,13 @@ Upload an image used for social media and OpenGraph previews. This is the image
29
29
  </Callout>
30
30
 
31
31
  ## How it works
32
- Behind the scenes, the Site settings page reads and writes \`config.json\` in your repository. You can also edit this file directly in the file editor if you prefer.
32
+ Behind the scenes, the Site settings page reads and writes \`config.json\` in your repository. You can also edit this file directly in the file editor if you prefer. See the [Globals](/globals) page for the full configuration reference.
33
33
 
34
34
  \`\`\`json
35
35
  {
36
36
  "name": "My Documentation",
37
37
  "description": "Documentation for my project",
38
- "favicon": "/favicon.png",
39
- "previewImage": "/preview.png"
38
+ "icon": "/favicon.png",
39
+ "image": "/preview.png"
40
40
  }
41
41
  \`\`\``;
@@ -1 +1 @@
1
- export declare const sectionsMdxTemplate = "---\ntitle: \"Sections\"\ndescription: \"Split your documentation into top-level sections with independent sidebars.\"\ndate: \"2026-02-19\"\ncategory: \"Configuration\"\ncategoryOrder: 3\norder: 3\n---\n# Sections\nSections let you divide your documentation into separate top-level areas - for example \"Guides\", \"API Reference\", and \"SDKs\". Each section gets its own sidebar and appears as a horizontal tab bar below the site header.\n\n<Callout type=\"note\">\n Sections are entirely opt-in. If you don't configure them, nothing changes - your site works exactly as before with a single flat navigation.\n</Callout>\n\n## Automatic sections (frontmatter)\nThe simplest way to add sections is through page frontmatter. Add a `section` field to group pages, and an optional `sectionOrder` to control the order of sections in the bar.\n\n### Frontmatter fields\n- **section**: The display name for the section this page belongs to (e.g. \"API Reference\").\n- **sectionOrder**: Controls the position of the section in the bar. Lower numbers appear first.\n\nThe section slug is derived automatically from the label - lowercased with spaces replaced by hyphens. So \"API Reference\" becomes `api-reference`.\n\nPages without a `section` field stay at the root URL and appear under a default tab labeled \"Docs\". You can rename this tab with the `sectionLabel` field on your `index.mdx`:\n\n```text\n---\ntitle: \"Welcome\"\nsectionLabel: \"Guides\"\n---\n```\n\n### Directory-based organization\nYou can organize each section's files in a subdirectory that matches the section slug. When the directory name matches, Doccupine automatically assigns the files to that section and strips the directory from the URL.\n\n```text\ndocs/\n index.mdx\n getting-started.mdx\n platform/\n index.mdx -> /platform\n auth.mdx -> /platform/auth\n```\n\nWhere `platform/index.mdx` has:\n\n```text\n---\ntitle: \"Platform\"\nsection: \"Platform\"\nsectionOrder: 1\ncategory: \"Overview\"\n---\n```\n\nThe directory `platform/` matches the section slug `platform`, so it is stripped. `platform/index.mdx` serves at `/platform/` and `platform/auth.mdx` serves at `/platform/auth`.\n\n<Callout type=\"info\">\n Once a section exists, any file placed in a matching directory is automatically assigned to it - even without a `section` field in its own frontmatter. Only the first file needs `section` and `sectionOrder` to create the section. After that, the directory does the work.\n</Callout>\n\nFiles at the root level with a `section` field work too - they keep their full slug under the section prefix.\n\n### Section index pages\nIf a section has no index page (no file at its root URL), Doccupine generates a redirect to the first page in that section, sorted by `categoryOrder` then `order`.\n\n<Callout type=\"note\">\n You can override the auto-redirect by creating an `index.mdx` in the section's directory.\n</Callout>\n\n### Flat file example\nYou can also keep all files at the root and rely purely on frontmatter:\n\n```text\n---\ntitle: \"Authentication\"\nsection: \"API Reference\"\nsectionOrder: 2\ncategory: \"Auth\"\ncategoryOrder: 1\norder: 1\n---\n```\n\nThis page would be served at `/api-reference/authentication`.\n\n## Explicit sections with sections.json\nFor full control over slugs, create a `sections.json` file at your project root (the same folder where you run `npx doccupine`).\n\n### Minimal example\n\n```json\n[\n { \"label\": \"Docs\", \"slug\": \"\" },\n { \"label\": \"Platform\", \"slug\": \"platform\" }\n]\n```\n\nThis defines two sections. Pages are assigned automatically:\n- Files in a `platform/` directory belong to the \"Platform\" section (directory name matches slug).\n- Files with `section: \"Platform\"` in their frontmatter also belong to it.\n- Everything else stays in the root \"Docs\" section.\n\nNo `directory` field is needed when the directory name already matches the section slug.\n\n### Example with explicit directories\nWhen the directory name differs from the slug, use the `directory` field to map them:\n\n```json\n[\n { \"label\": \"Guides\", \"slug\": \"\", \"directory\": \"guides\" },\n { \"label\": \"API Reference\", \"slug\": \"api\", \"directory\": \"api-reference\" },\n { \"label\": \"SDKs\", \"slug\": \"sdks\", \"directory\": \"sdks\" }\n]\n```\n\n### Fields\n- **label**: The display name shown in the section bar.\n- **slug**: The URL prefix for this section. Use an empty string `\"\"` for the default section that serves at the root.\n- **directory** (optional): The subdirectory under your watch directory that contains this section's MDX files. Only needed when the directory name differs from the slug.\n\n### Directory structure example\nWith the explicit directory config above and a watch directory of `docs`, your files would look like:\n\n```text\ndocs/\n guides/\n index.mdx\n getting-started.mdx\n api-reference/\n authentication.mdx\n endpoints.mdx\n sdks/\n javascript.mdx\n python.mdx\n```\n\n## Section navigation\nEach section builds its own sidebar from the pages that belong to it. By default, pages are grouped by `category` and sorted by `categoryOrder` and `order` from frontmatter.\n\nFor explicit control, use `navigation.json` with the object format to define per-section navigation:\n\n```json\n{\n \"\": [\n { \"label\": \"General\", \"links\": [{ \"slug\": \"\", \"title\": \"Getting Started\" }] }\n ],\n \"platform\": [\n { \"label\": \"API\", \"links\": [{ \"slug\": \"platform/auth\", \"title\": \"Auth\" }] }\n ]\n}\n```\n\nKeys are section slugs. The root section uses `\"\"`. Sections without a key fall back to auto-generated navigation. See the Navigation page for the full format.\n\n## How pages are assigned to sections\nDoccupine checks these rules in order and uses the first match:\n\n1. **Explicit directory** - the file is inside a directory listed in a section's `directory` field.\n2. **Directory matches slug** - the file's parent directory matches a section slug (e.g. files in `platform/` match a section with `slug: \"platform\"`).\n3. **Frontmatter section field** - the file's `section` value matches a section label.\n4. **No match** - the page stays at the root.\n\n## Precedence for section discovery\n1. **sections.json exists** - Doccupine uses it to define available sections.\n2. **No sections.json but pages have `section` frontmatter** - Doccupine auto-discovers sections from the frontmatter. Sections update live as you add or remove the `section` field from files.\n3. **Neither** - No section bar appears. The site works exactly as before.\n\n## URL structure\nPages in the default section (with `slug: \"\"`) serve at the root:\n\n- Default section: `/getting-started`, `/installation`\n- Other sections: `/api/authentication`, `/sdks/javascript`\n\n<Callout type=\"info\">\n When a file is in a directory that matches its section slug, the directory is stripped so it doesn't appear twice. For example, `platform/auth.mdx` in the \"Platform\" section serves at `/platform/auth`, not `/platform/platform/auth`.\n</Callout>\n\n## sections.json vs navigation.json\nThese two config files serve different purposes and complement each other:\n\n- **sections.json** defines which sections exist - their labels, slugs, directory mappings, and order in the tab bar.\n- **navigation.json** controls the sidebar within each section - page ordering and grouping.\n\nYou can use either one independently. `sections.json` without `navigation.json` gives you sections with auto-generated sidebars. `navigation.json` without `sections.json` gives you custom sidebar ordering with frontmatter-discovered sections (or no sections at all).\n\n## Tips\n- **Start simple**: Add `section` and `sectionOrder` to a few pages to try it out. No config files needed.\n- **Use directories**: Organize each section's files in a directory that matches the section slug for clean URLs and a tidy file tree.\n- **Rename the default tab**: Add `sectionLabel: \"Your Label\"` to your `index.mdx` frontmatter. Defaults to \"Docs\" if omitted.\n- **Switch to sections.json**: When you need custom slugs or directory mappings that don't match section names, `sections.json` gives full control.\n- **Per-section navigation**: Use the object format in `navigation.json` to define custom sidebar ordering for specific sections.\n- **Independent sidebars**: Each section has its own sidebar. Previous/next navigation stays within the active section.";
1
+ export declare const sectionsMdxTemplate = "---\ntitle: \"Sections\"\ndescription: \"Split your documentation into top-level sections with independent sidebars.\"\ndate: \"2026-02-19\"\ncategory: \"Configuration\"\ncategoryOrder: 3\norder: 3\n---\n# Sections\nSections let you divide your documentation into separate top-level areas - for example \"Guides\", \"API Reference\", and \"SDKs\". Each section gets its own sidebar and appears as a horizontal tab bar below the site header.\n\n<Callout type=\"note\">\n Sections are entirely opt-in. If you don't configure them, nothing changes - your site works exactly as before with a single flat navigation.\n</Callout>\n\n## Automatic sections (frontmatter)\nThe simplest way to add sections is through page frontmatter. Add a `section` field to group pages, and an optional `sectionOrder` to control the order of sections in the bar.\n\n### Frontmatter fields\n- **section**: The display name for the section this page belongs to (e.g. \"API Reference\").\n- **sectionOrder**: Controls the position of the section in the bar. Lower numbers appear first.\n\nThe section slug is derived automatically from the label - lowercased with spaces replaced by hyphens. So \"API Reference\" becomes `api-reference`.\n\nPages without a `section` field stay at the root URL and appear under a default tab labeled \"Docs\". You can rename this tab with the `sectionLabel` field on your `index.mdx`:\n\n```text\n---\ntitle: \"Welcome\"\nsectionLabel: \"Guides\"\n---\n```\n\n### Directory-based organization\nYou can organize each section's files in a subdirectory that matches the section slug. When the directory name matches, Doccupine automatically assigns the files to that section and strips the directory from the URL.\n\n```text\ndocs/\n index.mdx\n getting-started.mdx\n platform/\n index.mdx -> /platform\n auth.mdx -> /platform/auth\n```\n\nWhere `platform/index.mdx` has:\n\n```text\n---\ntitle: \"Platform Overview\"\nsection: \"Platform\"\nsectionOrder: 1\ncategory: \"Getting Started\"\n---\n```\n\nThe directory `platform/` matches the section slug `platform`, so it is stripped. `platform/index.mdx` serves at `/platform/` and `platform/auth.mdx` serves at `/platform/auth`.\n\n<Callout type=\"info\">\n Once a section exists, any file placed in a matching directory is automatically assigned to it - even without a `section` field in its own frontmatter. Only the first file needs `section` and `sectionOrder` to create the section. After that, the directory does the work.\n</Callout>\n\nFiles at the root level with a `section` field work too - they keep their full slug under the section prefix.\n\n### Section index pages\nIf a section has no index page (no file at its root URL), Doccupine generates a redirect to the first page in that section, sorted by `categoryOrder` then `order`.\n\n<Callout type=\"note\">\n You can override the auto-redirect by creating an `index.mdx` in the section's directory.\n</Callout>\n\n### Flat file example\nYou can also keep all files at the root and rely purely on frontmatter:\n\n```text\n---\ntitle: \"Authentication\"\nsection: \"API Reference\"\nsectionOrder: 2\ncategory: \"Auth\"\ncategoryOrder: 1\norder: 1\n---\n```\n\nThis page would be served at `/api-reference/authentication`.\n\n## Explicit sections with sections.json\nFor full control over slugs, create a `sections.json` file at your project root (the same folder where you run `npx doccupine`).\n\n### Minimal example\n\n```json\n[\n { \"label\": \"Docs\", \"slug\": \"\" },\n { \"label\": \"Platform\", \"slug\": \"platform\" }\n]\n```\n\nThis defines two sections. Pages are assigned automatically:\n- Files in a `platform/` directory belong to the \"Platform\" section (directory name matches slug).\n- Files with `section: \"Platform\"` in their frontmatter also belong to it.\n- Everything else stays in the root \"Docs\" section.\n\nNo `directory` field is needed when the directory name already matches the section slug.\n\n### Example with explicit directories\nWhen the directory name differs from the slug, use the `directory` field to map them:\n\n```json\n[\n { \"label\": \"Guides\", \"slug\": \"\", \"directory\": \"guides\" },\n { \"label\": \"API Reference\", \"slug\": \"api\", \"directory\": \"api-reference\" },\n { \"label\": \"SDKs\", \"slug\": \"sdks\", \"directory\": \"sdks\" }\n]\n```\n\n### Fields\n- **label**: The display name shown in the section bar.\n- **slug**: The URL prefix for this section. Use an empty string `\"\"` for the default section that serves at the root.\n- **directory** (optional): The subdirectory under your watch directory that contains this section's MDX files. Only needed when the directory name differs from the slug.\n\n### Directory structure example\nWith the explicit directory config above and a watch directory of `docs`, your files would look like:\n\n```text\ndocs/\n guides/\n index.mdx\n getting-started.mdx\n api-reference/\n authentication.mdx\n endpoints.mdx\n sdks/\n javascript.mdx\n python.mdx\n```\n\n## Section navigation\nEach section builds its own sidebar from the pages that belong to it. By default, pages are grouped by `category` and sorted by `categoryOrder` and `order` from frontmatter.\n\nFor explicit control, use `navigation.json` with the object format to define per-section navigation:\n\n```json\n{\n \"\": [\n { \"label\": \"General\", \"links\": [{ \"slug\": \"\", \"title\": \"Getting Started\" }] }\n ],\n \"platform\": [\n { \"label\": \"API\", \"links\": [{ \"slug\": \"platform/auth\", \"title\": \"Auth\" }] }\n ]\n}\n```\n\nKeys are section slugs. The root section uses `\"\"`. Sections without a key fall back to auto-generated navigation. See the Navigation page for the full format.\n\n## How pages are assigned to sections\nDoccupine checks these rules in order and uses the first match:\n\n1. **Explicit directory** - the file is inside a directory listed in a section's `directory` field.\n2. **Directory matches slug** - the file's parent directory matches a section slug (e.g. files in `platform/` match a section with `slug: \"platform\"`).\n3. **Frontmatter section field** - the file's `section` value matches a section label.\n4. **No match** - the page stays at the root.\n\n## Precedence for section discovery\n1. **sections.json exists** - Doccupine uses it to define available sections.\n2. **No sections.json but pages have `section` frontmatter** - Doccupine auto-discovers sections from the frontmatter. Sections update live as you add or remove the `section` field from files.\n3. **Neither** - No section bar appears. The site works exactly as before.\n\n## URL structure\nPages in the default section (with `slug: \"\"`) serve at the root:\n\n- Default section: `/getting-started`, `/installation`\n- Other sections: `/api/authentication`, `/sdks/javascript`\n\n<Callout type=\"info\">\n When a file is in a directory that matches its section slug, the directory is stripped so it doesn't appear twice. For example, `platform/auth.mdx` in the \"Platform\" section serves at `/platform/auth`, not `/platform/platform/auth`.\n</Callout>\n\n## sections.json vs navigation.json\nThese two config files serve different purposes and complement each other:\n\n- **sections.json** defines which sections exist - their labels, slugs, directory mappings, and order in the tab bar.\n- **navigation.json** controls the sidebar within each section - page ordering and grouping.\n\nYou can use either one independently. `sections.json` without `navigation.json` gives you sections with auto-generated sidebars. `navigation.json` without `sections.json` gives you custom sidebar ordering with frontmatter-discovered sections (or no sections at all).\n\n## Tips\n- **Start simple**: Add `section` and `sectionOrder` to a few pages to try it out. No config files needed.\n- **Use directories**: Organize each section's files in a directory that matches the section slug for clean URLs and a tidy file tree.\n- **Rename the default tab**: Add `sectionLabel: \"Your Label\"` to your `index.mdx` frontmatter. Defaults to \"Docs\" if omitted.\n- **Switch to sections.json**: When you need custom slugs or directory mappings that don't match section names, `sections.json` gives full control.\n- **Per-section navigation**: Use the object format in `navigation.json` to define custom sidebar ordering for specific sections.\n- **Independent sidebars**: Each section has its own sidebar. Previous/next navigation stays within the active section.";
@@ -47,10 +47,10 @@ Where \`platform/index.mdx\` has:
47
47
 
48
48
  \`\`\`text
49
49
  ---
50
- title: "Platform"
50
+ title: "Platform Overview"
51
51
  section: "Platform"
52
52
  sectionOrder: 1
53
- category: "Overview"
53
+ category: "Getting Started"
54
54
  ---
55
55
  \`\`\`
56
56
 
@@ -1 +1 @@
1
- export declare const stepsMdxTemplate = "---\ntitle: \"Steps\"\ndescription: \"Guide readers step-by-step using the Steps component.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 13\n---\n# Steps\nGuide readers step-by-step using the Steps component.\n\nThe Steps component is perfect for organizing procedures or workflows in a clear sequence. Include as many individual steps as necessary to outline your process.\n\n## Steps Usage\nYou can use the `Steps` component to create a step-by-step guide. Each step is represented by a `Step` component, which includes a title and content.\n\n```mdx\n<Steps>\n <Step title=\"Step 1\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 2\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 3\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n</Steps>\n```\n\n<Steps>\n <Step title=\"Step 1\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 2\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 3\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n</Steps>\n\n## Properties\n\n<Field value=\"title\" type=\"string\" required>\n The title of the step.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the step.\n</Field>\n";
1
+ export declare const stepsMdxTemplate = "---\ntitle: \"Steps\"\ndescription: \"Guide readers step-by-step using the Steps component.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 13\n---\n# Steps\nGuide readers step-by-step using the Steps component.\n\nThe Steps component is perfect for organizing procedures or workflows in a clear sequence. Include as many individual steps as necessary to outline your process.\n\n## Steps Usage\nYou can use the `Steps` component to create a step-by-step guide. Each step is represented by a `Step` component, which includes a title and content.\n\n```mdx\n<Steps>\n <Step title=\"Step 1\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 2\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 3\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n</Steps>\n```\n\n<Steps>\n <Step title=\"Step 1\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 2\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n\n <Step title=\"Step 3\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n </Step>\n</Steps>\n\n## Properties\n\n<Field value=\"title\" type=\"string\" required>\n The title of the step.\n</Field>\n\n<Field value=\"icon\" type=\"string\">\n A [Lucide](https://lucide.dev/icons) icon name shown next to the step title.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the step.\n</Field>\n";
@@ -50,6 +50,10 @@ You can use the \`Steps\` component to create a step-by-step guide. Each step is
50
50
  The title of the step.
51
51
  </Field>
52
52
 
53
+ <Field value="icon" type="string">
54
+ A [Lucide](https://lucide.dev/icons) icon name shown next to the step title.
55
+ </Field>
56
+
53
57
  <Field value="children" type="node" required>
54
58
  The content of the step.
55
59
  </Field>
@@ -1 +1 @@
1
- export declare const tabsMdxTemplate = "---\ntitle: \"Tabs\"\ndescription: \"Use the Tabs component to display different content sections in a switchable panel layout.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 5\n---\n# Tabs\nUse the Tabs component to display different content sections in a switchable panel layout.\n\nTabs are useful for grouping related information while keeping the interface tidy. You can create as many tabs as needed, and each one can hold other components, text, or code snippets.\n\n## Tabs Usage\nYou can use the Tabs component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Tabs>\n <TabContent title=\"First tab\">\n \u261D\uFE0F This is the content shown only when the first tab is active.\n\n Tabs can include all kinds of components. For example, a simple Java program:\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n </TabContent>\n <TabContent title=\"Second tab\">\n \u270C\uFE0F Content inside this second tab is separate from the first.\n </TabContent>\n <TabContent title=\"Third tab\">\n \uD83D\uDCAA This third tab contains its own unique content.\n </TabContent>\n</Tabs>\n~~~\n\n<Tabs>\n <TabContent title=\"First tab\">\n \u261D\uFE0F This is the content shown only when the first tab is active.\n\n Tabs can include all kinds of components. For example, a simple Java program:\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n </TabContent>\n <TabContent title=\"Second tab\" icon=\"leaf\">\n \u270C\uFE0F Content inside this second tab is separate from the first.\n </TabContent>\n <TabContent title=\"Third tab\">\n \uD83D\uDCAA This third tab contains its own unique content.\n </TabContent>\n</Tabs>\n\n## Properties\n\n<Field value=\"title\" type=\"string\">\n The title of the tab.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the tabs.\n</Field>";
1
+ export declare const tabsMdxTemplate = "---\ntitle: \"Tabs\"\ndescription: \"Use the Tabs component to display different content sections in a switchable panel layout.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 5\n---\n# Tabs\nUse the Tabs component to display different content sections in a switchable panel layout.\n\nTabs are useful for grouping related information while keeping the interface tidy. You can create as many tabs as needed, and each one can hold other components, text, or code snippets.\n\n## Tabs Usage\nYou can use the Tabs component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Tabs>\n <TabContent title=\"First tab\">\n \u261D\uFE0F This is the content shown only when the first tab is active.\n\n Tabs can include all kinds of components. For example, a simple Java program:\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n </TabContent>\n <TabContent title=\"Second tab\">\n \u270C\uFE0F Content inside this second tab is separate from the first.\n </TabContent>\n <TabContent title=\"Third tab\">\n \uD83D\uDCAA This third tab contains its own unique content.\n </TabContent>\n</Tabs>\n~~~\n\n<Tabs>\n <TabContent title=\"First tab\">\n \u261D\uFE0F This is the content shown only when the first tab is active.\n\n Tabs can include all kinds of components. For example, a simple Java program:\n ```java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n </TabContent>\n <TabContent title=\"Second tab\">\n \u270C\uFE0F Content inside this second tab is separate from the first.\n </TabContent>\n <TabContent title=\"Third tab\">\n \uD83D\uDCAA This third tab contains its own unique content.\n </TabContent>\n</Tabs>\n\n## Properties\n\n<Field value=\"title\" type=\"string\">\n The title of the tab.\n</Field>\n\n<Field value=\"children\" type=\"node\" required>\n The content of the tabs.\n</Field>";
@@ -50,7 +50,7 @@ You can use the Tabs component directly within your MDX files without any import
50
50
  }
51
51
  \`\`\`
52
52
  </TabContent>
53
- <TabContent title="Second tab" icon="leaf">
53
+ <TabContent title="Second tab">
54
54
  ✌️ Content inside this second tab is separate from the first.
55
55
  </TabContent>
56
56
  <TabContent title="Third tab">
@@ -10,13 +10,13 @@ export const packageJsonTemplate = JSON.stringify({
10
10
  format: "prettier --write .",
11
11
  },
12
12
  dependencies: {
13
- "@langchain/anthropic": "^1.3.18",
14
- "@langchain/core": "^1.1.26",
15
- "@langchain/google-genai": "^2.1.19",
16
- "@langchain/openai": "^1.2.8",
13
+ "@langchain/anthropic": "^1.3.19",
14
+ "@langchain/core": "^1.1.27",
15
+ "@langchain/google-genai": "^2.1.20",
16
+ "@langchain/openai": "^1.2.9",
17
17
  "@mdx-js/react": "^3.1.1",
18
18
  "@modelcontextprotocol/sdk": "^1.26.0",
19
- "cherry-styled-components": "^0.1.12",
19
+ "cherry-styled-components": "^0.1.13",
20
20
  langchain: "^1.2.25",
21
21
  "lucide-react": "^0.575.0",
22
22
  next: "16.1.6",
@@ -1 +1 @@
1
- export declare const llmTypesTemplate = "export type LLMProvider = \"openai\" | \"anthropic\" | \"google\";\n\nexport interface LLMConfig {\n provider: LLMProvider;\n chatModel: string;\n embeddingModel: string;\n temperature: number;\n}\n\nexport interface ProviderModels {\n chat: string;\n embedding: string;\n}\n\nexport type ProviderDefaults = Record<LLMProvider, ProviderModels>;\n";
1
+ export declare const llmTypesTemplate = "export type LLMProvider = \"openai\" | \"anthropic\" | \"google\";\n\nexport interface LLMConfig {\n provider: LLMProvider;\n chatModel: string;\n embeddingModel: string;\n temperature: number;\n}\n\ninterface ProviderModels {\n chat: string;\n embedding: string;\n}\n\nexport type ProviderDefaults = Record<LLMProvider, ProviderModels>;\n";
@@ -7,7 +7,7 @@ export interface LLMConfig {
7
7
  temperature: number;
8
8
  }
9
9
 
10
- export interface ProviderModels {
10
+ interface ProviderModels {
11
11
  chat: string;
12
12
  embedding: string;
13
13
  }
@@ -1 +1 @@
1
- export declare const mcpServerTemplate = "import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport {\n listDocs,\n getDoc,\n getAllDocsChunks,\n DOCS_TOOLS,\n} from \"@/services/mcp/tools\";\nimport { getLLMConfig, createEmbeddings } from \"@/services/llm\";\nimport type { DocsChunk } from \"@/services/mcp/types\";\n\n/**\n * In-memory cache for document embeddings.\n * Built once at server startup since docs are static.\n */\nlet docsIndex: {\n ready: boolean;\n building: boolean;\n chunks: (DocsChunk & { embedding: number[] })[];\n} = {\n ready: false,\n building: false,\n chunks: [],\n};\n\n/** Resolves when the initial index build completes */\nlet indexReady: Promise<void> | null = null;\n\n/**\n * Cosine similarity between two vectors\n */\nfunction cosineSim(a: number[], b: number[]): number {\n let dot = 0,\n na = 0,\n nb = 0;\n for (let i = 0; i < a.length; i++) {\n const x = a[i];\n const y = b[i];\n dot += x * y;\n na += x * x;\n nb += y * y;\n }\n if (na === 0 || nb === 0) return 0;\n return dot / (Math.sqrt(na) * Math.sqrt(nb));\n}\n\n/**\n * Build or rebuild the documentation index\n */\nexport async function buildDocsIndex(force = false): Promise<void> {\n if (docsIndex.building) return;\n if (docsIndex.ready && !force) return;\n\n docsIndex.building = true;\n try {\n const chunks = await getAllDocsChunks();\n\n if (chunks.length === 0) {\n docsIndex.chunks = [];\n docsIndex.ready = true;\n return;\n }\n\n const config = getLLMConfig();\n const embeddings = createEmbeddings(config);\n\n // Process embeddings in small batches to avoid exceeding token limits\n const BATCH_SIZE = 10;\n const texts = chunks.map((c) => c.text);\n const vectors: number[][] = [];\n\n for (let i = 0; i < texts.length; i += BATCH_SIZE) {\n const batch = texts.slice(i, i + BATCH_SIZE);\n const batchVectors = await embeddings.embedDocuments(batch);\n vectors.push(...batchVectors);\n }\n\n docsIndex.chunks = chunks.map((c, i) => ({\n ...c,\n embedding: vectors[i],\n }));\n docsIndex.ready = true;\n } catch (error) {\n // Reset so the next call to ensureDocsIndex retries\n indexReady = null;\n throw error;\n } finally {\n docsIndex.building = false;\n }\n}\n\n/**\n * Ensure the docs index is ready.\n * On first call, triggers the build; subsequent calls wait for the same promise.\n */\nexport async function ensureDocsIndex(force = false): Promise<void> {\n if (force) {\n // Wait for any in-flight build before starting a forced rebuild\n if (docsIndex.building && indexReady) {\n await indexReady.catch(() => {});\n }\n docsIndex.ready = false;\n docsIndex.chunks = [];\n indexReady = buildDocsIndex(true);\n return indexReady;\n }\n if (!indexReady) {\n indexReady = buildDocsIndex();\n }\n return indexReady;\n}\n\n// Eagerly start building the index on server startup (docs are static)\nindexReady = buildDocsIndex();\n\n/** Cached embeddings instance for search queries */\nlet cachedEmbeddings: ReturnType<typeof createEmbeddings> | null = null;\n\nfunction getEmbeddings() {\n if (!cachedEmbeddings) {\n cachedEmbeddings = createEmbeddings(getLLMConfig());\n }\n return cachedEmbeddings;\n}\n\n/**\n * Search documents using semantic similarity\n */\nexport async function searchDocs(\n query: string,\n limit = 6,\n): Promise<{ chunk: DocsChunk; score: number }[]> {\n await ensureDocsIndex();\n\n const queryVector = await getEmbeddings().embedQuery(query);\n\n const scored = docsIndex.chunks\n .map((c) => ({\n chunk: { id: c.id, text: c.text, path: c.path, uri: c.uri },\n score: cosineSim(queryVector, c.embedding),\n }))\n .sort((a, b) => b.score - a.score)\n .slice(0, limit);\n\n return scored;\n}\n\n/**\n * Get the current index status\n */\nexport function getIndexStatus(): { ready: boolean; chunkCount: number } {\n return {\n ready: docsIndex.ready,\n chunkCount: docsIndex.chunks.length,\n };\n}\n\n/**\n * Create and configure the MCP server with documentation tools\n */\nexport function createMCPServer(): McpServer {\n const server = new McpServer({\n name: \"docs-server\",\n version: \"1.0.0\",\n });\n\n // Register the search_docs tool\n server.tool(\n \"search_docs\",\n DOCS_TOOLS[0].description,\n {\n query: z\n .string()\n .describe(\"The search query to find relevant documentation\"),\n limit: z\n .number()\n .optional()\n .describe(\"Maximum number of results to return (default: 6)\"),\n },\n async ({ query, limit }) => {\n const results = await searchDocs(query, limit ?? 6);\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(\n results.map(({ chunk, score }) => ({\n path: chunk.path,\n uri: chunk.uri,\n score: score.toFixed(3),\n text: chunk.text,\n })),\n null,\n 2,\n ),\n },\n ],\n };\n },\n );\n\n // Register the get_doc tool\n server.tool(\n \"get_doc\",\n DOCS_TOOLS[1].description,\n {\n path: z.string().describe(\"The file path to the documentation page\"),\n },\n async ({ path }) => {\n const doc = await getDoc({ path });\n if (!doc) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify({ error: \"Document not found\" }),\n },\n ],\n isError: true,\n };\n }\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(doc, null, 2),\n },\n ],\n };\n },\n );\n\n // Register the list_docs tool\n server.tool(\n \"list_docs\",\n DOCS_TOOLS[2].description,\n {\n directory: z\n .string()\n .optional()\n .describe(\"Optional directory to filter results\"),\n },\n async ({ directory }) => {\n const docs = await listDocs({ directory });\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(\n docs.map((d) => ({\n name: d.name,\n path: d.path,\n uri: d.uri,\n })),\n null,\n 2,\n ),\n },\n ],\n };\n },\n );\n\n // Register documentation as resources\n server.resource(\"docs://list\", \"docs://list\", async () => {\n const docs = await listDocs();\n return {\n contents: [\n {\n uri: \"docs://list\",\n text: JSON.stringify(\n docs.map((d) => ({ name: d.name, path: d.path, uri: d.uri })),\n null,\n 2,\n ),\n },\n ],\n };\n });\n\n return server;\n}\n";
1
+ export declare const mcpServerTemplate = "import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport {\n listDocs,\n getDoc,\n getAllDocsChunks,\n DOCS_TOOLS,\n} from \"@/services/mcp/tools\";\nimport { getLLMConfig, createEmbeddings } from \"@/services/llm\";\nimport type { DocsChunk } from \"@/services/mcp/types\";\n\n/**\n * In-memory cache for document embeddings.\n * Built once at server startup since docs are static.\n */\nlet docsIndex: {\n ready: boolean;\n building: boolean;\n chunks: (DocsChunk & { embedding: number[] })[];\n} = {\n ready: false,\n building: false,\n chunks: [],\n};\n\n/** Resolves when the initial index build completes */\nlet indexReady: Promise<void> | null = null;\n\n/**\n * Cosine similarity between two vectors\n */\nfunction cosineSim(a: number[], b: number[]): number {\n let dot = 0,\n na = 0,\n nb = 0;\n for (let i = 0; i < a.length; i++) {\n const x = a[i];\n const y = b[i];\n dot += x * y;\n na += x * x;\n nb += y * y;\n }\n if (na === 0 || nb === 0) return 0;\n return dot / (Math.sqrt(na) * Math.sqrt(nb));\n}\n\n/**\n * Build or rebuild the documentation index\n */\nasync function buildDocsIndex(force = false): Promise<void> {\n if (docsIndex.building) return;\n if (docsIndex.ready && !force) return;\n\n docsIndex.building = true;\n try {\n const chunks = await getAllDocsChunks();\n\n if (chunks.length === 0) {\n docsIndex.chunks = [];\n docsIndex.ready = true;\n return;\n }\n\n const config = getLLMConfig();\n const embeddings = createEmbeddings(config);\n\n // Process embeddings in small batches to avoid exceeding token limits\n const BATCH_SIZE = 10;\n const texts = chunks.map((c) => c.text);\n const vectors: number[][] = [];\n\n for (let i = 0; i < texts.length; i += BATCH_SIZE) {\n const batch = texts.slice(i, i + BATCH_SIZE);\n const batchVectors = await embeddings.embedDocuments(batch);\n vectors.push(...batchVectors);\n }\n\n docsIndex.chunks = chunks.map((c, i) => ({\n ...c,\n embedding: vectors[i],\n }));\n docsIndex.ready = true;\n } catch (error) {\n // Reset so the next call to ensureDocsIndex retries\n indexReady = null;\n throw error;\n } finally {\n docsIndex.building = false;\n }\n}\n\n/**\n * Ensure the docs index is ready.\n * On first call, triggers the build; subsequent calls wait for the same promise.\n */\nexport async function ensureDocsIndex(force = false): Promise<void> {\n if (force) {\n // Wait for any in-flight build before starting a forced rebuild\n if (docsIndex.building && indexReady) {\n await indexReady.catch(() => {});\n }\n docsIndex.ready = false;\n docsIndex.chunks = [];\n indexReady = buildDocsIndex(true);\n return indexReady;\n }\n if (!indexReady) {\n indexReady = buildDocsIndex();\n }\n return indexReady;\n}\n\n// Eagerly start building the index on server startup (docs are static)\nindexReady = buildDocsIndex();\n\n/** Cached embeddings instance for search queries */\nlet cachedEmbeddings: ReturnType<typeof createEmbeddings> | null = null;\n\nfunction getEmbeddings() {\n if (!cachedEmbeddings) {\n cachedEmbeddings = createEmbeddings(getLLMConfig());\n }\n return cachedEmbeddings;\n}\n\n/**\n * Search documents using semantic similarity\n */\nexport async function searchDocs(\n query: string,\n limit = 6,\n): Promise<{ chunk: DocsChunk; score: number }[]> {\n await ensureDocsIndex();\n\n const queryVector = await getEmbeddings().embedQuery(query);\n\n const scored = docsIndex.chunks\n .map((c) => ({\n chunk: { id: c.id, text: c.text, path: c.path, uri: c.uri },\n score: cosineSim(queryVector, c.embedding),\n }))\n .sort((a, b) => b.score - a.score)\n .slice(0, limit);\n\n return scored;\n}\n\n/**\n * Get the current index status\n */\nexport function getIndexStatus(): { ready: boolean; chunkCount: number } {\n return {\n ready: docsIndex.ready,\n chunkCount: docsIndex.chunks.length,\n };\n}\n\n/**\n * Create and configure the MCP server with documentation tools\n */\nexport function createMCPServer(): McpServer {\n const server = new McpServer({\n name: \"docs-server\",\n version: \"1.0.0\",\n });\n\n // Register the search_docs tool\n server.tool(\n \"search_docs\",\n DOCS_TOOLS[0].description,\n {\n query: z\n .string()\n .describe(\"The search query to find relevant documentation\"),\n limit: z\n .number()\n .optional()\n .describe(\"Maximum number of results to return (default: 6)\"),\n },\n async ({ query, limit }) => {\n const results = await searchDocs(query, limit ?? 6);\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(\n results.map(({ chunk, score }) => ({\n path: chunk.path,\n uri: chunk.uri,\n score: score.toFixed(3),\n text: chunk.text,\n })),\n null,\n 2,\n ),\n },\n ],\n };\n },\n );\n\n // Register the get_doc tool\n server.tool(\n \"get_doc\",\n DOCS_TOOLS[1].description,\n {\n path: z.string().describe(\"The file path to the documentation page\"),\n },\n async ({ path }) => {\n const doc = await getDoc({ path });\n if (!doc) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify({ error: \"Document not found\" }),\n },\n ],\n isError: true,\n };\n }\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(doc, null, 2),\n },\n ],\n };\n },\n );\n\n // Register the list_docs tool\n server.tool(\n \"list_docs\",\n DOCS_TOOLS[2].description,\n {\n directory: z\n .string()\n .optional()\n .describe(\"Optional directory to filter results\"),\n },\n async ({ directory }) => {\n const docs = await listDocs({ directory });\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(\n docs.map((d) => ({\n name: d.name,\n path: d.path,\n uri: d.uri,\n })),\n null,\n 2,\n ),\n },\n ],\n };\n },\n );\n\n // Register documentation as resources\n server.resource(\"docs://list\", \"docs://list\", async () => {\n const docs = await listDocs();\n return {\n contents: [\n {\n uri: \"docs://list\",\n text: JSON.stringify(\n docs.map((d) => ({ name: d.name, path: d.path, uri: d.uri })),\n null,\n 2,\n ),\n },\n ],\n };\n });\n\n return server;\n}\n";
@@ -47,7 +47,7 @@ function cosineSim(a: number[], b: number[]): number {
47
47
  /**
48
48
  * Build or rebuild the documentation index
49
49
  */
50
- export async function buildDocsIndex(force = false): Promise<void> {
50
+ async function buildDocsIndex(force = false): Promise<void> {
51
51
  if (docsIndex.building) return;
52
52
  if (docsIndex.ready && !force) return;
53
53
 
@@ -1 +1 @@
1
- export declare const mcpToolsTemplate = "import path from \"node:path\";\nimport fs from \"node:fs/promises\";\nimport type {\n MCPToolDefinition,\n DocsResource,\n DocsChunk,\n GetDocParams,\n ListDocsParams,\n} from \"@/services/mcp/types\";\n\nconst PROJECT_ROOT = process.cwd();\nconst APP_DIR = path.join(PROJECT_ROOT, \"app\");\nconst VALID_EXT = new Set([\".ts\", \".tsx\", \".js\", \".jsx\"]);\n\n/**\n * Tool definitions for MCP - these describe the available tools\n */\nexport const DOCS_TOOLS: MCPToolDefinition[] = [\n {\n name: \"search_docs\",\n description:\n \"Search through the documentation content using semantic search. Returns relevant chunks of documentation based on the query.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"The search query to find relevant documentation\",\n },\n limit: {\n type: \"number\",\n description: \"Maximum number of results to return (default: 6)\",\n },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"get_doc\",\n description:\n \"Get the full content of a specific documentation page by its path.\",\n inputSchema: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"The file path to the documentation page (e.g., 'app/getting-started/page.tsx')\",\n },\n },\n required: [\"path\"],\n },\n },\n {\n name: \"list_docs\",\n description:\n \"List all available documentation pages, optionally filtered by directory.\",\n inputSchema: {\n type: \"object\",\n properties: {\n directory: {\n type: \"string\",\n description:\n \"Optional directory to filter results (e.g., 'components')\",\n },\n },\n },\n },\n];\n\n/**\n * Recursively walk directory to find documentation files\n */\nasync function* walkDocs(dir: string): AsyncGenerator<string> {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if ([\"node_modules\", \".next\", \".git\", \"api\"].includes(entry.name)) {\n continue;\n }\n yield* walkDocs(fullPath);\n } else {\n const ext = path.extname(entry.name).toLowerCase();\n if (VALID_EXT.has(ext) && entry.name.startsWith(\"page.\")) {\n yield fullPath;\n }\n }\n }\n}\n\n/**\n * Extract content blocks from a file\n */\nfunction extractContentBlocks(fileText: string): string[] {\n const results: string[] = [];\n\n const tplRegex = /(?:export\\s+)?const\\s+content\\s*=\\s*`((?:\\\\`|[^`])*)`\\s*;/g;\n let m: RegExpExecArray | null;\n while ((m = tplRegex.exec(fileText)) !== null) {\n results.push(m[1]);\n }\n\n const sglRegex = /(?:export\\s+)?const\\s+content\\s*=\\s*'([^']*)'\\s*;/g;\n while ((m = sglRegex.exec(fileText)) !== null) {\n results.push(m[1]);\n }\n\n const dblRegex = /(?:export\\s+)?const\\s+content\\s*=\\s*\"([^\"]*)\"\\s*;/g;\n while ((m = dblRegex.exec(fileText)) !== null) {\n results.push(m[1]);\n }\n\n return results;\n}\n\n/**\n * Get the title from markdown content\n */\nfunction extractTitle(content: string): string {\n const match = content.match(/^#\\s+(.+)$/m);\n return match ? match[1].trim() : \"Untitled\";\n}\n\n/**\n * List all documentation resources\n */\nexport async function listDocs(\n params?: ListDocsParams,\n): Promise<DocsResource[]> {\n const resources: DocsResource[] = [];\n const filterDir = params?.directory;\n\n for await (const filePath of walkDocs(APP_DIR)) {\n const relativePath = path.relative(PROJECT_ROOT, filePath);\n\n if (filterDir && !relativePath.includes(filterDir)) {\n continue;\n }\n\n try {\n const fileContent = await fs.readFile(filePath, \"utf8\");\n const blocks = extractContentBlocks(fileContent);\n const content = blocks.join(\"\\n\\n\");\n const title = extractTitle(content);\n const docPath = path.dirname(relativePath).replace(/^app\\/?/, \"\") || \"/\";\n\n resources.push({\n uri: `docs://${docPath}`,\n name: title,\n path: relativePath,\n content,\n });\n } catch (error) {\n console.warn(`Failed to read doc file: ${filePath}`, error);\n }\n }\n\n return resources;\n}\n\n/**\n * Get a specific documentation page\n */\nexport async function getDoc(\n params: GetDocParams,\n): Promise<DocsResource | null> {\n let targetPath = params.path;\n\n // Normalize path\n if (!targetPath.startsWith(\"app/\")) {\n targetPath = `app/${targetPath}`;\n }\n if (!targetPath.includes(\"page.\")) {\n targetPath = path.join(targetPath, \"page.tsx\");\n }\n\n const fullPath = path.join(PROJECT_ROOT, targetPath);\n\n // Prevent path traversal\n const resolvedPath = path.resolve(fullPath);\n if (!resolvedPath.startsWith(path.resolve(APP_DIR))) {\n return null;\n }\n\n try {\n const fileContent = await fs.readFile(fullPath, \"utf8\");\n const blocks = extractContentBlocks(fileContent);\n const content = blocks.join(\"\\n\\n\");\n const title = extractTitle(content);\n const docPath = path.dirname(targetPath).replace(/^app\\/?/, \"\") || \"/\";\n\n return {\n uri: `docs://${docPath}`,\n name: title,\n path: targetPath,\n content,\n };\n } catch (error) {\n console.warn(`Failed to read doc: ${targetPath}`, error);\n return null;\n }\n}\n\n/**\n * Chunk text for embeddings.\n * - chunkSize=800 chars balances granularity with embedding context window limits\n * - overlap=100 chars ensures continuity so searches don't miss content at chunk boundaries\n */\nexport function chunkText(\n text: string,\n chunkSize = 800,\n overlap = 100,\n): string[] {\n const chunks: string[] = [];\n let i = 0;\n while (i < text.length) {\n const end = Math.min(i + chunkSize, text.length);\n chunks.push(text.slice(i, end));\n if (end === text.length) break;\n i = end - overlap;\n if (i < 0) i = 0;\n }\n return chunks;\n}\n\n/**\n * Get all documentation chunks for indexing\n */\nexport async function getAllDocsChunks(): Promise<DocsChunk[]> {\n const allChunks: DocsChunk[] = [];\n const docs = await listDocs();\n\n for (const doc of docs) {\n const cleanContent = doc.content\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .slice(0, 200_000);\n\n const textChunks = chunkText(cleanContent);\n for (let i = 0; i < textChunks.length; i++) {\n allChunks.push({\n id: `${doc.path}:${i}`,\n text: textChunks[i],\n path: doc.path,\n uri: doc.uri,\n });\n }\n }\n\n return allChunks;\n}\n";
1
+ export declare const mcpToolsTemplate = "import path from \"node:path\";\nimport fs from \"node:fs/promises\";\nimport type {\n MCPToolDefinition,\n DocsResource,\n DocsChunk,\n GetDocParams,\n ListDocsParams,\n} from \"@/services/mcp/types\";\n\nconst PROJECT_ROOT = process.cwd();\nconst APP_DIR = path.join(PROJECT_ROOT, \"app\");\nconst VALID_EXT = new Set([\".ts\", \".tsx\", \".js\", \".jsx\"]);\n\n/**\n * Tool definitions for MCP - these describe the available tools\n */\nexport const DOCS_TOOLS: MCPToolDefinition[] = [\n {\n name: \"search_docs\",\n description:\n \"Search through the documentation content using semantic search. Returns relevant chunks of documentation based on the query.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"The search query to find relevant documentation\",\n },\n limit: {\n type: \"number\",\n description: \"Maximum number of results to return (default: 6)\",\n },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"get_doc\",\n description:\n \"Get the full content of a specific documentation page by its path.\",\n inputSchema: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"The file path to the documentation page (e.g., 'app/getting-started/page.tsx')\",\n },\n },\n required: [\"path\"],\n },\n },\n {\n name: \"list_docs\",\n description:\n \"List all available documentation pages, optionally filtered by directory.\",\n inputSchema: {\n type: \"object\",\n properties: {\n directory: {\n type: \"string\",\n description:\n \"Optional directory to filter results (e.g., 'components')\",\n },\n },\n },\n },\n];\n\n/**\n * Recursively walk directory to find documentation files\n */\nasync function* walkDocs(dir: string): AsyncGenerator<string> {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if ([\"node_modules\", \".next\", \".git\", \"api\"].includes(entry.name)) {\n continue;\n }\n yield* walkDocs(fullPath);\n } else {\n const ext = path.extname(entry.name).toLowerCase();\n if (VALID_EXT.has(ext) && entry.name.startsWith(\"page.\")) {\n yield fullPath;\n }\n }\n }\n}\n\n/**\n * Extract content blocks from a file\n */\nfunction extractContentBlocks(fileText: string): string[] {\n const results: string[] = [];\n\n const tplRegex = /(?:export\\s+)?const\\s+content\\s*=\\s*`((?:\\\\`|[^`])*)`\\s*;/g;\n let m: RegExpExecArray | null;\n while ((m = tplRegex.exec(fileText)) !== null) {\n results.push(m[1]);\n }\n\n const sglRegex = /(?:export\\s+)?const\\s+content\\s*=\\s*'([^']*)'\\s*;/g;\n while ((m = sglRegex.exec(fileText)) !== null) {\n results.push(m[1]);\n }\n\n const dblRegex = /(?:export\\s+)?const\\s+content\\s*=\\s*\"([^\"]*)\"\\s*;/g;\n while ((m = dblRegex.exec(fileText)) !== null) {\n results.push(m[1]);\n }\n\n return results;\n}\n\n/**\n * Get the title from markdown content\n */\nfunction extractTitle(content: string): string {\n const match = content.match(/^#\\s+(.+)$/m);\n return match ? match[1].trim() : \"Untitled\";\n}\n\n/**\n * List all documentation resources\n */\nexport async function listDocs(\n params?: ListDocsParams,\n): Promise<DocsResource[]> {\n const resources: DocsResource[] = [];\n const filterDir = params?.directory;\n\n for await (const filePath of walkDocs(APP_DIR)) {\n const relativePath = path.relative(PROJECT_ROOT, filePath);\n\n if (filterDir && !relativePath.includes(filterDir)) {\n continue;\n }\n\n try {\n const fileContent = await fs.readFile(filePath, \"utf8\");\n const blocks = extractContentBlocks(fileContent);\n const content = blocks.join(\"\\n\\n\");\n const title = extractTitle(content);\n const docPath = path.dirname(relativePath).replace(/^app\\/?/, \"\") || \"/\";\n\n resources.push({\n uri: `docs://${docPath}`,\n name: title,\n path: relativePath,\n content,\n });\n } catch (error) {\n console.warn(`Failed to read doc file: ${filePath}`, error);\n }\n }\n\n return resources;\n}\n\n/**\n * Get a specific documentation page\n */\nexport async function getDoc(\n params: GetDocParams,\n): Promise<DocsResource | null> {\n let targetPath = params.path;\n\n // Normalize path\n if (!targetPath.startsWith(\"app/\")) {\n targetPath = `app/${targetPath}`;\n }\n if (!targetPath.includes(\"page.\")) {\n targetPath = path.join(targetPath, \"page.tsx\");\n }\n\n const fullPath = path.join(PROJECT_ROOT, targetPath);\n\n // Prevent path traversal\n const resolvedPath = path.resolve(fullPath);\n if (!resolvedPath.startsWith(path.resolve(APP_DIR))) {\n return null;\n }\n\n try {\n const fileContent = await fs.readFile(fullPath, \"utf8\");\n const blocks = extractContentBlocks(fileContent);\n const content = blocks.join(\"\\n\\n\");\n const title = extractTitle(content);\n const docPath = path.dirname(targetPath).replace(/^app\\/?/, \"\") || \"/\";\n\n return {\n uri: `docs://${docPath}`,\n name: title,\n path: targetPath,\n content,\n };\n } catch (error) {\n console.warn(`Failed to read doc: ${targetPath}`, error);\n return null;\n }\n}\n\n/**\n * Chunk text for embeddings.\n * - chunkSize=800 chars balances granularity with embedding context window limits\n * - overlap=100 chars ensures continuity so searches don't miss content at chunk boundaries\n */\nfunction chunkText(text: string, chunkSize = 800, overlap = 100): string[] {\n const chunks: string[] = [];\n let i = 0;\n while (i < text.length) {\n const end = Math.min(i + chunkSize, text.length);\n chunks.push(text.slice(i, end));\n if (end === text.length) break;\n i = end - overlap;\n if (i < 0) i = 0;\n }\n return chunks;\n}\n\n/**\n * Get all documentation chunks for indexing\n */\nexport async function getAllDocsChunks(): Promise<DocsChunk[]> {\n const allChunks: DocsChunk[] = [];\n const docs = await listDocs();\n\n for (const doc of docs) {\n const cleanContent = doc.content\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .slice(0, 200_000);\n\n const textChunks = chunkText(cleanContent);\n for (let i = 0; i < textChunks.length; i++) {\n allChunks.push({\n id: `${doc.path}:${i}`,\n text: textChunks[i],\n path: doc.path,\n uri: doc.uri,\n });\n }\n }\n\n return allChunks;\n}\n";
@@ -207,11 +207,7 @@ export async function getDoc(
207
207
  * - chunkSize=800 chars balances granularity with embedding context window limits
208
208
  * - overlap=100 chars ensures continuity so searches don't miss content at chunk boundaries
209
209
  */
210
- export function chunkText(
211
- text: string,
212
- chunkSize = 800,
213
- overlap = 100,
214
- ): string[] {
210
+ function chunkText(text: string, chunkSize = 800, overlap = 100): string[] {
215
211
  const chunks: string[] = [];
216
212
  let i = 0;
217
213
  while (i < text.length) {
@@ -1 +1 @@
1
- export declare const configTemplate = "import { z } from \"zod\";\nimport configData from \"@/config.json\";\n\nconst configSchema = z.object({\n name: z.string().optional(),\n description: z.string().optional(),\n icon: z.string().optional(),\n image: z.string().optional(),\n});\n\nexport type Config = z.infer<typeof configSchema>;\n\nexport const config: Config = configSchema.parse(configData);\n";
1
+ export declare const configTemplate = "import { z } from \"zod\";\nimport configData from \"@/config.json\";\n\nconst configSchema = z.object({\n name: z.string().optional(),\n description: z.string().optional(),\n icon: z.string().optional(),\n image: z.string().optional(),\n});\n\ntype Config = z.infer<typeof configSchema>;\n\nexport const config: Config = configSchema.parse(configData);\n";
@@ -8,7 +8,7 @@ const configSchema = z.object({
8
8
  image: z.string().optional(),
9
9
  });
10
10
 
11
- export type Config = z.infer<typeof configSchema>;
11
+ type Config = z.infer<typeof configSchema>;
12
12
 
13
13
  export const config: Config = configSchema.parse(configData);
14
14
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doccupine",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {