@devries-cameron20 / composio Mirror · read-only / commits / b4dbab506
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

fix(cli): verify plugin setup state

Kshitij Jhunjhunwala committed Jul 13, 2026 at 19:20 UTC b4dbab5060b4362df3bc4145e349f08fd3c2225a
9 files changed +416 -536
docs/content/docs/claude-code-plugin.mdx
+43 -106
@@ -1,82 +1,62 @@
1 ---
2 title: Claude Code Plugin
3 -description: Install the Composio CLI plugin for Claude Code — connect and act across 1000+ apps with managed authentication.
4 -keywords: [claude code, plugin, marketplace, composio cli, composio connect, skills]
3 +description: Install Composio in Claude Code as a plugin — connect 1000+ apps with managed OAuth and ready-made skills.
4 +keywords: [claude code, plugin, marketplace, mcp, composio connect, skills]
5 ---
6
7 -The **Composio plugin for Claude Code** helps Claude discover and run the right Composio CLI command when a task involves an external app. It is a thin, CLI-based plugin: the plugin adds Claude Code hooks and a connection command, while the `composio` CLI handles tool search, execution, and authentication.
7 +The **Composio plugin for Claude Code** bundles the Composio Connect MCP server with a set of opinionated skills, so Claude Code can search, connect, and act across 1000+ apps right after install. Authentication is fully managed — no API key handling, no manual MCP config.
8
9 -The plugin does **not** bundle an MCP server or a skill. If you want to add the remote Composio MCP server to Claude Code, see [Composio Connect](/docs/composio-connect).
9 +<Callout type="info">
10 +Looking for the API-key based MCP setup (or other clients like Cursor, Codex, Claude Desktop)? See [Composio Connect](/docs/composio-connect).
11 +</Callout>
12
13 ## What you get
14
13 -| Component | Purpose |
14 -| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15 -| **SessionStart hook** | Tells Claude about Composio's `search` → `execute` workflow, reports CLI authentication status, and warms a local cache of popular toolkits. It runs when a session starts, resumes, clears, or compacts. |
16 -| **UserPromptSubmit hook** | Nudges Claude toward `composio search` when your prompt names an app in the local toolkit cache. It uses the cache and does not make a network request for each prompt. |
17 -| **`/composio-connect <app>` command** | Connects an app with `composio link` and managed OAuth, then verifies the connection. |
15 +The plugin ships two things together:
16
19 -The Composio CLI installs the full `composio-cli` skill separately when you sign in. That skill contains the detailed CLI reference; it is not packaged inside this plugin.
17 +- **Composio Connect MCP server** — the same gateway documented in [Composio Connect](/docs/composio-connect), pre-configured. Auth is handled via in-flow OAuth, so you don't paste API keys into your config.
18 +- **Bundled skills** — pre-written prompts that show Claude how to use the MCP server effectively:
19 + - **`composio-mcp`** — reference for the 7 meta-tools (`COMPOSIO_SEARCH_TOOLS`, `COMPOSIO_MANAGE_CONNECTIONS`, etc.) and the recommended search → connect → execute flow.
20 + - **`onboarding`** — interactive setup that asks what you want to automate, recommends 2–4 apps, and walks you through connecting them.
21 + - **`company-activity-summary`** — cross-app activity summary across Slack, GitHub, Notion, Linear, Gmail, and more.
22 + - **`prefer-composio`** — routing skill that tells Claude to reach for Composio first whenever you paste an app URL or mention an external service, so you don't end up using less reliable native connectors.
23
24 ## Install
25
26 <Steps>
27 <Step>
25 -<StepTitle>Install and set up Composio</StepTitle>
28 +<StepTitle>Add the Composio marketplace</StepTitle>
29
27 -If the CLI is not already installed, run:
30 +In Claude Code, run:
31
32 ```bash
30 -curl -fsSL https://composio.dev/install | bash
33 +/plugin marketplace add ComposioHQ/composio-plugin-cc
34 ```
35
33 -The installer adds `composio` to your `PATH`. Open a new terminal, or source the shell profile printed by the installer, before continuing:
36 +This registers the catalog. No plugins are installed yet.
37 +
38 +</Step>
39 +<Step>
40 +<StepTitle>Install the Composio plugin</StepTitle>
41
42 ```bash
36 -composio login
37 -composio setup --target claude
43 +/plugin install composio-mcp@composio
44 ```
45
40 -Login authenticates the CLI. Setup then adds the GitHub-hosted marketplace, installs and enables `composio@composio`, and installs the matching `composio-cli` skill. Setup is safe to rerun.
46 +Restart Claude Code (or run `/reload-plugins`) when prompted.
47
48 </Step>
49 <Step>
44 -<StepTitle>Try it</StepTitle>
45 -
46 -Ask Claude to act on an app, for example: _"List my open GitHub pull requests."_ Claude can search for the appropriate tool, ask you to connect GitHub if necessary, and execute it.
50 +<StepTitle>Connect your first app</StepTitle>
51
48 -You can also connect an app directly:
49 -
50 -```text
51 -/composio-connect github
52 -```
52 +Ask Claude something that needs an external service — for example: *"Star `composiohq/composio` on GitHub"* — and Claude will run the `onboarding` skill, walk you through connecting GitHub, and execute the action. Subsequent runs reuse the same connection.
53
54 </Step>
55 </Steps>
56
57 -### Manual plugin fallback
58 -
59 -If you need to register the plugin directly in Claude Code, add the marketplace:
60 -
61 -In Claude Code, run:
62 -
63 -```text
64 -/plugin marketplace add https://github.com/ComposioHQ/composio-plugin-cc.git
65 -```
66 -
67 -This adds Composio's GitHub-hosted marketplace. It does not install the plugin yet.
68 -
69 -Then install the plugin:
70 -
71 -```text
72 -/plugin install composio@composio
73 -```
74 -
75 -Finish the local prerequisites with `composio login` and `composio --install-skill claude` if they are not already ready. `composio setup --target claude` is preferred for plugin and skill installation because it verifies those pieces together.
76 -
57 ## Team setup
58
79 -To make the marketplace and plugin available to everyone working in a repository, add this to the project's `.claude/settings.json`:
59 +To pre-install the plugin for everyone on your team, add this to your project's `.claude/settings.json`:
60
61 ```json title=".claude/settings.json"
62 {
@@ -89,85 +69,42 @@ To make the marketplace and plugin available to everyone working in a repository
69 }
70 },
71 "enabledPlugins": {
92 - "composio@composio": true
72 + "composio-mcp@composio": true
73 }
74 }
75 ```
76
97 -Claude Code prompts teammates to trust and enable the plugin when they open the project. Each teammate still needs the `composio` CLI installed and must sign in on their machine.
98 -
99 -## How it works
100 -
101 -The plugin keeps the integration lightweight and lets the CLI own its capabilities:
102 -
103 -1. **Session context** — the SessionStart hook tells Claude to use Composio for external apps, surfaces CLI authentication status, and caches a small list of popular toolkits.
104 -2. **Prompt routing** — the UserPromptSubmit hook checks the prompt against that local cache. When it recognizes an app, it reminds Claude to use Composio's just-in-time tool search.
105 -3. **Tool discovery and execution** — Claude runs `composio search "<task>"`, then `composio execute` with the selected tool. If an app is not connected, it runs `composio link <app>` to start managed OAuth.
106 -4. **CLI-provided guidance** — the separately installed `composio-cli` skill gives Claude the full command and workflow reference.
107 -
108 -The hooks guide Claude; they do not expose tools or execute app actions themselves.
77 +Anyone who clones the repo and opens it in Claude Code will be prompted to enable the plugin. See the Claude Code [plugin scopes](https://docs.claude.com/en/docs/claude-code/plugins-reference#plugin-installation-scopes) reference for `user` vs `project` vs `local` scope behavior.
78
79 ## Updating
80
112 -Plugin updates and CLI updates are separate. Update the marketplace checkout and reload plugins in Claude Code:
81 +The plugin is versioned via the `version` field in its `plugin.json`. To pull the latest release:
82
114 -```text
83 +```bash
84 /plugin marketplace update composio
85 /reload-plugins
86 ```
87
119 -Update the CLI to receive the latest Composio commands, tool-routing behavior, and generated skill:
120 -
121 -```bash
122 -composio upgrade
123 -```
124 -
125 -## Plugin or MCP setup?
88 +## How it differs from the API-key MCP setup
89
127 -The Claude Code plugin and the API-key MCP setup are two different ways to use Composio:
90 +Both paths give Claude Code access to the same Composio Connect MCP server and the same 1000+ apps. The differences:
91
129 -| | Claude Code plugin | Composio Connect MCP |
130 -| ------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------- |
131 -| Runtime | Local `composio` CLI | Remote MCP server |
132 -| Tool access | Claude runs `composio search`, `composio execute`, and `composio link` | Claude calls Composio's MCP meta-tools |
133 -| Claude Code integration | Session and prompt hooks plus `/composio-connect` | MCP tools registered with `claude mcp add` |
134 -| Skill | Installed and updated separately by the CLI | No CLI skill required |
135 -| Initial Composio authentication | `composio login` | Consumer API key in the MCP configuration |
136 -| Updates | Update both the marketplace plugin and CLI | Server-side; the MCP configuration remains in Claude Code |
92 +| | Plugin install | `claude mcp add` |
93 +|---|---|---|
94 +| Setup steps | Two slash commands | One terminal command, requires copying an API key |
95 +| Auth | OAuth, no API key in your config | API key in `--header "x-consumer-api-key: ..."` |
96 +| Bundled skills | Yes (onboarding, routing, summaries) | No |
97 +| Discoverable in Claude Code marketplace | Yes | No |
98 +| Updates | `/plugin marketplace update composio` | Manual re-run of `claude mcp add` |
99
138 -Choose the plugin when you want Claude Code to use the local CLI and its scripting workflows. Choose [Composio Connect](/docs/composio-connect) when you want an MCP-native setup or the same remote MCP interface across multiple clients.
100 +Pick the plugin path if you want the fastest install and the bundled skills. Pick the `claude mcp add` path if you already have an API key and want a single-command setup script you can replicate across machines.
101
102 ## Source code
103
142 -The plugin is open source at [ComposioHQ/composio-plugin-cc](https://github.com/ComposioHQ/composio-plugin-cc).
104 +The plugin is open source: [ComposioHQ/composio-plugin-cc](https://github.com/ComposioHQ/composio-plugin-cc). Issues and PRs welcome.
105
106 ## Troubleshooting
107
146 -### The plugin installs, but Claude cannot run Composio
147 -
148 -Confirm the CLI is available and that you are signed in:
149 -
150 -```bash
151 -composio --version
152 -composio whoami
153 -```
154 -
155 -If the first command fails, [install the CLI](#install). If the second reports that you are signed out, run `composio login`.
156 -
157 -### The CLI skill is missing
158 -
159 -The plugin does not bundle the `composio-cli` skill. Rerun `composio setup --target claude`, or install the skill explicitly:
160 -
161 -```bash
162 -composio --install-skill claude
163 -```
164 -
165 -### Claude does not receive an app-specific nudge
166 -
167 -The UserPromptSubmit hook only matches apps in its cached popular-toolkit list. Claude can still use Composio for any supported app: ask it to run `composio search "<task>"`, or connect the app with `/composio-connect <app>`.
168 -
169 -### An app is not connected or a tool call fails
170 -
171 -Run `composio link <app>` to connect the app, then retry the action. For CLI-specific diagnostics, use the troubleshooting guidance in the installed `composio-cli` skill. For the separate MCP integration, see [Composio Connect troubleshooting](/docs/composio-connect#troubleshooting).
108 +For tools-not-appearing, OAuth, and connection issues, see the [Composio Connect troubleshooting section](/docs/composio-connect#troubleshooting). The same checks apply to the plugin install (the underlying MCP server is identical).
109
173 -For marketplace registration, plugin loading, or hook errors, see the [Claude Code plugin troubleshooting documentation](https://code.claude.com/docs/en/plugins-reference#common-issues).
110 +For plugin-specific issues — install errors, marketplace not updating, skills not appearing — see the [Claude Code plugin troubleshooting docs](https://docs.claude.com/en/docs/claude-code/plugins-reference#common-issues).
ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+10 -30
@@ -15,12 +15,16 @@ set -eu
15 mkdir -p /tmp/bin /tmp/host-state
16 cp fixtures/fake-agent-host.sh /tmp/bin/${host}
17 chmod +x /tmp/bin/${host}
18 -${host === 'claude' ? 'mkdir -p /tmp/.claude/skills/composio-cli' : ''}
18 +${
19 + host === 'claude'
20 + ? `mkdir -p /tmp/.claude/skills/composio-cli /tmp/.agents/skills/composio-cli
21 +printf '@composio/cli@%s\n' "$(composio --version)" > /tmp/.agents/skills/composio-cli/.composio-release-tag`
22 + : ''
23 +}
24 export HOST_STATE_DIR=/tmp/host-state
25 export PATH=/tmp/bin:$PATH
26 composio setup --target ${host} --yes > first.json
27 composio setup --target ${host} --yes > second.json
23 -composio setup status --json > status.json
28 cp /tmp/host-state/commands.log commands.log
29 `;
30
@@ -29,12 +33,8 @@ e2e(import.meta.url, {
33 cli: ['current'],
34 },
35 defineTests: ({ runCmd }) => {
32 - let claude: E2ETestResultWithFiles<
33 - 'first.json' | 'second.json' | 'status.json' | 'commands.log'
34 - >;
35 - let codex: E2ETestResultWithFiles<
36 - 'first.json' | 'second.json' | 'status.json' | 'commands.log'
37 - >;
36 + let claude: E2ETestResultWithFiles<'first.json' | 'second.json' | 'commands.log'>;
37 + let codex: E2ETestResultWithFiles<'first.json' | 'second.json' | 'commands.log'>;
38 let unavailable: E2ETestResult;
39
40 beforeAll(async () => {
@@ -42,11 +42,11 @@ e2e(import.meta.url, {
42 // these fresh-container cases sequential to avoid same-millisecond names.
43 claude = await runCmd({
44 command: setupFixture('claude'),
45 - files: ['first.json', 'second.json', 'status.json', 'commands.log'],
45 + files: ['first.json', 'second.json', 'commands.log'],
46 });
47 codex = await runCmd({
48 command: setupFixture('codex'),
49 - files: ['first.json', 'second.json', 'status.json', 'commands.log'],
49 + files: ['first.json', 'second.json', 'commands.log'],
50 });
51 unavailable = await runCmd('composio setup --target auto --yes');
52 }, TIMEOUTS.FIXTURE);
@@ -78,17 +78,6 @@ e2e(import.meta.url, {
78 targets: Array<{ target: string; changed: boolean; cli_skill_ready: boolean }>;
79 };
80 const second = JSON.parse(execution.files['second.json']) as typeof first;
81 - const status = JSON.parse(execution.files['status.json']) as {
82 - targets: Array<{
83 - target: string;
84 - available: boolean;
85 - marketplace_configured: boolean;
86 - plugin_installed: boolean;
87 - plugin_enabled: boolean;
88 - cli_skill_ready: boolean;
89 - }>;
90 - };
91 -
81 expect(first.success).toBe(true);
82 expect(first.targets).toContainEqual(
83 expect.objectContaining({ target: host, changed: true, cli_skill_ready: true })
@@ -96,15 +85,6 @@ e2e(import.meta.url, {
85 expect(second.targets).toContainEqual(
86 expect.objectContaining({ target: host, changed: false, cli_skill_ready: true })
87 );
99 - expect(status.targets).toContainEqual({
100 - target: host,
101 - available: true,
102 - marketplace_configured: true,
103 - plugin_installed: true,
104 - plugin_enabled: true,
105 - cli_skill_ready: true,
106 - });
107 -
88 const commands = execution.files['commands.log'].trim().split('\n');
89 expect(commands.filter(command => command === marketplaceCommand)).toHaveLength(1);
90 expect(commands.filter(command => command === installCommand)).toHaveLength(1);
ts/packages/cli/src/commands/root-help.ts
-6
@@ -880,18 +880,12 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
880 'composio setup',
881 'composio setup --target auto --yes',
882 'composio setup --target all',
883 - 'composio setup status --json',
883 ],
884 options: [
885 { name: '--target <target>', description: 'auto, claude, codex, or all' },
886 { name: '-y, --yes', description: 'Accept setup changes without prompting' },
887 ],
888 },
890 - 'setup status': {
891 - usage: 'composio setup status [--json]',
892 - description: 'Inspect agent plugin installation status.',
893 - flags: [{ name: '--json', description: 'Print machine-readable JSON' }],
894 - },
889 version: {
890 usage: 'composio version',
891 description: 'Display the current Composio CLI version.',
ts/packages/cli/src/commands/setup.cmd.ts
+4 -48
@@ -1,7 +1,6 @@
1 import { Command, Options } from '@effect/cli';
2 import { Effect } from 'effect';
3 import {
4 - inspectSetupTargets,
4 installSetupTargets,
5 resolveSetupTargets,
6 SETUP_TARGETS,
@@ -20,46 +19,6 @@ const yes = Options.boolean('yes').pipe(
19 Options.withDescription('Accept setup changes without prompting')
20 );
21
23 -const json = Options.boolean('json').pipe(
24 - Options.withDefault(false),
25 - Options.withDescription('Print machine-readable JSON')
26 -);
27 -
28 -const setupStatusCmd = Command.make('status', { json }).pipe(
29 - Command.withDescription('Inspect agent plugin installation status.'),
30 - Command.withHandler(({ json }) =>
31 - Effect.gen(function* () {
32 - const ui = yield* TerminalUI;
33 - const targets = yield* inspectSetupTargets;
34 - const result = { targets };
35 -
36 - if (!json) {
37 - yield* ui.note(
38 - [
39 - ...targets.map(item => {
40 - const state = !item.available
41 - ? 'not detected'
42 - : !item.plugin_installed
43 - ? 'not installed'
44 - : item.plugin_enabled
45 - ? 'installed and enabled'
46 - : 'installed but disabled';
47 - return `${item.target}: ${state}`;
48 - }),
49 - ...targets
50 - .filter(item => item.available)
51 - .map(
52 - item => `${item.target} CLI skill: ${item.cli_skill_ready ? 'ready' : 'not ready'}`
53 - ),
54 - ].join('\n'),
55 - 'Composio setup status'
56 - );
57 - }
58 - yield* ui.output(JSON.stringify(result), { force: json });
59 - })
60 - )
61 -);
62 -
22 const setupBaseCmd = Command.make('setup', { target, yes }, ({ target, yes }) =>
23 Effect.gen(function* () {
24 const ui = yield* TerminalUI;
@@ -84,11 +43,9 @@ const setupBaseCmd = Command.make('setup', { target, yes }, ({ target, yes }) =>
43 : `The Composio plugin for ${result.target} is already installed and enabled.`
44 );
45 if (result.target === 'claude') {
87 - yield* ui.log.success(
88 - result.skill_changed
89 - ? 'Installed the composio-cli skill for Claude Code.'
90 - : 'The composio-cli skill for Claude Code is already installed.'
91 - );
46 + if (!result.skill_changed) {
47 + yield* ui.log.success('The composio-cli skill for Claude Code is already installed.');
48 + }
49 } else {
50 yield* ui.log.success('The Codex plugin includes the composio-cli skill.');
51 }
@@ -105,6 +62,5 @@ const setupBaseCmd = Command.make('setup', { target, yes }, ({ target, yes }) =>
62 );
63
64 export const setupCmd = setupBaseCmd.pipe(
108 - Command.withDescription('Install Composio plugins for supported agent hosts.'),
109 - Command.withSubcommands([setupStatusCmd])
65 + Command.withDescription('Install Composio plugins for supported agent hosts.')
66 );
ts/packages/cli/src/effects/install-skill.ts
+11
@@ -15,6 +15,7 @@ import extractZip from 'extract-zip';
15
16 const SKILL_NAME = 'composio-cli';
17 const SKILL_ASSET_NAME = 'composio-skill.zip';
18 +export const SKILL_RELEASE_TAG_FILENAME = '.composio-release-tag';
19 export type SkillReleaseChannel = CliReleaseChannel;
20 export type SkillInstallTarget = 'claude' | 'codex' | 'openclaw';
21
@@ -66,6 +67,15 @@ export const resolveTargetSkillPath = ({
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 +};
78 +
79 const resolveTargetLabel = (target: SkillInstallTarget): string => SKILL_TARGET_LABELS[target];
80
81 export const inferSkillReleaseChannel = (tagOrVersion: string): SkillReleaseChannel =>
@@ -204,6 +214,7 @@ export const installSkill = (options?: {
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 }
ts/packages/cli/src/services/setup-skill-installer.ts
+12 -8
@@ -1,7 +1,7 @@
1 -import { FileSystem } from '@effect/platform';
1 import { Effect } from 'effect';
2 +import fs from 'node:fs';
3 import path from 'node:path';
4 -import { installSkill } from 'src/effects/install-skill';
4 +import { installSkill, readInstalledSkillReleaseTag } from 'src/effects/install-skill';
5 import { APP_VERSION } from 'src/constants';
6 import { readInstalledReleaseTag } from 'src/services/run-companion-modules';
7 import { NodeOs } from './node-os';
@@ -11,24 +11,28 @@ export const resolveSetupSkillReleaseTag = (
11 fallbackVersion = APP_VERSION
12 ): string => readInstalledReleaseTag(execPath) ?? `@composio/cli@${fallbackVersion}`;
13
14 +export const isClaudeSkillCurrent = (home: string, releaseTag: string): boolean => {
15 + const target = path.join(home, '.claude', 'skills', 'composio-cli');
16 + const skillDir = path.join(home, '.agents', 'skills', 'composio-cli');
17 + return fs.existsSync(target) && readInstalledSkillReleaseTag(skillDir) === releaseTag;
18 +};
19 +
20 export class SetupSkillInstaller extends Effect.Service<SetupSkillInstaller>()(
21 'services/SetupSkillInstaller',
22 {
23 sync: () => ({
24 isClaudeSkillInstalled: Effect.gen(function* () {
19 - const fs = yield* FileSystem.FileSystem;
25 const os = yield* NodeOs;
21 - return yield* fs.exists(path.join(os.homedir, '.claude', 'skills', 'composio-cli'));
26 + return isClaudeSkillCurrent(os.homedir, resolveSetupSkillReleaseTag());
27 }),
28 ensureClaudeSkill: Effect.gen(function* () {
24 - const fs = yield* FileSystem.FileSystem;
29 const os = yield* NodeOs;
26 - const target = path.join(os.homedir, '.claude', 'skills', 'composio-cli');
27 - if (yield* fs.exists(target)) return false;
30 + const releaseTag = resolveSetupSkillReleaseTag();
31 + if (isClaudeSkillCurrent(os.homedir, releaseTag)) return false;
32
33 yield* installSkill({
34 target: 'claude',
31 - releaseTag: resolveSetupSkillReleaseTag(),
35 + releaseTag,
36 });
37 return true;
38 }),
ts/packages/cli/src/services/setup.ts
+57 -17
@@ -46,6 +46,10 @@ interface SetupTargetAdapter {
46 readonly pluginEnableArgs: ReadonlyArray<string>;
47 }
48
49 +interface InspectedSetupTarget extends SetupTargetStatus {
50 + readonly marketplace_conflict: boolean;
51 +}
52 +
53 const CLAUDE_ADAPTER: SetupTargetAdapter = {
54 target: 'claude',
55 executable: 'claude',
@@ -127,10 +131,14 @@ const normalizeGitHubRepository = (value: string): string | undefined => {
131 return parts.join('/').toLowerCase();
132 };
133
130 -const marketplaceIsConfigured = (adapter: SetupTargetAdapter, output: string): boolean => {
134 +const marketplaceState = (
135 + adapter: SetupTargetAdapter,
136 + output: string
137 +): { readonly configured: boolean; readonly conflicting: boolean } => {
138 const parsed = parseJson(output);
139 const records = recordsFrom(parsed, adapter.target === 'codex' ? 'marketplaces' : undefined);
133 - return records.some(record => {
140 + const expected = normalizeGitHubRepository(adapter.marketplace.source);
141 + const sourceMatches = (record: Record<string, unknown>) => {
142 const repo = typeof record.repo === 'string' ? record.repo : undefined;
143 const url = typeof record.url === 'string' ? record.url : undefined;
144 const nestedSource = asRecord(record.source);
@@ -140,12 +148,16 @@ const marketplaceIsConfigured = (adapter: SetupTargetAdapter, output: string): b
148 (typeof nestedSource?.repo === 'string' ? nestedSource.repo : undefined) ??
149 (typeof nestedSource?.source === 'string' ? nestedSource.source : undefined) ??
150 (typeof marketplaceSource?.source === 'string' ? marketplaceSource.source : undefined);
143 - const expected = normalizeGitHubRepository(adapter.marketplace.source);
151 return [repo, url, source].some(
152 candidate =>
153 typeof candidate === 'string' && normalizeGitHubRepository(candidate) === expected
154 );
148 - });
155 + };
156 + const configured = records.some(sourceMatches);
157 + const conflicting = records.some(
158 + record => record.name === adapter.marketplace.name && !sourceMatches(record)
159 + );
160 + return { configured, conflicting };
161 };
162
163 const pluginState = (
@@ -182,7 +194,8 @@ const inspectAdapter = (adapter: SetupTargetAdapter) =>
194 plugin_installed: false,
195 plugin_enabled: false,
196 cli_skill_ready: false,
185 - } satisfies SetupTargetStatus;
197 + marketplace_conflict: false,
198 + } satisfies InspectedSetupTarget;
199 }
200
201 const [marketplaces, plugins] = yield* Effect.all([
@@ -195,21 +208,22 @@ const inspectAdapter = (adapter: SetupTargetAdapter) =>
208 : { installed: false, enabled: false };
209
210 const pluginReady = plugin.installed && plugin.enabled;
211 + const marketplace =
212 + marketplaces && marketplaces.exitCode === 0
213 + ? marketplaceState(adapter, marketplaces.stdout)
214 + : { configured: false, conflicting: false };
215 return {
216 target: adapter.target,
217 available: true,
201 - marketplace_configured: Boolean(
202 - marketplaces &&
203 - marketplaces.exitCode === 0 &&
204 - marketplaceIsConfigured(adapter, marketplaces.stdout)
205 - ),
218 + marketplace_configured: marketplace.configured,
219 plugin_installed: plugin.installed,
220 plugin_enabled: plugin.enabled,
221 // Codex loads the composio-cli skill from the plugin package itself. Claude's
222 // plugin uses the standalone skill installed from the matching CLI release.
223 cli_skill_ready:
224 adapter.target === 'codex' ? pluginReady : yield* skillInstaller.isClaudeSkillInstalled,
212 - } satisfies SetupTargetStatus;
225 + marketplace_conflict: marketplace.conflicting,
226 + } satisfies InspectedSetupTarget;
227 });
228
229 const runRequired = (adapter: SetupTargetAdapter, args: ReadonlyArray<string>, operation: string) =>
@@ -234,6 +248,17 @@ const installAdapter = (adapter: SetupTargetAdapter) =>
248 )
249 );
250 }
251 + if (initial.marketplace_conflict) {
252 + const removeCommand =
253 + adapter.target === 'claude'
254 + ? 'claude plugin marketplace remove composio --scope user'
255 + : 'codex plugin marketplace remove composio --json';
256 + return yield* Effect.fail(
257 + new Error(
258 + `The ${adapter.target} marketplace named "composio" points to a different source. Run \`${removeCommand}\`, then rerun \`composio setup --target ${adapter.target}\`.`
259 + )
260 + );
261 + }
262
263 let pluginChanged = false;
264 if (!initial.marketplace_configured) {
@@ -266,20 +291,35 @@ const installAdapter = (adapter: SetupTargetAdapter) =>
291 ? yield* skillInstaller.ensureClaudeSkill
292 : false;
293
294 + const final = yield* inspectAdapter(adapter);
295 + if (
296 + !final.available ||
297 + !final.marketplace_configured ||
298 + !final.plugin_installed ||
299 + !final.plugin_enabled ||
300 + !final.cli_skill_ready
301 + ) {
302 + return yield* Effect.fail(
303 + new Error(
304 + `Setup commands completed, but ${adapter.target} did not report the Composio plugin and CLI skill as ready. Rerun \`composio setup --target ${adapter.target}\` or inspect the native ${adapter.target} plugin configuration.`
305 + )
306 + );
307 + }
308 +
309 return {
310 target: adapter.target,
271 - available: true,
272 - marketplace_configured: true,
273 - plugin_installed: true,
274 - plugin_enabled: true,
275 - cli_skill_ready: true,
311 + available: final.available,
312 + marketplace_configured: final.marketplace_configured,
313 + plugin_installed: final.plugin_installed,
314 + plugin_enabled: final.plugin_enabled,
315 + cli_skill_ready: final.cli_skill_ready,
316 changed: pluginChanged || skillChanged,
317 plugin_changed: pluginChanged,
318 skill_changed: skillChanged,
319 } satisfies SetupTargetResult;
320 });
321
282 -export const inspectSetupTargets = Effect.all(ADAPTERS.map(inspectAdapter));
322 +const inspectSetupTargets = Effect.all(ADAPTERS.map(inspectAdapter));
323
324 export const resolveSetupTargets = (target: SetupTarget) =>
325 Effect.gen(function* () {
ts/packages/cli/test/src/commands/setup.cmd.test.ts
+251 -319
@@ -6,9 +6,18 @@ import { CommandRunner } from 'src/services/command-runner';
6 import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
7 import { cli, MockConsole, TestLive } from 'test/__utils__';
8
9 +type AgentHost = 'claude' | 'codex';
10 +type MarketplaceState = 'missing' | 'canonical' | 'conflict';
11 +type PluginState = 'missing' | 'disabled' | 'enabled';
12 +
13 +interface FakeHostState {
14 + available: boolean;
15 + marketplace: MarketplaceState;
16 + plugin: PluginState;
17 +}
18 +
19 const commandParts = (command: Command.Command): ReadonlyArray<string> => {
10 - const flattened = Command.flatten(command);
11 - const first = flattened[0];
20 + const first = Command.flatten(command)[0];
21 return [first.command, ...first.args];
22 };
23
@@ -17,15 +26,10 @@ const makeRunner = (
26 readonly exitCode?: number;
27 readonly stdout?: string;
28 readonly stderr?: string;
20 - },
21 - onRun: (parts: ReadonlyArray<string>) => void = () => undefined
29 + }
30 ) =>
31 new CommandRunner({
24 - run: command =>
25 - Effect.sync(() => {
26 - onRun(commandParts(command));
27 - return CommandExecutor.ExitCode(0);
28 - }),
32 + run: () => Effect.succeed(CommandExecutor.ExitCode(0)),
33 capture: command => {
34 const result = respond(commandParts(command));
35 return Effect.succeed({
@@ -36,286 +40,198 @@ const makeRunner = (
40 },
41 });
42
39 -describe('CLI: composio setup', () => {
40 - afterEach(() => {
41 - vi.restoreAllMocks();
42 - vi.unstubAllEnvs();
43 - process.exitCode = undefined;
44 - });
45 -
46 - const humanCommands: string[][] = [];
47 - const humanRunner = makeRunner(parts => {
48 - humanCommands.push([...parts]);
49 - if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
50 - if (parts.join(' ') === 'claude plugin marketplace list --json') {
51 - return { stdout: '[]' };
52 - }
53 - if (parts.join(' ') === 'claude plugin list --json') return { stdout: '[]' };
54 - return {};
43 +const makeSkillInstaller = (initiallyReady = false, failInstall = false) => {
44 + let ready = initiallyReady;
45 + return new SetupSkillInstaller({
46 + isClaudeSkillInstalled: Effect.sync(() => ready),
47 + ensureClaudeSkill: failInstall
48 + ? Effect.fail(new Error('skill download failed'))
49 + : Effect.sync(() => {
50 + const changed = !ready;
51 + ready = true;
52 + return changed;
53 + }),
54 });
55 +};
56
57 - layer(TestLive({ fixture: 'user-config-example', commandRunner: humanRunner }))(
58 - 'Claude plugin install',
59 - it => {
60 - it.scoped('registers and installs the Claude plugin with exact native commands', () =>
61 - Effect.gen(function* () {
62 - humanCommands.length = 0;
63 - yield* cli(['setup', '--target', 'claude', '--yes']);
57 +const defaultHostState = (): FakeHostState => ({
58 + available: false,
59 + marketplace: 'missing',
60 + plugin: 'missing',
61 +});
62
65 - expect(humanCommands).toContainEqual([
66 - 'claude',
67 - 'plugin',
68 - 'marketplace',
69 - 'add',
70 - 'https://github.com/ComposioHQ/composio-plugin-cc.git',
71 - '--scope',
72 - 'user',
73 - ]);
74 - expect(humanCommands).toContainEqual([
75 - 'claude',
76 - 'plugin',
77 - 'install',
78 - 'composio@composio',
79 - '--scope',
80 - 'user',
81 - ]);
63 +const makeFakeHosts = (
64 + initial: Partial<Record<AgentHost, Partial<FakeHostState>>>,
65 + options: { readonly noOp?: boolean; readonly failOn?: string } = {}
66 +) => {
67 + const state: Record<AgentHost, FakeHostState> = {
68 + claude: { ...defaultHostState(), ...initial.claude },
69 + codex: { ...defaultHostState(), ...initial.codex },
70 + };
71 + const commands: string[][] = [];
72
83 - const output = (yield* MockConsole.getLines()).join('\n');
84 - expect(output).toContain('Configured and enabled the Composio plugin for claude');
85 - expect(output).toContain('"success":true');
86 - })
87 - );
73 + const marketplaceOutput = (host: AgentHost): string => {
74 + const current = state[host].marketplace;
75 + const source =
76 + current === 'canonical'
77 + ? host === 'claude'
78 + ? 'https://github.com/ComposioHQ/composio-plugin-cc.git'
79 + : 'ComposioHQ/composio-plugin-openai'
80 + : 'someone-else/not-composio';
81 + if (host === 'claude') {
82 + return current === 'missing'
83 + ? '[]'
84 + : JSON.stringify([{ name: 'composio', source: { source: 'github', repo: source } }]);
85 }
89 - );
90 -
91 - const codexCommands: string[][] = [];
92 - const codexInstalledRunner = makeRunner(parts => {
93 - codexCommands.push([...parts]);
94 - if (parts.join(' ') === 'codex --version') return { stdout: 'codex-cli 0.144.1' };
95 - if (parts.join(' ') === 'codex plugin marketplace list --json') {
96 - return {
97 - stdout: JSON.stringify({
98 - marketplaces: [
99 - {
100 - name: 'composio',
101 - marketplaceSource: {
102 - sourceType: 'git',
103 - source: 'https://github.com/COMPOSIOHQ/composio-plugin-openai.git/',
86 + return JSON.stringify({
87 + marketplaces:
88 + current === 'missing'
89 + ? []
90 + : [
91 + {
92 + name: 'composio',
93 + marketplaceSource: { sourceType: 'git', source },
94 },
105 - },
106 - ],
107 - }),
108 - };
109 - }
110 - if (parts.join(' ') === 'codex plugin list --json') {
111 - return {
112 - stdout: JSON.stringify({
113 - installed: [{ pluginId: 'composio@composio', installed: true, enabled: true }],
114 - }),
115 - };
116 - }
117 - return {};
118 - });
95 + ],
96 + });
97 + };
98
120 - layer(TestLive({ fixture: 'user-config-example', commandRunner: codexInstalledRunner }))(
121 - 'existing Codex install',
122 - it => {
123 - it.scoped('is idempotent when the Codex marketplace and plugin are already installed', () =>
124 - Effect.gen(function* () {
125 - codexCommands.length = 0;
126 - yield* cli(['setup', '--target', 'codex', '--yes']);
127 -
128 - expect(codexCommands).not.toContainEqual([
129 - 'codex',
130 - 'plugin',
131 - 'marketplace',
132 - 'add',
133 - 'https://github.com/ComposioHQ/composio-plugin-openai.git',
134 - '--json',
135 - ]);
136 - expect(codexCommands).not.toContainEqual([
137 - 'codex',
138 - 'plugin',
139 - 'add',
140 - 'composio@composio',
141 - '--json',
142 - ]);
99 + const pluginOutput = (host: AgentHost): string => {
100 + const current = state[host].plugin;
101 + const installed = current !== 'missing';
102 + const enabled = current === 'enabled';
103 + return host === 'claude'
104 + ? JSON.stringify(installed ? [{ id: 'composio@composio', installed, enabled }] : [])
105 + : JSON.stringify({
106 + installed: installed ? [{ pluginId: 'composio@composio', installed, enabled }] : [],
107 + available: [],
108 + });
109 + };
110
144 - const output = (yield* MockConsole.getLines()).join('\n');
145 - expect(output).toContain('already installed and enabled');
146 - expect(output).toContain('"changed":false');
147 - expect(output).toContain('"cli_skill_ready":true');
148 - expect(output).toContain('"success":true');
149 - expect(output).not.toContain('uak_');
150 - expect(process.exitCode).toBeUndefined();
151 - })
152 - );
111 + const runner = makeRunner(parts => {
112 + commands.push([...parts]);
113 + const host = parts[0] as AgentHost;
114 + const command = parts.join(' ');
115 + if (parts[1] === '--version') {
116 + return state[host].available
117 + ? { stdout: host === 'claude' ? '2.1.0' : 'codex-cli 0.144.1' }
118 + : { exitCode: 127, stderr: 'not found' };
119 }
154 - );
155 -
156 - const disabledClaudeCommands: string[][] = [];
157 - const disabledClaudeRunner = makeRunner(parts => {
158 - disabledClaudeCommands.push([...parts]);
159 - if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
160 - if (parts.join(' ') === 'claude plugin marketplace list --json') {
161 - return {
162 - stdout: JSON.stringify([
163 - {
164 - name: 'composio',
165 - source: 'git',
166 - url: 'https://github.com/ComposioHQ/composio-plugin-cc.git',
167 - },
168 - ]),
169 - };
120 + if (command === `${host} plugin marketplace list --json`) {
121 + return { stdout: marketplaceOutput(host) };
122 }
171 - if (parts.join(' ') === 'claude plugin list --json') {
172 - return {
173 - stdout: JSON.stringify([{ id: 'composio@composio', installed: true, enabled: false }]),
174 - };
123 + if (command === `${host} plugin list --json`) {
124 + return { stdout: pluginOutput(host) };
125 + }
126 + if (options.failOn && command.includes(options.failOn)) {
127 + return { exitCode: 2, stderr: 'native operation failed' };
128 + }
129 + if (!options.noOp && command.includes('plugin marketplace add')) {
130 + state[host].marketplace = 'canonical';
131 + }
132 + if (
133 + !options.noOp &&
134 + (command.includes('plugin install') ||
135 + command.includes('plugin enable') ||
136 + command === 'codex plugin add composio@composio --json')
137 + ) {
138 + state[host].plugin = 'enabled';
139 }
140 return {};
141 });
142
179 - layer(TestLive({ fixture: 'user-config-example', commandRunner: disabledClaudeRunner }))(
180 - 'disabled Claude plugin',
181 - it => {
182 - it.scoped('repairs a disabled Claude plugin with the native enable command', () =>
183 - Effect.gen(function* () {
184 - disabledClaudeCommands.length = 0;
185 - yield* cli(['setup', '--target', 'claude', '--yes']);
143 + return { commands, runner, state };
144 +};
145
187 - expect(disabledClaudeCommands).toContainEqual([
188 - 'claude',
189 - 'plugin',
190 - 'enable',
191 - 'composio@composio',
192 - ]);
193 - expect(disabledClaudeCommands).not.toContainEqual([
194 - 'claude',
195 - 'plugin',
196 - 'install',
197 - 'composio@composio',
198 - '--scope',
199 - 'user',
200 - ]);
201 - const output = (yield* MockConsole.getLines()).join('\n');
202 - expect(output).toContain('"plugin_installed":true');
203 - expect(output).toContain('"plugin_enabled":true');
204 - })
205 - );
146 +describe('CLI: composio setup', () => {
147 + afterEach(() => {
148 + vi.restoreAllMocks();
149 + vi.unstubAllEnvs();
150 + process.exitCode = undefined;
151 + });
152
207 - it.scoped('reports a disabled plugin as not enabled in machine status', () =>
208 - Effect.gen(function* () {
209 - disabledClaudeCommands.length = 0;
210 - yield* cli(['setup', 'status', '--json']);
153 + const freshClaude = makeFakeHosts({ claude: { available: true } });
154 + layer(
155 + TestLive({
156 + fixture: 'user-config-example',
157 + commandRunner: freshClaude.runner,
158 + setupSkillInstaller: makeSkillInstaller(),
159 + })
160 + )('fresh Claude install', it => {
161 + it.scoped('uses exact native commands and verifies readiness', () =>
162 + Effect.gen(function* () {
163 + yield* cli(['setup', '--target', 'claude', '--yes']);
164
212 - const lines = yield* MockConsole.getLines();
213 - const jsonLine = lines.filter(line => line.startsWith('{')).at(-1);
214 - const status = JSON.parse(jsonLine ?? '{}') as {
215 - targets?: Array<Record<string, unknown>>;
216 - };
217 - expect(status.targets?.find(item => item.target === 'claude')).toMatchObject({
218 - plugin_installed: true,
219 - plugin_enabled: false,
220 - });
221 - expect(disabledClaudeCommands).not.toContainEqual([
222 - 'claude',
223 - 'plugin',
224 - 'enable',
225 - 'composio@composio',
226 - ]);
227 - })
228 - );
229 - }
230 - );
165 + expect(freshClaude.commands).toContainEqual([
166 + 'claude',
167 + 'plugin',
168 + 'marketplace',
169 + 'add',
170 + 'https://github.com/ComposioHQ/composio-plugin-cc.git',
171 + '--scope',
172 + 'user',
173 + ]);
174 + expect(freshClaude.commands).toContainEqual([
175 + 'claude',
176 + 'plugin',
177 + 'install',
178 + 'composio@composio',
179 + '--scope',
180 + 'user',
181 + ]);
182 + expect(freshClaude.state.claude).toMatchObject({
183 + marketplace: 'canonical',
184 + plugin: 'enabled',
185 + });
186 + expect((yield* MockConsole.getLines()).join('\n')).toContain('"success":true');
187 + })
188 + );
189 + });
190
232 - const disabledCodexCommands: string[][] = [];
233 - const disabledCodexRunner = makeRunner(parts => {
234 - disabledCodexCommands.push([...parts]);
235 - if (parts.join(' ') === 'codex --version') return { stdout: 'codex-cli 0.144.1' };
236 - if (parts.join(' ') === 'codex plugin marketplace list --json') {
237 - return {
238 - stdout: JSON.stringify({
239 - marketplaces: [
240 - {
241 - name: 'composio',
242 - marketplaceSource: {
243 - sourceType: 'git',
244 - source: 'ComposioHQ/composio-plugin-openai',
245 - },
246 - },
247 - ],
248 - }),
249 - };
250 - }
251 - if (parts.join(' ') === 'codex plugin list --json') {
252 - return {
253 - stdout: JSON.stringify({
254 - installed: [{ pluginId: 'composio@composio', installed: true, enabled: false }],
255 - }),
256 - };
257 - }
258 - return {};
191 + const existingCodex = makeFakeHosts({
192 + codex: { available: true, marketplace: 'canonical', plugin: 'enabled' },
193 });
194 + layer(TestLive({ commandRunner: existingCodex.runner }))('existing Codex install', it => {
195 + it.scoped('is idempotent', () =>
196 + Effect.gen(function* () {
197 + yield* cli(['setup', '--target', 'codex', '--yes']);
198
261 - layer(TestLive({ fixture: 'user-config-example', commandRunner: disabledCodexRunner }))(
262 - 'disabled Codex plugin',
263 - it => {
264 - it.scoped('repairs a disabled Codex plugin through its native add path', () =>
199 + expect(existingCodex.commands.some(parts => parts.includes('add'))).toBe(false);
200 + const output = (yield* MockConsole.getLines()).join('\n');
201 + expect(output).toContain('"changed":false');
202 + expect(output).toContain('"success":true');
203 + })
204 + );
205 + });
206 +
207 + for (const host of ['claude', 'codex'] as const) {
208 + const disabled = makeFakeHosts({
209 + [host]: { available: true, marketplace: 'canonical', plugin: 'disabled' },
210 + });
211 + layer(
212 + TestLive({
213 + commandRunner: disabled.runner,
214 + setupSkillInstaller: makeSkillInstaller(true),
215 + })
216 + )(`disabled ${host} plugin`, it => {
217 + it.scoped('repairs the plugin through the native path', () =>
218 Effect.gen(function* () {
266 - disabledCodexCommands.length = 0;
267 - yield* cli(['setup', '--target', 'codex', '--yes']);
219 + yield* cli(['setup', '--target', host, '--yes']);
220
269 - expect(disabledCodexCommands).toContainEqual([
270 - 'codex',
271 - 'plugin',
272 - 'add',
273 - 'composio@composio',
274 - '--json',
275 - ]);
276 - const output = (yield* MockConsole.getLines()).join('\n');
277 - expect(output).toContain('"plugin_installed":true');
278 - expect(output).toContain('"plugin_enabled":true');
279 - expect(output).toContain('"success":true');
221 + expect(disabled.state[host].plugin).toBe('enabled');
222 + expect((yield* MockConsole.getLines()).join('\n')).toContain('"plugin_enabled":true');
223 })
224 );
282 - }
283 - );
225 + });
226 + }
227
285 - const codexFreshCommands: string[][] = [];
286 - const codexFreshRunner = makeRunner(parts => {
287 - codexFreshCommands.push([...parts]);
288 - if (parts.join(' ') === 'codex --version') return { stdout: 'codex-cli 0.144.1' };
289 - if (parts.join(' ') === 'codex plugin marketplace list --json') {
290 - return { stdout: JSON.stringify({ marketplaces: [] }) };
291 - }
292 - if (parts.join(' ') === 'codex plugin list --json') {
293 - return { stdout: JSON.stringify({ installed: [], available: [] }) };
294 - }
295 - return {};
296 - });
297 - const codexBundledSkillInstaller = new SetupSkillInstaller({
298 - isClaudeSkillInstalled: Effect.die(
299 - new Error('Codex setup must not inspect the standalone Claude skill')
300 - ),
301 - ensureClaudeSkill: Effect.die(
302 - new Error('Codex setup must not install a redundant global CLI skill')
303 - ),
304 - });
305 -
306 - layer(
307 - TestLive({
308 - fixture: 'user-config-example',
309 - commandRunner: codexFreshRunner,
310 - setupSkillInstaller: codexBundledSkillInstaller,
311 - })
312 - )('fresh Codex install', it => {
313 - it.scoped('uses the planned OpenAI marketplace and exact Codex commands', () =>
228 + const freshCodex = makeFakeHosts({ codex: { available: true } });
229 + layer(TestLive({ commandRunner: freshCodex.runner }))('fresh Codex install', it => {
230 + it.scoped('uses the public OpenAI marketplace and exact native commands', () =>
231 Effect.gen(function* () {
315 - codexFreshCommands.length = 0;
232 yield* cli(['setup', '--target', 'codex', '--yes']);
233
318 - expect(codexFreshCommands).toContainEqual([
234 + expect(freshCodex.commands).toContainEqual([
235 'codex',
236 'plugin',
237 'marketplace',
@@ -323,79 +239,84 @@ describe('CLI: composio setup', () => {
239 'https://github.com/ComposioHQ/composio-plugin-openai.git',
240 '--json',
241 ]);
326 - expect(codexFreshCommands).toContainEqual([
242 + expect(freshCodex.commands).toContainEqual([
243 'codex',
244 'plugin',
245 'add',
246 'composio@composio',
247 '--json',
248 ]);
333 - const output = (yield* MockConsole.getLines()).join('\n');
334 - expect(output).toContain('"cli_skill_ready":true');
335 - expect(output).toContain('"success":true');
249 })
250 );
251 });
252
340 - const unavailableRunner = makeRunner(() => ({ exitCode: 127, stderr: 'not found' }));
341 - layer(TestLive({ commandRunner: unavailableRunner }))('status', it => {
342 - it.scoped('prints machine-readable status without installing anything', () =>
253 + const autoClaude = makeFakeHosts({ claude: { available: true } });
254 + layer(
255 + TestLive({
256 + commandRunner: autoClaude.runner,
257 + setupSkillInstaller: makeSkillInstaller(),
258 + })
259 + )('automatic setup with one host', it => {
260 + it.scoped('installs only the detected host', () =>
261 Effect.gen(function* () {
344 - yield* cli(['setup', 'status', '--json']);
345 - const lines = yield* MockConsole.getLines();
346 - expect(lines).toHaveLength(1);
347 - expect(JSON.parse(lines[0] ?? '{}')).toMatchObject({
348 - targets: [
349 - { target: 'claude', available: false, cli_skill_ready: false },
350 - { target: 'codex', available: false, cli_skill_ready: false },
351 - ],
352 - });
262 + yield* cli(['setup', '--target', 'auto', '--yes']);
263 +
264 + const output = (yield* MockConsole.getLines()).join('\n');
265 + expect(output).toContain('"target":"claude"');
266 + expect(output).not.toContain('"target":"codex"');
267 })
268 );
269 });
270
357 - const wrongMarketplaceRunner = makeRunner(parts => {
358 - if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
359 - if (parts.join(' ') === 'codex --version') return { exitCode: 127 };
360 - if (parts.join(' ') === 'claude plugin marketplace list --json') {
361 - return {
362 - stdout: JSON.stringify([
363 - {
364 - name: 'composio',
365 - source: { source: 'github', repo: 'someone-else/not-composio' },
366 - },
367 - ]),
368 - };
369 - }
370 - if (parts.join(' ') === 'claude plugin list --json') return { stdout: '[]' };
371 - return {};
271 + const autoBoth = makeFakeHosts({
272 + claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
273 + codex: { available: true, marketplace: 'canonical', plugin: 'enabled' },
274 });
373 - layer(TestLive({ commandRunner: wrongMarketplaceRunner }))('exact marketplace status', it => {
374 - it.scoped('does not accept a same-named marketplace from the wrong repository', () =>
275 + layer(
276 + TestLive({
277 + commandRunner: autoBoth.runner,
278 + setupSkillInstaller: makeSkillInstaller(true),
279 + })
280 + )('automatic setup with both hosts', it => {
281 + it.scoped('selects both detected hosts', () =>
282 Effect.gen(function* () {
376 - yield* cli(['setup', 'status', '--json']);
377 - const [line] = yield* MockConsole.getLines();
378 - const status = JSON.parse(line ?? '{}') as {
379 - targets?: Array<Record<string, unknown>>;
380 - };
381 - expect(status.targets?.find(item => item.target === 'claude')).toMatchObject({
382 - marketplace_configured: false,
383 - });
283 + yield* cli(['setup', '--target', 'auto', '--yes']);
284 +
285 + const output = (yield* MockConsole.getLines()).join('\n');
286 + expect(output).toContain('"target":"claude"');
287 + expect(output).toContain('"target":"codex"');
288 })
289 );
290 });
291
388 - const failingInstallRunner = makeRunner(parts => {
389 - if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
390 - if (parts.join(' ') === 'claude plugin marketplace list --json') return { stdout: '[]' };
391 - if (parts.join(' ') === 'claude plugin list --json') return { stdout: '[]' };
392 - if (parts.includes('install')) return { exitCode: 2, stderr: 'install failed' };
393 - return {};
292 + const unavailable = makeFakeHosts({});
293 + layer(TestLive({ commandRunner: unavailable.runner }))('no supported host', it => {
294 + it.scoped('fails automatic setup', () =>
295 + Effect.gen(function* () {
296 + const exit = yield* Effect.exit(cli(['setup', '--target', 'auto', '--yes']));
297 + expect(Exit.isFailure(exit)).toBe(true);
298 + })
299 + );
300 + });
301 +
302 + const conflict = makeFakeHosts({
303 + claude: { available: true, marketplace: 'conflict' },
304 });
395 - layer(TestLive({ fixture: 'user-config-example', commandRunner: failingInstallRunner }))(
396 - 'partial failure',
305 + layer(TestLive({ commandRunner: conflict.runner }))('marketplace source conflict', it => {
306 + it.scoped('fails safely instead of replacing the marketplace', () =>
307 + Effect.gen(function* () {
308 + const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
309 + expect(Exit.isFailure(exit)).toBe(true);
310 + expect(conflict.state.claude.marketplace).toBe('conflict');
311 + })
312 + );
313 + });
314 +
315 + const noOp = makeFakeHosts({ claude: { available: true } }, { noOp: true });
316 + layer(TestLive({ commandRunner: noOp.runner, setupSkillInstaller: makeSkillInstaller() }))(
317 + 'post-install verification',
318 it => {
398 - it.scoped('fails the command when a native plugin install fails', () =>
319 + it.scoped('fails when successful commands do not change native state', () =>
320 Effect.gen(function* () {
321 const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
322 expect(Exit.isFailure(exit)).toBe(true);
@@ -404,18 +325,29 @@ describe('CLI: composio setup', () => {
325 }
326 );
327
407 - const failingSkillInstaller = new SetupSkillInstaller({
408 - isClaudeSkillInstalled: Effect.succeed(false),
409 - ensureClaudeSkill: Effect.fail(new Error('skill download failed')),
328 + const failedInstall = makeFakeHosts(
329 + { claude: { available: true } },
330 + { failOn: 'plugin install' }
331 + );
332 + layer(TestLive({ commandRunner: failedInstall.runner }))('native install failure', it => {
333 + it.scoped('fails the command', () =>
334 + Effect.gen(function* () {
335 + const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
336 + expect(Exit.isFailure(exit)).toBe(true);
337 + })
338 + );
339 + });
340 +
341 + const skillFailure = makeFakeHosts({
342 + claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
343 });
344 layer(
345 TestLive({
413 - fixture: 'user-config-example',
414 - commandRunner: humanRunner,
415 - setupSkillInstaller: failingSkillInstaller,
346 + commandRunner: skillFailure.runner,
347 + setupSkillInstaller: makeSkillInstaller(false, true),
348 })
417 - )('skill failure', it => {
418 - it.scoped('fails rather than reporting readiness when the required Claude skill fails', () =>
349 + )('skill install failure', it => {
350 + it.scoped('fails instead of reporting readiness', () =>
351 Effect.gen(function* () {
352 const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
353 expect(Exit.isFailure(exit)).toBe(true);
ts/packages/cli/test/src/services/setup-skill-installer.test.ts
+28 -2
@@ -1,8 +1,12 @@
1 -import { writeFileSync } from 'node:fs';
1 +import { mkdirSync, writeFileSync } from 'node:fs';
2 import path from 'node:path';
3 import { describe, expect, it } from 'vitest';
4 import * as tempy from 'tempy';
5 -import { resolveSetupSkillReleaseTag } from 'src/services/setup-skill-installer';
5 +import { SKILL_RELEASE_TAG_FILENAME } from 'src/effects/install-skill';
6 +import {
7 + isClaudeSkillCurrent,
8 + resolveSetupSkillReleaseTag,
9 +} from 'src/services/setup-skill-installer';
10
11 describe('SetupSkillInstaller', () => {
12 it('uses the packaged CLI release tag', () => {
@@ -20,4 +24,26 @@ describe('SetupSkillInstaller', () => {
24 '@composio/cli@0.3.0'
25 );
26 });
27 +
28 + it('only accepts a Claude skill installed from the running CLI release', () => {
29 + const home = tempy.temporaryDirectory();
30 + const target = path.join(home, '.claude', 'skills', 'composio-cli');
31 + const skillDir = path.join(home, '.agents', 'skills', 'composio-cli');
32 + mkdirSync(target, { recursive: true });
33 + mkdirSync(skillDir, { recursive: true });
34 + writeFileSync(
35 + path.join(skillDir, SKILL_RELEASE_TAG_FILENAME),
36 + '@composio/cli@0.2.20-beta.42\n'
37 + );
38 +
39 + expect(isClaudeSkillCurrent(home, '@composio/cli@0.2.20-beta.42')).toBe(true);
40 + expect(isClaudeSkillCurrent(home, '@composio/cli@0.2.20-beta.43')).toBe(false);
41 + });
42 +
43 + it('treats an unversioned existing Claude skill as stale', () => {
44 + const home = tempy.temporaryDirectory();
45 + mkdirSync(path.join(home, '.claude', 'skills', 'composio-cli'), { recursive: true });
46 +
47 + expect(isClaudeSkillCurrent(home, '@composio/cli@0.3.0')).toBe(false);
48 + });
49 });