Browse Source

fix: remove hardcoded path and load from .env in handle-issue-ts.sh

Replace hardcoded AGENT_MANAGER_DIR with dynamic loading from .env file
using AGENT_MANAGER_PATH variable for better environment flexibility.

**Changes**:
- Load AGENT_MANAGER_PATH from .env file at multiple possible locations
- Try common paths: /home/claude/agent-manager/.env, /data/agent-manager/.env, $HOME/agent-manager/.env
- Fallback: Auto-detect from script location if .env not found
- Log which configuration source was used for debugging

**Benefits**:
- No hardcoded paths - works across different environments
- Respects .env.example configuration pattern
- Automatic fallback ensures script still works without .env
- Makes deployment to different servers easier

**Usage**:
Set in .env file:
```
AGENT_MANAGER_PATH=/your/custom/path/agent-manager
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fszontagh 9 tháng trước cách đây
mục cha
commit
839ea52c29
1 tập tin đã thay đổi với 31 bổ sung4 xóa
  1. 31 4
      scripts/handle-issue-ts.sh

+ 31 - 4
scripts/handle-issue-ts.sh

@@ -73,14 +73,41 @@ fi
 cd "$REPO_PATH" || exit 1
 echo "Working directory: $(pwd)"
 
+# Load AGENT_MANAGER_PATH from project .env file
+# Try multiple possible locations for the agent-manager .env file
+AGENT_MANAGER_ENV_PATHS=(
+    "/home/claude/agent-manager/.env"
+    "/data/agent-manager/.env"
+    "$HOME/agent-manager/.env"
+)
+
+AGENT_MANAGER_PATH=""
+for ENV_PATH in "${AGENT_MANAGER_ENV_PATHS[@]}"; do
+    if [ -f "$ENV_PATH" ]; then
+        # Load AGENT_MANAGER_PATH from .env if it exists
+        AGENT_MANAGER_PATH=$(grep -E "^AGENT_MANAGER_PATH=" "$ENV_PATH" | cut -d '=' -f2-)
+        if [ -n "$AGENT_MANAGER_PATH" ]; then
+            echo "Loaded AGENT_MANAGER_PATH from: $ENV_PATH"
+            break
+        fi
+    fi
+done
+
+# Fallback: try to detect from script location
+if [ -z "$AGENT_MANAGER_PATH" ]; then
+    # Get the directory where this script is located
+    SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+    # Go up one level from scripts/ to get agent-manager root
+    AGENT_MANAGER_PATH="$(dirname "$SCRIPT_DIR")"
+    echo "Using detected path from script location: $AGENT_MANAGER_PATH"
+fi
+
 echo "Calling Claude Agent SDK TypeScript client..."
+echo "Agent Manager Path: $AGENT_MANAGER_PATH"
 echo "---"
 
-# Get the path to the agent-manager directory
-AGENT_MANAGER_DIR="/data/agent-manager"
-
 # Call the TypeScript client
-node "$AGENT_MANAGER_DIR/client/dist/index.js" \
+node "$AGENT_MANAGER_PATH/client/dist/index.js" \
     "$OWNER" \
     "$REPO" \
     "$PUSHER" \