diff --git a/scripts/buildkite/bootstrap.sh b/scripts/buildkite/bootstrap.sh index 57b1b7e..ceba3a4 100755 --- a/scripts/buildkite/bootstrap.sh +++ b/scripts/buildkite/bootstrap.sh @@ -18,7 +18,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/lib.sh" REPO_ROOT="$(bk_repo_root)" -export PATH="${HOME}/.local/bin:/usr/local/bin:${PATH:-}" +bk_export_cursor_path # Sleek RID (Garden HTTPS checkouts lack a rad:// remote until we link them). RADICLE_RID="${RADICLE_RID:-rad:z9mjPzpVK472QXaaP1picc5U9xBR}" @@ -78,25 +78,32 @@ bk_soft_secret() { } install_cursor_agent() { - if command -v cursor-agent >/dev/null 2>&1; then - return 0 - fi - if command -v agent >/dev/null 2>&1; then + local cmd + bk_export_cursor_path + if cmd="$(bk_cursor_agent_cmd)"; then + echo "[bootstrap] Cursor CLI already on PATH: ${cmd} ($(command -v "$cmd"))" return 0 fi - echo "[bootstrap] installing Cursor CLI..." + echo "[bootstrap] installing Cursor CLI (curl https://cursor.com/install)..." curl -fsSL https://cursor.com/install | bash - export PATH="${HOME}/.cursor/bin:${PATH:-}" + # Installer may land in ~/.local/bin and/or ~/.cursor/bin; re-export both. + bk_export_cursor_path + + if ! cmd="$(bk_cursor_agent_cmd)"; then + echo "[bootstrap] warn: looking for agent binaries under common install dirs..." >&2 + ls -la "${HOME}/.local/bin/agent" "${HOME}/.local/bin/cursor-agent" \ + "${HOME}/.cursor/bin/agent" "${HOME}/.cursor/bin/cursor-agent" 2>&1 || true + bk_die "cursor-agent / agent not found after install (expected under ~/.local/bin or ~/.cursor/bin)" + fi + echo "[bootstrap] Cursor CLI installed: ${cmd} ($(command -v "$cmd"))" } cursor_agent_cmd() { - if command -v cursor-agent >/dev/null 2>&1; then - echo "cursor-agent" - return 0 - fi - if command -v agent >/dev/null 2>&1; then - echo "agent" + bk_export_cursor_path + local cmd + if cmd="$(bk_cursor_agent_cmd)"; then + echo "$cmd" return 0 fi bk_die "cursor-agent / agent not found after install" diff --git a/scripts/buildkite/delegate.sh b/scripts/buildkite/delegate.sh index 9faa78b..5004eaa 100755 --- a/scripts/buildkite/delegate.sh +++ b/scripts/buildkite/delegate.sh @@ -4,6 +4,11 @@ # [--output-format json|text] [--timeout SECONDS] [--force] set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=lib.sh +source "$SCRIPT_DIR/lib.sh" +bk_export_cursor_path + task="" workspace="" model="" @@ -34,12 +39,12 @@ if [[ -z "${task:-}" ]]; then fi AGENT_BIN="" -if command -v cursor-agent >/dev/null 2>&1; then - AGENT_BIN=cursor-agent -elif command -v agent >/dev/null 2>&1; then - AGENT_BIN=agent +if AGENT_BIN="$(bk_cursor_agent_cmd)"; then + : +else + echo "error: cursor-agent / agent not found on PATH (tried ~/.cursor/bin ~/.local/bin)" >&2 + exit 127 fi -[[ -n "$AGENT_BIN" ]] || { echo "error: cursor-agent / agent not found on PATH" >&2; exit 127; } "$AGENT_BIN" status >/dev/null 2>&1 || { echo "error: Cursor CLI not authenticated (set CURSOR_API_KEY or run: $AGENT_BIN login)" >&2; exit 1; } args=(--print --output-format "$output_format") diff --git a/scripts/buildkite/lib.sh b/scripts/buildkite/lib.sh index c21d5ff..e89fbe7 100755 --- a/scripts/buildkite/lib.sh +++ b/scripts/buildkite/lib.sh @@ -8,6 +8,27 @@ bk_require_cmd() { command -v "$1" >/dev/null 2>&1 || bk_die "$1 not found on PATH" } +# Cursor installer puts `agent` / `cursor-agent` under ~/.local/bin (and sometimes +# ~/.cursor/bin). Bootstrap runs as a subprocess, so every issue-agent entrypoint +# must re-export these dirs — otherwise delegate sees exit 127 after a successful +# install. +bk_export_cursor_path() { + export PATH="${HOME}/.cursor/bin:${HOME}/.local/bin:/usr/local/bin:${PATH:-}" +} + +# Resolve cursor-agent CLI name after PATH is set. Prints binary name or returns 1. +bk_cursor_agent_cmd() { + if command -v cursor-agent >/dev/null 2>&1; then + echo "cursor-agent" + return 0 + fi + if command -v agent >/dev/null 2>&1; then + echo "agent" + return 0 + fi + return 1 +} + bk_repo_root() { git rev-parse --show-toplevel 2>/dev/null || bk_die "not inside a git repository" } diff --git a/scripts/buildkite/run-issue-agent.sh b/scripts/buildkite/run-issue-agent.sh index 4ae242a..c1431d0 100755 --- a/scripts/buildkite/run-issue-agent.sh +++ b/scripts/buildkite/run-issue-agent.sh @@ -18,6 +18,7 @@ cd "$REPO_ROOT" # shellcheck source=lib.sh source "$SCRIPT_DIR/lib.sh" +bk_export_cursor_path TIMEOUT="${RADICLE_AGENT_TIMEOUT:-3600}" MODEL="${RADICLE_AGENT_MODEL:-}" @@ -65,6 +66,12 @@ if git show-ref --verify --quiet "refs/heads/$RADICLE_ISSUE_BRANCH"; then fi bash "$SCRIPT_DIR/bootstrap.sh" +# Bootstrap is a subprocess — re-apply Cursor + local bin PATH for delegate. +bk_export_cursor_path +if ! bk_cursor_agent_cmd >/dev/null; then + bk_die "cursor-agent / agent not found on PATH after bootstrap (PATH=$PATH)" +fi +echo "cursor-agent: $(command -v "$(bk_cursor_agent_cmd)")" if command -v buildkite-agent >/dev/null 2>&1; then buildkite-agent meta-data set "radicle_issue_id" "$RADICLE_ISSUE_ID" || true