From 9692d3a7526f991010f92504d79ad55f7a376647 Mon Sep 17 00:00:00 2001 From: darrenhinde <107584450+darrenhinde@users.noreply.github.com> Date: Wed, 19 Nov 2025 01:22:21 +0000 Subject: [PATCH] fix: respect --install-dir argument throughout installation process - Add get_install_path() helper to convert registry paths to installation paths - Fix collision detection to check files in custom install directory - Fix file installation to use custom directory instead of hardcoded .opencode - Fix env.example path check in post-install message - Tested with .test-install-dir and .openffff directories - all files now install to correct location --- install.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 59be0c6..11727f9 100755 --- a/install.sh +++ b/install.sh @@ -275,6 +275,17 @@ get_registry_key() { esac } +# Helper function to convert registry path to installation path +# Registry paths are like ".opencode/agent/foo.md" +# We need to replace ".opencode" with the actual INSTALL_DIR +get_install_path() { + local registry_path=$1 + # Strip leading .opencode/ if present + local relative_path="${registry_path#.opencode/}" + # Return INSTALL_DIR + relative path + echo "${INSTALL_DIR}/${relative_path}" +} + resolve_dependencies() { local component=$1 local type="${component%%:*}" @@ -809,8 +820,11 @@ perform_installation() { local registry_key=$(get_registry_key "$type") local path=$(jq -r ".components.${registry_key}[] | select(.id == \"${id}\") | .path" "$TEMP_DIR/registry.json") - if [ -n "$path" ] && [ "$path" != "null" ] && [ -f "$path" ]; then - collisions+=("$path") + if [ -n "$path" ] && [ "$path" != "null" ]; then + local install_path=$(get_install_path "$path") + if [ -f "$install_path" ]; then + collisions+=("$install_path") + fi fi done @@ -878,9 +892,12 @@ perform_installation() { continue fi + # Convert registry path to installation path + local dest=$(get_install_path "$path") + # Check if file exists before we install (for proper messaging) local file_existed=false - if [ -f "$path" ]; then + if [ -f "$dest" ]; then file_existed=true fi @@ -893,7 +910,6 @@ perform_installation() { # Download component local url="${RAW_URL}/${path}" - local dest="${path}" # Create parent directory if needed mkdir -p "$(dirname "$dest")" @@ -945,7 +961,7 @@ show_post_install() { echo "1. Review the installed components in ${CYAN}${INSTALL_DIR}/${NC}" # Check if env.example was installed - if [ -f "${INSTALL_DIR}/../env.example" ] || [ -f "env.example" ]; then + if [ -f "${INSTALL_DIR}/env.example" ] || [ -f "env.example" ]; then echo "2. Copy env.example to .env and configure:" echo " ${CYAN}cp env.example .env${NC}" echo "3. Start using OpenCode agents:"