doccupine 0.0.133 → 0.0.135

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 (174) hide show
  1. package/README.md +50 -10
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +478 -45
  4. package/dist/lib/config-manager.d.ts +8 -1
  5. package/dist/lib/config-manager.js +98 -4
  6. package/dist/lib/metadata.d.ts +5 -0
  7. package/dist/lib/metadata.js +15 -4
  8. package/dist/lib/openapi-types.d.ts +120 -0
  9. package/dist/lib/openapi-types.js +14 -0
  10. package/dist/lib/openapi.d.ts +52 -0
  11. package/dist/lib/openapi.js +603 -0
  12. package/dist/lib/rss.d.ts +24 -0
  13. package/dist/lib/rss.js +137 -0
  14. package/dist/lib/structures.js +50 -4
  15. package/dist/lib/types.d.ts +22 -0
  16. package/dist/lib/utils.d.ts +8 -0
  17. package/dist/lib/utils.js +14 -0
  18. package/dist/templates/app/api/playground/route.d.ts +1 -0
  19. package/dist/templates/app/api/playground/route.js +199 -0
  20. package/dist/templates/app/rssRoute.d.ts +11 -0
  21. package/dist/templates/app/rssRoute.js +30 -0
  22. package/dist/templates/components/Docs.d.ts +1 -1
  23. package/dist/templates/components/Docs.js +15 -3
  24. package/dist/templates/components/MDXComponents.d.ts +1 -1
  25. package/dist/templates/components/MDXComponents.js +29 -0
  26. package/dist/templates/components/SideBar.d.ts +1 -1
  27. package/dist/templates/components/SideBar.js +13 -0
  28. package/dist/templates/components/layout/Accordion.d.ts +1 -1
  29. package/dist/templates/components/layout/Accordion.js +3 -2
  30. package/dist/templates/components/layout/ActionBar.d.ts +1 -1
  31. package/dist/templates/components/layout/ActionBar.js +65 -27
  32. package/dist/templates/components/layout/ApiPlayground.d.ts +1 -0
  33. package/dist/templates/components/layout/ApiPlayground.js +1075 -0
  34. package/dist/templates/components/layout/ApiPlaygroundDemo.d.ts +1 -0
  35. package/dist/templates/components/layout/ApiPlaygroundDemo.js +81 -0
  36. package/dist/templates/components/layout/Badge.d.ts +1 -0
  37. package/dist/templates/components/layout/Badge.js +455 -0
  38. package/dist/templates/components/layout/Code.d.ts +1 -1
  39. package/dist/templates/components/layout/Code.js +10 -22
  40. package/dist/templates/components/layout/CopyButton.d.ts +1 -0
  41. package/dist/templates/components/layout/CopyButton.js +68 -0
  42. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  43. package/dist/templates/components/layout/DocsComponents.js +14 -0
  44. package/dist/templates/components/layout/Mermaid.d.ts +1 -1
  45. package/dist/templates/components/layout/Mermaid.js +21 -3
  46. package/dist/templates/components/layout/Prompt.d.ts +1 -0
  47. package/dist/templates/components/layout/Prompt.js +149 -0
  48. package/dist/templates/components/layout/SharedStyles.d.ts +1 -1
  49. package/dist/templates/components/layout/SharedStyles.js +0 -4
  50. package/dist/templates/components/layout/Steps.d.ts +1 -1
  51. package/dist/templates/components/layout/Steps.js +0 -1
  52. package/dist/templates/components/layout/Tooltip.d.ts +1 -0
  53. package/dist/templates/components/layout/Tooltip.js +222 -0
  54. package/dist/templates/components/layout/Tree.d.ts +1 -0
  55. package/dist/templates/components/layout/Tree.js +322 -0
  56. package/dist/templates/components/layout/TreeData.d.ts +1 -0
  57. package/dist/templates/components/layout/TreeData.js +131 -0
  58. package/dist/templates/components/layout/Update.d.ts +1 -1
  59. package/dist/templates/components/layout/Update.js +5 -1
  60. package/dist/templates/lib/rss.d.ts +1 -0
  61. package/dist/templates/lib/rss.js +78 -0
  62. package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
  63. package/dist/templates/mdx/accordion.mdx.js +19 -1
  64. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  65. package/dist/templates/mdx/ai-assistant.mdx.js +3 -2
  66. package/dist/templates/mdx/analytics.mdx.d.ts +1 -1
  67. package/dist/templates/mdx/analytics.mdx.js +2 -2
  68. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -0
  69. package/dist/templates/mdx/api-playground.mdx.js +158 -0
  70. package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
  71. package/dist/templates/mdx/authentication.mdx.js +3 -3
  72. package/dist/templates/mdx/badges.mdx.d.ts +1 -0
  73. package/dist/templates/mdx/badges.mdx.js +237 -0
  74. package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
  75. package/dist/templates/mdx/buttons.mdx.js +1 -1
  76. package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
  77. package/dist/templates/mdx/callouts.mdx.js +1 -1
  78. package/dist/templates/mdx/cards.mdx.d.ts +1 -1
  79. package/dist/templates/mdx/cards.mdx.js +1 -1
  80. package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
  81. package/dist/templates/mdx/color-swatches.mdx.js +1 -1
  82. package/dist/templates/mdx/columns.mdx.d.ts +1 -1
  83. package/dist/templates/mdx/columns.mdx.js +1 -1
  84. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  85. package/dist/templates/mdx/commands.mdx.js +3 -2
  86. package/dist/templates/mdx/components.mdx.d.ts +1 -1
  87. package/dist/templates/mdx/components.mdx.js +25 -10
  88. package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
  89. package/dist/templates/mdx/deployment-and-hosting.mdx.js +4 -3
  90. package/dist/templates/mdx/fields.mdx.d.ts +1 -1
  91. package/dist/templates/mdx/fields.mdx.js +1 -1
  92. package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
  93. package/dist/templates/mdx/fonts.mdx.js +2 -2
  94. package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
  95. package/dist/templates/mdx/footer-links.mdx.js +1 -1
  96. package/dist/templates/mdx/frames.mdx.d.ts +1 -1
  97. package/dist/templates/mdx/frames.mdx.js +1 -1
  98. package/dist/templates/mdx/globals.mdx.d.ts +1 -1
  99. package/dist/templates/mdx/globals.mdx.js +1 -1
  100. package/dist/templates/mdx/icons.mdx.d.ts +1 -1
  101. package/dist/templates/mdx/icons.mdx.js +1 -1
  102. package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
  103. package/dist/templates/mdx/image-and-embeds.mdx.js +1 -1
  104. package/dist/templates/mdx/images-and-embeds.mdx.d.ts +1 -0
  105. package/dist/templates/mdx/images-and-embeds.mdx.js +118 -0
  106. package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
  107. package/dist/templates/mdx/media-and-assets.mdx.js +2 -2
  108. package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
  109. package/dist/templates/mdx/mermaid.mdx.js +1 -1
  110. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  111. package/dist/templates/mdx/model-context-protocol.mdx.js +2 -2
  112. package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
  113. package/dist/templates/mdx/navigation.mdx.js +27 -12
  114. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  115. package/dist/templates/mdx/platform/ai-assistant.mdx.js +4 -3
  116. package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
  117. package/dist/templates/mdx/platform/analytics.mdx.js +2 -2
  118. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -0
  119. package/dist/templates/mdx/platform/api-playground.mdx.js +62 -0
  120. package/dist/templates/mdx/platform/billing.mdx.d.ts +1 -1
  121. package/dist/templates/mdx/platform/billing.mdx.js +1 -1
  122. package/dist/templates/mdx/platform/build-and-deploy.mdx.d.ts +1 -1
  123. package/dist/templates/mdx/platform/build-and-deploy.mdx.js +1 -1
  124. package/dist/templates/mdx/platform/creating-a-project.mdx.d.ts +1 -1
  125. package/dist/templates/mdx/platform/creating-a-project.mdx.js +12 -2
  126. package/dist/templates/mdx/platform/custom-domains.mdx.d.ts +1 -1
  127. package/dist/templates/mdx/platform/custom-domains.mdx.js +1 -1
  128. package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
  129. package/dist/templates/mdx/platform/fonts-settings.mdx.js +1 -1
  130. package/dist/templates/mdx/platform/footer-links.mdx.d.ts +1 -0
  131. package/dist/templates/mdx/platform/{external-links.mdx.js → footer-links.mdx.js} +5 -5
  132. package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -0
  133. package/dist/templates/mdx/platform/import-from-github.mdx.js +91 -0
  134. package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
  135. package/dist/templates/mdx/platform/mcp.mdx.js +3 -3
  136. package/dist/templates/mdx/platform/project-settings.mdx.d.ts +1 -1
  137. package/dist/templates/mdx/platform/project-settings.mdx.js +1 -1
  138. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -0
  139. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +113 -0
  140. package/dist/templates/mdx/platform/team-members.mdx.d.ts +1 -1
  141. package/dist/templates/mdx/platform/team-members.mdx.js +1 -1
  142. package/dist/templates/mdx/prompt.mdx.d.ts +1 -0
  143. package/dist/templates/mdx/prompt.mdx.js +69 -0
  144. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  145. package/dist/templates/mdx/sections.mdx.js +1 -1
  146. package/dist/templates/mdx/steps.mdx.d.ts +1 -1
  147. package/dist/templates/mdx/steps.mdx.js +1 -1
  148. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  149. package/dist/templates/mdx/tabs.mdx.js +1 -1
  150. package/dist/templates/mdx/theme.mdx.d.ts +1 -1
  151. package/dist/templates/mdx/theme.mdx.js +1 -1
  152. package/dist/templates/mdx/tooltips.mdx.d.ts +1 -0
  153. package/dist/templates/mdx/tooltips.mdx.js +57 -0
  154. package/dist/templates/mdx/tree.mdx.d.ts +1 -0
  155. package/dist/templates/mdx/tree.mdx.js +158 -0
  156. package/dist/templates/mdx/update.mdx.d.ts +1 -1
  157. package/dist/templates/mdx/update.mdx.js +42 -2
  158. package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
  159. package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
  160. package/dist/templates/package.js +7 -7
  161. package/dist/templates/services/openapi/playgroundAllowlistStub.d.ts +1 -0
  162. package/dist/templates/services/openapi/playgroundAllowlistStub.js +4 -0
  163. package/dist/templates/types/openapi.d.ts +1 -0
  164. package/dist/templates/types/openapi.js +93 -0
  165. package/dist/templates/utils/apiSnippets.d.ts +1 -0
  166. package/dist/templates/utils/apiSnippets.js +94 -0
  167. package/dist/templates/utils/orderNavItems.d.ts +1 -1
  168. package/dist/templates/utils/orderNavItems.js +3 -0
  169. package/dist/templates/utils/playgroundAllowlist.d.ts +1 -0
  170. package/dist/templates/utils/playgroundAllowlist.js +70 -0
  171. package/dist/templates/utils/ssrfGuard.d.ts +1 -0
  172. package/dist/templates/utils/ssrfGuard.js +217 -0
  173. package/package.json +4 -3
  174. package/dist/templates/mdx/platform/external-links.mdx.d.ts +0 -1
