@devries-cameron20 / composio Mirror · read-only / commits / 82341643a
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 21, 18:30 UTC

feat(cli): add plugin uninstall flow

Kshitij Jhunjhunwala committed Jul 14, 2026 at 15:51 UTC 82341643a424a2617ae418e0da8897a2c0e28dad
9 files changed +415 -18
ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+25 -4
@@ -31,10 +31,12 @@ composio setup --target ${host} --yes
31 cp /tmp/host-state/commands.log first-run.log
32 : > /tmp/host-state/commands.log
33 composio setup --target ${host} --yes
34 +composio setup --uninstall --target ${host} --yes
35 +composio setup --uninstall --target ${host} --yes
36 ${
37 host === 'claude'
36 - ? `test -L /tmp/.claude/skills/composio-cli
37 -test -r /tmp/.claude/skills/composio-cli/SKILL.md`
38 + ? `test ! -L /tmp/.claude/skills/composio-cli
39 +test ! -e /tmp/.agents/skills/composio-cli`
40 : ''
41 }
42 cp /tmp/host-state/commands.log second-run.log
@@ -49,6 +51,7 @@ e2e(import.meta.url, {
51 let codex: E2ETestResultWithFiles<'first-run.log' | 'second-run.log'>;
52 let unavailable: E2ETestResult;
53 let skippedUnavailable: E2ETestResult;
54 + let skippedUnavailableUninstall: E2ETestResult;
55
56 beforeAll(async () => {
57 // The shared E2E runner derives container names from Date.now(), so keep
@@ -63,6 +66,9 @@ e2e(import.meta.url, {
66 });
67 unavailable = await runCmd('composio setup --target auto --yes');
68 skippedUnavailable = await runCmd('composio setup --target auto --yes --if-present');
69 + skippedUnavailableUninstall = await runCmd(
70 + 'composio setup --uninstall --target auto --yes --if-present'
71 + );
72 }, TIMEOUTS.FIXTURE);
73
74 describe.each([
@@ -73,6 +79,7 @@ e2e(import.meta.url, {
79 'claude plugin marketplace add https://github.com/ComposioHQ/composio-plugin-cc.git --scope user',
80 installCommand: 'claude plugin install composio@composio --scope user',
81 additionalMutationCommands: ['claude plugin enable composio@composio --scope user'],
82 + uninstallCommand: 'claude plugin uninstall composio@composio --scope user --yes',
83 },
84 {
85 host: 'codex' as const,
@@ -81,11 +88,18 @@ e2e(import.meta.url, {
88 'codex plugin marketplace add https://github.com/ComposioHQ/composio-plugin-openai.git --json',
89 installCommand: 'codex plugin add composio@composio --json',
90 additionalMutationCommands: [],
91 + uninstallCommand: 'codex plugin remove composio@composio --json',
92 },
93 ])(
94 '$host setup',
87 - ({ result, marketplaceCommand, installCommand, additionalMutationCommands }) => {
88 - it('configures the plugin on the first run and is idempotent', () => {
95 + ({
96 + result,
97 + marketplaceCommand,
98 + installCommand,
99 + additionalMutationCommands,
100 + uninstallCommand,
101 + }) => {
102 + it('installs once and uninstalls once with idempotent reruns', () => {
103 const execution = result();
104 expect(execution.exitCode).toBe(0);
105 expect(execution.stdout).toBe('');
@@ -108,6 +122,7 @@ e2e(import.meta.url, {
122 mutationCommands.some(mutation => mutation === command)
123 )
124 ).toEqual([]);
125 + expect(secondRunCommands.filter(command => command === uninstallCommand)).toHaveLength(1);
126 });
127 }
128 );
@@ -124,6 +139,12 @@ e2e(import.meta.url, {
139 expect(skippedUnavailable.stdout).toBe('');
140 expect(skippedUnavailable.stderr).toBe('');
141 });
142 +
143 + it('can skip uninstall cleanly when no host is present', () => {
144 + expect(skippedUnavailableUninstall.exitCode).toBe(0);
145 + expect(skippedUnavailableUninstall.stdout).toBe('');
146 + expect(skippedUnavailableUninstall.stderr).toBe('');
147 + });
148 });
149 },
150 });
ts/e2e-tests/cli/setup-plugins/fixtures/fake-agent-host.sh
+6
@@ -35,6 +35,9 @@ case "$host:$command" in
35 "claude:plugin enable composio@composio --scope user")
36 touch "$state_dir/claude-plugin"
37 ;;
38 + "claude:plugin uninstall composio@composio --scope user --yes")
39 + rm -f "$state_dir/claude-plugin"
40 + ;;
41 "codex:--version")
42 printf '%s\n' 'codex-cli 0.144.1'
43 ;;
@@ -58,6 +61,9 @@ case "$host:$command" in
61 "codex:plugin add composio@composio --json")
62 touch "$state_dir/codex-plugin"
63 ;;
64 + "codex:plugin remove composio@composio --json")
65 + rm -f "$state_dir/codex-plugin"
66 + ;;
67 *)
68 printf 'Unexpected fake host command: %s %s\n' "$host" "$command" >&2
69 exit 64
ts/packages/cli/src/commands/root-help.ts
+8 -3
@@ -162,7 +162,7 @@ const GENERATE_COMMAND: TaggedValue<CompactCommand> = tagged({
162 // ── Account commands ───────────────────────────────────────────────────
163
164 const ACCOUNT_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
165 - tagged({ name: 'setup', description: 'Install agent plugins' }),
165 + tagged({ name: 'setup', description: 'Install or uninstall agent plugins' }),
166 tagged({ name: 'login', description: 'Log in to Composio' }),
167 tagged({ name: 'logout', description: 'Log out from Composio' }),
168 tagged({ name: 'whoami', description: 'Show current account info' }),
@@ -874,16 +874,21 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
874 description: 'Display your account information.',
875 },
876 setup: {
877 - usage: 'composio setup [--target auto|claude|codex|all] [--yes] [--if-present]',
878 - description: 'Install plugins for supported agent hosts.',
877 + usage: 'composio setup [--target auto|claude|codex|all] [--uninstall] [--yes] [--if-present]',
878 + description: 'Install or uninstall plugins for supported agent hosts.',
879 examples: [
880 'composio setup',
881 'composio setup --target auto --yes',
882 + 'composio setup --uninstall --target auto --yes',
883 'composio setup --target all',
884 ],
885 options: [
886 { name: '--target <target>', description: 'auto, claude, codex, or all' },
887 { name: '-y, --yes', description: 'Accept setup changes without prompting' },
888 + {
889 + name: '--uninstall',
890 + description: 'Uninstall Composio plugins instead of installing them',
891 + },
892 {
893 name: '--if-present',
894 description: 'Exit successfully when automatic detection finds no supported host',
ts/packages/cli/src/commands/setup.cmd.ts
+59 -7
@@ -7,6 +7,7 @@ import {
7 isSetupPluginReady,
8 isSetupReady,
9 SETUP_TARGETS,
10 + uninstallSetupTargets,
11 type AgentHost,
12 type SetupTarget,
13 } from 'src/services/setup';
@@ -29,6 +30,11 @@ const ifPresent = Options.boolean('if-present').pipe(
30 Options.withDescription('Exit successfully when automatic detection finds no supported host')
31 );
32
33 +const uninstall = Options.boolean('uninstall').pipe(
34 + Options.withDefault(false),
35 + Options.withDescription('Uninstall Composio plugins instead of installing them')
36 +);
37 +
38 const TARGET_LABELS: Readonly<Record<AgentHost, string>> = {
39 claude: 'Claude Code',
40 codex: 'Codex',
@@ -39,11 +45,11 @@ const formatTargets = (targets: ReadonlyArray<AgentHost>): string =>
45
46 const setupBaseCmd = Command.make(
47 'setup',
42 - { target, yes, ifPresent },
43 - ({ target, yes, ifPresent }) =>
48 + { target, yes, ifPresent, uninstall },
49 + ({ target, yes, ifPresent, uninstall }) =>
50 Effect.gen(function* () {
51 const ui = yield* TerminalUI;
46 - yield* ui.intro('composio setup');
52 + yield* ui.intro(uninstall ? 'composio setup --uninstall' : 'composio setup');
53
54 const detections = yield* detectSetupTargets(target);
55 const detected = detections.filter(result => result.available).map(result => result.target);
@@ -61,15 +67,61 @@ const setupBaseCmd = Command.make(
67 if (!ifPresent || target !== 'auto') {
68 return yield* Effect.fail(
69 new Error(
64 - 'No supported agent host was detected. Install Claude Code or Codex, then rerun `composio setup`.'
70 + `No supported agent host was detected. Install Claude Code or Codex, then rerun \`composio setup${uninstall ? ' --uninstall' : ''}\`.`
71 )
72 );
73 }
68 - yield* ui.outro('No supported agent host detected; plugin setup skipped.');
74 + yield* ui.outro(
75 + `No supported agent host detected; plugin ${uninstall ? 'uninstall' : 'setup'} skipped.`
76 + );
77 + return;
78 + }
79 +
80 + const inspected = yield* inspectSetupTargets(detections, {
81 + allowMarketplaceConflict: uninstall,
82 + });
83 + if (uninstall) {
84 + const installed = inspected.filter(status => status.plugin_installed);
85 + const notInstalled = inspected.filter(status => !status.plugin_installed);
86 +
87 + for (const status of installed) {
88 + yield* ui.log.success(
89 + `The Composio plugin for ${TARGET_LABELS[status.target]} is installed.`
90 + );
91 + }
92 + for (const status of notInstalled) {
93 + yield* ui.log.info(
94 + `The Composio plugin for ${TARGET_LABELS[status.target]} is not installed.`
95 + );
96 + }
97 +
98 + if (!yes && installed.length > 0) {
99 + if (!isInteractiveTerminal()) {
100 + return yield* Effect.fail(
101 + new Error('Non-interactive uninstall requires `--yes` to approve local changes.')
102 + );
103 + }
104 + const confirmed = yield* ui.confirm(
105 + `Uninstall the Composio plugin for ${formatTargets(installed.map(status => status.target))}?`,
106 + { defaultValue: false }
107 + );
108 + if (!confirmed) {
109 + yield* ui.outro('Uninstall cancelled.');
110 + return;
111 + }
112 + }
113 +
114 + const results = yield* uninstallSetupTargets(inspected);
115 + for (const result of results) {
116 + if (!result.plugin_changed) continue;
117 + yield* ui.log.success(
118 + `Successfully uninstalled the Composio plugin for ${TARGET_LABELS[result.target]}.`
119 + );
120 + }
121 + yield* ui.outro('Composio plugin uninstall complete.');
122 return;
123 }
124
72 - const inspected = yield* inspectSetupTargets(detections);
125 for (const status of inspected.filter(isSetupPluginReady)) {
126 yield* ui.log.success(
127 `The Composio plugin for ${TARGET_LABELS[status.target]} is already installed and enabled.`
@@ -116,5 +168,5 @@ const setupBaseCmd = Command.make(
168 );
169
170 export const setupCmd = setupBaseCmd.pipe(
119 - Command.withDescription('Install Composio plugins for supported agent hosts.')
171 + Command.withDescription('Install or uninstall Composio plugins for supported agent hosts.')
172 );
ts/packages/cli/src/services/setup-skill-installer.ts
+38
@@ -44,6 +44,43 @@ export const isClaudeSkillCurrent = (home: string, releaseTag: string) =>
44 return yield* checkClaudeSkillCurrent(fs, path, home, releaseTag);
45 });
46
47 +const isLinkedTo = (fs: FileSystem.FileSystem, path: Path.Path, source: string, target: string) =>
48 + fs.readLink(source).pipe(
49 + Effect.map(link => path.resolve(path.dirname(source), link) === target),
50 + Effect.catchAll(() => Effect.succeed(false))
51 + );
52 +
53 +export const removeManagedClaudeSkill = (home: string) =>
54 + Effect.gen(function* () {
55 + const fs = yield* FileSystem.FileSystem;
56 + const path = yield* Path.Path;
57 + const skillName = resolveInstalledSkillName();
58 + const canonicalSkill = path.join(home, '.agents', 'skills', skillName);
59 + const claudeSkill = resolveTargetSkillPath({ home, path, skillName, target: 'claude' });
60 +
61 + let changed = false;
62 + if (yield* isLinkedTo(fs, path, claudeSkill, canonicalSkill)) {
63 + yield* fs.remove(claudeSkill, { recursive: true, force: true });
64 + changed = true;
65 + }
66 +
67 + const isManaged = yield* fs.exists(path.join(canonicalSkill, SKILL_RELEASE_TAG_FILENAME));
68 + if (!isManaged) return changed;
69 +
70 + const otherTargets = (['codex', 'openclaw'] as const).map(target =>
71 + resolveTargetSkillPath({ home, path, skillName, target })
72 + );
73 + const references = yield* Effect.all(
74 + otherTargets.map(target => isLinkedTo(fs, path, target, canonicalSkill))
75 + );
76 + const stillReferenced = references.some(Boolean);
77 + if (!stillReferenced) {
78 + yield* fs.remove(canonicalSkill, { recursive: true, force: true });
79 + changed = true;
80 + }
81 + return changed;
82 + }).pipe(Effect.uninterruptible);
83 +
84 export class SetupSkillInstaller extends Effect.Service<SetupSkillInstaller>()(
85 'services/SetupSkillInstaller',
86 {
@@ -67,6 +104,7 @@ export class SetupSkillInstaller extends Effect.Service<SetupSkillInstaller>()(
104 });
105 return true;
106 }),
107 + removeClaudeSkill: removeManagedClaudeSkill(os.homedir),
108 };
109 }),
110 dependencies: [],
ts/packages/cli/src/services/setup.ts
+77 -4
@@ -44,6 +44,7 @@ interface SetupTargetAdapter {
44 readonly marketplaceAddArgs: ReadonlyArray<string>;
45 readonly pluginInstallArgs: ReadonlyArray<string>;
46 readonly pluginEnableArgs: ReadonlyArray<string>;
47 + readonly pluginUninstallArgs: ReadonlyArray<string>;
48 readonly marketplaceRecordsKey?: string;
49 readonly pluginRecordsKey?: string;
50 readonly pluginScope?: string;
@@ -72,6 +73,14 @@ const ADAPTERS: Readonly<Record<AgentHost, SetupTargetAdapter>> = {
73 ],
74 pluginInstallArgs: ['plugin', 'install', CLAUDE_PLUGIN_MARKETPLACE.plugin, '--scope', 'user'],
75 pluginEnableArgs: ['plugin', 'enable', CLAUDE_PLUGIN_MARKETPLACE.plugin, '--scope', 'user'],
76 + pluginUninstallArgs: [
77 + 'plugin',
78 + 'uninstall',
79 + CLAUDE_PLUGIN_MARKETPLACE.plugin,
80 + '--scope',
81 + 'user',
82 + '--yes',
83 + ],
84 pluginScope: 'user',
85 marketplaceRemoveCommand: 'claude plugin marketplace remove composio --scope user',
86 skillSource: 'standalone',
@@ -86,6 +95,7 @@ const ADAPTERS: Readonly<Record<AgentHost, SetupTargetAdapter>> = {
95 pluginInstallArgs: ['plugin', 'add', CODEX_PLUGIN_MARKETPLACE.plugin, '--json'],
96 // Codex has no separate enable command. Re-adding is its native install/repair path.
97 pluginEnableArgs: ['plugin', 'add', CODEX_PLUGIN_MARKETPLACE.plugin, '--json'],
98 + pluginUninstallArgs: ['plugin', 'remove', CODEX_PLUGIN_MARKETPLACE.plugin, '--json'],
99 marketplaceRecordsKey: 'marketplaces',
100 pluginRecordsKey: 'installed',
101 marketplaceRemoveCommand: 'codex plugin marketplace remove composio --json',
@@ -416,6 +426,46 @@ const installAdapter = (adapter: SetupTargetAdapter, initial: InspectedSetupTarg
426 } satisfies SetupTargetResult;
427 });
428
429 +const uninstallAdapter = (adapter: SetupTargetAdapter, initial: InspectedSetupTarget) =>
430 + Effect.gen(function* () {
431 + let pluginChanged = false;
432 + if (initial.plugin_installed) {
433 + yield* runRequired(
434 + adapter,
435 + adapter.pluginUninstallArgs,
436 + `Uninstalling the ${adapter.target} plugin`
437 + );
438 + pluginChanged = true;
439 + }
440 +
441 + const skillInstaller = yield* SetupSkillInstaller;
442 + let skillChanged = false;
443 + if (adapter.skillSource === 'standalone') {
444 + skillChanged = yield* skillInstaller.removeClaudeSkill;
445 + }
446 +
447 + const final = yield* inspectAdapter(adapter);
448 + if (final.plugin_installed || (adapter.skillSource === 'standalone' && final.cli_skill_ready)) {
449 + return yield* Effect.fail(
450 + new Error(
451 + `Uninstall commands completed, but ${adapter.target} still reports Composio as installed. Rerun \`composio setup --uninstall --target ${adapter.target}\` or inspect the native ${adapter.target} plugin configuration.`
452 + )
453 + );
454 + }
455 +
456 + return {
457 + target: adapter.target,
458 + available: final.available,
459 + marketplace_configured: final.marketplace_configured,
460 + plugin_installed: final.plugin_installed,
461 + plugin_enabled: final.plugin_enabled,
462 + cli_skill_ready: final.cli_skill_ready,
463 + changed: pluginChanged || skillChanged,
464 + plugin_changed: pluginChanged,
465 + skill_changed: skillChanged,
466 + } satisfies SetupTargetResult;
467 + });
468 +
469 const FIXED_TARGETS: Readonly<Partial<Record<SetupTarget, ReadonlyArray<AgentHost>>>> = {
470 claude: ['claude'],
471 codex: ['codex'],
@@ -439,15 +489,20 @@ export const detectSetupTargets = (target: SetupTarget) =>
489 );
490 });
491
442 -export const inspectSetupTargets = (detections: ReadonlyArray<SetupTargetDetection>) =>
492 +export const inspectSetupTargets = (
493 + detections: ReadonlyArray<SetupTargetDetection>,
494 + options: { readonly allowMarketplaceConflict?: boolean } = {}
495 +) =>
496 Effect.gen(function* () {
497 const inspected = yield* Effect.forEach(
498 detections.filter(detection => detection.available),
499 detection => inspectAdapter(ADAPTERS[detection.target], true)
500 );
448 - yield* Effect.forEach(inspected, status =>
449 - validateInitialState(ADAPTERS[status.target], status)
450 - );
501 + if (!options.allowMarketplaceConflict) {
502 + yield* Effect.forEach(inspected, status =>
503 + validateInitialState(ADAPTERS[status.target], status)
504 + );
505 + }
506 return inspected;
507 });
508
@@ -468,3 +523,21 @@ export const installSetupTargets = (inspected: ReadonlyArray<InspectedSetupTarge
523 }
524 return completed;
525 });
526 +
527 +export const uninstallSetupTargets = (inspected: ReadonlyArray<InspectedSetupTarget>) =>
528 + Effect.gen(function* () {
529 + const completed: SetupTargetResult[] = [];
530 + for (const status of inspected) {
531 + const result = yield* uninstallAdapter(ADAPTERS[status.target], status).pipe(
532 + Effect.mapError(error => {
533 + if (completed.length === 0) return error;
534 + const targets = completed.map(item => item.target).join(', ');
535 + return new Error(
536 + `Uninstall completed for ${targets} before a later target failed: ${errorMessage(error)}`
537 + );
538 + })
539 + );
540 + completed.push(result);
541 + }
542 + return completed;
543 + });
ts/packages/cli/test/__utils__/services/test-layer.ts
+1
@@ -1258,6 +1258,7 @@ export const TestLayer = (input?: TestLiveInput) =>
1258 new SetupSkillInstaller({
1259 isClaudeSkillReady: Effect.succeed(false),
1260 ensureClaudeSkill: Effect.succeed(false),
1261 + removeClaudeSkill: Effect.succeed(false),
1262 })
1263 );
1264
ts/packages/cli/test/src/commands/setup.cmd.test.ts
+154
@@ -100,6 +100,11 @@ const makeSkillInstaller = (initiallyReady = false, failInstall = false) => {
100 return new SetupSkillInstaller({
101 isClaudeSkillReady: Effect.sync(() => ready),
102 ensureClaudeSkill: ensureClaudeSkill(),
103 + removeClaudeSkill: Effect.sync(() => {
104 + const changed = ready;
105 + ready = false;
106 + return changed;
107 + }),
108 });
109 };
110
@@ -166,6 +171,14 @@ const makeFakeHosts = (
171 if (!options.noOp && command.includes('plugin marketplace add')) {
172 state[host].marketplace = 'canonical';
173 }
174 + if (
175 + !options.noOp &&
176 + (command === 'claude plugin uninstall composio@composio --scope user --yes' ||
177 + command === 'codex plugin remove composio@composio --json')
178 + ) {
179 + state[host].plugin = 'missing';
180 + return {};
181 + }
182 if (
183 !options.noOp &&
184 (command.includes('plugin install') ||
@@ -256,6 +269,11 @@ describe('CLI: composio setup', () => {
269 staleSkillReady = true;
270 return true;
271 }),
272 + removeClaudeSkill: Effect.sync(() => {
273 + const changed = staleSkillReady;
274 + staleSkillReady = false;
275 + return changed;
276 + }),
277 });
278 layer(
279 TestLive({
@@ -409,6 +427,142 @@ describe('CLI: composio setup', () => {
427 );
428 });
429
430 + const uninstallBoth = makeFakeHosts({
431 + claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
432 + codex: { available: true, marketplace: 'canonical', plugin: 'enabled' },
433 + });
434 + layer(
435 + TestLive({
436 + commandRunner: uninstallBoth.runner,
437 + setupSkillInstaller: makeSkillInstaller(true),
438 + })
439 + )('uninstall from both hosts', it => {
440 + it.scoped('uses native removal commands and is idempotent', () =>
441 + Effect.gen(function* () {
442 + yield* cli(['setup', '--uninstall', '--target', 'all', '--yes']);
443 + yield* cli(['setup', '--uninstall', '--target', 'all', '--yes']);
444 +
445 + expect(uninstallBoth.commands).toContainEqual([
446 + 'claude',
447 + 'plugin',
448 + 'uninstall',
449 + 'composio@composio',
450 + '--scope',
451 + 'user',
452 + '--yes',
453 + ]);
454 + expect(uninstallBoth.commands).toContainEqual([
455 + 'codex',
456 + 'plugin',
457 + 'remove',
458 + 'composio@composio',
459 + '--json',
460 + ]);
461 + expect(
462 + uninstallBoth.commands.filter(
463 + parts =>
464 + parts.join(' ') === 'claude plugin uninstall composio@composio --scope user --yes'
465 + )
466 + ).toHaveLength(1);
467 + expect(
468 + uninstallBoth.commands.filter(
469 + parts => parts.join(' ') === 'codex plugin remove composio@composio --json'
470 + )
471 + ).toHaveLength(1);
472 + expect(uninstallBoth.state.claude.plugin).toBe('missing');
473 + expect(uninstallBoth.state.codex.plugin).toBe('missing');
474 +
475 + const output = (yield* MockConsole.getLines()).join('\n');
476 + expect(output).toContain('Successfully uninstalled the Composio plugin for Claude Code.');
477 + expect(output).toContain('Successfully uninstalled the Composio plugin for Codex.');
478 + expect(output).not.toContain('skill');
479 + })
480 + );
481 + });
482 +
483 + const uninstallMissing = makeFakeHosts({
484 + claude: { available: true, marketplace: 'canonical', plugin: 'missing' },
485 + codex: { available: true, marketplace: 'canonical', plugin: 'missing' },
486 + });
487 + layer(TestLive({ commandRunner: uninstallMissing.runner }))(
488 + 'uninstall when plugins are absent',
489 + it => {
490 + it.scoped('reports the idempotent state without requiring approval', () =>
491 + Effect.gen(function* () {
492 + yield* cli(['setup', '--uninstall', '--target', 'all']);
493 +
494 + const output = (yield* MockConsole.getLines()).join('\n');
495 + expect(output).toContain('The Composio plugin for Claude Code is not installed.');
496 + expect(output).toContain('The Composio plugin for Codex is not installed.');
497 + })
498 + );
499 + }
500 + );
501 +
502 + const nonInteractiveUninstall = makeFakeHosts({
503 + claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
504 + });
505 + layer(
506 + TestLive({
507 + commandRunner: nonInteractiveUninstall.runner,
508 + setupSkillInstaller: makeSkillInstaller(true),
509 + })
510 + )('non-interactive uninstall approval', it => {
511 + it.scoped('requires --yes before removing an installed plugin', () =>
512 + Effect.gen(function* () {
513 + const exit = yield* Effect.exit(cli(['setup', '--uninstall', '--target', 'claude']));
514 +
515 + expect(Exit.isFailure(exit)).toBe(true);
516 + expect(nonInteractiveUninstall.commands.some(parts => parts.includes('uninstall'))).toBe(
517 + false
518 + );
519 + })
520 + );
521 + });
522 +
523 + const conflictingUninstall = makeFakeHosts({
524 + claude: { available: true, marketplace: 'conflict', plugin: 'enabled' },
525 + });
526 + layer(
527 + TestLive({
528 + commandRunner: conflictingUninstall.runner,
529 + setupSkillInstaller: makeSkillInstaller(true),
530 + })
531 + )('uninstall with a conflicting marketplace', it => {
532 + it.scoped('removes the installed plugin without replacing the marketplace', () =>
533 + Effect.gen(function* () {
534 + yield* cli(['setup', '--uninstall', '--target', 'claude', '--yes']);
535 +
536 + expect(conflictingUninstall.state.claude.plugin).toBe('missing');
537 + expect(conflictingUninstall.state.claude.marketplace).toBe('conflict');
538 + })
539 + );
540 + });
541 +
542 + const failedUninstall = makeFakeHosts(
543 + { claude: { available: true, marketplace: 'canonical', plugin: 'enabled' } },
544 + { failOn: 'plugin uninstall' }
545 + );
546 + layer(
547 + TestLive({
548 + commandRunner: failedUninstall.runner,
549 + setupSkillInstaller: makeSkillInstaller(true),
550 + })
551 + )('native uninstall failure', it => {
552 + it.scoped('fails without reporting the plugin as removed', () =>
553 + Effect.gen(function* () {
554 + const exit = yield* Effect.exit(
555 + cli(['setup', '--uninstall', '--target', 'claude', '--yes'])
556 + );
557 +
558 + expect(Exit.isFailure(exit)).toBe(true);
559 + expect(failedUninstall.state.claude.plugin).toBe('enabled');
560 + const output = (yield* MockConsole.getLines()).join('\n');
561 + expect(output).not.toContain('Successfully uninstalled');
562 + })
563 + );
564 + });
565 +
566 const projectScopedClaude = makeFakeHosts({
567 claude: {
568 available: true,
ts/packages/cli/test/src/services/setup-skill-installer.test.ts
+47
@@ -6,6 +6,7 @@ import * as tempy from 'tempy';
6 import { SKILL_RELEASE_TAG_FILENAME } from 'src/effects/install-skill';
7 import {
8 isClaudeSkillCurrent,
9 + removeManagedClaudeSkill,
10 resolveSetupSkillReleaseTag,
11 } from 'src/services/setup-skill-installer';
12
@@ -88,5 +89,51 @@ describe('SetupSkillInstaller', () => {
89 expect(yield* isClaudeSkillCurrent(home, '@composio/cli@0.3.0')).toBe(false);
90 })
91 );
92 +
93 + it.effect('removes the CLI-managed Claude skill and canonical copy', () =>
94 + Effect.gen(function* () {
95 + const fs = yield* FileSystem.FileSystem;
96 + const path = yield* Path.Path;
97 + const home = tempy.temporaryDirectory();
98 + const canonical = path.join(home, '.agents', 'skills', 'composio-cli');
99 + const claude = path.join(home, '.claude', 'skills', 'composio-cli');
100 + yield* fs.makeDirectory(canonical, { recursive: true });
101 + yield* fs.writeFileString(
102 + path.join(canonical, SKILL_RELEASE_TAG_FILENAME),
103 + '@composio/cli@0.3.0\n'
104 + );
105 + yield* fs.makeDirectory(path.dirname(claude), { recursive: true });
106 + yield* fs.symlink(path.relative(path.dirname(claude), canonical), claude);
107 +
108 + expect(yield* removeManagedClaudeSkill(home)).toBe(true);
109 + expect(yield* fs.exists(claude)).toBe(false);
110 + expect(yield* fs.exists(canonical)).toBe(false);
111 + })
112 + );
113 +
114 + it.effect('keeps the canonical skill while another agent references it', () =>
115 + Effect.gen(function* () {
116 + const fs = yield* FileSystem.FileSystem;
117 + const path = yield* Path.Path;
118 + const home = tempy.temporaryDirectory();
119 + const canonical = path.join(home, '.agents', 'skills', 'composio-cli');
120 + const claude = path.join(home, '.claude', 'skills', 'composio-cli');
121 + const openclaw = path.join(home, '.openclaw', 'skills', 'composio-cli');
122 + yield* fs.makeDirectory(canonical, { recursive: true });
123 + yield* fs.writeFileString(
124 + path.join(canonical, SKILL_RELEASE_TAG_FILENAME),
125 + '@composio/cli@0.3.0\n'
126 + );
127 + yield* fs.makeDirectory(path.dirname(claude), { recursive: true });
128 + yield* fs.makeDirectory(path.dirname(openclaw), { recursive: true });
129 + yield* fs.symlink(path.relative(path.dirname(claude), canonical), claude);
130 + yield* fs.symlink(path.relative(path.dirname(openclaw), canonical), openclaw);
131 +
132 + expect(yield* removeManagedClaudeSkill(home)).toBe(true);
133 + expect(yield* fs.exists(claude)).toBe(false);
134 + expect(yield* fs.exists(canonical)).toBe(true);
135 + expect(yield* fs.exists(openclaw)).toBe(true);
136 + })
137 + );
138 });
139 });