alchemy 0.3.0 → 0.3.1

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 (107) hide show
  1. package/lib/ai/approve.d.ts +99 -0
  2. package/lib/ai/approve.js +76 -0
  3. package/lib/ai/astro-file.js +7 -24
  4. package/lib/ai/client.d.ts +7 -0
  5. package/lib/ai/client.js +45 -0
  6. package/lib/ai/css-file.js +7 -24
  7. package/lib/ai/data.d.ts +26 -21
  8. package/lib/ai/data.js +33 -22
  9. package/lib/ai/document.d.ts +64 -4
  10. package/lib/ai/document.js +102 -55
  11. package/lib/ai/html-file.js +7 -24
  12. package/lib/ai/index.d.ts +2 -0
  13. package/lib/ai/index.js +2 -0
  14. package/lib/ai/json-file.js +11 -32
  15. package/lib/ai/review.d.ts +122 -0
  16. package/lib/ai/review.js +101 -0
  17. package/lib/ai/typescript-file.d.ts +1 -2
  18. package/lib/ai/typescript-file.js +8 -39
  19. package/lib/ai/vue-file.js +7 -24
  20. package/lib/ai/yaml-file.js +12 -48
  21. package/lib/alchemy.js +17 -2
  22. package/lib/apply.js +1 -1
  23. package/lib/cloudflare/generate-asset-manifest.js +1 -1
  24. package/lib/cloudflare/static-site-router.js +16 -7
  25. package/lib/cloudflare/static-site.js +3 -0
  26. package/lib/cloudflare/upload-asset-manifest.js +4 -2
  27. package/lib/fs/copy-file.d.ts +54 -0
  28. package/lib/fs/copy-file.js +63 -0
  29. package/lib/fs/file.d.ts +13 -0
  30. package/lib/fs/file.js +24 -5
  31. package/lib/fs/index.d.ts +6 -0
  32. package/lib/fs/index.js +6 -0
  33. package/lib/fs/static-astro-file.d.ts +34 -0
  34. package/lib/fs/static-astro-file.js +39 -0
  35. package/lib/fs/static-css-file.d.ts +24 -0
  36. package/lib/fs/static-css-file.js +29 -0
  37. package/lib/fs/static-html-file.d.ts +31 -0
  38. package/lib/fs/static-html-file.js +36 -0
  39. package/lib/fs/static-json-file.d.ts +2 -2
  40. package/lib/fs/static-json-file.js +3 -2
  41. package/lib/fs/static-text-file.d.ts +1 -1
  42. package/lib/fs/static-text-file.js +3 -2
  43. package/lib/fs/static-typescript-file.d.ts +2 -2
  44. package/lib/fs/static-typescript-file.js +3 -2
  45. package/lib/fs/static-vue-file.d.ts +28 -0
  46. package/lib/fs/static-vue-file.js +33 -0
  47. package/lib/fs/static-yaml-file.d.ts +11 -8
  48. package/lib/fs/static-yaml-file.js +3 -2
  49. package/lib/internal/getting-started.d.ts +15 -4
  50. package/lib/internal/getting-started.js +34 -41
  51. package/lib/internal/index.d.ts +3 -0
  52. package/lib/internal/index.js +3 -0
  53. package/lib/internal/providers.d.ts +7 -3
  54. package/lib/internal/providers.js +42 -18
  55. package/lib/internal/tutorial.d.ts +104 -0
  56. package/lib/internal/tutorial.js +251 -0
  57. package/lib/web/vitepress/config.d.ts +10 -0
  58. package/lib/web/vitepress/config.js +31 -0
  59. package/lib/web/vitepress/home-page.d.ts +5 -3
  60. package/lib/web/vitepress/home-page.js +48 -35
  61. package/lib/web/vitepress/index.d.ts +1 -0
  62. package/lib/web/vitepress/index.js +1 -0
  63. package/lib/web/vitepress/vitepress.d.ts +5 -4
  64. package/lib/web/vitepress/vitepress.js +17 -34
  65. package/package.json +1 -1
  66. package/src/ai/approve.ts +163 -0
  67. package/src/ai/astro-file.ts +11 -30
  68. package/src/ai/client.ts +59 -0
  69. package/src/ai/css-file.ts +11 -30
  70. package/src/ai/data.ts +50 -25
  71. package/src/ai/document.ts +146 -65
  72. package/src/ai/html-file.ts +11 -30
  73. package/src/ai/index.ts +2 -0
  74. package/src/ai/json-file.ts +13 -37
  75. package/src/ai/review.ts +213 -0
  76. package/src/ai/typescript-file.ts +14 -48
  77. package/src/ai/vue-file.ts +11 -30
  78. package/src/ai/yaml-file.ts +13 -53
  79. package/src/alchemy.ts +18 -7
  80. package/src/apply.ts +8 -8
  81. package/src/cloudflare/generate-asset-manifest.ts +4 -4
  82. package/src/cloudflare/static-site-router.ts +18 -8
  83. package/src/cloudflare/static-site.ts +11 -7
  84. package/src/cloudflare/upload-asset-manifest.ts +6 -4
  85. package/src/cloudflare/worker.ts +44 -43
  86. package/src/fs/copy-file.ts +115 -0
  87. package/src/fs/file.ts +35 -9
  88. package/src/fs/index.ts +6 -0
  89. package/src/fs/static-astro-file.ts +45 -0
  90. package/src/fs/static-css-file.ts +35 -0
  91. package/src/fs/static-html-file.ts +42 -0
  92. package/src/fs/static-json-file.ts +4 -3
  93. package/src/fs/static-text-file.ts +5 -2
  94. package/src/fs/static-typescript-file.ts +4 -3
  95. package/src/fs/static-vue-file.ts +39 -0
  96. package/src/fs/static-yaml-file.ts +13 -9
  97. package/src/internal/getting-started.ts +51 -43
  98. package/src/internal/index.ts +3 -0
  99. package/src/internal/providers.ts +59 -27
  100. package/src/internal/tutorial.ts +392 -0
  101. package/src/web/vitepress/config.ts +48 -0
  102. package/src/web/vitepress/home-page.ts +54 -42
  103. package/src/web/vitepress/index.ts +1 -0
  104. package/src/web/vitepress/vitepress.ts +31 -48
  105. package/lib/internal/project.d.ts +0 -13
  106. package/lib/internal/project.js +0 -101
  107. package/src/internal/project.ts +0 -119
