From ccad7e7b29643eacd56e2fc7ec833cb4bfd956ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 11 May 2026 15:07:29 +0300 Subject: [PATCH] fix(brain-install): remove dead-branch mapping; add catch-all to filter case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two code-quality fixes after review of dc71e23 (Task 1): I1 — Dead-branch logic in install.sh: The plugin-install block sits inside the `elif [ "$mode" = "user" ]` branch, so `[ "$mode" = "project" ] && plugin_target="consumer"` is unreachable (`$mode` is always "user" here). Replaced with hardcoded `--install-target=user` plus clarifying comment about future consumer-mode wiring. I2 — Filter case missing catch-all in install-plugins.sh: The two `case "$install_target"` blocks (validation at lines 40-43, filter at lines 75-82) were physically separate. If a future enum value is added to validation without updating filter, $filter would be unset → set -u crash. Added explicit `*)` catch-all with log_error + exit 1. Plan §Task 1 Step 1.7 contained the same I1 bug as dc71e23 — implementer followed plan faithfully. This fix corrects the code; plan stays as historical record. Future plans referencing this pattern should match THIS fix, not the original plan text. Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/install.sh | 9 +++++---- scripts/lib/install-plugins.sh | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 8da7768..31de3ef 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -144,13 +144,14 @@ elif [ "$mode" = "user" ]; then # Plugins if [ "$with_plugins" = "yes" ]; then if [ -f "$src/marketplaces.json" ] && [ -f "$src/plugins-manifest.json" ]; then - # Map mode (user|project) to install-target (user|consumer) - plugin_target="user" - [ "$mode" = "project" ] && plugin_target="consumer" + # NOTE: this plugin-install block currently only runs in user mode + # (it sits inside `elif [ "$mode" = "user" ]` above). Future consumer-mode + # plugin install would need a separate block in the `if [ "$mode" = "project" ]` + # branch above, passing --install-target=consumer. bash "$SCRIPT_DIR/lib/install-plugins.sh" \ --marketplaces="$src/marketplaces.json" \ --manifest="$src/plugins-manifest.json" \ - --install-target="$plugin_target" || exit 6 + --install-target=user || exit 6 fi fi fi diff --git a/scripts/lib/install-plugins.sh b/scripts/lib/install-plugins.sh index 07b1829..4c01269 100644 --- a/scripts/lib/install-plugins.sh +++ b/scripts/lib/install-plugins.sh @@ -79,6 +79,10 @@ case "$install_target" in consumer) filter='.plugins | to_entries[] | select(.value[0].target == "consumer" or .value[0].target == "user-level+consumer") | .key' ;; + *) + log_error "internal: unhandled install_target=$install_target (should have been validated above)" + exit 1 + ;; esac for plugin in $(jq -r "$filter" "$manifest"); do