54
fail "$label"
55
}
56
57
+# The single confirmation both setup paths print: it names the startup files
58
+# that now carry the managed block and never leaks internal vocabulary.
59
+configured_line() {
60
+ case $1 in
61
+ zsh) printf 'Configured zsh shell setup in ~/.zshrc.\n' ;;
62
+ bash) printf 'Configured bash shell setup in ~/.bashrc and ~/.bash_profile.\n' ;;
63
+ fish) printf 'Configured fish shell setup in ~/.config/fish/config.fish.\n' ;;
64
+ *) fail "configured_line: unknown shell $1" ;;
65
+ esac
66
+}
67
+
68
+# macOS Terminal.app starts bash as a login shell, which reads only the first
69
+# existing of ~/.bash_profile, ~/.bash_login, ~/.profile and never ~/.bashrc.
70
+# Probe a real login bash over the sandboxed HOME to prove the PATH entry
71
+# actually lands somewhere it reads.
72
+assert_login_bash_path() {
73
+ local home=$1
74
+ local bin=$2
75
+ local label=$3
76
+ local login_path
77
+ login_path=$(env -i HOME="$home" PATH=/usr/bin:/bin bash -lc 'printf %s "$PATH"') ||
78
+ fail "$label (login bash probe failed)"
79
+ case ":$login_path:" in
80
+ *":$bin:"*) ;;
81
+ *) fail "$label (login bash PATH lacks $bin: $login_path)" ;;
82
+ esac
83
+}
84
+
85
for script in "$repo_root/install.sh" "$repo_root"/install/*.sh; do
86
[[ $(tail -n 1 "$script") == 'main "$@"' ]] || fail "$script must end with main \"\$@\""
87
[[ $(grep -c '^main "\$@"$' "$script") -eq 1 ]] || fail "$script must contain one main entry point"
345
write_block "$HOME/.config/fish/config.fish" "set --export PATH \"$COMPOSIO_BIN_DIR\" \$PATH"
346
;;
347
bash)
348
+ # Login bash never reads .bashrc, so the CLI also configures a
349
+ # login-mode file, creating ~/.bash_profile when no override exists.
350
+ # (The real CLI additionally seeds a ~/.profile passthrough into a file
351
+ # it creates; that belongs to the CLI and is covered by its unit tests.)
352
write_block "$HOME/.bashrc" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
321
- if [ -f "$HOME/.bash_profile" ]; then
322
- write_block "$HOME/.bash_profile" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
323
- elif [ -f "$HOME/.bash_login" ]; then
353
+ if [ ! -f "$HOME/.bash_profile" ] && [ -f "$HOME/.bash_login" ]; then
354
write_block "$HOME/.bash_login" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
355
+ else
356
+ write_block "$HOME/.bash_profile" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
357
fi
358
;;
359
esac
476
[[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target"
477
assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery"
478
grep -Fq "|installer|$bin_dir|install --shell bash" "$composio_log" || fail "$interpreter_name default auto delegation"
447
- assert_contains "$output" 'Configured bash shell setup (cli).' "$interpreter_name default auto confirmation"
479
+ assert_contains "$output" "$(configured_line bash)" "$interpreter_name default auto confirmation"
480
+ assert_not_contains "$output" '(cli)' "$interpreter_name confirmation must not leak internal labels"
481
+ assert_not_contains "$output" '(fallback)' "$interpreter_name confirmation must not leak internal labels"
482
# Inherited-PATH contract: the installer prepends the bin dir to its own PATH
483
# for delegated CLI calls, but the ending must reflect only the PATH the
484
# invoking terminal inherited, which does not contain the bin dir here.
485
assert_tail "$output" "$case_b_tail" "$interpreter_name default auto Case B tail"
486
grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bashrc" || fail "$interpreter_name delegated default flow rc written by the CLI"
487
+ # A login bash reads none of ~/.bashrc, so the delegated path must reach a
488
+ # login-mode startup file as well.
489
+ grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bash_profile" ||
490
+ fail "$interpreter_name delegated default flow login file written by the CLI"
491
+ assert_login_bash_path "$home" "$bin_dir" "$interpreter_name delegated default flow login shell"
492
assert_not_contains "$output" 'Updated ~/.bashrc' "$interpreter_name delegated default flow must not rewrite rc files inline"
493
[[ $(wc -l <"$composio_log") -eq 3 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
494
grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe"
576
reset_case
577
CASE_HELP=0
578
help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1)
540
- assert_contains "$help_suppressed" 'Configured bash shell setup (cli).' "$interpreter_name help suppression keeps setup status"
579
+ assert_contains "$help_suppressed" "$(configured_line bash)" "$interpreter_name help suppression keeps setup status"
580
assert_not_contains "$help_suppressed" 'composio login' "$interpreter_name help suppression removes the final block"
581
assert_not_contains "$help_suppressed" 'Open a new terminal' "$interpreter_name help suppression removes the final block"
582
666
variant_output=$(run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins 2>&1)
667
grep -Fq "|installer|$variant_bin|install --shell $shell_name" "$composio_log" ||
668
fail "$interpreter_name $shell_name variant delegation"
630
- assert_contains "$variant_output" "Configured $shell_name shell setup (cli)." "$interpreter_name $shell_name variant confirmation"
669
+ assert_contains "$variant_output" "$(configured_line "$shell_name")" "$interpreter_name $shell_name variant confirmation"
670
assert_not_contains "$variant_output" 'Required next step' "$interpreter_name $shell_name variant must not print setup guidance"
671
assert_not_contains "$variant_output" 'Optional shell setup' "$interpreter_name $shell_name variant must not print setup guidance"
672
done
677
direct_bin="$case_root/direct-shell-bin"
678
direct_output=$(run_installer "$direct_home" "$case_root/direct-shell-install" "$direct_bin" "$stable_tag" 2>&1)
679
grep -Fq "|installer|$direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL delegation"
641
- assert_contains "$direct_output" 'Configured zsh shell setup (cli).' "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
680
+ assert_contains "$direct_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
681
assert_not_contains "$direct_output" 'Required next step' "$interpreter_name COMPOSIO_INSTALL_SHELL must not print setup guidance"
682
assert_tail "$direct_output" "$case_b_tail" "$interpreter_name COMPOSIO_INSTALL_SHELL Case B tail"
683
grep -Fq "export PATH=\"$direct_bin:\$PATH\"" "$direct_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL CLI-written block"
689
direct_fallback_home="$case_root/direct-fallback-home"
690
direct_fallback_output=$(run_installer "$direct_fallback_home" "$case_root/direct-fallback-install" "$case_root/direct-fallback-bin" "$stable_tag" 2>&1)
691
grep -Fqx '# Composio CLI' "$direct_fallback_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL unsupported CLI fallback"
653
- assert_contains "$direct_fallback_output" 'Configured zsh shell setup (fallback).' "$interpreter_name COMPOSIO_INSTALL_SHELL fallback confirmation"
692
+ assert_contains "$direct_fallback_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL fallback confirmation"
693
694
reset_case
695
CASE_INSTALL_SHELL=fish
765
auto_output=$(run_installer "$auto_home" "$auto_install" "$auto_bin" "$stable_tag" 2>&1)
766
grep -Fq "|installer|$auto_bin|install --shell $auto_shell" "$composio_log" ||
767
fail "$interpreter_name auto $auto_shell delegation"
729
- assert_contains "$auto_output" "Configured $auto_shell shell setup (cli)." "$interpreter_name auto $auto_shell confirmation"
768
+ assert_contains "$auto_output" "$(configured_line "$auto_shell")" "$interpreter_name auto $auto_shell confirmation"
769
assert_tail "$auto_output" "$case_b_tail" "$interpreter_name auto $auto_shell Case B tail"
770
done
771
857
# Pinned old CLI: supports --shell but ignores the invocation-origin hint,
858
# prints its own boxed restart hint, and exits 0 without reconciling. A
859
# relative COMPOSIO_BIN_DIR must never reach setup raw; the installer must
821
- # detect the unreconciled startup file and repair it inline; its plain final
822
- # block prints after the old hint and supersedes it.
860
+ # detect the unreconciled startup file and repair it inline. The delegated
861
+ # command's own presentation never reaches the user: the installer owns its
862
+ # output and its plain final block is the only ending.
863
reset_case
864
CASE_INSTALL_HINT=1
865
CASE_INSTALL_RECONCILE=0
872
fail "$interpreter_name old-CLI setup must receive the resolved absolute bin dir"
873
grep -Fq "export PATH=\"$oldcli_work/rel-bin:\$PATH\"" "$oldcli_home/.bashrc" ||
874
fail "$interpreter_name old-CLI delegation must be reconciled inline with the absolute bin dir"
835
- assert_contains "$oldcli_output" 'Configured bash shell setup (fallback).' "$interpreter_name old-CLI reconciliation disclosure"
836
- assert_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name old-CLI restart hint passes through"
875
+ assert_contains "$oldcli_output" "$(configured_line bash)" "$interpreter_name old-CLI reconciliation disclosure"
876
+ assert_not_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name delegated CLI output must not leak"
877
assert_tail "$oldcli_output" "$case_b_tail" "$interpreter_name old-CLI hint superseded by the installer tail"
878
879
+ # The suppressed delegated output stays available for troubleshooting.
880
+ reset_case
881
+ CASE_INSTALL_HINT=1
882
+ CASE_DEBUG=1
883
+ delegated_debug_output=$(run_installer "$case_root/delegated-debug-home" "$case_root/delegated-debug-install" "$case_root/delegated-debug-bin" "$stable_tag" 2>&1)
884
+ assert_contains "$delegated_debug_output" 'delegated shell setup exited 0' "$interpreter_name debug reports the delegated exit status"
885
+ assert_contains "$delegated_debug_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name debug replays the captured delegated output"
886
+ assert_contains "$delegated_debug_output" '+ shell setup source: cli' "$interpreter_name debug keeps the setup-source distinction"
887
+
888
+ # --- Login-shell reachability for bash (macOS Terminal.app) ---
889
+
890
+ # Inline path, virgin home: ~/.bashrc alone is unreachable from a login bash,
891
+ # so the installer must also create a login-mode startup file.
892
+ reset_case
893
+ CASE_SHELL_CAPABILITY=unsupported
894
+ CASE_SHELL_VALUE=/bin/bash
895
+ bash_login_home="$case_root/bash-login-home"
896
+ bash_login_bin="$case_root/bash-login-bin"
897
+ bash_login_output=$(run_installer "$bash_login_home" "$case_root/bash-login-install" "$bash_login_bin" "$stable_tag" 2>&1)
898
+ grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bashrc" ||
899
+ fail "$interpreter_name inline bash setup must configure .bashrc"
900
+ grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bash_profile" ||
901
+ fail "$interpreter_name inline bash setup must configure a login-mode startup file"
902
+ assert_login_bash_path "$bash_login_home" "$bash_login_bin" "$interpreter_name inline bash login shell"
903
+ assert_contains "$bash_login_output" "$(configured_line bash)" "$interpreter_name inline bash names both startup files"
904
+ [[ ! -e "$bash_login_home/.profile" ]] || fail "$interpreter_name inline bash setup must not create ~/.profile"
905
+
906
+ # A created ~/.bash_profile shadows an existing ~/.profile, so it must keep
907
+ # sourcing it — and must never rewrite ~/.profile itself.
908
+ reset_case
909
+ CASE_SHELL_CAPABILITY=unsupported
910
+ CASE_SHELL_VALUE=/bin/bash
911
+ bash_profile_home="$case_root/bash-profile-home"
912
+ bash_profile_bin="$case_root/bash-profile-bin"
913
+ mkdir -p "$bash_profile_home"
914
+ printf '%s\n' 'export DISTRO_PROFILE=1' >"$bash_profile_home/.profile"
915
+ run_installer "$bash_profile_home" "$case_root/bash-profile-install" "$bash_profile_bin" "$stable_tag" >/dev/null 2>&1
916
+ grep -Fq '. "$HOME/.profile"' "$bash_profile_home/.bash_profile" ||
917
+ fail "$interpreter_name a created .bash_profile must keep sourcing ~/.profile"
918
+ [[ $(<"$bash_profile_home/.profile") == 'export DISTRO_PROFILE=1' ]] ||
919
+ fail "$interpreter_name ~/.profile must not be modified"
920
+ assert_login_bash_path "$bash_profile_home" "$bash_profile_bin" "$interpreter_name shadowed profile login shell"
921
+ shadowed_profile_value=$(env -i HOME="$bash_profile_home" PATH=/usr/bin:/bin bash -lc 'printf %s "${DISTRO_PROFILE:-}"')
922
+ [[ $shadowed_profile_value == 1 ]] ||
923
+ fail "$interpreter_name a created .bash_profile must not shadow ~/.profile content"
924
+
925
+ # An existing ~/.bash_login is the login file bash reads, so it is reused and
926
+ # no ~/.bash_profile is invented in front of it.
927
+ reset_case
928
+ CASE_SHELL_CAPABILITY=unsupported
929
+ CASE_SHELL_VALUE=/bin/bash
930
+ bash_login_only_home="$case_root/bash-login-only-home"
931
+ bash_login_only_bin="$case_root/bash-login-only-bin"
932
+ mkdir -p "$bash_login_only_home"
933
+ printf '%s\n' 'export LOGIN_OVERRIDE=1' >"$bash_login_only_home/.bash_login"
934
+ bash_login_only_output=$(run_installer "$bash_login_only_home" "$case_root/bash-login-only-install" "$bash_login_only_bin" "$stable_tag" 2>&1)
935
+ grep -Fq "export PATH=\"$bash_login_only_bin:\$PATH\"" "$bash_login_only_home/.bash_login" ||
936
+ fail "$interpreter_name existing .bash_login must receive the managed block"
937
+ [[ ! -e "$bash_login_only_home/.bash_profile" ]] ||
938
+ fail "$interpreter_name an existing .bash_login must not be shadowed by a new .bash_profile"
939
+ assert_contains "$bash_login_only_output" 'Configured bash shell setup in ~/.bashrc and ~/.bash_login.' "$interpreter_name .bash_login disclosure"
940
+ assert_login_bash_path "$bash_login_only_home" "$bash_login_only_bin" "$interpreter_name .bash_login login shell"
941
+
942
# --- Setup write failures stay non-fatal (KD3/KD4) ---
943
944
# Delegated path: CLI --shell fails, inline fallback also fails.
952
fail "$interpreter_name delegated setup failure must keep the install successful"
953
[[ -x "$wf_delegated_install/composio" ]] || fail "$interpreter_name delegated setup failure must retain the binary"
954
assert_contains "$wf_delegated_output" 'warning: Automatic PATH setup for zsh failed' "$interpreter_name delegated setup failure warning"
955
+ assert_contains "$wf_delegated_output" 'COMPOSIO_DEBUG=1' "$interpreter_name delegated setup failure points at the captured output"
956
assert_tail "$wf_delegated_output" $'To get started, run:\n\n '"$wf_delegated_install/composio login" "$interpreter_name delegated setup failure recovery tail"
957
958
# Inline path: helper failure inside a conditional must propagate explicitly.
1074
printf '%s\n' 'alias stale-guard=1' '' '# Composio CLI' 'export PATH="/stale/old-bin:$PATH"' >"$stale_home/.zshrc"
1075
stale_output=$(run_installer "$stale_home" "$case_root/stale-delegated-install" "$stale_bin" "$stable_tag" 2>&1)
1076
grep -Fq "|installer|$stale_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name stale delegation still delegates first"
973
- assert_contains "$stale_output" 'Configured zsh shell setup (fallback).' "$interpreter_name stale delegation reconciles inline"
1077
+ assert_contains "$stale_output" "$(configured_line zsh)" "$interpreter_name stale delegation reconciles inline"
1078
[[ $(grep -Fc '# Composio CLI' "$stale_home/.zshrc") -eq 1 ]] || fail "$interpreter_name stale reconcile keeps one marker block"
1079
grep -Fq "export PATH=\"$stale_bin:\$PATH\"" "$stale_home/.zshrc" || fail "$interpreter_name stale reconcile names the current bin dir"
1080
if grep -Fq '/stale/old-bin' "$stale_home/.zshrc"; then