alchemy 0.2.5 → 0.3.0

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 (151) hide show
  1. package/README.md +3 -3
  2. package/lib/ai/astro-file.d.ts +137 -0
  3. package/lib/ai/astro-file.js +173 -0
  4. package/lib/ai/client.d.ts +2 -10
  5. package/lib/ai/client.js +8 -24
  6. package/lib/ai/css-file.d.ts +131 -0
  7. package/lib/ai/css-file.js +158 -0
  8. package/lib/ai/data.d.ts +45 -5
  9. package/lib/ai/data.js +45 -10
  10. package/lib/ai/document.d.ts +44 -20
  11. package/lib/ai/document.js +95 -28
  12. package/lib/ai/html-file.d.ts +128 -0
  13. package/lib/ai/html-file.js +155 -0
  14. package/lib/ai/index.d.ts +7 -0
  15. package/lib/ai/index.js +7 -0
  16. package/lib/ai/json-file.d.ts +160 -0
  17. package/lib/ai/json-file.js +208 -0
  18. package/lib/ai/typescript-file.d.ts +140 -0
  19. package/lib/ai/typescript-file.js +176 -0
  20. package/lib/ai/vue-file.d.ts +126 -0
  21. package/lib/ai/vue-file.js +153 -0
  22. package/lib/ai/yaml-file.d.ts +169 -0
  23. package/lib/ai/yaml-file.js +236 -0
  24. package/lib/cloudflare/dns.d.ts +88 -0
  25. package/lib/cloudflare/dns.js +192 -0
  26. package/lib/cloudflare/index.d.ts +2 -1
  27. package/lib/cloudflare/index.js +2 -1
  28. package/lib/cloudflare/r2-rest-state-store.d.ts +125 -0
  29. package/lib/cloudflare/r2-rest-state-store.js +254 -0
  30. package/lib/cloudflare/response.d.ts +12 -0
  31. package/lib/cloudflare/response.js +0 -0
  32. package/lib/cloudflare/zone.d.ts +18 -0
  33. package/lib/cloudflare/zone.js +17 -4
  34. package/lib/dns/godaddy.d.ts +7 -0
  35. package/lib/dns/godaddy.js +21 -0
  36. package/lib/dns/import-dns.d.ts +82 -0
  37. package/lib/dns/import-dns.js +114 -0
  38. package/lib/dns/index.d.ts +2 -0
  39. package/lib/dns/index.js +2 -0
  40. package/lib/dns/record.d.ts +88 -0
  41. package/lib/dns/record.js +13 -0
  42. package/lib/fs/file-system-state-store.d.ts +17 -0
  43. package/lib/fs/file-system-state-store.js +87 -0
  44. package/lib/fs/folder.d.ts +10 -0
  45. package/lib/fs/folder.js +2 -2
  46. package/lib/fs/index.d.ts +4 -4
  47. package/lib/fs/index.js +4 -4
  48. package/lib/fs/{json-file.d.ts → static-json-file.d.ts} +2 -2
  49. package/lib/fs/static-json-file.js +14 -0
  50. package/lib/fs/{text-file.d.ts → static-text-file.d.ts} +2 -2
  51. package/lib/fs/{text-file.js → static-text-file.js} +1 -1
  52. package/lib/fs/{typescript-file.d.ts → static-typescript-file.d.ts} +2 -2
  53. package/lib/fs/{typescript-file.js → static-typescript-file.js} +1 -1
  54. package/lib/fs/{yaml-file.d.ts → static-yaml-file.d.ts} +2 -2
  55. package/lib/fs/{yaml-file.js → static-yaml-file.js} +1 -1
  56. package/lib/internal/getting-started.d.ts +10 -0
  57. package/lib/internal/getting-started.js +94 -0
  58. package/lib/internal/project.d.ts +13 -0
  59. package/lib/internal/project.js +101 -0
  60. package/lib/internal/providers.d.ts +23 -0
  61. package/lib/internal/providers.js +148 -0
  62. package/lib/resource.js +8 -1
  63. package/lib/scope.d.ts +1 -1
  64. package/lib/scope.js +4 -2
  65. package/lib/state.d.ts +1 -16
  66. package/lib/state.js +0 -87
  67. package/lib/test/bun.d.ts +11 -0
  68. package/lib/test/bun.js +36 -8
  69. package/lib/web/astro.d.ts +147 -0
  70. package/lib/web/astro.js +414 -0
  71. package/lib/{shadcn/component.js → web/shadcn-component.js} +2 -9
  72. package/lib/web/shadcn.d.ts +97 -0
  73. package/lib/web/shadcn.js +99 -0
  74. package/lib/web/tailwind.d.ts +64 -0
  75. package/lib/web/tailwind.js +97 -0
  76. package/lib/{vite → web}/vite.d.ts +5 -0
  77. package/lib/{vite → web}/vite.js +44 -44
  78. package/lib/web/vitepress/custom-theme.d.ts +173 -0
  79. package/lib/web/vitepress/custom-theme.js +336 -0
  80. package/lib/{vitepress → web/vitepress}/dependencies.d.ts +2 -2
  81. package/lib/{vitepress → web/vitepress}/dependencies.js +1 -1
  82. package/lib/web/vitepress/home-page.d.ts +244 -0
  83. package/lib/web/vitepress/home-page.js +134 -0
  84. package/lib/{vitepress → web/vitepress}/index.d.ts +1 -0
  85. package/lib/{vitepress → web/vitepress}/index.js +1 -0
  86. package/lib/{vitepress → web/vitepress}/vitepress.d.ts +10 -8
  87. package/lib/{vitepress → web/vitepress}/vitepress.js +11 -12
  88. package/package.json +6 -2
  89. package/src/ai/astro-file.ts +288 -0
  90. package/src/ai/client.ts +8 -28
  91. package/src/ai/css-file.ts +266 -0
  92. package/src/ai/data.ts +53 -16
  93. package/src/ai/document.ts +130 -33
  94. package/src/ai/html-file.ts +263 -0
  95. package/src/ai/index.ts +7 -0
  96. package/src/ai/json-file.ts +349 -0
  97. package/src/ai/typescript-file.ts +293 -0
  98. package/src/ai/vue-file.ts +261 -0
  99. package/src/ai/yaml-file.ts +368 -0
  100. package/src/apply.ts +0 -1
  101. package/src/cloudflare/dns.ts +344 -0
  102. package/src/cloudflare/index.ts +2 -1
  103. package/src/cloudflare/r2-rest-state-store.ts +353 -0
  104. package/src/cloudflare/response.ts +9 -0
  105. package/src/cloudflare/zone.ts +39 -23
  106. package/src/dns/godaddy.ts +29 -0
  107. package/src/dns/import-dns.ts +213 -0
  108. package/src/dns/index.ts +2 -0
  109. package/src/dns/record.ts +121 -0
  110. package/src/fs/file-system-state-store.ts +109 -0
  111. package/src/fs/folder.ts +14 -2
  112. package/src/fs/index.ts +4 -4
  113. package/src/fs/{json-file.ts → static-json-file.ts} +13 -3
  114. package/src/fs/{text-file.ts → static-text-file.ts} +5 -2
  115. package/src/fs/{typescript-file.ts → static-typescript-file.ts} +3 -3
  116. package/src/fs/{yaml-file.ts → static-yaml-file.ts} +5 -2
  117. package/src/internal/getting-started.ts +107 -0
  118. package/src/internal/project.ts +119 -0
  119. package/src/internal/providers.ts +209 -0
  120. package/src/resource.ts +10 -1
  121. package/src/scope.ts +5 -6
  122. package/src/state.ts +1 -111
  123. package/src/test/bun.ts +60 -10
  124. package/src/web/astro.ts +644 -0
  125. package/src/{shadcn/component.ts → web/shadcn-component.ts} +5 -13
  126. package/src/web/shadcn.ts +219 -0
  127. package/src/web/tailwind.ts +167 -0
  128. package/src/{vite → web}/vite.ts +54 -56
  129. package/src/web/vitepress/custom-theme.ts +514 -0
  130. package/src/{vitepress → web/vitepress}/dependencies.ts +2 -2
  131. package/src/web/vitepress/home-page.ts +363 -0
  132. package/src/{vitepress → web/vitepress}/index.ts +1 -0
  133. package/src/{vitepress → web/vitepress}/vitepress.ts +34 -27
  134. package/lib/cloudflare/state.d.ts +0 -82
  135. package/lib/cloudflare/state.js +0 -108
  136. package/lib/fs/json-file.js +0 -7
  137. package/lib/internal/docs.d.ts +0 -5
  138. package/lib/internal/docs.js +0 -287
  139. package/lib/shadcn/index.d.ts +0 -1
  140. package/lib/shadcn/index.js +0 -1
  141. package/lib/vite/index.d.ts +0 -1
  142. package/lib/vite/index.js +0 -1
  143. package/lib/vitepress/home-page.d.ts +0 -133
  144. package/lib/vitepress/home-page.js +0 -11
  145. package/src/cloudflare/state.ts +0 -138
  146. package/src/internal/docs.ts +0 -338
  147. package/src/shadcn/index.ts +0 -1
  148. package/src/vite/index.ts +0 -1
  149. package/src/vitepress/home-page.ts +0 -166
  150. /package/lib/{shadcn/component.d.ts → web/shadcn-component.d.ts} +0 -0
  151. /package/src/{vitepress → web/vitepress}/index.md +0 -0
