diff --git a/scripts/setup-ai-workspace-all-in-one.sh b/scripts/setup-ai-workspace-all-in-one.sh index 28cdc14..7e54971 100755 --- a/scripts/setup-ai-workspace-all-in-one.sh +++ b/scripts/setup-ai-workspace-all-in-one.sh @@ -1085,11 +1085,16 @@ patch_playbooks_for_macos() { info "Fetching and running macOS playbook patches..." local patch_script="/tmp/patch-macos-playbooks.py" local raw_url="https://raw.githubusercontent.com/ai-workspace-lab/xworkspace-console/main/scripts/patch-macos-playbooks.py" - - if command -v curl >/dev/null 2>&1; then - curl -sfL -o "$patch_script" "$raw_url" + local bootstrap_script_dir local_patch_script + bootstrap_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-}")" 2>/dev/null && pwd || true)" + local_patch_script="${bootstrap_script_dir}/patch-macos-playbooks.py" + + if [ -f "$local_patch_script" ]; then + cp "$local_patch_script" "$patch_script" + elif command -v curl >/dev/null 2>&1; then + curl -sfL -o "$patch_script" "${raw_url}?rev=$(date +%s)" else - wget -qO "$patch_script" "$raw_url" + wget -qO "$patch_script" "${raw_url}?rev=$(date +%s)" fi if [ -f "$patch_script" ]; then diff --git a/tests/setup-ai-workspace-all-in-one-test.sh b/tests/setup-ai-workspace-all-in-one-test.sh index 77ee9cf..c7177d8 100755 --- a/tests/setup-ai-workspace-all-in-one-test.sh +++ b/tests/setup-ai-workspace-all-in-one-test.sh @@ -250,6 +250,13 @@ test_macos_plugin_patch_uses_stable_directory() { fi } +test_local_bootstrap_prefers_local_macos_patcher() { + grep -Fq 'if [ -f "$local_patch_script" ]' "$BOOTSTRAP" || + fail "local bootstrap does not prefer its checked-in macOS patcher" + grep -Fq '"${raw_url}?rev=$(date +%s)"' "$BOOTSTRAP" || + fail "remote macOS patcher download is not cache-busted" +} + test_root_does_not_require_sudo printf 'ok - root execution does not require sudo\n' test_non_root_uses_sudo @@ -283,3 +290,5 @@ test_provider_api_keys_use_secret_logging printf 'ok - provider API keys use masked secret logging\n' test_macos_plugin_patch_uses_stable_directory printf 'ok - macOS plugin patch uses stable extension storage\n' +test_local_bootstrap_prefers_local_macos_patcher +printf 'ok - local bootstrap prefers the checked-in macOS patcher\n'