upgrade
Check for updates and upgrade era-code, OpenCode, and plugins. Also available as era-code update.
Usage
era-code upgrade [version] [options]
era-code update [version] [options]
Options
| Option | Description |
|---|---|
[version] | Specific era-code version to install (e.g., 3.4.0) |
-c, --check | Check for updates without installing |
-q, --quiet | No output (for scripting) |
--json | Output as JSON for programmatic use |
What It Checks
The upgrade command checks three components in sequence:
1. Era Code CLI
Queries the npm registry for the latest version of @era-laboratories/era-code. If a newer version is available, prompts to install it via npm install -g.
2. OpenCode Binary
Runs opencode --version and compares against the minimum required version. If OpenCode is missing or below the minimum, prompts to install/update via npm install -g opencode.
3. OpenCode Plugin
Reads .opencode/package.json and checks that @opencode-ai/plugin matches the validated version shipped with this era-code release. If mismatched, updates the file and runs bun install (or npm install as fallback).
Post-Upgrade Sync
After any component is updated, the command automatically re-syncs configuration files:
- Global resources (
~/.era/era-code/) - OpenCode configuration (
opencode.jsonc,AGENTS.md, symlinks) - Compiled directives
Examples
Check for updates
era-code upgrade --check
Output:
Era Upgrade
──────────────────────────────────────────────────
Era Code CLI
Current: 3.3.6
Latest: 3.4.0
↑ Update available
OpenCode
Installed: 0.2.3
Required: 0.2.0+
✓ Compatible
OpenCode Plugin
Installed: 1.2.20
Required: 1.2.20
✓ Up to date
Upgrade everything
era-code upgrade
Interactively prompts for each component that needs updating.
Upgrade to a specific version
era-code upgrade 3.3.5
Installs a specific era-code version (useful for pinning or downgrading). OpenCode and plugin checks still run.
JSON output for scripting
era-code upgrade --check --json
Returns structured JSON with version info for all three components.
Safety Net
The OpenCode plugin version is also checked silently during era-code start and era-code init. If the plugin version is wrong, it's automatically corrected without user interaction. This ensures the plugin stays at the validated version even if upgrade hasn't been run recently.
Version Constants
The validated versions are declared in src/core/config.ts:
OPENCODE_MIN_VERSION— Minimum compatible OpenCode binary version (semver>=)OPENCODE_PLUGIN_VERSION— Exact pinned version for@opencode-ai/plugin
These are updated with each era-code release to reflect tested/validated versions.