@@ -0,0 +1,336 @@
1
+ import { type } from "arktype";
2
+ import path from "path";
3
+ import { CSSFile } from "../../ai/css-file";
4
+ import { Data } from "../../ai/data";
5
+ import { TypeScriptFile } from "../../ai/typescript-file";
6
+ import { VueFile } from "../../ai/vue-file";
7
+ import { alchemy } from "../../alchemy";
8
+ import { Folder } from "../../fs";
9
+ import { Resource } from "../../resource";
10
+ /**
11
+ * Resource for generating a custom VitePress theme using AI.
12
+ *
13
+ * Generates the necessary theme files including:
14
+ * - Theme entry file (index.ts)
15
+ * - Layout component (Layout.vue)
16
+ * - Additional components based on configuration
17
+ * - Style sheets and utilities
18
+ *
19
+ * @example
20
+ * // Create a basic custom theme
21
+ * const theme = await CustomTheme("docs-theme", {
22
+ * outDir: "./.vitepress/theme",
23
+ * title: "My Custom Theme",
24
+ * description: "A clean, minimal theme for documentation",
25
+ * prompt: "Create a clean documentation theme with a sidebar and search"
26
+ * });
27
+ *
28
+ * @example
29
+ * // Create a theme with specific components
30
+ * const complexTheme = await CustomTheme("blog-theme", {
31
+ * outDir: "./.vitepress/theme",
32
+ * title: "Blog Theme",
33
+ * description: "A theme for technical blogs",
34
+ * components: [
35
+ * {
36
+ * name: "PostList",
37
+ * description: "Component that displays a list of blog posts with pagination",
38
+ * features: ["thumbnail images", "post dates", "categories", "excerpts"]
39
+ * },
40
+ * {
41
+ * name: "TableOfContents",
42
+ * description: "Component that displays the current page's table of contents",
43
+ * features: ["sticky positioning", "active link highlighting"]
44
+ * }
45
+ * ],
46
+ * darkMode: true,
47
+ * prompt: "Create a modern blog theme with post listings and detailed article pages"
48
+ * });
49
+ *
50
+ * @example
51
+ * // Create a theme with custom CSS variables
52
+ * const brandedTheme = await CustomTheme("branded-theme", {
53
+ * outDir: "./.vitepress/theme",
54
+ * title: "Branded Docs",
55
+ * description: "A themed documentation site with custom branding",
56
+ * customCssVars: {
57
+ * "--vp-c-brand": "#3a70b0",
58
+ * "--vp-c-brand-light": "#5785bc",
59
+ * "--vp-c-brand-lighter": "#79a1ce",
60
+ * "--vp-c-brand-dark": "#2c5989",
61
+ * "--vp-c-brand-darker": "#1e3d5c"
62
+ * },
63
+ * prompt: "Create a documentation theme with custom branding and color scheme"
64
+ * });
65
+ */
66
+ export const CustomTheme = Resource("vitepress::CustomTheme", async function (id, props) {
67
+ // Handle deletion
68
+ if (this.phase === "delete") {
69
+ // No need to actually delete files, as they're not critical infrastructure
70
+ // In a real implementation, you might want to clean up files
71
+ return this.destroy();
72
+ }
73
+ // Ensure the output directory exists
74
+ await Folder(props.outDir);
75
+ // Create components directory if it doesn't exist
76
+ await Folder(path.join(props.outDir, "components"));
77
+ // Build the system prompt with optional extension
78
+ const systemPrompt = `
79
+ You are creating a custom VitePress theme.
80
+
81
+ A VitePress custom theme consists of multiple files:
82
+ 1. An entry file (index.ts or index.js) that exports the theme object
83
+ 2. A Layout component (Layout.vue) that handles the overall page structure
84
+ 3. Optional additional Vue components for specific functionality
85
+ 4. Optional style files for theming and customization
86
+
87
+ The theme entry file must export an object with:
88
+ - Layout: The root layout component (required)
89
+ - enhanceApp: Function to enhance the Vue app (optional)
90
+ - extends: Another theme to extend (optional)
91
+
92
+ Follow these guidelines:
93
+ 1. Use Vue 3 Composition API and <script setup> syntax
94
+ 2. Ensure the theme is SSR-compatible
95
+ 3. Use the useData() composable to access page and site data
96
+ 4. Handle different page layouts (home, 404, regular pages)
97
+ 5. Include proper TypeScript types
98
+ 6. Use modern JavaScript/TypeScript features
99
+ 7. Include clear comments explaining key functionality
100
+ 8. Make components reusable and customizable
101
+ 9. Include support for dark mode if requested
102
+
103
+ ${props.systemPromptExtension || ""}
104
+ `;
105
+ // Generate the theme entry file (index.ts)
106
+ const indexFile = await TypeScriptFile(`${id}-index`, {
107
+ path: path.join(props.outDir, "index.ts"),
108
+ prompt: await alchemy `
109
+ Create a VitePress theme entry file (index.ts) for a theme named "${props.title}".
110
+
111
+ The theme should:
112
+ - Export a default theme object with the required properties
113
+ - Import the Layout component
114
+ - Include a proper enhanceApp function
115
+ - Include TypeScript types
116
+ - Have clear comments explaining the code
117
+
118
+ ${props.description ? `Theme description: ${props.description}` : ""}
119
+ ${props.plugins?.length ? `Include these plugins: ${props.plugins.join(", ")}` : ""}
120
+
121
+ The output should be a complete, well-structured TypeScript file.
122
+ `,
123
+ system: `${systemPrompt}
124
+ You are writing a TypeScript entry file for a VitePress theme.`,
125
+ baseURL: props.baseURL,
126
+ apiKey: props.apiKey,
127
+ model: props.model,
128
+ temperature: props.temperature,
129
+ });
130
+ // Generate the Layout component
131
+ const layoutFile = await VueFile(`${id}-layout`, {
132
+ path: path.join(props.outDir, "Layout.vue"),
133
+ prompt: await alchemy `
134
+ Create a Layout.vue component for a VitePress theme named "${props.title}".
135
+
136
+ The layout should:
137
+ - Use <script setup> with the Composition API
138
+ - Import and use the useData() composable
139
+ - Handle different page types (regular pages, home pages, 404 pages)
140
+ - Include a <Content /> component to render the page content
141
+ - Have a clean, modern design
142
+ - Include proper TypeScript types
143
+ - Use Vue's Teleport for elements like modals if needed
144
+
145
+ The layout should use modular components for different parts of the UI, such as:
146
+ - NavBar/Header component for navigation
147
+ - Sidebar component for documentation navigation
148
+ - Footer component
149
+ - Home page specific components (like hero sections)
150
+ - 404 page component
151
+
152
+ These components should be imported from the components directory.
153
+
154
+ ${props.description ? `Theme description: ${props.description}` : ""}
155
+ ${props.darkMode !== false ? "Include support for dark mode" : "Dark mode is not required"}
156
+
157
+ The layout should follow the user's requirements:
158
+ ${props.prompt}
159
+
160
+ The output should be a complete, well-structured Vue component file.
161
+ `,
162
+ system: `${systemPrompt}
163
+ You are writing a Vue component for a VitePress theme Layout.
164
+ Import smaller components from the components directory using relative paths (e.g., import NavBar from './components/NavBar.vue').
165
+ Break down the layout into logical components like NavBar, Sidebar, Footer, etc., which will be generated separately.`,
166
+ baseURL: props.baseURL,
167
+ apiKey: props.apiKey,
168
+ model: props.model,
169
+ temperature: props.temperature,
170
+ });
171
+ // Extract component imports from the Layout.vue file
172
+ const componentImportsData = await Data(`${id}-component-imports`, {
173
+ schema: type({
174
+ components: type({
175
+ name: type("string").describe("Component name as used in the import statement (e.g., NavBar, Footer)"),
176
+ path: type("string").describe("Import path as written in the import statement (e.g., './components/NavBar.vue')"),
177
+ purpose: type("string").describe("A clear description of the component's purpose, functionality, and responsibilities in the layout"),
178
+ }).array(),
179
+ }),
180
+ prompt: await alchemy `
181
+ Analyze the following Layout.vue file and extract information about all the component imports:
182
+
183
+ ${layoutFile.content}
184
+
185
+ For each component import:
186
+ 1. Extract the component name (e.g., NavBar)
187
+ 2. Extract the import path (e.g., ./components/NavBar.vue)
188
+ 3. Infer the purpose of the component based on its name and usage in the file
189
+
190
+ Return a structured list of all component imports found in the file.
191
+ Only include components that are imported from local files (not from VitePress or other libraries).
192
+ Focus on components that are likely Vue components (.vue files).
193
+ `,
194
+ system: "You are a code analyzer tasked with extracting component imports from a Vue file. Be precise and thorough in identifying all local component imports.",
195
+ baseURL: props.baseURL,
196
+ apiKey: props.apiKey,
197
+ model: props.model,
198
+ temperature: props.temperature || 0.2, // Lower temperature for more deterministic extraction
199
+ });
200
+ // Generate the detected components
201
+ const autoComponentFiles = await Promise.all(componentImportsData.object.components.map(async (component) => {
202
+ const componentName = component.name;
203
+ const componentPath = component.path;
204
+ const componentPurpose = component.purpose;
205
+ // Extract the relative path from the import
206
+ const relativePath = componentPath.startsWith("./")
207
+ ? componentPath.slice(2) // Remove './'
208
+ : componentPath.startsWith("/")
209
+ ? componentPath.slice(1) // Remove '/'
210
+ : componentPath;
211
+ // Compute the full file path
212
+ const fullPath = path.join(props.outDir, relativePath);
213
+ return VueFile(`${id}-component-${componentName}`, {
214
+ path: fullPath,
215
+ prompt: await alchemy `
216
+ Create a Vue component named "${componentName}" for a VitePress theme.
217
+
218
+ Component purpose: ${componentPurpose}
219
+
220
+ The component should:
221
+ - Use <script setup> with the Composition API
222
+ - Have a clean, focused design for its specific purpose
223
+ - Include proper TypeScript types
224
+ - Be reusable and customizable
225
+ - Include clear comments explaining key functionality
226
+ - Fit seamlessly with the overall theme design described below
227
+
228
+ This component will be used in the following layout context:
229
+ ${layoutFile.content}
230
+
231
+ ${props.description ? `Theme description: ${props.description}` : ""}
232
+ ${props.darkMode !== false ? "Include support for dark mode" : "Dark mode is not required"}
233
+
234
+ The component should follow the user's theme requirements:
235
+ ${props.prompt}
236
+ `,
237
+ system: `${systemPrompt}
238
+ You are writing a Vue component for a VitePress theme. This component (${componentName}) is intended to ${componentPurpose}.
239
+ Make sure it integrates well with the overall layout and theme style.`,
240
+ baseURL: props.baseURL,
241
+ apiKey: props.apiKey,
242
+ model: props.model,
243
+ temperature: props.temperature,
244
+ });
245
+ }));
246
+ // Generate user-specified components if provided
247
+ const userComponentFiles = await Promise.all((props.components || []).map(async (component) => {
248
+ return VueFile(`${id}-user-component-${component.name}`, {
249
+ path: path.join(props.outDir, "components", `${component.name}.vue`),
250
+ prompt: await alchemy `
251
+ Create a Vue component named "${component.name}" for a VitePress theme.
252
+
253
+ Component description: ${component.description}
254
+
255
+ The component should:
256
+ - Use <script setup> with the Composition API
257
+ - Have a clean, focused design for its specific purpose
258
+ - Include proper TypeScript types
259
+ - Be reusable and customizable
260
+ - Include clear comments
261
+
262
+ ${component.features?.length
263
+ ? `Include these features:
264
+ ${component.features.map((f) => `- ${f}`).join("\n")}`
265
+ : ""}
266
+
267
+ Make sure the component integrates well with the overall theme.
268
+
269
+ The output should be a complete, well-structured Vue component file.
270
+ `,
271
+ system: `${systemPrompt}
272
+ You are writing a Vue component for a VitePress theme.`,
273
+ baseURL: props.baseURL,
274
+ apiKey: props.apiKey,
275
+ model: props.model,
276
+ temperature: props.temperature,
277
+ });
278
+ }));
279
+ // Generate styles file
280
+ const stylesFile = await CSSFile(`${id}-styles`, {
281
+ path: path.join(props.outDir, "styles.css"),
282
+ prompt: await alchemy `
283
+ Create a CSS styles file for a VitePress theme named "${props.title}".
284
+
285
+ The styles should:
286
+ - Define a cohesive set of styles for the theme
287
+ - Include CSS variables for customization
288
+ - Use modern CSS features
289
+ - Be well-organized with clear comments
290
+ ${props.darkMode !== false ? "- Include dark mode variants using :root.dark selectors" : ""}
291
+
292
+ ${props.description ? `Theme description: ${props.description}` : ""}
293
+
294
+ ${props.customCssVars
295
+ ? `Include these custom CSS variables:
296
+ ${Object.entries(props.customCssVars)
297
+ .map(([key, value]) => `${key}: ${value};`)
298
+ .join("\n")}`
299
+ : ""}
300
+
301
+ Style according to the user's requirements:
302
+ ${props.prompt}
303
+
304
+ The output should be a complete, well-structured CSS file.
305
+ `,
306
+ system: `${systemPrompt}
307
+ You are writing CSS styles for a VitePress theme.`,
308
+ baseURL: props.baseURL,
309
+ apiKey: props.apiKey,
310
+ model: props.model,
311
+ temperature: props.temperature,
312
+ });
313
+ // Collect all generated files
314
+ const allFiles = [
315
+ indexFile,
316
+ layoutFile,
317
+ ...autoComponentFiles,
318
+ ...userComponentFiles,
319
+ stylesFile,
320
+ ];
321
+ // Create file objects for resource output
322
+ const files = allFiles.map((file) => ({
323
+ path: file.path,
324
+ content: file.content,
325
+ }));
326
+ // Get the current timestamp
327
+ const now = Date.now();
328
+ // Return the resource using this() to construct output
329
+ return this({
330
+ ...props,
331
+ themePath: props.outDir,
332
+ files,
333
+ createdAt: this.output?.createdAt || now,
334
+ updatedAt: now,
335
+ });
336
+ });
@@ -1,5 +1,5 @@
1
- import type { Context } from "../context";
2
- import { Resource } from "../resource";
1
+ import type { Context } from "../../context";
2
+ import { Resource } from "../../resource";
3
3
  export type InstallDependencies = Resource<"project::InstallDependencies">;
4
4
  export declare const InstallDependencies: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<InstallDependencies>, id: string, { cwd, dependencies, devDependencies, }: {
5
5
  cwd: string;
@@ -1,6 +1,6 @@
1
1
  import { exec } from "child_process";
2
2
  import { promisify } from "util";
3
- import { Resource } from "../resource";
3
+ import { Resource } from "../../resource";
4
4
  const execAsync = promisify(exec);
5
5
  export const InstallDependencies = Resource("project::InstallDependencies", {
6
6
  alwaysUpdate: true,
@@ -0,0 +1,244 @@
1
+ import type { Secret } from "../../secret";
2
+ /**
3
+ * Image that can be themed for light/dark mode
4
+ */
5
+ export interface ThemeableImage {
6
+ /**
7
+ * Image source URL
8
+ */
9
+ src?: string;
10
+ /**
11
+ * Image alt text
12
+ */
13
+ alt?: string;
14
+ /**
15
+ * Light theme image URL
16
+ */
17
+ light?: string;
18
+ /**
19
+ * Dark theme image URL
20
+ */
21
+ dark?: string;
22
+ }
23
+ /**
24
+ * Hero action button configuration
25
+ */
26
+ export interface HeroAction {
27
+ /**
28
+ * Color theme of the button
29
+ * @default "brand"
30
+ */
31
+ theme?: "brand" | "alt";
32
+ /**
33
+ * Label of the button
34
+ */
35
+ text: string;
36
+ /**
37
+ * Destination link of the button
38
+ */
39
+ link: string;
40
+ /**
41
+ * Link target attribute
42
+ */
43
+ target?: string;
44
+ /**
45
+ * Link rel attribute
46
+ */
47
+ rel?: string;
48
+ }
49
+ /**
50
+ * Hero section configuration
51
+ */
52
+ export interface Hero {
53
+ /**
54
+ * The string shown top of text. Comes with brand color
55
+ * and expected to be short, such as product name.
56
+ */
57
+ name?: string;
58
+ /**
59
+ * The main text for the hero section. This will be defined
60
+ * as h1 tag.
61
+ */
62
+ text: string;
63
+ /**
64
+ * Tagline displayed below text
65
+ */
66
+ tagline?: string;
67
+ /**
68
+ * The image displayed next to the text and tagline area
69
+ */
70
+ image?: string | ThemeableImage;
71
+ /**
72
+ * Action buttons to display in home hero section
73
+ */
74
+ actions?: HeroAction[];
75
+ }
76
+ /**
77
+ * Feature item configuration
78
+ */
79
+ export interface Feature {
80
+ /**
81
+ * Show icon on each feature box
82
+ */
83
+ icon?: string | ThemeableImage;
84
+ /**
85
+ * Title of the feature
86
+ */
87
+ title: string;
88
+ /**
89
+ * Details of the feature
90
+ */
91
+ details: string;
92
+ /**
93
+ * Link when clicked on feature component
94
+ */
95
+ link?: string;
96
+ /**
97
+ * Link text to be shown inside feature component
98
+ */
99
+ linkText?: string;
100
+ /**
101
+ * Link rel attribute
102
+ */
103
+ rel?: string;
104
+ /**
105
+ * Link target attribute
106
+ */
107
+ target?: string;
108
+ }
109
+ /**
110
+ * VitePress home page configuration
111
+ */
112
+ export interface HomePageConfig {
113
+ /**
114
+ * Use home page layout
115
+ */
116
+ layout: "home";
117
+ /**
118
+ * Hero section configuration
119
+ */
120
+ hero?: Hero;
121
+ /**
122
+ * Features section configuration
123
+ */
124
+ features?: Feature[];
125
+ /**
126
+ * Whether to apply default markdown styles
127
+ * @default true
128
+ */
129
+ markdownStyles?: boolean;
130
+ }
131
+ /**
132
+ * Properties for creating or updating a VitePress HomePage
133
+ */
134
+ export interface HomePageProps {
135
+ /**
136
+ * Output directory for the home page markdown file
137
+ */
138
+ outFile: string;
139
+ /**
140
+ * Title of the home page document
141
+ */
142
+ title: string;
143
+ /**
144
+ * Hero section configuration
145
+ */
146
+ hero?: Hero;
147
+ /**
148
+ * Features section configuration
149
+ */
150
+ features?: Feature[];
151
+ /**
152
+ * User prompt describing the design of the home page
153
+ */
154
+ prompt: string;
155
+ /**
156
+ * Optional extension to the built-in system prompt
157
+ */
158
+ systemPromptExtension?: string;
159
+ /**
160
+ * Base URL for the OpenAI API
161
+ * @default 'https://api.openai.com/v1'
162
+ */
163
+ baseURL?: string;
164
+ /**
165
+ * OpenAI API key to use for generating content
166
+ * If not provided, will use OPENAI_API_KEY environment variable
167
+ */
168
+ apiKey?: Secret;
169
+ /**
170
+ * Model configuration for the AI generator
171
+ */
172
+ model?: import("../../ai/client").ModelConfig;
173
+ /**
174
+ * Temperature for controlling randomness in generation
175
+ * @default 0.7
176
+ */
177
+ temperature?: number;
178
+ }
179
+ /**
180
+ * Output type for the HomePage resource
181
+ */
182
+ export type HomePage = import("../../ai/document").Document;
183
+ /**
184
+ * Parse YAML frontmatter to home page config
185
+ */
186
+ export declare function parseHomePage(content: string): HomePageConfig;
187
+ /**
188
+ * Resource for generating a VitePress homepage using AI.
189
+ * Creates an index.md file with the appropriate frontmatter and content
190
+ * based on the provided prompt and configuration.
191
+ *
192
+ * @example
193
+ * // Create a basic home page with just a prompt
194
+ * const homePage = await HomePage("docs-home", {
195
+ * outDir: "./docs",
196
+ * title: "My Project Documentation",
197
+ * prompt: "Create a welcoming homepage for a JavaScript utility library with modern design"
198
+ * });
199
+ *
200
+ * @example
201
+ * // Create a home page with hero and features configuration
202
+ * const detailedHome = await HomePage("product-home", {
203
+ * outDir: "./website",
204
+ * title: "Product Landing Page",
205
+ * prompt: "Create an engaging product page for our cloud database service",
206
+ * hero: {
207
+ * name: "CloudDB",
208
+ * text: "The database built for the cloud era",
209
+ * tagline: "Scalable, reliable, and developer-friendly",
210
+ * image: "/images/cloud-db-logo.png",
211
+ * actions: [
212
+ * { text: "Get Started", link: "/guide/", theme: "brand" },
213
+ * { text: "View on GitHub", link: "https://github.com/org/cloud-db" }
214
+ * ]
215
+ * },
216
+ * features: [
217
+ * {
218
+ * icon: "🚀",
219
+ * title: "Lightning Fast",
220
+ * details: "Optimized for performance at any scale"
221
+ * },
222
+ * {
223
+ * icon: "🔒",
224
+ * title: "Secure by Default",
225
+ * details: "Enterprise-grade security built in"
226
+ * }
227
+ * ]
228
+ * });
229
+ *
230
+ * @example
231
+ * // Create a home page with custom model settings
232
+ * const customHome = await HomePage("docs-home", {
233
+ * outDir: "./docs",
234
+ * title: "API Documentation",
235
+ * prompt: "Create a technical homepage for our REST API documentation",
236
+ * model: {
237
+ * id: "gpt-4o",
238
+ * provider: "openai"
239
+ * },
240
+ * temperature: 0.3,
241
+ * systemPromptExtension: "Make sure to use technical terminology appropriate for developers."
242
+ * });
243
+ */
244
+ export declare function HomePage(id: string, props: HomePageProps): Promise<HomePage>;