Skip to content

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

fix(cli): make GitHub releases the version authority (#3993)

Alberto Schiabel7bf09cdbb8d2
diff --git a/.agents/skills/cli-release/SKILL.md b/.agents/skills/cli-release/SKILL.md
index f3b516510..12712b64b 100644
--- a/.agents/skills/cli-release/SKILL.md
+++ b/.agents/skills/cli-release/SKILL.md
@@ -13,7 +13,9 @@ Read `references/release-workflow.md` before selecting a candidate or dispatchin
- Never add a Changeset for `@composio/cli` or `@composio/cli-local-tools`; both packages are ignored by Changesets and such files wedge `ts.release.yml`.
- Treat a merge to `next` that touches CLI paths as a beta build. Promote a tested beta with the `promote-stable` workflow action for the normal stable-release path.
-- Treat a direct CLI `package.json` version bump as a release-owner-only recovery path, not the contributor default.
+- Never bump the private CLI `package.json` to select a binary version. For an
+ intentional minor or major, build an explicitly versioned beta and promote
+ that tested beta through the same stable path.
- Resolve beta tags and workflow state from GitHub immediately before acting. Never invent or reuse a stale candidate from memory.
- A stable promotion is a production write. If the user did not name the exact beta tag, present the resolved candidate and obtain explicit confirmation before dispatching it.
- Follow the release through asset verification and installation tests. Do not stop after the dispatch succeeds.
diff --git a/.agents/skills/cli-release/references/release-workflow.md b/.agents/skills/cli-release/references/release-workflow.md
index 7da20c09f..09fcbcbcb 100644
--- a/.agents/skills/cli-release/references/release-workflow.md
+++ b/.agents/skills/cli-release/references/release-workflow.md
@@ -23,14 +23,16 @@
## Choose The Path
-| Goal | Path | Result |
-| --- | --- | --- |
-| Ship an ordinary CLI change | Merge the reviewed PR to `next` | The push builds a rolling beta automatically. |
-| Build a beta from a branch | Dispatch `build-beta` at that branch | A prerelease is built from the branch commit. |
-| Publish a stable CLI | Promote an existing tested beta | The beta's source commit is rebuilt and published under the stable tag. |
-| Resume a failed promotion | Re-run or re-dispatch the same beta after inspecting the draft | An unpublished draft can be resumed and its assets replaced. |
+| Goal | Path | Result |
+| --------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------- |
+| Ship an ordinary CLI change | Merge the reviewed PR to `next` | The push builds a rolling beta automatically. |
+| Build a beta from a branch | Dispatch `build-beta` at that branch | A prerelease is built from the branch commit. |
+| Publish a stable CLI | Promote an existing tested beta | The beta's source commit is rebuilt and published under the stable tag. |
+| Resume a failed promotion | Re-run or re-dispatch the same beta after inspecting the draft | An unpublished draft can be resumed and its assets replaced. |
-The resolver also treats a CLI `package.json` version change pushed to `next` as a stable release. Do not use that as the normal contributor procedure. It bypasses beta selection and is reserved for explicit release-owner recovery or migration work.
+The private CLI `package.json` uses a development sentinel and never selects a
+binary version. If a release owner needs an intentional minor or major version,
+dispatch an explicitly versioned beta, verify it, and promote that exact beta.
## Changeset Rule
@@ -94,7 +96,10 @@ If the user asked for a stable release without naming a beta, show the candidate
## Build A Manual Beta
-Use this only when an explicit beta build is requested. The selected ref supplies both the workflow definition and source commit.
+Use this only when an explicit beta build is requested. The selected ref
+supplies both the workflow definition and source commit. Omit `version` for the
+normal next-patch beta, or provide an exact `major.minor.patch` base for an
+intentional minor or major release.
```bash
SOURCE_BRANCH='replace-with-branch'
@@ -105,6 +110,16 @@ gh workflow run build-cli-binaries.yml \
--raw-field action=build-beta
```
+For an intentional minor or major, add a version newer than the latest stable:
+
+```bash
+gh workflow run build-cli-binaries.yml \
+ --repo "$REPOSITORY" \
+ --ref "$SOURCE_BRANCH" \
+ --raw-field action=build-beta \
+ --raw-field version=0.3.0
+```
+
Watch the returned run through publication and installation tests. A beta is not a stable release.
## Promote A Beta To Stable
diff --git a/.github/scripts/cli-release/resolve-release-target.sh b/.github/scripts/cli-release/resolve-release-target.sh
index f51e12401..03297f147 100755
--- a/.github/scripts/cli-release/resolve-release-target.sh
+++ b/.github/scripts/cli-release/resolve-release-target.sh
@@ -3,12 +3,12 @@
# Resolve the CLI release target and write its metadata to $GITHUB_OUTPUT for the
# build/release jobs of build-cli-binaries.yml. Three modes:
#
-# - push to `next` with a ts/packages/cli/package.json version bump → stable release
-# - push to `next` without a bump, or workflow_dispatch build-beta → rolling beta
-# - workflow_dispatch promote-stable <beta tag> → stable promotion
+# - push to `next` → rolling beta
+# - workflow_dispatch build-beta [version] → rolling or explicitly versioned beta
+# - workflow_dispatch promote-stable <beta tag> → stable promotion
#
-# Inputs (env): EVENT_NAME, ACTION_INPUT, BETA_TAG_INPUT, GITHUB_TOKEN,
-# REPOSITORY, RUN_NUMBER, COMMIT_SHA
+# Inputs (env): EVENT_NAME, ACTION_INPUT, BETA_TAG_INPUT, VERSION_INPUT,
+# GITHUB_TOKEN, REPOSITORY, RUN_NUMBER, COMMIT_SHA
# Output: key=value lines appended to $GITHUB_OUTPUT
set -euo pipefail
@@ -30,26 +30,57 @@ latest_stable_tag() {
| last | .tagName // empty'
}
-# Echo the next "<major>.<minor>.<patch+1>" off the latest stable release, falling
-# back to the working-tree package.json when no stable release exists yet.
+# Echo the next "<major>.<minor>.<patch+1>" off the latest stable release.
next_beta_base_version() {
local latest current
latest=$(latest_stable_tag)
if [[ -z "$latest" ]]; then
- echo "No stable @composio/cli release found, falling back to package.json" >&2
- current=$(node -p "require('./ts/packages/cli/package.json').version")
- else
- current=${latest#@composio/cli@}
+ echo "No stable @composio/cli release found; provide VERSION_INPUT for the first beta" >&2
+ return 1
fi
+ current=${latest#@composio/cli@}
local major minor patch
IFS='.' read -r major minor patch <<<"$current"
echo "${major}.${minor}.$((patch + 1))"
}
+version_is_greater() {
+ local candidate=$1 baseline=$2
+ local candidate_major candidate_minor candidate_patch
+ local baseline_major baseline_minor baseline_patch
+ IFS='.' read -r candidate_major candidate_minor candidate_patch <<<"$candidate"
+ IFS='.' read -r baseline_major baseline_minor baseline_patch <<<"$baseline"
+
+ ((candidate_major > baseline_major)) ||
+ ((candidate_major == baseline_major && candidate_minor > baseline_minor)) ||
+ ((
+ candidate_major == baseline_major &&
+ candidate_minor == baseline_minor &&
+ candidate_patch > baseline_patch
+ ))
+}
+
emit_beta_target() {
- local next_version release_tag
- next_version=$(next_beta_base_version)
+ local requested_version=${1:-}
+ local latest latest_version next_version release_tag
+ if [[ -n "$requested_version" ]]; then
+ if [[ ! "$requested_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Beta version must match <major>.<minor>.<patch>" >&2
+ return 1
+ fi
+ next_version=$requested_version
+ latest=$(latest_stable_tag)
+ if [[ -n "$latest" ]]; then
+ latest_version=${latest#@composio/cli@}
+ if ! version_is_greater "$next_version" "$latest_version"; then
+ echo "Beta version ${next_version} must be newer than latest stable ${latest_version}" >&2
+ return 1
+ fi
+ fi
+ else
+ next_version=$(next_beta_base_version)
+ fi
release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"
{
echo "checkout_ref=${COMMIT_SHA}"
@@ -73,24 +104,16 @@ emit_stable_target() {
} >>"$GITHUB_OUTPUT"
}
-# ── Push to next ──
+# Every push to next is a beta. Stable releases always promote an already-tested
+# beta, so package metadata can never create a second version authority.
if [[ "$EVENT_NAME" == "push" ]]; then
- current_version=$(node -p "require('./ts/packages/cli/package.json').version")
- previous_version=$(git show HEAD^:ts/packages/cli/package.json 2>/dev/null \
- | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version" 2>/dev/null || echo "")
-
- # A version bump on push is a stable release; anything else is a rolling beta.
- if [[ -n "$previous_version" && "$current_version" != "$previous_version" ]]; then
- emit_stable_target "@composio/cli@${current_version}" "$current_version" "$COMMIT_SHA"
- else
- emit_beta_target
- fi
+ emit_beta_target
exit 0
fi
# ── workflow_dispatch: build-beta ──
if [[ "$EVENT_NAME" == "workflow_dispatch" && "$ACTION_INPUT" == "build-beta" ]]; then
- emit_beta_target
+ emit_beta_target "${VERSION_INPUT:-}"
exit 0
fi
diff --git a/.github/workflows/build-cli-binaries.yml b/.github/workflows/build-cli-binaries.yml
index c991f2a00..7b282f913 100644
--- a/.github/workflows/build-cli-binaries.yml
+++ b/.github/workflows/build-cli-binaries.yml
@@ -23,6 +23,9 @@ on:
beta_tag:
description: 'Existing beta release tag to promote (only for promote-stable, e.g. @composio/[email protected])'
required: false
+ version:
+ description: 'Optional semver base for a manual beta (e.g. 0.3.0); omit for the next patch after latest stable'
+ required: false
# Least privilege by default: only the release job creates/edits releases and uploads assets.
# `prepare` reads releases (gh release list) and `build` uploads workflow artifacts — both work
@@ -58,6 +61,7 @@ jobs:
EVENT_NAME: ${{ github.event_name }}
ACTION_INPUT: ${{ inputs.action }}
BETA_TAG_INPUT: ${{ inputs.beta_tag }}
+ VERSION_INPUT: ${{ inputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
RUN_NUMBER: ${{ github.run_number }}
@@ -132,6 +136,8 @@ jobs:
- name: Cross-compile CLI binary
working-directory: ts/packages/cli
+ env:
+ RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}
run: pnpm build:binary:cross --target ${{ matrix.target }}
- name: Verify binary
@@ -140,6 +146,13 @@ jobs:
ls -la dist/binaries/${{ matrix.artifact }}
file dist/binaries/${{ matrix.artifact }}
+ - name: Verify binary version
+ if: matrix.target == 'bun-linux-x64'
+ working-directory: ts/packages/cli
+ run: |
+ expected_version='${{ needs.prepare.outputs.release_tag }}'
+ test "$(./dist/binaries/${{ matrix.artifact }} --version)" = "${expected_version#@composio/cli@}"
+
- name: Test binary
if: matrix.target == 'bun-linux-x64'
working-directory: ts/packages/cli
diff --git a/test/release-workflow.test.ts b/test/release-workflow.test.ts
index 787eb3e3f..699f1d247 100644
--- a/test/release-workflow.test.ts
+++ b/test/release-workflow.test.ts
@@ -47,6 +47,10 @@ const buildCliWorkflow = readFileSync(
new URL('../.github/workflows/build-cli-binaries.yml', import.meta.url),
'utf8'
);
+const buildAllCliBinariesScript = readFileSync(
+ new URL('../ts/packages/cli/scripts/build-all-binaries.ts', import.meta.url),
+ 'utf8'
+);
const installGuide = readFileSync(new URL('../INSTALL.md', import.meta.url), 'utf8');
const installHealthCheck = readFileSync(
new URL('../.github/workflows/cli.install-health-check.yml', import.meta.url),
@@ -629,6 +633,26 @@ if (!resolveTargetScript.includes('--exclude-drafts')) {
'resolve-release-target.sh must exclude draft stable releases from beta base selection'
);
}
+if (!buildCliWorkflow.includes('RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}')) {
+ throw new Error('CLI binary builds must receive the resolved GitHub release tag');
+}
+if (
+ !buildAllCliBinariesScript.includes(
+ '...buildCliReleaseVersionDefineArgs(process.env.RELEASE_TAG)'
+ )
+) {
+ throw new Error('the all-target CLI build must embed the resolved GitHub release version');
+}
+if (
+ !buildCliWorkflow.includes(
+ "- name: Verify binary version\n if: matrix.target == 'bun-linux-x64'"
+ )
+) {
+ throw new Error('CLI binary version verification must run only on a native target');
+}
+if (!buildCliWorkflow.includes('expected_version#@composio/cli@')) {
+ throw new Error('CLI binary version verification must strip the release tag prefix');
+}
// --- cli.install-health-check.yml: canary must exercise the failure-prone pinned path ---
@@ -955,6 +979,82 @@ function runResolver({ env, releasesFixture, curlFixture, ghViewIsDraft }) {
}
}
+// Pushes to next are always betas, regardless of private package metadata.
+{
+ const r = runResolver({
+ env: {
+ EVENT_NAME: 'push',
+ REPOSITORY: 'ComposioHQ/composio',
+ RUN_NUMBER: '43',
+ COMMIT_SHA: 'deadbeef',
+ },
+ releasesFixture: [{ tagName: '@composio/[email protected]', isPrerelease: false }],
+ });
+ if (r.status !== 0) {
+ throw new Error(`resolve-release-target.sh push failed\nstderr:\n${r.stderr}`);
+ }
+ if (r.outputs.release_tag !== '@composio/[email protected]') {
+ throw new Error(`push must produce the next rolling beta, got ${r.outputs.release_tag}`);
+ }
+ if (r.outputs.prerelease !== 'true') {
+ throw new Error('push must never publish a stable release directly');
+ }
+}
+
+// Release owners can choose an intentional minor/major base without changing package.json.
+{
+ const r = runResolver({
+ env: {
+ EVENT_NAME: 'workflow_dispatch',
+ ACTION_INPUT: 'build-beta',
+ VERSION_INPUT: '0.3.0',
+ REPOSITORY: 'ComposioHQ/composio',
+ RUN_NUMBER: '44',
+ COMMIT_SHA: 'deadbeef',
+ },
+ releasesFixture: [{ tagName: '@composio/[email protected]', isPrerelease: false }],
+ });
+ if (r.status !== 0) {
+ throw new Error(`explicitly versioned build-beta failed\nstderr:\n${r.stderr}`);
+ }
+ if (r.outputs.release_tag !== '@composio/[email protected]') {
+ throw new Error(`explicit build-beta version was not honored: ${r.outputs.release_tag}`);
+ }
+}
+
+{
+ const r = runResolver({
+ env: {
+ EVENT_NAME: 'workflow_dispatch',
+ ACTION_INPUT: 'build-beta',
+ VERSION_INPUT: '0.2.33',
+ REPOSITORY: 'ComposioHQ/composio',
+ RUN_NUMBER: '45',
+ COMMIT_SHA: 'deadbeef',
+ },
+ releasesFixture: [{ tagName: '@composio/[email protected]', isPrerelease: false }],
+ });
+ if (r.status === 0 || !r.stderr.includes('must be newer than latest stable')) {
+ throw new Error('build-beta must reject an explicit version at or below latest stable');
+ }
+}
+
+{
+ const r = runResolver({
+ env: {
+ EVENT_NAME: 'workflow_dispatch',
+ ACTION_INPUT: 'build-beta',
+ VERSION_INPUT: 'next',
+ REPOSITORY: 'ComposioHQ/composio',
+ RUN_NUMBER: '46',
+ COMMIT_SHA: 'deadbeef',
+ },
+ });
+ if (r.status === 0 || !r.stderr.includes('Beta version must match')) {
+ throw new Error('build-beta must reject a non-semver explicit version');
+ }
+}
+
// build-beta bumps off the NUMERIC-latest stable release. The fixture deliberately interleaves
// 0.2.10 and 0.2.9: a lexical sort would pick 0.2.9 and resolve 0.2.10 here — regression lock.
{
diff --git a/ts/packages/cli/AGENTS.md b/ts/packages/cli/AGENTS.md
index 7065afbfe..fbfa7c480 100644
--- a/ts/packages/cli/AGENTS.md
+++ b/ts/packages/cli/AGENTS.md
@@ -228,7 +228,10 @@ Use the repo-local `cli-release` skill before building or publishing first-party
- A push to `next` touching CLI paths publishes a rolling beta automatically.
- The normal stable path promotes an existing tested beta through the `promote-stable` workflow action.
- `@composio/cli` and `@composio/cli-local-tools` are ignored by Changesets. Never add a changeset targeting either package; it wedges the TypeScript SDK release action. Put human-facing CLI notes in `CHANGELOG.md` directly.
-- A direct `package.json` version bump is supported by the resolver only as an explicit release-owner recovery path, not the contributor default.
+- `package.json` uses a private development sentinel and is never a
+ binary-release authority. For an intentional minor or major release,
+ dispatch `build-beta` with its optional version input, verify that beta, then
+ promote it normally.
### Key Workflow Files
diff --git a/ts/packages/cli/CHANGELOG.md b/ts/packages/cli/CHANGELOG.md
index 85d6306f3..51992431d 100644
--- a/ts/packages/cli/CHANGELOG.md
+++ b/ts/packages/cli/CHANGELOG.md
@@ -1,6 +1,15 @@
# @composio/cli
-## 0.3.0
+## Unreleased
+
+### Patch Changes
+
+- Make GitHub release metadata the sole version authority for standalone CLI
+ binaries. Release builds now embed their exact tag version, manual skill
+ installation follows the packaged release tag, and stable releases can only
+ promote a tested beta.
+
+## 0.2.33
### Security
diff --git a/ts/packages/cli/package.json b/ts/packages/cli/package.json
index d112af356..4e771d89a 100644
--- a/ts/packages/cli/package.json
+++ b/ts/packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@composio/cli",
- "version": "0.3.0",
+ "version": "0.0.0-development",
"description": "Composio CLI",
"main": "./dist/bin.mjs",
"private": true,
diff --git a/ts/packages/cli/scripts/build-all-binaries.ts b/ts/packages/cli/scripts/build-all-binaries.ts
index 9636c8eba..8282a398a 100644
--- a/ts/packages/cli/scripts/build-all-binaries.ts
+++ b/ts/packages/cli/scripts/build-all-binaries.ts
@@ -17,6 +17,7 @@ import { Command } from '@effect/platform';
import { BunContext, BunRuntime } from '@effect/platform-bun';
import { buildCompanionModules, copyLocalToolBinaryAssets, teardown } from './_shared';
import { BinaryBuildError } from './build-error';
+import { buildCliReleaseVersionDefineArgs } from '../src/utils/cli-release-version';
/**
* All cross-compilation targets and their artifact names.
@@ -36,6 +37,7 @@ function runBunBuild(target: string, outfile: string) {
'./src/bin.ts',
'--env',
'DEBUG_OVERRIDE_*',
+ ...buildCliReleaseVersionDefineArgs(process.env.RELEASE_TAG),
'--compile',
'--production',
'--target',
diff --git a/ts/packages/cli/scripts/build-binary-cross.ts b/ts/packages/cli/scripts/build-binary-cross.ts
index 2b316385f..0c6e82720 100644
--- a/ts/packages/cli/scripts/build-binary-cross.ts
+++ b/ts/packages/cli/scripts/build-binary-cross.ts
@@ -20,6 +20,7 @@ import { Command } from '@effect/platform';
import { BunContext, BunRuntime } from '@effect/platform-bun';
import { buildCompanionModules, copyLocalToolBinaryAssets, teardown } from './_shared';
import { BinaryBuildError } from './build-error';
+import { buildCliReleaseVersionDefineArgs } from '../src/utils/cli-release-version';
/**
* Maps Bun cross-compilation targets to Composio artifact names.
@@ -67,6 +68,7 @@ export function buildBinaryCross() {
'./src/bin.ts',
'--env',
'DEBUG_OVERRIDE_*',
+ ...buildCliReleaseVersionDefineArgs(process.env.RELEASE_TAG),
'--compile',
'--production',
'--target',
diff --git a/ts/packages/cli/scripts/build-binary.ts b/ts/packages/cli/scripts/build-binary.ts
index 31179a414..27521276a 100644
--- a/ts/packages/cli/scripts/build-binary.ts
+++ b/ts/packages/cli/scripts/build-binary.ts
@@ -4,6 +4,7 @@ import { Command } from '@effect/platform';
import { BunContext, BunRuntime } from '@effect/platform-bun';
import { buildCompanionModules, copyLocalToolBinaryAssets, teardown } from './_shared';
import { BinaryBuildError } from './build-error';
+import { buildCliReleaseVersionDefineArgs } from '../src/utils/cli-release-version';
/**
* Usage: `bun scripts/build-binary.ts`
@@ -27,6 +28,8 @@ export function buildBinary() {
'--env',
'DEBUG_OVERRIDE_*',
+ ...buildCliReleaseVersionDefineArgs(process.env.RELEASE_TAG),
+
/**
* Generate a standalone Bun executable containing your bundled code.
*/
diff --git a/ts/packages/cli/src/constants.ts b/ts/packages/cli/src/constants.ts
index 43cb77758..9af58648a 100644
--- a/ts/packages/cli/src/constants.ts
+++ b/ts/packages/cli/src/constants.ts
@@ -1,6 +1,8 @@
import { constants } from '@composio/core';
import pkg from '../package.json' with { type: 'json' };
+declare const __COMPOSIO_CLI_RELEASE_VERSION__: string | undefined;
+
const { DEFAULT_BASE_URL, DEFAULT_WEB_URL } = constants;
export { DEFAULT_BASE_URL, DEFAULT_WEB_URL };
@@ -53,9 +55,16 @@ export const CACHE_FILENAMES = {
};
/**
- * Version of the Composio CLI, read from `package.json` at build time.
+ * Version of the running Composio CLI.
+ *
+ * Release builds replace `__COMPOSIO_CLI_RELEASE_VERSION__` with the exact
+ * GitHub release version. The private package version is only a source/dev
+ * fallback and must never drive binary release selection.
*/
-export const APP_VERSION = pkg.version;
+export const APP_VERSION =
+ typeof __COMPOSIO_CLI_RELEASE_VERSION__ === 'undefined'
+ ? pkg.version
+ : __COMPOSIO_CLI_RELEASE_VERSION__;
/**
* Name of the Composio CLI application, read from `package.json` at build time.
diff --git a/ts/packages/cli/src/effects/install-skill.ts b/ts/packages/cli/src/effects/install-skill.ts
index 0c51dd5e2..92792d876 100644
--- a/ts/packages/cli/src/effects/install-skill.ts
+++ b/ts/packages/cli/src/effects/install-skill.ts
@@ -4,6 +4,7 @@ import { NodeOs } from 'src/services/node-os';
import { TerminalUI } from 'src/services/terminal-ui';
import { GITHUB_CONFIG } from 'src/effects/github-config';
import { APP_VERSION, type CliReleaseChannel } from 'src/constants';
+import { readInstalledReleaseTag } from 'src/services/run-companion-modules';
import {
fetchLatestCliRelease,
fetchCliReleaseByTag,
@@ -81,11 +82,13 @@ export const resolveSkillReleaseTag = ({
channel,
githubConfig,
httpClient,
+ installedReleaseTag,
releaseTag,
}: {
channel?: SkillReleaseChannel;
githubConfig: GitHubConfig;
httpClient: HttpClient.HttpClient;
+ installedReleaseTag?: string;
releaseTag?: string;
}) =>
Effect.gen(function* () {
@@ -98,13 +101,13 @@ export const resolveSkillReleaseTag = ({
return configTag;
}
- if (!channel) {
- return `@composio/cli@${APP_VERSION}`;
+ if (installedReleaseTag) {
+ return installedReleaseTag;
}
const latest = yield* fetchLatestCliRelease({
assetDescription: SKILL_ASSET_NAME,
- channel,
+ channel: channel ?? inferSkillReleaseChannel(APP_VERSION),
githubConfig,
hasRequiredAsset: hasSkillAsset,
httpClient,
@@ -147,6 +150,7 @@ export const installSkill = (options?: {
channel: options?.channel,
githubConfig,
httpClient,
+ installedReleaseTag: yield* readInstalledReleaseTag(process.execPath),
releaseTag: options?.releaseTag,
});
diff --git a/ts/packages/cli/src/services/run-companion-modules.ts b/ts/packages/cli/src/services/run-companion-modules.ts
index dcd6bcab3..4583b5e09 100644
--- a/ts/packages/cli/src/services/run-companion-modules.ts
+++ b/ts/packages/cli/src/services/run-companion-modules.ts
@@ -10,6 +10,7 @@ import extractZip from 'extract-zip';
import { GitHubRelease } from 'src/effects/resolve-cli-release';
import { BaseConfigProviderLive, extendConfigProvider } from 'src/services/config';
import { parseChecksumsText, sha256Hex } from 'src/utils/checksums';
+import { CLI_RELEASE_TAG_PREFIX } from 'src/utils/cli-release-version';
export const RUN_COMPANION_MODULE_BASENAMES: ReadonlyArray<string> = [
'run-helpers-runtime',
@@ -295,8 +296,8 @@ export const readInstalledReleaseTag = (
export const normalizeCliReleaseVersion = (releaseIdentifier: string): string => {
const trimmed = releaseIdentifier.trim();
- if (trimmed.startsWith('@composio/cli@')) {
- return trimmed.slice('@composio/cli@'.length);
+ if (trimmed.startsWith(CLI_RELEASE_TAG_PREFIX)) {
+ return trimmed.slice(CLI_RELEASE_TAG_PREFIX.length);
}
if (/^v\d+\.\d+\.\d+(?:[-+].*)?$/.test(trimmed)) {
return trimmed.slice(1);
@@ -304,6 +305,9 @@ export const normalizeCliReleaseVersion = (releaseIdentifier: string): string =>
return trimmed;
};
+export const normalizeCliReleaseTag = (releaseIdentifier: string): string =>
+ `${CLI_RELEASE_TAG_PREFIX}${normalizeCliReleaseVersion(releaseIdentifier)}`;
+
export const resolveInstalledCliVersion = (
execPath: string,
fallbackVersion: string
@@ -312,6 +316,14 @@ export const resolveInstalledCliVersion = (
normalizeCliReleaseVersion(releaseTag ?? fallbackVersion)
);
+export const resolveInstalledCliReleaseTag = (
+ execPath: string,
+ fallbackVersion: string
+): Effect.Effect<string, never, FileSystem.FileSystem | Path.Path> =>
+ Effect.map(readInstalledReleaseTag(execPath), releaseTag =>
+ normalizeCliReleaseTag(releaseTag ?? fallbackVersion)
+ );
+
export const writeInstalledReleaseTag = (
installDir: string,
releaseTag: string
@@ -439,8 +451,7 @@ const resolveRepairReleaseTag = ({
return pinnedTag;
}
- const installedTag = yield* readInstalledReleaseTag(execPath);
- return installedTag || `@composio/cli@${appVersion}`;
+ return yield* resolveInstalledCliReleaseTag(execPath, appVersion);
});
const nonEmptyConfigWithFallback = (name: string, fallback: string) =>
diff --git a/ts/packages/cli/src/services/setup-skill-installer.ts b/ts/packages/cli/src/services/setup-skill-installer.ts
index b588d0767..31b1da1a4 100644
--- a/ts/packages/cli/src/services/setup-skill-installer.ts
+++ b/ts/packages/cli/src/services/setup-skill-installer.ts
@@ -1,11 +1,14 @@
-import { FileSystem, Path } from '@effect/platform';
-import { Effect } from 'effect';
+import { FileSystem, HttpClient, Path } from '@effect/platform';
+import { Config, Effect } from 'effect';
import {
+ inferSkillReleaseChannel,
installSkill,
resolveInstalledSkillName,
+ resolveSkillReleaseTag,
resolveTargetSkillPath,
SKILL_RELEASE_TAG_FILENAME,
} from 'src/effects/install-skill';
+import { GITHUB_CONFIG } from 'src/effects/github-config';
import { APP_VERSION } from 'src/constants';
import { readInstalledReleaseTag } from 'src/services/run-companion-modules';
import { NodeOs } from './node-os';
@@ -13,11 +16,19 @@ import { NodeOs } from './node-os';
export const resolveSetupSkillReleaseTag = (
execPath = process.execPath,
fallbackVersion = APP_VERSION
-): Effect.Effect<string, never, FileSystem.FileSystem | Path.Path> =>
- Effect.map(
- readInstalledReleaseTag(execPath),
- releaseTag => releaseTag ?? `@composio/cli@${fallbackVersion}`
- );
+) =>
+ Effect.gen(function* () {
+ const httpClient = yield* HttpClient.HttpClient;
+ const githubConfig = yield* Config.all(GITHUB_CONFIG);
+ const installedReleaseTag = yield* readInstalledReleaseTag(execPath);
+
+ return yield* resolveSkillReleaseTag({
+ channel: inferSkillReleaseChannel(fallbackVersion),
+ githubConfig,
+ httpClient,
+ installedReleaseTag,
+ });
+ });
const checkClaudeSkillCurrent = (
fs: FileSystem.FileSystem,
@@ -115,21 +126,23 @@ export class SetupSkillInstaller extends Effect.Service<SetupSkillInstaller>()(
const os = yield* NodeOs;
const isCurrent = (releaseTag: string) =>
checkClaudeSkillCurrent(fs, path, os.homedir, releaseTag);
- const installedReleaseTag = resolveSetupSkillReleaseTag().pipe(
- Effect.provideService(FileSystem.FileSystem, fs),
- Effect.provideService(Path.Path, path)
+ const releaseTag = yield* Effect.cached(
+ resolveSetupSkillReleaseTag().pipe(
+ Effect.provideService(FileSystem.FileSystem, fs),
+ Effect.provideService(Path.Path, path)
+ )
);
return {
- isClaudeSkillReady: Effect.flatMap(installedReleaseTag, isCurrent),
+ isClaudeSkillReady: Effect.flatMap(releaseTag, isCurrent),
hasManagedClaudeSkill: hasManagedClaudeSkill(os.homedir),
ensureClaudeSkill: Effect.gen(function* () {
- const releaseTag = yield* installedReleaseTag;
- if (yield* isCurrent(releaseTag)) return false;
+ const targetReleaseTag = yield* releaseTag;
+ if (yield* isCurrent(targetReleaseTag)) return false;
yield* installSkill({
target: 'claude',
- releaseTag,
+ releaseTag: targetReleaseTag,
silent: true,
});
return true;
diff --git a/ts/packages/cli/src/services/upgrade-binary.ts b/ts/packages/cli/src/services/upgrade-binary.ts
index ce57f5b2f..f6150fbc4 100644
--- a/ts/packages/cli/src/services/upgrade-binary.ts
+++ b/ts/packages/cli/src/services/upgrade-binary.ts
@@ -14,7 +14,7 @@ import { renderPrettyError } from './utils/pretty-error';
import { TerminalUI } from './terminal-ui';
import {
collectExpectedRunCompanionAssetRelativePaths,
- readInstalledReleaseTag,
+ resolveInstalledCliReleaseTag,
writeInstalledReleaseTag,
} from './run-companion-modules';
@@ -173,9 +173,7 @@ const provideFsAndPath = <A, E>(
* Check if update is available
*/
const resolveCurrentReleaseIdentifier = (ctx: UpgradeBinaryContext, currentPath: string) =>
- provideFsAndPath(ctx, readInstalledReleaseTag(currentPath)).pipe(
- Effect.map(releaseTag => releaseTag || `@composio/cli@${APP_VERSION}`)
- );
+ provideFsAndPath(ctx, resolveInstalledCliReleaseTag(currentPath, APP_VERSION));
const isUpdateAvailable = (
release: GitHubRelease,
diff --git a/ts/packages/cli/src/utils/cli-release-version.ts b/ts/packages/cli/src/utils/cli-release-version.ts
new file mode 100644
index 000000000..f11ecbf14
--- /dev/null
+++ b/ts/packages/cli/src/utils/cli-release-version.ts
@@ -0,0 +1,21 @@
+export const CLI_RELEASE_TAG_PREFIX = '@composio/cli@';
+export const CLI_RELEASE_VERSION_DEFINE = '__COMPOSIO_CLI_RELEASE_VERSION__';
+
+const CLI_RELEASE_TAG_PATTERN =
+ /^@composio\/cli@(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/u;
+
+export const extractCliReleaseVersion = (releaseTag: string): string | undefined =>
+ CLI_RELEASE_TAG_PATTERN.exec(releaseTag.trim())?.[1];
+
+export const buildCliReleaseVersionDefineArgs = (
+ releaseTag: string | undefined
+): ReadonlyArray<string> => {
+ if (!releaseTag?.trim()) return [];
+
+ const releaseVersion = extractCliReleaseVersion(releaseTag);
+ if (!releaseVersion) {
+ throw new Error(`Invalid Composio CLI release tag: ${releaseTag}`);
+ }
+
+ return ['--define', `${CLI_RELEASE_VERSION_DEFINE}=${JSON.stringify(releaseVersion)}`] as const;
+};
diff --git a/ts/packages/cli/test/src/effects/install-skill.test.ts b/ts/packages/cli/test/src/effects/install-skill.test.ts
index d0ae240db..5222fbd23 100644
--- a/ts/packages/cli/test/src/effects/install-skill.test.ts
+++ b/ts/packages/cli/test/src/effects/install-skill.test.ts
@@ -30,8 +30,12 @@ const TEST_SKILL_ZIP = Uint8Array.from(
const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
-const makeInstallEffect = (home: string, apiBaseUrl: string) =>
- installSkill({ target: 'claude', releaseTag: TEST_RELEASE_TAG }).pipe(
+const makeInstallEffect = (
+ home: string,
+ apiBaseUrl: string,
+ options: { readonly releaseTag?: string } = { releaseTag: TEST_RELEASE_TAG }
+) =>
+ installSkill({ target: 'claude', ...options }).pipe(
Effect.provide(
Layer.mergeAll(
TestPlatform,
@@ -159,6 +163,7 @@ const makeResolveEffect = (
configEntries: ReadonlyArray<[string, string]>,
options: {
channel?: SkillReleaseChannel;
+ installedReleaseTag?: string;
releaseTag?: string;
} = {}
) =>
@@ -170,6 +175,7 @@ const makeResolveEffect = (
channel: options.channel,
githubConfig,
httpClient,
+ installedReleaseTag: options.installedReleaseTag,
releaseTag: options.releaseTag,
});
}).pipe(
@@ -235,6 +241,7 @@ describe('install-skill', () => {
const releaseTag = '@composio/[email protected]';
const tag = yield* makeResolveEffect([], {
channel: 'stable',
+ installedReleaseTag: '@composio/[email protected]',
releaseTag,
});
@@ -242,6 +249,119 @@ describe('install-skill', () => {
})
);
+ it.effect('prefers the configured release tag over packaged metadata', () =>
+ Effect.gen(function* () {
+ const tag = yield* makeResolveEffect([['GITHUB_TAG', '@composio/[email protected]']], {
+ installedReleaseTag: '@composio/[email protected]',
+ });
+
+ expect(tag).toBe('@composio/[email protected]');
+ })
+ );
+
+ it.effect('uses the packaged release tag when no explicit selector is provided', () =>
+ Effect.gen(function* () {
+ const tag = yield* makeResolveEffect([], {
+ installedReleaseTag: '@composio/[email protected]',
+ });
+
+ expect(tag).toBe('@composio/[email protected]');
+ })
+ );
+
+ it.scoped('installs from the packaged release tag when package metadata differs', () => {
+ const installDir = tempy.temporaryDirectory();
+ const execPathSpy = vi
+ .spyOn(process, 'execPath', 'get')
+ .mockReturnValue(`${installDir}/composio`);
+ let requestedReleasePath = '';
+
+ return Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const packagedReleaseTag = '@composio/[email protected]';
+ yield* fs.writeFileString(path.join(installDir, 'release-tag.txt'), packagedReleaseTag);
+
+ const apiBaseUrl = yield* startTestHttpServer((req, res) => {
+ if (req.url === '/skill.zip') {
+ res.writeHead(200, { 'content-type': 'application/zip' });
+ res.end(TEST_SKILL_ZIP);
+ return;
+ }
+
+ requestedReleasePath = req.url ?? '';
+ res.writeHead(200, { 'content-type': 'application/json' });
+ res.end(
+ JSON.stringify({
+ tag_name: packagedReleaseTag,
+ assets: [
+ {
+ name: 'composio-skill.zip',
+ browser_download_url: `http://${req.headers.host}/skill.zip`,
+ },
+ ],
+ })
+ );
+ });
+
+ const home = tempy.temporaryDirectory();
+ yield* makeInstallEffect(home, apiBaseUrl, {});
+
+ expect(requestedReleasePath).toContain(encodeURIComponent(packagedReleaseTag));
+ expect(
+ yield* fs.readFileString(
+ path.join(home, '.agents', 'skills', 'composio-cli', SKILL_RELEASE_TAG_FILENAME)
+ )
+ ).toBe(`${packagedReleaseTag}\n`);
+ }).pipe(
+ Effect.provide(TestPlatform),
+ Effect.ensuring(Effect.sync(() => execPathSpy.mockRestore()))
+ );
+ });
+
+ it.scoped('falls back to the latest inferred channel for source and development runs', () =>
+ Effect.gen(function* () {
+ yield* stubBunWhichMiss;
+ const apiBaseUrl = yield* startTestHttpServer((_req, res) => {
+ res.writeHead(200, { 'content-type': 'application/json' });
+ res.end(
+ JSON.stringify([
+ {
+ tag_name: '@composio/[email protected]',
+ draft: false,
+ prerelease: true,
+ assets: [
+ {
+ name: 'composio-skill.zip',
+ browser_download_url: 'http://127.0.0.1/beta-skill.zip',
+ },
+ ],
+ },
+ {
+ tag_name: '@composio/[email protected]',
+ draft: false,
+ prerelease: false,
+ assets: [
+ {
+ name: 'composio-skill.zip',
+ browser_download_url: 'http://127.0.0.1/stable-skill.zip',
+ },
+ ],
+ },
+ ])
+ );
+ });
+
+ const tag = yield* makeResolveEffect([
+ ['GITHUB_API_BASE_URL', apiBaseUrl],
+ ['GITHUB_OWNER', 'test-owner'],
+ ['GITHUB_REPO', 'test-repo'],
+ ]);
+
+ expect(tag).toBe('@composio/[email protected]');
+ })
+ );
+
it.scoped('fails with a typed decode error for malformed GitHub release lists', () =>
Effect.gen(function* () {
const apiBaseUrl = yield* startTestHttpServer((_req, res) => {
diff --git a/ts/packages/cli/test/src/services/setup-skill-installer.test.ts b/ts/packages/cli/test/src/services/setup-skill-installer.test.ts
index d39d45510..37be00379 100644
--- a/ts/packages/cli/test/src/services/setup-skill-installer.test.ts
+++ b/ts/packages/cli/test/src/services/setup-skill-installer.test.ts
@@ -1,4 +1,4 @@
-import { FileSystem, Path } from '@effect/platform';
+import { FileSystem, HttpClient, HttpClientResponse, Path } from '@effect/platform';
import { BunFileSystem, BunPath } from '@effect/platform-bun';
import { describe, expect, layer } from '@effect/vitest';
import { Effect, Layer } from 'effect';
@@ -11,7 +11,36 @@ import {
resolveSetupSkillReleaseTag,
} from 'src/services/setup-skill-installer';
-const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
+const TestHttpClient = Layer.succeed(
+ HttpClient.HttpClient,
+ HttpClient.make(request =>
+ Effect.succeed(
+ HttpClientResponse.fromWeb(
+ request,
+ new Response(
+ JSON.stringify([
+ {
+ tag_name: '@composio/[email protected]',
+ prerelease: false,
+ assets: [
+ {
+ name: 'composio-skill.zip',
+ browser_download_url: 'https://example.test/composio-skill.zip',
+ },
+ ],
+ },
+ ]),
+ {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ }
+ )
+ )
+ )
+ )
+);
+
+const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer, TestHttpClient);
describe('SetupSkillInstaller', () => {
layer(TestPlatform)(it => {
@@ -32,13 +61,13 @@ describe('SetupSkillInstaller', () => {
})
);
- it.effect('falls back to the build version outside a packaged install', () =>
+ it.effect('discovers the latest stable release outside a packaged install', () =>
Effect.gen(function* () {
const path = yield* Path.Path;
const installDir = tempy.temporaryDirectory();
expect(yield* resolveSetupSkillReleaseTag(path.join(installDir, 'composio'), '0.3.0')).toBe(
- '@composio/[email protected]'
+ '@composio/[email protected]'
);
})
);
diff --git a/ts/packages/cli/test/src/services/upgrade-binary.test.ts b/ts/packages/cli/test/src/services/upgrade-binary.test.ts
index bf8612340..2428de219 100644
--- a/ts/packages/cli/test/src/services/upgrade-binary.test.ts
+++ b/ts/packages/cli/test/src/services/upgrade-binary.test.ts
@@ -1,10 +1,7 @@
import { describe, expect, it, vi } from '@effect/vitest';
import { ConfigProvider, Effect, Layer } from 'effect';
-import { FetchHttpClient, Path } from '@effect/platform';
-import { BunFileSystem } from '@effect/platform-bun';
-import { existsSync, mkdirSync, readFileSync, mkdtempSync, writeFileSync } from 'node:fs';
-import { tmpdir } from 'node:os';
-import path from 'node:path';
+import { FetchHttpClient, FileSystem, Path } from '@effect/platform';
+import { BunFileSystem, BunPath } from '@effect/platform-bun';
import { withHttpServer } from 'test/__utils__/http-server';
import { getTerminalCapabilities, TerminalUI } from 'src/services/terminal-ui';
import { UpgradeBinary, UpgradeBinaryError } from 'src/services/upgrade-binary';
@@ -56,6 +53,8 @@ const NodeOsTest = Layer.succeed(
})
);
+const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
+
const makeUpgradeEffect = (
configEntries: ReadonlyArray<[string, string]>,
options?: {
@@ -230,6 +229,15 @@ describe('UpgradeBinary', () => {
vi.stubGlobal('Bun', { which: vi.fn(() => null) });
return Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDir = yield* fs.makeTempDirectoryScoped({
+ prefix: 'composio-upgrade-current-',
+ });
+ const fakeExecPath = path.join(installDir, 'composio');
+ yield* fs.writeFileString(path.join(installDir, 'release-tag.txt'), '@composio/[email protected]\n');
+ vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
+
const apiBaseUrl = yield* scopedHttpServer((_req, res) => {
res.writeHead(200, { 'content-type': 'application/json' });
res.end(
@@ -267,13 +275,22 @@ describe('UpgradeBinary', () => {
]);
expect(result).toBeUndefined();
- }).pipe(Effect.ensuring(restoreStubsAndMocks));
+ }).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));
});
it.scoped('ignores prereleases when checking the stable channel', () => {
vi.stubGlobal('Bun', { which: vi.fn(() => null) });
return Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDir = yield* fs.makeTempDirectoryScoped({
+ prefix: 'composio-upgrade-current-',
+ });
+ const fakeExecPath = path.join(installDir, 'composio');
+ yield* fs.writeFileString(path.join(installDir, 'release-tag.txt'), '@composio/[email protected]\n');
+ vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
+
const apiBaseUrl = yield* scopedHttpServer((_req, res) => {
res.writeHead(200, { 'content-type': 'application/json' });
res.end(
@@ -311,17 +328,25 @@ describe('UpgradeBinary', () => {
]);
expect(result).toBeUndefined();
- }).pipe(Effect.ensuring(restoreStubsAndMocks));
+ }).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));
});
it.scoped('selects the latest prerelease when beta upgrades are requested', () => {
- const installDir = mkdtempSync(path.join(tmpdir(), 'composio-beta-select-'));
- const fakeExecPath = path.join(installDir, 'composio');
- writeFileSync(path.join(installDir, 'release-tag.txt'), '@composio/[email protected]\n');
vi.stubGlobal('Bun', { which: vi.fn(() => null) });
- const execPathSpy = vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
return Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDir = yield* fs.makeTempDirectoryScoped({
+ prefix: 'composio-beta-select-',
+ });
+ const fakeExecPath = path.join(installDir, 'composio');
+ yield* fs.writeFileString(
+ path.join(installDir, 'release-tag.txt'),
+ '@composio/[email protected]\n'
+ );
+ vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
+
const apiBaseUrl = yield* scopedHttpServer((_req, res) => {
res.writeHead(200, { 'content-type': 'application/json' });
res.end(
@@ -378,48 +403,51 @@ describe('UpgradeBinary', () => {
}
expect(error.message).toBe('Failed to download binary: composio-darwin-aarch64.zip');
expect(String(error.cause)).toContain('beta-3.zip');
- }).pipe(
- Effect.ensuring(Effect.sync(() => execPathSpy.mockRestore())),
- Effect.ensuring(restoreStubsAndMocks)
- );
+ }).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));
});
- it.effect('copies local-tool bundled binary assets during local-target upgrades', () => {
- const installDir = mkdtempSync(path.join(tmpdir(), 'composio-local-tool-upgrade-target-'));
- const sourceDir = mkdtempSync(path.join(tmpdir(), 'composio-local-tool-upgrade-source-'));
- const fakeExecPath = path.join(installDir, 'composio');
- const sourceBinaryPath = path.join(sourceDir, 'composio');
- const sourceLocalToolPath = path.join(
- sourceDir,
- 'local-tools-binaries',
- 'beeper-imessage',
- 'darwin-arm64',
- 'imessage-cli'
- );
- const installedLocalToolPath = path.join(
- installDir,
- 'local-tools-binaries',
- 'beeper-imessage',
- 'darwin-arm64',
- 'imessage-cli'
- );
-
- writeFileSync(fakeExecPath, 'old-binary');
- writeFileSync(sourceBinaryPath, 'new-binary');
- mkdirSync(path.dirname(sourceLocalToolPath), { recursive: true });
- writeFileSync(sourceLocalToolPath, 'imessage-sidecar');
-
+ it.scoped('copies local-tool bundled binary assets during local-target upgrades', () => {
vi.stubGlobal('Bun', { which: vi.fn(() => null) });
- const execPathSpy = vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
return Effect.gen(function* () {
- const companionRelativePaths = yield* collectExpectedRunCompanionAssetRelativePaths(
- sourceDir
- ).pipe(Effect.provide(Layer.mergeAll(BunFileSystem.layer, Path.layer)));
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDir = yield* fs.makeTempDirectoryScoped({
+ prefix: 'composio-local-tool-upgrade-target-',
+ });
+ const sourceDir = yield* fs.makeTempDirectoryScoped({
+ prefix: 'composio-local-tool-upgrade-source-',
+ });
+ const fakeExecPath = path.join(installDir, 'composio');
+ const sourceBinaryPath = path.join(sourceDir, 'composio');
+ const sourceLocalToolPath = path.join(
+ sourceDir,
+ 'local-tools-binaries',
+ 'beeper-imessage',
+ 'darwin-arm64',
+ 'imessage-cli'
+ );
+ const installedLocalToolPath = path.join(
+ installDir,
+ 'local-tools-binaries',
+ 'beeper-imessage',
+ 'darwin-arm64',
+ 'imessage-cli'
+ );
+
+ yield* fs.writeFileString(fakeExecPath, 'old-binary');
+ yield* fs.writeFileString(sourceBinaryPath, 'new-binary');
+ yield* fs.makeDirectory(path.dirname(sourceLocalToolPath), { recursive: true });
+ yield* fs.writeFileString(sourceLocalToolPath, 'imessage-sidecar');
+
+ vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
+
+ const companionRelativePaths =
+ yield* collectExpectedRunCompanionAssetRelativePaths(sourceDir);
for (const relativePath of companionRelativePaths) {
const companionPath = path.join(sourceDir, relativePath);
- mkdirSync(path.dirname(companionPath), { recursive: true });
- writeFileSync(companionPath, 'support-file');
+ yield* fs.makeDirectory(path.dirname(companionPath), { recursive: true });
+ yield* fs.writeFileString(companionPath, 'support-file');
}
const result = yield* runUpgradeSuccess([
@@ -427,23 +455,28 @@ describe('UpgradeBinary', () => {
]);
expect(result).toBeUndefined();
- expect(readFileSync(fakeExecPath, 'utf8')).toBe('new-binary');
- expect(existsSync(installedLocalToolPath)).toBe(true);
- expect(readFileSync(installedLocalToolPath, 'utf8')).toBe('imessage-sidecar');
- }).pipe(
- Effect.ensuring(Effect.sync(() => execPathSpy.mockRestore())),
- Effect.ensuring(restoreStubsAndMocks)
- );
+ expect(yield* fs.readFileString(fakeExecPath)).toBe('new-binary');
+ expect(yield* fs.exists(installedLocalToolPath)).toBe(true);
+ expect(yield* fs.readFileString(installedLocalToolPath)).toBe('imessage-sidecar');
+ }).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));
});
it.scoped('uses the installed beta release tag when comparing beta updates', () => {
- const installDir = mkdtempSync(path.join(tmpdir(), 'composio-beta-upgrade-'));
- const fakeExecPath = path.join(installDir, 'composio');
- writeFileSync(path.join(installDir, 'release-tag.txt'), '@composio/[email protected]\n');
vi.stubGlobal('Bun', { which: vi.fn(() => null) });
- const execPathSpy = vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
return Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDir = yield* fs.makeTempDirectoryScoped({
+ prefix: 'composio-beta-upgrade-',
+ });
+ const fakeExecPath = path.join(installDir, 'composio');
+ yield* fs.writeFileString(
+ path.join(installDir, 'release-tag.txt'),
+ '@composio/[email protected]\n'
+ );
+ vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
+
const apiBaseUrl = yield* scopedHttpServer((_req, res) => {
res.writeHead(200, { 'content-type': 'application/json' });
res.end(
@@ -478,9 +511,6 @@ describe('UpgradeBinary', () => {
}
expect(error.message).toBe('Failed to download binary: composio-darwin-aarch64.zip');
expect(String(error.cause)).toContain('beta-3.zip');
- }).pipe(
- Effect.ensuring(Effect.sync(() => execPathSpy.mockRestore())),
- Effect.ensuring(restoreStubsAndMocks)
- );
+ }).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));
});
});
diff --git a/ts/packages/cli/test/src/utils/cli-release-version.test.ts b/ts/packages/cli/test/src/utils/cli-release-version.test.ts
new file mode 100644
index 000000000..703e34923
--- /dev/null
+++ b/ts/packages/cli/test/src/utils/cli-release-version.test.ts
@@ -0,0 +1,21 @@
+import { describe, expect, it } from '@effect/vitest';
+import cliPackageJson from '../../../package.json' with { type: 'json' };
+import {
+ buildCliReleaseVersionDefineArgs,
+ extractCliReleaseVersion,
+} from 'src/utils/cli-release-version';
+
+describe('CLI release version authority', () => {
+ it('uses a non-release development sentinel', () => {
+ expect(cliPackageJson.version).toBe('0.0.0-development');
+ });
+
+ it('derives the exact GitHub release version', () => {
+ expect(extractCliReleaseVersion('@composio/[email protected]')).toBe('0.2.33-beta.322');
+ expect(extractCliReleaseVersion('@composio/[email protected]')).toBeUndefined();
+ expect(buildCliReleaseVersionDefineArgs('@composio/[email protected]')).toEqual([
+ '--define',
+ '__COMPOSIO_CLI_RELEASE_VERSION__="0.2.33-beta.322"',
+ ]);
+ });
+});