@devries-cameron20 / composio-1 / commits / 5a5b5a330
Fork 0

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

refactor(cli): flatten the plugin-adoption telemetry plumbing

Keep SetupCommandError in services/setup.ts with its reasonCode, read the code structurally in analytics/events.ts, raise the two validate-stage failures as SetupCommandError directly instead of a second reason-code layer, fold the host install probe into agent-host-env.ts, pass the host presence booleans straight through on CLI_SETUP_HOST_DETECTED, and track the plugin hint where it is printed. Event names and properties are unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Kshitij Jhunjhunwala committed Sep 15, 2026 at 13:44 UTC 5a5b5a3308477ff6244ce88539006e0bea8d186c
12 files changed +269 -439
ts/packages/cli/src/analytics/events.ts
+12 -22
@@ -1,10 +1,10 @@
1 import type { CliCommandTelemetryContext, TrackEvent } from './types';
2 +import { Predicate } from 'effect';
3 import { APP_VERSION } from 'src/constants';
4 import { inferSkillReleaseChannel } from 'src/effects/install-skill';
5 import type { AgentHost } from 'src/services/agent-host';
6 import type { AgentHostEnv } from 'src/services/agent-host-env';
7 import type { CliInvocationContext } from 'src/services/runtime-cli-context';
7 -import { setupFailureReasonCodeOf } from 'src/services/setup-command-error';
8 import { ToolInputValidationError } from 'src/services/tool-input-validation';
9 import { guessToolkitFromToolSlug } from 'src/utils/toolkit-from-tool-slug';
10
@@ -245,6 +245,13 @@ const extractUnknownKeys = (issues: ReadonlyArray<string>): ReadonlyArray<string
245 const errorNameOf = (error: unknown): string =>
246 error instanceof Error && error.name ? error.name : 'UnknownError';
247
248 +const failureReasonProperties = (error: unknown) => {
249 + if (Predicate.hasProperty(error, 'reasonCode') && Predicate.isString(error.reasonCode)) {
250 + return { failure_reason_code: error.reasonCode };
251 + }
252 + return {};
253 +};
254 +
255 const isFlagPresent = (argv: ReadonlyArray<string>, ...flags: string[]): boolean =>
256 argv.slice(2).some(token => {
257 if (flags.includes(token)) return true;
@@ -545,13 +552,8 @@ type SpecialLifecycleFamily = {
552 readonly succeededEventName: CliAnalyticsEventName;
553 readonly failedEventName: CliAnalyticsEventName;
554 readonly getProperties: (context: CliCommandTelemetryContext) => Record<string, unknown>;
548 - readonly getFailureProperties?: (error: unknown) => Record<string, unknown>;
555 };
556
551 -const getSetupFailureProperties = (error: unknown) => ({
552 - failure_reason_code: setupFailureReasonCodeOf(error),
553 -});
554 -
557 const SPECIAL_LIFECYCLE_FAMILIES: ReadonlyArray<SpecialLifecycleFamily> = [
558 {
559 match: isExecuteCommand,
@@ -615,7 +617,6 @@ const SPECIAL_LIFECYCLE_FAMILIES: ReadonlyArray<SpecialLifecycleFamily> = [
617 succeededEventName: CLI_ANALYTICS_EVENTS.CLI_SETUP_SUCCEEDED,
618 failedEventName: CLI_ANALYTICS_EVENTS.CLI_SETUP_FAILED,
619 getProperties: getSetupCommandProperties,
618 - getFailureProperties: getSetupFailureProperties,
620 },
621 ];
622
@@ -653,12 +654,12 @@ export const getPrimaryLifecycleFailedEvent = (
654 return buildEvent(family.failedEventName, {
655 ...family.getProperties(context),
656 error_name: errorNameOf(error),
656 - ...family.getFailureProperties?.(error),
657 + ...failureReasonProperties(error),
658 });
659 };
660
661 export const getPluginHintShownEvent = (params: {
661 - readonly invocationOrigin: string | undefined;
662 + readonly invocationOrigin: string;
663 readonly cliVersion: string;
664 readonly commandPath: string;
665 readonly agentHost: AgentHost;
@@ -712,18 +713,6 @@ export const getPluginLifecycleFailedEvent = (params: {
713 error_name: errorNameOf(params.error),
714 });
715
715 -const hostAbsenceProperties = (params: {
716 - readonly available: boolean;
717 - readonly hostConfigDirPresent?: boolean;
718 - readonly hostBinaryInKnownPaths?: boolean;
719 -}) => {
720 - if (params.available) return {};
721 - return {
722 - host_config_dir_present: params.hostConfigDirPresent,
723 - host_binary_in_known_paths: params.hostBinaryInKnownPaths,
724 - };
725 -};
726 -
716 export const getSetupHostDetectedEvent = (params: {
717 readonly operation: 'setup' | 'uninstall';
718 readonly requestedTarget: 'auto' | 'claude' | 'codex' | 'all';
@@ -750,7 +739,8 @@ export const getSetupHostDetectedEvent = (params: {
739 supported: params.supported,
740 host_version: params.hostVersion,
741 unsupported_reason_code: params.unsupportedReasonCode,
753 - ...hostAbsenceProperties(params),
742 + host_config_dir_present: params.hostConfigDirPresent,
743 + host_binary_in_known_paths: params.hostBinaryInKnownPaths,
744 });
745
746 export const getSetupCancelledEvent = (params: {
ts/packages/cli/src/commands/setup.cmd.ts
+46 -54
@@ -16,7 +16,6 @@ import {
16 isSetupReady,
17 SETUP_TARGETS,
18 SetupCommandError,
19 - SetupProcessError,
19 uninstallSetupTargets,
20 type AgentHost,
21 type SetupFailureReasonCode,
@@ -52,33 +51,31 @@ const formatTargets = (targets: ReadonlyArray<AgentHost>): string =>
51 const errorMessage = (error: unknown): string =>
52 Predicate.isError(error) ? error.message : String(error);
53
55 -const setupCommandError = (
56 - message: string,
57 - operation: 'setup' | 'uninstall',
58 - reasonCode: SetupFailureReasonCode,
59 - cause?: unknown
60 -) =>
61 - new SetupCommandError({
62 - message,
63 - operation,
64 - reasonCode,
65 - ...(cause === undefined ? {} : { cause }),
66 - });
54 +type SetupOperation = 'setup' | 'uninstall';
55
68 -const processFailureReasonCode = (error: unknown): SetupFailureReasonCode => {
69 - if (error instanceof SetupProcessError) return error.reasonCode ?? 'unknown';
70 - return 'unknown';
56 +interface SetupCommandErrorParams {
57 + readonly message: string;
58 + readonly reasonCode: SetupFailureReasonCode;
59 + readonly cause?: unknown;
60 +}
61 +
62 +const operationOf = (uninstall: boolean): SetupOperation => {
63 + if (uninstall) return 'uninstall';
64 + return 'setup';
65 };
66
67 const setupBaseCmd = Command.make(
68 'setup',
69 { target, yes, ifPresent, uninstall },
76 - ({ target, yes, ifPresent, uninstall }) =>
77 - Effect.gen(function* () {
70 + ({ target, yes, ifPresent, uninstall }) => {
71 + const operation = operationOf(uninstall);
72 + const setupCommandError = (params: SetupCommandErrorParams) =>
73 + new SetupCommandError({ operation, ...params });
74 +
75 + return Effect.gen(function* () {
76 const ui = yield* TerminalUI;
77 const terminal = yield* ui.capabilities;
78 const { invocationOrigin } = yield* cliInvocationContext;
81 - const operation = uninstall ? 'uninstall' : 'setup';
79 yield* ui.intro(uninstall ? 'composio setup --uninstall' : 'composio setup');
80
81 const detections = yield* detectSetupTargets(target);
@@ -116,11 +113,10 @@ const setupBaseCmd = Command.make(
113 yield* ui.log.info(`${formatTargets(notDetected)} not detected.`);
114 }
115 if (target === 'all' && notDetected.length > 0) {
119 - return yield* setupCommandError(
120 - `\`--target all\` requires Claude Code and Codex. Missing: ${formatTargets(notDetected)}. Install the missing agent host, or use \`--target auto\` to operate on detected hosts only.`,
121 - operation,
122 - 'all_requires_both_hosts'
123 - );
116 + return yield* setupCommandError({
117 + message: `\`--target all\` requires Claude Code and Codex. Missing: ${formatTargets(notDetected)}. Install the missing agent host, or use \`--target auto\` to operate on detected hosts only.`,
118 + reasonCode: 'all_requires_both_hosts',
119 + });
120 }
121 if (unsupported.length > 0) {
122 const reason = unsupported
@@ -128,7 +124,7 @@ const setupBaseCmd = Command.make(
124 .filter((message): message is string => Boolean(message))
125 .join(' ');
126 if (target !== 'auto') {
131 - return yield* setupCommandError(reason, operation, 'unsupported_host');
127 + return yield* setupCommandError({ message: reason, reasonCode: 'unsupported_host' });
128 }
129 yield* ui.log.warn(
130 `${formatTargets(unsupported.map(result => result.target))} plugin setup skipped. ${reason}`
@@ -148,23 +144,21 @@ const setupBaseCmd = Command.make(
144 );
145 return;
146 }
151 - return yield* setupCommandError(reason, operation, 'unsupported_host');
147 + return yield* setupCommandError({ message: reason, reasonCode: 'unsupported_host' });
148 }
149 }
150 if (detected.length === 0) {
151 if (target === 'claude' || target === 'codex') {
156 - return yield* setupCommandError(
157 - `${target} is not installed or not available on PATH. Install it and rerun \`composio setup${uninstall ? ' --uninstall' : ''} --target ${target}\`.`,
158 - operation,
159 - 'target_not_installed'
160 - );
152 + return yield* setupCommandError({
153 + message: `${target} is not installed or not available on PATH. Install it and rerun \`composio setup${uninstall ? ' --uninstall' : ''} --target ${target}\`.`,
154 + reasonCode: 'target_not_installed',
155 + });
156 }
157 if (!ifPresent || target !== 'auto') {
163 - return yield* setupCommandError(
164 - `No supported agent host was detected. Install Claude Code or Codex, then rerun \`composio setup${uninstall ? ' --uninstall' : ''}\`.`,
165 - operation,
166 - 'no_host_detected'
167 - );
158 + return yield* setupCommandError({
159 + message: `No supported agent host was detected. Install Claude Code or Codex, then rerun \`composio setup${uninstall ? ' --uninstall' : ''}\`.`,
160 + reasonCode: 'no_host_detected',
161 + });
162 }
163 yield* trackCliEventEffect(
164 getSetupSkippedEvent({
@@ -182,7 +176,7 @@ const setupBaseCmd = Command.make(
176
177 const inspected = yield* inspectSetupTargets(detections, {
178 allowMarketplaceConflict: uninstall,
185 - operation: uninstall ? 'uninstall' : 'setup',
179 + operation,
180 });
181 if (uninstall) {
182 const installed = inspected.filter(status => status.plugin_installed);
@@ -208,11 +202,10 @@ const setupBaseCmd = Command.make(
202
203 if (!yes && removable.length > 0) {
204 if (!terminal.canPrompt) {
211 - return yield* setupCommandError(
212 - 'Non-interactive uninstall requires `--yes` to approve local changes.',
213 - operation,
214 - 'non_interactive_requires_yes'
215 - );
205 + return yield* setupCommandError({
206 + message: 'Non-interactive uninstall requires `--yes` to approve local changes.',
207 + reasonCode: 'non_interactive_requires_yes',
208 + });
209 }
210 const confirmed = yield* ui.confirm(
211 `Remove Composio from ${formatTargets(removable.map(status => status.target))}?`,
@@ -258,11 +251,10 @@ const setupBaseCmd = Command.make(
251 const pendingPlugins = pending.filter(status => !isSetupPluginReady(status));
252 if (!yes) {
253 if (!terminal.canPrompt) {
261 - return yield* setupCommandError(
262 - 'Non-interactive setup requires `--yes` to approve local changes.',
263 - operation,
264 - 'non_interactive_requires_yes'
265 - );
254 + return yield* setupCommandError({
255 + message: 'Non-interactive setup requires `--yes` to approve local changes.',
256 + reasonCode: 'non_interactive_requires_yes',
257 + });
258 }
259
260 const prompt =
@@ -307,14 +299,14 @@ const setupBaseCmd = Command.make(
299 }).pipe(
300 Effect.mapError(error => {
301 if (error instanceof SetupCommandError) return error;
310 - return setupCommandError(
311 - errorMessage(error),
312 - uninstall ? 'uninstall' : 'setup',
313 - processFailureReasonCode(error),
314 - error
315 - );
302 + return setupCommandError({
303 + message: errorMessage(error),
304 + reasonCode: 'unknown',
305 + cause: error,
306 + });
307 })
317 - )
308 + );
309 + }
310 );
311
312 export const setupCmd = setupBaseCmd.pipe(
ts/packages/cli/src/services/agent-host-env.ts
+39 -10
@@ -1,5 +1,8 @@
1 +import * as FileSystem from 'effect/FileSystem';
2 +import * as Path from 'effect/Path';
3 import { Config, ConfigProvider, Effect, Option } from 'effect';
4 import type { AgentHost } from './agent-host';
5 +import { NodeOs } from './node-os';
6
7 export type AgentHostEnv = AgentHost | 'none';
8
@@ -51,14 +54,40 @@ export const rawHostEnvironment: Effect.Effect<RawHostEnvironment> = Effect.gen(
54 )
55 );
56
54 -export const hostConfigDirectory = (params: {
55 - readonly host: AgentHost;
56 - readonly env: RawHostEnvironment;
57 - readonly homedir: string;
58 - readonly join: (...segments: string[]) => string;
59 -}): string => {
60 - if (params.host === 'claude') {
61 - return params.env.claudeConfigDir ?? params.join(params.homedir, '.claude');
62 - }
63 - return params.env.codexHome ?? params.join(params.homedir, '.codex');
57 +export const hostConfigDirectory = (host: AgentHost) =>
58 + Effect.gen(function* () {
59 + const path = yield* Path.Path;
60 + const os = yield* NodeOs;
61 + const env = yield* rawHostEnvironment;
62 + if (host === 'claude') return env.claudeConfigDir ?? path.join(os.homedir, '.claude');
63 + return env.codexHome ?? path.join(os.homedir, '.codex');
64 + });
65 +
66 +const KNOWN_BINARY_PATHS: Readonly<Record<AgentHost, ReadonlyArray<string>>> = {
67 + claude: [
68 + '.claude/local/claude',
69 + '.local/bin/claude',
70 + '.npm-global/bin/claude',
71 + '/usr/local/bin/claude',
72 + '/opt/homebrew/bin/claude',
73 + ],
74 + codex: [
75 + '.local/bin/codex',
76 + '.npm-global/bin/codex',
77 + '/usr/local/bin/codex',
78 + '/opt/homebrew/bin/codex',
79 + ],
80 };
81 +
82 +export const probeHostInstallation = (host: AgentHost) =>
83 + Effect.gen(function* () {
84 + const fs = yield* FileSystem.FileSystem;
85 + const path = yield* Path.Path;
86 + const os = yield* NodeOs;
87 + const exists = (target: string) => fs.exists(target).pipe(Effect.orElseSucceed(() => false));
88 + const configDirPresent = yield* exists(yield* hostConfigDirectory(host));
89 + const found = yield* Effect.forEach(KNOWN_BINARY_PATHS[host], entry =>
90 + exists(path.resolve(os.homedir, entry))
91 + );
92 + return { configDirPresent, binaryInKnownPaths: found.includes(true) };
93 + });
ts/packages/cli/src/services/agent-host-locations.ts deleted
-51
@@ -1,51 +0,0 @@
1 -import * as FileSystem from 'effect/FileSystem';
2 -import * as Path from 'effect/Path';
3 -import { Effect } from 'effect';
4 -import type { AgentHost } from './agent-host';
5 -import { hostConfigDirectory, rawHostEnvironment } from './agent-host-env';
6 -import { NodeOs } from './node-os';
7 -
8 -export interface HostInstallationSignals {
9 - readonly configDirPresent: boolean;
10 - readonly binaryInKnownPaths: boolean;
11 -}
12 -
13 -const HOME_RELATIVE_BINARY_DIRS: Readonly<Record<AgentHost, ReadonlyArray<ReadonlyArray<string>>>> =
14 - {
15 - claude: [
16 - ['.claude', 'local'],
17 - ['.local', 'bin'],
18 - ['.npm-global', 'bin'],
19 - ],
20 - codex: [
21 - ['.local', 'bin'],
22 - ['.npm-global', 'bin'],
23 - ],
24 - };
25 -
26 -const ABSOLUTE_BINARY_DIRS = ['/usr/local/bin', '/opt/homebrew/bin'] as const;
27 -
28 -/**
29 - * Cheap on-disk signals that tell a real host absence apart from a PATH miss
30 - * when `<host> --version` cannot be spawned.
31 - */
32 -export const probeHostInstallation = (host: AgentHost) =>
33 - Effect.gen(function* () {
34 - const fs = yield* FileSystem.FileSystem;
35 - const path = yield* Path.Path;
36 - const os = yield* NodeOs;
37 - const env = yield* rawHostEnvironment;
38 - const exists = (target: string) => fs.exists(target).pipe(Effect.orElseSucceed(() => false));
39 -
40 - const configDir = hostConfigDirectory({ host, env, homedir: os.homedir, join: path.join });
41 - const binaries = [
42 - ...HOME_RELATIVE_BINARY_DIRS[host].map(segments => path.join(os.homedir, ...segments, host)),
43 - ...ABSOLUTE_BINARY_DIRS.map(dir => path.join(dir, host)),
44 - ];
45 - const configDirPresent = yield* exists(configDir);
46 - const found = yield* Effect.forEach(binaries, exists);
47 - return {
48 - configDirPresent,
49 - binaryInKnownPaths: found.includes(true),
50 - } satisfies HostInstallationSignals;
51 - });
ts/packages/cli/src/services/plugin-hint.ts
+19 -35
@@ -5,11 +5,10 @@ import { trackCliEventEffect } from 'src/analytics/dispatch';
5 import { getPluginHintShownEvent } from 'src/analytics/events';
6 import { APP_CONFIG } from 'src/effects/app-config';
7 import { setupCacheDir } from 'src/effects/setup-cache-dir';
8 -import { getVersion } from 'src/effects/version';
8 +import { APP_VERSION } from 'src/constants';
9 import { AGENT_HOST_LABELS, COMPOSIO_AGENT_PLUGIN_ID, type AgentHost } from './agent-host';
10 import { detectPluginHost, hostConfigDirectory, rawHostEnvironment } from './agent-host-env';
11 -import { NodeOs } from './node-os';
12 -import { cliInvocationContext } from './runtime-cli-context';
11 +import { DEFAULT_CLI_INVOCATION_ORIGIN } from './runtime-cli-context';
12 import { TerminalUI } from './terminal-ui';
13
14 /**
@@ -97,7 +96,6 @@ export function createPluginHint(config: PluginHintConfig) {
96 codex: codexPluginAbsent,
97 };
98
100 - /** Resolves to `true` only when the hint line was actually printed. */
99 function showPluginHint(terminal: Pick<TerminalUI, 'error'>) {
100 return Effect.gen(function* () {
101 const host = config.host;
@@ -106,15 +104,22 @@ export function createPluginHint(config: PluginHintConfig) {
104 config.invocationOrigin === 'run' ||
105 config.commandName === 'setup'
106 ) {
109 - return false;
107 + return;
108 }
111 - if (!(yield* pluginAbsentByHost[host])) return false;
112 - if (!(yield* claimHint(host))) return false;
109 + if (!(yield* pluginAbsentByHost[host])) return;
110 + if (!(yield* claimHint(host))) return;
111 yield* terminal.error(
112 `Tip: running under ${AGENT_HOST_LABELS[host]} without the Composio plugin — 'composio setup --yes' installs it.`
113 );
116 - return true;
117 - }).pipe(Effect.orElseSucceed(() => false));
114 + yield* trackCliEventEffect(
115 + getPluginHintShownEvent({
116 + invocationOrigin: config.invocationOrigin ?? DEFAULT_CLI_INVOCATION_ORIGIN,
117 + cliVersion: APP_VERSION,
118 + commandPath: config.commandName ?? 'composio',
119 + agentHost: host,
120 + })
121 + );
122 + }).pipe(Effect.ignore);
123 }
124
125 return { showPluginHint };
@@ -139,47 +144,26 @@ export function findRootCommandName(argv: ReadonlyArray<string>): string | undef
144 export const resolvePluginHintConfig = (argv: ReadonlyArray<string>) =>
145 Effect.gen(function* () {
146 const path = yield* Path.Path;
142 - const os = yield* NodeOs;
147 const cacheDir = yield* setupCacheDir;
148 const invocationOrigin = yield* APP_CONFIG.CLI_INVOCATION_ORIGIN;
149 const env = yield* rawHostEnvironment;
146 - const configDir = (host: AgentHost) =>
147 - hostConfigDirectory({ host, env, homedir: os.homedir, join: path.join });
150 + const claudeConfigDir = yield* hostConfigDirectory('claude');
151 + const codexConfigDir = yield* hostConfigDirectory('codex');
152 return {
153 stateDirectory: path.join(cacheDir, 'plugin-hints'),
154 host: detectPluginHost(env),
155 invocationOrigin,
156 commandName: findRootCommandName(argv),
153 - claudeInstalledPluginsFile: path.join(
154 - configDir('claude'),
155 - 'plugins',
156 - 'installed_plugins.json'
157 - ),
158 - codexConfigFile: path.join(configDir('codex'), 'config.toml'),
157 + claudeInstalledPluginsFile: path.join(claudeConfigDir, 'plugins', 'installed_plugins.json'),
158 + codexConfigFile: path.join(codexConfigDir, 'config.toml'),
159 hintIntervalMs: HINT_INTERVAL_MS,
160 } satisfies PluginHintConfig;
161 });
162
163 -const trackHintShown = (config: PluginHintConfig) =>
164 - Effect.gen(function* () {
165 - if (config.host === undefined) return;
166 - const { invocationOrigin } = yield* cliInvocationContext;
167 - yield* trackCliEventEffect(
168 - getPluginHintShownEvent({
169 - invocationOrigin,
170 - cliVersion: yield* getVersion,
171 - commandPath: config.commandName ?? 'composio',
172 - agentHost: config.host,
173 - })
174 - );
175 - }).pipe(Effect.ignore);
176 -
163 /** Print the plugin acquisition hint when eligible. Never fails, never blocks on network. */
164 export const showPluginAcquisitionHint = (argv: ReadonlyArray<string>) =>
165 Effect.gen(function* () {
166 const terminal = yield* TerminalUI;
167 const config = yield* resolvePluginHintConfig(argv);
182 - const shown = yield* createPluginHint(config).showPluginHint(terminal);
183 - if (!shown) return;
184 - yield* trackHintShown(config);
168 + yield* createPluginHint(config).showPluginHint(terminal);
169 });
ts/packages/cli/src/services/setup-command-error.ts deleted
-22
@@ -1,22 +0,0 @@
1 -import { Data } from 'effect';
2 -
3 -export type SetupFailureReasonCode =
4 - | 'all_requires_both_hosts'
5 - | 'unsupported_host'
6 - | 'target_not_installed'
7 - | 'no_host_detected'
8 - | 'non_interactive_requires_yes'
9 - | 'marketplace_conflict'
10 - | 'unknown';
11 -
12 -export class SetupCommandError extends Data.TaggedError('services/SetupCommandError')<{
13 - readonly message: string;
14 - readonly operation: 'setup' | 'uninstall';
15 - readonly reasonCode: SetupFailureReasonCode;
16 - readonly cause?: unknown;
17 -}> {}
18 -
19 -export const setupFailureReasonCodeOf = (error: unknown): SetupFailureReasonCode => {
20 - if (error instanceof SetupCommandError) return error.reasonCode;
21 - return 'unknown';
22 -};
ts/packages/cli/src/services/setup.ts
+25 -29
@@ -1,5 +1,3 @@
1 -import * as FileSystem from 'effect/FileSystem';
2 -import * as Path from 'effect/Path';
1 import * as PlatformError from 'effect/PlatformError';
2 import { Data, Effect, Option, Predicate, Schema } from 'effect';
3 import { ChildProcess as Command } from 'effect/unstable/process';
@@ -16,11 +14,9 @@ import {
14 COMPOSIO_AGENT_PLUGIN_ID,
15 type AgentHost,
16 } from './agent-host';
19 -import { probeHostInstallation, type HostInstallationSignals } from './agent-host-locations';
17 +import { probeHostInstallation } from './agent-host-env';
18 import { CommandRunner, type CommandResult } from './command-runner';
21 -import { NodeOs } from './node-os';
19 import { SetupSkillInstaller } from './setup-skill-installer';
23 -import type { SetupFailureReasonCode } from './setup-command-error';
20 import { cliInvocationContext } from './runtime-cli-context';
21
22 export const SETUP_TARGETS = ['auto', ...AGENT_HOSTS, 'all'] as const;
@@ -136,7 +132,21 @@ const ADAPTER_LIST = Object.values(ADAPTERS);
132 const SETUP_COMMAND_TIMEOUT = '2 minutes';
133 const MINIMUM_CODEX_SETUP_VERSION = '0.139.0';
134
139 -export { SetupCommandError, type SetupFailureReasonCode } from './setup-command-error';
135 +export type SetupFailureReasonCode =
136 + | 'all_requires_both_hosts'
137 + | 'unsupported_host'
138 + | 'target_not_installed'
139 + | 'no_host_detected'
140 + | 'non_interactive_requires_yes'
141 + | 'marketplace_conflict'
142 + | 'unknown';
143 +
144 +export class SetupCommandError extends Data.TaggedError('services/SetupCommandError')<{
145 + readonly message: string;
146 + readonly operation: 'setup' | 'uninstall';
147 + readonly reasonCode: SetupFailureReasonCode;
148 + readonly cause?: unknown;
149 +}> {}
150
151 type SetupFailureStage = 'detect' | 'inspect' | 'validate' | 'mutate' | 'verify' | 'skill';
152
@@ -144,7 +154,6 @@ export class SetupProcessError extends Data.TaggedError('services/SetupProcessEr
154 readonly message: string;
155 readonly target: AgentHost;
156 readonly stage: SetupFailureStage;
147 - readonly reasonCode?: SetupFailureReasonCode;
157 readonly cause?: unknown;
158 }> {}
159
@@ -152,14 +161,12 @@ const setupProcessError = (params: {
161 readonly adapter: SetupTargetAdapter;
162 readonly stage: SetupFailureStage;
163 readonly message: string;
155 - readonly reasonCode?: SetupFailureReasonCode;
164 readonly cause?: unknown;
165 }) =>
166 new SetupProcessError({
167 message: params.message,
168 target: params.adapter.target,
169 stage: params.stage,
162 - ...(params.reasonCode === undefined ? {} : { reasonCode: params.reasonCode }),
170 ...(params.cause === undefined ? {} : { cause: params.cause }),
171 });
172
@@ -392,18 +399,6 @@ const supportsInspection = (adapter: SetupTargetAdapter, versionOutput?: string)
399 return { supported: true } as const;
400 });
401
395 -type AdapterDetection = Omit<SetupTargetDetection, 'target'>;
396 -
397 -const withInstallationSignals = (
398 - adapter: SetupTargetAdapter,
399 - detection: AdapterDetection
400 -): Effect.Effect<AdapterDetection, never, FileSystem.FileSystem | Path.Path | NodeOs> => {
401 - if (detection.available) return Effect.succeed(detection);
402 - return probeHostInstallation(adapter.target).pipe(
403 - Effect.map(signals => ({ ...detection, ...signals }))
404 - );
405 -};
406 -
402 const detectAdapter = (adapter: SetupTargetAdapter) =>
403 Effect.gen(function* () {
404 const versionArgs = ['--version'];
@@ -476,7 +471,8 @@ const detectAdapter = (adapter: SetupTargetAdapter) =>
471 },
472 })
473 );
479 - return yield* withInstallationSignals(adapter, detection);
474 + if (detection.available) return detection;
475 + return { ...detection, ...(yield* probeHostInstallation(adapter.target)) };
476 });
477
478 const commandFailureSuffix = (result: CommandResult): string => {
@@ -677,17 +673,15 @@ const runRequired = (
673
674 const validateInitialState = (adapter: SetupTargetAdapter, initial: InspectedSetupTarget) => {
675 if (!initial.available) {
680 - return setupProcessError({
681 - adapter,
682 - stage: 'validate',
676 + return new SetupCommandError({
677 + operation: 'setup',
678 reasonCode: 'target_not_installed',
679 message: `${adapter.executable} is not installed or not available on PATH. Install it and rerun \`composio setup --target ${adapter.target}\`.`,
680 });
681 }
682 if (initial.marketplace_conflict) {
688 - return setupProcessError({
689 - adapter,
690 - stage: 'validate',
683 + return new SetupCommandError({
684 + operation: 'setup',
685 reasonCode: 'marketplace_conflict',
686 message: `The ${adapter.target} marketplace named "composio" points to a different source. Run \`${adapter.marketplaceRemoveCommand}\`, then rerun \`composio setup --target ${adapter.target}\`.`,
687 });
@@ -804,13 +798,15 @@ const FIXED_TARGETS: Readonly<Partial<Record<SetupTarget, ReadonlyArray<AgentHos
798 export type SetupUnsupportedReasonCode =
799 'codex_too_old' | 'no_json_inspection' | 'host_command_failed' | 'unknown';
800
807 -export interface SetupTargetDetection extends Partial<HostInstallationSignals> {
801 +export interface SetupTargetDetection {
802 readonly target: AgentHost;
803 readonly available: boolean;
804 readonly supported: boolean;
805 readonly version?: string;
806 readonly unsupportedReason?: string;
807 readonly unsupportedReasonCode?: SetupUnsupportedReasonCode;
808 + readonly configDirPresent?: boolean;
809 + readonly binaryInKnownPaths?: boolean;
810 }
811
812 export const detectSetupTargets = (target: SetupTarget) =>
ts/packages/cli/test/__utils__/tracked-events.ts new
+11
@@ -0,0 +1,11 @@
1 +import { Effect } from 'effect';
2 +import type { TrackEvent } from 'src/analytics/types';
3 +
4 +export const trackedEvents: Array<NonNullable<TrackEvent>> = [];
5 +
6 +export const eventsNamed = (name: string) => trackedEvents.filter(event => event.name === name);
7 +
8 +export const recordTrackedEvent = (event: TrackEvent) =>
9 + Effect.sync(() => {
10 + if (event) trackedEvents.push(event);
11 + });
ts/packages/cli/test/src/analytics.events.test.ts
+9 -16
@@ -333,13 +333,11 @@ describe('CLI analytics setup runtime-context events', () => {
333 target: 'claude',
334 available: true,
335 supported: true,
336 - hostConfigDirPresent: true,
337 - hostBinaryInKnownPaths: true,
336 invocationOrigin: DEFAULT_CLI_INVOCATION_ORIGIN,
337 cliVersion: APP_VERSION,
338 });
341 - expect(detected?.properties).not.toHaveProperty('host_config_dir_present');
342 - expect(detected?.properties).not.toHaveProperty('host_binary_in_known_paths');
339 + expect(detected?.properties?.host_config_dir_present).toBeUndefined();
340 + expect(detected?.properties?.host_binary_in_known_paths).toBeUndefined();
341 });
342
343 it('tracks a printed plugin hint as a setup-stage event', () => {
@@ -382,19 +380,14 @@ describe('CLI analytics setup runtime-context events', () => {
380 error_name: 'services/SetupCommandError',
381 failure_reason_code: 'non_interactive_requires_yes',
382 });
385 - expect(
386 - getPrimaryLifecycleFailedEvent(context, new Error('boom'))?.properties?.failure_reason_code
387 - ).toBe('unknown');
388 - });
389 -
390 - it('keeps failure reason codes out of other lifecycle families', () => {
391 - const context = createCliCommandTelemetryContext(
392 - ['bun', 'composio', 'login'],
393 - APP_VERSION,
394 - { stdoutIsTTY: false, stderrIsTTY: false },
395 - CLI_INVOCATION
383 + const unknown = new SetupCommandError({
384 + message: 'native failure',
385 + operation: 'setup',
386 + reasonCode: 'unknown',
387 + });
388 + expect(getPrimaryLifecycleFailedEvent(context, unknown)?.properties?.failure_reason_code).toBe(
389 + 'unknown'
390 );
397 -
391 expect(
392 getPrimaryLifecycleFailedEvent(context, new Error('boom'))?.properties
393 ).not.toHaveProperty('failure_reason_code');
ts/packages/cli/test/src/commands/setup.cmd.test.ts
+59 -78
@@ -1232,87 +1232,68 @@ const reasonCodeOf = (exit: Exit.Exit<unknown, unknown>): string | undefined =>
1232 return undefined;
1233 };
1234
1235 +const REASON_CODE_FIXTURES = {
1236 + 'only Claude Code installed': () => makeFakeHosts({ claude: { available: true } }),
1237 + 'no host installed': () => makeFakeHosts({}),
1238 + 'unsupported Codex only': () =>
1239 + makeFakeHosts({ codex: { available: true } }, { codexVersion: 'codex-cli 0.137.0' }),
1240 + 'marketplace conflict': () =>
1241 + makeFakeHosts({ claude: { available: true, marketplace: 'conflict' } }),
1242 + 'native install failure': () =>
1243 + makeFakeHosts({ claude: { available: true } }, { failOn: 'plugin install' }),
1244 +} as const;
1245 +
1246 +const REASON_CODE_CASES: ReadonlyArray<{
1247 + readonly hosts: keyof typeof REASON_CODE_FIXTURES;
1248 + readonly argv: ReadonlyArray<string>;
1249 + readonly expected: string;
1250 +}> = [
1251 + {
1252 + hosts: 'only Claude Code installed',
1253 + argv: ['--target', 'all', '--yes'],
1254 + expected: 'all_requires_both_hosts',
1255 + },
1256 + {
1257 + hosts: 'only Claude Code installed',
1258 + argv: ['--target', 'codex', '--yes'],
1259 + expected: 'target_not_installed',
1260 + },
1261 + {
1262 + hosts: 'only Claude Code installed',
1263 + argv: ['--target', 'claude'],
1264 + expected: 'non_interactive_requires_yes',
1265 + },
1266 + { hosts: 'no host installed', argv: ['--yes'], expected: 'no_host_detected' },
1267 + {
1268 + hosts: 'unsupported Codex only',
1269 + argv: ['--target', 'codex', '--yes'],
1270 + expected: 'unsupported_host',
1271 + },
1272 + { hosts: 'unsupported Codex only', argv: ['--yes'], expected: 'unsupported_host' },
1273 + {
1274 + hosts: 'marketplace conflict',
1275 + argv: ['--target', 'claude', '--yes'],
1276 + expected: 'marketplace_conflict',
1277 + },
1278 + { hosts: 'native install failure', argv: ['--target', 'claude', '--yes'], expected: 'unknown' },
1279 +];
1280 +
1281 describe('CLI: composio setup failure reason codes', () => {
1282 afterEach(() => {
1283 process.exitCode = undefined;
1284 });
1285
1240 - const claudeOnly = makeFakeHosts({ claude: { available: true } });
1241 - layer(TestLive({ commandRunner: claudeOnly.runner }))('only Claude Code installed', it => {
1242 - it.effect('codes `--target all` with a missing host', () =>
1243 - Effect.gen(function* () {
1244 - const exit = yield* Effect.exit(cli(['setup', '--target', 'all', '--yes']));
1245 - expect(reasonCodeOf(exit)).toBe('all_requires_both_hosts');
1246 - })
1247 - );
1248 -
1249 - it.effect('codes an explicitly requested missing host', () =>
1250 - Effect.gen(function* () {
1251 - const exit = yield* Effect.exit(cli(['setup', '--target', 'codex', '--yes']));
1252 - expect(reasonCodeOf(exit)).toBe('target_not_installed');
1253 - })
1254 - );
1255 -
1256 - it.effect('codes a non-interactive run without --yes', () =>
1257 - Effect.gen(function* () {
1258 - const exit = yield* Effect.exit(cli(['setup', '--target', 'claude']));
1259 - expect(reasonCodeOf(exit)).toBe('non_interactive_requires_yes');
1260 - })
1261 - );
1262 - });
1263 -
1264 - const noHosts = makeFakeHosts({});
1265 - layer(TestLive({ commandRunner: noHosts.runner }))('no host installed', it => {
1266 - it.effect('codes automatic detection that finds nothing', () =>
1267 - Effect.gen(function* () {
1268 - const exit = yield* Effect.exit(cli(['setup', '--yes']));
1269 - expect(reasonCodeOf(exit)).toBe('no_host_detected');
1270 - })
1271 - );
1272 - });
1273 -
1274 - const legacyCodex = makeFakeHosts(
1275 - { codex: { available: true } },
1276 - { codexVersion: 'codex-cli 0.137.0' }
1277 - );
1278 - layer(TestLive({ commandRunner: legacyCodex.runner }))('unsupported Codex only', it => {
1279 - it.effect('codes an unsupported explicit target', () =>
1280 - Effect.gen(function* () {
1281 - const exit = yield* Effect.exit(cli(['setup', '--target', 'codex', '--yes']));
1282 - expect(reasonCodeOf(exit)).toBe('unsupported_host');
1283 - })
1284 - );
1285 -
1286 - it.effect('codes automatic detection that only finds unsupported hosts', () =>
1287 - Effect.gen(function* () {
1288 - const exit = yield* Effect.exit(cli(['setup', '--yes']));
1289 - expect(reasonCodeOf(exit)).toBe('unsupported_host');
1290 - })
1291 - );
1292 - });
1293 -
1294 - const conflict = makeFakeHosts({ claude: { available: true, marketplace: 'conflict' } });
1295 - layer(TestLive({ commandRunner: conflict.runner }))('marketplace conflict', it => {
1296 - it.effect('codes the conflicting marketplace', () =>
1297 - Effect.gen(function* () {
1298 - const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
1299 - expect(reasonCodeOf(exit)).toBe('marketplace_conflict');
1300 - })
1301 - );
1302 - });
1303 -
1304 - const failedInstall = makeFakeHosts(
1305 - { claude: { available: true } },
1306 - { failOn: 'plugin install' }
1307 - );
1308 - layer(
1309 - TestLive({ commandRunner: failedInstall.runner, setupSkillInstaller: makeSkillInstaller() })
1310 - )('native install failure', it => {
1311 - it.effect('codes every other failure as unknown', () =>
1312 - Effect.gen(function* () {
1313 - const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
1314 - expect(reasonCodeOf(exit)).toBe('unknown');
1315 - })
1316 - );
1317 - });
1286 + for (const [hosts, makeHosts] of Object.entries(REASON_CODE_FIXTURES)) {
1287 + const fake = makeHosts();
1288 + layer(TestLive({ commandRunner: fake.runner }))(hosts, it => {
1289 + for (const { argv, expected } of REASON_CODE_CASES.filter(c => c.hosts === hosts)) {
1290 + it.effect(`codes \`setup ${argv.join(' ')}\` as ${expected}`, () =>
1291 + Effect.gen(function* () {
1292 + const exit = yield* Effect.exit(cli(['setup', ...argv]));
1293 + expect(reasonCodeOf(exit)).toBe(expected);
1294 + })
1295 + );
1296 + }
1297 + });
1298 + }
1299 });
ts/packages/cli/test/src/commands/setup.telemetry.cmd.test.ts
+7 -18
@@ -10,27 +10,16 @@ import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
10 import { getTerminalCapabilities, TerminalUI } from 'src/services/terminal-ui';
11 import { cli, TestLive } from 'test/__utils__';
12 import { terminalUITestImpl } from 'test/__utils__/services/terminal-ui-test';
13 -
14 -const tracked = vi.hoisted(() => ({
15 - events: [] as Array<{ readonly name: string; readonly properties?: Record<string, unknown> }>,
16 -}));
13 +import { eventsNamed, trackedEvents } from 'test/__utils__/tracked-events';
14
15 vi.mock('src/analytics/dispatch', async importOriginal => {
19 - const actual = await importOriginal<typeof import('src/analytics/dispatch')>();
20 - const { Effect } = await import('effect');
16 + const { recordTrackedEvent } = await import('test/__utils__/tracked-events');
17 return {
22 - ...actual,
23 - trackCliEventEffect: (
24 - event: { readonly name: string; readonly properties?: Record<string, unknown> } | null
25 - ) =>
26 - Effect.sync(() => {
27 - if (event) tracked.events.push(event);
28 - }),
18 + ...(await importOriginal<typeof import('src/analytics/dispatch')>()),
19 + trackCliEventEffect: recordTrackedEvent,
20 };
21 });
22
32 -const eventsNamed = (name: string) => tracked.events.filter(event => event.name === name);
33 -
23 type AgentHost = 'claude' | 'codex';
24
25 interface FakeHostState {
@@ -179,7 +168,7 @@ const decliningUI = TerminalUI.of({
168
169 describe('CLI: composio setup telemetry', () => {
170 beforeEach(() => {
182 - tracked.events.length = 0;
171 + trackedEvents.length = 0;
172 });
173
174 afterEach(() => {
@@ -213,8 +202,8 @@ describe('CLI: composio setup telemetry', () => {
202 host_binary_in_known_paths: true,
203 });
204 expect(claude?.properties).toMatchObject({ available: true });
216 - expect(claude?.properties).not.toHaveProperty('host_config_dir_present');
217 - expect(claude?.properties).not.toHaveProperty('host_binary_in_known_paths');
205 + expect(claude?.properties?.host_config_dir_present).toBeUndefined();
206 + expect(claude?.properties?.host_binary_in_known_paths).toBeUndefined();
207 })
208 );
209 });
ts/packages/cli/test/src/services/plugin-hint.test.ts
+42 -104
@@ -1,13 +1,12 @@
1 import { describe, expect, it } from '@effect/vitest';
2 import { afterEach, beforeEach, vi } from 'vitest';
3 -import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
4 -import * as BunPath from '@effect/platform-bun/BunPath';
3 import * as BunServices from '@effect/platform-bun/BunServices';
4 import { ConfigProvider, Effect, Layer } from 'effect';
5 import { existsSync, mkdirSync, mkdtempSync, rmSync, utimesSync, writeFileSync } from 'node:fs';
6 import { tmpdir } from 'node:os';
7 import { dirname, join } from 'node:path';
8 import { Writable } from 'node:stream';
9 +import { APP_VERSION } from 'src/constants';
10 import { extendConfigProvider } from 'src/services/config';
11 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
12 import { NodeProcess } from 'src/services/node-process';
@@ -16,27 +15,17 @@ import {
15 createPluginHint,
16 findRootCommandName,
17 resolvePluginHintConfig,
19 - showPluginAcquisitionHint,
18 type PluginHintConfig,
19 } from 'src/services/plugin-hint';
20 import { makeTerminalUI, TerminalUI } from 'src/services/terminal-ui';
21 import { terminalUITestImpl } from 'test/__utils__/services/terminal-ui-test';
24 -
25 -const tracked = vi.hoisted(() => ({
26 - events: [] as Array<{ readonly name: string; readonly properties?: Record<string, unknown> }>,
27 -}));
22 +import { trackedEvents } from 'test/__utils__/tracked-events';
23
24 vi.mock('src/analytics/dispatch', async importOriginal => {
30 - const actual = await importOriginal<typeof import('src/analytics/dispatch')>();
31 - const { Effect } = await import('effect');
25 + const { recordTrackedEvent } = await import('test/__utils__/tracked-events');
26 return {
33 - ...actual,
34 - trackCliEventEffect: (
35 - event: { readonly name: string; readonly properties?: Record<string, unknown> } | null
36 - ) =>
37 - Effect.sync(() => {
38 - if (event) tracked.events.push(event);
39 - }),
27 + ...(await importOriginal<typeof import('src/analytics/dispatch')>()),
28 + trackCliEventEffect: recordTrackedEvent,
29 };
30 });
31
@@ -49,11 +38,17 @@ beforeEach(() => {
38 afterEach(() => {
39 vi.useRealTimers();
40 vi.unstubAllEnvs();
52 - tracked.events.length = 0;
41 + trackedEvents.length = 0;
42 rmSync(tempDir, { recursive: true, force: true });
43 });
44
56 -const PlatformLayers = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
45 +const hintLayers = () =>
46 + Layer.mergeAll(
47 + BunServices.layer,
48 + NodeProcess.Default,
49 + Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempDir })),
50 + Layer.succeed(TerminalUI, terminalUITestImpl)
51 + );
52
53 function makeConfig(overrides?: Partial<PluginHintConfig>): PluginHintConfig {
54 return {
@@ -128,9 +123,7 @@ describe('resolvePluginHintConfig', () => {
123 ConfigProvider.ConfigProvider,
124 extendConfigProvider(ConfigProvider.fromEnv())
125 ),
131 - Effect.provide(
132 - Layer.merge(PlatformLayers, Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempDir })))
133 - )
126 + Effect.provide(hintLayers())
127 );
128 });
129
@@ -150,9 +143,7 @@ describe('resolvePluginHintConfig', () => {
143 ConfigProvider.ConfigProvider,
144 extendConfigProvider(ConfigProvider.fromEnv())
145 ),
153 - Effect.provide(
154 - Layer.merge(PlatformLayers, Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempDir })))
155 - )
146 + Effect.provide(hintLayers())
147 );
148 });
149
@@ -174,9 +165,7 @@ describe('resolvePluginHintConfig', () => {
165 ConfigProvider.ConfigProvider,
166 extendConfigProvider(ConfigProvider.fromEnv())
167 ),
177 - Effect.provide(
178 - Layer.merge(PlatformLayers, Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempDir })))
179 - )
168 + Effect.provide(hintLayers())
169 );
170 });
171 });
@@ -214,20 +203,30 @@ describe('showPluginHint', () => {
203 "Tip: running under Claude Code without the Composio plugin — 'composio setup --yes' installs it.",
204 "Tip: running under Codex without the Composio plugin — 'composio setup --yes' installs it.",
205 ]);
217 - }).pipe(Effect.provide(PlatformLayers))
206 + }).pipe(Effect.provide(hintLayers()))
207 );
208
220 - it.effect('reports whether the hint was printed', () =>
209 + it.effect('tracks CLI_PLUGIN_HINT_SHOWN once per printed hint', () =>
210 Effect.gen(function* () {
222 - const config = makeConfig();
211 + const config = makeConfig({ invocationOrigin: 'installer', commandName: 'whoami' });
212
224 - const first = yield* createPluginHint(config).showPluginHint(makeTerminal(output));
225 - const second = yield* createPluginHint(config).showPluginHint(makeTerminal(output));
213 + yield* createPluginHint(config).showPluginHint(makeTerminal(output));
214 + yield* createPluginHint(config).showPluginHint(makeTerminal(output));
215
227 - expect(first).toBe(true);
228 - expect(second).toBe(false);
216 expect(output).toHaveLength(1);
230 - }).pipe(Effect.provide(PlatformLayers))
217 + expect(trackedEvents).toEqual([
218 + {
219 + name: 'CLI_PLUGIN_HINT_SHOWN',
220 + properties: expect.objectContaining({
221 + source: 'cli',
222 + invocation_origin: 'installer',
223 + cli_version: APP_VERSION,
224 + command_path: 'whoami',
225 + agent_host: 'claude',
226 + }),
227 + },
228 + ]);
229 + }).pipe(Effect.provide(hintLayers()))
230 );
231
232 it.effect('stays silent when the plugin is installed', () =>
@@ -242,7 +241,7 @@ describe('showPluginHint', () => {
241
242 expect(output).toEqual([]);
243 expect(existsSync(claudeConfig.stateDirectory)).toBe(false);
245 - }).pipe(Effect.provide(PlatformLayers))
244 + }).pipe(Effect.provide(hintLayers()))
245 );
246
247 it.effect('stays silent when plugin state is unreadable', () =>
@@ -253,7 +252,7 @@ describe('showPluginHint', () => {
252 yield* createPluginHint(config).showPluginHint(makeTerminal(output));
253
254 expect(output).toEqual([]);
256 - }).pipe(Effect.provide(PlatformLayers))
255 + }).pipe(Effect.provide(hintLayers()))
256 );
257
258 it.effect('stays silent outside a host, in run children, and for setup', () =>
@@ -269,8 +268,9 @@ describe('showPluginHint', () => {
268 );
269
270 expect(output).toEqual([]);
271 + expect(trackedEvents).toEqual([]);
272 expect(existsSync(configs[2]!.stateDirectory)).toBe(false);
273 - }).pipe(Effect.provide(PlatformLayers))
273 + }).pipe(Effect.provide(hintLayers()))
274 );
275
276 it.effect('allows only one concurrent process to claim a host hint', () =>
@@ -286,7 +286,7 @@ describe('showPluginHint', () => {
286
287 expect(output).toHaveLength(1);
288 expect(existsSync(join(config.stateDirectory, 'claude.stamp'))).toBe(true);
289 - }).pipe(Effect.provide(PlatformLayers))
289 + }).pipe(Effect.provide(hintLayers()))
290 );
291
292 it.effect('throttles each host independently', () =>
@@ -300,7 +300,7 @@ describe('showPluginHint', () => {
300 yield* createPluginHint(codexConfig).showPluginHint(makeTerminal(output));
301
302 expect(output).toHaveLength(2);
303 - }).pipe(Effect.provide(PlatformLayers))
303 + }).pipe(Effect.provide(hintLayers()))
304 );
305
306 it.effect('retires a stale stamp and shows the hint again', () =>
@@ -316,7 +316,7 @@ describe('showPluginHint', () => {
316 yield* createPluginHint(config).showPluginHint(makeTerminal(output));
317
318 expect(output).toHaveLength(1);
319 - }).pipe(Effect.provide(PlatformLayers))
319 + }).pipe(Effect.provide(hintLayers()))
320 );
321
322 it.effect('writes to stderr even when no stream is a TTY', () =>
@@ -338,68 +338,6 @@ describe('showPluginHint', () => {
338 yield* createPluginHint(config).showPluginHint(terminal);
339
340 expect(chunks.join('')).toContain('composio setup');
341 - }).pipe(Effect.provide(PlatformLayers))
342 - );
343 -});
344 -
345 -describe('showPluginAcquisitionHint', () => {
346 - const output: string[] = [];
347 - const runHint = (argv: ReadonlyArray<string>) =>
348 - showPluginAcquisitionHint(argv).pipe(
349 - Effect.provideService(
350 - ConfigProvider.ConfigProvider,
351 - extendConfigProvider(ConfigProvider.fromEnv())
352 - ),
353 - Effect.provide(
354 - Layer.mergeAll(
355 - BunServices.layer,
356 - NodeProcess.Default,
357 - Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempDir })),
358 - Layer.succeed(
359 - TerminalUI,
360 - TerminalUI.of({
361 - ...terminalUITestImpl,
362 - error: line => Effect.sync(() => output.push(line)),
363 - })
364 - )
365 - )
366 - )
367 - );
368 -
369 - beforeEach(() => {
370 - output.length = 0;
371 - vi.stubEnv('COMPOSIO_CACHE_DIR', join(tempDir, 'cache'));
372 - vi.stubEnv('CLAUDECODE', '1');
373 - vi.stubEnv('COMPOSIO_CLI_INVOCATION_ORIGIN', 'installer');
374 - });
375 -
376 - it.effect('tracks CLI_PLUGIN_HINT_SHOWN once per printed hint', () =>
377 - Effect.gen(function* () {
378 - yield* runHint(['/bin/bun', '/cli/bin.ts', 'whoami']);
379 - yield* runHint(['/bin/bun', '/cli/bin.ts', 'whoami']);
380 -
381 - expect(output).toHaveLength(1);
382 - expect(tracked.events).toEqual([
383 - {
384 - name: 'CLI_PLUGIN_HINT_SHOWN',
385 - properties: expect.objectContaining({
386 - source: 'cli',
387 - invocation_origin: 'installer',
388 - cli_version: expect.any(String),
389 - command_path: 'whoami',
390 - agent_host: 'claude',
391 - }),
392 - },
393 - ]);
394 - })
395 - );
396 -
397 - it.effect('tracks nothing when the hint is suppressed', () =>
398 - Effect.gen(function* () {
399 - yield* runHint(['/bin/bun', '/cli/bin.ts', 'setup']);
400 -
401 - expect(output).toEqual([]);
402 - expect(tracked.events).toEqual([]);
403 - })
341 + }).pipe(Effect.provide(hintLayers()))
342 );
343 });