cursor path
This commit is contained in:
parent
5b3ff5b50e
commit
9e13a50e07
3 changed files with 119 additions and 2 deletions
|
|
@ -51,6 +51,16 @@ jobs:
|
|||
curl https://cursor.com/install -fsS | bash
|
||||
export PATH="$HOME/.cursor/bin:$PATH"
|
||||
echo "$HOME/.cursor/bin" >> $GITHUB_PATH
|
||||
# Verify installation
|
||||
if [ -f "$HOME/.cursor/bin/cursor-agent" ]; then
|
||||
echo "✅ Cursor CLI installed at $HOME/.cursor/bin/cursor-agent"
|
||||
chmod +x "$HOME/.cursor/bin/cursor-agent"
|
||||
"$HOME/.cursor/bin/cursor-agent" --version || echo "cursor-agent executable found but version check failed"
|
||||
else
|
||||
echo "❌ Cursor CLI not found at $HOME/.cursor/bin/cursor-agent"
|
||||
ls -la $HOME/.cursor/bin/ || echo "Directory $HOME/.cursor/bin/ does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
|
|
@ -83,7 +93,24 @@ jobs:
|
|||
MAX_ITERATIONS: 10
|
||||
MAX_RETRIES: 3
|
||||
TIMEOUT_HOURS: 6
|
||||
PATH: ${{ env.PATH }}:$HOME/.cursor/bin
|
||||
run: |
|
||||
# Ensure cursor-agent is in PATH for this step
|
||||
export PATH="$HOME/.cursor/bin:$PATH"
|
||||
|
||||
# Verify cursor-agent is accessible
|
||||
if ! command -v cursor-agent &> /dev/null; then
|
||||
echo "❌ cursor-agent not found in PATH"
|
||||
echo "PATH: $PATH"
|
||||
echo "Trying full path..."
|
||||
if [ -f "$HOME/.cursor/bin/cursor-agent" ]; then
|
||||
export PATH="$HOME/.cursor/bin:$PATH"
|
||||
else
|
||||
echo "❌ cursor-agent not found at $HOME/.cursor/bin/cursor-agent"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cd ${{ github.workspace }}
|
||||
python3 tools/agent/agent_orchestrator.py ${{ inputs.component }}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,16 @@ jobs:
|
|||
curl https://cursor.com/install -fsS | bash
|
||||
export PATH="$HOME/.cursor/bin:$PATH"
|
||||
echo "$HOME/.cursor/bin" >> $GITHUB_PATH
|
||||
# Verify installation
|
||||
if [ -f "$HOME/.cursor/bin/cursor-agent" ]; then
|
||||
echo "✅ Cursor CLI installed at $HOME/.cursor/bin/cursor-agent"
|
||||
chmod +x "$HOME/.cursor/bin/cursor-agent"
|
||||
"$HOME/.cursor/bin/cursor-agent" --version || echo "cursor-agent executable found but version check failed"
|
||||
else
|
||||
echo "❌ Cursor CLI not found at $HOME/.cursor/bin/cursor-agent"
|
||||
ls -la $HOME/.cursor/bin/ || echo "Directory $HOME/.cursor/bin/ does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
|
|
@ -47,7 +57,25 @@ jobs:
|
|||
CURSOR_MODEL: ${{ secrets.CURSOR_MODEL }}
|
||||
PROJECT_ROOT: ${{ github.workspace }}
|
||||
MAX_ITERATIONS: 10
|
||||
PATH: ${{ env.PATH }}:$HOME/.cursor/bin
|
||||
run: |
|
||||
# Ensure cursor-agent is in PATH for this step
|
||||
export PATH="$HOME/.cursor/bin:$PATH"
|
||||
|
||||
# Verify cursor-agent is accessible
|
||||
if ! command -v cursor-agent &> /dev/null; then
|
||||
echo "❌ cursor-agent not found in PATH"
|
||||
echo "PATH: $PATH"
|
||||
echo "Trying full path..."
|
||||
if [ -f "$HOME/.cursor/bin/cursor-agent" ]; then
|
||||
export PATH="$HOME/.cursor/bin:$PATH"
|
||||
alias cursor-agent="$HOME/.cursor/bin/cursor-agent"
|
||||
else
|
||||
echo "❌ cursor-agent not found at $HOME/.cursor/bin/cursor-agent"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cd ${{ github.workspace }}
|
||||
python3 tools/agent/planning_agent.py ${{ inputs.component }}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
Cursor CLI wrapper with stream-json parsing and progress tracking.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
|
@ -43,6 +45,38 @@ class CursorCLI:
|
|||
self.api_key = api_key
|
||||
self.model = model
|
||||
self.verbose = verbose
|
||||
self.cursor_agent_path = self._find_cursor_agent()
|
||||
|
||||
def _find_cursor_agent(self) -> str:
|
||||
"""Find cursor-agent executable."""
|
||||
# Try to find in PATH first
|
||||
cursor_agent = shutil.which("cursor-agent")
|
||||
if cursor_agent:
|
||||
return cursor_agent
|
||||
|
||||
# Try common installation locations
|
||||
home = os.path.expanduser("~")
|
||||
possible_paths = [
|
||||
os.path.join(home, ".cursor", "bin", "cursor-agent"),
|
||||
"/usr/local/bin/cursor-agent",
|
||||
"/usr/bin/cursor-agent",
|
||||
os.path.join(home, ".local", "bin", "cursor-agent"),
|
||||
]
|
||||
|
||||
for path in possible_paths:
|
||||
if os.path.isfile(path) and os.access(path, os.X_OK):
|
||||
if self.verbose:
|
||||
print(f"✅ Found cursor-agent at: {path}")
|
||||
return path
|
||||
|
||||
# If not found, return "cursor-agent" and let it fail with a clear error
|
||||
if self.verbose:
|
||||
print("⚠️ cursor-agent not found in PATH or common locations")
|
||||
print(f" PATH: {os.environ.get('PATH', 'not set')}")
|
||||
print(f" Home: {home}")
|
||||
print(" Trying 'cursor-agent' anyway...")
|
||||
|
||||
return "cursor-agent"
|
||||
|
||||
def run_agent(self,
|
||||
task_description: str,
|
||||
|
|
@ -61,9 +95,9 @@ class CursorCLI:
|
|||
Returns:
|
||||
CursorResult with execution details
|
||||
"""
|
||||
# Build command
|
||||
# Build command using found path
|
||||
cmd = [
|
||||
"cursor-agent",
|
||||
self.cursor_agent_path,
|
||||
"-p", # Print mode (non-interactive)
|
||||
"--output-format", "stream-json",
|
||||
"--stream-partial-output",
|
||||
|
|
@ -84,6 +118,34 @@ class CursorCLI:
|
|||
if self.verbose:
|
||||
print(f"🚀 Running cursor-agent in {self.project_root}")
|
||||
print(f"📝 Task: {task_description[:100]}...")
|
||||
print(f"🔧 Using cursor-agent at: {self.cursor_agent_path}")
|
||||
|
||||
# Verify cursor-agent exists
|
||||
if self.cursor_agent_path == "cursor-agent":
|
||||
# Try one more time to find it
|
||||
cursor_agent = shutil.which("cursor-agent")
|
||||
if not cursor_agent:
|
||||
error_msg = (
|
||||
f"❌ cursor-agent not found!\n"
|
||||
f" Please ensure Cursor CLI is installed.\n"
|
||||
f" Installation: curl https://cursor.com/install -fsS | bash\n"
|
||||
f" Expected location: $HOME/.cursor/bin/cursor-agent\n"
|
||||
f" Current PATH: {os.environ.get('PATH', 'not set')}\n"
|
||||
f" Current HOME: {os.environ.get('HOME', 'not set')}"
|
||||
)
|
||||
return CursorResult(
|
||||
status=CursorResultStatus.ERROR,
|
||||
output="",
|
||||
error=error_msg,
|
||||
duration_ms=None,
|
||||
files_modified=[],
|
||||
files_created=[],
|
||||
files_read=[],
|
||||
tool_calls=0
|
||||
)
|
||||
self.cursor_agent_path = cursor_agent
|
||||
if self.verbose:
|
||||
print(f"✅ Found cursor-agent at: {self.cursor_agent_path}")
|
||||
|
||||
# Track execution metrics
|
||||
accumulated_text = ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue