@devries-cameron20 / composio Mirror · read-only / commits / 2ff9d9f97
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 17:15 UTC

feat(cli): make automatic shell setup the installer default

COMPOSIO_INSTALL_SHELL grows auto (the new default) and none. auto infers the login shell from $SHELL and always runs idempotent setup for recognized shells; none keeps install-only behavior for CI and dotfile managers. Final output follows the KD4 state matrix against a pre-install PATH snapshot with physical-path identity, setup failures never fail the install, and the managed PATH block reconciles stale bin directories.

jkomyno committed Aug 3, 2026 at 17:08 UTC 2ff9d9f97ead45066784978f3db565ccdf4dfa57
3 files changed +611 -96
install.sh
+234 -76
@@ -45,7 +45,8 @@ print_usage() {
45 ' --no-plugins Skip agent plugin installation (the default).' \
46 ' -h, --help Show this help.' \
47 '' \
48 - 'Set COMPOSIO_INSTALL_SHELL=zsh|bash|fish to configure that shell after installation.' \
48 + 'Set COMPOSIO_INSTALL_SHELL=auto|zsh|bash|fish|none to control automatic shell setup' \
49 + "(default auto: detect the login shell from \$SHELL; none: install only)." \
50 'Version tags may be stable or beta, for example 0.3.1 or @composio/cli@0.3.1-beta.329.'
51 }
52
@@ -268,13 +269,62 @@ install_entry_point() {
269 error "Failed to create entry point \"$entry_point\""
270 }
271
271 -path_contains_bin_dir() {
272 - case :${PATH:-}: in
272 +inherited_path_contains_bin_dir() {
273 + case :$inherited_path: in
274 *:"$resolved_bin_dir":*) return 0 ;;
275 *) return 1 ;;
276 esac
277 }
278
279 +# Renders a value as one POSIX-safe shell word so recovery commands stay
280 +# copy-paste safe even when the installed path contains whitespace.
281 +shell_quote() {
282 + case $1 in
283 + '') printf "''\n" ;;
284 + *[!A-Za-z0-9_./-]*) printf '%s\n' "$1" | sed "s/'/'\\\\''/g; s/^/'/; s/\$/'/" ;;
285 + *) printf '%s\n' "$1" ;;
286 + esac
287 +}
288 +
289 +# Follows symlinks and resolves the parent directory physically, so two paths
290 +# compare equal exactly when they name the same executable (KD3).
291 +resolve_physical_path() {
292 + resolve_physical_target=$1
293 + resolve_physical_steps=0
294 + while [ -L "$resolve_physical_target" ] && [ "$resolve_physical_steps" -lt 40 ]; do
295 + resolve_physical_link=$(readlink "$resolve_physical_target") || break
296 + case $resolve_physical_link in
297 + /*) resolve_physical_target=$resolve_physical_link ;;
298 + *) resolve_physical_target=$(dirname "$resolve_physical_target")/$resolve_physical_link ;;
299 + esac
300 + resolve_physical_steps=$((resolve_physical_steps + 1))
301 + done
302 + resolve_physical_base=$(basename "$resolve_physical_target")
303 + if resolve_physical_dir=$(cd "$(dirname "$resolve_physical_target")" 2>/dev/null && pwd -P); then
304 + printf '%s/%s\n' "$resolve_physical_dir" "$resolve_physical_base"
305 + else
306 + printf '%s\n' "$resolve_physical_target"
307 + fi
308 +}
309 +
310 +# Resolves the composio command against the PATH snapshot taken before any
311 +# installer code could modify PATH: what the invoking terminal can run.
312 +resolve_inherited_command() {
313 + PATH=$inherited_path command -v composio 2>/dev/null
314 +}
315 +
316 +compute_inherited_resolution() {
317 + inherited_command=$(resolve_inherited_command) || inherited_command=
318 + inherited_resolution=unresolved
319 + if [ -n "$inherited_command" ]; then
320 + if [ "$(resolve_physical_path "$inherited_command")" = "$(resolve_physical_path "$exe")" ]; then
321 + inherited_resolution=installed
322 + else
323 + inherited_resolution=shadowed
324 + fi
325 + fi
326 +}
327 +
328 is_unsafe_path() {
329 case $1 in *':'* | *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
330 unsafe_path_cr=$(printf '\r')
@@ -289,109 +339,183 @@ render_bin_dir() {
339 printf '%s\n' "$render_bin_dir_value"
340 }
341
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\"" ;;
342 +path_block_line() {
343 + case $1 in
344 + fish) printf "set --export PATH \"%s\" \$PATH\n" "$2" ;;
345 + *) printf "export PATH=\"%s:\$PATH\"\n" "$2" ;;
346 esac
303 - printf '\n# Composio CLI\n%s\n' "$append_path_line" >>"$append_path_file"
347 +}
348 +
349 +# Succeeds only when the file holds exactly one managed marker block and that
350 +# block already names the expected line.
351 +path_block_current() {
352 + awk -v expected="$2" '
353 + $0 == "# Composio CLI" { markers++; pending = 1; next }
354 + pending { pending = 0; if ($0 == expected) matches++ }
355 + END { exit !(markers == 1 && matches == 1) }
356 + ' "$1" 2>/dev/null
357 +}
358 +
359 +# Reconciles the single managed PATH block in one startup file: keeps an
360 +# already-current block, replaces stale managed blocks, preserves unmanaged
361 +# content, and reports every failure through its return status.
362 +write_path_block() {
363 + write_path_file=$1
364 + write_path_line=$(path_block_line "$2" "$3") || return 1
365 + mkdir -p "$(dirname "$write_path_file")" 2>/dev/null || return 1
366 + if [ -e "$write_path_file" ] && [ ! -f "$write_path_file" ]; then
367 + return 1
368 + fi
369 + if [ ! -f "$write_path_file" ]; then
370 + touch "$write_path_file" 2>/dev/null || return 1
371 + fi
372 + if path_block_current "$write_path_file" "$write_path_line"; then
373 + info "$(tildify "$write_path_file") is already up to date."
374 + return 0
375 + fi
376 + write_path_tmp=$write_path_file.composio.tmp
377 + if ! awk '
378 + pending { pending = 0; next }
379 + $0 == "# Composio CLI" { pending = 1; next }
380 + { print }
381 + ' "$write_path_file" >"$write_path_tmp" 2>/dev/null; then
382 + rm -f "$write_path_tmp"
383 + return 1
384 + fi
385 + if ! printf '\n# Composio CLI\n%s\n' "$write_path_line" >>"$write_path_tmp" 2>/dev/null; then
386 + rm -f "$write_path_tmp"
387 + return 1
388 + fi
389 + if ! mv "$write_path_tmp" "$write_path_file" 2>/dev/null; then
390 + rm -f "$write_path_tmp"
391 + return 1
392 + fi
393 + info "Updated $(tildify "$write_path_file")."
394 + return 0
395 }
396
397 inline_shell_setup() {
398 inline_setup_shell=$1
399 inline_setup_bin_dir=$2
309 - is_unsafe_path "$inline_setup_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
400 + if is_unsafe_path "$inline_setup_bin_dir"; then
401 + return 1
402 + fi
403 inline_setup_rendered=$(render_bin_dir "$inline_setup_bin_dir")
404 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" ;;
405 + zsh) write_path_block "$HOME/.zshrc" zsh "$inline_setup_rendered" || return 1 ;;
406 + fish) write_path_block "$HOME/.config/fish/config.fish" fish "$inline_setup_rendered" || return 1 ;;
407 bash)
315 - append_path_block "$HOME/.bashrc" bash "$inline_setup_rendered"
408 + inline_setup_status=0
409 + write_path_block "$HOME/.bashrc" bash "$inline_setup_rendered" || inline_setup_status=1
410 if [ -f "$HOME/.bash_profile" ]; then
317 - append_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered"
411 + write_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered" || inline_setup_status=1
412 elif [ -f "$HOME/.bash_login" ]; then
319 - append_path_block "$HOME/.bash_login" bash "$inline_setup_rendered"
413 + write_path_block "$HOME/.bash_login" bash "$inline_setup_rendered" || inline_setup_status=1
414 fi
415 + [ "$inline_setup_status" -eq 0 ] || return 1
416 ;;
417 + *) return 1 ;;
418 esac
419 + return 0
420 }
421
422 setup_requested_shell() {
423 + if is_unsafe_path "$resolved_bin_dir"; then
424 + warn "Skipping automatic shell setup: the executable directory \"$resolved_bin_dir\" contains unsupported characters."
425 + return 1
426 + fi
427 if "$exe" install --help 2>&1 | grep -q -- '--shell'; then
428 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
429 + if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$resolved_bin_dir" "$exe" install --shell "$requested_shell"; then
430 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
431 + info "Configured $requested_shell shell setup ($shell_configured)."
432 + return 0
433 fi
335 - else
336 - debug "falling back to inline $requested_shell shell setup"
337 - inline_shell_setup "$requested_shell" "$COMPOSIO_BIN_DIR"
434 + fi
435 + debug "falling back to inline $requested_shell shell setup"
436 + if inline_shell_setup "$requested_shell" "$resolved_bin_dir"; then
437 shell_configured=fallback
438 + info "Configured $requested_shell shell setup ($shell_configured)."
439 + return 0
440 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
441 + return 1
442 }
443
444 +# Final action block for every non-failure flow (KD4 state matrix). KD7: this
445 +# is the last output; nothing prints after it. Suppressible because it only
446 +# covers normal success.
447 print_post_install_help() {
448 [ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] || return 0
351 - is_true "${COMPOSIO_QUIET:-}" && return 0
352 -
353 - shell_name=${SHELL:-}
354 - shell_name=${shell_name##*/}
355 - shell_route=
356 - shell_config=
357 - case $shell_name in
358 - zsh)
359 - shell_route=zsh
360 - shell_config=~/.zshrc
361 - ;;
362 - bash)
363 - shell_route=bash
364 - shell_config=~/.bashrc
365 - ;;
366 - fish)
367 - shell_route=fish
368 - shell_config=~/.config/fish/config.fish
369 - ;;
370 - esac
371 -
372 - guidance_required=0
373 - path_contains_bin_dir || guidance_required=1
374 - if [ "$shell_name" = bash ] && { [ -f "$HOME/.bash_profile" ] || [ -f "$HOME/.bash_login" ]; }; then
375 - guidance_required=1
449 + if is_true "${COMPOSIO_QUIET:-}"; then
450 + return 0
451 fi
452
453 + compute_inherited_resolution
454 printf '\n'
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"
455 +
456 + if [ "$install_agent" = 1 ]; then
457 + printf 'Composio agent login complete.\n'
458 + if [ "$inherited_resolution" != installed ]; then
459 + if [ "$shell_setup_outcome" = success ]; then
460 + printf 'Open a new terminal to use the composio command.\n'
461 + else
462 + printf 'Run composio from its installed location:\n\n %s --help\n' "$(shell_quote "$exe")"
463 + fi
464 + fi
465 + return 0
466 + fi
467 +
468 + # Case A: the invoking terminal already resolves the installed executable.
469 + if [ "$inherited_resolution" = installed ]; then
470 + if [ "$shell_setup_outcome" = success ] || [ "$shell_setup_mode" = none ]; then
471 + printf 'composio is ready.\n\n composio login\n'
472 + return 0
473 + fi
474 + fi
475 +
476 + if [ "$shell_setup_outcome" = success ]; then
477 + if [ "$inherited_resolution" = shadowed ]; then
478 + printf 'Another composio command at %s takes precedence in this terminal.\n' "$inherited_command"
479 + printf 'To use the newly installed CLI, run:\n\n %s login\n' "$(shell_quote "$exe")"
480 else
385 - printf 'Optional shell setup for future PATH changes:\n\n'
481 + # Case B: configured for future terminals, vocabulary-free.
482 + printf 'Open a new terminal, then run:\n\n composio login\n'
483 fi
387 - printf ' curl -fsSL https://composio.dev/install | COMPOSIO_INSTALL_SHELL=%s sh\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'
484 + return 0
485 + fi
486 +
487 + # Install-only guidance: COMPOSIO_INSTALL_SHELL=none or an unrecognized
488 + # login shell. Never point the user at a shadowed bare command.
489 + if [ "$shell_setup_mode" = none ]; then
490 + printf 'Shell setup was skipped (COMPOSIO_INSTALL_SHELL=none).\n'
491 + else
492 + printf 'Automatic shell setup is not available for your shell.\n'
493 + fi
494 + case $inherited_resolution in
495 + shadowed) printf 'Another composio command at %s takes precedence in this terminal.\n' "$inherited_command" ;;
496 + unresolved)
497 + if ! inherited_path_contains_bin_dir; then
498 + printf 'Add %s to your PATH to use composio in new terminals.\n' "$(tildify "$resolved_bin_dir")"
499 + fi
500 + ;;
501 + esac
502 + printf 'To get started now, run:\n\n %s login\n' "$(shell_quote "$exe")"
503 +}
504 +
505 +# Setup failure never fails the install. Recovery travels the stderr warn
506 +# channel so quiet mode and COMPOSIO_INSTALL_HELP=0 cannot suppress it, and the
507 +# trusted --version-verified installed executable is always the last output.
508 +print_setup_failure_ending() {
509 + if [ "$install_agent" = 1 ]; then
510 + if [ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] && ! is_true "${COMPOSIO_QUIET:-}"; then
511 + printf '\nComposio agent login complete.\n'
512 + fi
513 + warn "Automatic PATH setup for $requested_shell failed. The Composio CLI is installed and unaffected."
514 + printf '\nRun composio from its installed location:\n\n %s --help\n' "$(shell_quote "$exe")" >&2
515 else
392 - printf 'Add %s to PATH, then start a new shell.\n' "$(tildify "$resolved_bin_dir")"
516 + warn "Automatic PATH setup for $requested_shell failed. The Composio CLI is installed and unaffected."
517 + printf '\nTo get started, run:\n\n %s login\n' "$(shell_quote "$exe")" >&2
518 fi
394 - printf "\nRun \`composio --help\` to get started.\n"
519 }
520
521 cleanup() {
@@ -408,6 +532,10 @@ cleanup_on_signal() {
532 }
533
534 main() {
535 + # Snapshot the PATH the invoking terminal handed us before any installer
536 + # code can modify it; every final-state decision uses only this snapshot.
537 + inherited_path=${PATH:-}
538 +
539 install_agent=0
540 install_plugins=${COMPOSIO_INSTALL_PLUGINS:-0}
541 version_arg=
@@ -419,8 +547,8 @@ main() {
547 esac
548
549 case $requested_shell in
422 - '' | zsh | bash | fish) ;;
423 - *) error "COMPOSIO_INSTALL_SHELL must be zsh, bash, or fish (got \"$requested_shell\")" ;;
550 + '' | auto | zsh | bash | fish | none) ;;
551 + *) error "COMPOSIO_INSTALL_SHELL must be auto, zsh, bash, fish, or none (got \"$requested_shell\")" ;;
552 esac
553
554 while [ "$#" -gt 0 ]; do
@@ -440,6 +568,21 @@ main() {
568 shift
569 done
570
571 + # Resolve the setup mode right after argument parsing: auto (the default)
572 + # infers the login shell from $SHELL and degrades to install-only when it
573 + # is unset or unrecognized; none is the documented install-only opt-out.
574 + shell_setup_mode=${requested_shell:-auto}
575 + case $shell_setup_mode in
576 + auto)
577 + login_shell=$(basename "${SHELL:-}" 2>/dev/null) || login_shell=
578 + case $login_shell in
579 + zsh | bash | fish) requested_shell=$login_shell ;;
580 + *) requested_shell= ;;
581 + esac
582 + ;;
583 + none) requested_shell= ;;
584 + esac
585 +
586 COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-ComposioHQ}
587 COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-composio}
588 COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-https://github.com}
@@ -526,6 +669,12 @@ main() {
669 info "The composio entry point is $(tildify "$resolved_bin_dir/composio")"
670 fi
671
672 + # Delegated CLI invocations below may spawn composio subprocesses; make the
673 + # fresh entry point resolvable for them. Final-state decisions keep using
674 + # the inherited snapshot taken at the top of main().
675 + PATH=$resolved_bin_dir:$PATH
676 + export PATH
677 +
678 if [ "$install_plugins" = 1 ]; then
679 info 'Installing plugins for detected agent hosts...'
680 COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" setup --target auto --yes --if-present ||
@@ -538,11 +687,20 @@ main() {
687 error 'Failed to sign up or log in as a Composio agent.'
688 fi
689
690 + shell_setup_outcome=skipped
691 if [ -n "$requested_shell" ]; then
542 - setup_requested_shell
692 + if setup_requested_shell; then
693 + shell_setup_outcome=success
694 + else
695 + shell_setup_outcome=failure
696 + fi
697 fi
698
545 - print_post_install_help
699 + if [ "$shell_setup_outcome" = failure ]; then
700 + print_setup_failure_ending
701 + else
702 + print_post_install_help
703 + fi
704 }
705
706 main "$@"
test/install-sh-release-resolution.test.sh
+361 -14
@@ -4,6 +4,9 @@ set -euo pipefail
4 repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5 suite_tmp="$(mktemp -d)"
6 trap 'rm -rf "$suite_tmp"' EXIT
7 +# Case A and recovery-path assertions compare resolved physical paths, so the
8 +# suite root itself must be physical (macOS mktemp returns /var -> /private/var).
9 +suite_tmp="$(cd "$suite_tmp" && pwd -P)"
10
11 fail() {
12 printf 'FAIL: %s\n' "$*" >&2
@@ -26,6 +29,21 @@ assert_not_contains() {
29 fi
30 }
31
32 +# Asserts the exact final N lines of an output capture, proving nothing prints
33 +# after the final action block (KD7: the last block wins).
34 +assert_tail() {
35 + local haystack=$1
36 + local expected=$2
37 + local label=$3
38 + local lines actual
39 + lines=$(printf '%s\n' "$expected" | wc -l | tr -d '[:space:]')
40 + actual=$(printf '%s\n' "$haystack" | tail -n "$lines")
41 + if [[ $actual != "$expected" ]]; then
42 + printf 'FAIL: %s\nexpected tail:\n%s\nactual tail:\n%s\n' "$label" "$expected" "$actual" >&2
43 + exit 1
44 + fi
45 +}
46 +
47 wait_for_file() {
48 local file=$1
49 local label=$2
@@ -101,11 +119,30 @@ github_url='https://github.example.test'
119 archive_url="https://downloads.example.test/$stable_tag/$archive_name"
120 script_url='https://installer.example.test/install.sh'
121
122 +# KD4 exact endings: plain indented lines, no box drawing, nothing after them.
123 +case_a_tail=$'composio is ready.\n\n composio login'
124 +case_b_tail=$'Open a new terminal, then run:\n\n composio login'
125 +
126 interpreters=("$(command -v sh)")
127 if command -v dash >/dev/null 2>&1 && [[ $(command -v dash) != "${interpreters[0]}" ]]; then
128 interpreters+=("$(command -v dash)")
129 fi
130
131 +# The installer's final block depends on what the inherited PATH resolves, so
132 +# strip any real composio installation from the ambient PATH to keep the
133 +# resolution cases deterministic on developer machines and CI runners.
134 +sanitize_path() {
135 + local entry result=
136 + local IFS=':'
137 + for entry in $1; do
138 + if [[ -n $entry && ! -x $entry/composio ]]; then
139 + result+="${result:+:}$entry"
140 + fi
141 + done
142 + printf '%s\n' "$result"
143 +}
144 +ambient_path=$(sanitize_path "$PATH")
145 +
146 for interpreter in "${interpreters[@]}"; do
147 interpreter_name=$(basename "$interpreter")
148 case_root="$suite_tmp/$interpreter_name"
@@ -255,6 +292,9 @@ install)
292 exit 0
293 fi
294 if [ "${2:-}" = --shell ]; then
295 + if [ "${TEST_INSTALL_HINT:-0}" = 1 ]; then
296 + printf '%s\n' '│ Restart your shell so composio is on PATH │'
297 + fi
298 exit "${TEST_INSTALL_EXIT:-0}"
299 fi
300 exit 98
@@ -283,7 +323,7 @@ EOF
323 unset CASE_GITHUB_URL CASE_API_BASE CASE_INSTALL_VERSION CASE_INSTALL_SHELL CASE_PLUGINS CASE_QUIET CASE_DEBUG CASE_HELP
324 unset CASE_ALLOW_HTTP_HOST CASE_CHECKSUM_MODE CASE_API_ASSET_URL CASE_BASE_MODE CASE_REDIRECT_DOWNGRADE
325 unset CASE_SHELL_CAPABILITY CASE_INSTALL_EXIT CASE_SETUP_EXIT CASE_VERSION_EXIT CASE_PATH_PREFIX CASE_UNSET_SHELL
286 - unset CASE_CURL_DELAY_URL CASE_CURL_DELAY_SECONDS
326 + unset CASE_CURL_DELAY_URL CASE_CURL_DELAY_SECONDS CASE_SHELL_VALUE CASE_INSTALL_HINT
327 rm -f "$case_root/curl-parent.pid"
328 : >"$curl_log"
329 : >"$composio_log"
@@ -300,9 +340,9 @@ EOF
340 installer_command=("$interpreter" -c 'unset SHELL; script=$1; shift; . "$script"' unset-shell "$repo_root/install.sh")
341 fi
342 env \
303 - PATH="${CASE_PATH_PREFIX:-}$fake_bin:$PATH" \
343 + PATH="${CASE_PATH_PREFIX:-}$fake_bin:$ambient_path" \
344 HOME="$home" \
305 - SHELL=/bin/bash \
345 + SHELL="${CASE_SHELL_VALUE:-/bin/bash}" \
346 COMPOSIO_INSTALL_DIR="$install_dir" \
347 COMPOSIO_BIN_DIR="$bin_dir" \
348 COMPOSIO_INSTALL_VERSION="${CASE_INSTALL_VERSION:-}" \
@@ -321,6 +361,7 @@ EOF
361 TEST_REDIRECT_DOWNGRADE="${CASE_REDIRECT_DOWNGRADE:-0}" \
362 TEST_SHELL_CAPABILITY="${CASE_SHELL_CAPABILITY:-supported}" \
363 TEST_INSTALL_EXIT="${CASE_INSTALL_EXIT:-0}" \
364 + TEST_INSTALL_HINT="${CASE_INSTALL_HINT:-0}" \
365 TEST_SETUP_EXIT="${CASE_SETUP_EXIT:-0}" \
366 TEST_VERSION_EXIT="${CASE_VERSION_EXIT:-0}" \
367 TEST_CURL_DELAY_URL="${CASE_CURL_DELAY_URL:-}" \
@@ -337,7 +378,7 @@ EOF
378 shift 4
379 mkdir -p "$home" "$install_dir" "$bin_dir"
380 env \
340 - PATH="$fake_bin:$PATH" \
381 + PATH="$fake_bin:$ambient_path" \
382 HOME="$home" \
383 SHELL="/bin/$shell_name" \
384 COMPOSIO_INSTALL_DIR="$install_dir" \
@@ -369,9 +410,14 @@ EOF
410 expected_install_dir=$(cd "$install_dir" && pwd -P)
411 [[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target"
412 assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery"
372 - assert_contains "$output" 'Required next step for bash:' "$interpreter_name required PATH guidance"
373 - [[ ! -e "$home/.bashrc" ]] || fail "$interpreter_name default flow must not write rc files"
374 - [[ $(wc -l <"$composio_log") -eq 1 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
413 + grep -Fq "|installer|$bin_dir|install --shell bash" "$composio_log" || fail "$interpreter_name default auto delegation"
414 + assert_contains "$output" 'Configured bash shell setup (cli).' "$interpreter_name default auto confirmation"
415 + # Inherited-PATH contract: the installer prepends the bin dir to its own PATH
416 + # for delegated CLI calls, but the ending must reflect only the PATH the
417 + # invoking terminal inherited, which does not contain the bin dir here.
418 + assert_tail "$output" "$case_b_tail" "$interpreter_name default auto Case B tail"
419 + [[ ! -e "$home/.bashrc" ]] || fail "$interpreter_name delegated default flow must not write rc files"
420 + [[ $(wc -l <"$composio_log") -eq 3 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
421 grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe"
422 [[ ! -s "$case_root/git.log" ]] || fail "$interpreter_name must not use git"
423
@@ -445,6 +491,9 @@ EOF
491 CASE_QUIET=1
492 quiet_output=$(run_installer "$case_root/quiet-home" "$case_root/quiet-install" "$case_root/quiet-bin" "$stable_tag" 2>&1)
493 assert_not_contains "$quiet_output" 'Installing Composio CLI' "$interpreter_name quiet output"
494 + assert_not_contains "$quiet_output" 'composio login' "$interpreter_name quiet suppresses the normal-success final block"
495 + assert_not_contains "$quiet_output" 'composio is ready' "$interpreter_name quiet suppresses the normal-success final block"
496 + assert_not_contains "$quiet_output" 'Open a new terminal' "$interpreter_name quiet suppresses the normal-success final block"
497
498 reset_case
499 CASE_DEBUG=1
@@ -454,12 +503,19 @@ EOF
503 reset_case
504 CASE_HELP=0
505 help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1)
457 - assert_not_contains "$help_suppressed" 'next step' "$interpreter_name help suppression"
506 + assert_contains "$help_suppressed" 'Configured bash shell setup (cli).' "$interpreter_name help suppression keeps setup status"
507 + assert_not_contains "$help_suppressed" 'composio login' "$interpreter_name help suppression removes the final block"
508 + assert_not_contains "$help_suppressed" 'Open a new terminal' "$interpreter_name help suppression removes the final block"
509
510 reset_case
511 CASE_UNSET_SHELL=1
461 - run_installer "$case_root/unset-shell-home" "$case_root/unset-shell-install" "$case_root/unset-shell-bin" "$stable_tag" >/dev/null 2>&1 ||
512 + unset_shell_install="$case_root/unset-shell-install"
513 + unset_shell_output=$(run_installer "$case_root/unset-shell-home" "$unset_shell_install" "$case_root/unset-shell-bin" "$stable_tag" 2>&1) ||
514 fail "$interpreter_name unset SHELL must not fail after installation"
515 + if grep -Fq 'install --shell' "$composio_log"; then
516 + fail "$interpreter_name unset SHELL must not run shell setup"
517 + fi
518 + assert_tail "$unset_shell_output" $'To get started now, run:\n\n '"$unset_shell_install/composio login" "$interpreter_name unset SHELL install-only tail"
519
520 reset_case
521 CASE_CURL_DELAY_URL="$github_url/FakeOwner/fake-repo/releases/download/$stable_tag/$archive_name"
@@ -550,6 +606,7 @@ EOF
606 grep -Fq "|installer|$direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL delegation"
607 assert_contains "$direct_output" 'Configured zsh shell setup (cli).' "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
608 assert_not_contains "$direct_output" 'Required next step' "$interpreter_name COMPOSIO_INSTALL_SHELL must not print setup guidance"
609 + assert_tail "$direct_output" "$case_b_tail" "$interpreter_name COMPOSIO_INSTALL_SHELL Case B tail"
610 [[ ! -e "$direct_home/.zshrc" ]] || fail "$interpreter_name COMPOSIO_INSTALL_SHELL CLI path must not write rc files"
611
612 reset_case
@@ -572,7 +629,7 @@ EOF
629 if invalid_shell_output=$(run_installer "$case_root/invalid-shell-home" "$case_root/invalid-shell-install" "$case_root/invalid-shell-bin" 2>&1); then
630 fail "$interpreter_name invalid COMPOSIO_INSTALL_SHELL must fail"
631 fi
575 - assert_contains "$invalid_shell_output" 'COMPOSIO_INSTALL_SHELL must be zsh, bash, or fish' "$interpreter_name invalid COMPOSIO_INSTALL_SHELL message"
632 + assert_contains "$invalid_shell_output" 'COMPOSIO_INSTALL_SHELL must be auto, zsh, bash, fish, or none' "$interpreter_name invalid COMPOSIO_INSTALL_SHELL message"
633 [[ ! -s "$curl_log" ]] || fail "$interpreter_name invalid COMPOSIO_INSTALL_SHELL must fail before network"
634
635 reset_case
@@ -599,11 +656,17 @@ EOF
656 for unsafe_character in ';' ':'; do
657 reset_case
658 CASE_SHELL_CAPABILITY=unsupported
602 - unsafe_home="$case_root/unsafe-${unsafe_character//[^[:alnum:]]/delimiter}-variant-home"
603 - 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
604 - fail "$interpreter_name unsafe variant bin dir with $unsafe_character must fail"
605 - fi
659 + unsafe_slug=${unsafe_character//[^[:alnum:]]/delimiter}
660 + unsafe_home="$case_root/unsafe-$unsafe_slug-variant-home"
661 + unsafe_install="$case_root/unsafe-$unsafe_slug-variant-install"
662 + unsafe_bin="$case_root/unsafe${unsafe_character}variant-bin"
663 + unsafe_variant_output=$(run_variant zsh "$unsafe_home" "$unsafe_install" "$unsafe_bin" "$stable_tag" 2>&1) ||
664 + fail "$interpreter_name unsafe variant bin dir with $unsafe_character must keep the install successful"
665 [[ ! -e "$unsafe_home/.zshrc" ]] || fail "$interpreter_name unsafe variant must not write rc file"
666 + [[ -x "$unsafe_install/composio" ]] || fail "$interpreter_name unsafe variant must retain the binary"
667 + assert_contains "$unsafe_variant_output" 'warning:' "$interpreter_name unsafe variant warning"
668 + assert_contains "$unsafe_variant_output" "$unsafe_bin" "$interpreter_name unsafe variant warning names the rejected path"
669 + assert_tail "$unsafe_variant_output" $'To get started, run:\n\n '"$unsafe_install/composio login" "$interpreter_name unsafe variant recovery tail"
670 done
671
672 for base_mode in fail empty; do
@@ -616,6 +679,290 @@ EOF
679 [[ ! -e "$base_failure_home/.zshrc" ]] || fail "$interpreter_name $base_mode download must not write rc"
680 done
681
682 + # --- Auto shell setup default (KD2/KD3) ---
683 +
684 + # Every recognized default-flow shell delegates through the setup chain.
685 + for auto_shell in zsh bash fish; do
686 + reset_case
687 + CASE_SHELL_VALUE="/bin/$auto_shell"
688 + auto_home="$case_root/auto-$auto_shell-home"
689 + auto_install="$case_root/auto-$auto_shell-install"
690 + auto_bin="$case_root/auto-$auto_shell-bin"
691 + auto_output=$(run_installer "$auto_home" "$auto_install" "$auto_bin" "$stable_tag" 2>&1)
692 + grep -Fq "|installer|$auto_bin|install --shell $auto_shell" "$composio_log" ||
693 + fail "$interpreter_name auto $auto_shell delegation"
694 + assert_contains "$auto_output" "Configured $auto_shell shell setup (cli)." "$interpreter_name auto $auto_shell confirmation"
695 + assert_tail "$auto_output" "$case_b_tail" "$interpreter_name auto $auto_shell Case B tail"
696 + done
697 +
698 + # Repeated default-flow installs keep taking the idempotent setup chain.
699 + reset_case
700 + idempotent_home="$case_root/idempotent-home"
701 + idempotent_install="$case_root/idempotent-install"
702 + idempotent_bin="$case_root/idempotent-bin"
703 + run_installer "$idempotent_home" "$idempotent_install" "$idempotent_bin" "$stable_tag" >/dev/null 2>&1
704 + run_installer "$idempotent_home" "$idempotent_install" "$idempotent_bin" "$stable_tag" >/dev/null 2>&1
705 + [[ $(grep -c 'install --shell bash' "$composio_log") -eq 2 ]] ||
706 + fail "$interpreter_name repeated auto installs must re-run idempotent setup"
707 +
708 + # COMPOSIO_INSTALL_SHELL=none preserves install-only behavior.
709 + reset_case
710 + CASE_INSTALL_SHELL=none
711 + none_home="$case_root/none-home"
712 + none_install="$case_root/none-install"
713 + none_output=$(run_installer "$none_home" "$none_install" "$case_root/none-bin" "$stable_tag" 2>&1)
714 + if grep -Fq 'install --shell' "$composio_log"; then
715 + fail "$interpreter_name none must not run shell setup"
716 + fi
717 + [[ ! -e "$none_home/.bashrc" && ! -e "$none_home/.bash_profile" ]] || fail "$interpreter_name none must not write rc files"
718 + assert_contains "$none_output" 'COMPOSIO_INSTALL_SHELL=none' "$interpreter_name none skip disclosure"
719 + assert_tail "$none_output" $'To get started now, run:\n\n '"$none_install/composio login" "$interpreter_name none install-only tail"
720 +
721 + # none + already-resolving installed command uses the bare Case A ending.
722 + reset_case
723 + CASE_INSTALL_SHELL=none
724 + none_ready_bin="$case_root/none-ready-bin"
725 + CASE_PATH_PREFIX="$none_ready_bin:"
726 + none_ready_output=$(run_installer "$case_root/none-ready-home" "$case_root/none-ready-install" "$none_ready_bin" "$stable_tag" 2>&1)
727 + assert_tail "$none_ready_output" "$case_a_tail" "$interpreter_name none Case A tail"
728 +
729 + # Case A: recognized shell, setup succeeds, and the inherited PATH already
730 + # resolves the installed entry point. Setup still runs (idempotent).
731 + reset_case
732 + ready_bin="$case_root/ready-bin"
733 + CASE_PATH_PREFIX="$ready_bin:"
734 + ready_output=$(run_installer "$case_root/ready-home" "$case_root/ready-install" "$ready_bin" "$stable_tag" 2>&1)
735 + grep -Fq 'install --shell bash' "$composio_log" || fail "$interpreter_name Case A still runs idempotent setup"
736 + assert_tail "$ready_output" "$case_a_tail" "$interpreter_name Case A tail"
737 +
738 + # Explicit shell + resolving command also ends in Case A.
739 + reset_case
740 + CASE_INSTALL_SHELL=zsh
741 + explicit_ready_bin="$case_root/explicit-ready-bin"
742 + CASE_PATH_PREFIX="$explicit_ready_bin:"
743 + explicit_ready_output=$(run_installer "$case_root/explicit-ready-home" "$case_root/explicit-ready-install" "$explicit_ready_bin" "$stable_tag" 2>&1)
744 + assert_tail "$explicit_ready_output" "$case_a_tail" "$interpreter_name explicit shell Case A tail"
745 +
746 + # Physical-path identity: a pre-existing symlink on PATH that resolves to the
747 + # installed executable still counts as Case A.
748 + reset_case
749 + alias_dir="$case_root/alias-dir"
750 + alias_install="$case_root/alias-install"
751 + mkdir -p "$alias_dir" "$alias_install"
752 + ln -sf "$alias_install/composio" "$alias_dir/composio"
753 + CASE_PATH_PREFIX="$alias_dir:"
754 + alias_output=$(run_installer "$case_root/alias-home" "$alias_install" "$case_root/alias-bin" "$stable_tag" 2>&1)
755 + assert_tail "$alias_output" "$case_a_tail" "$interpreter_name symlink-alias Case A tail"
756 +
757 + # Unknown $SHELL degrades to install-only guidance plus the trusted absolute command.
758 + reset_case
759 + CASE_SHELL_VALUE=/bin/tcsh
760 + unknown_home="$case_root/unknown-shell-home"
761 + unknown_install="$case_root/unknown-shell-install"
762 + unknown_output=$(run_installer "$unknown_home" "$unknown_install" "$case_root/unknown-shell-bin" "$stable_tag" 2>&1)
763 + if grep -Fq 'install --shell' "$composio_log"; then
764 + fail "$interpreter_name unknown shell must not run shell setup"
765 + fi
766 + [[ ! -e "$unknown_home/.bashrc" ]] || fail "$interpreter_name unknown shell must not write rc files"
767 + assert_tail "$unknown_output" $'To get started now, run:\n\n '"$unknown_install/composio login" "$interpreter_name unknown shell install-only tail"
768 +
769 + # Shadowing: bin dir on the inherited PATH, but another composio resolves
770 + # first. The ending must never run the shadowed bare command.
771 + reset_case
772 + shadow_dir="$case_root/shadow-dir"
773 + mkdir -p "$shadow_dir"
774 + printf '#!/bin/sh\nexit 0\n' >"$shadow_dir/composio"
775 + chmod +x "$shadow_dir/composio"
776 + shadow_bin="$case_root/shadow-bin"
777 + shadow_install="$case_root/shadow-install"
778 + CASE_PATH_PREFIX="$shadow_dir:$shadow_bin:"
779 + shadow_output=$(run_installer "$case_root/shadow-home" "$shadow_install" "$shadow_bin" "$stable_tag" 2>&1)
780 + assert_contains "$shadow_output" "$shadow_dir/composio" "$interpreter_name shadow ending names the shadowing command"
781 + 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"
782 +
783 + # Pinned old CLI: supports --shell but ignores the invocation-origin hint and
784 + # prints its own boxed restart hint. A relative COMPOSIO_BIN_DIR must never
785 + # reach setup raw; startup files stay untouched; the installer's plain final
786 + # block prints after the old hint and supersedes it.
787 + reset_case
788 + CASE_INSTALL_HINT=1
789 + oldcli_home="$case_root/oldcli-home"
790 + oldcli_work="$case_root/oldcli-work"
791 + oldcli_install="$case_root/oldcli-install"
792 + mkdir -p "$oldcli_work"
793 + oldcli_output=$(cd "$oldcli_work" && run_installer "$oldcli_home" "$oldcli_install" "rel-bin" "$stable_tag" 2>&1)
794 + grep -Fq "|installer|$oldcli_work/rel-bin|install --shell bash" "$composio_log" ||
795 + fail "$interpreter_name old-CLI setup must receive the resolved absolute bin dir"
796 + [[ ! -e "$oldcli_home/.bashrc" && ! -e "$oldcli_home/.bash_profile" ]] ||
797 + fail "$interpreter_name old-CLI delegation must leave startup files unchanged"
798 + assert_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name old-CLI restart hint passes through"
799 + assert_tail "$oldcli_output" "$case_b_tail" "$interpreter_name old-CLI hint superseded by the installer tail"
800 +
801 + # --- Setup write failures stay non-fatal (KD3/KD4) ---
802 +
803 + # Delegated path: CLI --shell fails, inline fallback also fails.
804 + reset_case
805 + CASE_SHELL_VALUE=/bin/zsh
806 + CASE_INSTALL_EXIT=23
807 + wf_delegated_home="$case_root/write-failure-delegated-home"
808 + wf_delegated_install="$case_root/write-failure-delegated-install"
809 + mkdir -p "$wf_delegated_home/.zshrc"
810 + wf_delegated_output=$(run_installer "$wf_delegated_home" "$wf_delegated_install" "$case_root/write-failure-delegated-bin" "$stable_tag" 2>&1) ||
811 + fail "$interpreter_name delegated setup failure must keep the install successful"
812 + [[ -x "$wf_delegated_install/composio" ]] || fail "$interpreter_name delegated setup failure must retain the binary"
813 + assert_contains "$wf_delegated_output" 'warning: Automatic PATH setup for zsh failed' "$interpreter_name delegated setup failure warning"
814 + assert_tail "$wf_delegated_output" $'To get started, run:\n\n '"$wf_delegated_install/composio login" "$interpreter_name delegated setup failure recovery tail"
815 +
816 + # Inline path: helper failure inside a conditional must propagate explicitly.
817 + reset_case
818 + CASE_SHELL_CAPABILITY=unsupported
819 + wf_inline_home="$case_root/write-failure-inline-home"
820 + wf_inline_install="$case_root/write-failure-inline-install"
821 + mkdir -p "$wf_inline_home/.bashrc"
822 + wf_inline_output=$(run_installer "$wf_inline_home" "$wf_inline_install" "$case_root/write-failure-inline-bin" "$stable_tag" 2>&1) ||
823 + fail "$interpreter_name inline setup failure must keep the install successful"
824 + [[ -x "$wf_inline_install/composio" ]] || fail "$interpreter_name inline setup failure must retain the binary"
825 + assert_contains "$wf_inline_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name inline setup failure warning"
826 + assert_tail "$wf_inline_output" $'To get started, run:\n\n '"$wf_inline_install/composio login" "$interpreter_name inline setup failure recovery tail"
827 +
828 + # --- Managed-block reconciliation (KD3) ---
829 +
830 + reset_case
831 + CASE_SHELL_CAPABILITY=unsupported
832 + CASE_SHELL_VALUE=/bin/zsh
833 + reconcile_home="$case_root/reconcile-home"
834 + reconcile_install="$case_root/reconcile-install"
835 + reconcile_bin_a="$case_root/reconcile-bin-a"
836 + reconcile_bin_b="$case_root/reconcile-bin-b"
837 + mkdir -p "$reconcile_home"
838 + printf '%s\n' 'alias reconcile-before=1' >"$reconcile_home/.zshrc"
839 + reconcile_first=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_a" "$stable_tag" 2>&1)
840 + assert_contains "$reconcile_first" 'Updated ~/.zshrc' "$interpreter_name inline setup update disclosure"
841 + grep -Fq "export PATH=\"$reconcile_bin_a:\$PATH\"" "$reconcile_home/.zshrc" || fail "$interpreter_name first managed block"
842 + printf '%s\n' 'alias reconcile-after=1' >>"$reconcile_home/.zshrc"
843 + reconcile_second=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_a" "$stable_tag" 2>&1)
844 + assert_contains "$reconcile_second" 'already' "$interpreter_name inline setup already-current disclosure"
845 + [[ $(grep -Fc '# Composio CLI' "$reconcile_home/.zshrc") -eq 1 ]] || fail "$interpreter_name idempotent rerun keeps one marker block"
846 + reconcile_third=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_b" "$stable_tag" 2>&1)
847 + assert_contains "$reconcile_third" 'Updated ~/.zshrc' "$interpreter_name reconcile update disclosure"
848 + [[ $(grep -Fc '# Composio CLI' "$reconcile_home/.zshrc") -eq 1 ]] || fail "$interpreter_name reconcile keeps exactly one marker block"
849 + grep -Fq "export PATH=\"$reconcile_bin_b:\$PATH\"" "$reconcile_home/.zshrc" || fail "$interpreter_name reconciled managed block"
850 + if grep -Fq "$reconcile_bin_a" "$reconcile_home/.zshrc"; then
851 + fail "$interpreter_name stale managed path must be replaced"
852 + fi
853 + grep -Fq 'alias reconcile-before=1' "$reconcile_home/.zshrc" || fail "$interpreter_name unmanaged content preserved (before block)"
854 + grep -Fq 'alias reconcile-after=1' "$reconcile_home/.zshrc" || fail "$interpreter_name unmanaged content preserved (after block)"
855 +
856 + # --- Unsafe resolved bin dirs under the default flow (KD3) ---
857 +
858 + unsafe_auto_index=0
859 + for unsafe_character in ';' '$'; do
860 + unsafe_auto_index=$((unsafe_auto_index + 1))
861 + reset_case
862 + unsafe_auto_home="$case_root/unsafe-auto-$unsafe_auto_index-home"
863 + unsafe_auto_install="$case_root/unsafe-auto-$unsafe_auto_index-install"
864 + unsafe_auto_bin="$case_root/unsafe-auto${unsafe_character}$unsafe_auto_index-bin"
865 + unsafe_auto_output=$(run_installer "$unsafe_auto_home" "$unsafe_auto_install" "$unsafe_auto_bin" "$stable_tag" 2>&1) ||
866 + fail "$interpreter_name unsafe auto bin dir with $unsafe_character must keep the install successful"
867 + if grep -Fq 'install --shell' "$composio_log"; then
868 + fail "$interpreter_name unsafe auto bin dir must be rejected before delegation"
869 + fi
870 + [[ ! -e "$unsafe_auto_home/.bashrc" && ! -e "$unsafe_auto_home/.bash_profile" ]] ||
871 + fail "$interpreter_name unsafe auto bin dir must not write startup files"
872 + [[ -x "$unsafe_auto_install/composio" ]] || fail "$interpreter_name unsafe auto bin dir must retain the binary"
873 + assert_contains "$unsafe_auto_output" "$unsafe_auto_bin" "$interpreter_name unsafe auto warning names the rejected path"
874 + assert_tail "$unsafe_auto_output" $'To get started, run:\n\n '"$unsafe_auto_install/composio login" "$interpreter_name unsafe auto recovery tail"
875 + done
876 +
877 + # A valid absolute install dir containing spaces stays copy-paste safe in
878 + # recovery output: the printed command executes the installed binary as-is.
879 + reset_case
880 + CASE_SHELL_CAPABILITY=unsupported
881 + space_home="$case_root/space-home"
882 + space_install="$case_root/space install/dir"
883 + mkdir -p "$space_home/.bashrc"
884 + space_output=$(run_installer "$space_home" "$space_install" "$case_root/space-bin" "$stable_tag" 2>&1) ||
885 + fail "$interpreter_name spaced install dir setup failure must keep the install successful"
886 + assert_tail "$space_output" $'To get started, run:\n\n '"'$space_install/composio' login" "$interpreter_name spaced recovery tail"
887 + space_recovery_line=$(printf '%s\n' "$space_output" | tail -n 1)
888 + space_recovery_command=${space_recovery_line# }
889 + space_recovery_command=${space_recovery_command% login}
890 + space_paste_output=$(env TEST_COMPOSIO_LOG="$composio_log" "$interpreter" -c "$space_recovery_command --version") ||
891 + fail "$interpreter_name spaced recovery command must execute when pasted"
892 + [[ $space_paste_output == 'composio fake 98.0.0' ]] || fail "$interpreter_name spaced recovery command output"
893 +
894 + # --- Final-block contract combinations (KD4/KD7) ---
895 +
896 + # Plugin output completes before the final block.
897 + reset_case
898 + CASE_PLUGINS=1
899 + plugin_order_output=$(run_installer "$case_root/plugin-order-home" "$case_root/plugin-order-install" "$case_root/plugin-order-bin" "$stable_tag" 2>&1)
900 + assert_contains "$plugin_order_output" 'Installing plugins for detected agent hosts...' "$interpreter_name plugin status printed"
901 + assert_tail "$plugin_order_output" "$case_b_tail" "$interpreter_name plugin output precedes the final block"
902 +
903 + # --agent, setup succeeds, command not yet resolvable: completed state plus
904 + # only the new-terminal notice; never a second login command.
905 + reset_case
906 + agent_home="$case_root/agent-home"
907 + agent_output=$(run_installer "$agent_home" "$case_root/agent-install" "$case_root/agent-bin" "$stable_tag" --agent 2>&1)
908 + grep -Fq 'login --agent --no-skill-install' "$composio_log" || fail "$interpreter_name agent login invocation"
909 + assert_not_contains "$agent_output" 'composio login' "$interpreter_name agent flow must not print a generic login command"
910 + assert_tail "$agent_output" $'Composio agent login complete.\nOpen a new terminal to use the composio command.' "$interpreter_name agent Case B tail"
911 +
912 + # --agent with the installed command already resolvable: completed state only.
913 + reset_case
914 + agent_ready_bin="$case_root/agent-ready-bin"
915 + CASE_PATH_PREFIX="$agent_ready_bin:"
916 + agent_ready_output=$(run_installer "$case_root/agent-ready-home" "$case_root/agent-ready-install" "$agent_ready_bin" "$stable_tag" --agent 2>&1)
917 + assert_not_contains "$agent_ready_output" 'Open a new terminal' "$interpreter_name agent ready flow needs no terminal notice"
918 + assert_tail "$agent_ready_output" 'Composio agent login complete.' "$interpreter_name agent Case A tail"
919 +
920 + # --agent with setup failure: completed state plus warning and trusted
921 + # installed-path guidance; still no generic login command.
922 + reset_case
923 + CASE_SHELL_CAPABILITY=unsupported
924 + agent_fail_home="$case_root/agent-fail-home"
925 + agent_fail_install="$case_root/agent-fail-install"
926 + mkdir -p "$agent_fail_home/.bashrc"
927 + agent_fail_output=$(run_installer "$agent_fail_home" "$agent_fail_install" "$case_root/agent-fail-bin" "$stable_tag" --agent 2>&1) ||
928 + fail "$interpreter_name agent setup failure must keep the install successful"
929 + assert_contains "$agent_fail_output" 'Composio agent login complete.' "$interpreter_name agent completion survives setup failure"
930 + assert_contains "$agent_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name agent setup failure warning"
931 + assert_not_contains "$agent_fail_output" 'composio login' "$interpreter_name agent setup failure must not print a login command"
932 + 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"
933 +
934 + # --agent with setup skipped (none): completed state plus installed-path guidance.
935 + reset_case
936 + CASE_INSTALL_SHELL=none
937 + agent_none_install="$case_root/agent-none-install"
938 + agent_none_output=$(run_installer "$case_root/agent-none-home" "$agent_none_install" "$case_root/agent-none-bin" "$stable_tag" --agent 2>&1)
939 + assert_not_contains "$agent_none_output" 'composio login' "$interpreter_name agent none flow must not print a login command"
940 + 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"
941 +
942 + # Quiet mode keeps setup-failure recovery visible.
943 + reset_case
944 + CASE_QUIET=1
945 + CASE_SHELL_CAPABILITY=unsupported
946 + quiet_fail_home="$case_root/quiet-fail-home"
947 + quiet_fail_install="$case_root/quiet-fail-install"
948 + mkdir -p "$quiet_fail_home/.bashrc"
949 + quiet_fail_output=$(run_installer "$quiet_fail_home" "$quiet_fail_install" "$case_root/quiet-fail-bin" "$stable_tag" 2>&1) ||
950 + fail "$interpreter_name quiet setup failure must keep the install successful"
951 + assert_contains "$quiet_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name quiet keeps the setup-failure warning"
952 + assert_tail "$quiet_fail_output" $'To get started, run:\n\n '"$quiet_fail_install/composio login" "$interpreter_name quiet keeps the recovery tail"
953 +
954 + # COMPOSIO_INSTALL_HELP=0 also keeps setup-failure recovery visible.
955 + reset_case
956 + CASE_HELP=0
957 + CASE_SHELL_CAPABILITY=unsupported
958 + helpless_fail_home="$case_root/helpless-fail-home"
959 + helpless_fail_install="$case_root/helpless-fail-install"
960 + mkdir -p "$helpless_fail_home/.bashrc"
961 + helpless_fail_output=$(run_installer "$helpless_fail_home" "$helpless_fail_install" "$case_root/helpless-fail-bin" "$stable_tag" 2>&1) ||
962 + fail "$interpreter_name help-suppressed setup failure must keep the install successful"
963 + assert_contains "$helpless_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name help suppression keeps the setup-failure warning"
964 + assert_tail "$helpless_fail_output" $'To get started, run:\n\n '"$helpless_fail_install/composio login" "$interpreter_name help suppression keeps the recovery tail"
965 +
966 printf 'install scripts passed under %s\n' "$interpreter_name"
967 done
968
ts/packages/cli/test/src/analytics.events.test.ts
+16 -6
@@ -481,23 +481,33 @@ describe('CLI analytics journey taxonomy', () => {
481 });
482 });
483
484 - it('keeps the base installer install-only and marks shell-variant delegation as installer-origin', () => {
484 + it('marks base-installer shell-setup delegation as installer-origin and keeps shell variants on the env override', () => {
485 + // The base installer defaults to automatic shell setup, so it owns the
486 + // `install --shell` delegation and must tag it as installer-origin.
487 const installScript = readFileSync(
488 new URL('../../../../../install.sh', import.meta.url),
489 'utf8'
490 );
489 - expect(installScript).not.toContain('"$exe" install');
491 + const delegationLine = installScript
492 + .split('\n')
493 + .find(line => line.includes('"$exe" install --shell'));
494
495 + expect(delegationLine).toBeDefined();
496 + expect(delegationLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');
497 +
498 + // Shell variants delegate to the base installer through the explicit
499 + // COMPOSIO_INSTALL_SHELL override instead of invoking the CLI themselves.
500 for (const shell of ['zsh', 'bash', 'fish']) {
501 const variantScript = readFileSync(
502 new URL(`../../../../../install/${shell}.sh`, import.meta.url),
503 'utf8'
504 );
496 - const installLine = variantScript
497 - .split('\n')
498 - .find(line => line.includes('"$variant_exe" install --shell'));
505
500 - expect(installLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');
506 + expect(variantScript).toContain(`requested_shell() { printf '%s\\n' ${shell}; }`);
507 + expect(variantScript).toContain(
508 + 'COMPOSIO_INSTALL_SHELL="$variant_shell" sh "$variant_tmpdir/install.sh" "$@"'
509 + );
510 + expect(variantScript).not.toContain('install --shell');
511 }
512 });
513 });