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.
- package/lib/ai/approve.d.ts +99 -0
- package/lib/ai/approve.js +76 -0
- package/lib/ai/astro-file.js +7 -24
- package/lib/ai/client.d.ts +7 -0
- package/lib/ai/client.js +45 -0
- package/lib/ai/css-file.js +7 -24
- package/lib/ai/data.d.ts +26 -21
- package/lib/ai/data.js +33 -22
- package/lib/ai/document.d.ts +64 -4
- package/lib/ai/document.js +102 -55
- package/lib/ai/html-file.js +7 -24
- package/lib/ai/index.d.ts +2 -0
- package/lib/ai/index.js +2 -0
- package/lib/ai/json-file.js +11 -32
- package/lib/ai/review.d.ts +122 -0
- package/lib/ai/review.js +101 -0
- package/lib/ai/typescript-file.d.ts +1 -2
- package/lib/ai/typescript-file.js +8 -39
- package/lib/ai/vue-file.js +7 -24
- package/lib/ai/yaml-file.js +12 -48
- package/lib/alchemy.js +17 -2
- package/lib/apply.js +1 -1
- package/lib/cloudflare/generate-asset-manifest.js +1 -1
- package/lib/cloudflare/static-site-router.js +16 -7
- package/lib/cloudflare/static-site.js +3 -0
- package/lib/cloudflare/upload-asset-manifest.js +4 -2
- package/lib/fs/copy-file.d.ts +54 -0
- package/lib/fs/copy-file.js +63 -0
- package/lib/fs/file.d.ts +13 -0
- package/lib/fs/file.js +24 -5
- package/lib/fs/index.d.ts +6 -0
- package/lib/fs/index.js +6 -0
- package/lib/fs/static-astro-file.d.ts +34 -0
- package/lib/fs/static-astro-file.js +39 -0
- package/lib/fs/static-css-file.d.ts +24 -0
- package/lib/fs/static-css-file.js +29 -0
- package/lib/fs/static-html-file.d.ts +31 -0
- package/lib/fs/static-html-file.js +36 -0
- package/lib/fs/static-json-file.d.ts +2 -2
- package/lib/fs/static-json-file.js +3 -2
- package/lib/fs/static-text-file.d.ts +1 -1
- package/lib/fs/static-text-file.js +3 -2
- package/lib/fs/static-typescript-file.d.ts +2 -2
- package/lib/fs/static-typescript-file.js +3 -2
- package/lib/fs/static-vue-file.d.ts +28 -0
- package/lib/fs/static-vue-file.js +33 -0
- package/lib/fs/static-yaml-file.d.ts +11 -8
- package/lib/fs/static-yaml-file.js +3 -2
- package/lib/internal/getting-started.d.ts +15 -4
- package/lib/internal/getting-started.js +34 -41
- package/lib/internal/index.d.ts +3 -0
- package/lib/internal/index.js +3 -0
- package/lib/internal/providers.d.ts +7 -3
- package/lib/internal/providers.js +42 -18
- package/lib/internal/tutorial.d.ts +104 -0
- package/lib/internal/tutorial.js +251 -0
- package/lib/web/vitepress/config.d.ts +10 -0
- package/lib/web/vitepress/config.js +31 -0
- package/lib/web/vitepress/home-page.d.ts +5 -3
- package/lib/web/vitepress/home-page.js +48 -35
- package/lib/web/vitepress/index.d.ts +1 -0
- package/lib/web/vitepress/index.js +1 -0
- package/lib/web/vitepress/vitepress.d.ts +5 -4
- package/lib/web/vitepress/vitepress.js +17 -34
- package/package.json +1 -1
- package/src/ai/approve.ts +163 -0
- package/src/ai/astro-file.ts +11 -30
- package/src/ai/client.ts +59 -0
- package/src/ai/css-file.ts +11 -30
- package/src/ai/data.ts +50 -25
- package/src/ai/document.ts +146 -65
- package/src/ai/html-file.ts +11 -30
- package/src/ai/index.ts +2 -0
- package/src/ai/json-file.ts +13 -37
- package/src/ai/review.ts +213 -0
- package/src/ai/typescript-file.ts +14 -48
- package/src/ai/vue-file.ts +11 -30
- package/src/ai/yaml-file.ts +13 -53
- package/src/alchemy.ts +18 -7
- package/src/apply.ts +8 -8
- package/src/cloudflare/generate-asset-manifest.ts +4 -4
- package/src/cloudflare/static-site-router.ts +18 -8
- package/src/cloudflare/static-site.ts +11 -7
- package/src/cloudflare/upload-asset-manifest.ts +6 -4
- package/src/cloudflare/worker.ts +44 -43
- package/src/fs/copy-file.ts +115 -0
- package/src/fs/file.ts +35 -9
- package/src/fs/index.ts +6 -0
- package/src/fs/static-astro-file.ts +45 -0
- package/src/fs/static-css-file.ts +35 -0
- package/src/fs/static-html-file.ts +42 -0
- package/src/fs/static-json-file.ts +4 -3
- package/src/fs/static-text-file.ts +5 -2
- package/src/fs/static-typescript-file.ts +4 -3
- package/src/fs/static-vue-file.ts +39 -0
- package/src/fs/static-yaml-file.ts +13 -9
- package/src/internal/getting-started.ts +51 -43
- package/src/internal/index.ts +3 -0
- package/src/internal/providers.ts +59 -27
- package/src/internal/tutorial.ts +392 -0
- package/src/web/vitepress/config.ts +48 -0
- package/src/web/vitepress/home-page.ts +54 -42
- package/src/web/vitepress/index.ts +1 -0
- package/src/web/vitepress/vitepress.ts +31 -48
- package/lib/internal/project.d.ts +0 -13
- package/lib/internal/project.js +0 -101
- 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>© 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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
8
|
-
* server:
|
|
9
|
-
* host: "localhost"
|
|
7
|
+
* const config = await StaticYamlFile("config.yaml", {
|
|
8
|
+
* server: {
|
|
9
|
+
* host: "localhost",
|
|
10
10
|
* port: 3000
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
|
30
|
+
path,
|
|
27
31
|
content: yaml.stringify(content),
|
|
28
32
|
});
|
|
29
33
|
}
|
|
@@ -1,93 +1,103 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
21
|
-
path:
|
|
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
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
44
|
+
If you need a template structure to follow, use this format:
|
|
32
45
|
|
|
33
|
-
|
|
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
|
-
#
|
|
39
|
-
bun add alchemy
|
|
53
|
+
# Installation command
|
|
40
54
|
\`\`\`
|
|
41
55
|
|
|
42
|
-
## Creating Your First
|
|
56
|
+
## Creating Your First Project
|
|
43
57
|
|
|
44
|
-
(Step-by-step guide to creating a basic
|
|
58
|
+
(Step-by-step guide to creating a basic project)
|
|
45
59
|
|
|
46
60
|
\`\`\`ts
|
|
47
|
-
// Example of a simple
|
|
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
|
-
###
|
|
66
|
+
### [Concept 1]
|
|
56
67
|
|
|
57
|
-
(Explanation of
|
|
68
|
+
(Explanation of the first core concept)
|
|
58
69
|
|
|
59
70
|
\`\`\`ts
|
|
60
|
-
// Example of
|
|
71
|
+
// Example of using the concept
|
|
61
72
|
\`\`\`
|
|
62
73
|
|
|
63
|
-
###
|
|
74
|
+
### [Concept 2]
|
|
64
75
|
|
|
65
|
-
(Explanation of
|
|
76
|
+
(Explanation of the second core concept)
|
|
66
77
|
|
|
67
78
|
\`\`\`ts
|
|
68
|
-
// Example of
|
|
79
|
+
// Example of using the concept
|
|
69
80
|
\`\`\`
|
|
70
81
|
|
|
71
|
-
## Working with
|
|
82
|
+
## Working with [Feature]
|
|
72
83
|
|
|
73
|
-
(How to
|
|
84
|
+
(How to use a specific feature)
|
|
74
85
|
|
|
75
86
|
\`\`\`ts
|
|
76
|
-
// Example of using
|
|
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
|
|
92
|
+
(How to test your project)
|
|
83
93
|
|
|
84
94
|
\`\`\`ts
|
|
85
|
-
// Example of testing
|
|
95
|
+
// Example of testing
|
|
86
96
|
\`\`\`
|
|
87
97
|
|
|
88
98
|
## Deployment
|
|
89
99
|
|
|
90
|
-
(How to deploy
|
|
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
|
|
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
|
}
|
|
@@ -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 = [
|
|
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(
|
|
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: "
|
|
87
|
+
id: "o3-mini",
|
|
74
88
|
provider: "openai",
|
|
75
|
-
|
|
76
|
-
|
|
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("
|
|
101
|
-
For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("
|
|
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
|
-
|
|
122
|
-
).path;
|
|
134
|
+
const providerDocsDir = (await Folder(path.join(outDir, providerName)))
|
|
135
|
+
.path;
|
|
123
136
|
|
|
124
|
-
const documents = await Promise.
|
|
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("
|
|
137
|
-
See ${alchemy.file("
|
|
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
|
}
|