mnemo_cards/mnemo_cards_web_v2/cursor_agent_loop.sh

67 lines
1.7 KiB
Bash
Raw Permalink Normal View History

2025-11-10 23:55:41 +00:00
#!/bin/bash
# Script to loop cursor-agent calls with a given prompt
# Usage: ./cursor_agent_loop.sh "your prompt here"
# Check if prompt is provided
if [ -z "$1" ]; then
echo "Usage: $0 \"your prompt here\""
echo "Example: $0 \"Analyze the code and suggest improvements\""
exit 1
fi
PROMPT="$1"
ITERATION=1
CURSOR_CMD=""
# Find which cursor command is available
if command -v cursor-agent &> /dev/null; then
CURSOR_CMD="cursor-agent"
elif command -v cursor &> /dev/null; then
CURSOR_CMD="cursor"
else
echo "Error: cursor-agent or cursor command not found"
echo "Please install Cursor CLI or ensure it's in your PATH"
exit 1
fi
echo "Starting cursor-agent loop with prompt:"
echo "$PROMPT"
echo ""
echo "Using command: $CURSOR_CMD"
echo "Press Ctrl+C to stop"
echo ""
# Main loop
while true; do
echo "========================================="
echo "Iteration $ITERATION"
echo "Starting at $(date '+%Y-%m-%d %H:%M:%S')"
echo "========================================="
# Call cursor with the prompt
if [ "$CURSOR_CMD" = "cursor-agent" ]; then
echo "Calling cursor-agent..."
cursor-agent "$PROMPT"
EXIT_CODE=$?
elif [ "$CURSOR_CMD" = "cursor" ]; then
echo "Calling cursor CLI..."
# Try different possible cursor CLI invocations
cursor agent "$PROMPT" 2>/dev/null || cursor -a "$PROMPT" 2>/dev/null || cursor "$PROMPT" 2>/dev/null
EXIT_CODE=$?
fi
if [ $EXIT_CODE -eq 0 ]; then
echo "✓ Agent completed successfully"
else
echo "✗ Agent exited with code: $EXIT_CODE"
fi
echo ""
echo "Waiting 5 seconds before next iteration..."
sleep 5
echo ""
((ITERATION++))
done