alchemy 0.1.11 → 0.1.13
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/README.md +324 -0
- package/lib/$.d.ts +8 -3
- package/lib/$.d.ts.map +1 -1
- package/lib/$.js +38 -27
- package/lib/$.js.map +1 -1
- package/lib/alchemize.d.ts.map +1 -1
- package/lib/alchemize.js +7 -0
- package/lib/alchemize.js.map +1 -1
- package/lib/apply.d.ts +2 -2
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +3 -3
- package/lib/apply.js.map +1 -1
- package/lib/aws/index.d.ts +1 -0
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +1 -0
- package/lib/aws/index.js.map +1 -1
- package/lib/aws/ses.d.ts +75 -0
- package/lib/aws/ses.d.ts.map +1 -0
- package/lib/aws/ses.js +197 -0
- package/lib/aws/ses.js.map +1 -0
- package/lib/cloudflare/api.d.ts +88 -0
- package/lib/cloudflare/api.d.ts.map +1 -0
- package/lib/cloudflare/api.js +184 -0
- package/lib/cloudflare/api.js.map +1 -0
- package/lib/cloudflare/asset-manifest.d.ts +15 -0
- package/lib/cloudflare/asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/asset-manifest.js +2 -0
- package/lib/cloudflare/asset-manifest.js.map +1 -0
- package/lib/cloudflare/auth.d.ts +52 -0
- package/lib/cloudflare/auth.d.ts.map +1 -0
- package/lib/cloudflare/auth.js +114 -0
- package/lib/cloudflare/auth.js.map +1 -0
- package/lib/cloudflare/bindings.d.ts +254 -0
- package/lib/cloudflare/bindings.d.ts.map +1 -0
- package/lib/cloudflare/bindings.js +2 -0
- package/lib/cloudflare/bindings.js.map +1 -0
- package/lib/cloudflare/durable-object-namespace.d.ts +23 -0
- package/lib/cloudflare/durable-object-namespace.d.ts.map +1 -0
- package/lib/cloudflare/durable-object-namespace.js +26 -0
- package/lib/cloudflare/durable-object-namespace.js.map +1 -0
- package/lib/cloudflare/generate-asset-manifest.d.ts +3 -0
- package/lib/cloudflare/generate-asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/generate-asset-manifest.js +69 -0
- package/lib/cloudflare/generate-asset-manifest.js.map +1 -0
- package/lib/cloudflare/index.d.ts +7 -0
- package/lib/cloudflare/index.d.ts.map +1 -0
- package/lib/cloudflare/index.js +7 -0
- package/lib/cloudflare/index.js.map +1 -0
- package/lib/cloudflare/kv-namespace.d.ts +61 -0
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -0
- package/lib/cloudflare/kv-namespace.js +93 -0
- package/lib/cloudflare/kv-namespace.js.map +1 -0
- package/lib/cloudflare/state.d.ts +83 -0
- package/lib/cloudflare/state.d.ts.map +1 -0
- package/lib/cloudflare/state.js +109 -0
- package/lib/cloudflare/state.js.map +1 -0
- package/lib/cloudflare/static-site-router.d.ts +19 -0
- package/lib/cloudflare/static-site-router.d.ts.map +1 -0
- package/lib/cloudflare/static-site-router.js +110 -0
- package/lib/cloudflare/static-site-router.js.map +1 -0
- package/lib/cloudflare/static-site.d.ts +166 -0
- package/lib/cloudflare/static-site.d.ts.map +1 -0
- package/lib/cloudflare/static-site.js +168 -0
- package/lib/cloudflare/static-site.js.map +1 -0
- package/lib/cloudflare/types.d.ts +52 -0
- package/lib/cloudflare/types.d.ts.map +1 -0
- package/lib/cloudflare/types.js +21 -0
- package/lib/cloudflare/types.js.map +1 -0
- package/lib/cloudflare/upload-asset-manifest.d.ts +12 -0
- package/lib/cloudflare/upload-asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/upload-asset-manifest.js +55 -0
- package/lib/cloudflare/upload-asset-manifest.js.map +1 -0
- package/lib/cloudflare/worker-metadata.d.ts +130 -0
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -0
- package/lib/cloudflare/worker-metadata.js +2 -0
- package/lib/cloudflare/worker-metadata.js.map +1 -0
- package/lib/cloudflare/worker-migration.d.ts +110 -0
- package/lib/cloudflare/worker-migration.d.ts.map +1 -0
- package/lib/cloudflare/worker-migration.js +11 -0
- package/lib/cloudflare/worker-migration.js.map +1 -0
- package/lib/cloudflare/worker.d.ts +105 -0
- package/lib/cloudflare/worker.d.ts.map +1 -0
- package/lib/cloudflare/worker.js +358 -0
- package/lib/cloudflare/worker.js.map +1 -0
- package/lib/destroy.d.ts +1 -1
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +2 -1
- package/lib/destroy.js.map +1 -1
- package/lib/esbuild.d.ts +83 -1
- package/lib/esbuild.d.ts.map +1 -1
- package/lib/esbuild.js +27 -18
- package/lib/esbuild.js.map +1 -1
- package/lib/fs.d.ts +1 -1
- package/lib/global.d.ts +0 -2
- package/lib/global.d.ts.map +1 -1
- package/lib/global.js +3 -3
- package/lib/global.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/main.js +1 -1
- package/lib/main.js.map +1 -1
- package/lib/output.d.ts +18 -13
- package/lib/output.d.ts.map +1 -1
- package/lib/output.js +12 -5
- package/lib/output.js.map +1 -1
- package/lib/print.d.ts +7 -0
- package/lib/print.d.ts.map +1 -0
- package/lib/print.js +10 -0
- package/lib/print.js.map +1 -0
- package/lib/resource.d.ts +9 -4
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +127 -93
- package/lib/resource.js.map +1 -1
- package/lib/scope.d.ts +3 -0
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +4 -12
- package/lib/scope.js.map +1 -1
- package/lib/utils/content-type.d.ts +8 -0
- package/lib/utils/content-type.d.ts.map +1 -0
- package/lib/utils/content-type.js +41 -0
- package/lib/utils/content-type.js.map +1 -0
- package/package.json +27 -8
- package/src/$.ts +63 -30
- package/src/alchemize.ts +12 -0
- package/src/apply.ts +6 -6
- package/src/aws/index.ts +1 -0
- package/src/aws/ses.ts +346 -0
- package/src/cloudflare/api.ts +282 -0
- package/src/cloudflare/asset-manifest.ts +16 -0
- package/src/cloudflare/auth.ts +187 -0
- package/src/cloudflare/bindings.ts +297 -0
- package/src/cloudflare/durable-object-namespace.ts +43 -0
- package/src/cloudflare/generate-asset-manifest.ts +93 -0
- package/src/cloudflare/index.ts +6 -0
- package/src/cloudflare/kv-namespace.ts +195 -0
- package/src/cloudflare/state.ts +138 -0
- package/src/cloudflare/static-site-router.ts +150 -0
- package/src/cloudflare/static-site.ts +395 -0
- package/src/cloudflare/types.ts +71 -0
- package/src/cloudflare/upload-asset-manifest.ts +83 -0
- package/src/cloudflare/worker-metadata.ts +154 -0
- package/src/cloudflare/worker-migration.ts +145 -0
- package/src/cloudflare/worker.ts +666 -0
- package/src/destroy.ts +2 -2
- package/src/esbuild.ts +34 -22
- package/src/global.ts +1 -3
- package/src/index.ts +1 -1
- package/src/main.ts +1 -1
- package/src/output.ts +53 -37
- package/src/print.ts +18 -0
- package/src/resource.ts +163 -116
- package/src/scope.ts +7 -12
- package/src/utils/content-type.ts +42 -0
- package/lib/agent/ai.d.ts +0 -40
- package/lib/agent/ai.d.ts.map +0 -1
- package/lib/agent/ai.js +0 -132
- package/lib/agent/ai.js.map +0 -1
- package/lib/agent/anthropic.d.ts +0 -9
- package/lib/agent/anthropic.d.ts.map +0 -1
- package/lib/agent/anthropic.js +0 -25
- package/lib/agent/anthropic.js.map +0 -1
- package/lib/agent/dependencies.d.ts +0 -4
- package/lib/agent/dependencies.d.ts.map +0 -1
- package/lib/agent/dependencies.js +0 -48
- package/lib/agent/dependencies.js.map +0 -1
- package/lib/agent/file-context.d.ts +0 -13
- package/lib/agent/file-context.d.ts.map +0 -1
- package/lib/agent/file-context.js +0 -6
- package/lib/agent/file-context.js.map +0 -1
- package/lib/agent/index.d.ts +0 -10
- package/lib/agent/index.d.ts.map +0 -1
- package/lib/agent/index.js +0 -10
- package/lib/agent/index.js.map +0 -1
- package/lib/agent/model.d.ts +0 -8
- package/lib/agent/model.d.ts.map +0 -1
- package/lib/agent/model.js +0 -29
- package/lib/agent/model.js.map +0 -1
- package/lib/agent/module.d.ts +0 -81
- package/lib/agent/module.d.ts.map +0 -1
- package/lib/agent/module.js +0 -309
- package/lib/agent/module.js.map +0 -1
- package/lib/agent/openai.d.ts +0 -6
- package/lib/agent/openai.d.ts.map +0 -1
- package/lib/agent/openai.js +0 -41
- package/lib/agent/openai.js.map +0 -1
- package/lib/agent/program.d.ts +0 -12
- package/lib/agent/program.d.ts.map +0 -1
- package/lib/agent/program.js +0 -21
- package/lib/agent/program.js.map +0 -1
- package/lib/agent/prompts.d.ts +0 -4
- package/lib/agent/prompts.d.ts.map +0 -1
- package/lib/agent/prompts.js +0 -11
- package/lib/agent/prompts.js.map +0 -1
- package/lib/agent/scrape.d.ts +0 -71
- package/lib/agent/scrape.d.ts.map +0 -1
- package/lib/agent/scrape.js +0 -45
- package/lib/agent/scrape.js.map +0 -1
- package/lib/aws/auto/docs.d.ts +0 -11
- package/lib/aws/auto/docs.d.ts.map +0 -1
- package/lib/aws/auto/docs.js +0 -56
- package/lib/aws/auto/docs.js.map +0 -1
- package/lib/aws/auto/index.d.ts +0 -5
- package/lib/aws/auto/index.d.ts.map +0 -1
- package/lib/aws/auto/index.js +0 -5
- package/lib/aws/auto/index.js.map +0 -1
- package/lib/aws/auto/resource.d.ts +0 -24
- package/lib/aws/auto/resource.d.ts.map +0 -1
- package/lib/aws/auto/resource.js +0 -194
- package/lib/aws/auto/resource.js.map +0 -1
- package/lib/aws/auto/service.d.ts +0 -10
- package/lib/aws/auto/service.d.ts.map +0 -1
- package/lib/aws/auto/service.js +0 -34
- package/lib/aws/auto/service.js.map +0 -1
- package/lib/aws/auto/spec.d.ts +0 -83
- package/lib/aws/auto/spec.d.ts.map +0 -1
- package/lib/aws/auto/spec.js +0 -58
- package/lib/aws/auto/spec.js.map +0 -1
- package/lib/markdown/design.d.ts +0 -17
- package/lib/markdown/design.d.ts.map +0 -1
- package/lib/markdown/design.js +0 -92
- package/lib/markdown/design.js.map +0 -1
- package/lib/markdown/extract.d.ts +0 -7
- package/lib/markdown/extract.d.ts.map +0 -1
- package/lib/markdown/extract.js +0 -10
- package/lib/markdown/extract.js.map +0 -1
- package/lib/markdown/index.d.ts +0 -4
- package/lib/markdown/index.d.ts.map +0 -1
- package/lib/markdown/index.js +0 -4
- package/lib/markdown/index.js.map +0 -1
- package/lib/markdown/requirements.d.ts +0 -79
- package/lib/markdown/requirements.d.ts.map +0 -1
- package/lib/markdown/requirements.js +0 -105
- package/lib/markdown/requirements.js.map +0 -1
- package/lib/typescript/check-omission.d.ts +0 -2
- package/lib/typescript/check-omission.d.ts.map +0 -1
- package/lib/typescript/check-omission.js +0 -43
- package/lib/typescript/check-omission.js.map +0 -1
- package/lib/typescript/debug-type-errors.d.ts +0 -3
- package/lib/typescript/debug-type-errors.d.ts.map +0 -1
- package/lib/typescript/debug-type-errors.js +0 -35
- package/lib/typescript/debug-type-errors.js.map +0 -1
- package/lib/typescript/extract.d.ts +0 -7
- package/lib/typescript/extract.d.ts.map +0 -1
- package/lib/typescript/extract.js +0 -10
- package/lib/typescript/extract.js.map +0 -1
- package/lib/typescript/index.d.ts +0 -7
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/index.js +0 -7
- package/lib/typescript/index.js.map +0 -1
- package/lib/typescript/install-dependencies.d.ts +0 -29
- package/lib/typescript/install-dependencies.d.ts.map +0 -1
- package/lib/typescript/install-dependencies.js +0 -52
- package/lib/typescript/install-dependencies.js.map +0 -1
- package/lib/typescript/package.d.ts +0 -157
- package/lib/typescript/package.d.ts.map +0 -1
- package/lib/typescript/package.js +0 -115
- package/lib/typescript/package.js.map +0 -1
- package/lib/typescript/repair-omissions.d.ts +0 -3
- package/lib/typescript/repair-omissions.d.ts.map +0 -1
- package/lib/typescript/repair-omissions.js +0 -23
- package/lib/typescript/repair-omissions.js.map +0 -1
- package/lib/typescript/repair.d.ts +0 -3
- package/lib/typescript/repair.d.ts.map +0 -1
- package/lib/typescript/repair.js +0 -34
- package/lib/typescript/repair.js.map +0 -1
- package/lib/typescript/tsconfig.d.ts +0 -469
- package/lib/typescript/tsconfig.d.ts.map +0 -1
- package/lib/typescript/tsconfig.js +0 -143
- package/lib/typescript/tsconfig.js.map +0 -1
- package/lib/typescript/typescript.d.ts +0 -107
- package/lib/typescript/typescript.d.ts.map +0 -1
- package/lib/typescript/typescript.js +0 -180
- package/lib/typescript/typescript.js.map +0 -1
- package/lib/typescript/validate.d.ts +0 -10
- package/lib/typescript/validate.d.ts.map +0 -1
- package/lib/typescript/validate.js +0 -49
- package/lib/typescript/validate.js.map +0 -1
- package/src/agent/ai.ts +0 -215
- package/src/agent/anthropic.ts +0 -31
- package/src/agent/dependencies.ts +0 -62
- package/src/agent/file-context.ts +0 -8
- package/src/agent/index.ts +0 -9
- package/src/agent/model.ts +0 -39
- package/src/agent/module.ts +0 -418
- package/src/agent/openai.ts +0 -50
- package/src/agent/program.md +0 -38
- package/src/agent/program.ts +0 -37
- package/src/agent/prompts.ts +0 -20
- package/src/agent/scrape.ts +0 -47
- package/src/aws/auto/cfn.json +0 -225310
- package/src/aws/auto/docs.ts +0 -73
- package/src/aws/auto/index.ts +0 -4
- package/src/aws/auto/resource.ts +0 -269
- package/src/aws/auto/service.ts +0 -51
- package/src/aws/auto/spec.ts +0 -160
- package/src/markdown/design.ts +0 -125
- package/src/markdown/extract.ts +0 -9
- package/src/markdown/index.ts +0 -3
- package/src/markdown/requirements.ts +0 -135
- package/src/typescript/check-omission.ts +0 -47
- package/src/typescript/debug-type-errors.ts +0 -42
- package/src/typescript/extract.ts +0 -9
- package/src/typescript/index.ts +0 -6
- package/src/typescript/install-dependencies.ts +0 -61
- package/src/typescript/package.ts +0 -143
- package/src/typescript/repair-omissions.ts +0 -31
- package/src/typescript/repair.ts +0 -45
- package/src/typescript/tsconfig.ts +0 -170
- package/src/typescript/typescript.ts +0 -217
- package/src/typescript/validate.ts +0 -73
package/lib/aws/auto/docs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","sourceRoot":"","s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I,EAAE,MAAM;gBACZ,OAAO,EAAE,uDAAuD,KAAK,CAAC,WAAW,0EAA0E,KAAK,CAAC,YAAY;;;EAGrL,KAAK,CAAC,YAAY;;;;;;;;;;;EAWlB,QAAQ,EAAE;aACH;SACF;KACF,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,IAAI;KACzB,CAAC;AACJ,CAAC,CACF;CAAG"}
|
package/lib/aws/auto/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/aws/auto/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
package/lib/aws/auto/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/aws/auto/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Requirements } from "../../markdown/requirements";
|
|
2
|
-
import { TypeScriptFile } from "../../typescript";
|
|
3
|
-
declare const AWSResource_base: import("../../resource").Provider<"cfn-resource", [props: import("./spec").ResourceSpec & {
|
|
4
|
-
ServiceName: string;
|
|
5
|
-
ResourceName: string;
|
|
6
|
-
ResourceFQN: string;
|
|
7
|
-
Properties: {
|
|
8
|
-
[propertyName: string]: import("./spec").ResourceProperty & {
|
|
9
|
-
Spec: import("./spec").PropertySpec;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
} & {
|
|
13
|
-
ServiceName: string;
|
|
14
|
-
requirementsDir: string;
|
|
15
|
-
srcDir: string;
|
|
16
|
-
rootDir: string;
|
|
17
|
-
}], {
|
|
18
|
-
requirements: Requirements;
|
|
19
|
-
implementation: TypeScriptFile;
|
|
20
|
-
} | undefined>;
|
|
21
|
-
export declare class AWSResource extends AWSResource_base {
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/aws/auto/resource.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;;;;;;;;;;;iBAS/B,MAAM;qBACF,MAAM;YACf,MAAM;aACL,MAAM;;;;;AARrB,qBAAa,WAAY,SAAQ,gBAmMhC;CAAG"}
|
package/lib/aws/auto/resource.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { kebabCase } from "change-case";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { generateObject } from "../../agent/ai";
|
|
6
|
-
import { resolveModel } from "../../agent/model";
|
|
7
|
-
import { Requirements } from "../../markdown/requirements";
|
|
8
|
-
import { Resource } from "../../resource";
|
|
9
|
-
import { TypeScriptFile } from "../../typescript";
|
|
10
|
-
import { AWSDocReference } from "./docs";
|
|
11
|
-
export class AWSResource extends Resource("cfn-resource", async (ctx, props) => {
|
|
12
|
-
if (ctx.event === "delete") {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
// Load relevant Terraform provider implementation files for this resource
|
|
16
|
-
const terraformServicePath = path.join(props.rootDir, "3p", "terraform-provider-aws", "internal", "service", props.ServiceName.toLowerCase());
|
|
17
|
-
const files = await fs.readdir(terraformServicePath);
|
|
18
|
-
const resourcePrefix = kebabCase(props.ResourceName).toLowerCase();
|
|
19
|
-
const goFiles = files.filter((file) => file.endsWith(".go") && !file.endsWith("_test.go"));
|
|
20
|
-
if (goFiles.length === 0) {
|
|
21
|
-
throw new Error(`No Terraform implementation files found for resource ${props.ResourceName} in ${terraformServicePath}. Expected files starting with "${resourcePrefix}"`);
|
|
22
|
-
}
|
|
23
|
-
// Identify relevant files using AI
|
|
24
|
-
const { relevantFiles } = await identifyRelevantFiles(props.ResourceName, props.ServiceName, goFiles, resourcePrefix, props);
|
|
25
|
-
if (relevantFiles.length === 0) {
|
|
26
|
-
throw new Error(`No relevant Terraform implementation files identified for resource ${props.ResourceName}`);
|
|
27
|
-
}
|
|
28
|
-
console.log(`Found ${relevantFiles.length} relevant files for ${props.ResourceFQN}:`);
|
|
29
|
-
for (const file of relevantFiles) {
|
|
30
|
-
console.log(` - ${file}`);
|
|
31
|
-
}
|
|
32
|
-
const fileContents = await Promise.all(relevantFiles.map(async (file) => {
|
|
33
|
-
const content = await fs.readFile(path.join(terraformServicePath, file), "utf-8");
|
|
34
|
-
return `// ${file}\n${content}`;
|
|
35
|
-
}));
|
|
36
|
-
const terraformImplementation = fileContents.join("\n\n");
|
|
37
|
-
const requirements = new Requirements("requirements", {
|
|
38
|
-
modelId: "o3-mini",
|
|
39
|
-
reasoningEffort: "high",
|
|
40
|
-
file: path.join(props.requirementsDir, kebabCase(props.ResourceName) + ".md"),
|
|
41
|
-
requirements: [
|
|
42
|
-
`Due to problems relying on the AWS CloudFormation Service, we have decided
|
|
43
|
-
to reproduce the CRUD lifecycle of the ${props.ResourceName} resource locally using
|
|
44
|
-
TypeScript and the AWS SDK v3.
|
|
45
|
-
|
|
46
|
-
Before proceeding, we need to clearly define the requirements for this Resource's lifecycle handler, covering the following aspects:
|
|
47
|
-
1. Input and Output contract. These are the input properties that are accepted by CloudFormation
|
|
48
|
-
and the output Attributes produced and referenceable after the resource has been created. Don't be lazy by just referencing the documentation, you should describe the property and its behavior explicitly in the requirements document.
|
|
49
|
-
2. Update lifecycle for each property. This determines the behavior of the CRUD lifecycle when
|
|
50
|
-
a property changes, e.g. when a resource must be REPLACED when a property changes, or whether it can be mutated with a PUT.
|
|
51
|
-
3. AWS APIs that must be called to create this "CloudFormation Resource". This is not always 1:1, e.g. an IAM Role may have Policies that need to be created and attached.
|
|
52
|
-
4. Waiting for stabilization - AWS resources can take time to fully stabilize and be ready for use. Our Resource should wait and poll until the resource is ready. Please identify the resources that require stabilization check and which API call can be used to check the status reliably.
|
|
53
|
-
Note: ideally, stabilization checks are performed downstream where they are used (i.e. optimistically instead of pessimistically), so we should analyze this Resource's upstream dependencies and define any checks that should be performed.
|
|
54
|
-
5. Create, Update and Delete lifecycle procedure. What operations should be performed on CREATE, UPDATE and DELETE?
|
|
55
|
-
6. Error handling. Point out specific error codes for AWS APIs that require special handling an describe how.
|
|
56
|
-
|
|
57
|
-
Don't be vague. This is a specific requirements doc. Information like "robust" blah-blah is not relevant. Simply focus on the details of the AWS Resource, its contract, composite parts, error handling and lifecycle.
|
|
58
|
-
|
|
59
|
-
Based on analysis of the Terraform AWS Provider implementation below, be sure to identify:
|
|
60
|
-
- Important edge cases and error conditions that need special handling
|
|
61
|
-
- API call patterns and sequences that have been proven to work
|
|
62
|
-
- Stabilization and wait conditions that are necessary
|
|
63
|
-
- Any specific error codes or scenarios that require retry logic or special handling
|
|
64
|
-
|
|
65
|
-
Here is the relevant Terraform implementation:
|
|
66
|
-
${terraformImplementation}
|
|
67
|
-
|
|
68
|
-
Below is the CloudFormation Resource Specification for the ${props.ResourceName} resource:
|
|
69
|
-
${JSON.stringify(props, null, 2)}
|
|
70
|
-
`,
|
|
71
|
-
],
|
|
72
|
-
});
|
|
73
|
-
// First, fetch AWS SDK documentation
|
|
74
|
-
const docReference = new AWSDocReference("docs", {
|
|
75
|
-
serviceName: props.ServiceName,
|
|
76
|
-
resourceName: props.ResourceName,
|
|
77
|
-
requirements: requirements.content,
|
|
78
|
-
});
|
|
79
|
-
const exampleDir = path.join(props.rootDir, "alchemy", "src", "aws");
|
|
80
|
-
const fewShotExamples = await Promise.all((await fs.readdir(exampleDir))
|
|
81
|
-
.filter((file) => file.endsWith(".ts"))
|
|
82
|
-
.map(async (file) => {
|
|
83
|
-
const content = await fs.readFile(path.join(exampleDir, file), "utf-8");
|
|
84
|
-
return `// ${file}\n${content}`;
|
|
85
|
-
}));
|
|
86
|
-
const implementation = new TypeScriptFile("implementation", {
|
|
87
|
-
modelId: "claude-3-5-sonnet-20241022",
|
|
88
|
-
path: path.join(props.srcDir, kebabCase(props.ResourceName) + ".ts"),
|
|
89
|
-
projectRoot: __dirname,
|
|
90
|
-
typeCheck: true,
|
|
91
|
-
requirements: requirements.content.apply((requirements) => docReference.content.apply((docs) => `Implement the ${props.ResourceName} using TypeScript and AWS SDK V3.
|
|
92
|
-
|
|
93
|
-
Requirements:
|
|
94
|
-
${requirements}
|
|
95
|
-
|
|
96
|
-
API SDK v3 Documentation:
|
|
97
|
-
${docs}
|
|
98
|
-
|
|
99
|
-
Here is the Terraform Go implementation that we can learn from:
|
|
100
|
-
${terraformImplementation}
|
|
101
|
-
|
|
102
|
-
Here are some examples of how this has been done before. Make sure to follow the same structure and style of defining input and output contracts as types and then export a class using the mixin pattern and implement the lifecycle as a function, using ctx.event to detect CREATE, UPDATE and DELETE events:
|
|
103
|
-
${fewShotExamples.join("\n")}
|
|
104
|
-
|
|
105
|
-
One slight difference from the example is that the \`ignore\` and \`Resource\` functions should be imported from alchemy
|
|
106
|
-
|
|
107
|
-
import { type Context, Resource, ignore } from "alchemy";
|
|
108
|
-
|
|
109
|
-
Make sure to add an explicit type for Context<T>
|
|
110
|
-
|
|
111
|
-
async (ctx: Context<OutputType>, props: InputType) => Promise<OutputType> { .. }
|
|
112
|
-
|
|
113
|
-
It must be the OutputType. This avoids problems like it ctx.output being \`unknown\`.
|
|
114
|
-
|
|
115
|
-
Another common gotcha is that ctx.outputs only exists when ctx.event is update | delete. You will get type error when it is create.
|
|
116
|
-
|
|
117
|
-
For reference, here is what the Context object looks like:
|
|
118
|
-
export type Context<Outputs> = {
|
|
119
|
-
stage: string;
|
|
120
|
-
resourceID: ResourceID;
|
|
121
|
-
scope: IScope;
|
|
122
|
-
/**
|
|
123
|
-
* Indicate that this resource is being replaced.
|
|
124
|
-
* This will cause the resource to be deleted at the end of the stack's CREATE phase.
|
|
125
|
-
*/
|
|
126
|
-
replace(): void;
|
|
127
|
-
} & (
|
|
128
|
-
| {
|
|
129
|
-
event: "create";
|
|
130
|
-
}
|
|
131
|
-
| {
|
|
132
|
-
event: "update" | "delete";
|
|
133
|
-
output: Outputs;
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
`)),
|
|
137
|
-
});
|
|
138
|
-
return {
|
|
139
|
-
requirements,
|
|
140
|
-
implementation,
|
|
141
|
-
};
|
|
142
|
-
}) {
|
|
143
|
-
}
|
|
144
|
-
const RelevantFilesSchema = z.object({
|
|
145
|
-
/**
|
|
146
|
-
* List of Go file names that are relevant for implementing the CRUD lifecycle
|
|
147
|
-
* for this resource
|
|
148
|
-
*/
|
|
149
|
-
relevantFiles: z.array(z.string()),
|
|
150
|
-
});
|
|
151
|
-
async function identifyRelevantFiles(resourceName, serviceName, files, resourcePrefix, cfnSpec) {
|
|
152
|
-
const model = await resolveModel("gpt-4o");
|
|
153
|
-
const result = await generateObject({
|
|
154
|
-
model,
|
|
155
|
-
schema: RelevantFilesSchema,
|
|
156
|
-
temperature: 0.1,
|
|
157
|
-
messages: [
|
|
158
|
-
{
|
|
159
|
-
role: "system",
|
|
160
|
-
content: "You are an expert at AWS service implementations and Go code analysis. Your task is to identify ONLY the Go files that are specifically implementing the given AWS resource's CRUD lifecycle, excluding any files that work with other resources.",
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
role: "user",
|
|
164
|
-
content: `Please identify which Go files are specifically implementing the CRUD lifecycle for the AWS::${serviceName}::${resourceName} resource.
|
|
165
|
-
|
|
166
|
-
Available files (all in the ${serviceName.toLowerCase()} package):
|
|
167
|
-
${files.map((f) => `- ${f}`).join("\n")}
|
|
168
|
-
|
|
169
|
-
CloudFormation Resource Specification:
|
|
170
|
-
${JSON.stringify(cfnSpec, null, 2)}
|
|
171
|
-
|
|
172
|
-
Selection Rules:
|
|
173
|
-
1. ONLY select files that are specifically implementing this exact resource type (AWS::${serviceName}::${resourceName})
|
|
174
|
-
2. Files must handle one or more of:
|
|
175
|
-
- Resource creation and deletion
|
|
176
|
-
- Resource updates and modifications
|
|
177
|
-
- Resource state checking and stabilization
|
|
178
|
-
- Resource validation
|
|
179
|
-
3. Strict Exclusions:
|
|
180
|
-
- Test files
|
|
181
|
-
- Files working with other resource types
|
|
182
|
-
- General utility files (unless they are ONLY used by this resource)
|
|
183
|
-
- Files that just happen to share a similar prefix but work with different resources
|
|
184
|
-
4. Files should start with the prefix: ${resourcePrefix}
|
|
185
|
-
|
|
186
|
-
Important: Be very strict about only including files that are specifically working with this exact resource type. If a file works with multiple resources or similar resources, exclude it unless it's absolutely essential for this resource's implementation.
|
|
187
|
-
|
|
188
|
-
Return ONLY the list of relevant file names.`,
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
});
|
|
192
|
-
return result.object;
|
|
193
|
-
}
|
|
194
|
-
//# sourceMappingURL=resource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/aws/auto/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,E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AAC,CAAC,MAAM,CAAC;IACnC;;;OAGG;IACH,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACnC,CAAC,CAAC;AAEH,KAAK,UAAU,qBAAqB,CAClC,YAAoB,EACpB,WAAmB,EACnB,KAAe,EACf,cAAsB,EACtB,OAAoB;IAEpB,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;QAClC,KAAK;QACL,MAAM,EAAE,mBAAmB;QAC3B,WAAW,EAAE,GAAG;QAChB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,QAAQ;gBACd,OAAO,EACL,mPAAmP;aACtP;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,gGAAgG,WAAW,KAAK,YAAY;;8BAE/G,WAAW,CAAC,WAAW,EAAE;EACrD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGrC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;;;yFAGuD,WAAW,KAAK,YAAY;;;;;;;;;;;yCAW5E,cAAc;;;;6CAIV;aACtC;SACF;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CfnService } from "./spec";
|
|
2
|
-
declare const AWSService_base: import("../../resource").Provider<"aws-service", [props: CfnService & {
|
|
3
|
-
requirementsDir: string;
|
|
4
|
-
srcDir: string;
|
|
5
|
-
rootDir: string;
|
|
6
|
-
}], unknown>;
|
|
7
|
-
export declare class AWSService extends AWSService_base {
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/aws/auto/service.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;;qBAOlB,MAAM;YACf,MAAM;aACL,MAAM;;AAPrB,qBAAa,UAAW,SAAQ,eA2C/B;CAAG"}
|
package/lib/aws/auto/service.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { kebabCase } from "change-case";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { Folder } from "../../fs";
|
|
4
|
-
import { Resource } from "../../resource";
|
|
5
|
-
import { AWSResource } from "./resource";
|
|
6
|
-
export class AWSService extends Resource("aws-service", async (ctx, props) => {
|
|
7
|
-
const serviceDir = new Folder("service", path.join(props.requirementsDir, kebabCase(props.ServiceName))).path;
|
|
8
|
-
const srcDir = new Folder("src", path.join(props.srcDir, kebabCase(props.ServiceName))).path;
|
|
9
|
-
const resources = Object.entries(props.Resources);
|
|
10
|
-
if (process.env.DEBUG) {
|
|
11
|
-
// Only instantiate first resource in debug mode
|
|
12
|
-
const [resourceName, resource] = resources[0];
|
|
13
|
-
return [
|
|
14
|
-
new AWSResource(resourceName, {
|
|
15
|
-
...resource,
|
|
16
|
-
ServiceName: props.ServiceName,
|
|
17
|
-
requirementsDir: serviceDir,
|
|
18
|
-
srcDir,
|
|
19
|
-
rootDir: props.rootDir,
|
|
20
|
-
}),
|
|
21
|
-
];
|
|
22
|
-
}
|
|
23
|
-
return resources.map(([resourceName, resource]) => {
|
|
24
|
-
return new AWSResource(resourceName, {
|
|
25
|
-
...resource,
|
|
26
|
-
ServiceName: props.ServiceName,
|
|
27
|
-
rootDir: props.rootDir,
|
|
28
|
-
srcDir,
|
|
29
|
-
requirementsDir: serviceDir,
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}) {
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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Y,EAAE,QAAQ,CAAC,EAAE,EAAE;QAChD,OAAO,IAAI,WAAW,CAAC,YAAY,EAAE;YACnC,GAAG,QAAQ;YACX,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM;YACN,eAAe,EAAE,UAAU;SAC5B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CACF;CAAG"}
|
package/lib/aws/auto/spec.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export interface CfnSpec {
|
|
2
|
-
PropertyTypes: {
|
|
3
|
-
[propertyFQN: `${keyof CfnSpec["ResourceTypes"]}.${string}`]: PropertySpec;
|
|
4
|
-
};
|
|
5
|
-
ResourceTypes: {
|
|
6
|
-
[key: `AWS::${string}::${string}`]: ResourceSpec;
|
|
7
|
-
};
|
|
8
|
-
ResourceSpecificationVersion: string;
|
|
9
|
-
}
|
|
10
|
-
export type UpdateType = "Immutable" | "Mutable" | "Conditional";
|
|
11
|
-
export type PrimitiveType = "String" | "Double" | "Integer" | "Json";
|
|
12
|
-
export type PropertySpec = {
|
|
13
|
-
Type?: never;
|
|
14
|
-
PrimitiveType?: never;
|
|
15
|
-
Documentation: string;
|
|
16
|
-
Properties: {
|
|
17
|
-
[propertyName: string]: {
|
|
18
|
-
Documentation: string;
|
|
19
|
-
Type: "Extensions" | "Subject";
|
|
20
|
-
UpdateType: UpdateType;
|
|
21
|
-
Required: boolean;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
} | {
|
|
25
|
-
Type: "List" | "Map";
|
|
26
|
-
PrimitiveType?: PrimitiveType;
|
|
27
|
-
Required: boolean;
|
|
28
|
-
ItemType: string;
|
|
29
|
-
UpdateType: UpdateType;
|
|
30
|
-
} | {
|
|
31
|
-
Type?: never;
|
|
32
|
-
PrimitiveType: PrimitiveType;
|
|
33
|
-
Documentation: string;
|
|
34
|
-
UpdateType: UpdateType;
|
|
35
|
-
Required: boolean;
|
|
36
|
-
};
|
|
37
|
-
export type ResourceProperty = {
|
|
38
|
-
[propertyName: string]: {
|
|
39
|
-
Documentation: string;
|
|
40
|
-
UpdateType: UpdateType;
|
|
41
|
-
Required: boolean;
|
|
42
|
-
} & ({
|
|
43
|
-
Type: string;
|
|
44
|
-
PrimitiveType?: never;
|
|
45
|
-
} | {
|
|
46
|
-
Type: "List";
|
|
47
|
-
ItemType?: string;
|
|
48
|
-
PrimitiveItemType?: PrimitiveType;
|
|
49
|
-
DuplicatesAllowed: boolean;
|
|
50
|
-
} | {
|
|
51
|
-
Type?: never;
|
|
52
|
-
PrimitiveType: PrimitiveType;
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
export type ResourceSpec = {
|
|
56
|
-
Documentation: string;
|
|
57
|
-
Properties: ResourceProperty;
|
|
58
|
-
Attributes?: {
|
|
59
|
-
[attributeName: string]: {
|
|
60
|
-
PrimitiveType: PrimitiveType;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
export type CfnResource = ResourceSpec & {
|
|
65
|
-
ServiceName: string;
|
|
66
|
-
ResourceName: string;
|
|
67
|
-
ResourceFQN: string;
|
|
68
|
-
Properties: {
|
|
69
|
-
[propertyName: string]: ResourceProperty & {
|
|
70
|
-
Spec: PropertySpec;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
export type CfnService = {
|
|
75
|
-
ServiceName: string;
|
|
76
|
-
Resources: {
|
|
77
|
-
[resourceName: string]: CfnResource;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
export type CfnServices = Record<string, CfnService>;
|
|
81
|
-
export declare function loadServices(): Promise<CfnServices>;
|
|
82
|
-
export declare function loadSpec(): Promise<CfnSpec>;
|
|
83
|
-
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../src/aws/auto/spec.ts"],"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package/lib/aws/auto/spec.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
export async function loadServices() {
|
|
3
|
-
const cfnSpec = await loadSpec();
|
|
4
|
-
const resources = Object.keys(cfnSpec.ResourceTypes).map((resourceType) => {
|
|
5
|
-
const [partition, service, resource] = resourceType.split("::");
|
|
6
|
-
return {
|
|
7
|
-
partition,
|
|
8
|
-
service,
|
|
9
|
-
resource,
|
|
10
|
-
};
|
|
11
|
-
});
|
|
12
|
-
const awsServices = resources.filter(({ partition }) => partition === "AWS");
|
|
13
|
-
const awsServiceGroups = awsServices.reduce((acc, service) => {
|
|
14
|
-
if (!acc[service.service]) {
|
|
15
|
-
acc[service.service] = {
|
|
16
|
-
ServiceName: service.service,
|
|
17
|
-
Resources: {},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const spec = {
|
|
21
|
-
...cfnSpec.ResourceTypes[`AWS::${service.service}::${service.resource}`],
|
|
22
|
-
ServiceName: service.service,
|
|
23
|
-
ResourceName: service.resource,
|
|
24
|
-
ResourceFQN: `AWS::${service.service}::${service.resource}`,
|
|
25
|
-
};
|
|
26
|
-
for (const [propertyName, property] of Object.entries(spec.Properties)) {
|
|
27
|
-
if (property.Type && !["List", "Map"].includes(property.Type)) {
|
|
28
|
-
const propFQN = `${spec.ResourceFQN}.${propertyName}`;
|
|
29
|
-
const propertySpec = {
|
|
30
|
-
...cfnSpec.PropertyTypes[propFQN],
|
|
31
|
-
PropertyFQN: propFQN,
|
|
32
|
-
};
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
property.Spec = propertySpec;
|
|
35
|
-
if (propertySpec === undefined) {
|
|
36
|
-
throw new Error(`Property ${propertyName} has no spec`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
acc[service.service].Resources[service.resource] = spec;
|
|
41
|
-
return acc;
|
|
42
|
-
}, {});
|
|
43
|
-
return awsServiceGroups;
|
|
44
|
-
}
|
|
45
|
-
export async function loadSpec() {
|
|
46
|
-
const awsSpecURL = "https://dnwj8swjjbsbt.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json";
|
|
47
|
-
const specPath = path.join(__dirname, "cfn.json");
|
|
48
|
-
let awsSpec;
|
|
49
|
-
try {
|
|
50
|
-
awsSpec = JSON.parse(await Bun.file(specPath).text());
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
awsSpec = await (await fetch(awsSpecURL)).json();
|
|
54
|
-
await Bun.write(specPath, JSON.stringify(awsSpec, null, 2));
|
|
55
|
-
}
|
|
56
|
-
return awsSpec;
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=spec.js.map
|
package/lib/aws/auto/spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/aws/auto/spec.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAiG7B,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,OAAO,GAAG,MAAM,QAAQ,EAAE,CAAC;IAEjC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;QACxE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhE,OAAO;YACL,SAAS;YACT,OAAO;YACP,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC;IAC7E,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAM,CAAc,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QACxE,IAAI,CAAC,GAAG,CAAC,OAA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iB,CAAC,CAAC;IAEtB,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,UAAU,GACd,2FAA2F,CAAC;IAE9F,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAElD,IAAI,OAAO,CAAC;IACZ,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACjD,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,OAAkB,CAAC;AAC5B,CAAC"}
|
package/lib/markdown/design.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type FileContext, type ModelId } from "../agent";
|
|
2
|
-
export interface DesignInput {
|
|
3
|
-
prompt: string;
|
|
4
|
-
path: string;
|
|
5
|
-
deps?: any[];
|
|
6
|
-
model?: ModelId;
|
|
7
|
-
dependencies: FileContext[];
|
|
8
|
-
}
|
|
9
|
-
export interface DesignOutput {
|
|
10
|
-
path: string;
|
|
11
|
-
content: string;
|
|
12
|
-
}
|
|
13
|
-
declare const Design_base: import("../resource").Provider<"design", [props: DesignInput], DesignOutput>;
|
|
14
|
-
export declare class Design extends Design_base {
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=design.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"design.d.ts","sourceRoot":"","sources":["../../src/markdown/design.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,OAAO,EAIb,MAAM,UAAU,CAAC;AAMlB,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;;AAED,qBAAa,MAAO,SAAQ,WA+F3B;CAAG"}
|
package/lib/markdown/design.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { tool } from "ai";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { dependenciesAsMessages, generateText, resolveModel, } from "../agent";
|
|
6
|
-
import { Prompts } from "../agent/prompts";
|
|
7
|
-
import { rm } from "../fs";
|
|
8
|
-
import { extractMarkdown } from "../markdown/extract";
|
|
9
|
-
import { Resource } from "../resource";
|
|
10
|
-
export class Design extends Resource("design", async (ctx, props) => {
|
|
11
|
-
if (ctx.event === "delete") {
|
|
12
|
-
await rm(props.path);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const model = await resolveModel(props.model ?? "gpt-4o");
|
|
16
|
-
const loadFile = tool({
|
|
17
|
-
description: "Load a relevant file into context",
|
|
18
|
-
parameters: z.object({
|
|
19
|
-
file: z.string(),
|
|
20
|
-
}),
|
|
21
|
-
execute: async ({ file }) => fs.readFile(file, "utf-8"),
|
|
22
|
-
});
|
|
23
|
-
let existingContent = undefined;
|
|
24
|
-
if (ctx.event === "update") {
|
|
25
|
-
if (props.path) {
|
|
26
|
-
try {
|
|
27
|
-
existingContent = await fs.readFile(props.path, "utf-8");
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
// File doesn't exist yet, continue with empty content
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
existingContent = ctx.output.content;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
console.log(ctx.event === "create" ? "Designing" : "Revising design", ":", props.path);
|
|
38
|
-
const result = await generateText({
|
|
39
|
-
model,
|
|
40
|
-
// tools: {
|
|
41
|
-
// import: importFile,
|
|
42
|
-
// },
|
|
43
|
-
providerOptions: props.model === "o3-mini"
|
|
44
|
-
? {
|
|
45
|
-
openai: {
|
|
46
|
-
reasoningEffort: "high",
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
: undefined,
|
|
50
|
-
messages: [
|
|
51
|
-
{
|
|
52
|
-
role: "system",
|
|
53
|
-
content: Prompts.program,
|
|
54
|
-
},
|
|
55
|
-
...dependenciesAsMessages(props.dependencies),
|
|
56
|
-
...(existingContent
|
|
57
|
-
? [
|
|
58
|
-
{
|
|
59
|
-
role: "user",
|
|
60
|
-
content: `Here is the prior version of ${props.path}:\n${existingContent}`,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
role: "assistant",
|
|
64
|
-
content: "Thanks, I'll make sure to consider this when producing the next revision.",
|
|
65
|
-
},
|
|
66
|
-
]
|
|
67
|
-
: []),
|
|
68
|
-
{
|
|
69
|
-
role: "user",
|
|
70
|
-
content: props.prompt,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
role: "user",
|
|
74
|
-
content: [
|
|
75
|
-
`Make sure to list each of the files that need to be implemented and`,
|
|
76
|
-
"and to follow best practices in term of separation of concerns.",
|
|
77
|
-
"Ideally, each component has its own dedicated file.",
|
|
78
|
-
"Each file should be referenced using markdown links, e.g. [file.ts](./file.ts).",
|
|
79
|
-
].join(" "),
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
});
|
|
83
|
-
const content = extractMarkdown(result.text);
|
|
84
|
-
await fs.mkdir(path.dirname(props.path), { recursive: true });
|
|
85
|
-
await fs.writeFile(props.path, content);
|
|
86
|
-
return {
|
|
87
|
-
path: props.path,
|
|
88
|
-
content,
|
|
89
|
-
};
|
|
90
|
-
}) {
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=design.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"design.js","sourceRoot":"","sources":["../../src/markdown/design.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,sBAAsB,EACtB,YAAY,EACZ,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAgB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAerD,MAAM,OAAO,MAAO,SAAQ,QAAQ,CAClC,QAAQ,EACR,KAAK,EAAE,GAA0B,EAAE,KAAkB,EAAE,EAAE;IACvD,IAAI,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC;IAE1D,MAAM,QAAQ,GAAG,IAAI,CAAC;QACpB,WAAW,EAAE,mCAAmC;QAChD,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;YACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;SACjB,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,E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BACF;gBACH,CAAC,CAAC,EAAE,CAAC;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,KAAK,CAAC,MAAM;aACtB;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,qEAAqE;oBACrE,iEAAiE;oBACjE,qDAAqD;oBACrD,iFAAiF;iBAClF,CAAC,IAAI,CAAC,GAAG,CAAC;aACZ;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE7C,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE9D,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAExC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO;KACR,CAAC;AACJ,CAAC,CACF;CAAG"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts markdown content from a code block or returns the full content
|
|
3
|
-
* @param text Response text that may contain markdown code blocks
|
|
4
|
-
* @returns The markdown content from code block if found, otherwise returns the full text
|
|
5
|
-
*/
|
|
6
|
-
export declare function extractMarkdown(text: string): string;
|
|
7
|
-
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/markdown/extract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD"}
|
package/lib/markdown/extract.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts markdown content from a code block or returns the full content
|
|
3
|
-
* @param text Response text that may contain markdown code blocks
|
|
4
|
-
* @returns The markdown content from code block if found, otherwise returns the full text
|
|
5
|
-
*/
|
|
6
|
-
export function extractMarkdown(text) {
|
|
7
|
-
const matches = text.match(/```md\n([\s\S]*?)```/);
|
|
8
|
-
return matches?.[1]?.trim() ?? text.trim();
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=extract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/markdown/extract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACnD,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;AAC7C,CAAC"}
|
package/lib/markdown/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
|
package/lib/markdown/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/markdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
|