doccupine 0.0.140 → 0.0.142

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 (145) hide show
  1. package/README.md +14 -7
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +191 -0
  4. package/dist/index.d.ts +3 -7
  5. package/dist/index.js +5 -1894
  6. package/dist/lib/config-manager.d.ts +1 -0
  7. package/dist/lib/config-manager.js +63 -3
  8. package/dist/lib/generated-artifacts.d.ts +26 -0
  9. package/dist/lib/generated-artifacts.js +147 -0
  10. package/dist/lib/layout.js +30 -30
  11. package/dist/lib/metadata.js +58 -30
  12. package/dist/lib/openapi-types.d.ts +2 -2
  13. package/dist/lib/openapi.d.ts +6 -3
  14. package/dist/lib/openapi.js +330 -50
  15. package/dist/lib/output-safety.d.ts +15 -0
  16. package/dist/lib/output-safety.js +428 -0
  17. package/dist/lib/structures.js +11 -0
  18. package/dist/lib/utils.d.ts +10 -5
  19. package/dist/lib/utils.js +108 -5
  20. package/dist/mdx-to-nextjs-generator.d.ts +166 -0
  21. package/dist/mdx-to-nextjs-generator.js +2229 -0
  22. package/dist/templates/app/api/gate/route.d.ts +1 -1
  23. package/dist/templates/app/api/gate/route.js +18 -6
  24. package/dist/templates/app/api/mcp/route.d.ts +1 -1
  25. package/dist/templates/app/api/mcp/route.js +181 -111
  26. package/dist/templates/app/api/playground/route.d.ts +1 -1
  27. package/dist/templates/app/api/playground/route.js +45 -13
  28. package/dist/templates/app/api/rag/route.d.ts +1 -1
  29. package/dist/templates/app/api/rag/route.js +72 -20
  30. package/dist/templates/app/api/search/route.d.ts +1 -1
  31. package/dist/templates/app/api/search/route.js +5 -0
  32. package/dist/templates/app/robots.d.ts +1 -1
  33. package/dist/templates/app/robots.js +1 -26
  34. package/dist/templates/app/theme.d.ts +1 -1
  35. package/dist/templates/app/theme.js +31 -19
  36. package/dist/templates/components/Chat.d.ts +1 -1
  37. package/dist/templates/components/Chat.js +342 -34
  38. package/dist/templates/components/SearchDocs.d.ts +1 -1
  39. package/dist/templates/components/SearchDocs.js +63 -11
  40. package/dist/templates/components/SearchModalContent.d.ts +1 -1
  41. package/dist/templates/components/SearchModalContent.js +191 -49
  42. package/dist/templates/components/SideBar.d.ts +1 -1
  43. package/dist/templates/components/SideBar.js +8 -2
  44. package/dist/templates/components/layout/Accordion.d.ts +1 -1
  45. package/dist/templates/components/layout/Accordion.js +26 -3
  46. package/dist/templates/components/layout/Badge.d.ts +1 -1
  47. package/dist/templates/components/layout/Badge.js +1 -1
  48. package/dist/templates/components/layout/Button.d.ts +1 -1
  49. package/dist/templates/components/layout/Button.js +4 -4
  50. package/dist/templates/components/layout/Callout.d.ts +1 -1
  51. package/dist/templates/components/layout/Callout.js +6 -6
  52. package/dist/templates/components/layout/Card.d.ts +1 -1
  53. package/dist/templates/components/layout/Card.js +9 -4
  54. package/dist/templates/components/layout/CherryThemeProvider.d.ts +1 -1
  55. package/dist/templates/components/layout/CherryThemeProvider.js +63 -12
  56. package/dist/templates/components/layout/Code.d.ts +1 -1
  57. package/dist/templates/components/layout/Code.js +5 -5
  58. package/dist/templates/components/layout/CopyButton.d.ts +1 -1
  59. package/dist/templates/components/layout/CopyButton.js +1 -1
  60. package/dist/templates/components/layout/DemoTheme.d.ts +1 -1
  61. package/dist/templates/components/layout/DemoTheme.js +8 -28
  62. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  63. package/dist/templates/components/layout/DocsComponents.js +57 -6
  64. package/dist/templates/components/layout/GlobalStyles.d.ts +1 -1
  65. package/dist/templates/components/layout/GlobalStyles.js +15 -9
  66. package/dist/templates/components/layout/Prompt.d.ts +1 -1
  67. package/dist/templates/components/layout/Prompt.js +4 -7
  68. package/dist/templates/components/layout/Steps.d.ts +1 -1
  69. package/dist/templates/components/layout/Steps.js +7 -1
  70. package/dist/templates/components/layout/Tabs.d.ts +1 -1
  71. package/dist/templates/components/layout/Tabs.js +108 -19
  72. package/dist/templates/env.example.d.ts +1 -1
  73. package/dist/templates/env.example.js +11 -0
  74. package/dist/templates/eslint.config.d.ts +1 -1
  75. package/dist/templates/eslint.config.js +20 -0
  76. package/dist/templates/gitignore.d.ts +1 -1
  77. package/dist/templates/gitignore.js +4 -3
  78. package/dist/templates/lib/access.d.ts +1 -0
  79. package/dist/templates/lib/access.js +41 -0
  80. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  81. package/dist/templates/mdx/ai-assistant.mdx.js +17 -1
  82. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  83. package/dist/templates/mdx/api-playground.mdx.js +5 -3
  84. package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
  85. package/dist/templates/mdx/authentication.mdx.js +5 -3
  86. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  87. package/dist/templates/mdx/commands.mdx.js +20 -6
  88. package/dist/templates/mdx/components.mdx.d.ts +1 -1
  89. package/dist/templates/mdx/components.mdx.js +3 -0
  90. package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
  91. package/dist/templates/mdx/deployment-and-hosting.mdx.js +2 -2
  92. package/dist/templates/mdx/globals.mdx.d.ts +1 -1
  93. package/dist/templates/mdx/globals.mdx.js +14 -11
  94. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  95. package/dist/templates/mdx/model-context-protocol.mdx.js +22 -35
  96. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  97. package/dist/templates/mdx/platform/ai-assistant.mdx.js +23 -0
  98. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
  99. package/dist/templates/mdx/platform/api-playground.mdx.js +7 -0
  100. package/dist/templates/mdx/platform/authentication.mdx.d.ts +1 -0
  101. package/dist/templates/mdx/platform/authentication.mdx.js +63 -0
  102. package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -1
  103. package/dist/templates/mdx/platform/import-from-github.mdx.js +2 -2
  104. package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
  105. package/dist/templates/mdx/platform/index.mdx.js +1 -0
  106. package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
  107. package/dist/templates/mdx/platform/mcp.mdx.js +2 -1
  108. package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
  109. package/dist/templates/mdx/platform/navigation-settings.mdx.js +12 -1
  110. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  111. package/dist/templates/mdx/platform/publishing.mdx.js +43 -10
  112. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
  113. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +48 -9
  114. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  115. package/dist/templates/mdx/sections.mdx.js +4 -0
  116. package/dist/templates/mdx/space.mdx.d.ts +1 -0
  117. package/dist/templates/mdx/space.mdx.js +125 -0
  118. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  119. package/dist/templates/mdx/tabs.mdx.js +4 -0
  120. package/dist/templates/next.config.js +20 -8
  121. package/dist/templates/package.js +3 -3
  122. package/dist/templates/prettierignore.d.ts +1 -1
  123. package/dist/templates/prettierignore.js +1 -0
  124. package/dist/templates/proxy.js +47 -19
  125. package/dist/templates/scripts/build-docs-index.d.ts +1 -1
  126. package/dist/templates/scripts/build-docs-index.js +1 -0
  127. package/dist/templates/services/mcp/docsContentStub.d.ts +1 -0
  128. package/dist/templates/services/mcp/docsContentStub.js +1 -0
  129. package/dist/templates/services/mcp/server.d.ts +1 -1
  130. package/dist/templates/services/mcp/server.js +140 -83
  131. package/dist/templates/services/mcp/tools.d.ts +1 -1
  132. package/dist/templates/services/mcp/tools.js +65 -137
  133. package/dist/templates/utils/playgroundAllowlist.d.ts +1 -1
  134. package/dist/templates/utils/playgroundAllowlist.js +13 -4
  135. package/dist/templates/utils/rateLimit.d.ts +1 -1
  136. package/dist/templates/utils/rateLimit.js +40 -3
  137. package/dist/templates/utils/requestBody.d.ts +1 -0
  138. package/dist/templates/utils/requestBody.js +56 -0
  139. package/dist/templates/utils/ssrfGuard.d.ts +1 -1
  140. package/dist/templates/utils/ssrfGuard.js +138 -33
  141. package/package.json +13 -5
  142. package/dist/lib/mdxToMarkdown.d.ts +0 -1
  143. package/dist/lib/mdxToMarkdown.js +0 -134
  144. package/dist/templates/mdx/image-and-embeds.mdx.d.ts +0 -1
  145. package/dist/templates/mdx/image-and-embeds.mdx.js +0 -118
