import path from "path"; import { readFileSync } from "fs"; import { aiSetupPrompt, cliSetupPrompt, convexSetupPrompt, getSdkSetupPrompt, pythonBackendSetupPrompt, restApiBackendSetupPrompt, supabaseSetupPrompt } from "../packages/shared/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt"; import { deindent } from "../packages/shared/src/utils/strings"; import { writeFileSyncIfChanged } from "./utils"; import { remindersPrompt } from "../packages/shared/src/ai/unified-prompts/reminders"; import { buildLlmsFullTxt } from "../packages/shared/src/ai/llms/llms"; const generatedComment = "This file is auto-generated by scripts/generate-setup-prompt-docs.ts. Do not edit it manually; edit packages/shared/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.ts instead."; type SdkSetupToolCategory = "frontend" | "backend" | "database" | "other"; type SdkSetupTool = { label: string, where: SdkSetupToolCategory[], filterGroups: ("js" | "python" | "other")[], imageUrl: string, monochromeLogo: boolean, tabs: { label: string, mdContent: string }[], extraFeatures: string[], }; const repoRoot = path.resolve(__dirname, ".."); const docsJson = JSON.parse(readFileSync(path.join(repoRoot, "docs-mintlify/docs.json"), "utf-8")); const setupPromptText = aiSetupPrompt; const sdkSetupTools: Record = { nextjs: { label: "Next.js", where: ["frontend", "backend"], filterGroups: ["js"], imageUrl: "/images/setup-tools/nextjs.svg", monochromeLogo: true, tabs: [{ label: "Next.js", mdContent: getSdkSetupPrompt("nextjs"), }], extraFeatures: [], }, react: { label: "React", where: ["frontend"], filterGroups: ["js"], imageUrl: "/images/setup-tools/react.svg", monochromeLogo: false, tabs: [{ label: "React", mdContent: getSdkSetupPrompt("react"), }], extraFeatures: [], }, js: { label: "Other JS/TS", where: ["frontend"], filterGroups: ["js"], imageUrl: "/images/setup-tools/javascript.svg", monochromeLogo: false, tabs: [{ label: "JS/TS", mdContent: getSdkSetupPrompt("js"), }], extraFeatures: [], }, "tanstack-start": { label: "Tanstack Start", where: ["frontend"], filterGroups: ["js"], imageUrl: "/images/setup-tools/tanstack.svg", monochromeLogo: true, tabs: [{ label: "Tanstack Start", mdContent: getSdkSetupPrompt("tanstack-start"), }], extraFeatures: ["tanstack-query"], }, "tanstack-query": { label: "Tanstack Query", where: ["frontend"], filterGroups: ["js"], imageUrl: "/images/setup-tools/tanstack.svg", monochromeLogo: true, tabs: [], extraFeatures: ["tanstack-query"], }, nodejs: { label: "Node.js", where: ["backend"], filterGroups: ["js"], imageUrl: "/images/setup-tools/nodejs.svg", monochromeLogo: false, tabs: [{ label: "Node.js", mdContent: getSdkSetupPrompt("nodejs"), }], extraFeatures: [], }, bun: { label: "Bun", where: ["backend"], filterGroups: ["js"], imageUrl: "/images/setup-tools/bun.svg", monochromeLogo: false, tabs: [{ label: "Bun", mdContent: getSdkSetupPrompt("bun"), }], extraFeatures: [], }, python: { label: "Python", where: ["backend"], filterGroups: ["python"], imageUrl: "/images/setup-tools/python.svg", monochromeLogo: false, tabs: [{ label: "Python", mdContent: pythonBackendSetupPrompt, }], extraFeatures: [], }, "rest-api": { label: "Other (REST API)", where: ["backend"], filterGroups: ["other"], imageUrl: "/images/setup-tools/cli.svg", monochromeLogo: true, tabs: [{ label: "Other (REST API)", mdContent: restApiBackendSetupPrompt, }], extraFeatures: [], }, convex: { label: "Convex", where: ["backend", "database"], filterGroups: ["js"], imageUrl: "/images/setup-tools/convex.svg", monochromeLogo: false, tabs: [{ label: "Convex", mdContent: convexSetupPrompt, }], extraFeatures: [], }, supabase: { label: "Supabase", where: ["database"], filterGroups: ["other"], imageUrl: "/images/setup-tools/supabase.svg", monochromeLogo: false, tabs: [{ label: "Supabase", mdContent: supabaseSetupPrompt, }], extraFeatures: [], }, cli: { label: "CLI", where: ["other"], filterGroups: ["other"], imageUrl: "/images/setup-tools/cli.svg", monochromeLogo: true, tabs: [{ label: "CLI", mdContent: cliSetupPrompt, }], extraFeatures: [], }, /*mcp: { label: "MCP", where: ["other"], filterGroups: ["other"], imageUrl: "/images/setup-tools/mcp.svg", monochromeLogo: true, tabs: [{ label: "MCP", mdContent: mcpSetupPrompt, }], extraFeatures: [], },*/ }; function slugify(value: string) { return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""); } const categoryLabels = new Map([ ["frontend", "Frontend"], ["backend", "Backend"], ["database", "Database"], ["other", "Other"], ]); const setupToolIds = Object.keys(sdkSetupTools); const setupTabs = Object.entries(sdkSetupTools).flatMap(([toolId, tool]) => { return tool.tabs.map((tab, tabIndex) => ({ id: `${toolId}-${slugify(tab.label)}-${tabIndex}`, toolLabel: tool.label, toolId, tabLabel: tab.label, mdContent: tab.mdContent, })); }); const setupTabMetadata = setupTabs.map((tab) => ({ toolId: tab.toolId, title: tab.tabLabel, })); const unifiedAiPromptTabTitle = "Unified AI Prompt"; function renderToolCards(category: SdkSetupToolCategory) { const tools = Object.entries(sdkSetupTools).filter(([, tool]) => tool.where.includes(category)); return tools.map(([toolId, tool]) => { const hasTabs = tool.tabs.length > 0; const iconMarkup = tool.monochromeLogo ? deindent`