Skip to content

fix(cli): always use 'latest' for @elizaos deps in created projects#6480

Closed
lalalune wants to merge 7 commits into
developfrom
fix/elizaos-create-always-use-latest-version
Closed

fix(cli): always use 'latest' for @elizaos deps in created projects#6480
lalalune wants to merge 7 commits into
developfrom
fix/elizaos-create-always-use-latest-version

Conversation

@lalalune
Copy link
Copy Markdown
Member

@lalalune lalalune commented Feb 8, 2026

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 of workspace:*/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 of elizaos create --local (runtime now forces @elizaos/* to 'latest' unconditionally).

Confidence Score: 2/5

  • This PR is not safe to merge until the new integration test import error and template version-rewrite logic are corrected.
  • Score reflects two definite pre-merge issues: (1) packages/cli/tests/integration/local-development.test.ts references __dirname in 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 to latest.
  • packages/cli/tests/integration/local-development.test.ts, packages/cli/src/utils/copy-template.ts, packages/cli/src/scripts/copy-templates.ts

Important Files Changed

Filename Overview
.github/workflows/cli-tests.yml Increases CLI TS test timeout in workflow by passing --timeout 300000 to bun test.
packages/cli/bunfig.toml Raises Bun test timeout default to 300s for CLI tests to improve CI stability.
packages/cli/src/scripts/copy-templates.ts Build-time template copy now rewrites workspace:* to latest for all deps; needs scoping to avoid breaking non-@elizaOS workspace deps.
packages/cli/src/utils/copy-template.ts Runtime template copy now forces all @elizaos/* deps to latest, which likely breaks elizaos create --local / monorepo linking behavior.
packages/cli/tests/commands/update.test.ts Adds explicit exec timeout for project creation to reduce flakiness on slow CI.
packages/cli/tests/integration/local-development.test.ts Adds new integration tests but currently references __dirname without defining it in ESM, causing import-time failure.
packages/cli/tests/test-timeouts.ts Adjusts CI timeouts with macOS-specific increases for slow npm downloads.
packages/cli/tests/utils/copy-template.test.ts Extends copyTemplate tests to assert @elizaos/* deps become latest; mostly comment cleanups.

Sequence Diagram

sequenceDiagram
  autonumber
  participant User
  participant CLI as elizaos CLI
  participant CT as copyTemplate()
  participant FS as Filesystem
  participant NPM as npm registry

  User->>CLI: elizaos create <name> [--local]
  CLI->>CT: copyTemplate(templateType, targetDir)
  CT->>FS: copyDir(templateDir, targetDir)
  CT->>FS: read targetDir/package.json
  CT->>CT: set @elizaos/* deps => 'latest'
  CT->>FS: write targetDir/package.json
  CLI->>NPM: bun/npm install (resolves 'latest')

  Note over CLI,CT: If --local expects workspace/linking,
  Note over CLI,CT: forcing 'latest' breaks local workspace protocol

  rect rgba(200,200,255,0.25)
  User->>CLI: bun run build:cli
  CLI->>FS: run copy-templates build script
  FS->>FS: copy packages/*-starter into packages/cli/templates
  FS->>FS: rewrite package.json workspace:* => 'latest'
  end
Loading

0xbbjoker and others added 7 commits January 13, 2026 17:15
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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 8, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/elizaos-create-always-use-latest-version

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 8, 2026

Claude finished @lalalune's task in 1m 47s —— View job


Reviewing PR #6480

  • Analyze PR changes and context
  • Review changed files for issues
  • Check for tests and proper tooling
  • Provide feedback

Summary

This PR fixes an issue where elizaos create would pin @elizaos/* dependencies to the current CLI version (e.g., 1.7.2-alpha.0), which fails when those alpha versions aren't published to npm. The fix ensures all @elizaos/* dependencies use 'latest' instead.

✅ APPROVED - Changes look good

Key Changes Reviewed:

  1. packages/cli/src/scripts/copy-templates.ts - Build-time script now uses 'latest' instead of CLI version
  2. packages/cli/src/utils/copy-template.ts - Runtime normalization simplified and always sets 'latest'
  3. New integration tests - Comprehensive test coverage for local development scenarios
  4. Updated unit tests - Tests for version normalization behavior

💡 Minor Observations (non-blocking)

  1. copy-template.ts:107-114 - Duplicate path at index 0 and index 2:

    path.resolve(__dirname, '../../templates', packageName),  // index 0
    path.resolve(__dirname, '../templates', packageName),
    path.resolve(__dirname, '../../../templates', packageName),  // different

    The path ../../templates appears to have been deduplicated from the original, which is correct. No action needed.

  2. Test skip behavior in local-development.test.ts:131-137 - Tests silently skip with console.warn when dist/ doesn't exist. This is acceptable for CI where builds run before tests.

Checklist Verification

Check Status
Tests use bun:test only
Uses @elizaos/core imports
No npm/pnpm/yarn commands
No hardcoded secrets
Error handling present
TypeScript types (no any)
Functional code style
Tests cover new functionality

CI Status

CI workflows are currently in progress. Previous runs from Jan 26 show CLI tests passing.


Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +159 to +163
// 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') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment on lines 33 to 39
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';
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +23 to +27
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');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__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.

@lalalune lalalune closed this Mar 22, 2026
@lalalune lalalune deleted the fix/elizaos-create-always-use-latest-version branch May 5, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants