Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(cli): confirm managed skill removal
Kshitij Jhunjhunwalac8b1ddeb647d
diff --git a/ts/packages/cli/src/commands/setup.cmd.ts b/ts/packages/cli/src/commands/setup.cmd.tsindex 782c0a79d..82084e7d0 100644--- a/ts/packages/cli/src/commands/setup.cmd.ts+++ b/ts/packages/cli/src/commands/setup.cmd.ts@@ -12,6 +12,7 @@ import {type SetupTarget,} from 'src/services/setup';import { TerminalUI } from 'src/services/terminal-ui';+import { SetupSkillInstaller } from 'src/services/setup-skill-installer';import { isInteractiveTerminal } from 'src/utils/stdio';const target = Options.choice('target', SETUP_TARGETS).pipe(@@ -97,6 +98,13 @@ const setupBaseCmd = Command.make(if (uninstall) {const installed = inspected.filter(status => status.plugin_installed);const notInstalled = inspected.filter(status => !status.plugin_installed);+ const skillInstaller = yield* SetupSkillInstaller;+ const hasManagedClaudeSkill = inspected.some(status => status.target === 'claude')+ ? yield* skillInstaller.hasManagedClaudeSkill+ : false;+ const removable = inspected.filter(+ status => status.plugin_installed || (status.target === 'claude' && hasManagedClaudeSkill)+ );for (const status of installed) {yield* ui.log.success(@@ -109,14 +117,14 @@ const setupBaseCmd = Command.make();}- if (!yes && installed.length > 0) {+ if (!yes && removable.length > 0) {if (!isInteractiveTerminal()) {return yield* Effect.fail(new Error('Non-interactive uninstall requires `--yes` to approve local changes.'));}const confirmed = yield* ui.confirm(- `Uninstall the Composio plugin for ${formatTargets(installed.map(status => status.target))}?`,+ `Remove Composio from ${formatTargets(removable.map(status => status.target))}?`,{ defaultValue: false });if (!confirmed) {diff --git a/ts/packages/cli/src/services/setup-skill-installer.ts b/ts/packages/cli/src/services/setup-skill-installer.tsindex 18f5c5100..917513477 100644--- a/ts/packages/cli/src/services/setup-skill-installer.ts+++ b/ts/packages/cli/src/services/setup-skill-installer.ts@@ -50,6 +50,27 @@ const isLinkedTo = (fs: FileSystem.FileSystem, path: Path.Path, source: string,Effect.catchAll(() => Effect.succeed(false)));+export const hasManagedClaudeSkill = (home: string) =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const skillName = resolveInstalledSkillName();+ const canonicalSkill = path.join(home, '.agents', 'skills', skillName);+ const claudeSkill = resolveTargetSkillPath({ home, path, skillName, target: 'claude' });++ if (yield* isLinkedTo(fs, path, claudeSkill, canonicalSkill)) return true;+ const isManaged = yield* fs.exists(path.join(canonicalSkill, SKILL_RELEASE_TAG_FILENAME));+ if (!isManaged) return false;++ const otherTargets = (['codex', 'openclaw'] as const).map(target =>+ resolveTargetSkillPath({ home, path, skillName, target })+ );+ const references = yield* Effect.all(+ otherTargets.map(target => isLinkedTo(fs, path, target, canonicalSkill))+ );+ return !references.some(Boolean);+ });+export const removeManagedClaudeSkill = (home: string) =>Effect.gen(function* () {const fs = yield* FileSystem.FileSystem;@@ -93,6 +114,7 @@ export class SetupSkillInstaller extends Effect.Service<SetupSkillInstaller>()(return {isClaudeSkillReady: isCurrent(resolveSetupSkillReleaseTag()),+ hasManagedClaudeSkill: hasManagedClaudeSkill(os.homedir),ensureClaudeSkill: Effect.gen(function* () {const releaseTag = resolveSetupSkillReleaseTag();if (yield* isCurrent(releaseTag)) return false;diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.tsindex 8bfb5fbde..e8a28cb03 100644--- a/ts/packages/cli/test/__utils__/services/test-layer.ts+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts@@ -1257,6 +1257,7 @@ export const TestLayer = (input?: TestLiveInput) =>input?.setupSkillInstaller ??new SetupSkillInstaller({isClaudeSkillReady: Effect.succeed(false),+ hasManagedClaudeSkill: Effect.succeed(false),ensureClaudeSkill: Effect.succeed(false),removeClaudeSkill: Effect.succeed(false),})diff --git a/ts/packages/cli/test/src/commands/setup.cmd.test.ts b/ts/packages/cli/test/src/commands/setup.cmd.test.tsindex d6d49162f..cce61e702 100644--- a/ts/packages/cli/test/src/commands/setup.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/setup.cmd.test.ts@@ -99,6 +99,7 @@ const makeSkillInstaller = (initiallyReady = false, failInstall = false) => {};return new SetupSkillInstaller({isClaudeSkillReady: Effect.sync(() => ready),+ hasManagedClaudeSkill: Effect.sync(() => ready),ensureClaudeSkill: ensureClaudeSkill(),removeClaudeSkill: Effect.sync(() => {const changed = ready;@@ -264,6 +265,7 @@ describe('CLI: composio setup', () => {let staleSkillReady = false;const staleSkillInstaller = new SetupSkillInstaller({isClaudeSkillReady: Effect.sync(() => staleSkillReady),+ hasManagedClaudeSkill: Effect.succeed(true),ensureClaudeSkill: Effect.sync(() => {staleSkillRepaired = true;staleSkillReady = true;@@ -522,6 +524,39 @@ describe('CLI: composio setup', () => {});+ const orphanedClaudeSkill = makeFakeHosts({+ claude: { available: true, marketplace: 'canonical', plugin: 'missing' },+ });+ let managedClaudeSkill = true;+ layer(+ TestLive({+ commandRunner: orphanedClaudeSkill.runner,+ setupSkillInstaller: new SetupSkillInstaller({+ isClaudeSkillReady: Effect.sync(() => managedClaudeSkill),+ hasManagedClaudeSkill: Effect.sync(() => managedClaudeSkill),+ ensureClaudeSkill: Effect.succeed(false),+ removeClaudeSkill: Effect.sync(() => {+ const changed = managedClaudeSkill;+ managedClaudeSkill = false;+ return changed;+ }),+ }),+ })+ )('uninstall with an orphaned managed Claude skill', it => {+ it.scoped('requires approval before removing the managed skill', () =>+ Effect.gen(function* () {+ const withoutApproval = yield* Effect.exit(+ cli(['setup', '--uninstall', '--target', 'claude'])+ );+ expect(Exit.isFailure(withoutApproval)).toBe(true);+ expect(managedClaudeSkill).toBe(true);++ yield* cli(['setup', '--uninstall', '--target', 'claude', '--yes']);+ expect(managedClaudeSkill).toBe(false);+ })+ );+ });+const nonInteractiveUninstall = makeFakeHosts({claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },});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.tsindex 4af98711a..dcb2f9db9 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@@ -5,6 +5,7 @@ import { Effect, Layer } from 'effect';import * as tempy from 'tempy';import { SKILL_RELEASE_TAG_FILENAME } from 'src/effects/install-skill';import {+ hasManagedClaudeSkill,isClaudeSkillCurrent,removeManagedClaudeSkill,resolveSetupSkillReleaseTag,@@ -105,7 +106,9 @@ describe('SetupSkillInstaller', () => {yield* fs.makeDirectory(path.dirname(claude), { recursive: true });yield* fs.symlink(path.relative(path.dirname(claude), canonical), claude);+ expect(yield* hasManagedClaudeSkill(home)).toBe(true);expect(yield* removeManagedClaudeSkill(home)).toBe(true);+ expect(yield* hasManagedClaudeSkill(home)).toBe(false);expect(yield* fs.exists(claude)).toBe(false);expect(yield* fs.exists(canonical)).toBe(false);})@@ -129,7 +132,9 @@ describe('SetupSkillInstaller', () => {yield* fs.symlink(path.relative(path.dirname(claude), canonical), claude);yield* fs.symlink(path.relative(path.dirname(openclaw), canonical), openclaw);+ expect(yield* hasManagedClaudeSkill(home)).toBe(true);expect(yield* removeManagedClaudeSkill(home)).toBe(true);+ expect(yield* hasManagedClaudeSkill(home)).toBe(false);expect(yield* fs.exists(claude)).toBe(false);expect(yield* fs.exists(canonical)).toBe(true);expect(yield* fs.exists(openclaw)).toBe(true);