Skip to content

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

feat(cli): install agent plugins with composio setup

Kshitij Jhunjhunwalaf2beb2f25972
diff --git a/.changeset/cli-setup-agent-plugins.md b/.changeset/cli-setup-agent-plugins.md
new file mode 100644
index 000000000..21b061417
--- /dev/null
+++ b/.changeset/cli-setup-agent-plugins.md
@@ -0,0 +1,5 @@
+---
+'@composio/cli': minor
+---
+
+Add `composio setup` to idempotently install and enable the Composio marketplace and plugin for Claude Code and Codex. Claude setup also installs the matching standalone CLI skill; the Codex plugin bundles it.
diff --git a/docs/content/docs/claude-code-plugin.mdx b/docs/content/docs/claude-code-plugin.mdx
index e590c9047..546b0cd18 100644
--- a/docs/content/docs/claude-code-plugin.mdx
+++ b/docs/content/docs/claude-code-plugin.mdx
@@ -1,62 +1,77 @@
---
title: Claude Code Plugin
-description: Install Composio in Claude Code as a plugin — connect 1000+ apps with managed OAuth and ready-made skills.
-keywords: [claude code, plugin, marketplace, mcp, composio connect, skills]
+description: Install the Composio CLI plugin for Claude Code — connect and act across 1000+ apps with managed authentication.
+keywords: [claude code, plugin, marketplace, composio cli, composio connect, skills]
---
-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.
+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.
-<Callout type="info">
-Looking for the API-key based MCP setup (or other clients like Cursor, Codex, Claude Desktop)? See [Composio Connect](/docs/composio-connect).
-</Callout>
+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).
## What you get
-The plugin ships two things together:
+| Component | Purpose |
+| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **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. |
+| **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. |
+| **`/composio-connect <app>` command** | Connects an app with `composio link` and managed OAuth, then verifies the connection. |
-- **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.
-- **Bundled skills** — pre-written prompts that show Claude how to use the MCP server effectively:
- - **`composio-mcp`** — reference for the 7 meta-tools (`COMPOSIO_SEARCH_TOOLS`, `COMPOSIO_MANAGE_CONNECTIONS`, etc.) and the recommended search → connect → execute flow.
- - **`onboarding`** — interactive setup that asks what you want to automate, recommends 2–4 apps, and walks you through connecting them.
- - **`company-activity-summary`** — cross-app activity summary across Slack, GitHub, Notion, Linear, Gmail, and more.
- - **`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.
+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.
## Install
<Steps>
<Step>
-<StepTitle>Add the Composio marketplace</StepTitle>
+<StepTitle>Install and set up Composio</StepTitle>
-In Claude Code, run:
+If the CLI is not already installed, run:
```bash
-/plugin marketplace add ComposioHQ/composio-plugin-cc
+curl -fsSL https://composio.dev/install | bash
+composio login
+composio setup --target claude
```
-This registers the catalog. No plugins are installed yet.
+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.
</Step>
<Step>
-<StepTitle>Install the Composio plugin</StepTitle>
+<StepTitle>Try it</StepTitle>
-```bash
-/plugin install composio-mcp@composio
-```
+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.
-Restart Claude Code (or run `/reload-plugins`) when prompted.
+You can also connect an app directly:
-</Step>
-<Step>
-<StepTitle>Connect your first app</StepTitle>
-
-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.
+```text
+/composio-connect github
+```
</Step>
</Steps>
+### Manual plugin fallback
+
+If you need to register the plugin directly in Claude Code, add the marketplace:
+
+In Claude Code, run:
+
+```text
+/plugin marketplace add ComposioHQ/composio-plugin-cc
+```
+
+This adds Composio's GitHub-hosted marketplace. It does not install the plugin yet.
+
+Then install the plugin:
+
+```text
+/plugin install composio@composio
+```
+
+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.
+
## Team setup
-To pre-install the plugin for everyone on your team, add this to your project's `.claude/settings.json`:
+To make the marketplace and plugin available to everyone working in a repository, add this to the project's `.claude/settings.json`:
```json title=".claude/settings.json"
{
@@ -69,42 +84,85 @@ To pre-install the plugin for everyone on your team, add this to your project's
}
},
"enabledPlugins": {
- "composio-mcp@composio": true
+ "composio@composio": true
}
}
```
-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.
+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.
+
+## How it works
+
+The plugin keeps the integration lightweight and lets the CLI own its capabilities:
+
+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.
+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.
+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.
+4. **CLI-provided guidance** — the separately installed `composio-cli` skill gives Claude the full command and workflow reference.
+
+The hooks guide Claude; they do not expose tools or execute app actions themselves.
## Updating
-The plugin is versioned via the `version` field in its `plugin.json`. To pull the latest release:
+Plugin updates and CLI updates are separate. Update the marketplace checkout and reload plugins in Claude Code:
-```bash
+```text
/plugin marketplace update composio
/reload-plugins
```
-## How it differs from the API-key MCP setup
+Update the CLI to receive the latest Composio commands, tool-routing behavior, and generated skill:
+
+```bash
+composio upgrade
+```
-Both paths give Claude Code access to the same Composio Connect MCP server and the same 1000+ apps. The differences:
+## Plugin or MCP setup?
-| | Plugin install | `claude mcp add` |
-|---|---|---|
-| Setup steps | Two slash commands | One terminal command, requires copying an API key |
-| Auth | OAuth, no API key in your config | API key in `--header "x-consumer-api-key: ..."` |
-| Bundled skills | Yes (onboarding, routing, summaries) | No |
-| Discoverable in Claude Code marketplace | Yes | No |
-| Updates | `/plugin marketplace update composio` | Manual re-run of `claude mcp add` |
+The Claude Code plugin and the API-key MCP setup are two different ways to use Composio:
-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.
+| | Claude Code plugin | Composio Connect MCP |
+| ------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------- |
+| Runtime | Local `composio` CLI | Remote MCP server |
+| Tool access | Claude runs `composio search`, `composio execute`, and `composio link` | Claude calls Composio's MCP meta-tools |
+| Claude Code integration | Session and prompt hooks plus `/composio-connect` | MCP tools registered with `claude mcp add` |
+| Skill | Installed and updated separately by the CLI | No CLI skill required |
+| Initial Composio authentication | `composio login` | Consumer API key in the MCP configuration |
+| Updates | Update both the marketplace plugin and CLI | Server-side; the MCP configuration remains in Claude Code |
+
+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.
## Source code
-The plugin is open source: [ComposioHQ/composio-plugin-cc](https://github.com/ComposioHQ/composio-plugin-cc). Issues and PRs welcome.
+The plugin is open source at [ComposioHQ/composio-plugin-cc](https://github.com/ComposioHQ/composio-plugin-cc).
## Troubleshooting
-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).
+### The plugin installs, but Claude cannot run Composio
+
+Confirm the CLI is available and that you are signed in:
+
+```bash
+composio --version
+composio whoami
+```
+
+If the first command fails, [install the CLI](#install). If the second reports that you are signed out, run `composio login`.
+
+### The CLI skill is missing
+
+The plugin does not bundle the `composio-cli` skill. Rerun `composio setup --target claude`, or install the skill explicitly:
+
+```bash
+composio --install-skill claude
+```
+
+### Claude does not receive an app-specific nudge
+
+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>`.
+
+### An app is not connected or a tool call fails
+
+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).
-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).
+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).
diff --git a/ts/packages/cli/README.md b/ts/packages/cli/README.md
index 1c8a4fd8c..ad12b1ecb 100644
--- a/ts/packages/cli/README.md
+++ b/ts/packages/cli/README.md
@@ -96,6 +96,15 @@ To pull from the beta channel instead of the stable channel:
composio upgrade --beta
```
+### Plugin setup release dependency
+
+`composio setup` installs plugins from these public marketplace repositories:
+
+- Claude Code: `ComposioHQ/composio-plugin-cc`
+- Codex: `ComposioHQ/composio-plugin-openai`
+
+Both repositories must be publicly accessible with a `composio@composio` entry before releasing a CLI version that advertises automatic plugin setup. The CLI release must also contain `composio-skill.zip`; Claude setup installs that standalone skill, while the Codex plugin bundles its own copy.
+
## Caching
The CLI implements a file-based caching system for improved performance and offline capabilities.
diff --git a/ts/packages/cli/src/cli-main.ts b/ts/packages/cli/src/cli-main.ts
index 439542ff5..8b60bebb7 100644
--- a/ts/packages/cli/src/cli-main.ts
+++ b/ts/packages/cli/src/cli-main.ts
@@ -38,6 +38,7 @@ import {
} from 'src/analytics/events';
import { trackCliEvent, trackCliEventEffect } from 'src/analytics/dispatch';
import { mapOnlyComposioOverrideError } from 'src/services/composio-error-overrides';
+import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type RequiredLayer = Layer.Layer<any, any, never>;
@@ -108,6 +109,7 @@ const layers = Layer.mergeAll(
JsPackageManagerDetector.Default,
ProjectEnvironmentDetector.Default,
CommandRunner.Default,
+ SetupSkillInstaller.Default,
TriggersRealtimeLive,
ProjectContextLive,
BunContext.layer,
diff --git a/ts/packages/cli/src/commands/index.ts b/ts/packages/cli/src/commands/index.ts
index e27f5155d..d7b6bd839 100644
--- a/ts/packages/cli/src/commands/index.ts
+++ b/ts/packages/cli/src/commands/index.ts
@@ -8,6 +8,7 @@ import { upgradeCmd } from './upgrade.cmd';
import { whoamiCmd } from './whoami.cmd';
import { loginCmd } from './login.cmd';
import { signupCmd } from './signup.cmd';
+import { setupCmd } from './setup.cmd';
import { listenCmd } from './listen.cmd';
import { logoutCmd } from './logout.cmd';
import { runCmd } from './run.cmd';
@@ -63,6 +64,7 @@ const ROOT_COMMANDS: ReadonlyArray<TaggedValue<Command.Command<any, any, any, an
tagged(whoamiCmd),
tagged(loginCmd),
tagged(signupCmd),
+ tagged(setupCmd),
tagged(agentCmd),
experimental(CLI_EXPERIMENTAL_FEATURES.LISTEN, listenCmd),
tagged(logoutCmd),
diff --git a/ts/packages/cli/src/commands/root-help.ts b/ts/packages/cli/src/commands/root-help.ts
index cbe096477..91912b96b 100644
--- a/ts/packages/cli/src/commands/root-help.ts
+++ b/ts/packages/cli/src/commands/root-help.ts
@@ -162,6 +162,7 @@ const GENERATE_COMMAND: TaggedValue<CompactCommand> = tagged({
// ── Account commands ───────────────────────────────────────────────────
const ACCOUNT_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
+ tagged({ name: 'setup', description: 'Install agent plugins' }),
tagged({ name: 'login', description: 'Log in to Composio' }),
tagged({ name: 'logout', description: 'Log out from Composio' }),
tagged({ name: 'whoami', description: 'Show current account info' }),
@@ -868,6 +869,25 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
usage: 'composio whoami',
description: 'Display your account information.',
},
+ setup: {
+ usage: 'composio setup [--target auto|claude|codex|all] [--yes]',
+ description: 'Install plugins for supported agent hosts.',
+ examples: [
+ 'composio setup',
+ 'composio setup --target auto --yes',
+ 'composio setup --target all',
+ 'composio setup status --json',
+ ],
+ options: [
+ { name: '--target <target>', description: 'auto, claude, codex, or all' },
+ { name: '-y, --yes', description: 'Accept setup changes without prompting' },
+ ],
+ },
+ 'setup status': {
+ usage: 'composio setup status [--json]',
+ description: 'Inspect agent plugin installation status.',
+ flags: [{ name: '--json', description: 'Print machine-readable JSON' }],
+ },
version: {
usage: 'composio version',
description: 'Display the current Composio CLI version.',
diff --git a/ts/packages/cli/src/commands/setup.cmd.ts b/ts/packages/cli/src/commands/setup.cmd.ts
new file mode 100644
index 000000000..3d1473ceb
--- /dev/null
+++ b/ts/packages/cli/src/commands/setup.cmd.ts
@@ -0,0 +1,110 @@
+import { Command, Options } from '@effect/cli';
+import { Effect } from 'effect';
+import {
+ inspectSetupTargets,
+ installSetupTargets,
+ resolveSetupTargets,
+ SETUP_TARGETS,
+ type SetupTarget,
+} from 'src/services/setup';
+import { TerminalUI } from 'src/services/terminal-ui';
+
+const target = Options.choice('target', SETUP_TARGETS).pipe(
+ Options.withDefault('auto' as SetupTarget),
+ Options.withDescription('Agent host to configure: auto, claude, codex, or all')
+);
+
+const yes = Options.boolean('yes').pipe(
+ Options.withAlias('y'),
+ Options.withDefault(false),
+ Options.withDescription('Accept setup changes without prompting')
+);
+
+const json = Options.boolean('json').pipe(
+ Options.withDefault(false),
+ Options.withDescription('Print machine-readable JSON')
+);
+
+const setupStatusCmd = Command.make('status', { json }).pipe(
+ Command.withDescription('Inspect agent plugin installation status.'),
+ Command.withHandler(({ json }) =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ const targets = yield* inspectSetupTargets;
+ const result = { targets };
+
+ if (!json) {
+ yield* ui.note(
+ [
+ ...targets.map(item => {
+ const state = !item.available
+ ? 'not detected'
+ : !item.plugin_installed
+ ? 'not installed'
+ : item.plugin_enabled
+ ? 'installed and enabled'
+ : 'installed but disabled';
+ return `${item.target}: ${state}`;
+ }),
+ ...targets
+ .filter(item => item.available)
+ .map(
+ item => `${item.target} CLI skill: ${item.cli_skill_ready ? 'ready' : 'not ready'}`
+ ),
+ ].join('\n'),
+ 'Composio setup status'
+ );
+ }
+ yield* ui.output(JSON.stringify(result), { force: json });
+ })
+ )
+);
+
+const setupBaseCmd = Command.make('setup', { target, yes }, ({ target, yes }) =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.intro('composio setup');
+
+ const targets = yield* resolveSetupTargets(target);
+ if (!yes) {
+ const confirmed = yield* ui.confirm(`Install Composio for ${targets.join(' and ')}?`, {
+ defaultValue: true,
+ });
+ if (!confirmed) {
+ yield* ui.outro('Setup cancelled.');
+ return;
+ }
+ }
+
+ const results = yield* installSetupTargets(targets);
+ for (const result of results) {
+ yield* ui.log.success(
+ result.plugin_changed
+ ? `Configured and enabled the Composio plugin for ${result.target}.`
+ : `The Composio plugin for ${result.target} is already installed and enabled.`
+ );
+ if (result.target === 'claude') {
+ yield* ui.log.success(
+ result.skill_changed
+ ? 'Installed the composio-cli skill for Claude Code.'
+ : 'The composio-cli skill for Claude Code is already installed.'
+ );
+ } else {
+ yield* ui.log.success('The Codex plugin includes the composio-cli skill.');
+ }
+ }
+
+ yield* ui.output(
+ JSON.stringify({
+ success: true,
+ targets: results,
+ })
+ );
+ yield* ui.outro('Composio setup complete.');
+ })
+);
+
+export const setupCmd = setupBaseCmd.pipe(
+ Command.withDescription('Install Composio plugins for supported agent hosts.'),
+ Command.withSubcommands([setupStatusCmd])
+);
diff --git a/ts/packages/cli/src/services/command-runner.ts b/ts/packages/cli/src/services/command-runner.ts
index 9d3678fca..6aca7f342 100644
--- a/ts/packages/cli/src/services/command-runner.ts
+++ b/ts/packages/cli/src/services/command-runner.ts
@@ -1,9 +1,29 @@
import { Command } from '@effect/platform';
-import { Effect } from 'effect';
+import { Effect, Stream } from 'effect';
+
+export interface CommandResult {
+ readonly exitCode: number;
+ readonly stdout: string;
+ readonly stderr: string;
+}
+
+const collectText = (stream: Stream.Stream<Uint8Array, unknown>) =>
+ Stream.runFold(stream, '', (output, chunk) => output + new TextDecoder().decode(chunk));
export class CommandRunner extends Effect.Service<CommandRunner>()('services/CommandRunner', {
sync: () => ({
run: (command: Command.Command) => Command.exitCode(command),
+ capture: (command: Command.Command) =>
+ Effect.scoped(
+ Effect.gen(function* () {
+ const process = yield* Command.start(command);
+ const [exitCode, stdout, stderr] = yield* Effect.all(
+ [process.exitCode, collectText(process.stdout), collectText(process.stderr)],
+ { concurrency: 'unbounded' }
+ );
+ return { exitCode: Number(exitCode), stdout, stderr } satisfies CommandResult;
+ })
+ ),
}),
dependencies: [],
}) {}
diff --git a/ts/packages/cli/src/services/setup-skill-installer.ts b/ts/packages/cli/src/services/setup-skill-installer.ts
new file mode 100644
index 000000000..031b47f0a
--- /dev/null
+++ b/ts/packages/cli/src/services/setup-skill-installer.ts
@@ -0,0 +1,32 @@
+import { FileSystem } from '@effect/platform';
+import { Effect } from 'effect';
+import path from 'node:path';
+import { inferSkillReleaseChannel, installSkill } from 'src/effects/install-skill';
+import { APP_VERSION } from 'src/constants';
+import { NodeOs } from './node-os';
+
+export class SetupSkillInstaller extends Effect.Service<SetupSkillInstaller>()(
+ 'services/SetupSkillInstaller',
+ {
+ sync: () => ({
+ isClaudeSkillInstalled: Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const os = yield* NodeOs;
+ return yield* fs.exists(path.join(os.homedir, '.claude', 'skills', 'composio-cli'));
+ }),
+ ensureClaudeSkill: Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const os = yield* NodeOs;
+ const target = path.join(os.homedir, '.claude', 'skills', 'composio-cli');
+ if (yield* fs.exists(target)) return false;
+
+ yield* installSkill({
+ target: 'claude',
+ channel: inferSkillReleaseChannel(APP_VERSION),
+ });
+ return true;
+ }),
+ }),
+ dependencies: [],
+ }
+) {}
diff --git a/ts/packages/cli/src/services/setup.ts b/ts/packages/cli/src/services/setup.ts
new file mode 100644
index 000000000..f6d1db186
--- /dev/null
+++ b/ts/packages/cli/src/services/setup.ts
@@ -0,0 +1,304 @@
+import { Command } from '@effect/platform';
+import { Effect } from 'effect';
+import { CommandRunner, type CommandResult } from './command-runner';
+import { SetupSkillInstaller } from './setup-skill-installer';
+
+export const SETUP_TARGETS = ['auto', 'claude', 'codex', 'all'] as const;
+export type SetupTarget = (typeof SETUP_TARGETS)[number];
+export type AgentHost = Exclude<SetupTarget, 'auto' | 'all'>;
+
+export const CLAUDE_PLUGIN_MARKETPLACE = {
+ name: 'composio',
+ source: 'ComposioHQ/composio-plugin-cc',
+ plugin: 'composio@composio',
+} as const;
+
+export const CODEX_PLUGIN_MARKETPLACE = {
+ name: 'composio',
+ source: 'ComposioHQ/composio-plugin-openai',
+ plugin: 'composio@composio',
+} as const;
+
+export interface SetupTargetStatus {
+ readonly target: AgentHost;
+ readonly available: boolean;
+ readonly marketplace_configured: boolean;
+ readonly plugin_installed: boolean;
+ readonly plugin_enabled: boolean;
+ /** Whether this host can load the authenticated composio-cli skill. */
+ readonly cli_skill_ready: boolean;
+}
+
+export interface SetupTargetResult extends SetupTargetStatus {
+ readonly changed: boolean;
+ readonly plugin_changed: boolean;
+ readonly skill_changed: boolean;
+}
+
+interface SetupTargetAdapter {
+ readonly target: AgentHost;
+ readonly executable: string;
+ readonly marketplace: typeof CLAUDE_PLUGIN_MARKETPLACE | typeof CODEX_PLUGIN_MARKETPLACE;
+ readonly marketplaceListArgs: ReadonlyArray<string>;
+ readonly pluginListArgs: ReadonlyArray<string>;
+ readonly marketplaceAddArgs: ReadonlyArray<string>;
+ readonly pluginInstallArgs: ReadonlyArray<string>;
+ readonly pluginEnableArgs: ReadonlyArray<string>;
+}
+
+const CLAUDE_ADAPTER: SetupTargetAdapter = {
+ target: 'claude',
+ executable: 'claude',
+ marketplace: CLAUDE_PLUGIN_MARKETPLACE,
+ marketplaceListArgs: ['plugin', 'marketplace', 'list', '--json'],
+ pluginListArgs: ['plugin', 'list', '--json'],
+ marketplaceAddArgs: [
+ 'plugin',
+ 'marketplace',
+ 'add',
+ CLAUDE_PLUGIN_MARKETPLACE.source,
+ '--scope',
+ 'user',
+ ],
+ pluginInstallArgs: ['plugin', 'install', CLAUDE_PLUGIN_MARKETPLACE.plugin, '--scope', 'user'],
+ pluginEnableArgs: ['plugin', 'enable', CLAUDE_PLUGIN_MARKETPLACE.plugin],
+};
+
+const CODEX_ADAPTER: SetupTargetAdapter = {
+ target: 'codex',
+ executable: 'codex',
+ marketplace: CODEX_PLUGIN_MARKETPLACE,
+ marketplaceListArgs: ['plugin', 'marketplace', 'list', '--json'],
+ pluginListArgs: ['plugin', 'list', '--json'],
+ marketplaceAddArgs: ['plugin', 'marketplace', 'add', CODEX_PLUGIN_MARKETPLACE.source, '--json'],
+ pluginInstallArgs: ['plugin', 'add', CODEX_PLUGIN_MARKETPLACE.plugin, '--json'],
+ // Codex has no separate enable command. Re-adding is its native install/repair path.
+ pluginEnableArgs: ['plugin', 'add', CODEX_PLUGIN_MARKETPLACE.plugin, '--json'],
+};
+
+const ADAPTERS: ReadonlyArray<SetupTargetAdapter> = [CLAUDE_ADAPTER, CODEX_ADAPTER];
+
+const asRecord = (value: unknown): Record<string, unknown> | undefined =>
+ value !== null && typeof value === 'object' && !Array.isArray(value)
+ ? (value as Record<string, unknown>)
+ : undefined;
+
+const parseJson = (value: string): unknown => {
+ try {
+ return JSON.parse(value) as unknown;
+ } catch {
+ return undefined;
+ }
+};
+
+const recordsFrom = (value: unknown, key?: string): ReadonlyArray<Record<string, unknown>> => {
+ const selected = key ? asRecord(value)?.[key] : value;
+ return Array.isArray(selected)
+ ? selected.flatMap(item => {
+ const record = asRecord(item);
+ return record ? [record] : [];
+ })
+ : [];
+};
+
+const normalizeGitHubRepository = (value: string): string | undefined => {
+ const trimmed = value.trim();
+ if (!trimmed) return undefined;
+
+ let repository = trimmed;
+ const scpStyle = /^git@github\.com:(.+)$/i.exec(repository);
+ if (scpStyle) {
+ repository = scpStyle[1] ?? '';
+ } else if (/^[a-z][a-z0-9+.-]*:\/\//i.test(repository)) {
+ try {
+ const url = new URL(repository);
+ if (url.hostname.toLowerCase() !== 'github.com') return undefined;
+ repository = url.pathname;
+ } catch {
+ return undefined;
+ }
+ }
+
+ repository = repository.replace(/^\/+|\/+$/g, '').replace(/\.git$/i, '');
+ const parts = repository.split('/');
+ if (parts.length !== 2 || parts.some(part => !/^[a-z0-9._-]+$/i.test(part))) {
+ return undefined;
+ }
+ return parts.join('/').toLowerCase();
+};
+
+const marketplaceIsConfigured = (adapter: SetupTargetAdapter, output: string): boolean => {
+ const parsed = parseJson(output);
+ const records = recordsFrom(parsed, adapter.target === 'codex' ? 'marketplaces' : undefined);
+ return records.some(record => {
+ const repo = typeof record.repo === 'string' ? record.repo : undefined;
+ const nestedSource = asRecord(record.source);
+ const marketplaceSource = asRecord(record.marketplaceSource);
+ const source =
+ (typeof record.source === 'string' ? record.source : undefined) ??
+ (typeof nestedSource?.repo === 'string' ? nestedSource.repo : undefined) ??
+ (typeof nestedSource?.source === 'string' ? nestedSource.source : undefined) ??
+ (typeof marketplaceSource?.source === 'string' ? marketplaceSource.source : undefined);
+ const expected = normalizeGitHubRepository(adapter.marketplace.source);
+ return [repo, source].some(
+ candidate =>
+ typeof candidate === 'string' && normalizeGitHubRepository(candidate) === expected
+ );
+ });
+};
+
+const pluginState = (
+ adapter: SetupTargetAdapter,
+ output: string
+): { readonly installed: boolean; readonly enabled: boolean } => {
+ const parsed = parseJson(output);
+ const records = recordsFrom(parsed, adapter.target === 'codex' ? 'installed' : undefined);
+ const plugin = records.find(record => {
+ const id = record.id ?? record.pluginId;
+ return id === adapter.marketplace.plugin;
+ });
+ if (!plugin || plugin.installed === false) return { installed: false, enabled: false };
+ return { installed: true, enabled: plugin.enabled !== false };
+};
+
+const capture = (executable: string, args: ReadonlyArray<string>) =>
+ Effect.gen(function* () {
+ const runner = yield* CommandRunner;
+ return yield* runner
+ .capture(Command.make(executable, ...args))
+ .pipe(Effect.catchAll(() => Effect.succeed<CommandResult | undefined>(undefined)));
+ });
+
+const inspectAdapter = (adapter: SetupTargetAdapter) =>
+ Effect.gen(function* () {
+ const skillInstaller = yield* SetupSkillInstaller;
+ const version = yield* capture(adapter.executable, ['--version']);
+ if (!version || version.exitCode !== 0) {
+ return {
+ target: adapter.target,
+ available: false,
+ marketplace_configured: false,
+ plugin_installed: false,
+ plugin_enabled: false,
+ cli_skill_ready: false,
+ } satisfies SetupTargetStatus;
+ }
+
+ const [marketplaces, plugins] = yield* Effect.all([
+ capture(adapter.executable, adapter.marketplaceListArgs),
+ capture(adapter.executable, adapter.pluginListArgs),
+ ]);
+ const plugin =
+ plugins && plugins.exitCode === 0
+ ? pluginState(adapter, plugins.stdout)
+ : { installed: false, enabled: false };
+
+ const pluginReady = plugin.installed && plugin.enabled;
+ return {
+ target: adapter.target,
+ available: true,
+ marketplace_configured: Boolean(
+ marketplaces &&
+ marketplaces.exitCode === 0 &&
+ marketplaceIsConfigured(adapter, marketplaces.stdout)
+ ),
+ plugin_installed: plugin.installed,
+ plugin_enabled: plugin.enabled,
+ // Codex loads the composio-cli skill from the plugin package itself. Claude's
+ // plugin uses the standalone skill installed from the matching CLI release.
+ cli_skill_ready:
+ adapter.target === 'codex' ? pluginReady : yield* skillInstaller.isClaudeSkillInstalled,
+ } satisfies SetupTargetStatus;
+ });
+
+const runRequired = (adapter: SetupTargetAdapter, args: ReadonlyArray<string>, operation: string) =>
+ Effect.gen(function* () {
+ const runner = yield* CommandRunner;
+ const result = yield* runner.capture(Command.make(adapter.executable, ...args));
+ if (result.exitCode !== 0) {
+ const detail = result.stderr.trim() || result.stdout.trim();
+ return yield* Effect.fail(
+ new Error(`${operation} failed${detail ? `: ${detail}` : ` (exit ${result.exitCode})`}`)
+ );
+ }
+ });
+
+const installAdapter = (adapter: SetupTargetAdapter) =>
+ Effect.gen(function* () {
+ const initial = yield* inspectAdapter(adapter);
+ if (!initial.available) {
+ return yield* Effect.fail(
+ new Error(
+ `${adapter.executable} is not installed or not available on PATH. Install it and rerun \`composio setup --target ${adapter.target}\`.`
+ )
+ );
+ }
+
+ let pluginChanged = false;
+ if (!initial.marketplace_configured) {
+ yield* runRequired(
+ adapter,
+ adapter.marketplaceAddArgs,
+ `Adding the ${adapter.target} marketplace`
+ );
+ pluginChanged = true;
+ }
+ if (!initial.plugin_installed) {
+ yield* runRequired(
+ adapter,
+ adapter.pluginInstallArgs,
+ `Installing the ${adapter.target} plugin`
+ );
+ pluginChanged = true;
+ } else if (!initial.plugin_enabled) {
+ yield* runRequired(
+ adapter,
+ adapter.pluginEnableArgs,
+ `Enabling the ${adapter.target} plugin`
+ );
+ pluginChanged = true;
+ }
+
+ const skillInstaller = yield* SetupSkillInstaller;
+ const skillChanged =
+ adapter.target === 'claude' && !initial.cli_skill_ready
+ ? yield* skillInstaller.ensureClaudeSkill
+ : false;
+
+ return {
+ target: adapter.target,
+ available: true,
+ marketplace_configured: true,
+ plugin_installed: true,
+ plugin_enabled: true,
+ cli_skill_ready: true,
+ changed: pluginChanged || skillChanged,
+ plugin_changed: pluginChanged,
+ skill_changed: skillChanged,
+ } satisfies SetupTargetResult;
+ });
+
+export const inspectSetupTargets = Effect.all(ADAPTERS.map(inspectAdapter));
+
+export const resolveSetupTargets = (target: SetupTarget) =>
+ Effect.gen(function* () {
+ if (target === 'claude' || target === 'codex') return [target] as const;
+ if (target === 'all') return ['claude', 'codex'] as const;
+
+ const statuses = yield* inspectSetupTargets;
+ const detected = statuses.filter(status => status.available).map(status => status.target);
+ if (detected.length === 0) {
+ return yield* Effect.fail(
+ new Error(
+ 'No supported agent host was detected. Install Claude Code or Codex, or pass `--target claude|codex` after installing it.'
+ )
+ );
+ }
+ return detected;
+ });
+
+export const installSetupTargets = (targets: ReadonlyArray<AgentHost>) =>
+ Effect.forEach(targets, target => {
+ const adapter = ADAPTERS.find(candidate => candidate.target === target);
+ return installAdapter(adapter as SetupTargetAdapter);
+ });
diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.ts
index 35aa8818c..cba02a181 100644
--- a/ts/packages/cli/test/__utils__/services/test-layer.ts
+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts
@@ -69,6 +69,7 @@ import { ProjectEnvironmentDetector } from 'src/services/project-environment-det
import { CommandRunner } from 'src/services/command-runner';
import { TerminalUI } from 'src/services/terminal-ui';
import { CommandExecutor } from '@effect/platform';
+import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
export interface TestLiveInput {
/**
@@ -198,6 +199,9 @@ export interface TestLiveInput {
*/
commandRunner?: CommandRunner;
+ /** Override setup's Claude skill installer. Defaults to an idempotent no-op. */
+ setupSkillInstaller?: SetupSkillInstaller;
+
/**
* Override TerminalUI behavior for tests.
* When set, replaces the default TerminalUITest (which auto-selects first option).
@@ -1235,6 +1239,12 @@ export const TestLayer = (input?: TestLiveInput) =>
CommandRunner,
new CommandRunner({
run: () => Effect.succeed(CommandExecutor.ExitCode(0)),
+ capture: () =>
+ Effect.succeed({
+ exitCode: 0,
+ stdout: '',
+ stderr: '',
+ }),
})
);
@@ -1243,6 +1253,15 @@ export const TestLayer = (input?: TestLiveInput) =>
? Layer.succeed(TerminalUI, input.terminalUI)
: TerminalUITest;
+ const SetupSkillInstallerTest = Layer.succeed(
+ SetupSkillInstaller,
+ input?.setupSkillInstaller ??
+ new SetupSkillInstaller({
+ isClaudeSkillInstalled: Effect.succeed(false),
+ ensureClaudeSkill: Effect.succeed(false),
+ })
+ );
+
const _console = yield* MockConsole.make;
const layers = Layer.mergeAll(
@@ -1259,6 +1278,7 @@ export const TestLayer = (input?: TestLiveInput) =>
JsPackageManagerDetector.Default,
ProjectEnvironmentDetector.Default,
CommandRunnerTest,
+ SetupSkillInstallerTest,
ToolsExecutorTest,
BunFileSystem.layer,
BunContext.layer,
diff --git a/ts/packages/cli/test/src/commands/setup.cmd.test.ts b/ts/packages/cli/test/src/commands/setup.cmd.test.ts
new file mode 100644
index 000000000..9769d14ea
--- /dev/null
+++ b/ts/packages/cli/test/src/commands/setup.cmd.test.ts
@@ -0,0 +1,424 @@
+import { Command, CommandExecutor } from '@effect/platform';
+import { describe, expect, layer } from '@effect/vitest';
+import { Effect, Exit } from 'effect';
+import { afterEach, vi } from 'vitest';
+import { CommandRunner } from 'src/services/command-runner';
+import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
+import { cli, MockConsole, TestLive } from 'test/__utils__';
+
+const commandParts = (command: Command.Command): ReadonlyArray<string> => {
+ const flattened = Command.flatten(command);
+ const first = flattened[0];
+ return [first.command, ...first.args];
+};
+
+const makeRunner = (
+ respond: (parts: ReadonlyArray<string>) => {
+ readonly exitCode?: number;
+ readonly stdout?: string;
+ readonly stderr?: string;
+ },
+ onRun: (parts: ReadonlyArray<string>) => void = () => undefined
+) =>
+ new CommandRunner({
+ run: command =>
+ Effect.sync(() => {
+ onRun(commandParts(command));
+ return CommandExecutor.ExitCode(0);
+ }),
+ capture: command => {
+ const result = respond(commandParts(command));
+ return Effect.succeed({
+ exitCode: result.exitCode ?? 0,
+ stdout: result.stdout ?? '',
+ stderr: result.stderr ?? '',
+ });
+ },
+ });
+
+describe('CLI: composio setup', () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ vi.unstubAllEnvs();
+ process.exitCode = undefined;
+ });
+
+ const humanCommands: string[][] = [];
+ const humanRunner = makeRunner(parts => {
+ humanCommands.push([...parts]);
+ if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
+ if (parts.join(' ') === 'claude plugin marketplace list --json') {
+ return { stdout: '[]' };
+ }
+ if (parts.join(' ') === 'claude plugin list --json') return { stdout: '[]' };
+ return {};
+ });
+
+ layer(TestLive({ fixture: 'user-config-example', commandRunner: humanRunner }))(
+ 'Claude plugin install',
+ it => {
+ it.scoped('registers and installs the Claude plugin with exact native commands', () =>
+ Effect.gen(function* () {
+ humanCommands.length = 0;
+ yield* cli(['setup', '--target', 'claude', '--yes']);
+
+ expect(humanCommands).toContainEqual([
+ 'claude',
+ 'plugin',
+ 'marketplace',
+ 'add',
+ 'ComposioHQ/composio-plugin-cc',
+ '--scope',
+ 'user',
+ ]);
+ expect(humanCommands).toContainEqual([
+ 'claude',
+ 'plugin',
+ 'install',
+ 'composio@composio',
+ '--scope',
+ 'user',
+ ]);
+
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('Configured and enabled the Composio plugin for claude');
+ expect(output).toContain('"success":true');
+ })
+ );
+ }
+ );
+
+ const codexCommands: string[][] = [];
+ const codexInstalledRunner = makeRunner(parts => {
+ codexCommands.push([...parts]);
+ if (parts.join(' ') === 'codex --version') return { stdout: 'codex-cli 0.144.1' };
+ if (parts.join(' ') === 'codex plugin marketplace list --json') {
+ return {
+ stdout: JSON.stringify({
+ marketplaces: [
+ {
+ name: 'composio',
+ marketplaceSource: {
+ sourceType: 'git',
+ source: 'https://github.com/COMPOSIOHQ/composio-plugin-openai.git/',
+ },
+ },
+ ],
+ }),
+ };
+ }
+ if (parts.join(' ') === 'codex plugin list --json') {
+ return {
+ stdout: JSON.stringify({
+ installed: [{ pluginId: 'composio@composio', installed: true, enabled: true }],
+ }),
+ };
+ }
+ return {};
+ });
+
+ layer(TestLive({ fixture: 'user-config-example', commandRunner: codexInstalledRunner }))(
+ 'existing Codex install',
+ it => {
+ it.scoped('is idempotent when the Codex marketplace and plugin are already installed', () =>
+ Effect.gen(function* () {
+ codexCommands.length = 0;
+ yield* cli(['setup', '--target', 'codex', '--yes']);
+
+ expect(codexCommands).not.toContainEqual([
+ 'codex',
+ 'plugin',
+ 'marketplace',
+ 'add',
+ 'ComposioHQ/composio-plugin-openai',
+ '--json',
+ ]);
+ expect(codexCommands).not.toContainEqual([
+ 'codex',
+ 'plugin',
+ 'add',
+ 'composio@composio',
+ '--json',
+ ]);
+
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('already installed and enabled');
+ expect(output).toContain('"changed":false');
+ expect(output).toContain('"cli_skill_ready":true');
+ expect(output).toContain('"success":true');
+ expect(output).not.toContain('uak_');
+ expect(process.exitCode).toBeUndefined();
+ })
+ );
+ }
+ );
+
+ const disabledClaudeCommands: string[][] = [];
+ const disabledClaudeRunner = makeRunner(parts => {
+ disabledClaudeCommands.push([...parts]);
+ if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
+ if (parts.join(' ') === 'claude plugin marketplace list --json') {
+ return {
+ stdout: JSON.stringify([
+ {
+ name: 'composio',
+ source: { source: 'github', repo: 'ComposioHQ/composio-plugin-cc' },
+ },
+ ]),
+ };
+ }
+ if (parts.join(' ') === 'claude plugin list --json') {
+ return {
+ stdout: JSON.stringify([{ id: 'composio@composio', installed: true, enabled: false }]),
+ };
+ }
+ return {};
+ });
+
+ layer(TestLive({ fixture: 'user-config-example', commandRunner: disabledClaudeRunner }))(
+ 'disabled Claude plugin',
+ it => {
+ it.scoped('repairs a disabled Claude plugin with the native enable command', () =>
+ Effect.gen(function* () {
+ disabledClaudeCommands.length = 0;
+ yield* cli(['setup', '--target', 'claude', '--yes']);
+
+ expect(disabledClaudeCommands).toContainEqual([
+ 'claude',
+ 'plugin',
+ 'enable',
+ 'composio@composio',
+ ]);
+ expect(disabledClaudeCommands).not.toContainEqual([
+ 'claude',
+ 'plugin',
+ 'install',
+ 'composio@composio',
+ '--scope',
+ 'user',
+ ]);
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('"plugin_installed":true');
+ expect(output).toContain('"plugin_enabled":true');
+ })
+ );
+
+ it.scoped('reports a disabled plugin as not enabled in machine status', () =>
+ Effect.gen(function* () {
+ disabledClaudeCommands.length = 0;
+ yield* cli(['setup', 'status', '--json']);
+
+ const lines = yield* MockConsole.getLines();
+ const jsonLine = lines.filter(line => line.startsWith('{')).at(-1);
+ const status = JSON.parse(jsonLine ?? '{}') as {
+ targets?: Array<Record<string, unknown>>;
+ };
+ expect(status.targets?.find(item => item.target === 'claude')).toMatchObject({
+ plugin_installed: true,
+ plugin_enabled: false,
+ });
+ expect(disabledClaudeCommands).not.toContainEqual([
+ 'claude',
+ 'plugin',
+ 'enable',
+ 'composio@composio',
+ ]);
+ })
+ );
+ }
+ );
+
+ const disabledCodexCommands: string[][] = [];
+ const disabledCodexRunner = makeRunner(parts => {
+ disabledCodexCommands.push([...parts]);
+ if (parts.join(' ') === 'codex --version') return { stdout: 'codex-cli 0.144.1' };
+ if (parts.join(' ') === 'codex plugin marketplace list --json') {
+ return {
+ stdout: JSON.stringify({
+ marketplaces: [
+ {
+ name: 'composio',
+ marketplaceSource: {
+ sourceType: 'git',
+ source: 'ComposioHQ/composio-plugin-openai',
+ },
+ },
+ ],
+ }),
+ };
+ }
+ if (parts.join(' ') === 'codex plugin list --json') {
+ return {
+ stdout: JSON.stringify({
+ installed: [{ pluginId: 'composio@composio', installed: true, enabled: false }],
+ }),
+ };
+ }
+ return {};
+ });
+
+ layer(TestLive({ fixture: 'user-config-example', commandRunner: disabledCodexRunner }))(
+ 'disabled Codex plugin',
+ it => {
+ it.scoped('repairs a disabled Codex plugin through its native add path', () =>
+ Effect.gen(function* () {
+ disabledCodexCommands.length = 0;
+ yield* cli(['setup', '--target', 'codex', '--yes']);
+
+ expect(disabledCodexCommands).toContainEqual([
+ 'codex',
+ 'plugin',
+ 'add',
+ 'composio@composio',
+ '--json',
+ ]);
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('"plugin_installed":true');
+ expect(output).toContain('"plugin_enabled":true');
+ expect(output).toContain('"success":true');
+ })
+ );
+ }
+ );
+
+ const codexFreshCommands: string[][] = [];
+ const codexFreshRunner = makeRunner(parts => {
+ codexFreshCommands.push([...parts]);
+ if (parts.join(' ') === 'codex --version') return { stdout: 'codex-cli 0.144.1' };
+ if (parts.join(' ') === 'codex plugin marketplace list --json') {
+ return { stdout: JSON.stringify({ marketplaces: [] }) };
+ }
+ if (parts.join(' ') === 'codex plugin list --json') {
+ return { stdout: JSON.stringify({ installed: [], available: [] }) };
+ }
+ return {};
+ });
+ const codexBundledSkillInstaller = new SetupSkillInstaller({
+ isClaudeSkillInstalled: Effect.die(
+ new Error('Codex setup must not inspect the standalone Claude skill')
+ ),
+ ensureClaudeSkill: Effect.die(
+ new Error('Codex setup must not install a redundant global CLI skill')
+ ),
+ });
+
+ layer(
+ TestLive({
+ fixture: 'user-config-example',
+ commandRunner: codexFreshRunner,
+ setupSkillInstaller: codexBundledSkillInstaller,
+ })
+ )('fresh Codex install', it => {
+ it.scoped('uses the planned OpenAI marketplace and exact Codex commands', () =>
+ Effect.gen(function* () {
+ codexFreshCommands.length = 0;
+ yield* cli(['setup', '--target', 'codex', '--yes']);
+
+ expect(codexFreshCommands).toContainEqual([
+ 'codex',
+ 'plugin',
+ 'marketplace',
+ 'add',
+ 'ComposioHQ/composio-plugin-openai',
+ '--json',
+ ]);
+ expect(codexFreshCommands).toContainEqual([
+ 'codex',
+ 'plugin',
+ 'add',
+ 'composio@composio',
+ '--json',
+ ]);
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('"cli_skill_ready":true');
+ expect(output).toContain('"success":true');
+ })
+ );
+ });
+
+ const unavailableRunner = makeRunner(() => ({ exitCode: 127, stderr: 'not found' }));
+ layer(TestLive({ commandRunner: unavailableRunner }))('status', it => {
+ it.scoped('prints machine-readable status without installing anything', () =>
+ Effect.gen(function* () {
+ yield* cli(['setup', 'status', '--json']);
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toHaveLength(1);
+ expect(JSON.parse(lines[0] ?? '{}')).toMatchObject({
+ targets: [
+ { target: 'claude', available: false, cli_skill_ready: false },
+ { target: 'codex', available: false, cli_skill_ready: false },
+ ],
+ });
+ })
+ );
+ });
+
+ const wrongMarketplaceRunner = makeRunner(parts => {
+ if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
+ if (parts.join(' ') === 'codex --version') return { exitCode: 127 };
+ if (parts.join(' ') === 'claude plugin marketplace list --json') {
+ return {
+ stdout: JSON.stringify([
+ {
+ name: 'composio',
+ source: { source: 'github', repo: 'someone-else/not-composio' },
+ },
+ ]),
+ };
+ }
+ if (parts.join(' ') === 'claude plugin list --json') return { stdout: '[]' };
+ return {};
+ });
+ layer(TestLive({ commandRunner: wrongMarketplaceRunner }))('exact marketplace status', it => {
+ it.scoped('does not accept a same-named marketplace from the wrong repository', () =>
+ Effect.gen(function* () {
+ yield* cli(['setup', 'status', '--json']);
+ const [line] = yield* MockConsole.getLines();
+ const status = JSON.parse(line ?? '{}') as {
+ targets?: Array<Record<string, unknown>>;
+ };
+ expect(status.targets?.find(item => item.target === 'claude')).toMatchObject({
+ marketplace_configured: false,
+ });
+ })
+ );
+ });
+
+ const failingInstallRunner = makeRunner(parts => {
+ if (parts.join(' ') === 'claude --version') return { stdout: '2.1.0' };
+ if (parts.join(' ') === 'claude plugin marketplace list --json') return { stdout: '[]' };
+ if (parts.join(' ') === 'claude plugin list --json') return { stdout: '[]' };
+ if (parts.includes('install')) return { exitCode: 2, stderr: 'install failed' };
+ return {};
+ });
+ layer(TestLive({ fixture: 'user-config-example', commandRunner: failingInstallRunner }))(
+ 'partial failure',
+ it => {
+ it.scoped('fails the command when a native plugin install fails', () =>
+ Effect.gen(function* () {
+ const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
+ expect(Exit.isFailure(exit)).toBe(true);
+ })
+ );
+ }
+ );
+
+ const failingSkillInstaller = new SetupSkillInstaller({
+ isClaudeSkillInstalled: Effect.succeed(false),
+ ensureClaudeSkill: Effect.fail(new Error('skill download failed')),
+ });
+ layer(
+ TestLive({
+ fixture: 'user-config-example',
+ commandRunner: humanRunner,
+ setupSkillInstaller: failingSkillInstaller,
+ })
+ )('skill failure', it => {
+ it.scoped('fails rather than reporting readiness when the required Claude skill fails', () =>
+ Effect.gen(function* () {
+ const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
+ expect(Exit.isFailure(exit)).toBe(true);
+ })
+ );
+ });
+});