1
import { Command, Options } from '@effect/cli';
2
import { FileSystem, Path } from '@effect/platform';
3
import type { PlatformError } from '@effect/platform/Error';
4
-import { Array as Arr, Config, ConfigProvider, Effect, Option } from 'effect';
4
+import { Array as Arr, Config, ConfigProvider, Data, Effect, Option } from 'effect';
5
import { ComposioCliUserConfig } from 'src/services/cli-user-config';
6
import { NodeOs } from 'src/services/node-os';
7
import { NodeProcess } from 'src/services/node-process';
35
36
export type Shell = (typeof SHELLS)[number];
37
38
+/**
39
+ * Aborted shell setup must fail the process: install.sh only runs its guarded
40
+ * inline PATH fallback when `composio install` exits non-zero, so a successful
41
+ * exit here would leave the user with no PATH setup and a green install. The
42
+ * abort reason is already printed before this error is raised; cli-main.ts
43
+ * maps it to exit code 1 without printing anything further.
44
+ */
45
+export class ShellSetupAbortError extends Data.TaggedError('commands/ShellSetupAbortError')<{
46
+ readonly message: string;
47
+}> {}
48
+
49
interface ShellConfig {
50
readonly shell: Shell;
51
readonly pathFiles: readonly string[];
279
readonly shell?: Shell;
280
}): Effect.Effect<
281
void,
271
- PlatformError,
282
+ PlatformError | ShellSetupAbortError,
283
TerminalUI | NodeOs | NodeProcess | FileSystem.FileSystem | Path.Path | ComposioCliUserConfig
284
> =>
285
Effect.gen(function* () {
326
);
327
328
if (!path.isAbsolute(binDir)) {
318
- yield* failure('Resolved bin directory must be an absolute path.');
329
+ const message = 'Resolved bin directory must be an absolute path.';
330
+ yield* failure(message);
331
yield* ui.outro('Aborted.');
320
- return;
332
+ return yield* new ShellSetupAbortError({ message });
333
}
334
335
if (isUnsafePath(binDir)) {
324
- yield* failure(
325
- 'Resolved bin directory contains unsafe characters and cannot be written to shell config.'
326
- );
336
+ const message =
337
+ 'Resolved bin directory contains unsafe characters and cannot be written to shell config.';
338
+ yield* failure(message);
339
yield* ui.outro('Aborted.');
328
- return;
340
+ return yield* new ShellSetupAbortError({ message });
341
}
342
343
const isExplicitShell = params.shell !== undefined;