doccupine 0.0.146 → 0.0.148

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 (55) hide show
  1. package/README.md +11 -2
  2. package/dist/cli.d.ts +7 -0
  3. package/dist/cli.js +41 -0
  4. package/dist/generator/mdx-reconciliation-coordinator.d.ts +83 -0
  5. package/dist/generator/mdx-reconciliation-coordinator.js +471 -0
  6. package/dist/generator/page-renderer.js +18 -13
  7. package/dist/generator/secure-source-fs.js +5 -4
  8. package/dist/generator/site-artifacts.js +2 -2
  9. package/dist/generator/watch-coordinator.js +3 -2
  10. package/dist/index.js +8 -2
  11. package/dist/lib/layout.js +18 -10
  12. package/dist/lib/openapi-rendering.d.ts +17 -0
  13. package/dist/lib/openapi-rendering.js +193 -0
  14. package/dist/lib/openapi.d.ts +1 -7
  15. package/dist/lib/openapi.js +2 -192
  16. package/dist/lib/structures.js +2 -0
  17. package/dist/lib/utils.d.ts +14 -0
  18. package/dist/lib/utils.js +30 -8
  19. package/dist/mdx-to-nextjs-generator.d.ts +2 -41
  20. package/dist/mdx-to-nextjs-generator.js +37 -469
  21. package/dist/templates/components/Chat.d.ts +1 -1
  22. package/dist/templates/components/Chat.js +226 -1457
  23. package/dist/templates/components/SearchDocs.d.ts +1 -1
  24. package/dist/templates/components/SearchDocs.js +20 -15
  25. package/dist/templates/components/SearchModalContent.d.ts +1 -1
  26. package/dist/templates/components/SearchModalContent.js +7 -1
  27. package/dist/templates/components/layout/ApiPlayground.d.ts +1 -1
  28. package/dist/templates/components/layout/ApiPlayground.js +14 -148
  29. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  30. package/dist/templates/components/layout/DocsComponents.js +3 -3
  31. package/dist/templates/components/layout/DocsNavigation.d.ts +1 -1
  32. package/dist/templates/components/layout/DocsNavigation.js +2 -3
  33. package/dist/templates/components/layout/Footer.d.ts +1 -1
  34. package/dist/templates/components/layout/Footer.js +2 -4
  35. package/dist/templates/components/layout/Header.d.ts +1 -1
  36. package/dist/templates/components/layout/Header.js +3 -3
  37. package/dist/templates/components/layout/StaticLinks.d.ts +1 -1
  38. package/dist/templates/components/layout/StaticLinks.js +2 -3
  39. package/dist/templates/env.example.d.ts +1 -1
  40. package/dist/templates/env.example.js +8 -0
  41. package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
  42. package/dist/templates/mdx/platform/analytics.mdx.js +13 -0
  43. package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
  44. package/dist/templates/mdx/platform/fonts-settings.mdx.js +16 -0
  45. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  46. package/dist/templates/mdx/platform/publishing.mdx.js +16 -1
  47. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
  48. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +17 -5
  49. package/dist/templates/next.config.js +40 -0
  50. package/dist/templates/package.js +11 -10
  51. package/dist/templates/prettierignore.d.ts +1 -1
  52. package/dist/templates/prettierignore.js +11 -0
  53. package/dist/templates/utils/apiPlayground.d.ts +1 -0
  54. package/dist/templates/utils/apiPlayground.js +149 -0
  55. package/package.json +3 -3
