-
Notifications
You must be signed in to change notification settings - Fork 68
feat(project): tree-based scaffolding for agentcore project create
#1809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4e41c28
feat(assets): add AssetManager and CDK scaffold templates
tejaskash 0f84d7f
Remove comment
tejaskash 2dff1b8
fix(assets): strict template rendering and deterministic sort
tejaskash 969193c
refactor(assets): rename to kebab-case, doc types, sync cdk pins
tejaskash 0c04a17
docs(assets): note cdk README commands are provisional
tejaskash e0ea1cc
refactor(project): tree-based scaffolding with runtime-blind asset so…
tejaskash 675cc66
fix(project): address review feedback on tree-based scaffolding
tejaskash d1a704f
refactor(project): align scaffolding with codebase conventions
tejaskash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,3 +33,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | |
|
|
||
| # Finder (MacOS) folder config | ||
| .DS_Store | ||
|
|
||
| .agentreview | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| #!/usr/bin/env bun | ||
|
|
||
| import { $ } from "bun"; | ||
| import { join, resolve } from "node:path"; | ||
| import { runWithExitCode } from "../src/runnable"; | ||
|
|
||
| const REPO_ROOT = resolve(import.meta.dir, ".."); | ||
| const ASSETS_DIR = join(REPO_ROOT, "src", "assets"); | ||
| const ENTRYPOINT = join(REPO_ROOT, "src", "index.ts"); | ||
| const DIST = join(REPO_ROOT, "dist"); | ||
|
|
||
| const ASSET_NAMING = "agentcore-assets/[dir]/[name].[ext]"; | ||
|
|
||
| // Shrink whitespace/syntax but keep identifiers: minified names make stack | ||
| // traces unreadable and erase error names telemetry keys on. | ||
| const MINIFY = { whitespace: true, syntax: true, identifiers: false } as const; | ||
|
|
||
| /** Absolute paths of every asset file. dot:true so hidden files (.prettierrc) are included. */ | ||
| function discoverAssets(): string[] { | ||
| const files = [...new Bun.Glob("**/*").scanSync({ cwd: ASSETS_DIR, onlyFiles: true, dot: true })]; | ||
| return files.sort().map((relativePath) => join(ASSETS_DIR, relativePath)); | ||
| } | ||
|
|
||
| /** Force asset files through the file loader so template .ts/.js are embedded as bytes, not compiled. */ | ||
| function assetLoaderPlugin(): Bun.BunPlugin { | ||
| return { | ||
| name: "asset-file-loader", | ||
| setup(build) { | ||
| build.onLoad({ filter: /src[/\\]assets[/\\]/ }, async ({ path }) => ({ | ||
| contents: await Bun.file(path).bytes(), | ||
| loader: "file", | ||
| })); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| /** Fail loudly on a non-UTF-8 asset — the source reads every asset as text. */ | ||
| async function assertAssetsAreText(assets: string[]): Promise<void> { | ||
| const decoder = new TextDecoder("utf-8", { fatal: true }); | ||
| for (const path of assets) { | ||
| try { | ||
| decoder.decode(await Bun.file(path).bytes()); | ||
| } catch { | ||
| throw new Error(`Asset is not valid UTF-8: ${path}`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Bun.build rejects with an AggregateError on failure (throw defaults to true), | ||
| // so build errors propagate to runWithExitCode like any other. | ||
| async function bundle(): Promise<void> { | ||
| await Bun.build({ | ||
| entrypoints: [ENTRYPOINT], | ||
| outdir: DIST, | ||
| target: "node", | ||
| minify: MINIFY, | ||
| }); | ||
|
|
||
| // Mirror assets beside the emitted module for resolveAssetsRoot(). | ||
| const distAssets = join(DIST, "assets"); | ||
| await $`rm -rf ${distAssets}`; | ||
| await $`cp -R ${ASSETS_DIR} ${distAssets}`; | ||
| console.log(`Bundled to ${join(DIST, "index.js")} with assets/`); | ||
| } | ||
|
|
||
| async function compile(target: string): Promise<void> { | ||
| const assets = discoverAssets(); | ||
| await assertAssetsAreText(assets); | ||
|
|
||
| const outfile = join(DIST, "bin", `agentcore-${target.replace(/^bun-/, "")}`); | ||
| await $`mkdir -p ${join(DIST, "bin")}`; | ||
|
|
||
| await Bun.build({ | ||
| entrypoints: [ENTRYPOINT, ...assets], | ||
| compile: { target: target as Bun.Build.CompileTarget, outfile }, | ||
| minify: MINIFY, | ||
| root: REPO_ROOT, | ||
| naming: { asset: ASSET_NAMING }, | ||
| plugins: [assetLoaderPlugin()], | ||
| }); | ||
| console.log(`Compiled ${target} → ${outfile} (${assets.length} assets embedded)`); | ||
| } | ||
|
|
||
| process.exit( | ||
| await runWithExitCode(async () => { | ||
| const [command, target] = process.argv.slice(2); | ||
|
|
||
| if (command === "bundle") { | ||
| await bundle(); | ||
| } else if (command === "compile") { | ||
| if (!target) { | ||
| throw new Error("Usage: bun scripts/build.ts compile <bun-target>"); | ||
| } | ||
| await compile(target); | ||
| } else { | ||
| throw new Error("Usage: bun scripts/build.ts <bundle|compile <target>>"); | ||
| } | ||
| }), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "trailingComma": "es5", | ||
| "printWidth": 120, | ||
| "tabWidth": 2, | ||
| "semi": true, | ||
| "singleQuote": true, | ||
| "arrowParens": "avoid" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # AgentCore CDK Project | ||
|
|
||
| This CDK project is managed by the AgentCore CLI. It deploys your agent infrastructure into AWS using the `@aws/agentcore-cdk` L3 constructs. | ||
|
|
||
| ## Structure | ||
|
|
||
| - `bin/cdk.ts` — Entry point. Reads project configuration from `agentcore/` and creates a stack per deployment target. | ||
| - `lib/cdk-stack.ts` — Defines `AgentCoreStack`, which wraps the `AgentCoreApplication` L3 construct. | ||
| - `test/cdk.test.ts` — Unit tests for stack synthesis. | ||
|
|
||
| ## Useful commands | ||
|
|
||
| - `npm run build` compile TypeScript to JavaScript | ||
| - `npm run test` run unit tests | ||
| - `npx cdk synth` emit the synthesized CloudFormation template | ||
| - `npx cdk deploy` deploy this stack to your default AWS account/region | ||
| - `npx cdk diff` compare deployed stack with current state | ||
|
|
||
| ## Usage | ||
|
|
||
| You typically don't need to interact with this directory directly. The AgentCore CLI handles synthesis and deployment: | ||
|
|
||
| <!-- TODO: revisit these commands once the project CLI surface is final — | ||
| they may need a project prefix (e.g. --project / cwd) to disambiguate. --> | ||
|
|
||
| ```bash | ||
|
tejaskash marked this conversation as resolved.
|
||
| agentcore deploy # synthesizes and deploys via CDK | ||
| agentcore status # checks deployment status | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.