package/src/fs/index.ts CHANGED
@@ -1,8 +1,14 @@
1
+ export * from "./copy-file";
1
2
  export * from "./file";
2
3
  export * from "./file-collection";
3
4
  export * from "./file-ref";
5
+ export * from "./file-system-state-store";
4
6
  export * from "./folder";
7
+ export * from "./static-astro-file";
8
+ export * from "./static-css-file";
9
+ export * from "./static-html-file";
5
10
  export * from "./static-json-file";
6
11
  export * from "./static-text-file";
7
12
  export * from "./static-typescript-file";
13
+ export * from "./static-vue-file";
8
14
  export * from "./static-yaml-file";
@@ -0,0 +1,45 @@
1
+ import { File } from "./file";
2
+
3
+ export type StaticAstroFile = File;
4
+
5
+ /**
6
+ * Creates a static Astro component file
7
+ *
8
+ * @example
9
+ * // Create an Astro component file with content
10
+ * const header = await StaticAstroFile("Header.astro",
11
+ * `---
12
+ * import Logo from '../components/Logo.astro';
13
+ * const navItems = ['Home', 'About', 'Contact'];
14
+ * ---
15
+ *
16
+ * <header class="header">
17
+ * <Logo />
18
+ * <nav>
19
+ * <ul>
20
+ * {navItems.map(item => (
21
+ * <li><a href={`/${item.toLowerCase()}`}>{item}</a></li>
22
+ * ))}
23
+ * </ul>
24
+ * </nav>
25
+ * </header>
26
+ *
27
+ * <style>
28
+ * .header {
29
+ * display: flex;
30
+ * justify-content: space-between;
31
+ * padding: 1rem;
32
+ * }
33
+ * </style>`
34
+ * );
35
+ */
36
+ export function StaticAstroFile(
37
+ id: string,
38
+ ...args: [content: string] | [path: string, content: string]
39
+ ): Promise<StaticAstroFile> {
40
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
41
+ return File(id, {
42
+ path,
43
+ content,
44
+ });
45
+ }
@@ -0,0 +1,35 @@
1
+ import { File } from "./file";
2
+
3
+ export type StaticCSSFile = File;
4
+
5
+ /**
6
+ * Creates a static CSS file
7
+ *
8
+ * @example
9
+ * // Create a CSS file with styles
10
+ * const styles = await StaticCSSFile("styles.css",
11
+ * `.container {
12
+ * max-width: 1200px;
13
+ * margin: 0 auto;
14
+ * padding: 0 1rem;
15
+ * }
16
+ *
17
+ * .button {
18
+ * background-color: #0062ff;
19
+ * color: white;
20
+ * border: none;
21
+ * padding: 0.5rem 1rem;
22
+ * border-radius: 4px;
23
+ * }`
24
+ * );
25
+ */
26
+ export function StaticCSSFile(
27
+ id: string,
28
+ ...args: [content: string] | [path: string, content: string]
29
+ ): Promise<StaticCSSFile> {
30
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
31
+ return File(id, {
32
+ path,
33
+ content,
34
+ });
35
+ }
@@ -0,0 +1,42 @@
1
+ import { File } from "./file";
2
+
3
+ export type StaticHTMLFile = File;
4
+
5
+ /**
6
+ * Creates a static HTML file
7
+ *
8
+ * @example
9
+ * // Create an HTML file with content
10
+ * const page = await StaticHTMLFile("index.html",
11
+ * `<!DOCTYPE html>
12
+ * <html lang="en">
13
+ * <head>
14
+ * <meta charset="UTF-8">
15
+ * <meta name="viewport" content="width=device-width, initial-scale=1.0">
16
+ * <title>My Website</title>
17
+ * <link rel="stylesheet" href="styles.css">
18
+ * </head>
19
+ * <body>
20
+ * <header>
21
+ * <h1>Welcome to My Website</h1>
22
+ * </header>
23
+ * <main>
24
+ * <p>This is the main content of the page.</p>
25
+ * </main>
26
+ * <footer>
27
+ * <p>&copy; 2024 My Company</p>
28
+ * </footer>
29
+ * </body>
30
+ * </html>`
31
+ * );
32
+ */
33
+ export function StaticHTMLFile(
34
+ id: string,
35
+ ...args: [content: string] | [path: string, content: string]
36
+ ): Promise<StaticHTMLFile> {
37
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
38
+ return File(id, {
39
+ path,
40
+ content,
41
+ });
42
+ }
@@ -5,7 +5,7 @@ import { File } from "./file";
5
5
  *
