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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
export type StaticCSSFile = File;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a static CSS file
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a CSS file with styles
|
|
8
|
+
* const styles = await StaticCSSFile("styles.css",
|
|
9
|
+
* `.container {
|
|
10
|
+
* max-width: 1200px;
|
|
11
|
+
* margin: 0 auto;
|
|
12
|
+
* padding: 0 1rem;
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* .button {
|
|
16
|
+
* background-color: #0062ff;
|
|
17
|
+
* color: white;
|
|
18
|
+
* border: none;
|
|
19
|
+
* padding: 0.5rem 1rem;
|
|
20
|
+
* border-radius: 4px;
|
|
21
|
+
* }`
|
|
22
|
+
* );
|
|
23
|
+
*/
|
|
24
|
+
export declare function StaticCSSFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticCSSFile>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a static CSS file
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Create a CSS file with styles
|
|
7
|
+
* const styles = await StaticCSSFile("styles.css",
|
|
8
|
+
* `.container {
|
|
9
|
+
* max-width: 1200px;
|
|
10
|
+
* margin: 0 auto;
|
|
11
|
+
* padding: 0 1rem;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* .button {
|
|
15
|
+
* background-color: #0062ff;
|
|
16
|
+
* color: white;
|
|
17
|
+
* border: none;
|
|
18
|
+
* padding: 0.5rem 1rem;
|
|
19
|
+
* border-radius: 4px;
|
|
20
|
+
* }`
|
|
21
|
+
* );
|
|
22
|
+
*/
|
|
23
|
+
export function StaticCSSFile(id, ...args) {
|
|
24
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
25
|
+
return File(id, {
|
|
26
|
+
path,
|
|
27
|
+
content,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
export type StaticHTMLFile = File;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a static HTML file
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create an HTML file with content
|
|
8
|
+
* const page = await StaticHTMLFile("index.html",
|
|
9
|
+
* `<!DOCTYPE html>
|
|
10
|
+
* <html lang="en">
|
|
11
|
+
* <head>
|
|
12
|
+
* <meta charset="UTF-8">
|
|
13
|
+
* <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
14
|
+
* <title>My Website</title>
|
|
15
|
+
* <link rel="stylesheet" href="styles.css">
|
|
16
|
+
* </head>
|
|
17
|
+
* <body>
|
|
18
|
+
* <header>
|
|
19
|
+
* <h1>Welcome to My Website</h1>
|
|
20
|
+
* </header>
|
|
21
|
+
* <main>
|
|
22
|
+
* <p>This is the main content of the page.</p>
|
|
23
|
+
* </main>
|
|
24
|
+
* <footer>
|
|
25
|
+
* <p>© 2024 My Company</p>
|
|
26
|
+
* </footer>
|
|
27
|
+
* </body>
|
|
28
|
+
* </html>`
|
|
29
|
+
* );
|
|
30
|
+
*/
|
|
31
|
+
export declare function StaticHTMLFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticHTMLFile>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a static HTML file
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Create an HTML file with content
|
|
7
|
+
* const page = await StaticHTMLFile("index.html",
|
|
8
|
+
* `<!DOCTYPE html>
|
|
9
|
+
* <html lang="en">
|
|
10
|
+
* <head>
|
|
11
|
+
* <meta charset="UTF-8">
|
|
12
|
+
* <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
13
|
+
* <title>My Website</title>
|
|
14
|
+
* <link rel="stylesheet" href="styles.css">
|
|
15
|
+
* </head>
|
|
16
|
+
* <body>
|
|
17
|
+
* <header>
|
|
18
|
+
* <h1>Welcome to My Website</h1>
|
|
19
|
+
* </header>
|
|
20
|
+
* <main>
|
|
21
|
+
* <p>This is the main content of the page.</p>
|
|
22
|
+
* </main>
|
|
23
|
+
* <footer>
|
|
24
|
+
* <p>© 2024 My Company</p>
|
|
25
|
+
* </footer>
|
|
26
|
+
* </body>
|
|
27
|
+
* </html>`
|
|
28
|
+
* );
|
|
29
|
+
*/
|
|
30
|
+
export function StaticHTMLFile(id, ...args) {
|
|
31
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
32
|
+
return File(id, {
|
|
33
|
+
path,
|
|
34
|
+
content,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -4,7 +4,7 @@ import { File } from "./file";
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* // Create a JSON configuration file
|
|
7
|
-
* const config = await
|
|
7
|
+
* const config = await StaticJsonFile("config.json", {
|
|
8
8
|
* api: {
|
|
9
9
|
* endpoint: "https://api.example.com",
|
|
10
10
|
* version: "v1"
|
|
@@ -13,4 +13,4 @@ import { File } from "./file";
|
|
|
13
13
|
* });
|
|
14
14
|
*/
|
|
15
15
|
export type StaticJsonFile = File;
|
|
16
|
-
export declare function StaticJsonFile(id: string, content: any): Promise<StaticJsonFile>;
|
|
16
|
+
export declare function StaticJsonFile(id: string, ...args: [content: any] | [path: string, content: any]): Promise<StaticJsonFile>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { File } from "./file";
|
|
2
|
-
export async function StaticJsonFile(id,
|
|
2
|
+
export async function StaticJsonFile(id, ...args) {
|
|
3
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
3
4
|
const prettier = await import("prettier");
|
|
4
5
|
return File(id, {
|
|
5
|
-
path
|
|
6
|
+
path,
|
|
6
7
|
content: await prettier.format(JSON.stringify(content), {
|
|
7
8
|
parser: "json",
|
|
8
9
|
editor: {
|
|
@@ -9,4 +9,4 @@ import { File } from "./file";
|
|
|
9
9
|
* );
|
|
10
10
|
*/
|
|
11
11
|
export type StaticTextFile = File;
|
|
12
|
-
export declare function StaticTextFile(id: string, content: string): Promise<StaticTextFile>;
|
|
12
|
+
export declare function StaticTextFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticTextFile>;
|
|
@@ -4,7 +4,7 @@ import { File } from "./file";
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* // Create a TypeScript file
|
|
7
|
-
* const component = await
|
|
7
|
+
* const component = await StaticTypeScriptFile("Component.ts", `
|
|
8
8
|
* interface Props {
|
|
9
9
|
* name: string;
|
|
10
10
|
* age: number;
|
|
@@ -16,4 +16,4 @@ import { File } from "./file";
|
|
|
16
16
|
* `);
|
|
17
17
|
*/
|
|
18
18
|
export type StaticTypeScriptFile = File;
|
|
19
|
-
export declare function StaticTypeScriptFile(id: string, content: string): Promise<StaticTypeScriptFile>;
|
|
19
|
+
export declare function StaticTypeScriptFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticTypeScriptFile>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { File } from "./file";
|
|
2
|
-
export async function StaticTypeScriptFile(id,
|
|
2
|
+
export async function StaticTypeScriptFile(id, ...args) {
|
|
3
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
3
4
|
const prettier = await import("prettier");
|
|
4
5
|
return File(id, {
|
|
5
|
-
path
|
|
6
|
+
path,
|
|
6
7
|
content: await prettier.format(content, {
|
|
7
8
|
parser: "typescript",
|
|
8
9
|
editor: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
export type StaticVueFile = File;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a static Vue component file
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a Vue component file with content
|
|
8
|
+
* const button = await StaticVueFile("Button.vue",
|
|
9
|
+
* `<template>
|
|
10
|
+
* <button class="btn">{{ text }}</button>
|
|
11
|
+
* </template>
|
|
12
|
+
*
|
|
13
|
+
* <script>
|
|
14
|
+
* export default {
|
|
15
|
+
* props: {
|
|
16
|
+
* text: String
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* </script>
|
|
20
|
+
*
|
|
21
|
+
* <style>
|
|
22
|
+
* .btn {
|
|
23
|
+
* padding: 0.5rem 1rem;
|
|
24
|
+
* }
|
|
25
|
+
* </style>`
|
|
26
|
+
* );
|
|
27
|
+
*/
|
|
28
|
+
export declare function StaticVueFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticVueFile>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a static Vue component file
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Create a Vue component file with content
|
|
7
|
+
* const button = await StaticVueFile("Button.vue",
|
|
8
|
+
* `<template>
|
|
9
|
+
* <button class="btn">{{ text }}</button>
|
|
10
|
+
* </template>
|
|
11
|
+
*
|
|
12
|
+
* <script>
|
|
13
|
+
* export default {
|
|
14
|
+
* props: {
|
|
15
|
+
* text: String
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* </script>
|
|
19
|
+
*
|
|
20
|
+
* <style>
|
|
21
|
+
* .btn {
|
|
22
|
+
* padding: 0.5rem 1rem;
|
|
23
|
+
* }
|
|
24
|
+
* </style>`
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
export function StaticVueFile(id, ...args) {
|
|
28
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
29
|
+
return File(id, {
|
|
30
|
+
path,
|
|
31
|
+
content,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -4,16 +4,19 @@ 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
|
-
export declare function StaticYamlFile(id: string, content: any): Promise<StaticYamlFile>;
|
|
22
|
+
export declare function StaticYamlFile(id: string, ...args: [content: any] | [path: string, content: any]): Promise<StaticYamlFile>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { File } from "./file";
|
|
2
|
-
export async function StaticYamlFile(id,
|
|
2
|
+
export async function StaticYamlFile(id, ...args) {
|
|
3
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
3
4
|
const yaml = await import("yaml");
|
|
4
5
|
return File(id, {
|
|
5
|
-
path
|
|
6
|
+
path,
|
|
6
7
|
content: yaml.stringify(content),
|
|
7
8
|
});
|
|
8
9
|
}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { Document } from "
|
|
2
|
-
import type {
|
|
1
|
+
import { Document } from "../ai";
|
|
2
|
+
import type { ModelConfig } from "../ai/client";
|
|
3
|
+
import type { Folder } from "../fs";
|
|
3
4
|
export interface GettingStartedProps {
|
|
4
5
|
/**
|
|
5
6
|
* The output directory for the getting started document.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
path: string | Folder;
|
|
9
|
+
/**
|
|
10
|
+
* The prompt to use for generating the getting started guide.
|
|
11
|
+
* This should include specific details about the product or framework.
|
|
12
|
+
*/
|
|
13
|
+
prompt: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional model configuration for generating the getting started guide.
|
|
16
|
+
* Defaults to Claude 3.5 Sonnet.
|
|
17
|
+
*/
|
|
18
|
+
model?: ModelConfig;
|
|
8
19
|
}
|
|
9
20
|
export type GettingStarted = Document;
|
|
10
|
-
export declare function GettingStarted({
|
|
21
|
+
export declare function GettingStarted({ path: outFile, prompt, model, }: GettingStartedProps): Promise<Document>;
|
|
@@ -1,80 +1,75 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Document } from "../ai";
|
|
2
|
+
import { alchemy } from "../alchemy";
|
|
3
|
+
export async function GettingStarted({ path: outFile, prompt, model = {
|
|
4
|
+
id: "claude-3-5-sonnet-latest",
|
|
5
|
+
provider: "anthropic",
|
|
6
|
+
}, }) {
|
|
6
7
|
return Document(`docs/getting-started`, {
|
|
7
|
-
title: "Getting Started
|
|
8
|
-
path:
|
|
8
|
+
title: "Getting Started Guide",
|
|
9
|
+
path: typeof outFile === "string" ? outFile : outFile.path,
|
|
10
|
+
model,
|
|
9
11
|
prompt: await alchemy `
|
|
10
|
-
You are a technical writer creating a getting started guide
|
|
11
|
-
See ${alchemy.file("../README.md")} to understand the overview of Alchemy.
|
|
12
|
-
See ${alchemy.file("../.cursorrules")} to better understand the structure and conventions of Alchemy.
|
|
13
|
-
|
|
14
|
-
See ${alchemy.file("../alchemy/test/cloudflare/worker.test.ts")} for an example of how testing works.
|
|
15
|
-
|
|
16
|
-
Write a comprehensive getting started guide for Alchemy that covers the following topics:
|
|
12
|
+
You are a technical writer creating a getting started guide.
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
${prompt}
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
If you need a template structure to follow, use this format:
|
|
17
|
+
|
|
18
|
+
# Getting Started with [Product/Framework Name]
|
|
19
|
+
|
|
20
|
+
(Brief introduction to the product/framework)
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
24
|
\`\`\`bash
|
|
25
|
-
#
|
|
26
|
-
bun add alchemy
|
|
25
|
+
# Installation command
|
|
27
26
|
\`\`\`
|
|
28
27
|
|
|
29
|
-
## Creating Your First
|
|
28
|
+
## Creating Your First Project
|
|
30
29
|
|
|
31
|
-
(Step-by-step guide to creating a basic
|
|
30
|
+
(Step-by-step guide to creating a basic project)
|
|
32
31
|
|
|
33
32
|
\`\`\`ts
|
|
34
|
-
// Example of a simple
|
|
35
|
-
import alchemy from "alchemy";
|
|
36
|
-
|
|
37
|
-
// Sample code here
|
|
33
|
+
// Example of a simple project
|
|
38
34
|
\`\`\`
|
|
39
35
|
|
|
40
36
|
## Core Concepts
|
|
41
37
|
|
|
42
|
-
###
|
|
38
|
+
### [Concept 1]
|
|
43
39
|
|
|
44
|
-
(Explanation of
|
|
40
|
+
(Explanation of the first core concept)
|
|
45
41
|
|
|
46
42
|
\`\`\`ts
|
|
47
|
-
// Example of
|
|
43
|
+
// Example of using the concept
|
|
48
44
|
\`\`\`
|
|
49
45
|
|
|
50
|
-
###
|
|
46
|
+
### [Concept 2]
|
|
51
47
|
|
|
52
|
-
(Explanation of
|
|
48
|
+
(Explanation of the second core concept)
|
|
53
49
|
|
|
54
50
|
\`\`\`ts
|
|
55
|
-
// Example of
|
|
51
|
+
// Example of using the concept
|
|
56
52
|
\`\`\`
|
|
57
53
|
|
|
58
|
-
## Working with
|
|
54
|
+
## Working with [Feature]
|
|
59
55
|
|
|
60
|
-
(How to
|
|
56
|
+
(How to use a specific feature)
|
|
61
57
|
|
|
62
58
|
\`\`\`ts
|
|
63
|
-
// Example of using
|
|
64
|
-
const apiKey = alchemy.secret("API_KEY");
|
|
59
|
+
// Example of using the feature
|
|
65
60
|
\`\`\`
|
|
66
61
|
|
|
67
62
|
## Testing
|
|
68
63
|
|
|
69
|
-
(How to test
|
|
64
|
+
(How to test your project)
|
|
70
65
|
|
|
71
66
|
\`\`\`ts
|
|
72
|
-
// Example of testing
|
|
67
|
+
// Example of testing
|
|
73
68
|
\`\`\`
|
|
74
69
|
|
|
75
70
|
## Deployment
|
|
76
71
|
|
|
77
|
-
(How to deploy
|
|
72
|
+
(How to deploy your project)
|
|
78
73
|
|
|
79
74
|
\`\`\`ts
|
|
80
75
|
// Example of deployment
|
|
@@ -82,13 +77,11 @@ export async function GettingStarted({ outDir, }) {
|
|
|
82
77
|
|
|
83
78
|
## Next Steps
|
|
84
79
|
|
|
85
|
-
(Where to go next to learn more
|
|
86
|
-
|
|
87
|
-
> [!CAUTION]
|
|
88
|
-
> Avoid the temptation to over explain or over describe. Focus on concise, simple, high value snippets.
|
|
80
|
+
(Where to go next to learn more)
|
|
89
81
|
|
|
90
82
|
> [!TIP]
|
|
91
83
|
> Make sure the examples follow a natural progression from minimal examples to more complex use cases.
|
|
84
|
+
> Keep explanations concise and focused on high-value information.
|
|
92
85
|
`,
|
|
93
86
|
});
|
|
94
87
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Document } from "
|
|
2
|
-
import { Folder } from "
|
|
1
|
+
import { Document } from "../ai";
|
|
2
|
+
import { Folder } from "../fs";
|
|
3
3
|
export interface DocsProps {
|
|
4
4
|
/**
|
|
5
5
|
* The output directory for the docs.
|
|
6
6
|
*/
|
|
7
7
|
outDir: string | Folder;
|
|
8
|
+
/**
|
|
9
|
+
* The source directory for the docs.
|
|
10
|
+
*/
|
|
11
|
+
srcDir: string;
|
|
8
12
|
/**
|
|
9
13
|
* Whether to filter the docs.
|
|
10
14
|
* If true, include all docs.
|
|
@@ -20,4 +24,4 @@ export type AlchemyProviderDocs = {
|
|
|
20
24
|
provider: string;
|
|
21
25
|
documents: Document[];
|
|
22
26
|
}[];
|
|
23
|
-
export declare function AlchemyProviderDocs({ outDir, filter, }: DocsProps): Promise<AlchemyProviderDocs>;
|
|
27
|
+
export declare function AlchemyProviderDocs({ srcDir, outDir, filter, }: DocsProps): Promise<AlchemyProviderDocs>;
|
|
@@ -1,15 +1,22 @@
|
|
|
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";
|
|
7
|
-
|
|
4
|
+
import { Data, Document } from "../ai";
|
|
5
|
+
import { alchemy } from "../alchemy";
|
|
6
|
+
import { Folder } from "../fs";
|
|
7
|
+
export async function AlchemyProviderDocs({ srcDir, outDir, filter, }) {
|
|
8
8
|
outDir = typeof outDir === "string" ? outDir : outDir.path;
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const exclude = [
|
|
10
|
+
"util",
|
|
11
|
+
"test",
|
|
12
|
+
"vitepress",
|
|
13
|
+
"vite",
|
|
14
|
+
"shadcn",
|
|
15
|
+
"internal",
|
|
16
|
+
"web",
|
|
17
|
+
];
|
|
11
18
|
// Get all folders in the alchemy/src directory
|
|
12
|
-
let providers = (await fs.readdir(
|
|
19
|
+
let providers = (await fs.readdir(srcDir, {
|
|
13
20
|
withFileTypes: true,
|
|
14
21
|
}))
|
|
15
22
|
.filter((dirent) => dirent.isDirectory() && !exclude.includes(dirent.name))
|
|
@@ -31,11 +38,11 @@ export async function AlchemyProviderDocs({ outDir, filter, }) {
|
|
|
31
38
|
.filter((file) => file.endsWith(".ts") && !file.endsWith("index.ts"));
|
|
32
39
|
const { object: { groups }, } = await Data(`docs/${providerName}`, {
|
|
33
40
|
model: {
|
|
34
|
-
id: "
|
|
41
|
+
id: "o3-mini",
|
|
35
42
|
provider: "openai",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
options: {
|
|
44
|
+
reasoningEffort: "high",
|
|
45
|
+
},
|
|
39
46
|
},
|
|
40
47
|
temperature: 0.1,
|
|
41
48
|
schema: type({
|
|
@@ -52,8 +59,8 @@ export async function AlchemyProviderDocs({ outDir, filter, }) {
|
|
|
52
59
|
`,
|
|
53
60
|
prompt: await alchemy `
|
|
54
61
|
Identify and classify the documents that need to be written for the '${provider}' Service's Alchemy Resources.
|
|
55
|
-
For background knowledge on Alchemy, see ${alchemy.file("
|
|
56
|
-
For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("
|
|
62
|
+
For background knowledge on Alchemy, see ${alchemy.file("./README.md")}.
|
|
63
|
+
For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("./.cursorrules")}.
|
|
57
64
|
|
|
58
65
|
The ${provider} Service has the following resources:
|
|
59
66
|
${alchemy.files(files)}
|
|
@@ -70,16 +77,24 @@ export async function AlchemyProviderDocs({ outDir, filter, }) {
|
|
|
70
77
|
`,
|
|
71
78
|
});
|
|
72
79
|
// console.log(groups);
|
|
73
|
-
const providerDocsDir = (await Folder(path.join(
|
|
74
|
-
|
|
80
|
+
const providerDocsDir = (await Folder(path.join(outDir, providerName)))
|
|
81
|
+
.path;
|
|
82
|
+
const documents = await Promise.allSettled(groups
|
|
75
83
|
.filter((g) => g.category === "Resource")
|
|
76
84
|
.map(async (g) => Document(`docs/${providerName}/${g.title}`, {
|
|
77
85
|
title: g.title,
|
|
78
86
|
path: path.join(providerDocsDir, `${g.filename.replace(".ts", "").replace(".md", "")}.md`),
|
|
87
|
+
model: {
|
|
88
|
+
id: "claude-3-5-sonnet-latest",
|
|
89
|
+
provider: "anthropic",
|
|
90
|
+
// options: {
|
|
91
|
+
// reasoningEffort: "high",
|
|
92
|
+
// },
|
|
93
|
+
},
|
|
79
94
|
prompt: await alchemy `
|
|
80
95
|
You are a technical writer writing API documentation for an Alchemy IaC Resource.
|
|
81
|
-
See ${alchemy.file("
|
|
82
|
-
See ${alchemy.file("
|
|
96
|
+
See ${alchemy.file("./README.md")} to understand the overview of Alchemy.
|
|
97
|
+
See ${alchemy.file("./.cursorrules")} to better understand the structure and convention of an Alchemy Resource.
|
|
83
98
|
|
|
84
99
|
Relevant files for the ${providerName} Service:
|
|
85
100
|
${alchemy.files(files)}
|
|
@@ -102,6 +117,8 @@ export async function AlchemyProviderDocs({ outDir, filter, }) {
|
|
|
102
117
|
|
|
103
118
|
# Minimal Example
|
|
104
119
|
|
|
120
|
+
(brief 1-2 sentences of what it does)
|
|
121
|
+
|
|
105
122
|
\`\`\`ts
|
|
106
123
|
import { ${g.title.replaceAll(" ", "")} } from "alchemy/${providerName}";
|
|
107
124
|
|
|
@@ -139,10 +156,17 @@ export async function AlchemyProviderDocs({ outDir, filter, }) {
|
|
|
139
156
|
: ""}
|
|
140
157
|
`,
|
|
141
158
|
})));
|
|
159
|
+
// Unwrap all documents, fail if any rejected
|
|
160
|
+
const results = await Promise.all(documents.map((r) => {
|
|
161
|
+
if (r.status === "rejected") {
|
|
162
|
+
throw r.reason;
|
|
163
|
+
}
|
|
164
|
+
return r.value;
|
|
165
|
+
}));
|
|
142
166
|
return {
|
|
143
167
|
dir: providerDocsDir,
|
|
144
168
|
provider: providerName,
|
|
145
|
-
documents,
|
|
169
|
+
documents: results,
|
|
146
170
|
};
|
|
147
171
|
}));
|
|
148
172
|
}
|