|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
| 3 | +set -e # Exit on any error |
| 4 | + |
3 | 5 | AGENTS_WORKFLOW_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" |
4 | 6 |
|
5 | | -# We move the agents-workflow dir away from the workspace in order |
6 | | -# to prevent the agents from looking into it (this wastes their time) |
7 | | -sudo mv "$AGENTS_WORKFLOW_DIR" /agents-workflow |
| 7 | +# Use portable temp directory that works across all environments |
| 8 | +TEMP_DIR="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}" |
| 9 | +TEMP_AGENTS_DIR="$TEMP_DIR/agents-workflow" |
| 10 | + |
| 11 | +# Create the temp directory if it doesn't exist |
| 12 | +sudo mkdir -p "$TEMP_DIR" |
| 13 | + |
| 14 | +echo "About to move the agents-workflow dir from $AGENTS_WORKFLOW_DIR to $TEMP_AGENTS_DIR" |
| 15 | + |
| 16 | +# Remove any existing temp directory to avoid conflicts |
| 17 | +if [ -d "$TEMP_AGENTS_DIR" ]; then |
| 18 | + echo "Removing exisitng $TEMP_AGENTS_DIR" |
| 19 | + rm -rf "$TEMP_AGENTS_DIR" |
| 20 | +fi |
| 21 | + |
| 22 | +# Try to move the directory - this should work since the script is loaded in memory |
| 23 | +# This prevents agents from looking into it (wastes their time) |
| 24 | +if ! mv "$AGENTS_WORKFLOW_DIR" "$TEMP_AGENTS_DIR"; then |
| 25 | + echo "Move failed, falling back to copy strategy" >&2 |
| 26 | + cp -r "$AGENTS_WORKFLOW_DIR" "$TEMP_AGENTS_DIR" |
| 27 | + rm -rf "$AGENTS_WORKFLOW_DIR" || true |
| 28 | +fi |
| 29 | + |
| 30 | +# Try standard system directories that are already in PATH for all users |
| 31 | +# Use the first one that's writable or can be made writable |
| 32 | +if [ -d "/usr/local/bin" ]; then |
| 33 | + BIN_DIR="/usr/local/bin" |
| 34 | +elif [ -d "/usr/bin" ]; then |
| 35 | + BIN_DIR="/usr/bin" |
| 36 | +else |
| 37 | + echo "Cannot find suitable bin directory to install get-task" >&2 |
| 38 | + exit 1 |
| 39 | +fi |
| 40 | + |
| 41 | +# Create the get-task symlink in the chosen directory |
| 42 | +sudo ln -sf "$TEMP_AGENTS_DIR/bin/get-task" "$BIN_DIR/get-task" |
8 | 43 |
|
9 | | -# We want to make the `get-task` command available for the agent: |
10 | | -sudo ln -s "/agents-workflow/bin/get-task" /usr/local/bin/get-task |
| 44 | +echo "Final get-task script location: $BIN_DIR/get-task" |
| 45 | +echo "Final get-task script:" |
| 46 | +cat "$BIN_DIR/get-task" |
0 commit comments