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

next
ts 53 lines 1.84 KB
Raw
1 import { telemetry, withCommandTelemetry } from 'src/analytics/command-input';
2 import { Command, Flag } from 'effect/cli';
3 import { SHELLS } from 'src/services/shell-config';
4 import { runInstall } from './install.handler';
5
6 const completionsOpt = Flag.Boolean('completions').pipe(
7 Flag.withDescription('Install shell completions.'),
8 Flag.withDefault(false)
9 );
10
11 const noCompletionsOpt = Flag.Boolean('no-completions').pipe(
12 Flag.withDescription('Deprecated: shell completions are skipped by default.'),
13 Flag.withDefault(false)
14 );
15
16 const shellOpt = Flag.Literals('shell', SHELLS).pipe(
17 Flag.withDescription('Override automatic shell detection.'),
18 Flag.optional
19 );
20
21 /**
22 * CLI command to set up shell integration (PATH and completions).
23 *
24 * The directory added to `PATH` is `COMPOSIO_BIN_DIR` when set — the documented
25 * override an installer hands to this command — then `~/.local/bin` when its
26 * `composio` entry point is this executable, then the running binary's own
27 * directory.
28 *
29 * @example
30 * ```bash
31 * composio install
32 * composio install --completions
33 * composio install --no-completions
34 * composio install --shell zsh
35 * COMPOSIO_BIN_DIR=~/.local/bin composio install
36 * ```
37 */
38 const installCmdBase = Command.make(
39 'install',
40 { completions: completionsOpt, noCompletions: noCompletionsOpt, shell: shellOpt },
41 runInstall
42 ).pipe(
43 Command.withDescription(
44 'Set up shell integration (PATH and completions). Set COMPOSIO_BIN_DIR to choose the directory added to PATH; it otherwise defaults to ~/.local/bin when that holds this executable, and to the directory of the running binary.'
45 )
46 );
47
48 export const installCmd = withCommandTelemetry(installCmdBase, input =>
49 telemetry.fields({
50 completions: telemetry.flag('--completions', input.completions),
51 no_completions: telemetry.flag('--no-completions', input.noCompletions),
52 })
53 );