@@ -1,22 +1,26 @@
1
1
  export const tabsTemplate = `"use client";
2
2
  import { Theme } from "@/app/theme";
3
- import { styledText } from "cherry-styled-components";
4
- import React, { useState, ReactNode } from "react";
3
+ import { Button, resetButton, styledText } from "cherry-styled-components";
4
+ import React, { ReactNode, useId, useRef, useState } from "react";
5
5
  import styled, { css } from "styled-components";
6
6
  import { thinScrollbar } from "@/components/layout/SharedStyled";
7
7
  import { Icon } from "@/components/layout/Icon";
8
+
8
9
  interface TabContentProps {
9
10
  title: string;
10
11
  icon?: string;
11
12
  children: ReactNode;
12
13
  }
14
+
13
15
  interface TabsProps {
14
16
  children: React.ReactElement<TabContentProps>[];
15
17
  }
18
+
16
19
  const TabsContainer = styled.div\`
17
20
  width: 100%;
18
21
  margin: 0 auto;
19
22
  \`;
23
+
20
24
  const TabsList = styled.div<{ theme: Theme }>\`
21
25
  display: flex;
22
26
  overflow: hidden;
@@ -28,7 +32,10 @@ const TabsList = styled.div<{ theme: Theme }>\`
28
32
  overflow-x: auto;
29
33
  \${thinScrollbar};
30
34
  \`;
31
- const TabButton = styled.button<{ theme: Theme; $isActive?: boolean }>\`
35
+
36
+ const TabButton = styled(Button)<{ theme: Theme; $isActive?: boolean }>\`
37
+ \${resetButton};
38
+ appearance: none;
32
39
  flex: 1;
33
40
  display: flex;
34
41
  align-items: center;
@@ -36,25 +43,30 @@ const TabButton = styled.button<{ theme: Theme; $isActive?: boolean }>\`
36
43
  gap: 8px;
37
44
  padding: 12px 20px;
38
45
  border: none;
46
+ border-radius: 0;
39
47
  background: \${({ theme }) => theme.colors.light};
40
48
  cursor: pointer;
41
49
  transition: all 0.2s ease;
42
50
  border-bottom: 3px solid transparent;
43
51
  min-width: fit-content;
52
+ height: auto;
53
+ min-height: 0;
44
54
  \${({ theme }) => styledText(theme)};
45
55
  color: \${({ theme }) => theme.colors.dark};
46
56
  font-weight: 600;
57
+ position: relative;
47
58
 
48
59
  & svg {
49
60
  flex-shrink: 0;
50
61
  }
62
+
51
63
  \${({ theme, $isActive }) =>
52
64
  $isActive &&
53
65
  css\`
54
66
  color: \${theme.colors.primary};
55
- border-bottom: 3px solid \${theme.colors.primary};
67
+ border-bottom-color: \${theme.colors.primary};
56
68
  \`}
57
- position: relative;
69
+
58
70
  &:hover {
59
71
  \${({ theme, $isActive }) =>
60
72
  !$isActive &&
@@ -67,13 +79,22 @@ const TabButton = styled.button<{ theme: Theme; $isActive?: boolean }>\`
67
79
  );
68
80
  \`}
69
81
  }
70
- &:focus {
82
+
83
+ &:focus-visible {
71
84
  outline: none;
85
+ z-index: 1;
86
+ box-shadow: inset 0 0 0 2px \${({ theme }) => theme.colors.primaryLight};
72
87
  }
88
+
73
89
  &:not(:last-child) {
74
90
  border-right: 1px solid \${({ theme }) => theme.colors.grayLight};
75
91
  }
92
+
93
+ @media (prefers-reduced-motion: reduce) {
94
+ transition: none;
95
+ }
76
96
  \`;
97
+
77
98
  const TabPanel = styled.div<{ theme: Theme }>\`
78
99
  background-color: \${({ theme }) => theme.colors.light};
79
100
  padding: 20px;
@@ -88,12 +109,25 @@ const TabPanel = styled.div<{ theme: Theme }>\`
88
109
  gap: 20px;
89
110
  flex-wrap: wrap;
90
111
  flex: 1;
112
+
113
+ &[hidden] {
114
+ display: none;
115
+ }
116
+
117
+ &:focus-visible {
118
+ outline: none;
119
+ box-shadow: inset 0 0 0 2px \${({ theme }) => theme.colors.primaryLight};
120
+ }
91
121
  \`;
122
+
92
123
  const TabContent: React.FC<TabContentProps> = ({ children }) => {
93
124
  return <>{children}</>;
94
125
  };
126
+
95
127
  const Tabs: React.FC<TabsProps> = ({ children }) => {
96
128
  const [activeTab, setActiveTab] = useState(0);
129
+ const tabsId = useId();
130
+ const tabRefs = useRef<Array<HTMLButtonElement | null>>([]);
97
131
  const tabs = React.Children.toArray(children).filter(
98
132
  (child): child is React.ReactElement<TabContentProps> =>
99
133
  Boolean(
@@ -105,24 +139,79 @@ const Tabs: React.FC<TabsProps> = ({ children }) => {
105
139
  child.props.title.trim() !== "",
106
140
  ),
107
141
  );
142
+
143
+ const selectTab = (index: number) => {
144
+ setActiveTab(index);
145
+ tabRefs.current[index]?.focus();
146
+ };
147
+
148
+ const handleTabKeyDown = (
149
+ event: React.KeyboardEvent<HTMLButtonElement>,
150
+ index: number,
151
+ ) => {
152
+ let nextIndex: number | null = null;
153
+ if (event.key === "ArrowRight") {
154
+ nextIndex = index === tabs.length - 1 ? 0 : index + 1;
155
+ } else if (event.key === "ArrowLeft") {
156
+ nextIndex = index === 0 ? tabs.length - 1 : index - 1;
157
+ } else if (event.key === "Home") {
158
+ nextIndex = 0;
159
+ } else if (event.key === "End") {
160
+ nextIndex = tabs.length - 1;
161
+ }
162
+
163
+ if (nextIndex === null) return;
164
+ event.preventDefault();
165
+ selectTab(nextIndex);
166
+ };
167
+
108
168
  return (
109
169
  <TabsContainer>
110
- <TabsList>
111
- {tabs.map((tab, index) => (
112
- <TabButton
113
- key={index}
114
- $isActive={activeTab === index}
115
- onClick={() => setActiveTab(index)}
116
- type="button"
117
- >
118
- {tab.props.icon && <Icon name={tab.props.icon} size={18} />}
119
- {tab.props.title}
120
- </TabButton>
121
- ))}
170
+ <TabsList
171
+ role="tablist"
172
+ aria-label="Content tabs"
173
+ aria-orientation="horizontal"
174
+ >
175
+ {tabs.map((tab, index) => {
176
+ const tabId = tabsId + "-tab-" + index;
177
+ const panelId = tabsId + "-panel-" + index;
178
+ return (
179
+ <TabButton
180
+ key={tabId}
181
+ ref={(element) => {
182
+ tabRefs.current[index] = element;
183
+ }}
184
+ id={tabId}
185
+ role="tab"
186
+ aria-selected={activeTab === index}
187
+ aria-controls={panelId}
188
+ tabIndex={activeTab === index ? 0 : -1}
189
+ $isActive={activeTab === index}
190
+ onClick={() => setActiveTab(index)}
191
+ onKeyDown={(event) => handleTabKeyDown(event, index)}
192
+ type="button"
193
+ >
194
+ {tab.props.icon && <Icon name={tab.props.icon} size={18} />}
195
+ {tab.props.title}
196
+ </TabButton>
197
+ );
198
+ })}
122
199
  </TabsList>
123
- <TabPanel>{tabs[activeTab]?.props.children}</TabPanel>
200
+ {tabs.map((tab, index) => (
201
+ <TabPanel
202
+ key={tabsId + "-panel-" + index}
203
+ id={tabsId + "-panel-" + index}
204
+ role="tabpanel"
205
+ aria-labelledby={tabsId + "-tab-" + index}
206
+ tabIndex={activeTab === index ? 0 : -1}
207
+ hidden={activeTab !== index}
208
+ >
209
+ {tab.props.children}
210
+ </TabPanel>
211
+ ))}
124
212
  </TabsContainer>
125
213
  );
126
214
  };
215
+
127
216
  export { Tabs, TabContent };
128
217
  `;