@@ -3,10 +3,30 @@ export const nextConfigTemplate = (analyticsConfig = null) => {
3
3
  if (!hasPostHog) {
4
4
  return `import type { NextConfig } from "next";
5
5
 
6
+ // Dev-only allowlist for reaching the dev server through a non-localhost
7
+ // hostname (a LAN IP, a Tailscale/VPN name, ...). Next blocks its dev
8
+ // resources - including the HMR socket Turbopack needs before it hydrates
9
+ // the page - for hosts it does not know, which leaves the site rendered but
10
+ // inert. Comma-separated hostnames, set via ALLOWED_DEV_ORIGINS in .env;
11
+ // production builds ignore it.
12
+ const allowedDevOrigins = (process.env.ALLOWED_DEV_ORIGINS ?? "")
13
+ .split(",")
14
+ .map((origin) => origin.trim())
15
+ .filter(Boolean);
16
+
6
17
  const nextConfig: NextConfig = {
18
+ ...(allowedDevOrigins.length > 0 ? { allowedDevOrigins } : {}),
7
19
  compiler: {
8
20
  styledComponents: true,
9
21
  },
22
+ // Type-checking runs through TypeScript 6's compiler API (the \`typescript\`
23
+ // dependency is aliased to @typescript/typescript6, whose only binary is
24
+ // \`tsc6\`). Next 16.3 defaults experimental.useTypeScriptCli to true, and
25
+ // that path requires a \`tsc\` bin, so builds fail with a "typescript is not
26
+ // installed" prompt unless the CLI path stays off.
27
+ experimental: {
28
+ useTypeScriptCli: false,
29
+ },
10
30
  // Trace the runtime-loaded corpus and precomputed embeddings index into the
11
31
  // serverless functions (dynamic fs reads are invisible to automatic tracing).
12
32
  outputFileTracingIncludes: {
@@ -42,10 +62,30 @@ export default nextConfig;
42
62
  const assetsHost = host.replace(".i.", "-assets.i.");
43
63
  return `import type { NextConfig } from "next";
44
64
 
65
+ // Dev-only allowlist for reaching the dev server through a non-localhost
66
+ // hostname (a LAN IP, a Tailscale/VPN name, ...). Next blocks its dev
67
+ // resources - including the HMR socket Turbopack needs before it hydrates
68
+ // the page - for hosts it does not know, which leaves the site rendered but
69
+ // inert. Comma-separated hostnames, set via ALLOWED_DEV_ORIGINS in .env;
70
+ // production builds ignore it.
71
+ const allowedDevOrigins = (process.env.ALLOWED_DEV_ORIGINS ?? "")
72
+ .split(",")
73
+ .map((origin) => origin.trim())
74
+ .filter(Boolean);
75
+
45
76
  const nextConfig: NextConfig = {
77
+ ...(allowedDevOrigins.length > 0 ? { allowedDevOrigins } : {}),
46
78
  compiler: {
47
79
  styledComponents: true,
48
80
  },
81
+ // Type-checking runs through TypeScript 6's compiler API (the \`typescript\`
82
+ // dependency is aliased to @typescript/typescript6, whose only binary is
83
+ // \`tsc6\`). Next 16.3 defaults experimental.useTypeScriptCli to true, and
84
+ // that path requires a \`tsc\` bin, so builds fail with a "typescript is not
85
+ // installed" prompt unless the CLI path stays off.
86
+ experimental: {
87
+ useTypeScriptCli: false,
88
+ },
49
89
  // Trace the runtime-loaded corpus and precomputed embeddings index into the
50
90
  // serverless functions (dynamic fs reads are invisible to automatic tracing).
51
91
  outputFileTracingIncludes: {
@@ -8,6 +8,7 @@ export const packageJsonTemplate = JSON.stringify({
8
8
  start: "next start",
9
9
  lint: "eslint .",
10
10
  format: "prettier --write .",
11
+ "format:check": "prettier --check .",
11
12
  "type-check": "tsgo --noEmit",
12
13
  },
13
14
  dependencies: {
@@ -18,14 +19,14 @@ export const packageJsonTemplate = JSON.stringify({
18
19
  "@mdx-js/react": "^3.1.1",
19
20
  "@modelcontextprotocol/sdk": "^1.30.0",
20
21
  "beautiful-mermaid": "^1.1.3",
21
- "cherry-styled-components": "^0.2.12",
22
+ "cherry-styled-components": "^0.2.14",
22
23
  langchain: "^1.5.4",
23
24
  "lucide-react": "^1.28.0",
24
25
  minisearch: "^7.2.0",
25
- next: "16.2.12",
26
+ next: "16.3.0",
26
27
  "next-mdx-remote": "^6.0.0",
27
- "posthog-js": "^1.409.0",
28
- "posthog-node": "^5.47.0",
28
+ "posthog-js": "^1.410.7",
29
+ "posthog-node": "^5.47.8",
29
30
  react: "19.2.8",
30
31
  "react-dom": "19.2.8",
31
32
  "rehype-highlight": "^7.0.2",
@@ -37,22 +38,22 @@ export const packageJsonTemplate = JSON.stringify({
37
38
  zod: "^4.4.3",
38
39
  },
39
40
  devDependencies: {
40
- "@next/env": "16.2.12",
41
- "@next/eslint-plugin-next": "16.2.12",
41
+ "@next/env": "16.3.0",
42
+ "@next/eslint-plugin-next": "16.3.0",
42
43
  "@types/node": "^26",
43
44
  "@types/react": "^19",
44
45
  "@types/react-dom": "^19",
45
- "@typescript-eslint/eslint-plugin": "^8.65.0",
46
- "@typescript-eslint/parser": "^8.65.0",
46
+ "@typescript-eslint/eslint-plugin": "^8.66.0",
47
+ "@typescript-eslint/parser": "^8.66.0",
47
48
  "@typescript/native-preview": "^7.0.0-dev.20260707.2",
48
49
  eslint: "^10",
49
50
  "eslint-plugin-import": "^2.32.0",
50
51
  "eslint-plugin-jsx-a11y": "^6.10.2",
51
52
  "eslint-plugin-react": "^7.37.5",
52
53
  "eslint-plugin-react-hooks": "^7.1.1",
53
- globals: "^17.8.0",
54
+ globals: "^17.9.0",
54
55
  prettier: "^3.9.6",
55
- tsx: "^4.23.1",
56
+ tsx: "^4.23.5",
56
57
  typescript: "npm:@typescript/typescript6@^6.0.2",
57
58
  },
58
59
  }, null, 2) + "\n";
@@ -1 +1 @@
1
- export declare const prettierignoreTemplate = "node_modules\nconvex/_generated\npublic\npackage.json\npackage-lock.json\npnpm-lock.yaml\npnpm-workspace.yaml\nservices/mcp/docs-index.json\n.doccupine-*\n";
1
+ export declare const prettierignoreTemplate = "node_modules\nconvex/_generated\npublic\npackage.json\npackage-lock.json\npnpm-lock.yaml\npnpm-workspace.yaml\nservices/mcp/docs-index.json\n.doccupine-*\n\n# Mirrored verbatim from the project root, so their formatting is the author's\n# choice rather than generated output. Reformatting them here would also make\n# the copy differ from the source it is fingerprinted against.\nanalytics.json\nconfig.json\nfonts.json\nlinks.json\nnavigation.json\nsections.json\ntheme.json\n";
@@ -7,4 +7,15 @@ pnpm-lock.yaml
7
7
  pnpm-workspace.yaml
8
8
  services/mcp/docs-index.json
9
9
  .doccupine-*
10
+
11
+ # Mirrored verbatim from the project root, so their formatting is the author's
12
+ # choice rather than generated output. Reformatting them here would also make
13
+ # the copy differ from the source it is fingerprinted against.
14
+ analytics.json
15
+ config.json
16
+ fonts.json
17
+ links.json
18
+ navigation.json
19
+ sections.json
20
+ theme.json
10
21
  `;
@@ -0,0 +1 @@
1
+ export declare const apiPlaygroundUtilsTemplate = "import type {\n OperationDescriptor,\n ParameterDescriptor,\n ServerDescriptor,\n} from \"@/types/openapi\";\n\nexport interface PlaygroundResponse {\n status: number;\n statusText: string;\n headers: Record<string, string>;\n contentType: string | null;\n bodyEncoding: \"utf8\" | \"base64\";\n body: string;\n truncated: boolean;\n byteLength: number;\n durationMs: number;\n}\n\nexport interface BuiltRequest {\n url: string;\n headers: Record<string, string>;\n body: string | null;\n secretHeaderNames: string[];\n}\n\nexport function schemaTypeLabel(schema: unknown): string {\n if (schema && typeof schema === \"object\") {\n const record = schema as { type?: unknown; format?: unknown };\n if (typeof record.type === \"string\") {\n return typeof record.format === \"string\"\n ? record.type + \" (\" + record.format + \")\"\n : record.type;\n }\n }\n return \"string\";\n}\n\nexport function serverBase(server: ServerDescriptor | undefined): string {\n if (!server) return \"\";\n let url = server.url;\n const variables = server.variables;\n if (variables) {\n for (const key of Object.keys(variables)) {\n url = url.split(\"{\" + key + \"}\").join(variables[key].default);\n }\n }\n while (url.endsWith(\"/\")) url = url.slice(0, -1);\n return url;\n}\n\nexport function applyPathParams(\n template: string,\n values: Record<string, string>,\n): string {\n let result = template;\n for (const key of Object.keys(values)) {\n result = result\n .split(\"{\" + key + \"}\")\n .join(encodeURIComponent(values[key]));\n }\n return result;\n}\n\nexport function firstJsonExample(op: OperationDescriptor): {\n contentType: string;\n text: string;\n} | null {\n if (!op.requestBody || op.requestBody.content.length === 0) return null;\n const media =\n op.requestBody.content.find((m) => m.contentType.includes(\"json\")) ??\n op.requestBody.content[0];\n let text = \"\";\n if (media.example !== undefined) {\n try {\n text = JSON.stringify(media.example, null, 2);\n } catch {\n text = \"\";\n }\n }\n return { contentType: media.contentType, text };\n}\n\nexport function classifyResponse(\n contentType: string | null,\n): \"image\" | \"video\" | \"audio\" | \"text\" | \"binary\" {\n if (!contentType) return \"text\";\n const t = contentType.toLowerCase();\n if (t.startsWith(\"image/\") && !t.includes(\"svg\")) return \"image\";\n if (t.startsWith(\"video/\")) return \"video\";\n if (t.startsWith(\"audio/\")) return \"audio\";\n if (\n t.includes(\"json\") ||\n t.startsWith(\"text/\") ||\n t.includes(\"xml\") ||\n t.includes(\"svg\") ||\n t.includes(\"html\") ||\n t.includes(\"javascript\") ||\n t.includes(\"csv\")\n ) {\n return \"text\";\n }\n return \"binary\";\n}\n\nexport function codeLanguage(contentType: string | null): string {\n if (!contentType) return \"text\";\n const t = contentType.toLowerCase();\n if (t.includes(\"json\")) return \"json\";\n if (t.includes(\"html\")) return \"html\";\n if (t.includes(\"xml\") || t.includes(\"svg\")) return \"xml\";\n if (t.includes(\"javascript\")) return \"javascript\";\n return \"text\";\n}\n\nexport function prettyBody(contentType: string | null, body: string): string {\n if (contentType && contentType.toLowerCase().includes(\"json\")) {\n try {\n return JSON.stringify(JSON.parse(body), null, 2);\n } catch {\n return body;\n }\n }\n return body;\n}\n\nexport function bufferToBase64(buffer: ArrayBuffer): string {\n let binary = \"\";\n const bytes = new Uint8Array(buffer);\n const chunk = 0x8000;\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n return btoa(binary);\n}\n\nexport const LOCATIONS: ParameterDescriptor[\"in\"][] = [\n \"path\",\n \"query\",\n \"header\",\n \"cookie\",\n];\n\nexport const LOCATION_TITLES: Record<string, string> = {\n path: \"Path\",\n query: \"Query\",\n header: \"Headers\",\n cookie: \"Cookies\",\n};\n";
@@ -0,0 +1,149 @@
1
+ export const apiPlaygroundUtilsTemplate = `import type {
2
+ OperationDescriptor,
3
+ ParameterDescriptor,
4
+ ServerDescriptor,
5
+ } from "@/types/openapi";
6
+
7
+ export interface PlaygroundResponse {
8
+ status: number;
9
+ statusText: string;
10
+ headers: Record<string, string>;
11
+ contentType: string | null;
12
+ bodyEncoding: "utf8" | "base64";
13
+ body: string;
14
+ truncated: boolean;
15
+ byteLength: number;
16
+ durationMs: number;
17
+ }
18
+
19
+ export interface BuiltRequest {
20
+ url: string;
21
+ headers: Record<string, string>;
22
+ body: string | null;
23
+ secretHeaderNames: string[];
24
+ }
25
+
26
+ export function schemaTypeLabel(schema: unknown): string {
27
+ if (schema && typeof schema === "object") {
28
+ const record = schema as { type?: unknown; format?: unknown };
29
+ if (typeof record.type === "string") {
30
+ return typeof record.format === "string"
31
+ ? record.type + " (" + record.format + ")"
32
+ : record.type;
33
+ }
34
+ }
35
+ return "string";
36
+ }
37
+
38
+ export function serverBase(server: ServerDescriptor | undefined): string {
39
+ if (!server) return "";
40
+ let url = server.url;
41
+ const variables = server.variables;
42
+ if (variables) {
43
+ for (const key of Object.keys(variables)) {
44
+ url = url.split("{" + key + "}").join(variables[key].default);
45
+ }
46
+ }
47
+ while (url.endsWith("/")) url = url.slice(0, -1);
48
+ return url;
49
+ }
50
+
51
+ export function applyPathParams(
52
+ template: string,
53
+ values: Record<string, string>,
54
+ ): string {
55
+ let result = template;
56
+ for (const key of Object.keys(values)) {
57
+ result = result
58
+ .split("{" + key + "}")
59
+ .join(encodeURIComponent(values[key]));
60
+ }
61
+ return result;
62
+ }
63
+
64
+ export function firstJsonExample(op: OperationDescriptor): {
65
+ contentType: string;
66
+ text: string;
67
+ } | null {
68
+ if (!op.requestBody || op.requestBody.content.length === 0) return null;
69
+ const media =
70
+ op.requestBody.content.find((m) => m.contentType.includes("json")) ??
71
+ op.requestBody.content[0];
72
+ let text = "";
73
+ if (media.example !== undefined) {
74
+ try {
75
+ text = JSON.stringify(media.example, null, 2);
76
+ } catch {
77
+ text = "";
78
+ }
79
+ }
80
+ return { contentType: media.contentType, text };
81
+ }
82
+
83
+ export function classifyResponse(
84
+ contentType: string | null,
85
+ ): "image" | "video" | "audio" | "text" | "binary" {
86
+ if (!contentType) return "text";
87
+ const t = contentType.toLowerCase();
88
+ if (t.startsWith("image/") && !t.includes("svg")) return "image";
89
+ if (t.startsWith("video/")) return "video";
90
+ if (t.startsWith("audio/")) return "audio";
91
+ if (
92
+ t.includes("json") ||
93
+ t.startsWith("text/") ||
94
+ t.includes("xml") ||
95
+ t.includes("svg") ||
96
+ t.includes("html") ||
97
+ t.includes("javascript") ||
98
+ t.includes("csv")
99
+ ) {
100
+ return "text";
101
+ }
102
+ return "binary";
103
+ }
104
+
105
+ export function codeLanguage(contentType: string | null): string {
106
+ if (!contentType) return "text";
107
+ const t = contentType.toLowerCase();
108
+ if (t.includes("json")) return "json";
109
+ if (t.includes("html")) return "html";
110
+ if (t.includes("xml") || t.includes("svg")) return "xml";
111
+ if (t.includes("javascript")) return "javascript";
112
+ return "text";
113
+ }
114
+
115
+ export function prettyBody(contentType: string | null, body: string): string {
116
+ if (contentType && contentType.toLowerCase().includes("json")) {
117
+ try {
118
+ return JSON.stringify(JSON.parse(body), null, 2);
119
+ } catch {
120
+ return body;
121
+ }
122
+ }
123
+ return body;
124
+ }
125
+
126
+ export function bufferToBase64(buffer: ArrayBuffer): string {
127
+ let binary = "";
128
+ const bytes = new Uint8Array(buffer);
129
+ const chunk = 0x8000;
130
+ for (let i = 0; i < bytes.length; i += chunk) {
131
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
132
+ }
133
+ return btoa(binary);
134
+ }
135
+
136
+ export const LOCATIONS: ParameterDescriptor["in"][] = [
137
+ "path",
138
+ "query",
139
+ "header",
140
+ "cookie",
141
+ ];
142
+
143
+ export const LOCATION_TITLES: Record<string, string> = {
144
+ path: "Path",
145
+ query: "Query",
146
+ header: "Headers",
147
+ cookie: "Cookies",
148
+ };
149
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doccupine",
3
- "version": "0.0.146",
3
+ "version": "0.0.148",
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": {
@@ -10,7 +10,7 @@
10
10
  "engines": {
11
11
  "node": ">=22.12.0"
12
12
  },
13
- "packageManager": "pnpm@11.18.0",
13
+ "packageManager": "pnpm@11.20.0",
14
14
  "scripts": {
15
15
  "clean": "node scripts/clean.mjs",
16
16
  "build": "pnpm clean && tsc",
@@ -48,7 +48,7 @@
48
48
  "commander": "^15.0.0",
49
49
  "fs-extra": "^11.4.0",
50
50
  "gray-matter": "^4.0.3",
51
- "next": "^16.2.12",
51
+ "next": "^16.3.0",
52
52
  "prompts": "^2.4.2",
53
53
  "react": "^19.2.8",
54
54
  "react-dom": "^19.2.8"