doccupine 0.0.146 → 0.0.147

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 (40) 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 +4 -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 +20 -691
  23. package/dist/templates/components/ChatStyles.d.ts +1 -0
  24. package/dist/templates/components/ChatStyles.js +695 -0
  25. package/dist/templates/components/layout/ApiPlayground.d.ts +1 -1
  26. package/dist/templates/components/layout/ApiPlayground.js +14 -148
  27. package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
  28. package/dist/templates/mdx/platform/analytics.mdx.js +13 -0
  29. package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
  30. package/dist/templates/mdx/platform/fonts-settings.mdx.js +16 -0
  31. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  32. package/dist/templates/mdx/platform/publishing.mdx.js +16 -1
  33. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
  34. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +17 -5
  35. package/dist/templates/package.js +3 -2
  36. package/dist/templates/prettierignore.d.ts +1 -1
  37. package/dist/templates/prettierignore.js +11 -0
  38. package/dist/templates/utils/apiPlayground.d.ts +1 -0
  39. package/dist/templates/utils/apiPlayground.js +149 -0
  40. package/package.json +1 -1
@@ -2,7 +2,7 @@ export const platformSelfUpdatingDocsMdxTemplate = `---
2
2
  title: "Agent Sync"
3
3
  description: "Agent Sync links documentation pages to the code they describe and rewrites them when that code changes, keeping your docs self-updating."
4
4
  date: "2026-07-24"
5
- updated: "2026-07-30"
5
+ updated: "2026-08-01"
6
6
  category: "Editing"
7
7
  categoryOrder: 1
8
8
  order: 2
@@ -18,7 +18,7 @@ You'll find it under **Agent Sync** in the project sidebar.
18
18
 
19
19
  | View | What it's for |
20
20
  | --------- | ----------------------------------------------------------------------------- |
21
- | **Agent** | Ask the agent to write or update documentation, and read its replies |
21
+ | **Agent** | Ask questions about your code, or ask the agent to write and update pages |
22
22
  | **Map** | Each page beside the sources it came from, with its sync state |
23
23
  | **Table** | The same information as a dense, sortable list |
24
24
  | **Drift** | The queue of pages whose sources have changed |
@@ -27,15 +27,25 @@ A badge on the sidebar link counts the pages currently waiting for attention.
27
27
 
28
28
  ## Asking the agent for docs
29
29
 
30
- The **Agent** view is a chat. Describe what you want documented, choose a **source repository** and a **scope** - the whole repo, a folder, or a single file - and the agent researches the code, plans the pages, and writes them.
30
+ The **Agent** view is a chat. Choose a **source repository** and a **scope** - the whole repo, a folder, or a single file - then either ask a question or ask for a change.
31
31
 
32
- Replies are threaded, so a follow-up builds on what came before:
32
+ **Questions are answered in the chat.** Ask what a module does, which pages cover a feature, or whether a guide still matches the code, and the agent reads the source and replies without touching your documentation:
33
+
34
+ > Which pages would break if we renamed the refresh-token endpoint?
35
+
36
+ **Asking for a change starts a run.** The agent researches the code, plans the pages, and writes them:
33
37
 
34
38
  > Document the auth module - cover sessions, refresh tokens and the error codes.
35
39
 
40
+ > Update the buttons page so it matches the current component.
41
+
42
+ Replies are threaded, so a follow-up builds on what came before - and agreeing to something the agent suggested is enough to start the work, without repeating yourself:
43
+
36
44
  > Now do the same for the CLI.
37
45
 
38
- Each turn shows the steps the agent took, the pages it changed, the sources it read, and what the run cost. You can switch between conversations, rename them, or start a fresh one.
46
+ A turn that changes documentation shows the steps the agent took, the pages it changed, the sources it read, and what the run cost. You can switch between conversations, rename them, or start a fresh one.
47
+
48
+ A run commits itself only when every page it wrote is set to auto-update and untouched by hand. Anything else is staged alongside your own edits and waits, and you can settle it from the conversation or from the project's [Publish](/platform/publishing) modal - either way, the other side is kept in step.
39
49
 
40
50
  <Callout type="note">
41
51
  An empty result is a valid answer. If the docs already describe the code accurately, the agent will say so rather than rewriting pages for the sake of it.
@@ -102,6 +112,8 @@ When a linked source changes, what happens next depends on the page:
102
112
 
103
113
  Each row on the Map and Table views has an **Auto-update this page when its source changes** toggle, so you can let routine reference pages look after themselves while a carefully worded overview page always waits for you.
104
114
 
115
+ The same settings decide what happens to a run you started yourself from the Agent view - auto-update is not only about drift. What differs is that a run writes one change set and commits or stages it as a unit: if any page in it resolves to review, the whole set waits. Publishing half a coherent change and leaving the rest behind would be worse than waiting for you.
116
+
105
117
  For anything in review, **Review update** opens the change set - the same diff view as [publishing](/platform/publishing) - and **Update from source** asks the agent to regenerate that one page on demand.
106
118
 
107
119
  <Callout type="warning">
@@ -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: {
@@ -24,8 +25,8 @@ export const packageJsonTemplate = JSON.stringify({
24
25
  minisearch: "^7.2.0",
25
26
  next: "16.2.12",
26
27
  "next-mdx-remote": "^6.0.0",
27
- "posthog-js": "^1.409.0",
28
- "posthog-node": "^5.47.0",
28
+ "posthog-js": "^1.409.5",
29
+ "posthog-node": "^5.47.3",
29
30
  react: "19.2.8",
30
31
  "react-dom": "19.2.8",
31
32
  "rehype-highlight": "^7.0.2",
@@ -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.147",
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": {