@devries-cameron20 / composio-1 / commits / fac4bdca5
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.

feat(cli): add --shell flag to the base installer

Teach install.sh a --shell <zsh|bash|fish> flag that performs the same shell setup the /install/<shell> variants do: delegate to 'composio install --shell' when the installed CLI supports it, fall back to writing the # Composio CLI PATH block inline otherwise. The shell variants become thin wrappers that fetch the base installer and append '--shell <name>' to the forwarded arguments, so the delegation and fallback logic now lives in exactly one script. This also removes the double-configuration hazard of a variant blindly forwarding a user-supplied --shell. Shell setup no longer depends on the composio.dev/install/<shell> redirect rules existing: post-install guidance, docs, and release notes now print 'curl -fsSL https://composio.dev/install | sh -s -- --shell <shell>', which works through the single existing redirect. The variant scripts and their raw-URL preview commands keep working for when the routes land. Coverage: direct --shell delegation, fallback on unsupported or failing CLI, missing and invalid values failing before any network call, and a Docker e2e leg for the idempotent --shell bash flow.

jkomyno committed Aug 3, 2026 at 14:03 UTC fac4bdca5d72a648f71be35bcb2dce99e76ce80f
11 files changed +170 -246
.github/workflows/build-cli-binaries.yml
+1 -1
@@ -341,7 +341,7 @@ jobs:
341 export PATH="$COMPOSIO_BIN_DIR:$PATH"
342 ```
343
344 - Run `curl -fsSL https://composio.dev/install/zsh | sh`, replacing `zsh` with `bash` or `fish`, when you want the CLI to configure your shell.
344 + Run `curl -fsSL https://composio.dev/install | sh -s -- --shell zsh`, replacing `zsh` with `bash` or `fish`, when you want the CLI to configure your shell.
345
346 ## Usage
347
.github/workflows/cli.install-e2e.yml
+1
@@ -193,6 +193,7 @@ jobs:
193 echo ""
194 echo '```sh'
195 echo "curl -fsSL \"$RAW_BASE/install.sh\" | sh"
196 + echo "curl -fsSL \"$RAW_BASE/install.sh\" | sh -s -- --shell zsh"
197 echo '```'
198 echo ""
199 echo "Shell-specific setup routes (the override points the variant at this PR's base installer):"
INSTALL.md
+6 -3
@@ -9,11 +9,13 @@ curl -fsSL https://composio.dev/install | sh
9 The default installer changes no shell files and installs no agent plugins. If it reports that `~/.local/bin` is not available on `PATH`, run the shell-specific command it prints:
10
11 ```bash
12 -curl -fsSL https://composio.dev/install/zsh | sh
13 -curl -fsSL https://composio.dev/install/bash | sh
14 -curl -fsSL https://composio.dev/install/fish | sh
12 +curl -fsSL https://composio.dev/install | sh -s -- --shell zsh
13 +curl -fsSL https://composio.dev/install | sh -s -- --shell bash
14 +curl -fsSL https://composio.dev/install | sh -s -- --shell fish
15 ```
16
17 +Shell setup delegates to `composio install --shell <shell>` and falls back to writing the same `# Composio CLI` PATH block inline when the installed CLI release predates that flag.
18 +
19 Pin a stable or beta release with `COMPOSIO_INSTALL_VERSION`, or pass the tag as a positional argument:
20
21 ```bash
@@ -34,6 +36,7 @@ The positional argument takes precedence over `COMPOSIO_INSTALL_VERSION`.
36 | `COMPOSIO_INSTALL_PLUGINS` | Set to `1` to install plugins for detected agent hosts. | `0` |
37 | `--agent` | Log in as a Composio agent after installation. | Off |
38 | `--no-plugins` | Skip plugin setup. Kept for compatibility. | Off |
39 +| `--shell` | Configure the requested shell (`zsh`, `bash`, or `fish`) after installation. | Off |
40
41 ## Manual Installation
42
docs/content/changelog/07-31-26-installer.mdx
+1 -1
@@ -10,6 +10,6 @@ The Composio CLI installer now separates the release bundle from the command you
10
11 - `curl -fsSL https://composio.dev/install | sh` installs the verified release bundle in `~/.composio` and creates `~/.local/bin/composio`.
12 - The default flow does not edit shell files, install agent plugins, or log you in.
13 -- `/install/zsh`, `/install/bash`, and `/install/fish` configure the requested shell explicitly.
13 +- `--shell zsh|bash|fish` configures the requested shell explicitly, for example `curl -fsSL https://composio.dev/install | sh -s -- --shell zsh`.
14 - `COMPOSIO_INSTALL_VERSION`, `COMPOSIO_BIN_DIR`, `COMPOSIO_QUIET`, and `COMPOSIO_DEBUG` give you control over version, layout, and output.
15 - Existing `COMPOSIO_INSTALL_DIR` configurations keep their bundle-directory meaning.
docs/content/docs/cli.mdx
+6 -5
@@ -63,36 +63,37 @@ curl -fsSL https://composio.dev/install | sh -s -- @composio/cli@0.3.1
63 | `COMPOSIO_GITHUB_API_BASE_URL` | GitHub API base URL. | Derived from `COMPOSIO_GITHUB_URL` |
64 | `--agent` | Log in as a Composio agent after installation. | Off |
65 | `--no-plugins` | Skip agent plugin setup. Kept for compatibility and now matches the default. | Off |
66 +| `--shell` | Configure the requested shell (`zsh`, `bash`, or `fish`) after installation. See [Configure your shell](#configure-your-shell). | Off |
67
68 ### Configure your shell
69
69 -Use a shell-specific installer when `~/.local/bin` is not already on `PATH`, or when you want the CLI to configure the requested shell explicitly.
70 +Pass `--shell` when `~/.local/bin` is not already on `PATH`, or when you want the CLI to configure the requested shell explicitly.
71
72 <Tabs groupId="shell" items={['zsh','bash','fish']} persist>
73 <Tab value="zsh">
74 ```bash
74 -curl -fsSL https://composio.dev/install/zsh | sh
75 +curl -fsSL https://composio.dev/install | sh -s -- --shell zsh
76 ```
77
78 This configures `~/.zshrc` and delegates setup to `composio install --shell zsh`.
79 </Tab>
80 <Tab value="bash">
81 ```bash
81 -curl -fsSL https://composio.dev/install/bash | sh
82 +curl -fsSL https://composio.dev/install | sh -s -- --shell bash
83 ```
84
85 This configures `~/.bashrc`. If `~/.bash_profile` or `~/.bash_login` exists, it also updates the first active login file so `bash -ilc` can find `composio`.
86 </Tab>
87 <Tab value="fish">
88 ```bash
88 -curl -fsSL https://composio.dev/install/fish | sh
89 +curl -fsSL https://composio.dev/install | sh -s -- --shell fish
90 ```
91
92 This configures `~/.config/fish/config.fish` and delegates setup to `composio install --shell fish`.
93 </Tab>
94 </Tabs>
95
95 -Each shell installer is idempotent. It falls back to writing the same PATH block inline when you pin an older CLI release that does not support `--shell`.
96 +Shell setup is idempotent. It falls back to writing the same PATH block inline when you pin an older CLI release that does not support `composio install --shell`.
97
98 ### Verify the installation
99
install.sh
+93 -6
@@ -38,12 +38,13 @@ tildify() {
38
39 print_usage() {
40 printf '%s\n' \
41 - 'Usage: install.sh [--agent] [--no-plugins] [version-tag]' \
41 + 'Usage: install.sh [--agent] [--no-plugins] [--shell zsh|bash|fish] [version-tag]' \
42 '' \
43 'Options:' \
44 - ' --agent Sign up or log in as a Composio agent after installation.' \
45 - ' --no-plugins Skip agent plugin installation (the default).' \
46 - ' -h, --help Show this help.' \
44 + ' --agent Sign up or log in as a Composio agent after installation.' \
45 + ' --no-plugins Skip agent plugin installation (the default).' \
46 + ' --shell <shell> Configure zsh, bash, or fish so the composio command is on PATH.' \
47 + ' -h, --help Show this help.' \
48 '' \
49 'Version tags may be stable or beta, for example 0.3.1 or @composio/cli@0.3.1-beta.329.'
50 }
@@ -274,6 +275,77 @@ path_contains_bin_dir() {
275 esac
276 }
277
278 +is_unsafe_path() {
279 + case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
280 + unsafe_path_cr=$(printf '\r')
281 + case $1 in *"$unsafe_path_cr"* | *'
282 +'*) return 0 ;; esac
283 + return 1
284 +}
285 +
286 +render_bin_dir() {
287 + render_bin_dir_value=$1
288 + case $render_bin_dir_value in "$HOME"/*) render_bin_dir_value=\$HOME/${render_bin_dir_value#"$HOME"/} ;; esac
289 + printf '%s\n' "$render_bin_dir_value"
290 +}
291 +
292 +append_path_block() {
293 + append_path_file=$1
294 + append_path_shell=$2
295 + append_path_bin=$3
296 + mkdir -p "$(dirname "$append_path_file")"
297 + touch "$append_path_file"
298 + grep -Fqx '# Composio CLI' "$append_path_file" 2>/dev/null && return 0
299 + case $append_path_shell in
300 + fish) append_path_line="set --export PATH \"$append_path_bin\" \$PATH" ;;
301 + *) append_path_line="export PATH=\"$append_path_bin:\$PATH\"" ;;
302 + esac
303 + printf '\n# Composio CLI\n%s\n' "$append_path_line" >>"$append_path_file"
304 +}
305 +
306 +inline_shell_setup() {
307 + inline_setup_shell=$1
308 + inline_setup_bin_dir=$2
309 + is_unsafe_path "$inline_setup_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
310 + inline_setup_rendered=$(render_bin_dir "$inline_setup_bin_dir")
311 + case $inline_setup_shell in
312 + zsh) append_path_block "$HOME/.zshrc" zsh "$inline_setup_rendered" ;;
313 + fish) append_path_block "$HOME/.config/fish/config.fish" fish "$inline_setup_rendered" ;;
314 + bash)
315 + append_path_block "$HOME/.bashrc" bash "$inline_setup_rendered"
316 + if [ -f "$HOME/.bash_profile" ]; then
317 + append_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered"
318 + elif [ -f "$HOME/.bash_login" ]; then
319 + append_path_block "$HOME/.bash_login" bash "$inline_setup_rendered"
320 + fi
321 + ;;
322 + esac
323 +}
324 +
325 +setup_requested_shell() {
326 + if "$exe" install --help 2>&1 | grep -q -- '--shell'; then
327 + debug "delegating shell setup to $exe install --shell $requested_shell"
328 + if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$COMPOSIO_BIN_DIR" "$exe" install --shell "$requested_shell"; then
329 + shell_configured=cli
330 + else
331 + debug "falling back to inline $requested_shell shell setup"
332 + inline_shell_setup "$requested_shell" "$COMPOSIO_BIN_DIR"
333 + shell_configured=fallback
334 + fi
335 + else
336 + debug "falling back to inline $requested_shell shell setup"
337 + inline_shell_setup "$requested_shell" "$COMPOSIO_BIN_DIR"
338 + shell_configured=fallback
339 + fi
340 +
341 + info "Configured $requested_shell shell setup ($shell_configured)."
342 + case $requested_shell in
343 + zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
344 + bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
345 + fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
346 + esac
347 +}
348 +
349 print_post_install_help() {
350 [ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] || return 0
351 is_true "${COMPOSIO_QUIET:-}" && return 0
@@ -304,13 +376,15 @@ print_post_install_help() {
376 fi
377
378 printf '\n'
307 - if [ -n "$shell_route" ]; then
379 + if [ -n "$requested_shell" ]; then
380 + : # Shell setup already ran; skip the setup suggestion.
381 + elif [ -n "$shell_route" ]; then
382 if [ "$guidance_required" = 1 ]; then
383 printf 'Required next step for %s:\n\n' "$shell_name"
384 else
385 printf 'Optional shell setup for future PATH changes:\n\n'
386 fi
313 - printf ' curl -fsSL https://composio.dev/install/%s | sh\n' "$shell_route"
387 + printf ' curl -fsSL https://composio.dev/install | sh -s -- --shell %s\n' "$shell_route"
388 printf '\nThis configures %s.\n' "$shell_config"
389 elif path_contains_bin_dir; then
390 printf 'The composio command is available on PATH.\n'
@@ -337,6 +411,7 @@ main() {
411 install_agent=0
412 install_plugins=${COMPOSIO_INSTALL_PLUGINS:-0}
413 version_arg=
414 + requested_shell=
415
416 case $install_plugins in
417 0 | 1) ;;
@@ -347,6 +422,14 @@ main() {
422 case $1 in
423 --agent) install_agent=1 ;;
424 --no-plugins) install_plugins=0 ;;
425 + --shell)
426 + [ "$#" -ge 2 ] || error '--shell requires a value: zsh, bash, or fish'
427 + case $2 in
428 + zsh | bash | fish) requested_shell=$2 ;;
429 + *) error "Invalid --shell value \"$2\". Expected zsh, bash, or fish." ;;
430 + esac
431 + shift
432 + ;;
433 -h | --help)
434 print_usage
435 return 0
@@ -458,6 +541,10 @@ main() {
541 error 'Failed to sign up or log in as a Composio agent.'
542 fi
543
544 + if [ -n "$requested_shell" ]; then
545 + setup_requested_shell
546 + fi
547 +
548 print_post_install_help
549 }
550
install/bash.sh
+2 -76
@@ -8,7 +8,6 @@ error() {
8 exit 1
9 }
10 is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
11 -info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
11 debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
12
13 url_authority() {
@@ -49,53 +48,6 @@ download_installer() {
48 esac
49 }
50
52 -is_unsafe_path() {
53 - case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
54 - variant_cr=$(printf '\r')
55 - case $1 in *"$variant_cr"* | *'
56 -'*) return 0 ;; esac
57 - return 1
58 -}
59 -
60 -render_bin_dir() {
61 - variant_render=$1
62 - case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
63 - printf '%s\n' "$variant_render"
64 -}
65 -
66 -append_path_block() {
67 - variant_file=$1
68 - variant_shell=$2
69 - variant_bin=$3
70 - mkdir -p "$(dirname "$variant_file")"
71 - touch "$variant_file"
72 - grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
73 - case $variant_shell in
74 - fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
75 - *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
76 - esac
77 - printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
78 -}
79 -
80 -inline_shell_setup() {
81 - variant_shell=$1
82 - variant_bin_dir=$2
83 - is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
84 - variant_rendered=$(render_bin_dir "$variant_bin_dir")
85 - case $variant_shell in
86 - zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
87 - fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
88 - bash)
89 - append_path_block "$HOME/.bashrc" bash "$variant_rendered"
90 - if [ -f "$HOME/.bash_profile" ]; then
91 - append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
92 - elif [ -f "$HOME/.bash_login" ]; then
93 - append_path_block "$HOME/.bash_login" bash "$variant_rendered"
94 - fi
95 - ;;
96 - esac
97 -}
98 -
51 cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
52
53 cleanup_on_signal() {
@@ -119,34 +71,8 @@ main() {
71 download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
72 [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
73
122 - COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
123 -
124 - variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
125 - variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
126 - variant_exe=$variant_install_dir/composio
127 - [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
128 -
129 - if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
130 - debug "delegating shell setup to $variant_exe install --shell $variant_shell"
131 - if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
132 - variant_configured=cli
133 - else
134 - debug "falling back to inline $variant_shell shell setup"
135 - inline_shell_setup "$variant_shell" "$variant_bin_dir"
136 - variant_configured=fallback
137 - fi
138 - else
139 - debug "falling back to inline $variant_shell shell setup"
140 - inline_shell_setup "$variant_shell" "$variant_bin_dir"
141 - variant_configured=fallback
142 - fi
143 -
144 - info "Configured $variant_shell shell setup ($variant_configured)."
145 - case $variant_shell in
146 - zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
147 - bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
148 - fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
149 - esac
74 + # The trailing --shell wins over any forwarded one, so the route stays authoritative.
75 + sh "$variant_tmpdir/install.sh" "$@" --shell "$variant_shell"
76 }
77
78 main "$@"
install/fish.sh
+2 -76
@@ -8,7 +8,6 @@ error() {
8 exit 1
9 }
10 is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
11 -info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
11 debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
12
13 url_authority() {
@@ -49,53 +48,6 @@ download_installer() {
48 esac
49 }
50
52 -is_unsafe_path() {
53 - case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
54 - variant_cr=$(printf '\r')
55 - case $1 in *"$variant_cr"* | *'
56 -'*) return 0 ;; esac
57 - return 1
58 -}
59 -
60 -render_bin_dir() {
61 - variant_render=$1
62 - case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
63 - printf '%s\n' "$variant_render"
64 -}
65 -
66 -append_path_block() {
67 - variant_file=$1
68 - variant_shell=$2
69 - variant_bin=$3
70 - mkdir -p "$(dirname "$variant_file")"
71 - touch "$variant_file"
72 - grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
73 - case $variant_shell in
74 - fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
75 - *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
76 - esac
77 - printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
78 -}
79 -
80 -inline_shell_setup() {
81 - variant_shell=$1
82 - variant_bin_dir=$2
83 - is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
84 - variant_rendered=$(render_bin_dir "$variant_bin_dir")
85 - case $variant_shell in
86 - zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
87 - fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
88 - bash)
89 - append_path_block "$HOME/.bashrc" bash "$variant_rendered"
90 - if [ -f "$HOME/.bash_profile" ]; then
91 - append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
92 - elif [ -f "$HOME/.bash_login" ]; then
93 - append_path_block "$HOME/.bash_login" bash "$variant_rendered"
94 - fi
95 - ;;
96 - esac
97 -}
98 -
51 cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
52
53 cleanup_on_signal() {
@@ -119,34 +71,8 @@ main() {
71 download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
72 [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
73
122 - COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
123 -
124 - variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
125 - variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
126 - variant_exe=$variant_install_dir/composio
127 - [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
128 -
129 - if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
130 - debug "delegating shell setup to $variant_exe install --shell $variant_shell"
131 - if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
132 - variant_configured=cli
133 - else
134 - debug "falling back to inline $variant_shell shell setup"
135 - inline_shell_setup "$variant_shell" "$variant_bin_dir"
136 - variant_configured=fallback
137 - fi
138 - else
139 - debug "falling back to inline $variant_shell shell setup"
140 - inline_shell_setup "$variant_shell" "$variant_bin_dir"
141 - variant_configured=fallback
142 - fi
143 -
144 - info "Configured $variant_shell shell setup ($variant_configured)."
145 - case $variant_shell in
146 - zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
147 - bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
148 - fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
149 - esac
74 + # The trailing --shell wins over any forwarded one, so the route stays authoritative.
75 + sh "$variant_tmpdir/install.sh" "$@" --shell "$variant_shell"
76 }
77
78 main "$@"
install/zsh.sh
+2 -76
@@ -8,7 +8,6 @@ error() {
8 exit 1
9 }
10 is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
11 -info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
11 debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
12
13 url_authority() {
@@ -49,53 +48,6 @@ download_installer() {
48 esac
49 }
50
52 -is_unsafe_path() {
53 - case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
54 - variant_cr=$(printf '\r')
55 - case $1 in *"$variant_cr"* | *'
56 -'*) return 0 ;; esac
57 - return 1
58 -}
59 -
60 -render_bin_dir() {
61 - variant_render=$1
62 - case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
63 - printf '%s\n' "$variant_render"
64 -}
65 -
66 -append_path_block() {
67 - variant_file=$1
68 - variant_shell=$2
69 - variant_bin=$3
70 - mkdir -p "$(dirname "$variant_file")"
71 - touch "$variant_file"
72 - grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
73 - case $variant_shell in
74 - fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
75 - *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
76 - esac
77 - printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
78 -}
79 -
80 -inline_shell_setup() {
81 - variant_shell=$1
82 - variant_bin_dir=$2
83 - is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
84 - variant_rendered=$(render_bin_dir "$variant_bin_dir")
85 - case $variant_shell in
86 - zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
87 - fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
88 - bash)
89 - append_path_block "$HOME/.bashrc" bash "$variant_rendered"
90 - if [ -f "$HOME/.bash_profile" ]; then
91 - append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
92 - elif [ -f "$HOME/.bash_login" ]; then
93 - append_path_block "$HOME/.bash_login" bash "$variant_rendered"
94 - fi
95 - ;;
96 - esac
97 -}
98 -
51 cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
52
53 cleanup_on_signal() {
@@ -119,34 +71,8 @@ main() {
71 download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
72 [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
73
122 - COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
123 -
124 - variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
125 - variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
126 - variant_exe=$variant_install_dir/composio
127 - [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
128 -
129 - if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
130 - debug "delegating shell setup to $variant_exe install --shell $variant_shell"
131 - if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
132 - variant_configured=cli
133 - else
134 - debug "falling back to inline $variant_shell shell setup"
135 - inline_shell_setup "$variant_shell" "$variant_bin_dir"
136 - variant_configured=fallback
137 - fi
138 - else
139 - debug "falling back to inline $variant_shell shell setup"
140 - inline_shell_setup "$variant_shell" "$variant_bin_dir"
141 - variant_configured=fallback
142 - fi
143 -
144 - info "Configured $variant_shell shell setup ($variant_configured)."
145 - case $variant_shell in
146 - zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
147 - bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
148 - fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
149 - esac
74 + # The trailing --shell wins over any forwarded one, so the route stays authoritative.
75 + sh "$variant_tmpdir/install.sh" "$@" --shell "$variant_shell"
76 }
77
78 main "$@"
test/install-sh-release-resolution.test.sh
+40 -2
@@ -533,12 +533,50 @@ EOF
533 variant_home="$case_root/variant-$shell_name-home"
534 variant_install="$case_root/variant-$shell_name-install"
535 variant_bin="$case_root/variant-$shell_name-bin"
536 - run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins >/dev/null 2>&1
536 + variant_output=$(run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins 2>&1)
537 grep -Fq "|installer|$variant_bin|install --shell $shell_name" "$composio_log" ||
538 fail "$interpreter_name $shell_name variant delegation"
539 - grep -Eq '^0\|\|[^|]+\|--version$' "$composio_log" || fail "$interpreter_name $shell_name nested help suppression"
539 + assert_contains "$variant_output" "Configured $shell_name shell setup (cli)." "$interpreter_name $shell_name variant confirmation"
540 + assert_not_contains "$variant_output" 'Required next step' "$interpreter_name $shell_name variant must not print setup guidance"
541 + assert_not_contains "$variant_output" 'Optional shell setup' "$interpreter_name $shell_name variant must not print setup guidance"
542 done
543
544 + reset_case
545 + direct_home="$case_root/direct-shell-home"
546 + direct_bin="$case_root/direct-shell-bin"
547 + direct_output=$(run_installer "$direct_home" "$case_root/direct-shell-install" "$direct_bin" "$stable_tag" --shell zsh 2>&1)
548 + grep -Fq "|installer|$direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name --shell delegation"
549 + assert_contains "$direct_output" 'Configured zsh shell setup (cli).' "$interpreter_name --shell confirmation"
550 + assert_not_contains "$direct_output" 'Required next step' "$interpreter_name --shell must not print setup guidance"
551 + [[ ! -e "$direct_home/.zshrc" ]] || fail "$interpreter_name --shell CLI path must not write rc files"
552 +
553 + reset_case
554 + CASE_SHELL_CAPABILITY=unsupported
555 + direct_fallback_home="$case_root/direct-fallback-home"
556 + direct_fallback_output=$(run_installer "$direct_fallback_home" "$case_root/direct-fallback-install" "$case_root/direct-fallback-bin" "$stable_tag" --shell zsh 2>&1)
557 + grep -Fqx '# Composio CLI' "$direct_fallback_home/.zshrc" || fail "$interpreter_name --shell unsupported CLI fallback"
558 + assert_contains "$direct_fallback_output" 'Configured zsh shell setup (fallback).' "$interpreter_name --shell fallback confirmation"
559 +
560 + reset_case
561 + CASE_INSTALL_EXIT=23
562 + direct_failed_home="$case_root/direct-failed-home"
563 + run_installer "$direct_failed_home" "$case_root/direct-failed-install" "$case_root/direct-failed-bin" "$stable_tag" --shell fish >/dev/null 2>&1
564 + grep -Fqx '# Composio CLI' "$direct_failed_home/.config/fish/config.fish" || fail "$interpreter_name --shell failed delegation fallback"
565 +
566 + reset_case
567 + if missing_shell_output=$(run_installer "$case_root/missing-shell-home" "$case_root/missing-shell-install" "$case_root/missing-shell-bin" --shell 2>&1); then
568 + fail "$interpreter_name --shell without a value must fail"
569 + fi
570 + assert_contains "$missing_shell_output" '--shell requires a value' "$interpreter_name --shell missing value"
571 + [[ ! -s "$curl_log" ]] || fail "$interpreter_name --shell missing value must fail before network"
572 +
573 + reset_case
574 + if invalid_shell_output=$(run_installer "$case_root/invalid-shell-home" "$case_root/invalid-shell-install" "$case_root/invalid-shell-bin" --shell tcsh 2>&1); then
575 + fail "$interpreter_name invalid --shell value must fail"
576 + fi
577 + assert_contains "$invalid_shell_output" 'Invalid --shell value' "$interpreter_name invalid --shell message"
578 + [[ ! -s "$curl_log" ]] || fail "$interpreter_name invalid --shell must fail before network"
579 +
580 reset_case
581 CASE_SHELL_CAPABILITY=unsupported
582 fallback_home="$case_root/fallback-home"
ts/e2e-tests/cli/install/e2e.test.ts
+16
@@ -120,6 +120,22 @@ test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
120 test "$(bash -ilc 'composio --version')" = 98.0.0
121 test "$(grep -Fc '# Composio CLI' "$HOME/.bash_profile")" = 1
122 test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
123 +`);
124 + assertSuccess(result);
125 + },
126 + timeout
127 + );
128 +
129 + it(
130 + 'configures bash through the base installer --shell flag idempotently',
131 + async () => {
132 + const result = await run(`
133 +set -eu
134 +curl -fsSL "$INSTALL_BASE_URL/install" | sh -s -- --shell bash
135 +curl -fsSL "$INSTALL_BASE_URL/install" | sh -s -- --shell bash
136 +test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
137 +test "$(bash -ilc 'composio --version')" = 98.0.0
138 +test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
139 `);
140 assertSuccess(result);
141 },