From 7fe9ac913b3c8043552517d5f8697347b9bc1afd Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Thu, 25 Jun 2026 09:53:03 +0530 Subject: [PATCH] refactor: bashrc is always sourced after tool install automatically - Added source_bashrc funciton in shell_confi.sh - Removed bashrc source commands from installer scripts - Updated skill instructions --- .agents/skills/add_installer/SKILL.md | 1 + .agents/skills/release/SKILL.md | 20 +++++++++++++++----- b.sh | 9 +++++++++ installers/install_bat.sh | 1 - installers/install_node.sh | 1 - installers/install_pnpm.sh | 1 - lib/routes.sh | 1 + lib/shell_config.sh | 12 +++++++++++- scripts/release.sh | 5 +++-- 9 files changed, 40 insertions(+), 11 deletions(-) diff --git a/.agents/skills/add_installer/SKILL.md b/.agents/skills/add_installer/SKILL.md index bcd55ee..b7c2cc0 100644 --- a/.agents/skills/add_installer/SKILL.md +++ b/.agents/skills/add_installer/SKILL.md @@ -246,3 +246,4 @@ track_file "/usr/local/bin/binary" 6. **Error handling**: Use `set -euo pipefail` after the guard block. 7. **CLI Enforcement Guard**: Always copy the standalone execution guard block verbatim to the top of your installer script to prevent direct execution. 8. **Clean Official Scripts**: When implementing official curl/install scripts provided in the prompt, strip them of bloat, macOS/Windows support, and redundant shell setups before writing the script. +9. **No manual shell re-sourcing**: Do NOT manually run `source ~/.bashrc` or print instructions asking the user to run it. Sourcing of the shell configuration is handled automatically by the central router and CLI at the end of the installation. diff --git a/.agents/skills/release/SKILL.md b/.agents/skills/release/SKILL.md index e15bfab..84bc676 100644 --- a/.agents/skills/release/SKILL.md +++ b/.agents/skills/release/SKILL.md @@ -25,12 +25,22 @@ When the user asks to "cut a release", "bump the version", or "tag a new version - If any core-CLI commit has `feat:` → **minor** - Otherwise (only `fix:`, `refactor:`, etc. in core-CLI) → **patch** - If *all* commits are installer-only or docs-only → inform the user no release is needed. -3. **Run the release script** non-interactively (if an actual bump is needed): - ```bash - ./scripts/release.sh -- -y +3. **Formulate a verbose, structured description of the changes** based on the analyzed commits. Group the changes into logical sections (such as "Breaking Changes & Major Features:" and "Other Updates:") and list the corresponding commit messages or summaries. Example format: + ```text + Breaking Changes & Major Features: + + feat: Resumable Download Helper and Manifest Preservation + + Other Updates: + + docs: Update readme + feat(skills): Add Installer to use rollback and savepoint hooks ``` - (e.g., `./scripts/release.sh --minor -y`) -4. **Push** the tag and commit (ask for user confirmation before pushing): +4. **Run the release script** non-interactively, passing the compiled description: + ```bash + ./scripts/release.sh -- -y -m "" + ``` +5. **Push** the tag and commit (ask for user confirmation before pushing): ```bash git push origin master ``` diff --git a/b.sh b/b.sh index 5dde874..d380330 100755 --- a/b.sh +++ b/b.sh @@ -66,6 +66,15 @@ b() { # Execute the routes file bash "$routes_file" "$@" + local ret=$? + + # Sourced again in the parent shell after successfully running the command + if [ $ret -eq 0 ]; then + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi + fi + return $ret } # Autocompletion for the b command in Bash diff --git a/installers/install_bat.sh b/installers/install_bat.sh index 838c944..8fe6ccf 100644 --- a/installers/install_bat.sh +++ b/installers/install_bat.sh @@ -94,7 +94,6 @@ main() { echo log_success "Bat installation and configuration complete." - log_info "Please close and reopen your terminal or run: source ~/.bashrc to apply changes." } main "$@" diff --git a/installers/install_node.sh b/installers/install_node.sh index 201a9bc..bfdce16 100644 --- a/installers/install_node.sh +++ b/installers/install_node.sh @@ -109,7 +109,6 @@ main() { log_info "Installed NVM version: $(nvm --version 2>/dev/null || cat "$HOME/.nvm/package.json" | grep '"version":' | head -n1 | sed -E 's/.*"version": "([^"]+)".*/\1/' || echo "unknown")" else log_success "Installation complete." - log_info "Please close and reopen your terminal or run: source ~/.bashrc to verify." fi } diff --git a/installers/install_pnpm.sh b/installers/install_pnpm.sh index 046d228..46f8c2b 100644 --- a/installers/install_pnpm.sh +++ b/installers/install_pnpm.sh @@ -218,7 +218,6 @@ main() { log_info "Installed pnpm version: $(pnpm --version 2>/dev/null || echo 'unknown')" else log_success "Installation complete." - log_info "Please close and reopen your terminal or run: source ~/.bashrc to verify." fi } diff --git a/lib/routes.sh b/lib/routes.sh index 5993e23..8d43cf4 100755 --- a/lib/routes.sh +++ b/lib/routes.sh @@ -127,6 +127,7 @@ run_ware() { if [ "$run_status" -eq 0 ] && [ "$interrupted" = "false" ]; then mark_install_success "$tool" + source_bashrc else echo if [ "$interrupted" = "true" ]; then diff --git a/lib/shell_config.sh b/lib/shell_config.sh index 7f4bb8a..acf6632 100644 --- a/lib/shell_config.sh +++ b/lib/shell_config.sh @@ -166,8 +166,18 @@ create_fd_symlink() { fi } +# Source the bashrc file to reload configurations +source_bashrc() { + if [ -f "$HOME/.bashrc" ]; then + log_info "Re-sourcing ~/.bashrc..." + . "$HOME/.bashrc" + fi +} + # Export functions and variables for subshells export _LIB_SHELL_CONFIG_SOURCED=1 -export -f get_shell_configs remove_block inject_block add_alias_if_missing add_env_if_missing create_fd_symlink write_env_snippet write_alias_snippet remove_env_snippet remove_alias_snippet +export -f get_shell_configs remove_block inject_block add_alias_if_missing add_env_if_missing create_fd_symlink write_env_snippet write_alias_snippet remove_env_snippet remove_alias_snippet source_bashrc + + diff --git a/scripts/release.sh b/scripts/release.sh index ddc9511..08dd9b6 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -10,7 +10,7 @@ IFS='.' read -r cur_major cur_minor cur_patch <<< "${current#v}" bump="" auto_confirm=false - +message="" # Parse flags for non-interactive (agent) usage while [[ $# -gt 0 ]]; do case "$1" in @@ -18,6 +18,7 @@ while [[ $# -gt 0 ]]; do --minor) bump="minor"; shift ;; --major) bump="major"; shift ;; -y|--yes) auto_confirm=true; shift ;; + -m|--message) message="$2"; shift 2 ;; *) echo "Unknown option: $1" >&2; exit 1 ;; esac done @@ -58,7 +59,7 @@ if [[ "$confirm" =~ ^[Yy]$ ]]; then echo "${new_ver#v}" > VERSION git add VERSION git commit -m "release: $new_ver" - git tag -a "$new_ver" -m "Release $new_ver" + git tag -a "$new_ver" -m "${message:-Release $new_ver}" echo "Tagged $new_ver. Push with: git push origin master $new_ver" else echo "Aborted."