package/dist/index.js CHANGED
@@ -8,18 +8,21 @@ import matter from "gray-matter";
8
8
  import chalk from "chalk";
9
9
  import { appStructure, obsoleteFiles, startingDocsStructure, } from "./lib/structures.js";
10
10
  import { rootLayoutTemplate, siteLayoutTemplate } from "./lib/layout.js";
11
- import { ConfigManager } from "./lib/config-manager.js";
12
- import { findAvailablePort, generateSlug, getFullSlug, escapeTemplateContent, resolvePackageManager, } from "./lib/utils.js";
11
+ import { ConfigManager, normalizeOpenApiConfig } from "./lib/config-manager.js";
12
+ import { OpenApiRegistry, DEFAULT_API_BASE_SLUG, buildEndpointDoc, } from "./lib/openapi.js";
13
+ import { findAvailablePort, generateSlug, getFullSlug, escapeTemplateContent, toJsStringLiteral, resolvePackageManager, } from "./lib/utils.js";
13
14
  import { generateMetadataBlock, generateRuntimeOnlyMetadataBlock, generateJsonLdScript, } from "./lib/metadata.js";
15
+ import { parseUpdateBlocks } from "./lib/rss.js";
14
16
  import { nextConfigTemplate } from "./templates/next.config.js";
