@devries-cameron20 / composio Mirror · read-only / commits / 4589cd440
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 00:45 UTC

Skip CLI releases without platform binaries (#3045)

## Summary - Ignore published `@composio/cli` releases that do not include a binary for the current platform during upgrade discovery. - Keep explicit tag-based upgrades consistent by treating tagged releases without a matching binary as no-op upgrades. - Simplify binary asset lookup by centralizing the CLI asset name logic. - Add coverage for empty release lists, missing platform assets, and explicit tag upgrades without binaries. ## Testing - Ran/added unit tests in `ts/packages/cli/test/src/services/upgrade-binary.test.ts` covering the new skip behavior. - Not run: full repository test suite. - Not run: CLI integration/e2e validation against live GitHub releases.

Rahul Tarak committed Mar 27, 2026 at 06:09 UTC 4589cd440616d4e728a087c9417dc0b8b65e6664
3 files changed +145 -11
ts/packages/cli/src/commands/upgrade.cmd.ts
+2 -3
@@ -1,5 +1,6 @@
1 import { Command } from '@effect/cli';
2 import { Effect } from 'effect';
3 +import { APP_VERSION } from 'src/constants';
4 import { UpgradeBinary } from 'src/services/upgrade-binary';
5 import { installSkillSafe } from 'src/effects/install-skill';
6
@@ -15,8 +16,6 @@ export const upgradeCmd = Command.make('upgrade', {}, () =>
16 Effect.gen(function* () {
17 const upgradeBinary = yield* UpgradeBinary;
18 const newReleaseTag = yield* upgradeBinary.upgrade();
18 - if (newReleaseTag) {
19 - yield* installSkillSafe({ releaseTag: newReleaseTag });
20 - }
19 + yield* installSkillSafe({ releaseTag: newReleaseTag ?? `@composio/cli@${APP_VERSION}` });
20 })
21 ).pipe(Command.withDescription('Upgrade your Composio CLI to the latest available version.'));
ts/packages/cli/src/services/upgrade-binary.ts
+40 -8
@@ -36,6 +36,12 @@ type GitHubRelease = {
36
37 const CLI_RELEASE_TAG_PATTERN = /^@composio\/cli@\d+\.\d+\.\d+.*$/;
38
39 +const getBinaryAssetName = (platformArch: PlatformArch): string =>
40 + `${CLI_BINARY_NAME}-${platformArch.platform}-${platformArch.arch}.zip`;
41 +
42 +const hasBinaryAsset = (release: GitHubRelease, platformArch: PlatformArch): boolean =>
43 + release.assets.some(asset => asset.name === getBinaryAssetName(platformArch));
44 +
45 // Service to manage CLI binary upgrades
46 export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/UpgradeBinary', {
47 accessors: true,
@@ -98,7 +104,9 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
104 )) as T;
105 });
106
101 - const fetchLatestRelease = (): Effect.Effect<GitHubRelease, UpgradeBinaryError, never> =>
107 + const fetchLatestRelease = (
108 + platformArch: PlatformArch
109 + ): Effect.Effect<Option.Option<GitHubRelease>, UpgradeBinaryError, never> =>
110 Effect.gen(function* () {
111 const release = yield* githubConfig.TAG.pipe(
112 Option.match({
@@ -143,8 +151,19 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
151 );
152 }
153
146 - let latest = cliReleases[0];
147 - for (const release of cliReleases.slice(1)) {
154 + const releasesWithBinary = cliReleases.filter(release =>
155 + hasBinaryAsset(release, platformArch)
156 + );
157 +
158 + if (releasesWithBinary.length === 0) {
159 + yield* Effect.logDebug(
160 + `No published CLI releases currently contain ${getBinaryAssetName(platformArch)}`
161 + );
162 + return Option.none();
163 + }
164 +
165 + let latest = releasesWithBinary[0];
166 + for (const release of releasesWithBinary.slice(1)) {
167 const comparison = yield* semverComparator(latest.tag_name, release.tag_name).pipe(
168 Effect.mapError(
169 error =>
@@ -161,7 +180,7 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
180 }
181
182 yield* Effect.logDebug(`Resolved latest CLI release tag: ${latest.tag_name}`);
164 - return latest;
183 + return Option.some(latest);
184 }),
185 onSome: Effect.fn(function* (tag) {
186 yield* Effect.logDebug(`Using tag: ${tag}`);
@@ -173,7 +192,14 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
192 parseErrorMessage: 'Failed to parse GitHub release JSON response',
193 });
194
176 - return release as GitHubRelease;
195 + if (!hasBinaryAsset(release, platformArch)) {
196 + yield* Effect.logDebug(
197 + `Release ${tag} does not yet contain ${getBinaryAssetName(platformArch)}`
198 + );
199 + return Option.none();
200 + }
201 +
202 + return Option.some(release as GitHubRelease);
203 }),
204 })
205 );
@@ -205,7 +231,7 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
231 `Looking up binary for ${platformArch.platform}-${platformArch.arch}`
232 );
233
208 - const binaryName = `${CLI_BINARY_NAME}-${platformArch.platform}-${platformArch.arch}.zip`;
234 + const binaryName = getBinaryAssetName(platformArch);
235
236 const asset = release.assets.find(asset => asset.name === binaryName);
237 if (!asset) {
@@ -540,7 +566,14 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
566
567 const didUpgrade = yield* ui.useMakeSpinner('Checking for updates...', spinner =>
568 Effect.gen(function* () {
543 - const release = yield* fetchLatestRelease();
569 + const platformArch = yield* detectPlatform;
570 + const releaseOption = yield* fetchLatestRelease(platformArch);
571 + if (Option.isNone(releaseOption)) {
572 + yield* spinner.stop('You are already running the latest version!');
573 + return false;
574 + }
575 +
576 + const release = releaseOption.value;
577 const updateAvailable = yield* isUpdateAvailable(release);
578 if (!updateAvailable) {
579 yield* spinner.stop('You are already running the latest version!');
@@ -551,7 +584,6 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
584 `New version available: ${release.tag_name} (current: ${APP_VERSION}). Downloading...`
585 );
586
554 - const platformArch = yield* detectPlatform;
587 const { name, data } = yield* downloadBinary(release, platformArch);
588
589 yield* spinner.message('Verifying checksum...');
ts/packages/cli/test/src/services/upgrade-binary.test.ts
+103
@@ -58,6 +58,21 @@ const runUpgrade = (configEntries: ReadonlyArray<[string, string]>) =>
58 Effect.runPromise
59 );
60
61 +const runUpgradeSuccess = (configEntries: ReadonlyArray<[string, string]>) =>
62 + Effect.gen(function* () {
63 + const service = yield* UpgradeBinary;
64 + return yield* service.upgrade();
65 + }).pipe(
66 + Effect.provide(UpgradeBinary.Default),
67 + Effect.provide(FetchHttpClient.layer),
68 + Effect.provide(BunFileSystem.layer),
69 + Effect.provide(TerminalUINoop),
70 + Effect.provide(NodeOsTest),
71 + Effect.withConfigProvider(ConfigProvider.fromMap(new Map(configEntries))),
72 + Effect.scoped,
73 + Effect.runPromise
74 + );
75 +
76 describe('UpgradeBinary', () => {
77 it('wraps non-2xx releases fetch failures with fetch context (no tag branch)', async () => {
78 vi.stubGlobal('Bun', { which: vi.fn(() => null) });
@@ -153,4 +168,92 @@ describe('UpgradeBinary', () => {
168 vi.restoreAllMocks();
169 }
170 });
171 +
172 + it('skips newer releases that do not yet contain a binary for the current platform', async () => {
173 + vi.stubGlobal('Bun', { which: vi.fn(() => null) });
174 +
175 + try {
176 + await withHttpServer(
177 + (req, res) => {
178 + if (req.url === '/repos/test-owner/test-repo/releases?per_page=100') {
179 + res.writeHead(200, { 'content-type': 'application/json' });
180 + res.end(
181 + JSON.stringify([
182 + {
183 + tag_name: '@composio/cli@9.9.9',
184 + prerelease: false,
185 + draft: false,
186 + assets: [],
187 + },
188 + {
189 + tag_name: '@composio/cli@0.0.1',
190 + prerelease: false,
191 + draft: false,
192 + assets: [],
193 + },
194 + ])
195 + );
196 + return;
197 + }
198 +
199 + res.writeHead(404, { 'content-type': 'application/json' });
200 + res.end(JSON.stringify({ message: 'not found' }));
201 + },
202 + async apiBaseUrl => {
203 + const result = await runUpgradeSuccess([
204 + ['GITHUB_API_BASE_URL', apiBaseUrl],
205 + ['GITHUB_OWNER', 'test-owner'],
206 + ['GITHUB_REPO', 'test-repo'],
207 + ]);
208 +
209 + expect(result).toBeUndefined();
210 + }
211 + );
212 + } finally {
213 + vi.unstubAllGlobals();
214 + vi.restoreAllMocks();
215 + }
216 + });
217 +
218 + it('treats an explicitly requested release without binaries as no upgrade', async () => {
219 + vi.stubGlobal('Bun', { which: vi.fn(() => null) });
220 +
221 + try {
222 + await withHttpServer(
223 + (req, res) => {
224 + if (
225 + req.url ===
226 + `/repos/test-owner/test-repo/releases/tags/${encodeURIComponent('@composio/cli@9.9.9')}`
227 + ) {
228 + res.writeHead(200, { 'content-type': 'application/json' });
229 + res.end(
230 + JSON.stringify({
231 + tag_name: '@composio/cli@9.9.9',
232 + prerelease: false,
233 + draft: false,
234 + assets: [],
235 + })
236 + );
237 + return;
238 + }
239 +
240 + res.writeHead(404, { 'content-type': 'application/json' });
241 + res.end(JSON.stringify({ message: 'not found' }));
242 + },
243 + async apiBaseUrl => {
244 + const result = await runUpgradeSuccess([
245 + ['GITHUB_API_BASE_URL', apiBaseUrl],
246 + ['GITHUB_OWNER', 'test-owner'],
247 + ['GITHUB_REPO', 'test-repo'],
248 + ['GITHUB_TAG', '@composio/cli@9.9.9'],
249 + ]);
250 +
251 + expect(result).toBeUndefined();
252 + }
253 + );
254 + } finally {
255 + vi.unstubAllGlobals();
256 + vi.restoreAllMocks();
257 + }
258 + });
259 });