6
6
  * @example
7
7
  * // Create a JSON configuration file
8
- * const config = await JsonFile("config.json", {
8
+ * const config = await StaticJsonFile("config.json", {
9
9
  * api: {
10
10
  * endpoint: "https://api.example.com",
11
11
  * version: "v1"
@@ -17,11 +17,12 @@ export type StaticJsonFile = File;
17
17
 
18
18
  export async function StaticJsonFile(
19
19
  id: string,
20
- content: any,
20
+ ...args: [content: any] | [path: string, content: any]
21
21
  ): Promise<StaticJsonFile> {
22
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
22
23
  const prettier = await import("prettier");
23
24
  return File(id, {
24
- path: id,
25
+ path,
25
26
  content: await prettier.format(JSON.stringify(content), {
26
27
  parser: "json",
27
28
  editor: {
@@ -13,10 +13,13 @@ export type StaticTextFile = File;
13
13
 
14
14
  export function StaticTextFile(
15
15
  id: string,
16
- content: string,
16
+ ...args:
17
+ | [content: string]
18
+ | [path: string, content: string]
17
19
  ): Promise<StaticTextFile> {
20
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
18
21
  return File(id, {
19
- path: id,
22
+ path,
20
23
  content,
21
24
  });
22
25
  }
@@ -5,7 +5,7 @@ import { File } from "./file";
5
5
  *
6
6
  * @example
7
7
  * // Create a TypeScript file
8
- * const component = await TypeScriptFile("Component.ts", `
8
+ * const component = await StaticTypeScriptFile("Component.ts", `
9
9
  * interface Props {
10
10
  * name: string;
11
11
  * age: number;
@@ -20,11 +20,12 @@ export type StaticTypeScriptFile = File;
20
20
 
21
21
  export async function StaticTypeScriptFile(
22
22
  id: string,
23
- content: string,
23
+ ...args: [content: string] | [path: string, content: string]
24
24
  ): Promise<StaticTypeScriptFile> {
25
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
25
26
  const prettier = await import("prettier");
26
27
  return File(id, {
27
- path: id,
28
+ path,
28
29
  content: await prettier.format(content, {
29
30
  parser: "typescript",
30
31
  editor: {
@@ -0,0 +1,39 @@
1
+ import { File } from "./file";
2
+
3
+ export type StaticVueFile = File;
4
+
5
+ /**
6
+ * Creates a static Vue component file
7
+ *
8
+ * @example
9
+ * // Create a Vue component file with content
10
+ * const button = await StaticVueFile("Button.vue",
11
+ * `<template>
12
+ * <button class="btn">{{ text }}</button>
13
+ * </template>
14
+ *
15
+ * <script>
16
+ * export default {
17
+ * props: {
18
+ * text: String
19
+ * }
20
+ * }
21
+ * </script>
22
+ *
23
+ * <style>
24
+ * .btn {
25
+ * padding: 0.5rem 1rem;
26
+ * }
27
+ * </style>`
28
+ * );
29
+ */
30
+ export function StaticVueFile(
31
+ id: string,
32
+ ...args: [content: string] | [path: string, content: string]
33
+ ): Promise<StaticVueFile> {
34
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
35
+ return File(id, {
36
+ path,
37
+ content,
38
+ });
39
+ }
@@ -4,26 +4,30 @@ import { File } from "./file";
4
4
  *
5
5
  * @example
6
6
  * // Create a YAML configuration file
7
- * const config = await YamlFile("config.yaml", {
8
- * server:
9
- * host: "localhost"
7
+ * const config = await StaticYamlFile("config.yaml", {
8
+ * server: {
9
+ * host: "localhost",
10
10
  * port: 3000
11
- * database:
12
- * url: "postgresql://localhost:5432/db"
13
- * pool:
14
- * min: 1
11
+ * },
12
+ * database: {
13
+ * url: "postgresql://localhost:5432/db",
14
+ * pool: {
15
+ * min: 1,
15
16
  * max: 10
17
+ * }
18
+ * }
16
19
  * });
17
20
  */
18
21
  export type StaticYamlFile = File;
19
22
 
20
23
  export async function StaticYamlFile(
21
24
  id: string,
22
- content: any,
25
+ ...args: [content: any] | [path: string, content: any]
23
26
  ): Promise<StaticYamlFile> {
27
+ const [path, content] = args.length === 1 ? [id, args[0]] : args;
24
28
  const yaml = await import("yaml");
25
29
  return File(id, {
26
- path: id,
30
+ path,
27
31
  content: yaml.stringify(content),
28
32
  });
29
33
  }
@@ -1,93 +1,103 @@
1
- import alchemy from "alchemy";
2
- import { Document } from "alchemy/ai";
3
- import type { Folder } from "alchemy/fs";
4
- import path from "path";
1
+ import { Document } from "../ai";
2
+ import type { ModelConfig } from "../ai/client";
3
+ import { alchemy } from "../alchemy";
4
+ import type { Folder } from "../fs";
5
5
 
6
6
  export interface GettingStartedProps {
7
7
  /**
8
8
  * The output directory for the getting started document.
9
9
  */
10
- outDir: string | Folder;
10
+ path: string | Folder;
11
+
12
+ /**
13
+ * The prompt to use for generating the getting started guide.
14
+ * This should include specific details about the product or framework.
15
+ */
16
+ prompt: string;
17
+
18
+ /**
19
+ * Optional model configuration for generating the getting started guide.
20
+ * Defaults to Claude 3.5 Sonnet.
21
+ */
22
+ model?: ModelConfig;
11
23
  }
12
24
 
13
25
  export type GettingStarted = Document;
14
26
 
15
27
  export async function GettingStarted({
16
- outDir,
28
+ path: outFile,
29
+ prompt,
30
+ model = {
31
+ id: "claude-3-5-sonnet-latest",
32
+ provider: "anthropic",
33
+ },
17
34
  }: GettingStartedProps): Promise<Document> {
18
- outDir = typeof outDir === "string" ? outDir : outDir.path;
19
35
  return Document(`docs/getting-started`, {
20
- title: "Getting Started with Alchemy",
21
- path: path.join(outDir, "index.md"),
36
+ title: "Getting Started Guide",
37
+ path: typeof outFile === "string" ? outFile : outFile.path,
38
+ model,
22
39
  prompt: await alchemy`
23
- You are a technical writer creating a getting started guide for Alchemy, an infrastructure as code (IaC) framework.
24
- See ${alchemy.file("../README.md")} to understand the overview of Alchemy.
25
- See ${alchemy.file("../.cursorrules")} to better understand the structure and conventions of Alchemy.
26
-
27
- See ${alchemy.file("../alchemy/test/cloudflare/worker.test.ts")} for an example of how testing works.
28
-
29
- Write a comprehensive getting started guide for Alchemy that covers the following topics:
40
+ You are a technical writer creating a getting started guide.
41
+
42
+ ${prompt}
30
43
 
31
- # Getting Started with Alchemy
44
+ If you need a template structure to follow, use this format:
32
45
 
33
- (Brief introduction to Alchemy as an infrastructure as code framework)
46
+ # Getting Started with [Product/Framework Name]
47
+
48
+ (Brief introduction to the product/framework)
34
49
 
35
50
  ## Installation
36
51
 
37
52
  \`\`\`bash
38
- # Install Alchemy
39
- bun add alchemy
53
+ # Installation command
40
54
  \`\`\`
41
55
 
42
- ## Creating Your First Alchemy Project
56
+ ## Creating Your First Project
43
57
 
44
- (Step-by-step guide to creating a basic Alchemy project)
58
+ (Step-by-step guide to creating a basic project)
45
59
 
46
60
  \`\`\`ts
47
- // Example of a simple Alchemy project
48
- import alchemy from "alchemy";
49
-
50
- // Sample code here
61
+ // Example of a simple project
51
62
  \`\`\`
52
63
 
53
64
  ## Core Concepts
54
65
 
55
- ### Resources
66
+ ### [Concept 1]
56
67
 
57
- (Explanation of Alchemy resources and how they work)
68
+ (Explanation of the first core concept)
58
69
 
59
70
  \`\`\`ts
60
- // Example of creating a resource
71
+ // Example of using the concept
61
72
  \`\`\`
62
73
 
63
- ### Context
74
+ ### [Concept 2]
64
75
 
65
- (Explanation of Alchemy context and lifecycle management)
76
+ (Explanation of the second core concept)
66
77
 
67
78
  \`\`\`ts
68
- // Example of working with context
79
+ // Example of using the concept
69
80
  \`\`\`
70
81
 
71
- ## Working with Secrets
82
+ ## Working with [Feature]
72
83
 
73
- (How to handle secrets in Alchemy)
84
+ (How to use a specific feature)
74
85
 
75
86
  \`\`\`ts
76
- // Example of using alchemy.secret()
77
- const apiKey = alchemy.secret("API_KEY");
87
+ // Example of using the feature
78
88
  \`\`\`
79
89
 
80
90
  ## Testing
81
91
 
82
- (How to test Alchemy resources)
92
+ (How to test your project)
83
93
 
84
94
  \`\`\`ts
85
- // Example of testing Alchemy resources
95
+ // Example of testing
86
96
  \`\`\`
87
97
 
88
98
  ## Deployment
89
99
 
90
- (How to deploy resources with Alchemy)
100
+ (How to deploy your project)
91
101
 
92
102
  \`\`\`ts
93
103
  // Example of deployment
@@ -95,13 +105,11 @@ export async function GettingStarted({
95
105
 
96
106
  ## Next Steps
97
107
 
98
- (Where to go next to learn more about Alchemy)
99
-
100
- > [!CAUTION]
101
- > Avoid the temptation to over explain or over describe. Focus on concise, simple, high value snippets.
108
+ (Where to go next to learn more)
102
109
 
103
110
  > [!TIP]
104
111
  > Make sure the examples follow a natural progression from minimal examples to more complex use cases.
112
+ > Keep explanations concise and focused on high-value information.
105
113
  `,
106
114
  });
107
115
  }
@@ -0,0 +1,3 @@
1
+ export * from "./getting-started";
2
+ export * from "./providers";
3
+ export * from "./tutorial";
@@ -1,15 +1,21 @@
1
- import alchemy from "alchemy";
2
- import { Data, Document } from "alchemy/ai";
3
- import { Folder } from "alchemy/fs";
4
1
  import { type } from "arktype";
5
2
  import fs from "fs/promises";
6
3
  import path from "path";
4
+ import { Data, Document } from "../ai";
5
+ import { alchemy } from "../alchemy";
6
+ import { Folder } from "../fs";
7
7
 
8
8
  export interface DocsProps {
9
9
  /**
10
10
  * The output directory for the docs.
11
11
  */
12
12
  outDir: string | Folder;
13
+
14
+ /**
15
+ * The source directory for the docs.
16
+ */
17
+ srcDir: string;
18
+
13
19
  /**
14
20
  * Whether to filter the docs.
15
21
  * If true, include all docs.
@@ -28,17 +34,25 @@ export type AlchemyProviderDocs = {
28
34
  }[];
29
35
 
30
36
  export async function AlchemyProviderDocs({
37
+ srcDir,
31
38
  outDir,
32
39
  filter,
33
40
  }: DocsProps): Promise<AlchemyProviderDocs> {
34
41
  outDir = typeof outDir === "string" ? outDir : outDir.path;
35
- const providersDir = (await Folder(path.join(outDir, "providers"))).path;
36
42
 
37
- const exclude = ["util", "test", "vitepress", "vite", "shadcn", "internal"];
43
+ const exclude = [
44
+ "util",
45
+ "test",
46
+ "vitepress",
47
+ "vite",
48
+ "shadcn",
49
+ "internal",
50
+ "web",
51
+ ];
38
52
 
39
53
  // Get all folders in the alchemy/src directory
40
54
  let providers = (
41
- await fs.readdir(path.resolve("..", "alchemy", "src"), {
55
+ await fs.readdir(srcDir, {
42
56
  withFileTypes: true,
43
57
  })
44
58
  )
@@ -62,7 +76,7 @@ export async function AlchemyProviderDocs({
62
76
  )
63
77
  .filter((dirent) => dirent.isFile())
64
78
  .map((dirent) =>
65
- path.relative(process.cwd(), path.resolve(provider, dirent.name)),
79
+ path.relative(process.cwd(), path.resolve(provider, dirent.name))
66
80
  )
67
81
  .filter((file) => file.endsWith(".ts") && !file.endsWith("index.ts"));
68
82
 
@@ -70,23 +84,23 @@ export async function AlchemyProviderDocs({
70
84
  object: { groups },
71
85
  } = await Data(`docs/${providerName}`, {
72
86
  model: {
73
- id: "gpt-4o",
87
+ id: "o3-mini",
74
88
  provider: "openai",
75
- // options: {
76
- // reasoningEffort: "high",
77
- // },
89
+ options: {
90
+ reasoningEffort: "high",
91
+ },
78
92
  },
79
93
  temperature: 0.1,
80
94
  schema: type({
81
95
  groups: type({
82
96
  title: type("string").describe(
83
- "The title of the group, should be the Resource Name exactly as it's defined in code (const ResourceName translates to 'Resource Name') without spaces, e.g. Bucket or Static Site.",
97
+ "The title of the group, should be the Resource Name exactly as it's defined in code (const ResourceName translates to 'Resource Name') without spaces, e.g. Bucket or Static Site."
84
98
  ),
85
99
  filename: type("string").describe(
86
- "The filename of the Resource's Document, e.g. bucket.md or static-site.md",
100
+ "The filename of the Resource's Document, e.g. bucket.md or static-site.md"
87
101
  ),
88
102
  category: type("'Resource'|'Client'|'Utility'|'Types'").describe(
89
- "The classification of the Resource's Document, one of: Resource, Client, Utility, or Types.",
103
+ "The classification of the Resource's Document, one of: Resource, Client, Utility, or Types."
90
104
  ),
91
105
  }).array(),
92
106
  }),
@@ -97,8 +111,8 @@ export async function AlchemyProviderDocs({
97
111
  `,
98
112
  prompt: await alchemy`
99
113
  Identify and classify the documents that need to be written for the '${provider}' Service's Alchemy Resources.
100
- For background knowledge on Alchemy, see ${alchemy.file("../README.md")}.
101
- For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("../.cursorrules")}.
114
+ For background knowledge on Alchemy, see ${alchemy.file("./README.md")}.
115
+ For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("./.cursorrules")}.
102
116
 
103
117
  The ${provider} Service has the following resources:
104
118
  ${alchemy.files(files)}
@@ -117,11 +131,10 @@ export async function AlchemyProviderDocs({
117
131
 
118
132
  // console.log(groups);
119
133
 
120
- const providerDocsDir = (
121
- await Folder(path.join(providersDir, providerName))
122
- ).path;
134
+ const providerDocsDir = (await Folder(path.join(outDir, providerName)))
135
+ .path;
123
136
 
124
- const documents = await Promise.all(
137
+ const documents = await Promise.allSettled(
125
138
  groups
126
139
  .filter((g) => g.category === "Resource")
127
140
  .map(async (g) =>
@@ -129,12 +142,19 @@ export async function AlchemyProviderDocs({
129
142
  title: g.title,
130
143
  path: path.join(
131
144
  providerDocsDir,
132
- `${g.filename.replace(".ts", "").replace(".md", "")}.md`,
145
+ `${g.filename.replace(".ts", "").replace(".md", "")}.md`
133
146
  ),
147
+ model: {
148
+ id: "claude-3-5-sonnet-latest",
149
+ provider: "anthropic",
150
+ // options: {
151
+ // reasoningEffort: "high",
152
+ // },
153
+ },
134
154
  prompt: await alchemy`
135
155
  You are a technical writer writing API documentation for an Alchemy IaC Resource.
136
- See ${alchemy.file("../README.md")} to understand the overview of Alchemy.
137
- See ${alchemy.file("../.cursorrules")} to better understand the structure and convention of an Alchemy Resource.
156
+ See ${alchemy.file("./README.md")} to understand the overview of Alchemy.
157
+ See ${alchemy.file("./.cursorrules")} to better understand the structure and convention of an Alchemy Resource.
138
158
 
139
159
  Relevant files for the ${providerName} Service:
140
160
  ${alchemy.files(files)}
@@ -157,6 +177,8 @@ export async function AlchemyProviderDocs({
157
177
 
158
178
  # Minimal Example
159
179
 
180
+ (brief 1-2 sentences of what it does)
181
+
160
182
  \`\`\`ts
161
183
  import { ${g.title.replaceAll(" ", "")} } from "alchemy/${providerName}";
162
184
 
@@ -195,15 +217,25 @@ export async function AlchemyProviderDocs({
195
217
  : ""
196
218
  }
197
219
  `,
198
- }),
199
- ),
220
+ })
221
+ )
222
+ );
223
+
224
+ // Unwrap all documents, fail if any rejected
225
+ const results = await Promise.all(
226
+ documents.map((r) => {
227
+ if (r.status === "rejected") {
228
+ throw r.reason;
229
+ }
230
+ return r.value;
231
+ })
200
232
  );
201
233
 
202
234
  return {
203
235
  dir: providerDocsDir,
204
236
  provider: providerName,
205
- documents,
237
+ documents: results,
206
238
  } as const;
207
- }),
239
+ })
208
240
  );
209
241
  }