@@ -1 +1 @@
1
- export declare const envExampleTemplate = "# Public Site URL\n# Used by sitemap.xml and robots.txt. Overrides `url` in config.json when set.\n# NEXT_PUBLIC_SITE_URL=https://docs.example.com\n\n# Password Protection (optional)\n# Set a shared password to gate the whole site behind a login screen. When set,\n# pages require the password, the content APIs (chat + search) return 401\n# without it, and the site is hidden from search engines and crawlers. Leave\n# unset (or remove) to keep the site public.\n# SITE_PASSWORD=choose-a-strong-shared-password\n\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Override default chat model\n# See available models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/models\n# Anthropic: https://docs.anthropic.com/claude/docs/models-overview\n# Google: https://ai.google.dev/models/gemini\n# LLM_CHAT_MODEL=\n\n# Optional: Override default embedding model\n# See available embedding models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/guides/embeddings\n# Google: https://ai.google.dev/gemini-api/docs/embeddings\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are Matryoshka-truncated to this many dimensions and stored as\n# int8, which keeps services/mcp/docs-index.json small (~20x smaller than raw\n# floats) so large doc sets don't stall the AI chat on serverless cold starts.\n# Lower = smaller index, slightly lower recall. Values >= the model's native\n# dimension keep full precision. Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n";
1
+ export declare const envExampleTemplate = "# Public Site URL\n# Used by sitemap.xml and robots.txt. Overrides `url` in config.json when set.\n# NEXT_PUBLIC_SITE_URL=https://docs.example.com\n\n# Password Protection (optional)\n# Set a shared password to gate the whole site behind a login screen. When set,\n# pages require the password, the content APIs (chat + search) return 401\n# without it, and the site is hidden from search engines and crawlers. Leave\n# unset (or remove) to keep the site public.\n# SITE_PASSWORD=choose-a-strong-shared-password\n\n# Paid API Access (recommended for public deployments with AI enabled)\n# Public documentation remains intentionally public by default. Set RAG_API_KEY\n# to require Authorization: Bearer <key> for /api/rag and prevent anonymous LLM\n# spend. The browser chat cannot safely hold this server secret; use\n# SITE_PASSWORD instead when authenticated browser chat is required.\n# RAG_API_KEY=generate-a-long-random-secret\n# Set DOCS_API_KEY to require bearer authentication for /api/mcp. If omitted,\n# MCP follows the site access mode and remains public on an intentionally public\n# documentation site.\n# DOCS_API_KEY=generate-another-long-random-secret\n\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Override default chat model\n# See available models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/models\n# Anthropic: https://docs.anthropic.com/claude/docs/models-overview\n# Google: https://ai.google.dev/models/gemini\n# LLM_CHAT_MODEL=\n\n# Optional: Override default embedding model\n# See available embedding models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/guides/embeddings\n# Google: https://ai.google.dev/gemini-api/docs/embeddings\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are Matryoshka-truncated to this many dimensions and stored as\n# int8, which keeps services/mcp/docs-index.json small (~20x smaller than raw\n# floats) so large doc sets don't stall the AI chat on serverless cold starts.\n# Lower = smaller index, slightly lower recall. Values >= the model's native\n# dimension keep full precision. Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n";
@@ -9,6 +9,17 @@ export const envExampleTemplate = `# Public Site URL
9
9
  # unset (or remove) to keep the site public.
10
10
  # SITE_PASSWORD=choose-a-strong-shared-password
11
11
 
12
+ # Paid API Access (recommended for public deployments with AI enabled)
13
+ # Public documentation remains intentionally public by default. Set RAG_API_KEY
14
+ # to require Authorization: Bearer <key> for /api/rag and prevent anonymous LLM
15
+ # spend. The browser chat cannot safely hold this server secret; use
16
+ # SITE_PASSWORD instead when authenticated browser chat is required.
17
+ # RAG_API_KEY=generate-a-long-random-secret
18
+ # Set DOCS_API_KEY to require bearer authentication for /api/mcp. If omitted,
19
+ # MCP follows the site access mode and remains public on an intentionally public
20
+ # documentation site.
21
+ # DOCS_API_KEY=generate-another-long-random-secret
22
+
12
23
  # LLM Provider Configuration
13
24
  # Choose your preferred LLM provider: openai, anthropic, or google
14
25
  LLM_PROVIDER=openai
@@ -1 +1 @@
1
- export declare const eslintConfigTemplate = "import globals from \"globals\";\nimport nextPlugin from \"@next/eslint-plugin-next\";\nimport reactPlugin from \"eslint-plugin-react\";\nimport reactHooksPlugin from \"eslint-plugin-react-hooks\";\nimport jsxA11yPlugin from \"eslint-plugin-jsx-a11y\";\nimport importPlugin from \"eslint-plugin-import\";\nimport tsParser from \"@typescript-eslint/parser\";\nimport tsPlugin from \"@typescript-eslint/eslint-plugin\";\n\n// Hand-rolled replacement for `eslint-config-next`'s default config.\n//\n// We don't use eslint-config-next under ESLint 10: its React version detection\n// (`settings.react.version: \"detect\"`) calls `context.getFilename()`, which\n// ESLint 10 removed, so it crashes on load. Composing the same plugins\n// ourselves lets us pin `react.version` (below) and stay in control.\n//\n// The recommended rule sets below mirror what eslint-config-next enables:\n// React, React Hooks, Next.js and jsx-a11y. On top of that we keep a few\n// project-specific rules (no-console and two @typescript-eslint rules).\n\nconst config = [\n {\n // node_modules/ and .git/ are ignored by default.\n ignores: [\".next/**\", \"out/**\", \"build/**\", \"next-env.d.ts\"],\n },\n {\n name: \"doccupine/base\",\n files: [\"**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}\"],\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooksPlugin,\n import: importPlugin,\n \"jsx-a11y\": jsxA11yPlugin,\n \"@next/next\": nextPlugin,\n \"@typescript-eslint\": tsPlugin,\n },\n languageOptions: {\n parser: tsParser,\n parserOptions: {\n sourceType: \"module\",\n ecmaFeatures: { jsx: true },\n },\n globals: { ...globals.browser, ...globals.node },\n },\n settings: {\n // Pinned (not \"detect\") on purpose: eslint-plugin-react 7.37.x's version\n // detection calls the ESLint-10-removed `context.getFilename()`. Pinning\n // skips that code path. Keep roughly in sync with the installed React.\n react: { version: \"19.2\" },\n },\n rules: {\n ...reactPlugin.configs.recommended.rules,\n ...reactHooksPlugin.configs.recommended.rules,\n ...nextPlugin.configs.recommended.rules,\n \"import/no-anonymous-default-export\": \"warn\",\n \"react/no-unknown-property\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"react/prop-types\": \"off\",\n \"jsx-a11y/alt-text\": [\"warn\", { elements: [\"img\"], img: [\"Image\"] }],\n \"jsx-a11y/aria-props\": \"warn\",\n \"jsx-a11y/aria-proptypes\": \"warn\",\n \"jsx-a11y/aria-unsupported-elements\": \"warn\",\n \"jsx-a11y/role-has-required-aria-props\": \"warn\",\n \"jsx-a11y/role-supports-aria-props\": \"warn\",\n \"react/jsx-no-target-blank\": \"off\",\n \"no-console\": [\"warn\", { allow: [\"warn\", \"error\"] }],\n \"@typescript-eslint/no-explicit-any\": \"warn\",\n \"@typescript-eslint/no-unused-vars\": [\n \"warn\",\n { argsIgnorePattern: \"^_\", varsIgnorePattern: \"^_\" },\n ],\n },\n },\n];\n\nexport default config;\n";
1
+ export declare const eslintConfigTemplate = "import globals from \"globals\";\nimport nextPlugin from \"@next/eslint-plugin-next\";\nimport reactPlugin from \"eslint-plugin-react\";\nimport reactHooksPlugin from \"eslint-plugin-react-hooks\";\nimport jsxA11yPlugin from \"eslint-plugin-jsx-a11y\";\nimport importPlugin from \"eslint-plugin-import\";\nimport tsParser from \"@typescript-eslint/parser\";\nimport tsPlugin from \"@typescript-eslint/eslint-plugin\";\n\n// Hand-rolled replacement for `eslint-config-next`'s default config.\n//\n// We don't use eslint-config-next under ESLint 10: its React version detection\n// (`settings.react.version: \"detect\"`) calls `context.getFilename()`, which\n// ESLint 10 removed, so it crashes on load. Composing the same plugins\n// ourselves lets us pin `react.version` (below) and stay in control.\n//\n// The recommended rule sets below mirror what eslint-config-next enables:\n// React, React Hooks, Next.js and jsx-a11y. On top of that we keep a few\n// project-specific rules (no-console and two @typescript-eslint rules).\n\nconst config = [\n {\n // node_modules/ and .git/ are ignored by default.\n ignores: [\".next/**\", \"out/**\", \"build/**\", \"next-env.d.ts\"],\n },\n {\n name: \"doccupine/base\",\n files: [\"**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}\"],\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooksPlugin,\n import: importPlugin,\n \"jsx-a11y\": jsxA11yPlugin,\n \"@next/next\": nextPlugin,\n \"@typescript-eslint\": tsPlugin,\n },\n languageOptions: {\n parser: tsParser,\n parserOptions: {\n sourceType: \"module\",\n ecmaFeatures: { jsx: true },\n },\n globals: { ...globals.browser, ...globals.node },\n },\n settings: {\n // Pinned (not \"detect\") on purpose: eslint-plugin-react 7.37.x's version\n // detection calls the ESLint-10-removed `context.getFilename()`. Pinning\n // skips that code path. Keep roughly in sync with the installed React.\n react: { version: \"19.2\" },\n },\n rules: {\n ...reactPlugin.configs.recommended.rules,\n ...reactHooksPlugin.configs.recommended.rules,\n ...nextPlugin.configs.recommended.rules,\n ...jsxA11yPlugin.configs.recommended.rules,\n \"import/no-anonymous-default-export\": \"warn\",\n \"react/no-unknown-property\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"react/prop-types\": \"off\",\n \"jsx-a11y/alt-text\": [\"warn\", { elements: [\"img\"], img: [\"Image\"] }],\n \"jsx-a11y/aria-props\": \"warn\",\n \"jsx-a11y/aria-proptypes\": \"warn\",\n \"jsx-a11y/aria-unsupported-elements\": \"warn\",\n \"jsx-a11y/role-has-required-aria-props\": \"warn\",\n \"jsx-a11y/role-supports-aria-props\": \"warn\",\n \"react/jsx-no-target-blank\": \"off\",\n \"no-console\": [\"warn\", { allow: [\"warn\", \"error\"] }],\n \"@typescript-eslint/no-explicit-any\": \"warn\",\n \"@typescript-eslint/no-unused-vars\": [\n \"warn\",\n { argsIgnorePattern: \"^_\", varsIgnorePattern: \"^_\" },\n ],\n },\n },\n {\n // These generated previews intentionally render user-selected media without\n // author-provided caption tracks. Keep the complete recommended ruleset on\n // everywhere else while this isolated preview remains user-controlled.\n name: \"doccupine/media-preview\",\n files: [\"components/layout/ApiPlayground.tsx\"],\n rules: {\n \"jsx-a11y/media-has-caption\": \"off\",\n },\n },\n {\n // Cherry's Input owns the actual DOM input and focus behavior. Ignore only\n // non-DOM controls; raw JSX inputs remain covered by the recommended rule.\n name: \"doccupine/cherry-controls\",\n files: [\"components/layout/SiteGate.tsx\"],\n rules: {\n \"jsx-a11y/no-autofocus\": [\"error\", { ignoreNonDOM: true }],\n },\n },\n];\n\nexport default config;\n";
@@ -52,6 +52,7 @@ const config = [
52
52
  ...reactPlugin.configs.recommended.rules,
53
53
  ...reactHooksPlugin.configs.recommended.rules,
54
54
  ...nextPlugin.configs.recommended.rules,
55
+ ...jsxA11yPlugin.configs.recommended.rules,
55
56
  "import/no-anonymous-default-export": "warn",
56
57
  "react/no-unknown-property": "off",
57
58
  "react/react-in-jsx-scope": "off",
@@ -71,6 +72,25 @@ const config = [
71
72
  ],
72
73
  },
73
74
  },
75
+ {
76
+ // These generated previews intentionally render user-selected media without
77
+ // author-provided caption tracks. Keep the complete recommended ruleset on
78
+ // everywhere else while this isolated preview remains user-controlled.
79
+ name: "doccupine/media-preview",
80
+ files: ["components/layout/ApiPlayground.tsx"],
81
+ rules: {
82
+ "jsx-a11y/media-has-caption": "off",
83
+ },
84
+ },
85
+ {
86
+ // Cherry's Input owns the actual DOM input and focus behavior. Ignore only
87
+ // non-DOM controls; raw JSX inputs remain covered by the recommended rule.
88
+ name: "doccupine/cherry-controls",
89
+ files: ["components/layout/SiteGate.tsx"],
90
+ rules: {
91
+ "jsx-a11y/no-autofocus": ["error", { ignoreNonDOM: true }],
92
+ },
93
+ },
74
94
  ];
