feat(project): tree-based scaffolding for agentcore project create - #1809
Conversation
7a9663a to
15433db
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## refactor #1809 +/- ##
============================================
+ Coverage 95.64% 95.65% +0.01%
============================================
Files 187 192 +5
Lines 8912 9147 +235
============================================
+ Hits 8524 8750 +226
- Misses 388 397 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cafb131 to
356105c
Compare
AlexanderRichey
left a comment
There was a problem hiding this comment.
I didn't see any blocking issues in this PR, but I have a number of questions whose answers I'd like to understand before approving.
agentcore project create
Introduce the asset embedding + rendering subsystem: AssetManager renders asset trees from either Bun.embeddedFiles (compiled binary) or the source filesystem (dev/node), applying Handlebars templating with HTML escaping disabled and atomic writes. - src/fs/atomicWrite: central temp-file + rename write util - src/assetManager: AssetManager, types, barrel, tests, snapshot baseline - src/assets/cdk: CDK project scaffold templates (payload, not source) - tsconfig/bunfig/oxlint/prettier: exclude src/assets from all tooling - add handlebars dependency
Remove comment about directory injection for testability.
Address review feedback on the AssetManager: - Handlebars strict mode: a template referencing an undefined variable now throws instead of silently rendering an empty string into a generated project file. - drop the speculative `docker` branch from the ignore-template rename; only git/npm ignores ship as assets today. - use code-unit ordering for embedded files so both list paths (embedded and filesystem) sort identically and deterministically.
Address review feedback from @Hweinstock: - rename AssetManager.ts -> manager.ts (only non-React .ts in the repo with an uppercase name; feature dirs use role-named lowercase files like core/project/manager.tsx). - document AssetFile vs EmbeddedFile so the distinction between a resolved tree entry and a raw Bun.embeddedFiles blob is explicit. - sync src/assets/cdk/package.json to the minor-version pins landed in #1777 (aws-cdk-lib ~2.261.0, @aws/agentcore-cdk 0.1.0-alpha.45, etc.).
Add a source-only TODO (HTML comment, invisible in the rendered README shipped to generated projects) flagging that the agentcore deploy/status commands may need a project prefix once the project CLI surface is final.
…urce Replace AssetManager/render with a project tree: a runtime-blind writer (writeTree over dir/file nodes) fed by a single asset-access seam (Source) that reads from disk under Node and from Bun.embeddedFiles in the compiled executable. scripts/build.ts embeds assets by naming so no per-file import attributes are needed. - project create takes a required --project-name and scaffolds into a fresh ./<name>/ directory (writeTree refuses to clobber existing files) - Template carries a spec fragment spread over the fixed base, so a new template (runtimes/memories/harnesses) is a pure-data entry
- write agentcore.json inside agentcore/ so ConfigIO project discovery finds it - mirror the CDK schema's reserved-name validation on --project-name - rename the hello world runtime to hello_world (AgentNameSchema forbids hyphens) - keep identifiers un-minified in builds so stack traces stay readable - rebuild scripts/build.ts on runWithExitCode; Bun.build already throws on failure so reportAndExit was dead code - rename Source to AssetSource; read() returns data, laziness moved to compose - add modeled ProjectFileExistsError - move src/project under src/core/project; test through FsProjectManager.create - extract config resolvers in the vended bin/cdk.ts and fail early on zero targets (typechecked against the built @aws/agentcore-cdk)
Address review feedback: - AssetSource implementations are now classes (EmbeddedAssetSource, FsAssetSource) matching how interfaces are implemented elsewhere - TemplateSpec, Template, DirNode, and FileNode are types since they model concrete data, not extendable behavior - ProjectFileExistsError extends AgentCoreCLIError with a user error source so it participates in error classification and exit codes - atomicWrite moved from src/fs into the shared src/io module
fd67b7c to
d1a704f
Compare
Hweinstock
left a comment
There was a problem hiding this comment.
LGTM! one small error comment, but we can take that as a follow-up. I don't think its blocking
I also found one small edge case when manually testing, that could be addressed as a followup. If I create a project within a project, it appears to lift the child up to the root. For example,
bun run start project create --project-name root
cd root
bun run start project create --project-name child
cd ..
I see both root and child at the same level. I would have expected child inside root.
… error Post-review follow-ups from #1809: - EmbeddedAssetSource.read now throws a modeled EmbeddedAssetNotFoundError instead of a bare Error. - project create now walks up from cwd for an agentcore/agentcore.json marker and throws a modeled NestedProjectError (USER source) instead of scaffolding a project inside an existing one.
… error (#1875) Post-review follow-ups from #1809: - EmbeddedAssetSource.read now throws a modeled EmbeddedAssetNotFoundError instead of a bare Error. - project create now walks up from cwd for an agentcore/agentcore.json marker and throws a modeled NestedProjectError (USER source) instead of scaffolding a project inside an existing one.
Summary
Implements
agentcore project createwith a tree-based scaffolding subsystem. A project is modeled as a file tree (dir/filenodes) . The writer is unaware of the underlying runtime, but here's where files are actually read from:src/assets/on diskBun.embeddedFilesscripts/build.tsembeds assets by naming (agentcore-assets/[dir]/[name].[ext]) via a file-loader plugin, so no per-filewith { type: "file" }import attributes are needed.Testing
bun run typecheck— cleanoxlint— cleanbun test— 263 passdist/assets/):project create --project-name MyAgentscaffolds./MyAgent/, and a re-run refuses to overwrite