@devries-cameron20 / composio-1 / commits / 33b5a2a60
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.

refactor(cli): use Effect platform for skill installs

Replace direct Node filesystem and path access throughout the touched installer paths and tests. Preserve cleanup and replacement guarantees with focused lifecycle coverage.

jkomyno committed Jul 14, 2026 at 19:08 UTC 33b5a2a60a7c59b090314a251641b8715455a52a
6 files changed +280 -121
ts/packages/cli/src/cli-main.ts
+2 -2
@@ -3,7 +3,7 @@ import { Cause, Console, Effect, Exit, HashMap, Layer, Logger, Option } from 'ef
3 import { captureErrors, prettyPrintFromCapturedErrors } from 'effect-errors/index';
4 import { CliConfig, CommandDescriptor, HelpDoc, Usage, ValidationError } from '@effect/cli';
5 import { FetchHttpClient } from '@effect/platform';
6 -import { BunContext, BunRuntime, BunFileSystem } from '@effect/platform-bun';
6 +import { BunContext, BunRuntime, BunFileSystem, BunPath } from '@effect/platform-bun';
7 import type { Teardown } from '@effect/platform/Runtime';
8 import { buildRootCommand, runWithConfig } from 'src/commands';
9 import { matchCommandFromArgv, getCommandHelpText } from 'src/commands/root-help';
@@ -97,7 +97,7 @@ export const ProjectContextLive = Layer.provide(
97
98 export const SetupSkillInstallerLive = Layer.provide(
99 SetupSkillInstaller.Default,
100 - Layer.mergeAll(BunFileSystem.layer, NodeOs.Default)
100 + Layer.mergeAll(BunFileSystem.layer, BunPath.layer, NodeOs.Default)
101 ) satisfies RequiredLayer;
102
103 const layers = Layer.mergeAll(
ts/packages/cli/src/effects/install-skill.ts
+32 -53
@@ -1,7 +1,5 @@
1 -import * as fs from 'node:fs';
2 -import * as path from 'node:path';
1 import { Effect, Config, Option } from 'effect';
4 -import { HttpClient } from '@effect/platform';
2 +import { FileSystem, HttpClient, Path } from '@effect/platform';
3 import { NodeOs } from 'src/services/node-os';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 import { GITHUB_CONFIG } from 'src/effects/github-config';
@@ -27,6 +25,12 @@ const SKILL_TARGET_LABELS: Record<SkillInstallTarget, string> = {
25 openclaw: 'OpenClaw',
26 };
27
28 +const SKILL_TARGET_DIRECTORIES: Record<SkillInstallTarget, ReadonlyArray<string>> = {
29 + claude: ['.claude', 'skills'],
30 + codex: ['.codex', 'skills'],
31 + openclaw: ['.openclaw', 'skills'],
32 +};
33 +
34 type GitHubConfig = GitHubRepoConfig & {
35 TAG: Option.Option<string>;
36 ACCESS_TOKEN: Option.Option<string>;
@@ -50,31 +54,15 @@ export const resolveInstalledSkillName = (skillName?: string): string => {
54
55 export const resolveTargetSkillPath = ({
56 home,
57 + path,
58 skillName,
59 target,
60 }: {
61 home: string;
62 + path: Path.Path;
63 skillName: string;
64 target: SkillInstallTarget;
59 -}): string => {
60 - switch (target) {
61 - case 'claude':
62 - return path.join(home, '.claude', 'skills', skillName);
63 - case 'codex':
64 - return path.join(home, '.codex', 'skills', skillName);
65 - case 'openclaw':
66 - return path.join(home, '.openclaw', 'skills', skillName);
67 - }
68 -};
69 -
70 -export const readInstalledSkillReleaseTag = (skillDir: string): string | undefined => {
71 - try {
72 - const value = fs.readFileSync(path.join(skillDir, SKILL_RELEASE_TAG_FILENAME), 'utf8').trim();
73 - return value || undefined;
74 - } catch {
75 - return undefined;
76 - }
77 -};
65 +}): string => path.join(home, ...SKILL_TARGET_DIRECTORIES[target], skillName);
66
67 const resolveTargetLabel = (target: SkillInstallTarget): string => SKILL_TARGET_LABELS[target];
68
@@ -135,6 +123,8 @@ export const installSkill = (options?: {
123 Effect.gen(function* () {
124 const os = yield* NodeOs;
125 const ui = yield* TerminalUI;
126 + const fs = yield* FileSystem.FileSystem;
127 + const path = yield* Path.Path;
128 const httpClient = yield* HttpClient.HttpClient;
129 const githubConfig = yield* Config.all(GITHUB_CONFIG);
130 const home = os.homedir;
@@ -142,7 +132,7 @@ export const installSkill = (options?: {
132 const skillName = resolveInstalledSkillName(options?.skillName);
133
134 const agentSkillDir = path.join(home, '.agents', 'skills', skillName);
145 - const targetSkillPath = resolveTargetSkillPath({ home, skillName, target });
135 + const targetSkillPath = resolveTargetSkillPath({ home, path, skillName, target });
136
137 const tag = yield* resolveSkillReleaseTag({
138 channel: options?.channel,
@@ -193,11 +183,11 @@ export const installSkill = (options?: {
183
184 // Extract to a temp dir, then move into place
185 const tmpDir = path.join(os.homedir, '.agents', '.tmp-skill-install');
196 - fs.mkdirSync(tmpDir, { recursive: true });
186
198 - try {
187 + yield* Effect.gen(function* () {
188 + yield* fs.makeDirectory(tmpDir, { recursive: true });
189 const zipPath = path.join(tmpDir, SKILL_ASSET_NAME);
200 - fs.writeFileSync(zipPath, new Uint8Array(zipData));
190 + yield* fs.writeFile(zipPath, new Uint8Array(zipData));
191
192 yield* Effect.tryPromise({
193 try: () => extractZip(zipPath, { dir: tmpDir }),
@@ -206,36 +196,25 @@ export const installSkill = (options?: {
196
197 // The zip contains composio-cli/ directory
198 const extractedDir = path.join(tmpDir, SKILL_NAME);
209 - if (!fs.existsSync(extractedDir)) {
199 + if (!(yield* fs.exists(extractedDir))) {
200 return yield* Effect.fail(new Error('Extracted skill directory not found'));
201 }
202
213 - // Remove old skill dir and move new one into place
214 - fs.rmSync(agentSkillDir, { recursive: true, force: true });
215 - fs.mkdirSync(path.dirname(agentSkillDir), { recursive: true });
216 - fs.cpSync(extractedDir, agentSkillDir, { recursive: true });
217 - fs.writeFileSync(path.join(agentSkillDir, SKILL_RELEASE_TAG_FILENAME), `${tag}\n`, 'utf8');
218 - } finally {
219 - fs.rmSync(tmpDir, { recursive: true, force: true });
220 - }
221 -
222 - // Create agent-specific symlink — always replace any existing entry.
223 - fs.mkdirSync(path.dirname(targetSkillPath), { recursive: true });
224 - try {
225 - const stat = fs.lstatSync(targetSkillPath);
226 - // Entry exists (symlink, broken symlink, or directory) — remove it
227 - if (stat.isSymbolicLink()) {
228 - fs.unlinkSync(targetSkillPath);
229 - } else if (stat.isDirectory()) {
230 - fs.rmSync(targetSkillPath, { recursive: true, force: true });
231 - } else {
232 - fs.unlinkSync(targetSkillPath);
233 - }
234 - } catch {
235 - // lstatSync throws if nothing exists at the path — that's fine
236 - }
237 - const relativeTarget = path.relative(path.dirname(targetSkillPath), agentSkillDir);
238 - fs.symlinkSync(relativeTarget, targetSkillPath);
203 + yield* Effect.gen(function* () {
204 + // Replace the canonical skill and agent target without interruption leaving either absent.
205 + yield* fs.remove(agentSkillDir, { recursive: true, force: true });
206 + yield* fs.makeDirectory(path.dirname(agentSkillDir), { recursive: true });
207 + yield* fs.copy(extractedDir, agentSkillDir, { overwrite: true });
208 + yield* fs.writeFileString(path.join(agentSkillDir, SKILL_RELEASE_TAG_FILENAME), `${tag}\n`);
209 +
210 + yield* fs.makeDirectory(path.dirname(targetSkillPath), { recursive: true });
211 + yield* fs.remove(targetSkillPath, { recursive: true, force: true });
212 + const relativeTarget = path.relative(path.dirname(targetSkillPath), agentSkillDir);
213 + yield* fs.symlink(relativeTarget, targetSkillPath);
214 + }).pipe(Effect.uninterruptible);
215 + }).pipe(
216 + Effect.ensuring(fs.remove(tmpDir, { recursive: true, force: true }).pipe(Effect.orDie))
217 + );
218
219 yield* ui.log.success(`Installed ${skillName} skill for ${resolveTargetLabel(target)}`);
220 });
ts/packages/cli/src/services/setup-skill-installer.ts
+16 -6
@@ -1,5 +1,4 @@
1 -import path from 'node:path';
2 -import { FileSystem } from '@effect/platform';
1 +import { FileSystem, Path } from '@effect/platform';
2 import { Effect } from 'effect';
3 import {
4 installSkill,
@@ -16,10 +15,15 @@ export const resolveSetupSkillReleaseTag = (
15 fallbackVersion = APP_VERSION
16 ): string => readInstalledReleaseTag(execPath) ?? `@composio/cli@${fallbackVersion}`;
17
19 -const checkClaudeSkillCurrent = (fs: FileSystem.FileSystem, home: string, releaseTag: string) =>
18 +const checkClaudeSkillCurrent = (
19 + fs: FileSystem.FileSystem,
20 + path: Path.Path,
21 + home: string,
22 + releaseTag: string
23 +) =>
24 Effect.gen(function* () {
25 const skillName = resolveInstalledSkillName();
22 - const target = resolveTargetSkillPath({ home, skillName, target: 'claude' });
26 + const target = resolveTargetSkillPath({ home, path, skillName, target: 'claude' });
27 const installedReleaseTag = yield* fs
28 .readFileString(path.join(target, SKILL_RELEASE_TAG_FILENAME), 'utf8')
29 .pipe(
@@ -34,15 +38,21 @@ const checkClaudeSkillCurrent = (fs: FileSystem.FileSystem, home: string, releas
38 });
39
40 export const isClaudeSkillCurrent = (home: string, releaseTag: string) =>
37 - Effect.flatMap(FileSystem.FileSystem, fs => checkClaudeSkillCurrent(fs, home, releaseTag));
41 + Effect.gen(function* () {
42 + const fs = yield* FileSystem.FileSystem;
43 + const path = yield* Path.Path;
44 + return yield* checkClaudeSkillCurrent(fs, path, home, releaseTag);
45 + });
46
47 export class SetupSkillInstaller extends Effect.Service<SetupSkillInstaller>()(
48 'services/SetupSkillInstaller',
49 {
50 effect: Effect.gen(function* () {
51 const fs = yield* FileSystem.FileSystem;
52 + const path = yield* Path.Path;
53 const os = yield* NodeOs;
45 - const isCurrent = (releaseTag: string) => checkClaudeSkillCurrent(fs, os.homedir, releaseTag);
54 + const isCurrent = (releaseTag: string) =>
55 + checkClaudeSkillCurrent(fs, path, os.homedir, releaseTag);
56
57 return {
58 isClaudeSkillReady: isCurrent(resolveSetupSkillReleaseTag()),
ts/packages/cli/test/__utils__/services/test-layer.ts
+7 -11
@@ -1,7 +1,6 @@
1 -import path from 'node:path';
1 import * as tempy from 'tempy';
2 import { CliApp, CliConfig } from '@effect/cli';
4 -import { Command, FetchHttpClient, FileSystem } from '@effect/platform';
3 +import { Command, FetchHttpClient, FileSystem, Path } from '@effect/platform';
4 import { BunFileSystem, BunContext, BunPath } from '@effect/platform-bun';
5 import {
6 ConfigProvider,
@@ -1317,14 +1316,10 @@ function setupFixtureFolder({ fixture, tempDir }: { fixture?: string; tempDir: s
1316 }
1317
1318 const fs = yield* FileSystem.FileSystem;
1319 + const path = yield* Path.Path;
1320
1321 - const realFixturePath = path.resolve(
1322 - new URL('.', import.meta.url).pathname,
1323 - '..',
1324 - '..',
1325 - '__fixtures__',
1326 - fixture
1327 - );
1321 + const fixtureRoot = yield* path.fromFileUrl(new URL('.', import.meta.url));
1322 + const realFixturePath = path.resolve(fixtureRoot, '..', '..', '__fixtures__', fixture);
1323 const tmpFixturesPath = path.join(tempDir, 'test', '__fixtures__', fixture);
1324
1325 yield* Effect.logDebug(`Using fixture at: ${tmpFixturesPath}`);
@@ -1360,10 +1355,10 @@ function setupFixtureFolder({ fixture, tempDir }: { fixture?: string; tempDir: s
1355
1356 // Break symlinks in node_modules to isolate test from real packages
1357 const nodeModulesPath = path.join(tmpFixturesPath, 'node_modules');
1363 - yield* breakSymlinksInNodeModules(fs, nodeModulesPath);
1358 + yield* breakSymlinksInNodeModules(fs, path, nodeModulesPath);
1359
1360 return tmpFixturesPath;
1366 - }).pipe(Effect.provide(BunFileSystem.layer));
1361 + }).pipe(Effect.provide(Layer.mergeAll(BunFileSystem.layer, BunPath.layer)));
1362 }
1363
1364 /**
@@ -1373,6 +1368,7 @@ function setupFixtureFolder({ fixture, tempDir }: { fixture?: string; tempDir: s
1368 */
1369 function breakSymlinksInNodeModules(
1370 fs: FileSystem.FileSystem,
1371 + path: Path.Path,
1372 nodeModulesPath: string
1373 ): Effect.Effect<void, never, never> {
1374 // Helper: break a symlink by replacing it with a copy of its target
ts/packages/cli/test/src/effects/install-skill.test.ts
+152 -2
@@ -1,15 +1,113 @@
1 import { describe, expect, it, vi } from '@effect/vitest';
2 -import { Config, ConfigProvider, Effect } from 'effect';
3 -import { FetchHttpClient, HttpClient } from '@effect/platform';
2 +import { Config, ConfigProvider, Effect, Exit, Layer } from 'effect';
3 +import { FetchHttpClient, FileSystem, HttpClient, Path } from '@effect/platform';
4 +import type * as PlatformError from '@effect/platform/Error';
5 +import { BunFileSystem, BunPath } from '@effect/platform-bun';
6 +import * as tempy from 'tempy';
7 import { withHttpServer } from 'test/__utils__/http-server';
8 +import { TerminalUITest } from 'test/__utils__/services/terminal-ui-test';
9 import {
10 inferSkillReleaseChannel,
11 + installSkill,
12 resolveInstalledSkillName,
13 resolveSkillReleaseTag,
14 resolveTargetSkillPath,
15 + SKILL_RELEASE_TAG_FILENAME,
16 type SkillReleaseChannel,
17 } from 'src/effects/install-skill';
18 import { GITHUB_CONFIG } from 'src/effects/github-config';
19 +import { defaultNodeOs, NodeOs } from 'src/services/node-os';
20 +
21 +const path = Effect.runSync(Effect.provide(Path.Path, Path.layer));
22 +const TEST_RELEASE_TAG = '@composio/cli@0.3.0-test';
23 +const TEST_SKILL_ZIP = Uint8Array.from(
24 + atob(
25 + 'UEsDBAoAAAAAAEGX7lwAAAAAAAAAAAAAAAANABwAY29tcG9zaW8tY2xpL1VUCQADeU5WanlOVmp1eAsAAQT1AQAABBQAAABQSwMECgAAAAAAQZfuXMXglUQPAAAADwAAABUAHABjb21wb3Npby1jbGkvU0tJTEwubWRVVAkAA3lOVmp5TlZqdXgLAAEE9QEAAAQUAAAAIyBjb21wb3Npby1jbGkKUEsBAh4DCgAAAAAAQZfuXAAAAAAAAAAAAAAAAA0AGAAAAAAAAAAQAO1BAAAAAGNvbXBvc2lvLWNsaS9VVAUAA3lOVmp1eAsAAQT1AQAABBQAAABQSwECHgMKAAAAAABBl+5cxeCVRA8AAAAPAAAAFQAYAAAAAAABAAAApIFHAAAAY29tcG9zaW8tY2xpL1NLSUxMLm1kVVQFAAN5TlZqdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAACAAIArgAAAKUAAAAAAA=='
26 + ),
27 + character => character.charCodeAt(0)
28 +);
29 +
30 +const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
31 +
32 +const makeInstallEffect = (home: string, apiBaseUrl: string) =>
33 + installSkill({ target: 'claude', releaseTag: TEST_RELEASE_TAG }).pipe(
34 + Effect.provide(
35 + Layer.mergeAll(
36 + TestPlatform,
37 + FetchHttpClient.layer,
38 + TerminalUITest,
39 + Layer.succeed(NodeOs, defaultNodeOs({ homedir: home }))
40 + )
41 + ),
42 + Effect.withConfigProvider(
43 + ConfigProvider.fromMap(
44 + new Map([
45 + ['GITHUB_API_BASE_URL', apiBaseUrl],
46 + ['GITHUB_OWNER', 'test-owner'],
47 + ['GITHUB_REPO', 'test-repo'],
48 + ])
49 + )
50 + ),
51 + Effect.scoped
52 + );
53 +
54 +const withSkillRelease = (skillZip: Uint8Array, run: (apiBaseUrl: string) => Promise<void>) =>
55 + withHttpServer((req, res) => {
56 + if (req.url === '/skill.zip') {
57 + res.writeHead(200, { 'content-type': 'application/zip' });
58 + res.end(skillZip);
59 + return;
60 + }
61 +
62 + res.writeHead(200, { 'content-type': 'application/json' });
63 + res.end(
64 + JSON.stringify({
65 + assets: [
66 + {
67 + name: 'composio-skill.zip',
68 + browser_download_url: `http://${req.headers.host}/skill.zip`,
69 + },
70 + ],
71 + })
72 + );
73 + }, run);
74 +
75 +type TargetSetup = (
76 + fs: FileSystem.FileSystem,
77 + path: Path.Path,
78 + home: string,
79 + target: string
80 +) => Effect.Effect<void, PlatformError.PlatformError>;
81 +
82 +const TARGET_SCENARIOS = [
83 + ['a missing', (() => Effect.void) satisfies TargetSetup],
84 + [
85 + 'an existing directory',
86 + ((fs, _path, _home, target) =>
87 + fs.makeDirectory(target, { recursive: true })) satisfies TargetSetup,
88 + ],
89 + [
90 + 'an existing symlink',
91 + ((fs, path, home, target) =>
92 + Effect.gen(function* () {
93 + const existingTarget = path.join(home, 'existing-skill');
94 + yield* fs.makeDirectory(existingTarget, { recursive: true });
95 + yield* fs.makeDirectory(path.dirname(target), { recursive: true });
96 + yield* fs.symlink(path.relative(path.dirname(target), existingTarget), target);
97 + })) satisfies TargetSetup,
98 + ],
99 + [
100 + 'a broken symlink',
101 + ((fs, path, home, target) =>
102 + Effect.gen(function* () {
103 + yield* fs.makeDirectory(path.dirname(target), { recursive: true });
104 + yield* fs.symlink(
105 + path.relative(path.dirname(target), path.join(home, 'missing-skill')),
106 + target
107 + );
108 + })) satisfies TargetSetup,
109 + ],
110 +] as const;
111
112 const makeResolveEffect = (
113 configEntries: ReadonlyArray<[string, string]>,
@@ -60,6 +158,7 @@ describe('install-skill', () => {
158 expect(
159 resolveTargetSkillPath({
160 home: '/tmp/test-home',
161 + path,
162 skillName: 'composio-cli',
163 target: 'claude',
164 })
@@ -67,6 +166,7 @@ describe('install-skill', () => {
166 expect(
167 resolveTargetSkillPath({
168 home: '/tmp/test-home',
169 + path,
170 skillName: 'composio-cli',
171 target: 'codex',
172 })
@@ -74,6 +174,7 @@ describe('install-skill', () => {
174 expect(
175 resolveTargetSkillPath({
176 home: '/tmp/test-home',
177 + path,
178 skillName: 'composio-cli',
179 target: 'openclaw',
180 })
@@ -90,6 +191,55 @@ describe('install-skill', () => {
191 expect(tag).toBe(releaseTag);
192 });
193
194 + it.each(TARGET_SCENARIOS)('installs over %s target', async (_description, prepareTarget) => {
195 + await withSkillRelease(TEST_SKILL_ZIP, async apiBaseUrl => {
196 + const home = tempy.temporaryDirectory();
197 + const target = path.join(home, '.claude', 'skills', 'composio-cli');
198 + const canonicalSkill = path.join(home, '.agents', 'skills', 'composio-cli');
199 +
200 + await Effect.gen(function* () {
201 + const fs = yield* FileSystem.FileSystem;
202 + const platformPath = yield* Path.Path;
203 + yield* prepareTarget(fs, platformPath, home, target);
204 + }).pipe(Effect.provide(TestPlatform), Effect.runPromise);
205 +
206 + await makeInstallEffect(home, apiBaseUrl).pipe(Effect.runPromise);
207 +
208 + await Effect.gen(function* () {
209 + const fs = yield* FileSystem.FileSystem;
210 + const platformPath = yield* Path.Path;
211 + expect(yield* fs.readFileString(platformPath.join(target, 'SKILL.md'))).toBe(
212 + '# composio-cli\n'
213 + );
214 + expect(
215 + yield* fs.readFileString(platformPath.join(canonicalSkill, SKILL_RELEASE_TAG_FILENAME))
216 + ).toBe(`${TEST_RELEASE_TAG}\n`);
217 + expect(yield* fs.readLink(target)).toBe(
218 + platformPath.relative(platformPath.dirname(target), canonicalSkill)
219 + );
220 + expect(yield* fs.exists(platformPath.join(home, '.agents', '.tmp-skill-install'))).toBe(
221 + false
222 + );
223 + }).pipe(Effect.provide(TestPlatform), Effect.runPromise);
224 + });
225 + });
226 +
227 + it('removes the temporary install directory after extraction fails', async () => {
228 + await withSkillRelease(new TextEncoder().encode('not a zip'), async apiBaseUrl => {
229 + const home = tempy.temporaryDirectory();
230 + const exit = await makeInstallEffect(home, apiBaseUrl).pipe(Effect.exit, Effect.runPromise);
231 +
232 + expect(Exit.isFailure(exit)).toBe(true);
233 + expect(
234 + await FileSystem.FileSystem.pipe(
235 + Effect.flatMap(fs => fs.exists(path.join(home, '.agents', '.tmp-skill-install'))),
236 + Effect.provide(TestPlatform),
237 + Effect.runPromise
238 + )
239 + ).toBe(false);
240 + });
241 + });
242 +
243 it('resolves the latest stable release when the stable channel is requested', async () => {
244 vi.stubGlobal('Bun', { which: vi.fn(() => null) });
245
ts/packages/cli/test/src/services/setup-skill-installer.test.ts
+71 -47
@@ -1,8 +1,7 @@
1 -import { mkdirSync, symlinkSync, writeFileSync } from 'node:fs';
2 -import path from 'node:path';
3 -import { BunFileSystem } from '@effect/platform-bun';
4 -import { Effect } from 'effect';
5 -import { describe, expect, it } from 'vitest';
1 +import { FileSystem, Path } from '@effect/platform';
2 +import { BunFileSystem, BunPath } from '@effect/platform-bun';
3 +import { describe, expect, layer } from '@effect/vitest';
4 +import { Effect, Layer } from 'effect';
5 import * as tempy from 'tempy';
6 import { SKILL_RELEASE_TAG_FILENAME } from 'src/effects/install-skill';
7 import {
@@ -10,59 +9,84 @@ import {
9 resolveSetupSkillReleaseTag,
10 } from 'src/services/setup-skill-installer';
11
13 -const runIsClaudeSkillCurrent = (home: string, releaseTag: string) =>
14 - isClaudeSkillCurrent(home, releaseTag).pipe(
15 - Effect.provide(BunFileSystem.layer),
16 - Effect.runPromise
17 - );
12 +const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
13
14 describe('SetupSkillInstaller', () => {
20 - it('uses the packaged CLI release tag', () => {
21 - const installDir = tempy.temporaryDirectory();
22 - const execPath = path.join(installDir, 'composio');
23 - writeFileSync(path.join(installDir, 'release-tag.txt'), '@composio/cli@0.2.20-beta.42\n');
15 + layer(TestPlatform)(it => {
16 + it.effect('uses the packaged CLI release tag', () =>
17 + Effect.gen(function* () {
18 + const fs = yield* FileSystem.FileSystem;
19 + const path = yield* Path.Path;
20 + const installDir = tempy.temporaryDirectory();
21 + const execPath = path.join(installDir, 'composio');
22 + yield* fs.writeFileString(
23 + path.join(installDir, 'release-tag.txt'),
24 + '@composio/cli@0.2.20-beta.42\n'
25 + );
26
25 - expect(resolveSetupSkillReleaseTag(execPath, '0.3.0')).toBe('@composio/cli@0.2.20-beta.42');
26 - });
27 + expect(resolveSetupSkillReleaseTag(execPath, '0.3.0')).toBe('@composio/cli@0.2.20-beta.42');
28 + })
29 + );
30
28 - it('falls back to the build version outside a packaged install', () => {
29 - const installDir = tempy.temporaryDirectory();
31 + it.effect('falls back to the build version outside a packaged install', () =>
32 + Effect.gen(function* () {
33 + const path = yield* Path.Path;
34 + const installDir = tempy.temporaryDirectory();
35
31 - expect(resolveSetupSkillReleaseTag(path.join(installDir, 'composio'), '0.3.0')).toBe(
32 - '@composio/cli@0.3.0'
36 + expect(resolveSetupSkillReleaseTag(path.join(installDir, 'composio'), '0.3.0')).toBe(
37 + '@composio/cli@0.3.0'
38 + );
39 + })
40 );
34 - });
41
36 - it('only accepts a Claude skill installed from the running CLI release', async () => {
37 - const home = tempy.temporaryDirectory();
38 - const target = path.join(home, '.claude', 'skills', 'composio-cli');
39 - const skillDir = path.join(home, '.agents', 'skills', 'composio-cli');
40 - mkdirSync(skillDir, { recursive: true });
41 - mkdirSync(path.dirname(target), { recursive: true });
42 - symlinkSync(path.relative(path.dirname(target), skillDir), target);
43 - writeFileSync(
44 - path.join(skillDir, SKILL_RELEASE_TAG_FILENAME),
45 - '@composio/cli@0.2.20-beta.42\n'
46 - );
47 - writeFileSync(path.join(skillDir, 'SKILL.md'), '# composio-cli\n');
42 + it.effect('only accepts a Claude skill installed from the running CLI release', () =>
43 + Effect.gen(function* () {
44 + const fs = yield* FileSystem.FileSystem;
45 + const path = yield* Path.Path;
46 + const home = tempy.temporaryDirectory();
47 + const target = path.join(home, '.claude', 'skills', 'composio-cli');
48 + const skillDir = path.join(home, '.agents', 'skills', 'composio-cli');
49 + yield* fs.makeDirectory(skillDir, { recursive: true });
50 + yield* fs.makeDirectory(path.dirname(target), { recursive: true });
51 + yield* fs.symlink(path.relative(path.dirname(target), skillDir), target);
52 + yield* fs.writeFileString(
53 + path.join(skillDir, SKILL_RELEASE_TAG_FILENAME),
54 + '@composio/cli@0.2.20-beta.42\n'
55 + );
56 + yield* fs.writeFileString(path.join(skillDir, 'SKILL.md'), '# composio-cli\n');
57
49 - expect(await runIsClaudeSkillCurrent(home, '@composio/cli@0.2.20-beta.42')).toBe(true);
50 - expect(await runIsClaudeSkillCurrent(home, '@composio/cli@0.2.20-beta.43')).toBe(false);
51 - });
58 + expect(yield* isClaudeSkillCurrent(home, '@composio/cli@0.2.20-beta.42')).toBe(true);
59 + expect(yield* isClaudeSkillCurrent(home, '@composio/cli@0.2.20-beta.43')).toBe(false);
60 + })
61 + );
62
53 - it('treats an unversioned existing Claude skill as stale', async () => {
54 - const home = tempy.temporaryDirectory();
55 - mkdirSync(path.join(home, '.claude', 'skills', 'composio-cli'), { recursive: true });
63 + it.effect('treats an unversioned existing Claude skill as stale', () =>
64 + Effect.gen(function* () {
65 + const fs = yield* FileSystem.FileSystem;
66 + const path = yield* Path.Path;
67 + const home = tempy.temporaryDirectory();
68 + yield* fs.makeDirectory(path.join(home, '.claude', 'skills', 'composio-cli'), {
69 + recursive: true,
70 + });
71
57 - expect(await runIsClaudeSkillCurrent(home, '@composio/cli@0.3.0')).toBe(false);
58 - });
72 + expect(yield* isClaudeSkillCurrent(home, '@composio/cli@0.3.0')).toBe(false);
73 + })
74 + );
75
60 - it('treats a release marker without a readable skill as stale', async () => {
61 - const home = tempy.temporaryDirectory();
62 - const target = path.join(home, '.claude', 'skills', 'composio-cli');
63 - mkdirSync(target, { recursive: true });
64 - writeFileSync(path.join(target, SKILL_RELEASE_TAG_FILENAME), '@composio/cli@0.3.0\n');
76 + it.effect('treats a release marker without a readable skill as stale', () =>
77 + Effect.gen(function* () {
78 + const fs = yield* FileSystem.FileSystem;
79 + const path = yield* Path.Path;
80 + const home = tempy.temporaryDirectory();
81 + const target = path.join(home, '.claude', 'skills', 'composio-cli');
82 + yield* fs.makeDirectory(target, { recursive: true });
83 + yield* fs.writeFileString(
84 + path.join(target, SKILL_RELEASE_TAG_FILENAME),
85 + '@composio/cli@0.3.0\n'
86 + );
87
66 - expect(await runIsClaudeSkillCurrent(home, '@composio/cli@0.3.0')).toBe(false);
88 + expect(yield* isClaudeSkillCurrent(home, '@composio/cli@0.3.0')).toBe(false);
89 + })
90 + );
91 });
92 });