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): add --shell flag to the base installer

jkomynofac4bdca5d72
diff --git a/.github/workflows/build-cli-binaries.yml b/.github/workflows/build-cli-binaries.yml
index b5a88749e..fb0028106 100644
--- a/.github/workflows/build-cli-binaries.yml
+++ b/.github/workflows/build-cli-binaries.yml
@@ -341,7 +341,7 @@ jobs:
export PATH="$COMPOSIO_BIN_DIR:$PATH"
```
- Run `curl -fsSL https://composio.dev/install/zsh | sh`, replacing `zsh` with `bash` or `fish`, when you want the CLI to configure your shell.
+ 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.
## Usage
diff --git a/.github/workflows/cli.install-e2e.yml b/.github/workflows/cli.install-e2e.yml
index 27a36c76a..3e954767b 100644
--- a/.github/workflows/cli.install-e2e.yml
+++ b/.github/workflows/cli.install-e2e.yml
@@ -193,6 +193,7 @@ jobs:
echo ""
echo '```sh'
echo "curl -fsSL \"$RAW_BASE/install.sh\" | sh"
+ echo "curl -fsSL \"$RAW_BASE/install.sh\" | sh -s -- --shell zsh"
echo '```'
echo ""
echo "Shell-specific setup routes (the override points the variant at this PR's base installer):"
diff --git a/INSTALL.md b/INSTALL.md
index 91795ee90..302bc2342 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -9,11 +9,13 @@ curl -fsSL https://composio.dev/install | sh
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:
```bash
-curl -fsSL https://composio.dev/install/zsh | sh
-curl -fsSL https://composio.dev/install/bash | sh
-curl -fsSL https://composio.dev/install/fish | sh
+curl -fsSL https://composio.dev/install | sh -s -- --shell zsh
+curl -fsSL https://composio.dev/install | sh -s -- --shell bash
+curl -fsSL https://composio.dev/install | sh -s -- --shell fish
```
+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.
+
Pin a stable or beta release with `COMPOSIO_INSTALL_VERSION`, or pass the tag as a positional argument:
```bash
@@ -34,6 +36,7 @@ The positional argument takes precedence over `COMPOSIO_INSTALL_VERSION`.
| `COMPOSIO_INSTALL_PLUGINS` | Set to `1` to install plugins for detected agent hosts. | `0` |
| `--agent` | Log in as a Composio agent after installation. | Off |
| `--no-plugins` | Skip plugin setup. Kept for compatibility. | Off |
+| `--shell` | Configure the requested shell (`zsh`, `bash`, or `fish`) after installation. | Off |
## Manual Installation
diff --git a/docs/content/changelog/07-31-26-installer.mdx b/docs/content/changelog/07-31-26-installer.mdx
index e6628d3e0..bd70457c7 100644
--- a/docs/content/changelog/07-31-26-installer.mdx
+++ b/docs/content/changelog/07-31-26-installer.mdx
@@ -10,6 +10,6 @@ The Composio CLI installer now separates the release bundle from the command you
- `curl -fsSL https://composio.dev/install | sh` installs the verified release bundle in `~/.composio` and creates `~/.local/bin/composio`.
- The default flow does not edit shell files, install agent plugins, or log you in.
-- `/install/zsh`, `/install/bash`, and `/install/fish` configure the requested shell explicitly.
+- `--shell zsh|bash|fish` configures the requested shell explicitly, for example `curl -fsSL https://composio.dev/install | sh -s -- --shell zsh`.
- `COMPOSIO_INSTALL_VERSION`, `COMPOSIO_BIN_DIR`, `COMPOSIO_QUIET`, and `COMPOSIO_DEBUG` give you control over version, layout, and output.
- Existing `COMPOSIO_INSTALL_DIR` configurations keep their bundle-directory meaning.
diff --git a/docs/content/docs/cli.mdx b/docs/content/docs/cli.mdx
index 88f043143..70e227c1c 100644
--- a/docs/content/docs/cli.mdx
+++ b/docs/content/docs/cli.mdx
@@ -63,36 +63,37 @@ curl -fsSL https://composio.dev/install | sh -s -- @composio/[email protected]
| `COMPOSIO_GITHUB_API_BASE_URL` | GitHub API base URL. | Derived from `COMPOSIO_GITHUB_URL` |
| `--agent` | Log in as a Composio agent after installation. | Off |
| `--no-plugins` | Skip agent plugin setup. Kept for compatibility and now matches the default. | Off |
+| `--shell` | Configure the requested shell (`zsh`, `bash`, or `fish`) after installation. See [Configure your shell](#configure-your-shell). | Off |
### Configure your shell
-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.
+Pass `--shell` when `~/.local/bin` is not already on `PATH`, or when you want the CLI to configure the requested shell explicitly.
<Tabs groupId="shell" items={['zsh','bash','fish']} persist>
<Tab value="zsh">
```bash
-curl -fsSL https://composio.dev/install/zsh | sh
+curl -fsSL https://composio.dev/install | sh -s -- --shell zsh
```
This configures `~/.zshrc` and delegates setup to `composio install --shell zsh`.
</Tab>
<Tab value="bash">
```bash
-curl -fsSL https://composio.dev/install/bash | sh
+curl -fsSL https://composio.dev/install | sh -s -- --shell bash
```
This configures `~/.bashrc`. If `~/.bash_profile` or `~/.bash_login` exists, it also updates the first active login file so `bash -ilc` can find `composio`.
</Tab>
<Tab value="fish">
```bash
-curl -fsSL https://composio.dev/install/fish | sh
+curl -fsSL https://composio.dev/install | sh -s -- --shell fish
```
This configures `~/.config/fish/config.fish` and delegates setup to `composio install --shell fish`.
</Tab>
</Tabs>
-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`.
+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`.
### Verify the installation
diff --git a/install.sh b/install.sh
index 30bed523a..1cac29b41 100755
--- a/install.sh
+++ b/install.sh
@@ -38,12 +38,13 @@ tildify() {
print_usage() {
printf '%s\n' \
- 'Usage: install.sh [--agent] [--no-plugins] [version-tag]' \
+ 'Usage: install.sh [--agent] [--no-plugins] [--shell zsh|bash|fish] [version-tag]' \
'' \
'Options:' \
- ' --agent Sign up or log in as a Composio agent after installation.' \
- ' --no-plugins Skip agent plugin installation (the default).' \
- ' -h, --help Show this help.' \
+ ' --agent Sign up or log in as a Composio agent after installation.' \
+ ' --no-plugins Skip agent plugin installation (the default).' \
+ ' --shell <shell> Configure zsh, bash, or fish so the composio command is on PATH.' \
+ ' -h, --help Show this help.' \
'' \
'Version tags may be stable or beta, for example 0.3.1 or @composio/[email protected].'
}
@@ -274,6 +275,77 @@ path_contains_bin_dir() {
esac
}
+is_unsafe_path() {
+ case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
+ unsafe_path_cr=$(printf '\r')
+ case $1 in *"$unsafe_path_cr"* | *'
+'*) return 0 ;; esac
+ return 1
+}
+
+render_bin_dir() {
+ render_bin_dir_value=$1
+ case $render_bin_dir_value in "$HOME"/*) render_bin_dir_value=\$HOME/${render_bin_dir_value#"$HOME"/} ;; esac
+ printf '%s\n' "$render_bin_dir_value"
+}
+
+append_path_block() {
+ append_path_file=$1
+ append_path_shell=$2
+ append_path_bin=$3
+ mkdir -p "$(dirname "$append_path_file")"
+ touch "$append_path_file"
+ grep -Fqx '# Composio CLI' "$append_path_file" 2>/dev/null && return 0
+ case $append_path_shell in
+ fish) append_path_line="set --export PATH \"$append_path_bin\" \$PATH" ;;
+ *) append_path_line="export PATH=\"$append_path_bin:\$PATH\"" ;;
+ esac
+ printf '\n# Composio CLI\n%s\n' "$append_path_line" >>"$append_path_file"
+}
+
+inline_shell_setup() {
+ inline_setup_shell=$1
+ inline_setup_bin_dir=$2
+ is_unsafe_path "$inline_setup_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
+ inline_setup_rendered=$(render_bin_dir "$inline_setup_bin_dir")
+ case $inline_setup_shell in
+ zsh) append_path_block "$HOME/.zshrc" zsh "$inline_setup_rendered" ;;
+ fish) append_path_block "$HOME/.config/fish/config.fish" fish "$inline_setup_rendered" ;;
+ bash)
+ append_path_block "$HOME/.bashrc" bash "$inline_setup_rendered"
+ if [ -f "$HOME/.bash_profile" ]; then
+ append_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered"
+ elif [ -f "$HOME/.bash_login" ]; then
+ append_path_block "$HOME/.bash_login" bash "$inline_setup_rendered"
+ fi
+ ;;
+ esac
+}
+
+setup_requested_shell() {
+ if "$exe" install --help 2>&1 | grep -q -- '--shell'; then
+ debug "delegating shell setup to $exe install --shell $requested_shell"
+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$COMPOSIO_BIN_DIR" "$exe" install --shell "$requested_shell"; then
+ shell_configured=cli
+ else
+ debug "falling back to inline $requested_shell shell setup"
+ inline_shell_setup "$requested_shell" "$COMPOSIO_BIN_DIR"
+ shell_configured=fallback
+ fi
+ else
+ debug "falling back to inline $requested_shell shell setup"
+ inline_shell_setup "$requested_shell" "$COMPOSIO_BIN_DIR"
+ shell_configured=fallback
+ fi
+
+ info "Configured $requested_shell shell setup ($shell_configured)."
+ case $requested_shell in
+ zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
+ bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
+ fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
+ esac
+}
+
print_post_install_help() {
[ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] || return 0
is_true "${COMPOSIO_QUIET:-}" && return 0
@@ -304,13 +376,15 @@ print_post_install_help() {
fi
printf '\n'
- if [ -n "$shell_route" ]; then
+ if [ -n "$requested_shell" ]; then
+ : # Shell setup already ran; skip the setup suggestion.
+ elif [ -n "$shell_route" ]; then
if [ "$guidance_required" = 1 ]; then
printf 'Required next step for %s:\n\n' "$shell_name"
else
printf 'Optional shell setup for future PATH changes:\n\n'
fi
- printf ' curl -fsSL https://composio.dev/install/%s | sh\n' "$shell_route"
+ printf ' curl -fsSL https://composio.dev/install | sh -s -- --shell %s\n' "$shell_route"
printf '\nThis configures %s.\n' "$shell_config"
elif path_contains_bin_dir; then
printf 'The composio command is available on PATH.\n'
@@ -337,6 +411,7 @@ main() {
install_agent=0
install_plugins=${COMPOSIO_INSTALL_PLUGINS:-0}
version_arg=
+ requested_shell=
case $install_plugins in
0 | 1) ;;
@@ -347,6 +422,14 @@ main() {
case $1 in
--agent) install_agent=1 ;;
--no-plugins) install_plugins=0 ;;
+ --shell)
+ [ "$#" -ge 2 ] || error '--shell requires a value: zsh, bash, or fish'
+ case $2 in
+ zsh | bash | fish) requested_shell=$2 ;;
+ *) error "Invalid --shell value \"$2\". Expected zsh, bash, or fish." ;;
+ esac
+ shift
+ ;;
-h | --help)
print_usage
return 0
@@ -458,6 +541,10 @@ main() {
error 'Failed to sign up or log in as a Composio agent.'
fi
+ if [ -n "$requested_shell" ]; then
+ setup_requested_shell
+ fi
+
print_post_install_help
}
diff --git a/install/bash.sh b/install/bash.sh
index 1c3fb2278..1f9d1a91e 100755
--- a/install/bash.sh
+++ b/install/bash.sh
@@ -8,7 +8,6 @@ error() {
exit 1
}
is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
-info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
url_authority() {
@@ -49,53 +48,6 @@ download_installer() {
esac
}
-is_unsafe_path() {
- case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
- variant_cr=$(printf '\r')
- case $1 in *"$variant_cr"* | *'
-'*) return 0 ;; esac
- return 1
-}
-
-render_bin_dir() {
- variant_render=$1
- case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
- printf '%s\n' "$variant_render"
-}
-
-append_path_block() {
- variant_file=$1
- variant_shell=$2
- variant_bin=$3
- mkdir -p "$(dirname "$variant_file")"
- touch "$variant_file"
- grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
- case $variant_shell in
- fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
- *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
- esac
- printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
-}
-
-inline_shell_setup() {
- variant_shell=$1
- variant_bin_dir=$2
- is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
- variant_rendered=$(render_bin_dir "$variant_bin_dir")
- case $variant_shell in
- zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
- fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
- bash)
- append_path_block "$HOME/.bashrc" bash "$variant_rendered"
- if [ -f "$HOME/.bash_profile" ]; then
- append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
- elif [ -f "$HOME/.bash_login" ]; then
- append_path_block "$HOME/.bash_login" bash "$variant_rendered"
- fi
- ;;
- esac
-}
-
cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
cleanup_on_signal() {
@@ -119,34 +71,8 @@ main() {
download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
[ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
- COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
-
- variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
- variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
- variant_exe=$variant_install_dir/composio
- [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
-
- if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
- debug "delegating shell setup to $variant_exe install --shell $variant_shell"
- if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
- variant_configured=cli
- else
- debug "falling back to inline $variant_shell shell setup"
- inline_shell_setup "$variant_shell" "$variant_bin_dir"
- variant_configured=fallback
- fi
- else
- debug "falling back to inline $variant_shell shell setup"
- inline_shell_setup "$variant_shell" "$variant_bin_dir"
- variant_configured=fallback
- fi
-
- info "Configured $variant_shell shell setup ($variant_configured)."
- case $variant_shell in
- zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
- bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
- fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
- esac
+ # The trailing --shell wins over any forwarded one, so the route stays authoritative.
+ sh "$variant_tmpdir/install.sh" "$@" --shell "$variant_shell"
}
main "$@"
diff --git a/install/fish.sh b/install/fish.sh
index df47c7abe..d77d0f894 100755
--- a/install/fish.sh
+++ b/install/fish.sh
@@ -8,7 +8,6 @@ error() {
exit 1
}
is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
-info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
url_authority() {
@@ -49,53 +48,6 @@ download_installer() {
esac
}
-is_unsafe_path() {
- case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
- variant_cr=$(printf '\r')
- case $1 in *"$variant_cr"* | *'
-'*) return 0 ;; esac
- return 1
-}
-
-render_bin_dir() {
- variant_render=$1
- case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
- printf '%s\n' "$variant_render"
-}
-
-append_path_block() {
- variant_file=$1
- variant_shell=$2
- variant_bin=$3
- mkdir -p "$(dirname "$variant_file")"
- touch "$variant_file"
- grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
- case $variant_shell in
- fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
- *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
- esac
- printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
-}
-
-inline_shell_setup() {
- variant_shell=$1
- variant_bin_dir=$2
- is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
- variant_rendered=$(render_bin_dir "$variant_bin_dir")
- case $variant_shell in
- zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
- fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
- bash)
- append_path_block "$HOME/.bashrc" bash "$variant_rendered"
- if [ -f "$HOME/.bash_profile" ]; then
- append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
- elif [ -f "$HOME/.bash_login" ]; then
- append_path_block "$HOME/.bash_login" bash "$variant_rendered"
- fi
- ;;
- esac
-}
-
cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
cleanup_on_signal() {
@@ -119,34 +71,8 @@ main() {
download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
[ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
- COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
-
- variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
- variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
- variant_exe=$variant_install_dir/composio
- [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
-
- if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
- debug "delegating shell setup to $variant_exe install --shell $variant_shell"
- if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
- variant_configured=cli
- else
- debug "falling back to inline $variant_shell shell setup"
- inline_shell_setup "$variant_shell" "$variant_bin_dir"
- variant_configured=fallback
- fi
- else
- debug "falling back to inline $variant_shell shell setup"
- inline_shell_setup "$variant_shell" "$variant_bin_dir"
- variant_configured=fallback
- fi
-
- info "Configured $variant_shell shell setup ($variant_configured)."
- case $variant_shell in
- zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
- bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
- fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
- esac
+ # The trailing --shell wins over any forwarded one, so the route stays authoritative.
+ sh "$variant_tmpdir/install.sh" "$@" --shell "$variant_shell"
}
main "$@"
diff --git a/install/zsh.sh b/install/zsh.sh
index c7c244e1f..0e2d941fb 100755
--- a/install/zsh.sh
+++ b/install/zsh.sh
@@ -8,7 +8,6 @@ error() {
exit 1
}
is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
-info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
url_authority() {
@@ -49,53 +48,6 @@ download_installer() {
esac
}
-is_unsafe_path() {
- case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
- variant_cr=$(printf '\r')
- case $1 in *"$variant_cr"* | *'
-'*) return 0 ;; esac
- return 1
-}
-
-render_bin_dir() {
- variant_render=$1
- case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
- printf '%s\n' "$variant_render"
-}
-
-append_path_block() {
- variant_file=$1
- variant_shell=$2
- variant_bin=$3
- mkdir -p "$(dirname "$variant_file")"
- touch "$variant_file"
- grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
- case $variant_shell in
- fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
- *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
- esac
- printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
-}
-
-inline_shell_setup() {
- variant_shell=$1
- variant_bin_dir=$2
- is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
- variant_rendered=$(render_bin_dir "$variant_bin_dir")
- case $variant_shell in
- zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
- fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
- bash)
- append_path_block "$HOME/.bashrc" bash "$variant_rendered"
- if [ -f "$HOME/.bash_profile" ]; then
- append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
- elif [ -f "$HOME/.bash_login" ]; then
- append_path_block "$HOME/.bash_login" bash "$variant_rendered"
- fi
- ;;
- esac
-}
-
cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
cleanup_on_signal() {
@@ -119,34 +71,8 @@ main() {
download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
[ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
- COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
-
- variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
- variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
- variant_exe=$variant_install_dir/composio
- [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
-
- if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
- debug "delegating shell setup to $variant_exe install --shell $variant_shell"
- if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
- variant_configured=cli
- else
- debug "falling back to inline $variant_shell shell setup"
- inline_shell_setup "$variant_shell" "$variant_bin_dir"
- variant_configured=fallback
- fi
- else
- debug "falling back to inline $variant_shell shell setup"
- inline_shell_setup "$variant_shell" "$variant_bin_dir"
- variant_configured=fallback
- fi
-
- info "Configured $variant_shell shell setup ($variant_configured)."
- case $variant_shell in
- zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
- bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
- fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
- esac
+ # The trailing --shell wins over any forwarded one, so the route stays authoritative.
+ sh "$variant_tmpdir/install.sh" "$@" --shell "$variant_shell"
}
main "$@"
diff --git a/test/install-sh-release-resolution.test.sh b/test/install-sh-release-resolution.test.sh
index b6ad00040..440f2dabf 100755
--- a/test/install-sh-release-resolution.test.sh
+++ b/test/install-sh-release-resolution.test.sh
@@ -533,12 +533,50 @@ EOF
variant_home="$case_root/variant-$shell_name-home"
variant_install="$case_root/variant-$shell_name-install"
variant_bin="$case_root/variant-$shell_name-bin"
- run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins >/dev/null 2>&1
+ variant_output=$(run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins 2>&1)
grep -Fq "|installer|$variant_bin|install --shell $shell_name" "$composio_log" ||
fail "$interpreter_name $shell_name variant delegation"
- grep -Eq '^0\|\|[^|]+\|--version$' "$composio_log" || fail "$interpreter_name $shell_name nested help suppression"
+ assert_contains "$variant_output" "Configured $shell_name shell setup (cli)." "$interpreter_name $shell_name variant confirmation"
+ assert_not_contains "$variant_output" 'Required next step' "$interpreter_name $shell_name variant must not print setup guidance"
+ assert_not_contains "$variant_output" 'Optional shell setup' "$interpreter_name $shell_name variant must not print setup guidance"
done
+ reset_case
+ direct_home="$case_root/direct-shell-home"
+ direct_bin="$case_root/direct-shell-bin"
+ direct_output=$(run_installer "$direct_home" "$case_root/direct-shell-install" "$direct_bin" "$stable_tag" --shell zsh 2>&1)
+ grep -Fq "|installer|$direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name --shell delegation"
+ assert_contains "$direct_output" 'Configured zsh shell setup (cli).' "$interpreter_name --shell confirmation"
+ assert_not_contains "$direct_output" 'Required next step' "$interpreter_name --shell must not print setup guidance"
+ [[ ! -e "$direct_home/.zshrc" ]] || fail "$interpreter_name --shell CLI path must not write rc files"
+
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ direct_fallback_home="$case_root/direct-fallback-home"
+ direct_fallback_output=$(run_installer "$direct_fallback_home" "$case_root/direct-fallback-install" "$case_root/direct-fallback-bin" "$stable_tag" --shell zsh 2>&1)
+ grep -Fqx '# Composio CLI' "$direct_fallback_home/.zshrc" || fail "$interpreter_name --shell unsupported CLI fallback"
+ assert_contains "$direct_fallback_output" 'Configured zsh shell setup (fallback).' "$interpreter_name --shell fallback confirmation"
+
+ reset_case
+ CASE_INSTALL_EXIT=23
+ direct_failed_home="$case_root/direct-failed-home"
+ run_installer "$direct_failed_home" "$case_root/direct-failed-install" "$case_root/direct-failed-bin" "$stable_tag" --shell fish >/dev/null 2>&1
+ grep -Fqx '# Composio CLI' "$direct_failed_home/.config/fish/config.fish" || fail "$interpreter_name --shell failed delegation fallback"
+
+ reset_case
+ 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
+ fail "$interpreter_name --shell without a value must fail"
+ fi
+ assert_contains "$missing_shell_output" '--shell requires a value' "$interpreter_name --shell missing value"
+ [[ ! -s "$curl_log" ]] || fail "$interpreter_name --shell missing value must fail before network"
+
+ reset_case
+ 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
+ fail "$interpreter_name invalid --shell value must fail"
+ fi
+ assert_contains "$invalid_shell_output" 'Invalid --shell value' "$interpreter_name invalid --shell message"
+ [[ ! -s "$curl_log" ]] || fail "$interpreter_name invalid --shell must fail before network"
+
reset_case
CASE_SHELL_CAPABILITY=unsupported
fallback_home="$case_root/fallback-home"
diff --git a/ts/e2e-tests/cli/install/e2e.test.ts b/ts/e2e-tests/cli/install/e2e.test.ts
index ba361d583..69f4c4390 100644
--- a/ts/e2e-tests/cli/install/e2e.test.ts
+++ b/ts/e2e-tests/cli/install/e2e.test.ts
@@ -120,6 +120,22 @@ test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
test "$(bash -ilc 'composio --version')" = 98.0.0
test "$(grep -Fc '# Composio CLI' "$HOME/.bash_profile")" = 1
test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
+`);
+ assertSuccess(result);
+ },
+ timeout
+ );
+
+ it(
+ 'configures bash through the base installer --shell flag idempotently',
+ async () => {
+ const result = await run(`
+set -eu
+curl -fsSL "$INSTALL_BASE_URL/install" | sh -s -- --shell bash
+curl -fsSL "$INSTALL_BASE_URL/install" | sh -s -- --shell bash
+test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
+test "$(bash -ilc 'composio --version')" = 98.0.0
+test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
`);
assertSuccess(result);
},