75
95
 
76
96
  export default config;
@@ -1 +1 @@
1
- export declare const gitignoreTemplate = "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n.yarn/install-state.gz\n\n# testing\n/coverage\n\n# next.js\n/.next/\n/out/\n.next\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# local env files\n.env*.local\n\n# vercel\n.vercel\n\n# typescript\n*.tsbuildinfo\nnext-env.d.ts\n\n.env\n.vscode\n\n# generated build artifact (precomputed embeddings)\nservices/mcp/docs-index.json\n";
1
+ export declare const gitignoreTemplate = "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n.yarn/install-state.gz\n\n# testing\n/coverage\n\n# next.js\n/.next/\n/out/\n.next\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# environment files may contain provider and API secrets\n.env*\n!.env.example\n\n# vercel\n.vercel\n\n# typescript\n*.tsbuildinfo\nnext-env.d.ts\n\n.vscode\n.doccupine-*\n\n# generated build artifact (precomputed embeddings)\nservices/mcp/docs-index.json\n";
@@ -26,8 +26,9 @@ npm-debug.log*
26
26
  yarn-debug.log*
27
27
  yarn-error.log*
28
28
 
29
- # local env files
30
- .env*.local
29
+ # environment files may contain provider and API secrets
30
+ .env*
31
+ !.env.example
31
32
 
32
33
  # vercel
33
34
  .vercel
@@ -36,8 +37,8 @@ yarn-error.log*
36
37
  *.tsbuildinfo
37
38
  next-env.d.ts
38
39
 
39
- .env
40
40
  .vscode
41
+ .doccupine-*
41
42
 
42
43
  # generated build artifact (precomputed embeddings)
43
44
  services/mcp/docs-index.json
@@ -0,0 +1 @@
1
+ export declare const accessControlTemplate = "import { cookies } from \"next/headers\";\nimport {\n GATE_COOKIE_NAME,\n isGateUnlocked,\n timingSafeEqual,\n} from \"@/lib/siteGate\";\n\nfunction bearerToken(req: Request): string | null {\n const authorization = req.headers.get(\"authorization\");\n return authorization?.startsWith(\"Bearer \")\n ? authorization.slice(\"Bearer \".length)\n : null;\n}\n\n/**\n * Route-level authorization for site content. Middleware provides the fast\n * outer gate, while this check ensures direct route invocations are protected\n * too.\n */\nexport async function isSiteRequestAuthorized(): Promise<boolean> {\n const password = process.env.SITE_PASSWORD;\n if (!password) return true;\n\n const cookieStore = await cookies();\n return isGateUnlocked(cookieStore.get(GATE_COOKIE_NAME)?.value, password);\n}\n\n/**\n * MCP clients may authenticate with DOCS_API_KEY. When no API key is configured,\n * a password-protected site requires the normal gate cookie instead of silently\n * exposing its documentation API.\n */\nexport async function isMcpRequestAuthorized(req: Request): Promise<boolean> {\n const apiKey = process.env.DOCS_API_KEY;\n if (apiKey) {\n const token = bearerToken(req);\n return token !== null && timingSafeEqual(token, apiKey);\n }\n return isSiteRequestAuthorized();\n}\n";
@@ -0,0 +1,41 @@
1
+ export const accessControlTemplate = `import { cookies } from "next/headers";
2
+ import {
3
+ GATE_COOKIE_NAME,
4
+ isGateUnlocked,
5
+ timingSafeEqual,
6
+ } from "@/lib/siteGate";
7
+
8
+ function bearerToken(req: Request): string | null {
9
+ const authorization = req.headers.get("authorization");
10
+ return authorization?.startsWith("Bearer ")
11
+ ? authorization.slice("Bearer ".length)
12
+ : null;
13
+ }
14
+
15
+ /**
16
+ * Route-level authorization for site content. Middleware provides the fast
17
+ * outer gate, while this check ensures direct route invocations are protected
18
+ * too.
19
+ */
20
+ export async function isSiteRequestAuthorized(): Promise<boolean> {
21
+ const password = process.env.SITE_PASSWORD;
22
+ if (!password) return true;
23
+
24
+ const cookieStore = await cookies();
25
+ return isGateUnlocked(cookieStore.get(GATE_COOKIE_NAME)?.value, password);
26
+ }
27
+
28
+ /**
29
+ * MCP clients may authenticate with DOCS_API_KEY. When no API key is configured,
30
+ * a password-protected site requires the normal gate cookie instead of silently
31
+ * exposing its documentation API.
32
+ */
33
+ export async function isMcpRequestAuthorized(req: Request): Promise<boolean> {
34
+ const apiKey = process.env.DOCS_API_KEY;
35
+ if (apiKey) {
36
+ const token = bearerToken(req);
37
+ return token !== null && timingSafeEqual(token, apiKey);
38
+ }
39
+ return isSiteRequestAuthorized();
40
+ }
41
+ `;
@@ -1 +1 @@
1
- export declare const aiAssistantMdxTemplate = "---\ntitle: \"AI Assistant\"\ndescription: \"Integrate AI capabilities into your Doccupine documentation using OpenAI, Anthropic, or Google Gemini.\"\ndate: \"2026-02-19\"\ncategory: \"AI & Integrations\"\ncategoryOrder: 3\ncategoryIcon: \"sparkles\"\norder: 1\n---\n# AI Assistant\n\nDoccupine supports AI integration to enhance your documentation experience. You can use OpenAI, Anthropic, or Google Gemini to power AI features in your documentation site. The AI assistant uses your documentation content as context, allowing users to ask questions about your docs and receive accurate answers based on the documentation.\n\n## Opening the Assistant\n\nOnce a provider is configured, an assistant button appears in the header. You can open and close the assistant from anywhere on the site by pressing <kbd>Command</kbd> + <kbd>I</kbd> (<kbd>Ctrl</kbd> + <kbd>I</kbd> on Windows). Press the same shortcut again to dismiss it.\n\n<Callout type=\"note\">\n The keyboard shortcut is only active once you have configured an LLM provider, as described below.\n</Callout>\n\n## Setup\n\nTo enable AI features, create an `.env` file in the directory where your website is generated. By default, this is the `nextjs-app/` directory.\n\n## Configuration\n\nCreate an `.env` file with the following configuration options:\n\n```env\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Override default chat model (see your provider's docs for available models)\n# LLM_CHAT_MODEL=your-model-id\n\n# Optional: Override default embedding model (see your provider's docs for available models)\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=your-embedding-model-id\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are truncated to this many dimensions and stored as int8 to keep\n# the search index small. Lower = smaller index, slightly lower recall.\n# Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n```\n\n## Provider Selection\n\nSet `LLM_PROVIDER` to one of the following values:\n\n- `openai` - Use OpenAI's models\n- `anthropic` - Use Anthropic's models\n- `google` - Use Google's models\n\n## API Keys\n\nYou need to set the API key that matches your chosen provider:\n\n- For OpenAI: Set `OPENAI_API_KEY`\n- For Anthropic: Set `ANTHROPIC_API_KEY`\n- For Google: Set `GOOGLE_API_KEY`\n\n<Callout type=\"warning\">\n Keep your API keys secure. Never commit your `.env` file to version control.\n</Callout>\n\n<Callout type=\"note\">\n Doccupine automatically adds `.env` to your `.gitignore` file.\n</Callout>\n\n## Using Anthropic with OpenAI\n\nIf you want to use Anthropic as your LLM provider, you must also have an OpenAI API key set. Here's why:\n\n### The Situation\n\nAnthropic (Claude) does not provide an embeddings API. They only offer chat/completion models, not text embeddings.\n\nYour RAG (Retrieval-Augmented Generation) system has two components:\n\n- **Chat/Completion** - Generates answers, works with Anthropic.\n- **Embeddings** - Creates vector representations of text for search, Anthropic doesn't provide this.\n\nWhen using Anthropic as your `LLM_PROVIDER`, Doccupine will use Anthropic for chat/completion tasks, but will automatically fallback to OpenAI for embeddings. This means you need both API keys configured:\n\n```env\nLLM_PROVIDER=anthropic\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nOPENAI_API_KEY=your_openai_api_key_here\n```\n\nThis hybrid approach allows you to leverage Anthropic's powerful chat models while still having access to embeddings functionality through OpenAI.\n\n## Default models\n\n| Provider | Chat model | Embedding model |\n| --------- | ---------------------------- | ------------------------ |\n| OpenAI | `gpt-4.1-nano` | `text-embedding-3-small` |\n| Anthropic | `claude-sonnet-4-5-20250929` | OpenAI fallback |\n| Google | `gemini-2.5-flash-lite` | `gemini-embedding-001` |\n\n## Optional Settings\n\n### Chat Model\n\nOverride the default chat model by uncommenting and setting `LLM_CHAT_MODEL`. You can use any available model from your chosen provider. For a complete list of available models, refer to the official documentation:\n\n- [OpenAI Models](https://platform.openai.com/docs/models)\n- [Anthropic Models](https://docs.anthropic.com/claude/docs/models-overview)\n- [Google Gemini Models](https://ai.google.dev/models/gemini)\n\n### Embedding Model\n\nOverride the default embedding model by uncommenting and setting `LLM_EMBEDDING_MODEL`. For a complete list of available embedding models, refer to the official documentation:\n\n- [OpenAI Embeddings](https://platform.openai.com/docs/guides/embeddings)\n- [Google Gemini Embeddings](https://ai.google.dev/gemini-api/docs/embeddings)\n- **Anthropic**: Anthropic doesn't provide embeddings. If you use Anthropic as your provider, Doccupine will fallback to OpenAI for embeddings.\n\n### Temperature\n\nControl the randomness of AI responses by setting `LLM_TEMPERATURE` to a value between 0 and 1:\n\n- `0` - More deterministic and focused responses (default)\n- `1` - More creative and varied responses\n\n### Embedding Dimensions\n\nControl the size of the prebuilt search index by setting `LLM_EMBEDDING_DIMS` (default: 512). Doc vectors are truncated to this many dimensions and stored as int8, keeping `services/mcp/docs-index.json` small so large doc sets don't stall the AI chat on serverless cold starts.\n\n- Lower values produce a smaller index with slightly lower search recall.\n- Values greater than or equal to the model's native dimension keep full precision.\n\nThis value must match between build time and runtime. A mismatch forces Doccupine to re-embed your docs at runtime, so rebuild or redeploy your site after changing it.";
1
+ export declare const aiAssistantMdxTemplate = "---\ntitle: \"AI Assistant\"\ndescription: \"Integrate AI capabilities into your Doccupine documentation using OpenAI, Anthropic, or Google Gemini.\"\ndate: \"2026-02-19\"\ncategory: \"AI & Integrations\"\ncategoryOrder: 3\ncategoryIcon: \"sparkles\"\norder: 1\n---\n# AI Assistant\n\nDoccupine supports AI integration to enhance your documentation experience. You can use OpenAI, Anthropic, or Google Gemini to power AI features in your documentation site. The AI assistant uses your documentation content as context, allowing users to ask questions about your docs and receive accurate answers based on the documentation.\n\n## Opening the Assistant\n\nOnce a provider is configured, an assistant button appears in the header. You can open and close the assistant from anywhere on the site by pressing <kbd>Command</kbd> + <kbd>I</kbd> (<kbd>Ctrl</kbd> + <kbd>I</kbd> on Windows). Press the same shortcut again to dismiss it.\n\n<Callout type=\"note\">\n The keyboard shortcut is only active once you have configured an LLM provider, as described below.\n</Callout>\n\n## Setup\n\nTo enable AI features, create an `.env` file in the directory where your website is generated. By default, this is the `nextjs-app/` directory.\n\n## Configuration\n\nCreate an `.env` file with the following configuration options:\n\n```env\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Require a bearer token for direct /api/rag requests on a public site\n# RAG_API_KEY=generate-a-long-random-secret\n\n# Optional: Override default chat model (see your provider's docs for available models)\n# LLM_CHAT_MODEL=your-model-id\n\n# Optional: Override default embedding model (see your provider's docs for available models)\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=your-embedding-model-id\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are truncated to this many dimensions and stored as int8 to keep\n# the search index small. Lower = smaller index, slightly lower recall.\n# Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n```\n\n## Provider Selection\n\nSet `LLM_PROVIDER` to one of the following values:\n\n- `openai` - Use OpenAI's models\n- `anthropic` - Use Anthropic's models\n- `google` - Use Google's models\n\n## API Keys\n\nYou need to set the API key that matches your chosen provider:\n\n- For OpenAI: Set `OPENAI_API_KEY`\n- For Anthropic: Set `ANTHROPIC_API_KEY`\n- For Google: Set `GOOGLE_API_KEY`\n\n<Callout type=\"warning\">\n Keep your API keys secure. Never commit your `.env` file to version control.\n</Callout>\n\n<Callout type=\"note\">\n Doccupine ignores every `.env*` variant except the non-secret\n `.env.example`, helping prevent development, test, and production credentials\n from being committed accidentally.\n</Callout>\n\n## Protecting model spend\n\nPublic documentation intentionally leaves the browser assistant available by default. For a public deployment where only server-to-server clients should call the paid RAG endpoint, set `RAG_API_KEY` and require `Authorization: Bearer <key>` on `/api/rag`.\n\n<Callout type=\"warning\">\n The built-in browser assistant cannot safely store a server API key. Setting\n `RAG_API_KEY` on an otherwise public site disables anonymous browser chat. Use\n `SITE_PASSWORD` instead when signed-in browser visitors should keep using the\n assistant, or leave `RAG_API_KEY` unset when public chat is intentional.\n</Callout>\n\n## Using Anthropic with OpenAI\n\nIf you want to use Anthropic as your LLM provider, you must also have an OpenAI API key set. Here's why:\n\n### The Situation\n\nAnthropic (Claude) does not provide an embeddings API. They only offer chat/completion models, not text embeddings.\n\nYour RAG (Retrieval-Augmented Generation) system has two components:\n\n- **Chat/Completion** - Generates answers, works with Anthropic.\n- **Embeddings** - Creates vector representations of text for search, Anthropic doesn't provide this.\n\nWhen using Anthropic as your `LLM_PROVIDER`, Doccupine will use Anthropic for chat/completion tasks, but will automatically fallback to OpenAI for embeddings. This means you need both API keys configured:\n\n```env\nLLM_PROVIDER=anthropic\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nOPENAI_API_KEY=your_openai_api_key_here\n```\n\nThis hybrid approach allows you to leverage Anthropic's powerful chat models while still having access to embeddings functionality through OpenAI.\n\n## Default models\n\n| Provider | Chat model | Embedding model |\n| --------- | ---------------------------- | ------------------------ |\n| OpenAI | `gpt-4.1-nano` | `text-embedding-3-small` |\n| Anthropic | `claude-sonnet-4-5-20250929` | OpenAI fallback |\n| Google | `gemini-2.5-flash-lite` | `gemini-embedding-001` |\n\n## Optional Settings\n\n### Chat Model\n\nOverride the default chat model by uncommenting and setting `LLM_CHAT_MODEL`. You can use any available model from your chosen provider. For a complete list of available models, refer to the official documentation:\n\n- [OpenAI Models](https://platform.openai.com/docs/models)\n- [Anthropic Models](https://docs.anthropic.com/claude/docs/models-overview)\n- [Google Gemini Models](https://ai.google.dev/models/gemini)\n\n### Embedding Model\n\nOverride the default embedding model by uncommenting and setting `LLM_EMBEDDING_MODEL`. For a complete list of available embedding models, refer to the official documentation:\n\n- [OpenAI Embeddings](https://platform.openai.com/docs/guides/embeddings)\n- [Google Gemini Embeddings](https://ai.google.dev/gemini-api/docs/embeddings)\n- **Anthropic**: Anthropic doesn't provide embeddings. If you use Anthropic as your provider, Doccupine will fallback to OpenAI for embeddings.\n\n### Temperature\n\nControl the randomness of AI responses by setting `LLM_TEMPERATURE` to a value between 0 and 1:\n\n- `0` - More deterministic and focused responses (default)\n- `1` - More creative and varied responses\n\n### Embedding Dimensions\n\nControl the size of the prebuilt search index by setting `LLM_EMBEDDING_DIMS` (default: 512). Doc vectors are truncated to this many dimensions and stored as int8, keeping `services/mcp/docs-index.json` small so large doc sets don't stall the AI chat on serverless cold starts.\n\n- Lower values produce a smaller index with slightly lower search recall.\n- Values greater than or equal to the model's native dimension keep full precision.\n\nThis value must match between build time and runtime. A mismatch forces Doccupine to re-embed your docs at runtime, so rebuild or redeploy your site after changing it.";
@@ -37,6 +37,9 @@ OPENAI_API_KEY=your_openai_api_key_here
37
37
  ANTHROPIC_API_KEY=your_anthropic_api_key_here