15
17
  import { pnpmWorkspaceTemplate } from "./templates/pnpmWorkspace.js";
16
18
  import { proxyTemplate } from "./templates/proxy.js";
17
19
  import { robotsTemplate } from "./templates/app/robots.js";
20
+ import { rssRouteTemplate } from "./templates/app/rssRoute.js";
18
21
  import { sitemapTemplate } from "./templates/app/sitemap.js";
19
22
  import { llmsIndexTemplate } from "./templates/llms/llmsIndex.js";
20
23
  import { llmsFullTemplate, } from "./templates/llms/llmsFull.js";
21
24
  import { llmsPageTemplate } from "./templates/llms/llmsPage.js";
22
- export { generateSlug, getFullSlug, escapeTemplateContent, } from "./lib/utils.js";
25
+ export { generateSlug, getFullSlug, escapeTemplateContent, toJsStringLiteral, } from "./lib/utils.js";
23
26
  const __filename = fileURLToPath(import.meta.url);
24
27
  const __dirname = path.dirname(__filename);
25
28
  const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
@@ -34,6 +37,9 @@ class MDXToNextJSGenerator {
34
37
  publicWatcher = null;
35
38
  rootDirWatcher = null;
36
39
  analyticsWatcher = null;
40
+ openApiWatcher = null;
41
+ doccupineConfigWatcher = null;
42
+ doccupineConfigFile = "doccupine.json";
37
43
  configFiles = [
38
44
  "theme.json",
39
45
  "navigation.json",
@@ -49,10 +55,19 @@ class MDXToNextJSGenerator {
49
55
  isReprocessing = false;
50
56
  /** Tracks per-page .md files written under public/ so we can clean up stale ones on rename/delete */
51
57
  generatedLlmsPagePaths = new Set();
52
- constructor(watchDir, outputDir) {
58
+ /** OpenAPI specs (build config) that drive the generated API reference. */
59
+ openApiSpecs;
60
+ apiBaseSlug = DEFAULT_API_BASE_SLUG;
61
+ apiRegistry = new OpenApiRegistry();
62
+ /** Route slugs of the endpoint pages written last pass, for stale cleanup. */
63
+ generatedApiPageSlugs = new Set();
64
+ /** Section slugs whose index redirect we wrote this session, for cleanup. */
65
+ generatedSectionIndexSlugs = new Set();
66
+ constructor(watchDir, outputDir, openApiSpecs = []) {
53
67
  this.watchDir = path.resolve(watchDir);
54
68
  this.outputDir = path.resolve(outputDir);
55
69
  this.rootDir = process.cwd();
70
+ this.openApiSpecs = openApiSpecs;
56
71
  }
57
72
  async init() {
58
73
  console.log(chalk.blue("🚀 Initializing MDX to Next.js generator..."));
@@ -63,6 +78,9 @@ class MDXToNextJSGenerator {
63
78
  if (this.analyticsConfig) {
64
79
  console.log(chalk.blue(`📊 Analytics enabled: ${this.analyticsConfig.provider}`));
65
80
  }
81
+ // Parse OpenAPI spec(s) before generating structure so the synthetic
82
+ // endpoint pages flow into the very first layout/sitemap/llms pass.
83
+ await this.loadOpenApiRegistry();
66
84
  await this.createNextJSStructure();
67
85
  await this.createStartingDocs();
68
86
  await this.copyCustomConfigFiles();
@@ -78,6 +96,10 @@ class MDXToNextJSGenerator {
78
96
  if (this.sectionsConfig) {
79
97
  console.log(chalk.blue(`📑 Found ${this.sectionsConfig.length} section(s): ${this.sectionsConfig.map((s) => s.label).join(", ")}`));
80
98
  }
99
+ // Write the endpoint pages + request allowlist before the MDX pass so its
100
+ // aggregate refresh (nav/sitemap/llms) already sees them on disk and in the
101
+ // registry.
102
+ await this.writeApiPages();
81
103
  await this.processAllMDXFiles();
82
104
  console.log(chalk.green("✅ Initial setup complete!"));
83
105
  console.log(chalk.cyan("💡 To start the Next.js dev server:"));
@@ -257,9 +279,28 @@ class MDXToNextJSGenerator {
257
279
  }
258
280
  async resolveSections() {
259
281
  const fromFile = await this.loadSectionsConfig();
260
- if (fromFile)
261
- return fromFile;
262
- return this.discoverSectionsFromFrontmatter();
282
+ const base = fromFile ?? (await this.discoverSectionsFromFrontmatter());
283
+ return this.withApiReferenceSection(base);
284
+ }
285
+ /**
286
+ * Promotes the generated OpenAPI endpoints into a dedicated "API Reference"
287
+ * section so they get their own top-level nav, separate from hand-written
288
+ * docs. When the site had no sections, a root "Documentation" section is added
289
+ * for the existing pages so both appear in the section switcher.
290
+ */
291
+ withApiReferenceSection(sections) {
292
+ if (this.apiRegistry.isEmpty)
293
+ return sections;
294
+ const apiSection = {
295
+ label: "API Reference",
296
+ slug: this.apiBaseSlug,
297
+ };
298
+ if (!sections || sections.length === 0) {
299
+ return [{ label: "Documentation", slug: "" }, apiSection];
300
+ }
301
+ if (sections.some((s) => s.slug === this.apiBaseSlug))
302
+ return sections;
303
+ return [...sections, apiSection];
263
304
  }
264
305
  async reloadSections() {
265
306
  console.log(chalk.cyan("📑 Sections configuration changed"));
@@ -273,7 +314,7 @@ class MDXToNextJSGenerator {
273
314
  const fromFile = await this.loadSectionsConfig();
274
315
  if (fromFile)
275
316
  return;
276
- const newSections = await this.discoverSectionsFromFrontmatter();
317
+ const newSections = this.withApiReferenceSection(await this.discoverSectionsFromFrontmatter());
277
318
  const changed = JSON.stringify(newSections) !== JSON.stringify(this.sectionsConfig);
278
319
  if (changed) {
279
320
  console.log(chalk.cyan(newSections
@@ -590,6 +631,18 @@ class MDXToNextJSGenerator {
590
631
  .on("error", (error) => {
591
632
  console.error(chalk.red("❌ Analytics watcher error:"), error);
592
633
  });
634
+ await this.syncOpenApiSpecWatcher();
635
+ const doccupineConfigPath = path.join(this.rootDir, this.doccupineConfigFile);
636
+ this.doccupineConfigWatcher = chokidar.watch(doccupineConfigPath, {
637
+ persistent: true,
638
+ ignoreInitial: true,
639
+ });
640
+ this.doccupineConfigWatcher
641
+ .on("add", () => this.handleDoccupineConfigChange())
642
+ .on("change", () => this.handleDoccupineConfigChange())
643
+ .on("error", (error) => {
644
+ console.error(chalk.red("❌ doccupine.json watcher error:"), error);
645
+ });
593
646
  const publicDir = path.join(this.rootDir, "public");
594
647
  if (await fs.pathExists(publicDir)) {
595
648
  this.setupPublicWatcher();
@@ -662,6 +715,14 @@ class MDXToNextJSGenerator {
662
715
  // ignore
663
716
  }
664
717
  }
718
+ // A hand-written page that embeds an endpoint via `openapi:` frontmatter
719
+ // gets the same method badge in the sidebar as a generated endpoint page.
720
+ let httpMethod;
721
+ if (frontmatter.openapi) {
722
+ const op = this.apiRegistry.lookup(String(frontmatter.openapi));
723
+ if (op)
724
+ httpMethod = op.method.toUpperCase();
725
+ }
665
726
  return {
666
727
  slug: fullSlug,
667
728
  title: frontmatter.title || "Untitled",
@@ -679,12 +740,27 @@ class MDXToNextJSGenerator {
679
740
  ...(frontmatter.categoryIcon
680
741
  ? { categoryIcon: String(frontmatter.categoryIcon) }
681
742
  : {}),
743
+ ...(httpMethod ? { httpMethod } : {}),
682
744
  lastModified,
683
745
  };
684
746
  }
685
747
  async buildAllPagesMeta() {
686
748
  const files = await this.getAllMDXFiles();
687
- return Promise.all(files.map((file) => this.parseMDXFile(file)));
749
+ const real = await Promise.all(files.map((file) => this.parseMDXFile(file)));
750
+ if (this.apiRegistry.isEmpty)
751
+ return real;
752
+ // Inject synthetic OpenAPI endpoint pages here - the single funnel every
753
+ // aggregate (nav, sitemap, llms) flows through - so they cannot be dropped
754
+ // by the .mdx-only disk scan. Hand-written pages win on any slug collision.
755
+ const realSlugs = new Set(real.map((page) => page.slug));
756
+ const synthetic = this.apiRegistry.syntheticPages().filter((page) => {
757
+ if (realSlugs.has(page.slug)) {
758
+ console.log(chalk.yellow(`⚠️ API page ${page.slug} is shadowed by a hand-written page; skipping`));
759
+ return false;
760
+ }
761
+ return true;
762
+ });
763
+ return [...real, ...synthetic];
688
764
  }
689
765
  /**
690
766
  * Writes the generated page(s) for a single MDX file: the doc page and, for a
@@ -713,7 +789,17 @@ class MDXToNextJSGenerator {
713
789
  frontmatter,
714
790
  slug: fullSlug,
715
791
  };
716
- await this.generatePageFromMDX(mdxFile);
792
+ // `openapi: <METHOD> <path>` (or an operationId) in frontmatter renders
793
+ // that operation's playground inline with the author's prose. An unknown
794
+ // reference is logged and the page still renders its prose (graceful).
795
+ let apiOperation;
796
+ if (frontmatter.openapi) {
797
+ apiOperation = this.apiRegistry.lookup(String(frontmatter.openapi));
798
+ if (!apiOperation) {
799
+ console.error(chalk.red(`❌ openapi frontmatter "${frontmatter.openapi}" in ${filePath} not found in any spec`));
800
+ }
801
+ }
802
+ await this.generatePageFromMDX(mdxFile, apiOperation ? { apiOperation } : undefined);
717
803
  }
718
804
  if (isSectionIndex) {
719
805
  await this.updateSectionIndex(sectionSlug, frontmatter, mdxContent, filePath);
@@ -815,41 +901,98 @@ class MDXToNextJSGenerator {
815
901
  return siteLayoutTemplate(resolvedPages, this.sectionsConfig);
816
902
  }
817
903
  async generateSectionIndexPages(pages) {
818
- if (!this.sectionsConfig || this.sectionsConfig.length === 0)
819
- return;
820
- const resolvedPages = pages ?? (await this.buildAllPagesMeta());
821
- for (const section of this.sectionsConfig) {
822
- if (section.slug === "")
823
- continue;
824
- // Check if a page already exists at the section root
825
- const hasIndex = resolvedPages.some((p) => p.slug === section.slug);
826
- if (hasIndex)
827
- continue;
828
- // Find the first page in this section
829
- const sectionPages = resolvedPages
830
- .filter((p) => p.section === section.slug)
831
- .sort((a, b) => {
832
- if (a.categoryOrder !== b.categoryOrder)
833
- return a.categoryOrder - b.categoryOrder;
834
- return a.order - b.order;
835
- });
836
- if (sectionPages.length === 0)
837
- continue;
838
- const firstPage = sectionPages[0];
839
- const redirectContent = `import { redirect } from "next/navigation";
904
+ const nextSlugs = new Set();
905
+ if (this.sectionsConfig && this.sectionsConfig.length > 0) {
906
+ const resolvedPages = pages ?? (await this.buildAllPagesMeta());
907
+ for (const section of this.sectionsConfig) {
908
+ if (section.slug === "")
909
+ continue;
910
+ // Check if a page already exists at the section root
911
+ const hasIndex = resolvedPages.some((p) => p.slug === section.slug);
912
+ if (hasIndex)
913
+ continue;
914
+ // Find the first page in this section
915
+ const sectionPages = resolvedPages
916
+ .filter((p) => p.section === section.slug)
917
+ .sort((a, b) => {
918
+ if (a.categoryOrder !== b.categoryOrder)
919
+ return a.categoryOrder - b.categoryOrder;
920
+ return a.order - b.order;
921
+ });
922
+ if (sectionPages.length === 0)
923
+ continue;
924
+ const firstPage = sectionPages[0];
925
+ const redirectContent = `import { redirect } from "next/navigation";
840
926
 
841
927
  export default function SectionIndex() {
842
928
  redirect("/${firstPage.slug}");
843
929
  }
844
930
  `;
845
- const pagePath = path.join(this.outputDir, "app", "(site)", section.slug, "page.tsx");
846
- await fs.ensureDir(path.dirname(pagePath));
847
- await fs.writeFile(pagePath, redirectContent, "utf8");
848
- console.log(chalk.blue(`🔀 Generated section index redirect: /${section.slug} -> /${firstPage.slug}`));
931
+ const pagePath = path.join(this.outputDir, "app", "(site)", section.slug, "page.tsx");
932
+ await fs.ensureDir(path.dirname(pagePath));
933
+ await fs.writeFile(pagePath, redirectContent, "utf8");
934
+ nextSlugs.add(section.slug);
935
+ console.log(chalk.blue(`🔀 Generated section index redirect: /${section.slug} -> /${firstPage.slug}`));
936
+ }
849
937
  }
938
+ await this.cleanupStaleSectionIndexPages(nextSlugs);
850
939
  }
851
- async generatePageFromMDX(mdxFile) {
940
+ /**
941
+ * Removes section index redirects written earlier in this session whose
942
+ * section has since disappeared (e.g. the API Reference section after the
943
+ * `openapi` config is removed mid-watch). Only files that still contain the
944
+ * generated redirect are deleted, so a hand-written page that has taken
945
+ * over the slug is never touched. Fresh processes start clean anyway -
946
+ * init() wipes app/ - so in-session tracking is enough.
947
+ */
948
+ async cleanupStaleSectionIndexPages(nextSlugs) {
949
+ for (const stale of this.generatedSectionIndexSlugs) {
950
+ if (nextSlugs.has(stale))
951
+ continue;
952
+ const pagePath = path.join(this.outputDir, "app", "(site)", stale, "page.tsx");
953
+ try {
954
+ if (!(await fs.pathExists(pagePath)))
955
+ continue;
956
+ const content = await fs.readFile(pagePath, "utf8");
957
+ if (!content.includes("function SectionIndex()"))
958
+ continue;
959
+ await fs.remove(pagePath);
960
+ await this.removeEmptyDirsUpTo(path.dirname(pagePath), path.join(this.outputDir, "app", "(site)"));
961
+ console.log(chalk.blue(`🧹 Removed stale section index redirect: /${stale}`));
962
+ }
963
+ catch {
964
+ // ignore
965
+ }
966
+ }
967
+ this.generatedSectionIndexSlugs = nextSlugs;
968
+ }
969
+ /** Best-effort removal of now-empty directories up to (not incl.) stopDir. */
970
+ async removeEmptyDirsUpTo(dir, stopDir) {
971
+ const stop = path.resolve(stopDir);
972
+ let current = path.resolve(dir);
973
+ while (current !== stop && current.startsWith(stop + path.sep)) {
974
+ try {
975
+ const entries = await fs.readdir(current);
976
+ if (entries.length > 0)
977
+ return;
978
+ await fs.remove(current);
979
+ }
980
+ catch {
981
+ return;
982
+ }
983
+ current = path.dirname(current);
984
+ }
985
+ }
986
+ async generatePageFromMDX(mdxFile, options) {
852
987
  const fm = mdxFile.frontmatter;
988
+ const apiOperation = options?.apiOperation;
989
+ // Pages containing <Update> blocks publish a subscribable changelog: an
990
+ // RSS feed at {page-url}/rss.xml. Synthetic OpenAPI pages never contain
991
+ // Update blocks, so skip the parse for them.
992
+ const isSynthetic = mdxFile.path.startsWith("@openapi/");
993
+ const updates = isSynthetic ? [] : parseUpdateBlocks(mdxFile.content);
994
+ const hasFeed = updates.length > 0;
995
+ const feedPath = `/${mdxFile.slug}/rss.xml`;
853
996
  const metadataBlock = generateMetadataBlock({
854
997
  title: fm.title,
855
998
  titleFallback: "Generated with Doccupine",
@@ -859,6 +1002,7 @@ export default function SectionIndex() {
859
1002
  icon: fm.icon,
860
1003
  image: fm.image,
861
1004
  canonicalPath: mdxFile.slug,
1005
+ rssPath: hasFeed ? feedPath : undefined,
862
1006
  });
863
1007
  const jsonLd = generateJsonLdScript({
864
1008
  kind: "article",
@@ -873,12 +1017,60 @@ export default function SectionIndex() {
873
1017
  : undefined,
874
1018
  image: fm.image,
875
1019
  });
1020
+ // For an OpenAPI-backed page, embed the operation descriptor as a JS string
1021
+ // literal parsed at load. Serializing to JSON then re-`JSON.parse`ing is
1022
+ // total escaping for arbitrary JSON - unlike `escapeTemplateContent`, which
1023
+ // only guards backticks/`${`/backslashes for the MDX prose literal.
1024
+ const apiImport = apiOperation
1025
+ ? `\nimport { ApiPlayground } from "@/components/layout/ApiPlayground";`
1026
+ : "";
1027
+ // The descriptor JSON always exceeds the 80-col print width, so emit the
1028
+ // call pre-wrapped in the exact shape Prettier produces (argument on its own
1029
+ // line with a trailing comma, single-quoted so the JSON's own double quotes
1030
+ // need no escaping). Keeps generated endpoint pages Prettier-stable without
1031
+ // running a formatter at build time.
1032
+ const apiConst = apiOperation
1033
+ ? (() => {
1034
+ const arg = toJsStringLiteral(JSON.stringify(apiOperation));
1035
+ const inline = `const operation = JSON.parse(${arg});`;
1036
+ const decl = inline.length <= 80
1037
+ ? inline
1038
+ : `const operation = JSON.parse(\n ${arg},\n);`;
1039
+ return `\n${decl}\n`;
1040
+ })()
1041
+ : "";
1042
+ // The playground renders as a child of <Docs> so it sits inside the docs
1043
+ // content column (a sibling would escape the layout and overlap the nav).
1044
+ // Synthetic endpoint pages pass no `sourcePath`: it only namespaces Mermaid
1045
+ // diagrams (which endpoint docs never contain), and its long `@openapi/...`
1046
+ // value would push the opening tag past 80 cols and make Prettier rewrap it.
1047
+ const sourcePathLiteral = JSON.stringify(mdxFile.path);
1048
+ // `rss: true` frontmatter opts the page into an RSS button in the action
1049
+ // bar (only when a feed actually exists). The playground branch keeps its
1050
+ // fixed JSX shape - a feed on an inline-playground page stays reachable
1051
+ // via autodiscovery. The buttoned form usually exceeds the 80-col print
1052
+ // width, so pre-wrap it in the shape Prettier produces (attributes on
1053
+ // their own lines) relative to its 6-space insertion indent.
1054
+ const showRssButton = hasFeed && fm.rss === true && !apiOperation;
1055
+ const docsAttrs = [
1056
+ `content={content}`,
1057
+ `sourcePath={${sourcePathLiteral}}`,
1058
+ ...(showRssButton ? [`rssHref={${JSON.stringify(feedPath)}}`] : []),
1059
+ ];
1060
+ const inlineDocs = `<Docs ${docsAttrs.join(" ")} />`;
1061
+ const docsElement = apiOperation
1062
+ ? `<Docs content={content}>
1063
+ <ApiPlayground operation={operation} />
1064
+ </Docs>`
1065
+ : inlineDocs.length + 6 <= 80
1066
+ ? inlineDocs
1067
+ : `<Docs\n${docsAttrs.map((attr) => ` ${attr}`).join("\n")}\n />`;
876
1068
  const pageContent = `import { Metadata } from "next";
877
1069
  import { Docs } from "@/components/Docs";
878
- import { config } from "@/utils/config";
1070
+ import { config } from "@/utils/config";${apiImport}
879
1071
 
880
1072
  const content = \`${escapeTemplateContent(mdxFile.content)}\`;
881
-
1073
+ ${apiConst}
882
1074
  ${metadataBlock}
883
1075
 
884
1076
  // Doc pages have no per-request data: theme resolves client-side via the
@@ -893,7 +1085,7 @@ export default function Page() {
893
1085
  return (
894
1086
  <>
895
1087
  ${jsonLd.element}
896
- <Docs content={content} sourcePath={${JSON.stringify(mdxFile.path)}} />
1088
+ ${docsElement}
897
1089
  </>
898
1090
  );
899
1091
  }
@@ -901,6 +1093,211 @@ export default function Page() {
901
1093
  const pagePath = path.join(this.outputDir, "app", "(site)", mdxFile.slug, "page.tsx");
902
1094
  await fs.ensureDir(path.dirname(pagePath));
903
1095
  await fs.writeFile(pagePath, pageContent, "utf8");
1096
+ // The feed route lives inside the page's directory, so a deleted page
1097
+ // takes its feed along (handleFileDelete removes the whole dir) and the
1098
+ // else-branch prunes the route when a regenerated page no longer has
1099
+ // Update blocks. Cross-run staleness is covered by the app/ wipe in
1100
+ // createNextJSStructure.
1101
+ if (!isSynthetic) {
1102
+ const rssDir = path.join(path.dirname(pagePath), "rss.xml");
1103
+ if (hasFeed) {
1104
+ await fs.ensureDir(rssDir);
1105
+ await fs.writeFile(path.join(rssDir, "route.ts"), rssRouteTemplate({
1106
+ pagePath: mdxFile.slug,
1107
+ title: typeof fm.title === "string" ? fm.title : null,
1108
+ description: typeof fm.description === "string" ? fm.description : null,
1109
+ items: updates.map((update) => ({
1110
+ title: update.label,
1111
+ anchor: update.anchor,
1112
+ description: update.description,
1113
+ })),
1114
+ }), "utf8");
1115
+ }
1116
+ else {
1117
+ await fs.remove(rssDir);
1118
+ }
1119
+ }
1120
+ }
1121
+ /** Parses the configured OpenAPI spec(s) into the shared registry. */
1122
+ async loadOpenApiRegistry() {
1123
+ if (this.openApiSpecs.length === 0)
1124
+ return;
1125
+ await this.apiRegistry.load(this.openApiSpecs, this.rootDir, this.apiBaseSlug);
1126
+ if (!this.apiRegistry.isEmpty) {
1127
+ console.log(chalk.blue(`📘 Loaded ${this.apiRegistry.all.length} API endpoint(s) from ${this.openApiSpecs.length} spec(s)`));
1128
+ }
1129
+ }
1130
+ /**
1131
+ * Generates one page per OpenAPI operation, (re)writes the request-execution
1132
+ * allowlist consumed by the playground proxy + component, and removes endpoint
1133
+ * pages that no longer exist in the spec. Safe to call when there are no specs
1134
+ * - it still emits an empty allowlist and prunes any previously generated
1135
+ * pages (e.g. after the `openapi` config is removed).
1136
+ */
1137
+ async writeApiPages() {
1138
+ const nextSlugs = new Set();
1139
+ for (const op of this.apiRegistry.all) {
1140
+ const methodUpper = op.method.toUpperCase();
1141
+ const mdxFile = {
1142
+ path: `@openapi/${op.specName}/${op.method}${op.path}`,
1143
+ content: buildEndpointDoc(op),
1144
+ frontmatter: {
1145
+ title: op.summary ?? `${methodUpper} ${op.path}`,
1146
+ description: op.summary ?? "",
1147
+ },
1148
+ slug: op.slug,
1149
+ };
1150
+ try {
1151
+ await this.generatePageFromMDX(mdxFile, { apiOperation: op });
1152
+ nextSlugs.add(op.slug);
1153
+ }
1154
+ catch (error) {
1155
+ console.error(chalk.red(`❌ Error generating API page ${op.slug}:`), error);
1156
+ }
1157
+ }
1158
+ await this.writeApiAllowlist();
1159
+ await this.cleanupStaleApiPages(nextSlugs);
1160
+ if (nextSlugs.size > 0) {
1161
+ console.log(chalk.green(`🧩 Generated ${nextSlugs.size} API reference page(s)`));
1162
+ }
1163
+ }
1164
+ /** Writes the request-execution allowlist (overwrites the shipped stub). */
1165
+ async writeApiAllowlist() {
1166
+ const target = path.join(this.outputDir, "services", "openapi", "playground-allowlist.json");
1167
+ await fs.ensureDir(path.dirname(target));
1168
+ await fs.writeFile(target, `${JSON.stringify(this.apiRegistry.allowlist(), null, 2)}\n`, "utf8");
1169
+ }
1170
+ apiManifestPath() {
1171
+ return path.join(this.outputDir, ".doccupine-api-manifest.json");
1172
+ }
1173
+ async readApiManifest() {
1174
+ try {
1175
+ const manifestPath = this.apiManifestPath();
1176
+ if (await fs.pathExists(manifestPath)) {
1177
+ const raw = await fs.readFile(manifestPath, "utf8");
1178
+ const parsed = JSON.parse(raw);
1179
+ if (Array.isArray(parsed.pageSlugs)) {
1180
+ return new Set(parsed.pageSlugs.filter((entry) => typeof entry === "string"));
1181
+ }
1182
+ }
1183
+ }
1184
+ catch {
1185
+ // ignore corrupted manifest
1186
+ }
1187
+ return new Set();
1188
+ }
1189
+ async writeApiManifest(slugs) {
1190
+ const payload = { pageSlugs: Array.from(slugs).sort() };
1191
+ await fs.writeFile(this.apiManifestPath(), `${JSON.stringify(payload, null, 2)}\n`, "utf8");
1192
+ }
1193
+ /** Removes endpoint page directories that are no longer in the spec. */
1194
+ async cleanupStaleApiPages(nextSlugs) {
1195
+ const previous = new Set([
1196
+ ...this.generatedApiPageSlugs,
1197
+ ...(await this.readApiManifest()),
1198
+ ]);
1199
+ for (const stale of previous) {
1200
+ if (nextSlugs.has(stale))
1201
+ continue;
1202
+ try {
1203
+ const dir = path.join(this.outputDir, "app", "(site)", stale);
1204
+ if (await fs.pathExists(dir)) {
1205
+ await fs.remove(dir);
1206
+ await this.removeEmptyDirsUpTo(path.dirname(dir), path.join(this.outputDir, "app", "(site)"));
1207
+ }
1208
+ }
1209
+ catch {
1210
+ // ignore
1211
+ }
1212
+ }
1213
+ this.generatedApiPageSlugs = nextSlugs;
1214
+ await this.writeApiManifest(nextSlugs);
1215
+ }
1216
+ /**
1217
+ * (Re)points the spec-file watcher at the currently configured spec paths.
1218
+ * Called at startup and whenever doccupine.json changes the `openapi` set,
1219
+ * so specs added mid-session are watched without a restart.
1220
+ */
1221
+ async syncOpenApiSpecWatcher() {
1222
+ if (this.openApiWatcher) {
1223
+ await this.openApiWatcher.close();
1224
+ this.openApiWatcher = null;
1225
+ }
1226
+ if (this.openApiSpecs.length === 0)
1227
+ return;
1228
+ const specPaths = this.openApiSpecs.map((spec) => path.resolve(this.rootDir, spec.file));
1229
+ this.openApiWatcher = chokidar.watch(specPaths, {
1230
+ persistent: true,
1231
+ ignoreInitial: true,
1232
+ });
1233
+ this.openApiWatcher
1234
+ .on("add", () => this.handleOpenApiChange())
1235
+ .on("change", () => this.handleOpenApiChange())
1236
+ .on("unlink", () => this.handleOpenApiChange())
1237
+ .on("error", (error) => {
1238
+ console.error(chalk.red("❌ OpenAPI watcher error:"), error);
1239
+ });
1240
+ }
1241
+ /**
1242
+ * Reparses the spec(s) and rewrites everything derived from them: the
1243
+ * endpoint pages and allowlist, the sections (the "API Reference" section
1244
+ * appears and disappears with the registry), and the site aggregates.
1245
+ */
1246
+ async rebuildApiReference() {
1247
+ await this.apiRegistry.load(this.openApiSpecs, this.rootDir, this.apiBaseSlug);
1248
+ this.sectionsConfig = await this.resolveSections();
1249
+ await this.writeApiPages();
1250
+ await this.refreshSiteAggregates();
1251
+ }
1252
+ /** Reparses the spec(s) and regenerates the API reference on a watch event. */
1253
+ async handleOpenApiChange() {
1254
+ console.log(chalk.cyan("📘 OpenAPI spec changed - regenerating API reference"));
1255
+ try {
1256
+ await this.rebuildApiReference();
1257
+ console.log(chalk.green("✅ API reference updated"));
1258
+ }
1259
+ catch (error) {
1260
+ console.error(chalk.red("❌ Error updating API reference:"), error);
1261
+ }
1262
+ }
1263
+ /**
1264
+ * Applies `openapi` edits in doccupine.json without a restart: reloads the
1265
+ * registry, regenerates or prunes the endpoint pages and allowlist,
1266
+ * refreshes nav/sitemap/llms, and re-points the spec-file watcher. Other
1267
+ * fields (watchDir, outputDir, port) cannot be hot-applied, so a change
1268
+ * there only logs a restart hint. Invalid or missing JSON (e.g. a
1269
+ * half-written editor save) keeps the current configuration.
1270
+ */
1271
+ async handleDoccupineConfigChange() {
1272
+ const configPath = path.join(this.rootDir, this.doccupineConfigFile);
1273
+ let config;
1274
+ try {
1275
+ config = JSON.parse(await fs.readFile(configPath, "utf8"));
1276
+ }
1277
+ catch {
1278
+ console.warn(chalk.yellow("⚠️ doccupine.json is missing or invalid - keeping the current configuration"));
1279
+ return;
1280
+ }
1281
+ if ((config.watchDir &&
1282
+ path.resolve(this.rootDir, config.watchDir) !== this.watchDir) ||
1283
+ (config.outputDir &&
1284
+ path.resolve(this.rootDir, config.outputDir) !== this.outputDir)) {
1285
+ console.log(chalk.yellow("⚠️ watchDir/outputDir changes in doccupine.json need a restart to apply"));
1286
+ }
1287
+ const nextSpecs = normalizeOpenApiConfig(config.openapi);
1288
+ if (JSON.stringify(nextSpecs) === JSON.stringify(this.openApiSpecs)) {
1289
+ return;
1290
+ }
1291
+ console.log(chalk.cyan("📘 OpenAPI configuration changed - updating API reference"));
1292
+ this.openApiSpecs = nextSpecs;
1293
+ try {
1294
+ await this.syncOpenApiSpecWatcher();
1295
+ await this.rebuildApiReference();
1296
+ console.log(chalk.green("✅ API reference updated"));
1297
+ }
1298
+ catch (error) {
1299
+ console.error(chalk.red("❌ Error updating API reference:"), error);
1300
+ }
904
1301
  }
905
1302
  async updatePagesIndex() {
906
1303
  const files = await this.getAllMDXFiles();
@@ -921,6 +1318,9 @@ export default function Page() {
921
1318
  updated: typeof frontmatter.updated === "string"
922
1319
  ? frontmatter.updated
923
1320
  : undefined,
1321
+ openapi: typeof frontmatter.openapi === "string"
1322
+ ? frontmatter.openapi
1323
+ : undefined,
924
1324
  };
925
1325
  break;
926
1326
  }
@@ -946,12 +1346,32 @@ export default function Page() {
946
1346
  updated: indexMDX?.updated ?? indexMDX?.date,
947
1347
  image: indexMDX?.image,
948
1348
  });
1349
+ // The homepage supports the same `openapi: <METHOD> <path>` frontmatter as
1350
+ // any other page: look the operation up and embed its playground inline.
1351
+ let apiOperation;
1352
+ if (indexMDX?.openapi) {
1353
+ apiOperation = this.apiRegistry.lookup(indexMDX.openapi);
1354
+ if (!apiOperation) {
1355
+ console.error(chalk.red(`❌ openapi frontmatter "${indexMDX.openapi}" in index.mdx not found in any spec`));
1356
+ }
1357
+ }
1358
+ const apiImport = apiOperation
1359
+ ? `\nimport { ApiPlayground } from "@/components/layout/ApiPlayground";`
1360
+ : "";
1361
+ const apiConst = apiOperation
1362
+ ? `\nconst operation = JSON.parse(${JSON.stringify(JSON.stringify(apiOperation))});\n`
1363
+ : "";
1364
+ const docsElement = apiOperation
1365
+ ? `<Docs content={content} sourcePath="index.mdx">
1366
+ <ApiPlayground operation={operation} />
1367
+ </Docs>`
1368
+ : `<Docs content={content} sourcePath="index.mdx" />`;
949
1369
  const indexContent = `import { Metadata } from "next";
950
1370
  import { Docs } from "@/components/Docs";
951
- import { config } from "@/utils/config";
1371
+ import { config } from "@/utils/config";${apiImport}
952
1372
 
953
1373
  ${indexMDX ? `const content = \`${escapeTemplateContent(indexMDX.content)}\`;` : `const content = null;`}
954
-
1374
+ ${apiConst}
955
1375
  ${metadataBlock}
956
1376
 
957
1377
  export const dynamic = "force-static";
@@ -963,7 +1383,7 @@ export default function Home() {
963
1383
  return (
964
1384
  <>
965
1385
  ${homeJsonLd.element}
966
- <Docs content={content} sourcePath="index.mdx" />
1386
+ ${docsElement}
967
1387
  </>
968
1388
  );
969
1389
  }
@@ -1125,6 +1545,11 @@ export default function Page() {
1125
1545
  return { url, name, description };
1126
1546
  }
1127
1547
  async readPageWithBody(page) {
1548
+ // Synthetic OpenAPI pages have no backing .mdx file; their markdown body
1549
+ // comes from the registry instead of disk.
1550
+ if (!page.path.endsWith(".mdx")) {
1551
+ return { ...page, body: this.apiRegistry.bodyForSlug(page.slug) ?? "" };
1552
+ }
1128
1553
  const fullPath = path.join(this.watchDir, page.path);
1129
1554
  const raw = await fs.readFile(fullPath, "utf8");
1130
1555
  const { content: body } = matter(raw);
@@ -1223,6 +1648,14 @@ export default function Page() {
1223
1648
  await this.analyticsWatcher.close();
1224
1649
  console.log(chalk.yellow("👋 Stopped watching for analytics config changes"));
1225
1650
  }
1651
+ if (this.openApiWatcher) {
1652
+ await this.openApiWatcher.close();
1653
+ console.log(chalk.yellow("👋 Stopped watching for OpenAPI spec changes"));
1654
+ }
1655
+ if (this.doccupineConfigWatcher) {
1656
+ await this.doccupineConfigWatcher.close();
1657
+ console.log(chalk.yellow("👋 Stopped watching for doccupine.json changes"));
1658
+ }
1226
1659
  if (this.publicWatcher) {
1227
1660
  await this.publicWatcher.close();
1228
1661
  console.log(chalk.yellow("👋 Stopped watching for public directory changes"));
@@ -1249,7 +1682,7 @@ program
1249
1682
  reset: options.reset,
1250
1683
  port: options.port,
1251
1684
  });
1252
- const generator = new MDXToNextJSGenerator(config.watchDir, config.outputDir);
1685
+ const generator = new MDXToNextJSGenerator(config.watchDir, config.outputDir, normalizeOpenApiConfig(config.openapi));
1253
1686
  // Config paths are project-relative; child processes get an absolute cwd.
1254
1687
  const outputDir = path.resolve(process.cwd(), config.outputDir);
1255
1688
  await generator.init();
@@ -1341,7 +1774,7 @@ program
1341
1774
  const config = await configManager.getConfig({
1342
1775
  reset: options.reset,
1343
1776
  });
1344
- const generator = new MDXToNextJSGenerator(config.watchDir, config.outputDir);
1777
+ const generator = new MDXToNextJSGenerator(config.watchDir, config.outputDir, normalizeOpenApiConfig(config.openapi));
1345
1778
  await generator.init();
1346
1779
  console.log(chalk.green("🎉 Build complete!"));
1347
1780
  });