microsoft/hve-core
Publicmirrored from https://github.com/microsoft/hve-coreAvailable
.github/skills/installer/hve-core-installer/scripts/collision-detection.sh
47lines · modecode
| 1 | #!/usr/bin/env bash |
| 2 | # Copyright (c) Microsoft Corporation. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # Detects file collisions before copying HVE-Core agents. |
| 5 | # Usage: collision-detection.sh <hve_core_base_path> <selection> [collection_agents...] |
| 6 | # selection: 'hve-core' for RPI core bundle, or collection id |
| 7 | # collection_agents: space-separated relative paths (when selection is a collection) |
| 8 | set -euo pipefail |
| 9 | |
| 10 | hve_core_base_path="${1:?Usage: $0 <hve_core_base_path> <selection> [collection_agents...]}" |
| 11 | selection="${2:?Usage: $0 <hve_core_base_path> <selection> [collection_agents...]}" |
| 12 | shift 2 |
| 13 | |
| 14 | target_dir=".github/agents" |
| 15 | |
| 16 | # Build file list based on selection |
| 17 | case "$selection" in |
| 18 | hve-core) |
| 19 | files_to_copy=( |
| 20 | "hve-core/task-researcher.agent.md" |
| 21 | "hve-core/task-planner.agent.md" |
| 22 | "hve-core/task-implementor.agent.md" |
| 23 | "hve-core/task-reviewer.agent.md" |
| 24 | "hve-core/rpi-agent.agent.md" |
| 25 | ) |
| 26 | ;; |
| 27 | *) |
| 28 | files_to_copy=("$@") |
| 29 | ;; |
| 30 | esac |
| 31 | |
| 32 | # Check for collisions (target uses filename only) |
| 33 | collisions=() |
| 34 | for file in "${files_to_copy[@]}"; do |
| 35 | filename=$(basename "$file") |
| 36 | target_path="$target_dir/$filename" |
| 37 | if [ -f "$target_path" ]; then |
| 38 | collisions+=("$target_path") |
| 39 | fi |
| 40 | done |
| 41 | |
| 42 | if [ ${#collisions[@]} -gt 0 ]; then |
| 43 | echo "COLLISIONS_DETECTED=true" |
| 44 | IFS=','; echo "COLLISION_FILES=${collisions[*]}" |
| 45 | else |
| 46 | echo "COLLISIONS_DETECTED=false" |
| 47 | fi |