38
38
  GOOGLE_API_KEY=your_google_api_key_here
39
39
 
40
+ # Optional: Require a bearer token for direct /api/rag requests on a public site
41
+ # RAG_API_KEY=generate-a-long-random-secret
42
+
40
43
  # Optional: Override default chat model (see your provider's docs for available models)
41
44
  # LLM_CHAT_MODEL=your-model-id
42
45
 
@@ -75,7 +78,20 @@ You need to set the API key that matches your chosen provider:
75
78
  </Callout>
76
79
 
77
80
  <Callout type="note">
78
- Doccupine automatically adds \`.env\` to your \`.gitignore\` file.
81
+ Doccupine ignores every \`.env*\` variant except the non-secret
82
+ \`.env.example\`, helping prevent development, test, and production credentials
83
+ from being committed accidentally.
84
+ </Callout>
85
+
86
+ ## Protecting model spend
87
+
88
+ Public documentation intentionally leaves the browser assistant available by default. For a public deployment where only server-to-server clients should call the paid RAG endpoint, set \`RAG_API_KEY\` and require \`Authorization: Bearer <key>\` on \`/api/rag\`.
89
+
90
+ <Callout type="warning">
91
+ The built-in browser assistant cannot safely store a server API key. Setting
92
+ \`RAG_API_KEY\` on an otherwise public site disables anonymous browser chat. Use
93
+ \`SITE_PASSWORD\` instead when signed-in browser visitors should keep using the
94
+ assistant, or leave \`RAG_API_KEY\` unset when public chat is intentional.
79
95
  </Callout>
80
96
 
81
97
  ## Using Anthropic with OpenAI
@@ -1 +1 @@
1
- export declare const apiPlaygroundMdxTemplate = "---\ntitle: \"API Playground\"\ndescription: \"Turn an OpenAPI document into an interactive API reference where readers send real requests and see live responses, right inside your docs.\"\ndate: \"2026-07-25\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 20\n---\n# API Playground\n\nPoint Doccupine at an OpenAPI document and it generates a complete, interactive API reference: one page per endpoint, grouped by tag in the sidebar, each with a \"Send request\" panel that makes real calls and shows the live response - plus copy-pasteable code snippets.\n\n<Callout type=\"note\">\nThe playground is driven entirely by your OpenAPI document. There is nothing to wire up by hand - add one line of config and every endpoint becomes a documented, runnable page.\n</Callout>\n\n## Try it\n\nPress **Try it** below to open the playground, tweak the request body, and send a real request to a live API - right from these docs.\n\n<ApiPlaygroundDemo />\n\n## Enabling the playground\n\n<Steps>\n <Step title=\"Add an openapi path to doccupine.json.\">\n Point at a local `.json`, `.yaml`, or `.yml` OpenAPI 3.0 or 3.1 document.\n\n```json\n{\n \"watchDir\": \"docs\",\n \"outputDir\": \"nextjs-app\",\n \"openapi\": \"openapi.yaml\"\n}\n```\n </Step>\n <Step title=\"Run Doccupine.\">\n On the next build (or live, while watching) Doccupine parses the document, resolves every `$ref`, and writes an endpoint page for each operation.\n </Step>\n <Step title=\"Open the API Reference section.\">\n Endpoints appear in the sidebar grouped by their OpenAPI tag. Editing the spec regenerates the pages automatically.\n </Step>\n</Steps>\n\n## Example spec\n\nDo not have a document yet? This `openapi.yaml` points at [JSONPlaceholder](https://jsonplaceholder.typicode.com), a free public test API, so it works end to end - save it, set `openapi` to it, and the generated pages can send real requests:\n\n```yaml\nopenapi: 3.1.0\ninfo:\n title: JSONPlaceholder\n version: 1.0.0\nservers:\n - url: https://jsonplaceholder.typicode.com\ntags:\n - name: Todos\n - name: Posts\npaths:\n /todos/{id}:\n get:\n summary: Get a to-do\n tags: [Todos]\n parameters:\n - name: id\n in: path\n required: true\n schema:\n type: integer\n responses:\n \"200\":\n description: Just a demo of a to-do item\n /posts:\n post:\n summary: Create a post\n tags: [Posts]\n requestBody:\n required: true\n content:\n application/json:\n example:\n title: Hello\n body: Sent from the docs\n userId: 1\n responses:\n \"201\":\n description: Just a demo of the created post\n```\n\nEach part maps to something in the playground: `servers` sets the request target - and the only host the proxy will call - `tags` group endpoints in the sidebar, and `parameters` and `requestBody` become the inputs (adding a `securitySchemes` entry would produce authentication fields). Doccupine reads OpenAPI 3.0 and 3.1; see the [OpenAPI specification](https://spec.openapis.org) for the full format.\n\n## What gets generated\n\nEvery operation becomes its own page under `/api-reference/{tag}/{operation}`, showing:\n\n<Field value=\"Parameters\" type=\"path, query, header, cookie\">\nEach parameter is rendered with its name, type, and whether it is required, grouped into a collapsible section with an input to fill in.\n</Field>\n\n<Field value=\"Request body\" type=\"editable\">\nA JSON editor prefilled from the schema's example, ready to tweak and send.\n</Field>\n\n<Field value=\"Authentication\" type=\"from securitySchemes\">\nInputs for the endpoint's security schemes - API keys, bearer tokens, or basic auth - generated from the document.\n</Field>\n\n<Field value=\"Response\" type=\"live\">\nThe real status, timing, and body from your API, rendered to match its content type.\n</Field>\n\n## Embedding a single endpoint\n\nTo mix prose and a live endpoint on a hand-written page, reference an operation from the page's frontmatter with `openapi`. Use `METHOD /path` or an `operationId`:\n\n```mdx\n---\ntitle: \"Create a post\"\nopenapi: \"POST /posts\"\n---\n\nPosts are created for a user. The playground above is fully live - fill in the\nbody and send a real request.\n```\n\nDoccupine renders that endpoint's playground above your prose. If the reference does not match any operation in your document, the page still renders its prose and a warning is logged.\n\n## Running requests\n\nRequests run one of two ways, and readers can switch between them:\n\n<Callout type=\"note\">\n**Proxy (default).** The request is forwarded server-side, so it works even when the target API blocks cross-origin browser calls. **Direct.** The browser calls the API itself - useful when the API allows CORS and you want requests to never leave the reader's machine.\n</Callout>\n\nThe proxy is deliberately locked down. It only forwards to the servers declared in your OpenAPI document, refuses to reach private or internal network addresses, and never logs request URLs, headers, or bodies - so API keys a reader enters are not written anywhere.\n\n<Callout type=\"warning\">\nKeys and tokens a reader types are used only to make the request. Turn on \"Show secrets\" to reveal them in the generated code snippets; they are redacted by default.\n</Callout>\n\n## Responses and snippets\n\nResponses render to match their type: images and video play inline, everything else is shown as a formatted, syntax-highlighted body. Alongside the response, the playground generates ready-to-run **cURL**, **JavaScript**, and **Python** snippets for the exact request you built.\n\n## Documenting more than one API\n\nPass an array to document several APIs at once. Each spec becomes its own namespaced section:\n\n```json\n{\n \"openapi\": [\n { \"name\": \"public\", \"file\": \"specs/public.yaml\" },\n { \"name\": \"admin\", \"file\": \"specs/admin.yaml\" }\n ]\n}\n```\n";
1
+ export declare const apiPlaygroundMdxTemplate = "---\ntitle: \"API Playground\"\ndescription: \"Turn an OpenAPI document into an interactive API reference where readers send real requests and see live responses, right inside your docs.\"\ndate: \"2026-07-25\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 20\n---\n# API Playground\n\nPoint Doccupine at an OpenAPI document and it generates a complete, interactive API reference: one page per endpoint, grouped by tag in the sidebar, each with a \"Send request\" panel that makes real calls and shows the live response - plus copy-pasteable code snippets.\n\n<Callout type=\"note\">\nThe playground is driven entirely by your OpenAPI document. There is nothing to wire up by hand - add one line of config and every endpoint becomes a documented, runnable page.\n</Callout>\n\n## Try it\n\nPress **Try it** below to open the playground, tweak the request body, and send a real request to a live API - right from these docs.\n\n<ApiPlaygroundDemo />\n\n## Enabling the playground\n\n<Steps>\n <Step title=\"Add an openapi path to doccupine.json.\">\n Point at a local `.json`, `.yaml`, or `.yml` OpenAPI 3.0 or 3.1 document.\n\n```json\n{\n \"watchDir\": \"docs\",\n \"outputDir\": \"nextjs-app\",\n \"openapi\": \"openapi.yaml\"\n}\n```\n </Step>\n <Step title=\"Run Doccupine.\">\n On the next build (or live, while watching) Doccupine parses the document and writes an endpoint page for each operation. Local `$ref` files must stay inside the configured spec's directory, use `.json`, `.yaml`, or `.yml`, and cannot be dotfiles or live inside dot-directories.\n </Step>\n <Step title=\"Open the API Reference section.\">\n Endpoints appear in the sidebar grouped by their OpenAPI tag. Editing the spec regenerates the pages automatically.\n </Step>\n</Steps>\n\n## Example spec\n\nDo not have a document yet? This `openapi.yaml` points at [JSONPlaceholder](https://jsonplaceholder.typicode.com), a free public test API, so it works end to end - save it, set `openapi` to it, and the generated pages can send real requests:\n\n```yaml\nopenapi: 3.1.0\ninfo:\n title: JSONPlaceholder\n version: 1.0.0\nservers:\n - url: https://jsonplaceholder.typicode.com\ntags:\n - name: Todos\n - name: Posts\npaths:\n /todos/{id}:\n get:\n summary: Get a to-do\n tags: [Todos]\n parameters:\n - name: id\n in: path\n required: true\n schema:\n type: integer\n responses:\n \"200\":\n description: Just a demo of a to-do item\n /posts:\n post:\n summary: Create a post\n tags: [Posts]\n requestBody:\n required: true\n content:\n application/json:\n example:\n title: Hello\n body: Sent from the docs\n userId: 1\n responses:\n \"201\":\n description: Just a demo of the created post\n```\n\nEach part maps to something in the playground: `servers` sets the request target - and the only host the proxy will call - `tags` group endpoints in the sidebar, and `parameters` and `requestBody` become the inputs (adding a `securitySchemes` entry would produce authentication fields). Doccupine reads OpenAPI 3.0 and 3.1; see the [OpenAPI specification](https://spec.openapis.org) for the full format.\n\n## What gets generated\n\nThe generated `/api-reference` index lists every operation with a direct link, grouped by API and tag. Each operation also gets its own page under `/api-reference/{tag}/{operation}`, showing:\n\n<Field value=\"Parameters\" type=\"path, query, header, cookie\">\nEach parameter is rendered with its name, type, and whether it is required, grouped into a collapsible section with an input to fill in.\n</Field>\n\n<Field value=\"Request body\" type=\"editable\">\nA JSON editor prefilled from the schema's example, ready to tweak and send.\n</Field>\n\n<Field value=\"Authentication\" type=\"from securitySchemes\">\nInputs for the endpoint's security schemes - API keys, bearer tokens, or basic auth - generated from the document.\n</Field>\n\n<Field value=\"Response\" type=\"live\">\nThe real status, timing, and body from your API, rendered to match its content type.\n</Field>\n\n## Embedding a single endpoint\n\nTo mix prose and a live endpoint on a hand-written page, reference an operation from the page's frontmatter with `openapi`. Use `METHOD /path` or an `operationId`:\n\n```mdx\n---\ntitle: \"Create a post\"\nopenapi: \"POST /posts\"\n---\n\nPosts are created for a user. The playground above is fully live - fill in the\nbody and send a real request.\n```\n\nDoccupine renders that endpoint's playground above your prose. If the reference does not match any operation in your document, the page still renders its prose and a warning is logged.\n\n## Running requests\n\nRequests run one of two ways, and readers can switch between them:\n\n<Callout type=\"note\">\n**Proxy (default).** The request is forwarded server-side, so it works even when the target API blocks cross-origin browser calls. **Direct.** The browser calls the API itself - useful when the API allows CORS and you want requests to never leave the reader's machine.\n</Callout>\n\nThe proxy is deliberately locked down. It only forwards to servers declared in your OpenAPI document and refuses private, internal, metadata, and reserved network addresses, including IPv4 destinations represented through IPv6 translation ranges. An explicitly declared loopback server such as `http://localhost:4000` is available only outside production for local development and tests; production always blocks loopback and every other private target even when the spec declares one. Request URLs, headers, and bodies are never logged, so API keys a reader enters are not written anywhere. On a [password-protected site](/authentication), the proxy also requires the visitor's unlocked session, so it cannot be called anonymously.\n\nProxy requests are rate limited per trusted client address on recognized hosting platforms. Unknown and self-hosted proxy setups share one fallback bucket rather than trusting spoofable forwarding headers; use your trusted edge or a shared rate-limit store when those deployments need accurate per-client limits.\n\n<Callout type=\"warning\">\nKeys and tokens a reader types are used only to make the request. Turn on \"Show secrets\" to reveal them in the generated code snippets; they are redacted by default.\n</Callout>\n\n## Responses and snippets\n\nResponses render to match their type: images and video play inline, everything else is shown as a formatted, syntax-highlighted body. Alongside the response, the playground generates ready-to-run **cURL**, **JavaScript**, and **Python** snippets for the exact request you built.\n\n## Documenting more than one API\n\nPass an array to document several APIs at once. Each spec becomes its own namespaced section:\n\n```json\n{\n \"openapi\": [\n { \"name\": \"public\", \"file\": \"specs/public.yaml\" },\n { \"name\": \"admin\", \"file\": \"specs/admin.yaml\" }\n ]\n}\n```\n";
@@ -35,7 +35,7 @@ Press **Try it** below to open the playground, tweak the request body, and send
35
35
  \`\`\`
36
36
  </Step>
37
37
  <Step title="Run Doccupine.">
38
- On the next build (or live, while watching) Doccupine parses the document, resolves every \`$ref\`, and writes an endpoint page for each operation.
38
+ On the next build (or live, while watching) Doccupine parses the document and writes an endpoint page for each operation. Local \`$ref\` files must stay inside the configured spec's directory, use \`.json\`, \`.yaml\`, or \`.yml\`, and cannot be dotfiles or live inside dot-directories.
39
39
  </Step>
40
40
  <Step title="Open the API Reference section.">
41
41
  Endpoints appear in the sidebar grouped by their OpenAPI tag. Editing the spec regenerates the pages automatically.
@@ -91,7 +91,7 @@ Each part maps to something in the playground: \`servers\` sets the request targ
91
91
 
92
92
  ## What gets generated
93
93
 
94
- Every operation becomes its own page under \`/api-reference/{tag}/{operation}\`, showing:
94
+ The generated \`/api-reference\` index lists every operation with a direct link, grouped by API and tag. Each operation also gets its own page under \`/api-reference/{tag}/{operation}\`, showing:
95
95
 
96
96
  <Field value="Parameters" type="path, query, header, cookie">
97
97
  Each parameter is rendered with its name, type, and whether it is required, grouped into a collapsible section with an input to fill in.
@@ -133,7 +133,9 @@ Requests run one of two ways, and readers can switch between them:
133
133
  **Proxy (default).** The request is forwarded server-side, so it works even when the target API blocks cross-origin browser calls. **Direct.** The browser calls the API itself - useful when the API allows CORS and you want requests to never leave the reader's machine.
134
134
  </Callout>
135
135
 
136
- The proxy is deliberately locked down. It only forwards to the servers declared in your OpenAPI document, refuses to reach private or internal network addresses, and never logs request URLs, headers, or bodies - so API keys a reader enters are not written anywhere.
136
+ The proxy is deliberately locked down. It only forwards to servers declared in your OpenAPI document and refuses private, internal, metadata, and reserved network addresses, including IPv4 destinations represented through IPv6 translation ranges. An explicitly declared loopback server such as \`http://localhost:4000\` is available only outside production for local development and tests; production always blocks loopback and every other private target even when the spec declares one. Request URLs, headers, and bodies are never logged, so API keys a reader enters are not written anywhere. On a [password-protected site](/authentication), the proxy also requires the visitor's unlocked session, so it cannot be called anonymously.
137
+
138
+ Proxy requests are rate limited per trusted client address on recognized hosting platforms. Unknown and self-hosted proxy setups share one fallback bucket rather than trusting spoofable forwarding headers; use your trusted edge or a shared rate-limit store when those deployments need accurate per-client limits.
137
139
 
138
140
  <Callout type="warning">
139
141
  Keys and tokens a reader types are used only to make the request. Turn on "Show secrets" to reveal them in the generated code snippets; they are redacted by default.
@@ -1 +1 @@
1
- export declare const authenticationMdxTemplate = "---\ntitle: \"Authentication\"\ndescription: \"Password protect your documentation site with a single environment variable that gates pages, content APIs, and search crawlers behind a shared password.\"\ndate: \"2026-07-01\"\ncategory: \"Deployment\"\ncategoryOrder: 4\norder: 2\n---\n# Authentication\n\nKeep your documentation private by putting the whole site behind a shared password. Set one environment variable and Doccupine gates every page behind a login screen, blocks the content APIs, and hides the site from search engines - no accounts, no database, no extra services.\n\n## Enabling password protection\n\nSet `SITE_PASSWORD` in your environment (for local development, add it to `.env`):\n\n```bash\nSITE_PASSWORD=choose-a-strong-shared-password\n```\n\nThat is the only setting. Everyone who visits the site shares this single password.\n\n<Callout type=\"note\">\n When `SITE_PASSWORD` is unset or empty, the site is fully public and behaves exactly as before. Removing the variable turns protection off again.\n</Callout>\n\n## What gets protected\n\nWhile a password is set, protection is enforced across three layers:\n\n- **Pages**: Every page renders a login screen instead of your documentation until the visitor enters the correct password.\n- **Content APIs**: The AI chat (`/api/rag`) and search (`/api/search`) endpoints return `401 Unauthorized` without a valid session, so the docs cannot be scraped around the login screen.\n- **Search engines and crawlers**: `robots.txt` disallows all crawlers, every page ships a `noindex, nofollow` meta tag, and responses carry an `X-Robots-Tag: noindex, nofollow` header.\n\n<Callout type=\"note\">\n The [MCP server](/model-context-protocol) keeps its own authentication through the `DOCS_API_KEY` bearer token and is not affected by `SITE_PASSWORD`. Set both when you want the docs and the MCP endpoint locked down.\n</Callout>\n\n## How it works\n\nWhen a visitor submits the correct password, Doccupine sets a signed, `httpOnly` cookie that unlocks the site for 30 days. The cookie never stores the password itself - it holds an HMAC derived from it - and it is checked in constant time to avoid leaking information through timing.\n\nBecause the check reads `SITE_PASSWORD` at request time, you can turn protection on or off by changing the environment variable and redeploying. No rebuild of your content is required.\n\n## Security notes\n\n- **Use a strong password.** It is shared by everyone with access, so treat it like any other shared secret and rotate it when needed.\n- **Serve over HTTPS in production.** The session cookie is marked `secure` in production, so it is only sent over encrypted connections.\n- **Brute-force protection.** Password attempts are rate limited by IP address to slow down guessing.\n- **Rotating the password.** Changing `SITE_PASSWORD` invalidates every existing session immediately - visitors will need to enter the new password.\n\n<Callout type=\"warning\">\n A shared password is meant for lightweight gating - private previews, internal docs, or work-in-progress sites. For per-user access control or audit trails, put the site behind your own identity provider or a hosting platform's access controls.\n</Callout>\n\n## Behavior\n\n- **Runtime toggle**: Protection is controlled entirely by the `SITE_PASSWORD` environment variable, evaluated on each request.\n- **Graceful default**: With no password set, nothing changes - the site stays public and fully indexable.\n- **Session length**: A successful login lasts 30 days before the visitor is asked to sign in again.\n\n## Example\n\nProtect a staging deployment while it is being reviewed:\n\n```bash\nSITE_PASSWORD=preview-2026\nNEXT_PUBLIC_SITE_URL=https://staging.example.com\n```\n\nWhen you are ready to launch publicly, remove `SITE_PASSWORD` and redeploy. The login screen disappears, crawlers are welcomed back, and your [sitemap](/deployment-and-hosting) is advertised again.";
1
+ export declare const authenticationMdxTemplate = "---\ntitle: \"Authentication\"\ndescription: \"Password protect your documentation site with a single environment variable that gates pages, content APIs, and search crawlers behind a shared password.\"\ndate: \"2026-07-01\"\ncategory: \"Deployment\"\ncategoryOrder: 4\norder: 2\n---\n# Authentication\n\nKeep your documentation private by putting the whole site behind a shared password. Set one environment variable and Doccupine gates every page behind a login screen, blocks the content APIs, and hides the site from search engines - no accounts, no database, no extra services.\n\n## Enabling password protection\n\nSet `SITE_PASSWORD` in your environment (for local development, add it to `.env`):\n\n```bash\nSITE_PASSWORD=choose-a-strong-shared-password\n```\n\nThat is the only setting. Everyone who visits the site shares this single password.\n\n<Callout type=\"note\">\n When `SITE_PASSWORD` is unset or empty, the site is fully public and behaves exactly as before. Removing the variable turns protection off again.\n</Callout>\n\n## What gets protected\n\nWhile a password is set, protection is enforced across three layers:\n\n- **Pages**: Every page renders a login screen instead of your documentation until the visitor enters the correct password.\n- **Content APIs**: The AI chat (`/api/rag`), search (`/api/search`), and [API playground](/api-playground) proxy (`/api/playground`) endpoints return `401 Unauthorized` without a valid session. The docs cannot be scraped around the login screen, and the proxy cannot be used to relay requests on behalf of an anonymous visitor. Each route re-checks the session itself, so a direct invocation is refused even when it does not pass through the middleware.\n- **Search engines and crawlers**: `robots.txt` disallows all crawlers, every page ships a `noindex, nofollow` meta tag, and responses carry an `X-Robots-Tag: noindex, nofollow` header.\n\n<Callout type=\"note\">\n The [MCP server](/model-context-protocol) uses `DOCS_API_KEY` bearer authentication when that variable is set. Otherwise, a password-protected site requires the normal gate session for MCP too, so the endpoint cannot bypass `SITE_PASSWORD`.\n</Callout>\n\nThe AI endpoint also supports `RAG_API_KEY` for authenticated server-to-server access on public sites. Because the browser cannot safely hold that secret, use `SITE_PASSWORD` rather than `RAG_API_KEY` when authenticated browser visitors should use the built-in assistant.\n\n## How it works\n\nWhen a visitor submits the correct password, Doccupine sets a signed, `httpOnly` cookie that unlocks the site for 30 days. The cookie never stores the password itself - it holds an HMAC derived from it - and it is checked in constant time to avoid leaking information through timing.\n\nBecause the check reads `SITE_PASSWORD` at request time, you can turn protection on or off by changing the environment variable and redeploying. No rebuild of your content is required.\n\n## Security notes\n\n- **Use a strong password.** It is shared by everyone with access, so treat it like any other shared secret and rotate it when needed.\n- **Serve over HTTPS in production.** The session cookie is marked `secure` in production, so it is only sent over encrypted connections.\n- **Brute-force protection.** On recognized hosting platforms, password attempts are rate limited by the platform's trusted client address. Unknown and self-hosted proxy setups use one shared fallback bucket rather than trusting a spoofable forwarding header; configure a trusted edge limiter for accurate per-client limits there.\n- **Rotating the password.** Changing `SITE_PASSWORD` invalidates every existing session immediately - visitors will need to enter the new password.\n\n<Callout type=\"warning\">\n A shared password is meant for lightweight gating - private previews, internal docs, or work-in-progress sites. For per-user access control or audit trails, put the site behind your own identity provider or a hosting platform's access controls.\n</Callout>\n\n## Behavior\n\n- **Runtime toggle**: Protection is controlled entirely by the `SITE_PASSWORD` environment variable, evaluated on each request.\n- **Graceful default**: With no password set, nothing changes - the site stays public and fully indexable.\n- **Session length**: A successful login lasts 30 days before the visitor is asked to sign in again.\n\n## Example\n\nProtect a staging deployment while it is being reviewed:\n\n```bash\nSITE_PASSWORD=preview-2026\nNEXT_PUBLIC_SITE_URL=https://staging.example.com\n```\n\nWhen you are ready to launch publicly, remove `SITE_PASSWORD` and redeploy. The login screen disappears, crawlers are welcomed back, and your [sitemap](/deployment-and-hosting) is advertised again.";
@@ -29,13 +29,15 @@ That is the only setting. Everyone who visits the site shares this single passwo
29
29
  While a password is set, protection is enforced across three layers:
30
30
 
31
31
  - **Pages**: Every page renders a login screen instead of your documentation until the visitor enters the correct password.
32
- - **Content APIs**: The AI chat (\`/api/rag\`) and search (\`/api/search\`) endpoints return \`401 Unauthorized\` without a valid session, so the docs cannot be scraped around the login screen.
32
+ - **Content APIs**: The AI chat (\`/api/rag\`), search (\`/api/search\`), and [API playground](/api-playground) proxy (\`/api/playground\`) endpoints return \`401 Unauthorized\` without a valid session. The docs cannot be scraped around the login screen, and the proxy cannot be used to relay requests on behalf of an anonymous visitor. Each route re-checks the session itself, so a direct invocation is refused even when it does not pass through the middleware.
33
33
  - **Search engines and crawlers**: \`robots.txt\` disallows all crawlers, every page ships a \`noindex, nofollow\` meta tag, and responses carry an \`X-Robots-Tag: noindex, nofollow\` header.
34
34
 
35
35
  <Callout type="note">
36
- The [MCP server](/model-context-protocol) keeps its own authentication through the \`DOCS_API_KEY\` bearer token and is not affected by \`SITE_PASSWORD\`. Set both when you want the docs and the MCP endpoint locked down.
36
+ The [MCP server](/model-context-protocol) uses \`DOCS_API_KEY\` bearer authentication when that variable is set. Otherwise, a password-protected site requires the normal gate session for MCP too, so the endpoint cannot bypass \`SITE_PASSWORD\`.
37
37
  </Callout>
38
38
 
39
+ The AI endpoint also supports \`RAG_API_KEY\` for authenticated server-to-server access on public sites. Because the browser cannot safely hold that secret, use \`SITE_PASSWORD\` rather than \`RAG_API_KEY\` when authenticated browser visitors should use the built-in assistant.
40
+
39
41
  ## How it works
40
42
 
41
43
  When a visitor submits the correct password, Doccupine sets a signed, \`httpOnly\` cookie that unlocks the site for 30 days. The cookie never stores the password itself - it holds an HMAC derived from it - and it is checked in constant time to avoid leaking information through timing.
@@ -46,7 +48,7 @@ Because the check reads \`SITE_PASSWORD\` at request time, you can turn protecti
46
48
 
47
49
  - **Use a strong password.** It is shared by everyone with access, so treat it like any other shared secret and rotate it when needed.
48
50
  - **Serve over HTTPS in production.** The session cookie is marked \`secure\` in production, so it is only sent over encrypted connections.
49
- - **Brute-force protection.** Password attempts are rate limited by IP address to slow down guessing.
51
+ - **Brute-force protection.** On recognized hosting platforms, password attempts are rate limited by the platform's trusted client address. Unknown and self-hosted proxy setups use one shared fallback bucket rather than trusting a spoofable forwarding header; configure a trusted edge limiter for accurate per-client limits there.
50
52
  - **Rotating the password.** Changing \`SITE_PASSWORD\` invalidates every existing session immediately - visitors will need to enter the new password.
51
53
 
52
54
  <Callout type="warning">
@@ -1 +1 @@
1
- export declare const commandsMdxTemplate = "---\ntitle: \"Commands\"\ndescription: \"In this page, you can find all the commands available in Doccupine CLI.\"\ndate: \"2026-02-19\"\ncategory: \"Getting Started\"\ncategoryOrder: 0\norder: 2\n---\n# Commands\n\nIn this page, you can find all the commands available in Doccupine CLI.\n\n## Run Doccupine CLI\n\nCreate a new directory for your project and navigate to it in your terminal. Run the following command to create a new Doccupine project:\n\n```bash\nnpx doccupine\n```\n\nOnce you run the command, Doccupine will ask you to select a directory to store your MDX files. Choose the directory where you want to create your documentation files.\nAfter selecting the directory, Doccupine will ask you to enter the name of the directory for the generated website. Enter the name of the directory where you want to create your website.\nFinally, Doccupine will ask for an optional path to an OpenAPI document. Leave it blank to skip, or point it at a `.yaml`, `.yml`, or `.json` spec to generate an interactive [API Playground](/api-playground) from your API.\n\nThis will start the development server on port 3000. Open your browser and navigate to http://localhost:3000 to view your documentation.\n\n## Options\n\n| Flag | Description |\n| --------------- | -------------------------------------------------------------------- |\n| `--port <port>` | Port for the dev server (default: `3000`). Auto-increments if taken. |\n| `--verbose` | Show all Next.js output including compilation details. |\n| `--reset` | Re-prompt for watch/output directories and the OpenAPI spec path. |\n\n## Verbose mode\n\n```bash\nnpx doccupine --verbose\n```\n\n<Callout type=\"note\">\n This will show Next.js output in the terminal, providing detailed logs useful for debugging during development.\n</Callout>\n\n## Generate the website\n\n```bash\nnpx doccupine build\n```\n\nThis scaffolds the Next.js app from your MDX files without starting the development server. To produce a production build, run `npm install && npm run build` in the generated output directory.\n\n## Show current configuration\n\n```bash\nnpx doccupine config --show\n```\n\nThis will show the current configuration for Doccupine.\n\n## Reset configuration\n\n```bash\nnpx doccupine config --reset\n```\n\nThis will reset the current configuration for Doccupine.";
1
+ export declare const commandsMdxTemplate = "---\ntitle: \"Commands\"\ndescription: \"In this page, you can find all the commands available in Doccupine CLI.\"\ndate: \"2026-02-19\"\ncategory: \"Getting Started\"\ncategoryOrder: 0\norder: 2\n---\n# Commands\n\nIn this page, you can find all the commands available in Doccupine CLI.\n\n## Run Doccupine CLI\n\nCreate a new directory for your project and navigate to it in your terminal. Run the following command to create a new Doccupine project:\n\n```bash\nnpx doccupine\n```\n\nOnce you run the command, Doccupine will ask you to select a directory to store your MDX files. Choose the directory where you want to create your documentation files.\nAfter selecting the directory, Doccupine will ask you to enter the name of the directory for the generated website. Enter the name of the directory where you want to create your website.\nFinally, Doccupine will ask for an optional path to an OpenAPI document. Leave it blank to skip, or point it at a `.yaml`, `.yml`, or `.json` spec to generate an interactive [API Playground](/api-playground) from your API.\n\nThis will start the development server on port 3000. Open your browser and navigate to http://localhost:3000 to view your documentation.\n\n## Options\n\n| Flag | Description |\n| -------------------------- | --------------------------------------------------------------------------- |\n| `--port <port>` | Port for the dev server (default: `3000`). Auto-increments if taken. |\n| `--verbose` | Show all Next.js output including compilation details. |\n| `--reset` | Re-prompt for watch/output directories and the OpenAPI spec path. |\n| `--skip-install` | Always skip dependency installation before starting the development server. |\n| `--package-manager <name>` | Use `pnpm` or `npm` for the generated app instead of auto-detection. |\n\n<Callout type=\"warning\">\n The watch and output directories must not overlap. The output directory must be empty, contain only local metadata such as `.DS_Store` or `.env.local`, or already be owned by Doccupine. This prevents the generator from overwriting another project. If an older `doccupine.json` no longer validates, run `doccupine config --reset`. Generation also reports a validation error, instead of letting one page overwrite another, when two source files resolve to the same route.\n</Callout>\n\nStarter documentation is created only when the selected source directory contains no MDX files. Existing pages are never replaced just because `index.mdx` is missing. Frontmatter must use the normal YAML `---` delimiter; language-tagged executable frontmatter is rejected.\n\nDoccupine records generated route and Markdown-mirror ownership in `.doccupine-artifacts.json` inside the generated app. Watch-mode renames and deletes use that registry rather than guessing routes from filenames, so section moves remove only files owned by the changed source.\n\n## Dependency installation\n\nThe first run installs the generated app's dependencies. After that, Doccupine records a fingerprint of the generated `package.json` and the package manager in `.doccupine-install` and reinstalls only when that fingerprint changes or `node_modules` is missing - later runs start the dev server straight away. Pass `--skip-install` to skip the check entirely, for example when you manage dependencies yourself.\n\n## Verbose mode\n\n```bash\nnpx doccupine --verbose\n```\n\n<Callout type=\"note\">\n This will show Next.js output in the terminal, providing detailed logs useful for debugging during development.\n</Callout>\n\n## Generate the website\n\n```bash\nnpx doccupine build\n```\n\nYou can also use the equivalent `npx doccupine generate` command. These commands scaffold the Next.js app from your MDX files without installing dependencies or starting the development server. To produce a production build, install dependencies and run the generated app's `build` script.\n\n## Show current configuration\n\n```bash\nnpx doccupine config --show\n```\n\nThis will show the current configuration for Doccupine.\n\n## Reset configuration\n\n```bash\nnpx doccupine config --reset\n```\n\nThis will reset the current configuration for Doccupine.";