Skip to content

Commit 5baf622

Browse files
christsoclaude
andcommitted
fix(cli): cap auto-update at current major version
Intersect the config's required_version range with <(major+1).0.0 so auto-update never pulls in a new major version with potential breaking changes. E.g., if current is 4.14.2 and range is ">=4.1.0", installs ">=4.1.0 <5.0.0" instead of ">=4.1.0". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8a75e7d commit 5baf622

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

apps/cli/src/version-check.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { coerce, satisfies, validRange } from 'semver';
1+
import { coerce, major, satisfies, validRange } from 'semver';
22

33
import packageJson from '../package.json' with { type: 'json' };
44
import { performSelfUpdate } from './self-update.js';
@@ -92,8 +92,14 @@ async function promptUpdate(): Promise<boolean> {
9292
}
9393

9494
async function runInlineUpdate(currentVersion: string, versionRange: string): Promise<void> {
95+
// Cap at the current major version to avoid unintended breaking changes.
96+
// e.g., if current is 4.14.2 and range is ">=4.1.0", install ">=4.1.0 <5.0.0"
97+
// so that a hypothetical 5.0.0 is never pulled in by auto-update.
98+
const currentMajor = major(coerce(currentVersion) ?? currentVersion);
99+
const safeRange = `${versionRange} <${currentMajor + 1}.0.0`;
100+
95101
console.log('');
96-
const result = await performSelfUpdate({ currentVersion, versionRange });
102+
const result = await performSelfUpdate({ currentVersion, versionRange: safeRange });
97103

98104
if (!result.success) {
99105
console.error(`${ANSI_RED}Update failed. Run \`agentv self update\` manually.${ANSI_RESET}`);

0 commit comments

Comments
 (0)