fix(cli): always use 'latest' for @elizaos deps in created projects#6480
fix(cli): always use 'latest' for @elizaos deps in created projects#6480lalalune wants to merge 7 commits into
Conversation
When running `elizaos create`, the created project's package.json now always uses 'latest' for @elizaos/* dependencies instead of pinning to the current CLI version. This fixes an issue where projects created with an alpha/dev CLI (e.g., 1.7.2-alpha.0) would fail to install because those versions aren't published on npm. Changes: - Build script (copy-templates.ts) now uses 'latest' instead of CLI version - Runtime script (copy-template.ts) simplified to always set 'latest' - Added integration tests for local development scenarios - Added unit tests for version normalization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The change to use 'latest' for @elizaOS deps means `elizaos create` now actually downloads packages from npm instead of failing when a dev version doesn't exist. This takes longer, especially on macOS CI runners with slower network I/O. Changes: - Add --timeout 300000 (5 min) flag to CLI test command in CI workflow - Increase bunfig.toml default test timeout from 180s to 300s - Make INDIVIDUAL_TEST timeout platform-specific (5 min macOS CI) - Make PROJECT_CREATION timeout platform-specific (4 min macOS CI) - Add explicit timeout to makeProj() helper in update.test.ts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @lalalune's task in 1m 47s —— View job Reviewing PR #6480
SummaryThis PR fixes an issue where ✅ APPROVED - Changes look goodKey Changes Reviewed:
💡 Minor Observations (non-blocking)
Checklist Verification
CI StatusCI workflows are currently in progress. Previous runs from Jan 26 show CLI tests passing. |
| // Set @elizaos dependencies to 'latest' for npm installability | ||
| // For local development testing, use `elizaos create --local` which links packages after creation | ||
| const normalizeElizaDeps = (deps: Record<string, string>, isDevDeps = false): void => { | ||
| for (const depName of Object.keys(deps)) { | ||
| if (depName.startsWith('@elizaos/') && deps[depName] !== 'latest') { |
There was a problem hiding this comment.
Breaks --local flow
copyTemplate() now forces all @elizaos/* deps (including workspace:*) to 'latest' (packages/cli/src/utils/copy-template.ts:159-170). That makes elizaos create --local unable to rely on workspace resolution/linking after creation, because the workspace protocol has already been destroyed in the generated package.json. If --local is intended to produce a monorepo-linked project, this change will make it install from npm instead (and could fail when local unpublished changes are required). Consider gating the 'latest' normalization behind the non-local path (or only converting workspace: specs while leaving non-workspace semver ranges unchanged).
| for (const section of ['dependencies', 'devDependencies']) { | ||
| if (packageData[section]) { | ||
| for (const [dep, version] of Object.entries(packageData[section])) { | ||
| if (version === 'workspace:*') { | ||
| packageData[section][dep] = cliVersion; | ||
| packageData[section][dep] = 'latest'; | ||
| } | ||
| } |
There was a problem hiding this comment.
Overwrites non-workspace versions
The build-time template rewriter replaces any dependency in dependencies/devDependencies whose version is exactly workspace:* with 'latest' (packages/cli/src/scripts/copy-templates.ts:33-39) without checking the package scope. If the starter templates ever include non-@elizaos/* workspace deps (common in monorepos), those will be rewritten to 'latest' too, which will break installs because those packages likely aren't published. This should probably be limited to @elizaos/* (matching the PR intent) or to a known allowlist.
| const MONOREPO_ROOT = join(__dirname, '../../../..'); | ||
| const CLI_PACKAGE = join(MONOREPO_ROOT, 'packages/cli'); | ||
| const PROJECT_STARTER = join(MONOREPO_ROOT, 'packages/project-starter'); | ||
| const PLUGIN_STARTER = join(MONOREPO_ROOT, 'packages/plugin-starter'); | ||
|
|
There was a problem hiding this comment.
__dirname undefined in ESM
This new test file uses __dirname (packages/cli/tests/integration/local-development.test.ts:23) but doesn’t define it. In Bun/Node ESM modules, __dirname is not available by default, so this test will throw at import time. Use fileURLToPath(import.meta.url) + path.dirname(...) like other ESM files in this repo.
Reopened from #6362 (was merged then rolled back)
Made with Cursor
Greptile Overview
Greptile Summary
This PR changes the CLI’s template handling so newly created projects always use
'latest'for@elizaos/*dependencies instead ofworkspace:*/pinned versions, aiming to ensure projects created from the published CLI can always install from npm. It updates both the build-time template bundling script (packages/cli/src/scripts/copy-templates.ts) and the runtime template copier (packages/cli/src/utils/copy-template.ts), and adjusts CI/test timeouts plus adds local-development/integration coverage.Key concerns are around correctness of the version-rewrite scope (build script currently rewrites any
workspace:*, not just@elizaos/*) and preserving the intended behavior ofelizaos create --local(runtime now forces@elizaos/*to'latest'unconditionally).Confidence Score: 2/5
packages/cli/tests/integration/local-development.test.tsreferences__dirnamein ESM, causing an import-time crash, and (2) both build-time and runtime dependency rewriting are broader than intended, likely breaking local/monorepo flows (--local) and potentially rewriting non-published workspace deps tolatest.Important Files Changed
--timeout 300000tobun test.workspace:*tolatestfor all deps; needs scoping to avoid breaking non-@elizaOS workspace deps.@elizaos/*deps tolatest, which likely breakselizaos create --local/ monorepo linking behavior.__dirnamewithout defining it in ESM, causing import-time failure.@elizaos/*deps becomelatest; mostly comment cleanups.Sequence Diagram