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): make automatic shell setup the installer default

jkomyno2ff9d9f97ead
diff --git a/install.sh b/install.sh
index a6ea15cab..170d894a8 100755
--- a/install.sh
+++ b/install.sh
@@ -45,7 +45,8 @@ print_usage() {
' --no-plugins Skip agent plugin installation (the default).' \
' -h, --help Show this help.' \
'' \
- 'Set COMPOSIO_INSTALL_SHELL=zsh|bash|fish to configure that shell after installation.' \
+ 'Set COMPOSIO_INSTALL_SHELL=auto|zsh|bash|fish|none to control automatic shell setup' \
+ "(default auto: detect the login shell from \$SHELL; none: install only)." \
'Version tags may be stable or beta, for example 0.3.1 or @composio/[email protected].'
}
@@ -268,13 +269,62 @@ install_entry_point() {
error "Failed to create entry point \"$entry_point\""
}
-path_contains_bin_dir() {
- case :${PATH:-}: in
+inherited_path_contains_bin_dir() {
+ case :$inherited_path: in
*:"$resolved_bin_dir":*) return 0 ;;
*) return 1 ;;
esac
}
+# Renders a value as one POSIX-safe shell word so recovery commands stay
+# copy-paste safe even when the installed path contains whitespace.
+shell_quote() {
+ case $1 in
+ '') printf "''\n" ;;
+ *[!A-Za-z0-9_./-]*) printf '%s\n' "$1" | sed "s/'/'\\\\''/g; s/^/'/; s/\$/'/" ;;
+ *) printf '%s\n' "$1" ;;
+ esac
+}
+
+# Follows symlinks and resolves the parent directory physically, so two paths
+# compare equal exactly when they name the same executable (KD3).
+resolve_physical_path() {
+ resolve_physical_target=$1
+ resolve_physical_steps=0
+ while [ -L "$resolve_physical_target" ] && [ "$resolve_physical_steps" -lt 40 ]; do
+ resolve_physical_link=$(readlink "$resolve_physical_target") || break
+ case $resolve_physical_link in
+ /*) resolve_physical_target=$resolve_physical_link ;;
+ *) resolve_physical_target=$(dirname "$resolve_physical_target")/$resolve_physical_link ;;
+ esac
+ resolve_physical_steps=$((resolve_physical_steps + 1))
+ done
+ resolve_physical_base=$(basename "$resolve_physical_target")
+ if resolve_physical_dir=$(cd "$(dirname "$resolve_physical_target")" 2>/dev/null && pwd -P); then
+ printf '%s/%s\n' "$resolve_physical_dir" "$resolve_physical_base"
+ else
+ printf '%s\n' "$resolve_physical_target"
+ fi
+}
+
+# Resolves the composio command against the PATH snapshot taken before any
+# installer code could modify PATH: what the invoking terminal can run.
+resolve_inherited_command() {
+ PATH=$inherited_path command -v composio 2>/dev/null
+}
+
+compute_inherited_resolution() {
+ inherited_command=$(resolve_inherited_command) || inherited_command=
+ inherited_resolution=unresolved
+ if [ -n "$inherited_command" ]; then
+ if [ "$(resolve_physical_path "$inherited_command")" = "$(resolve_physical_path "$exe")" ]; then
+ inherited_resolution=installed
+ else
+ inherited_resolution=shadowed
+ fi
+ fi
+}
+
is_unsafe_path() {
case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
unsafe_path_cr=$(printf '\r')
@@ -289,109 +339,183 @@ render_bin_dir() {
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\"" ;;
+path_block_line() {
+ case $1 in
+ fish) printf "set --export PATH \"%s\" \$PATH\n" "$2" ;;
+ *) printf "export PATH=\"%s:\$PATH\"\n" "$2" ;;
esac
- printf '\n# Composio CLI\n%s\n' "$append_path_line" >>"$append_path_file"
+}
+
+# Succeeds only when the file holds exactly one managed marker block and that
+# block already names the expected line.
+path_block_current() {
+ awk -v expected="$2" '
+ $0 == "# Composio CLI" { markers++; pending = 1; next }
+ pending { pending = 0; if ($0 == expected) matches++ }
+ END { exit !(markers == 1 && matches == 1) }
+ ' "$1" 2>/dev/null
+}
+
+# Reconciles the single managed PATH block in one startup file: keeps an
+# already-current block, replaces stale managed blocks, preserves unmanaged
+# content, and reports every failure through its return status.
+write_path_block() {
+ write_path_file=$1
+ write_path_line=$(path_block_line "$2" "$3") || return 1
+ mkdir -p "$(dirname "$write_path_file")" 2>/dev/null || return 1
+ if [ -e "$write_path_file" ] && [ ! -f "$write_path_file" ]; then
+ return 1
+ fi
+ if [ ! -f "$write_path_file" ]; then
+ touch "$write_path_file" 2>/dev/null || return 1
+ fi
+ if path_block_current "$write_path_file" "$write_path_line"; then
+ info "$(tildify "$write_path_file") is already up to date."
+ return 0
+ fi
+ write_path_tmp=$write_path_file.composio.tmp
+ if ! awk '
+ pending { pending = 0; next }
+ $0 == "# Composio CLI" { pending = 1; next }
+ { print }
+ ' "$write_path_file" >"$write_path_tmp" 2>/dev/null; then
+ rm -f "$write_path_tmp"
+ return 1
+ fi
+ if ! printf '\n# Composio CLI\n%s\n' "$write_path_line" >>"$write_path_tmp" 2>/dev/null; then
+ rm -f "$write_path_tmp"
+ return 1
+ fi
+ if ! mv "$write_path_tmp" "$write_path_file" 2>/dev/null; then
+ rm -f "$write_path_tmp"
+ return 1
+ fi
+ info "Updated $(tildify "$write_path_file")."
+ return 0
}
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"
+ if is_unsafe_path "$inline_setup_bin_dir"; then
+ return 1
+ fi
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" ;;
+ zsh) write_path_block "$HOME/.zshrc" zsh "$inline_setup_rendered" || return 1 ;;
+ fish) write_path_block "$HOME/.config/fish/config.fish" fish "$inline_setup_rendered" || return 1 ;;
bash)
- append_path_block "$HOME/.bashrc" bash "$inline_setup_rendered"
+ inline_setup_status=0
+ write_path_block "$HOME/.bashrc" bash "$inline_setup_rendered" || inline_setup_status=1
if [ -f "$HOME/.bash_profile" ]; then
- append_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered"
+ write_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered" || inline_setup_status=1
elif [ -f "$HOME/.bash_login" ]; then
- append_path_block "$HOME/.bash_login" bash "$inline_setup_rendered"
+ write_path_block "$HOME/.bash_login" bash "$inline_setup_rendered" || inline_setup_status=1
fi
+ [ "$inline_setup_status" -eq 0 ] || return 1
;;
+ *) return 1 ;;
esac
+ return 0
}
setup_requested_shell() {
+ if is_unsafe_path "$resolved_bin_dir"; then
+ warn "Skipping automatic shell setup: the executable directory \"$resolved_bin_dir\" contains unsupported characters."
+ return 1
+ fi
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
+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$resolved_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
+ info "Configured $requested_shell shell setup ($shell_configured)."
+ return 0
fi
- else
- debug "falling back to inline $requested_shell shell setup"
- inline_shell_setup "$requested_shell" "$COMPOSIO_BIN_DIR"
+ fi
+ debug "falling back to inline $requested_shell shell setup"
+ if inline_shell_setup "$requested_shell" "$resolved_bin_dir"; then
shell_configured=fallback
+ info "Configured $requested_shell shell setup ($shell_configured)."
+ return 0
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
+ return 1
}
+# Final action block for every non-failure flow (KD4 state matrix). KD7: this
+# is the last output; nothing prints after it. Suppressible because it only
+# covers normal success.
print_post_install_help() {
[ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] || return 0
- is_true "${COMPOSIO_QUIET:-}" && return 0
-
- shell_name=${SHELL:-}
- shell_name=${shell_name##*/}
- shell_route=
- shell_config=
- case $shell_name in
- zsh)
- shell_route=zsh
- shell_config=~/.zshrc
- ;;
- bash)
- shell_route=bash
- shell_config=~/.bashrc
- ;;
- fish)
- shell_route=fish
- shell_config=~/.config/fish/config.fish
- ;;
- esac
-
- guidance_required=0
- path_contains_bin_dir || guidance_required=1
- if [ "$shell_name" = bash ] && { [ -f "$HOME/.bash_profile" ] || [ -f "$HOME/.bash_login" ]; }; then
- guidance_required=1
+ if is_true "${COMPOSIO_QUIET:-}"; then
+ return 0
fi
+ compute_inherited_resolution
printf '\n'
- 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"
+
+ if [ "$install_agent" = 1 ]; then
+ printf 'Composio agent login complete.\n'
+ if [ "$inherited_resolution" != installed ]; then
+ if [ "$shell_setup_outcome" = success ]; then
+ printf 'Open a new terminal to use the composio command.\n'
+ else
+ printf 'Run composio from its installed location:\n\n %s --help\n' "$(shell_quote "$exe")"
+ fi
+ fi
+ return 0
+ fi
+
+ # Case A: the invoking terminal already resolves the installed executable.
+ if [ "$inherited_resolution" = installed ]; then
+ if [ "$shell_setup_outcome" = success ] || [ "$shell_setup_mode" = none ]; then
+ printf 'composio is ready.\n\n composio login\n'
+ return 0
+ fi
+ fi
+
+ if [ "$shell_setup_outcome" = success ]; then
+ if [ "$inherited_resolution" = shadowed ]; then
+ printf 'Another composio command at %s takes precedence in this terminal.\n' "$inherited_command"
+ printf 'To use the newly installed CLI, run:\n\n %s login\n' "$(shell_quote "$exe")"
else
- printf 'Optional shell setup for future PATH changes:\n\n'
+ # Case B: configured for future terminals, vocabulary-free.
+ printf 'Open a new terminal, then run:\n\n composio login\n'
fi
- printf ' curl -fsSL https://composio.dev/install | COMPOSIO_INSTALL_SHELL=%s sh\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'
+ return 0
+ fi
+
+ # Install-only guidance: COMPOSIO_INSTALL_SHELL=none or an unrecognized
+ # login shell. Never point the user at a shadowed bare command.
+ if [ "$shell_setup_mode" = none ]; then
+ printf 'Shell setup was skipped (COMPOSIO_INSTALL_SHELL=none).\n'
+ else
+ printf 'Automatic shell setup is not available for your shell.\n'
+ fi
+ case $inherited_resolution in
+ shadowed) printf 'Another composio command at %s takes precedence in this terminal.\n' "$inherited_command" ;;
+ unresolved)
+ if ! inherited_path_contains_bin_dir; then
+ printf 'Add %s to your PATH to use composio in new terminals.\n' "$(tildify "$resolved_bin_dir")"
+ fi
+ ;;
+ esac
+ printf 'To get started now, run:\n\n %s login\n' "$(shell_quote "$exe")"
+}
+
+# Setup failure never fails the install. Recovery travels the stderr warn
+# channel so quiet mode and COMPOSIO_INSTALL_HELP=0 cannot suppress it, and the
+# trusted --version-verified installed executable is always the last output.
+print_setup_failure_ending() {
+ if [ "$install_agent" = 1 ]; then
+ if [ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] && ! is_true "${COMPOSIO_QUIET:-}"; then
+ printf '\nComposio agent login complete.\n'
+ fi
+ warn "Automatic PATH setup for $requested_shell failed. The Composio CLI is installed and unaffected."
+ printf '\nRun composio from its installed location:\n\n %s --help\n' "$(shell_quote "$exe")" >&2
else
- printf 'Add %s to PATH, then start a new shell.\n' "$(tildify "$resolved_bin_dir")"
+ warn "Automatic PATH setup for $requested_shell failed. The Composio CLI is installed and unaffected."
+ printf '\nTo get started, run:\n\n %s login\n' "$(shell_quote "$exe")" >&2
fi
- printf "\nRun \`composio --help\` to get started.\n"
}
cleanup() {
@@ -408,6 +532,10 @@ cleanup_on_signal() {
}
main() {
+ # Snapshot the PATH the invoking terminal handed us before any installer
+ # code can modify it; every final-state decision uses only this snapshot.
+ inherited_path=${PATH:-}
+
install_agent=0
install_plugins=${COMPOSIO_INSTALL_PLUGINS:-0}
version_arg=
@@ -419,8 +547,8 @@ main() {
esac
case $requested_shell in
- '' | zsh | bash | fish) ;;
- *) error "COMPOSIO_INSTALL_SHELL must be zsh, bash, or fish (got \"$requested_shell\")" ;;
+ '' | auto | zsh | bash | fish | none) ;;
+ *) error "COMPOSIO_INSTALL_SHELL must be auto, zsh, bash, fish, or none (got \"$requested_shell\")" ;;
esac
while [ "$#" -gt 0 ]; do
@@ -440,6 +568,21 @@ main() {
shift
done
+ # Resolve the setup mode right after argument parsing: auto (the default)
+ # infers the login shell from $SHELL and degrades to install-only when it
+ # is unset or unrecognized; none is the documented install-only opt-out.
+ shell_setup_mode=${requested_shell:-auto}
+ case $shell_setup_mode in
+ auto)
+ login_shell=$(basename "${SHELL:-}" 2>/dev/null) || login_shell=
+ case $login_shell in
+ zsh | bash | fish) requested_shell=$login_shell ;;
+ *) requested_shell= ;;
+ esac
+ ;;
+ none) requested_shell= ;;
+ esac
+
COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-ComposioHQ}
COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-composio}
COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-https://github.com}
@@ -526,6 +669,12 @@ main() {
info "The composio entry point is $(tildify "$resolved_bin_dir/composio")"
fi
+ # Delegated CLI invocations below may spawn composio subprocesses; make the
+ # fresh entry point resolvable for them. Final-state decisions keep using
+ # the inherited snapshot taken at the top of main().
+ PATH=$resolved_bin_dir:$PATH
+ export PATH
+
if [ "$install_plugins" = 1 ]; then
info 'Installing plugins for detected agent hosts...'
COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" setup --target auto --yes --if-present ||
@@ -538,11 +687,20 @@ main() {
error 'Failed to sign up or log in as a Composio agent.'
fi
+ shell_setup_outcome=skipped
if [ -n "$requested_shell" ]; then
- setup_requested_shell
+ if setup_requested_shell; then
+ shell_setup_outcome=success
+ else
+ shell_setup_outcome=failure
+ fi
fi
- print_post_install_help
+ if [ "$shell_setup_outcome" = failure ]; then
+ print_setup_failure_ending
+ else
+ print_post_install_help
+ fi
}
main "$@"
diff --git a/test/install-sh-release-resolution.test.sh b/test/install-sh-release-resolution.test.sh
index f03e82519..e4aa674f6 100755
--- a/test/install-sh-release-resolution.test.sh
+++ b/test/install-sh-release-resolution.test.sh
@@ -4,6 +4,9 @@ set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
suite_tmp="$(mktemp -d)"
trap 'rm -rf "$suite_tmp"' EXIT
+# Case A and recovery-path assertions compare resolved physical paths, so the
+# suite root itself must be physical (macOS mktemp returns /var -> /private/var).
+suite_tmp="$(cd "$suite_tmp" && pwd -P)"
fail() {
printf 'FAIL: %s\n' "$*" >&2
@@ -26,6 +29,21 @@ assert_not_contains() {
fi
}
+# Asserts the exact final N lines of an output capture, proving nothing prints
+# after the final action block (KD7: the last block wins).
+assert_tail() {
+ local haystack=$1
+ local expected=$2
+ local label=$3
+ local lines actual
+ lines=$(printf '%s\n' "$expected" | wc -l | tr -d '[:space:]')
+ actual=$(printf '%s\n' "$haystack" | tail -n "$lines")
+ if [[ $actual != "$expected" ]]; then
+ printf 'FAIL: %s\nexpected tail:\n%s\nactual tail:\n%s\n' "$label" "$expected" "$actual" >&2
+ exit 1
+ fi
+}
+
wait_for_file() {
local file=$1
local label=$2
@@ -101,11 +119,30 @@ github_url='https://github.example.test'
archive_url="https://downloads.example.test/$stable_tag/$archive_name"
script_url='https://installer.example.test/install.sh'
+# KD4 exact endings: plain indented lines, no box drawing, nothing after them.
+case_a_tail=$'composio is ready.\n\n composio login'
+case_b_tail=$'Open a new terminal, then run:\n\n composio login'
+
interpreters=("$(command -v sh)")
if command -v dash >/dev/null 2>&1 && [[ $(command -v dash) != "${interpreters[0]}" ]]; then
interpreters+=("$(command -v dash)")
fi
+# The installer's final block depends on what the inherited PATH resolves, so
+# strip any real composio installation from the ambient PATH to keep the
+# resolution cases deterministic on developer machines and CI runners.
+sanitize_path() {
+ local entry result=
+ local IFS=':'
+ for entry in $1; do
+ if [[ -n $entry && ! -x $entry/composio ]]; then
+ result+="${result:+:}$entry"
+ fi
+ done
+ printf '%s\n' "$result"
+}
+ambient_path=$(sanitize_path "$PATH")
+
for interpreter in "${interpreters[@]}"; do
interpreter_name=$(basename "$interpreter")
case_root="$suite_tmp/$interpreter_name"
@@ -255,6 +292,9 @@ install)
exit 0
fi
if [ "${2:-}" = --shell ]; then
+ if [ "${TEST_INSTALL_HINT:-0}" = 1 ]; then
+ printf '%s\n' '│ Restart your shell so composio is on PATH │'
+ fi
exit "${TEST_INSTALL_EXIT:-0}"
fi
exit 98
@@ -283,7 +323,7 @@ EOF
unset CASE_GITHUB_URL CASE_API_BASE CASE_INSTALL_VERSION CASE_INSTALL_SHELL CASE_PLUGINS CASE_QUIET CASE_DEBUG CASE_HELP
unset CASE_ALLOW_HTTP_HOST CASE_CHECKSUM_MODE CASE_API_ASSET_URL CASE_BASE_MODE CASE_REDIRECT_DOWNGRADE
unset CASE_SHELL_CAPABILITY CASE_INSTALL_EXIT CASE_SETUP_EXIT CASE_VERSION_EXIT CASE_PATH_PREFIX CASE_UNSET_SHELL
- unset CASE_CURL_DELAY_URL CASE_CURL_DELAY_SECONDS
+ unset CASE_CURL_DELAY_URL CASE_CURL_DELAY_SECONDS CASE_SHELL_VALUE CASE_INSTALL_HINT
rm -f "$case_root/curl-parent.pid"
: >"$curl_log"
: >"$composio_log"
@@ -300,9 +340,9 @@ EOF
installer_command=("$interpreter" -c 'unset SHELL; script=$1; shift; . "$script"' unset-shell "$repo_root/install.sh")
fi
env \
- PATH="${CASE_PATH_PREFIX:-}$fake_bin:$PATH" \
+ PATH="${CASE_PATH_PREFIX:-}$fake_bin:$ambient_path" \
HOME="$home" \
- SHELL=/bin/bash \
+ SHELL="${CASE_SHELL_VALUE:-/bin/bash}" \
COMPOSIO_INSTALL_DIR="$install_dir" \
COMPOSIO_BIN_DIR="$bin_dir" \
COMPOSIO_INSTALL_VERSION="${CASE_INSTALL_VERSION:-}" \
@@ -321,6 +361,7 @@ EOF
TEST_REDIRECT_DOWNGRADE="${CASE_REDIRECT_DOWNGRADE:-0}" \
TEST_SHELL_CAPABILITY="${CASE_SHELL_CAPABILITY:-supported}" \
TEST_INSTALL_EXIT="${CASE_INSTALL_EXIT:-0}" \
+ TEST_INSTALL_HINT="${CASE_INSTALL_HINT:-0}" \
TEST_SETUP_EXIT="${CASE_SETUP_EXIT:-0}" \
TEST_VERSION_EXIT="${CASE_VERSION_EXIT:-0}" \
TEST_CURL_DELAY_URL="${CASE_CURL_DELAY_URL:-}" \
@@ -337,7 +378,7 @@ EOF
shift 4
mkdir -p "$home" "$install_dir" "$bin_dir"
env \
- PATH="$fake_bin:$PATH" \
+ PATH="$fake_bin:$ambient_path" \
HOME="$home" \
SHELL="/bin/$shell_name" \
COMPOSIO_INSTALL_DIR="$install_dir" \
@@ -369,9 +410,14 @@ EOF
expected_install_dir=$(cd "$install_dir" && pwd -P)
[[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target"
assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery"
- assert_contains "$output" 'Required next step for bash:' "$interpreter_name required PATH guidance"
- [[ ! -e "$home/.bashrc" ]] || fail "$interpreter_name default flow must not write rc files"
- [[ $(wc -l <"$composio_log") -eq 1 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
+ grep -Fq "|installer|$bin_dir|install --shell bash" "$composio_log" || fail "$interpreter_name default auto delegation"
+ assert_contains "$output" 'Configured bash shell setup (cli).' "$interpreter_name default auto confirmation"
+ # Inherited-PATH contract: the installer prepends the bin dir to its own PATH
+ # for delegated CLI calls, but the ending must reflect only the PATH the
+ # invoking terminal inherited, which does not contain the bin dir here.
+ assert_tail "$output" "$case_b_tail" "$interpreter_name default auto Case B tail"
+ [[ ! -e "$home/.bashrc" ]] || fail "$interpreter_name delegated default flow must not write rc files"
+ [[ $(wc -l <"$composio_log") -eq 3 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe"
[[ ! -s "$case_root/git.log" ]] || fail "$interpreter_name must not use git"
@@ -445,6 +491,9 @@ EOF
CASE_QUIET=1
quiet_output=$(run_installer "$case_root/quiet-home" "$case_root/quiet-install" "$case_root/quiet-bin" "$stable_tag" 2>&1)
assert_not_contains "$quiet_output" 'Installing Composio CLI' "$interpreter_name quiet output"
+ assert_not_contains "$quiet_output" 'composio login' "$interpreter_name quiet suppresses the normal-success final block"
+ assert_not_contains "$quiet_output" 'composio is ready' "$interpreter_name quiet suppresses the normal-success final block"
+ assert_not_contains "$quiet_output" 'Open a new terminal' "$interpreter_name quiet suppresses the normal-success final block"
reset_case
CASE_DEBUG=1
@@ -454,12 +503,19 @@ EOF
reset_case
CASE_HELP=0
help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1)
- assert_not_contains "$help_suppressed" 'next step' "$interpreter_name help suppression"
+ assert_contains "$help_suppressed" 'Configured bash shell setup (cli).' "$interpreter_name help suppression keeps setup status"
+ assert_not_contains "$help_suppressed" 'composio login' "$interpreter_name help suppression removes the final block"
+ assert_not_contains "$help_suppressed" 'Open a new terminal' "$interpreter_name help suppression removes the final block"
reset_case
CASE_UNSET_SHELL=1
- run_installer "$case_root/unset-shell-home" "$case_root/unset-shell-install" "$case_root/unset-shell-bin" "$stable_tag" >/dev/null 2>&1 ||
+ unset_shell_install="$case_root/unset-shell-install"
+ unset_shell_output=$(run_installer "$case_root/unset-shell-home" "$unset_shell_install" "$case_root/unset-shell-bin" "$stable_tag" 2>&1) ||
fail "$interpreter_name unset SHELL must not fail after installation"
+ if grep -Fq 'install --shell' "$composio_log"; then
+ fail "$interpreter_name unset SHELL must not run shell setup"
+ fi
+ assert_tail "$unset_shell_output" $'To get started now, run:\n\n '"$unset_shell_install/composio login" "$interpreter_name unset SHELL install-only tail"
reset_case
CASE_CURL_DELAY_URL="$github_url/FakeOwner/fake-repo/releases/download/$stable_tag/$archive_name"
@@ -550,6 +606,7 @@ EOF
grep -Fq "|installer|$direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL delegation"
assert_contains "$direct_output" 'Configured zsh shell setup (cli).' "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
assert_not_contains "$direct_output" 'Required next step' "$interpreter_name COMPOSIO_INSTALL_SHELL must not print setup guidance"
+ assert_tail "$direct_output" "$case_b_tail" "$interpreter_name COMPOSIO_INSTALL_SHELL Case B tail"
[[ ! -e "$direct_home/.zshrc" ]] || fail "$interpreter_name COMPOSIO_INSTALL_SHELL CLI path must not write rc files"
reset_case
@@ -572,7 +629,7 @@ EOF
if invalid_shell_output=$(run_installer "$case_root/invalid-shell-home" "$case_root/invalid-shell-install" "$case_root/invalid-shell-bin" 2>&1); then
fail "$interpreter_name invalid COMPOSIO_INSTALL_SHELL must fail"
fi
- assert_contains "$invalid_shell_output" 'COMPOSIO_INSTALL_SHELL must be zsh, bash, or fish' "$interpreter_name invalid COMPOSIO_INSTALL_SHELL message"
+ assert_contains "$invalid_shell_output" 'COMPOSIO_INSTALL_SHELL must be auto, zsh, bash, fish, or none' "$interpreter_name invalid COMPOSIO_INSTALL_SHELL message"
[[ ! -s "$curl_log" ]] || fail "$interpreter_name invalid COMPOSIO_INSTALL_SHELL must fail before network"
reset_case
@@ -599,11 +656,17 @@ EOF
for unsafe_character in ';' ':'; do
reset_case
CASE_SHELL_CAPABILITY=unsupported
- unsafe_home="$case_root/unsafe-${unsafe_character//[^[:alnum:]]/delimiter}-variant-home"
- if run_variant zsh "$unsafe_home" "$case_root/unsafe-variant-install" "$case_root/unsafe${unsafe_character}variant-bin" "$stable_tag" >/dev/null 2>&1; then
- fail "$interpreter_name unsafe variant bin dir with $unsafe_character must fail"
- fi
+ unsafe_slug=${unsafe_character//[^[:alnum:]]/delimiter}
+ unsafe_home="$case_root/unsafe-$unsafe_slug-variant-home"
+ unsafe_install="$case_root/unsafe-$unsafe_slug-variant-install"
+ unsafe_bin="$case_root/unsafe${unsafe_character}variant-bin"
+ unsafe_variant_output=$(run_variant zsh "$unsafe_home" "$unsafe_install" "$unsafe_bin" "$stable_tag" 2>&1) ||
+ fail "$interpreter_name unsafe variant bin dir with $unsafe_character must keep the install successful"
[[ ! -e "$unsafe_home/.zshrc" ]] || fail "$interpreter_name unsafe variant must not write rc file"
+ [[ -x "$unsafe_install/composio" ]] || fail "$interpreter_name unsafe variant must retain the binary"
+ assert_contains "$unsafe_variant_output" 'warning:' "$interpreter_name unsafe variant warning"
+ assert_contains "$unsafe_variant_output" "$unsafe_bin" "$interpreter_name unsafe variant warning names the rejected path"
+ assert_tail "$unsafe_variant_output" $'To get started, run:\n\n '"$unsafe_install/composio login" "$interpreter_name unsafe variant recovery tail"
done
for base_mode in fail empty; do
@@ -616,6 +679,290 @@ EOF
[[ ! -e "$base_failure_home/.zshrc" ]] || fail "$interpreter_name $base_mode download must not write rc"
done
+ # --- Auto shell setup default (KD2/KD3) ---
+
+ # Every recognized default-flow shell delegates through the setup chain.
+ for auto_shell in zsh bash fish; do
+ reset_case
+ CASE_SHELL_VALUE="/bin/$auto_shell"
+ auto_home="$case_root/auto-$auto_shell-home"
+ auto_install="$case_root/auto-$auto_shell-install"
+ auto_bin="$case_root/auto-$auto_shell-bin"
+ auto_output=$(run_installer "$auto_home" "$auto_install" "$auto_bin" "$stable_tag" 2>&1)
+ grep -Fq "|installer|$auto_bin|install --shell $auto_shell" "$composio_log" ||
+ fail "$interpreter_name auto $auto_shell delegation"
+ assert_contains "$auto_output" "Configured $auto_shell shell setup (cli)." "$interpreter_name auto $auto_shell confirmation"
+ assert_tail "$auto_output" "$case_b_tail" "$interpreter_name auto $auto_shell Case B tail"
+ done
+
+ # Repeated default-flow installs keep taking the idempotent setup chain.
+ reset_case
+ idempotent_home="$case_root/idempotent-home"
+ idempotent_install="$case_root/idempotent-install"
+ idempotent_bin="$case_root/idempotent-bin"
+ run_installer "$idempotent_home" "$idempotent_install" "$idempotent_bin" "$stable_tag" >/dev/null 2>&1
+ run_installer "$idempotent_home" "$idempotent_install" "$idempotent_bin" "$stable_tag" >/dev/null 2>&1
+ [[ $(grep -c 'install --shell bash' "$composio_log") -eq 2 ]] ||
+ fail "$interpreter_name repeated auto installs must re-run idempotent setup"
+
+ # COMPOSIO_INSTALL_SHELL=none preserves install-only behavior.
+ reset_case
+ CASE_INSTALL_SHELL=none
+ none_home="$case_root/none-home"
+ none_install="$case_root/none-install"
+ none_output=$(run_installer "$none_home" "$none_install" "$case_root/none-bin" "$stable_tag" 2>&1)
+ if grep -Fq 'install --shell' "$composio_log"; then
+ fail "$interpreter_name none must not run shell setup"
+ fi
+ [[ ! -e "$none_home/.bashrc" && ! -e "$none_home/.bash_profile" ]] || fail "$interpreter_name none must not write rc files"
+ assert_contains "$none_output" 'COMPOSIO_INSTALL_SHELL=none' "$interpreter_name none skip disclosure"
+ assert_tail "$none_output" $'To get started now, run:\n\n '"$none_install/composio login" "$interpreter_name none install-only tail"
+
+ # none + already-resolving installed command uses the bare Case A ending.
+ reset_case
+ CASE_INSTALL_SHELL=none
+ none_ready_bin="$case_root/none-ready-bin"
+ CASE_PATH_PREFIX="$none_ready_bin:"
+ none_ready_output=$(run_installer "$case_root/none-ready-home" "$case_root/none-ready-install" "$none_ready_bin" "$stable_tag" 2>&1)
+ assert_tail "$none_ready_output" "$case_a_tail" "$interpreter_name none Case A tail"
+
+ # Case A: recognized shell, setup succeeds, and the inherited PATH already
+ # resolves the installed entry point. Setup still runs (idempotent).
+ reset_case
+ ready_bin="$case_root/ready-bin"
+ CASE_PATH_PREFIX="$ready_bin:"
+ ready_output=$(run_installer "$case_root/ready-home" "$case_root/ready-install" "$ready_bin" "$stable_tag" 2>&1)
+ grep -Fq 'install --shell bash' "$composio_log" || fail "$interpreter_name Case A still runs idempotent setup"
+ assert_tail "$ready_output" "$case_a_tail" "$interpreter_name Case A tail"
+
+ # Explicit shell + resolving command also ends in Case A.
+ reset_case
+ CASE_INSTALL_SHELL=zsh
+ explicit_ready_bin="$case_root/explicit-ready-bin"
+ CASE_PATH_PREFIX="$explicit_ready_bin:"
+ explicit_ready_output=$(run_installer "$case_root/explicit-ready-home" "$case_root/explicit-ready-install" "$explicit_ready_bin" "$stable_tag" 2>&1)
+ assert_tail "$explicit_ready_output" "$case_a_tail" "$interpreter_name explicit shell Case A tail"
+
+ # Physical-path identity: a pre-existing symlink on PATH that resolves to the
+ # installed executable still counts as Case A.
+ reset_case
+ alias_dir="$case_root/alias-dir"
+ alias_install="$case_root/alias-install"
+ mkdir -p "$alias_dir" "$alias_install"
+ ln -sf "$alias_install/composio" "$alias_dir/composio"
+ CASE_PATH_PREFIX="$alias_dir:"
+ alias_output=$(run_installer "$case_root/alias-home" "$alias_install" "$case_root/alias-bin" "$stable_tag" 2>&1)
+ assert_tail "$alias_output" "$case_a_tail" "$interpreter_name symlink-alias Case A tail"
+
+ # Unknown $SHELL degrades to install-only guidance plus the trusted absolute command.
+ reset_case
+ CASE_SHELL_VALUE=/bin/tcsh
+ unknown_home="$case_root/unknown-shell-home"
+ unknown_install="$case_root/unknown-shell-install"
+ unknown_output=$(run_installer "$unknown_home" "$unknown_install" "$case_root/unknown-shell-bin" "$stable_tag" 2>&1)
+ if grep -Fq 'install --shell' "$composio_log"; then
+ fail "$interpreter_name unknown shell must not run shell setup"
+ fi
+ [[ ! -e "$unknown_home/.bashrc" ]] || fail "$interpreter_name unknown shell must not write rc files"
+ assert_tail "$unknown_output" $'To get started now, run:\n\n '"$unknown_install/composio login" "$interpreter_name unknown shell install-only tail"
+
+ # Shadowing: bin dir on the inherited PATH, but another composio resolves
+ # first. The ending must never run the shadowed bare command.
+ reset_case
+ shadow_dir="$case_root/shadow-dir"
+ mkdir -p "$shadow_dir"
+ printf '#!/bin/sh\nexit 0\n' >"$shadow_dir/composio"
+ chmod +x "$shadow_dir/composio"
+ shadow_bin="$case_root/shadow-bin"
+ shadow_install="$case_root/shadow-install"
+ CASE_PATH_PREFIX="$shadow_dir:$shadow_bin:"
+ shadow_output=$(run_installer "$case_root/shadow-home" "$shadow_install" "$shadow_bin" "$stable_tag" 2>&1)
+ assert_contains "$shadow_output" "$shadow_dir/composio" "$interpreter_name shadow ending names the shadowing command"
+ assert_tail "$shadow_output" $'To use the newly installed CLI, run:\n\n '"$shadow_install/composio login" "$interpreter_name shadow tail avoids the shadowed bare command"
+
+ # Pinned old CLI: supports --shell but ignores the invocation-origin hint and
+ # prints its own boxed restart hint. A relative COMPOSIO_BIN_DIR must never
+ # reach setup raw; startup files stay untouched; the installer's plain final
+ # block prints after the old hint and supersedes it.
+ reset_case
+ CASE_INSTALL_HINT=1
+ oldcli_home="$case_root/oldcli-home"
+ oldcli_work="$case_root/oldcli-work"
+ oldcli_install="$case_root/oldcli-install"
+ mkdir -p "$oldcli_work"
+ oldcli_output=$(cd "$oldcli_work" && run_installer "$oldcli_home" "$oldcli_install" "rel-bin" "$stable_tag" 2>&1)
+ grep -Fq "|installer|$oldcli_work/rel-bin|install --shell bash" "$composio_log" ||
+ fail "$interpreter_name old-CLI setup must receive the resolved absolute bin dir"
+ [[ ! -e "$oldcli_home/.bashrc" && ! -e "$oldcli_home/.bash_profile" ]] ||
+ fail "$interpreter_name old-CLI delegation must leave startup files unchanged"
+ assert_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name old-CLI restart hint passes through"
+ assert_tail "$oldcli_output" "$case_b_tail" "$interpreter_name old-CLI hint superseded by the installer tail"
+
+ # --- Setup write failures stay non-fatal (KD3/KD4) ---
+
+ # Delegated path: CLI --shell fails, inline fallback also fails.
+ reset_case
+ CASE_SHELL_VALUE=/bin/zsh
+ CASE_INSTALL_EXIT=23
+ wf_delegated_home="$case_root/write-failure-delegated-home"
+ wf_delegated_install="$case_root/write-failure-delegated-install"
+ mkdir -p "$wf_delegated_home/.zshrc"
+ wf_delegated_output=$(run_installer "$wf_delegated_home" "$wf_delegated_install" "$case_root/write-failure-delegated-bin" "$stable_tag" 2>&1) ||
+ fail "$interpreter_name delegated setup failure must keep the install successful"
+ [[ -x "$wf_delegated_install/composio" ]] || fail "$interpreter_name delegated setup failure must retain the binary"
+ assert_contains "$wf_delegated_output" 'warning: Automatic PATH setup for zsh failed' "$interpreter_name delegated setup failure warning"
+ assert_tail "$wf_delegated_output" $'To get started, run:\n\n '"$wf_delegated_install/composio login" "$interpreter_name delegated setup failure recovery tail"
+
+ # Inline path: helper failure inside a conditional must propagate explicitly.
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ wf_inline_home="$case_root/write-failure-inline-home"
+ wf_inline_install="$case_root/write-failure-inline-install"
+ mkdir -p "$wf_inline_home/.bashrc"
+ wf_inline_output=$(run_installer "$wf_inline_home" "$wf_inline_install" "$case_root/write-failure-inline-bin" "$stable_tag" 2>&1) ||
+ fail "$interpreter_name inline setup failure must keep the install successful"
+ [[ -x "$wf_inline_install/composio" ]] || fail "$interpreter_name inline setup failure must retain the binary"
+ assert_contains "$wf_inline_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name inline setup failure warning"
+ assert_tail "$wf_inline_output" $'To get started, run:\n\n '"$wf_inline_install/composio login" "$interpreter_name inline setup failure recovery tail"
+
+ # --- Managed-block reconciliation (KD3) ---
+
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ CASE_SHELL_VALUE=/bin/zsh
+ reconcile_home="$case_root/reconcile-home"
+ reconcile_install="$case_root/reconcile-install"
+ reconcile_bin_a="$case_root/reconcile-bin-a"
+ reconcile_bin_b="$case_root/reconcile-bin-b"
+ mkdir -p "$reconcile_home"
+ printf '%s\n' 'alias reconcile-before=1' >"$reconcile_home/.zshrc"
+ reconcile_first=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_a" "$stable_tag" 2>&1)
+ assert_contains "$reconcile_first" 'Updated ~/.zshrc' "$interpreter_name inline setup update disclosure"
+ grep -Fq "export PATH=\"$reconcile_bin_a:\$PATH\"" "$reconcile_home/.zshrc" || fail "$interpreter_name first managed block"
+ printf '%s\n' 'alias reconcile-after=1' >>"$reconcile_home/.zshrc"
+ reconcile_second=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_a" "$stable_tag" 2>&1)
+ assert_contains "$reconcile_second" 'already' "$interpreter_name inline setup already-current disclosure"
+ [[ $(grep -Fc '# Composio CLI' "$reconcile_home/.zshrc") -eq 1 ]] || fail "$interpreter_name idempotent rerun keeps one marker block"
+ reconcile_third=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_b" "$stable_tag" 2>&1)
+ assert_contains "$reconcile_third" 'Updated ~/.zshrc' "$interpreter_name reconcile update disclosure"
+ [[ $(grep -Fc '# Composio CLI' "$reconcile_home/.zshrc") -eq 1 ]] || fail "$interpreter_name reconcile keeps exactly one marker block"
+ grep -Fq "export PATH=\"$reconcile_bin_b:\$PATH\"" "$reconcile_home/.zshrc" || fail "$interpreter_name reconciled managed block"
+ if grep -Fq "$reconcile_bin_a" "$reconcile_home/.zshrc"; then
+ fail "$interpreter_name stale managed path must be replaced"
+ fi
+ grep -Fq 'alias reconcile-before=1' "$reconcile_home/.zshrc" || fail "$interpreter_name unmanaged content preserved (before block)"
+ grep -Fq 'alias reconcile-after=1' "$reconcile_home/.zshrc" || fail "$interpreter_name unmanaged content preserved (after block)"
+
+ # --- Unsafe resolved bin dirs under the default flow (KD3) ---
+
+ unsafe_auto_index=0
+ for unsafe_character in ';' '$'; do
+ unsafe_auto_index=$((unsafe_auto_index + 1))
+ reset_case
+ unsafe_auto_home="$case_root/unsafe-auto-$unsafe_auto_index-home"
+ unsafe_auto_install="$case_root/unsafe-auto-$unsafe_auto_index-install"
+ unsafe_auto_bin="$case_root/unsafe-auto${unsafe_character}$unsafe_auto_index-bin"
+ unsafe_auto_output=$(run_installer "$unsafe_auto_home" "$unsafe_auto_install" "$unsafe_auto_bin" "$stable_tag" 2>&1) ||
+ fail "$interpreter_name unsafe auto bin dir with $unsafe_character must keep the install successful"
+ if grep -Fq 'install --shell' "$composio_log"; then
+ fail "$interpreter_name unsafe auto bin dir must be rejected before delegation"
+ fi
+ [[ ! -e "$unsafe_auto_home/.bashrc" && ! -e "$unsafe_auto_home/.bash_profile" ]] ||
+ fail "$interpreter_name unsafe auto bin dir must not write startup files"
+ [[ -x "$unsafe_auto_install/composio" ]] || fail "$interpreter_name unsafe auto bin dir must retain the binary"
+ assert_contains "$unsafe_auto_output" "$unsafe_auto_bin" "$interpreter_name unsafe auto warning names the rejected path"
+ assert_tail "$unsafe_auto_output" $'To get started, run:\n\n '"$unsafe_auto_install/composio login" "$interpreter_name unsafe auto recovery tail"
+ done
+
+ # A valid absolute install dir containing spaces stays copy-paste safe in
+ # recovery output: the printed command executes the installed binary as-is.
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ space_home="$case_root/space-home"
+ space_install="$case_root/space install/dir"
+ mkdir -p "$space_home/.bashrc"
+ space_output=$(run_installer "$space_home" "$space_install" "$case_root/space-bin" "$stable_tag" 2>&1) ||
+ fail "$interpreter_name spaced install dir setup failure must keep the install successful"
+ assert_tail "$space_output" $'To get started, run:\n\n '"'$space_install/composio' login" "$interpreter_name spaced recovery tail"
+ space_recovery_line=$(printf '%s\n' "$space_output" | tail -n 1)
+ space_recovery_command=${space_recovery_line# }
+ space_recovery_command=${space_recovery_command% login}
+ space_paste_output=$(env TEST_COMPOSIO_LOG="$composio_log" "$interpreter" -c "$space_recovery_command --version") ||
+ fail "$interpreter_name spaced recovery command must execute when pasted"
+ [[ $space_paste_output == 'composio fake 98.0.0' ]] || fail "$interpreter_name spaced recovery command output"
+
+ # --- Final-block contract combinations (KD4/KD7) ---
+
+ # Plugin output completes before the final block.
+ reset_case
+ CASE_PLUGINS=1
+ plugin_order_output=$(run_installer "$case_root/plugin-order-home" "$case_root/plugin-order-install" "$case_root/plugin-order-bin" "$stable_tag" 2>&1)
+ assert_contains "$plugin_order_output" 'Installing plugins for detected agent hosts...' "$interpreter_name plugin status printed"
+ assert_tail "$plugin_order_output" "$case_b_tail" "$interpreter_name plugin output precedes the final block"
+
+ # --agent, setup succeeds, command not yet resolvable: completed state plus
+ # only the new-terminal notice; never a second login command.
+ reset_case
+ agent_home="$case_root/agent-home"
+ agent_output=$(run_installer "$agent_home" "$case_root/agent-install" "$case_root/agent-bin" "$stable_tag" --agent 2>&1)
+ grep -Fq 'login --agent --no-skill-install' "$composio_log" || fail "$interpreter_name agent login invocation"
+ assert_not_contains "$agent_output" 'composio login' "$interpreter_name agent flow must not print a generic login command"
+ assert_tail "$agent_output" $'Composio agent login complete.\nOpen a new terminal to use the composio command.' "$interpreter_name agent Case B tail"
+
+ # --agent with the installed command already resolvable: completed state only.
+ reset_case
+ agent_ready_bin="$case_root/agent-ready-bin"
+ CASE_PATH_PREFIX="$agent_ready_bin:"
+ agent_ready_output=$(run_installer "$case_root/agent-ready-home" "$case_root/agent-ready-install" "$agent_ready_bin" "$stable_tag" --agent 2>&1)
+ assert_not_contains "$agent_ready_output" 'Open a new terminal' "$interpreter_name agent ready flow needs no terminal notice"
+ assert_tail "$agent_ready_output" 'Composio agent login complete.' "$interpreter_name agent Case A tail"
+
+ # --agent with setup failure: completed state plus warning and trusted
+ # installed-path guidance; still no generic login command.
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ agent_fail_home="$case_root/agent-fail-home"
+ agent_fail_install="$case_root/agent-fail-install"
+ mkdir -p "$agent_fail_home/.bashrc"
+ agent_fail_output=$(run_installer "$agent_fail_home" "$agent_fail_install" "$case_root/agent-fail-bin" "$stable_tag" --agent 2>&1) ||
+ fail "$interpreter_name agent setup failure must keep the install successful"
+ assert_contains "$agent_fail_output" 'Composio agent login complete.' "$interpreter_name agent completion survives setup failure"
+ assert_contains "$agent_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name agent setup failure warning"
+ assert_not_contains "$agent_fail_output" 'composio login' "$interpreter_name agent setup failure must not print a login command"
+ assert_tail "$agent_fail_output" $'Run composio from its installed location:\n\n '"$agent_fail_install/composio --help" "$interpreter_name agent setup failure recovery tail"
+
+ # --agent with setup skipped (none): completed state plus installed-path guidance.
+ reset_case
+ CASE_INSTALL_SHELL=none
+ agent_none_install="$case_root/agent-none-install"
+ agent_none_output=$(run_installer "$case_root/agent-none-home" "$agent_none_install" "$case_root/agent-none-bin" "$stable_tag" --agent 2>&1)
+ assert_not_contains "$agent_none_output" 'composio login' "$interpreter_name agent none flow must not print a login command"
+ assert_tail "$agent_none_output" $'Composio agent login complete.\nRun composio from its installed location:\n\n '"$agent_none_install/composio --help" "$interpreter_name agent none tail"
+
+ # Quiet mode keeps setup-failure recovery visible.
+ reset_case
+ CASE_QUIET=1
+ CASE_SHELL_CAPABILITY=unsupported
+ quiet_fail_home="$case_root/quiet-fail-home"
+ quiet_fail_install="$case_root/quiet-fail-install"
+ mkdir -p "$quiet_fail_home/.bashrc"
+ quiet_fail_output=$(run_installer "$quiet_fail_home" "$quiet_fail_install" "$case_root/quiet-fail-bin" "$stable_tag" 2>&1) ||
+ fail "$interpreter_name quiet setup failure must keep the install successful"
+ assert_contains "$quiet_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name quiet keeps the setup-failure warning"
+ assert_tail "$quiet_fail_output" $'To get started, run:\n\n '"$quiet_fail_install/composio login" "$interpreter_name quiet keeps the recovery tail"
+
+ # COMPOSIO_INSTALL_HELP=0 also keeps setup-failure recovery visible.
+ reset_case
+ CASE_HELP=0
+ CASE_SHELL_CAPABILITY=unsupported
+ helpless_fail_home="$case_root/helpless-fail-home"
+ helpless_fail_install="$case_root/helpless-fail-install"
+ mkdir -p "$helpless_fail_home/.bashrc"
+ helpless_fail_output=$(run_installer "$helpless_fail_home" "$helpless_fail_install" "$case_root/helpless-fail-bin" "$stable_tag" 2>&1) ||
+ fail "$interpreter_name help-suppressed setup failure must keep the install successful"
+ assert_contains "$helpless_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name help suppression keeps the setup-failure warning"
+ assert_tail "$helpless_fail_output" $'To get started, run:\n\n '"$helpless_fail_install/composio login" "$interpreter_name help suppression keeps the recovery tail"
+
printf 'install scripts passed under %s\n' "$interpreter_name"
done
diff --git a/ts/packages/cli/test/src/analytics.events.test.ts b/ts/packages/cli/test/src/analytics.events.test.ts
index 87d4dd10d..50d08e724 100644
--- a/ts/packages/cli/test/src/analytics.events.test.ts
+++ b/ts/packages/cli/test/src/analytics.events.test.ts
@@ -481,23 +481,33 @@ describe('CLI analytics journey taxonomy', () => {
});
});
- it('keeps the base installer install-only and marks shell-variant delegation as installer-origin', () => {
+ it('marks base-installer shell-setup delegation as installer-origin and keeps shell variants on the env override', () => {
+ // The base installer defaults to automatic shell setup, so it owns the
+ // `install --shell` delegation and must tag it as installer-origin.
const installScript = readFileSync(
new URL('../../../../../install.sh', import.meta.url),
'utf8'
);
- expect(installScript).not.toContain('"$exe" install');
+ const delegationLine = installScript
+ .split('\n')
+ .find(line => line.includes('"$exe" install --shell'));
+ expect(delegationLine).toBeDefined();
+ expect(delegationLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');
+
+ // Shell variants delegate to the base installer through the explicit
+ // COMPOSIO_INSTALL_SHELL override instead of invoking the CLI themselves.
for (const shell of ['zsh', 'bash', 'fish']) {
const variantScript = readFileSync(
new URL(`../../../../../install/${shell}.sh`, import.meta.url),
'utf8'
);
- const installLine = variantScript
- .split('\n')
- .find(line => line.includes('"$variant_exe" install --shell'));
- expect(installLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');
+ expect(variantScript).toContain(`requested_shell() { printf '%s\\n' ${shell}; }`);
+ expect(variantScript).toContain(
+ 'COMPOSIO_INSTALL_SHELL="$variant_shell" sh "$variant_tmpdir/install.sh" "$@"'
+ );
+ expect(variantScript).not.toContain('install --shell');
}
});
});