Skip to content

About

A LinkedIn project suggested by Jepson to convert SMS messages into Cursor Agent tasks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SMS to Cursor Automation System

A Python-based automation system that allows you to send commands to the Cursor IDE via SMS using Google Voice's email-to-SMS gateway. Send coding requests from your phone and receive automated responses back via SMS.

🏗️ System Architecture

The complete workflow: Phone SMS → Google Voice Gateway → Email → Local Machine → Cursor IDE → File Output → Email → Google Voice Gateway → Phone SMS

Component Overview

  • Email Handler: Monitors Gmail inbox for Google Voice SMS notifications
  • Cursor Automation: Controls Cursor IDE using pyautogui and AppleScript
  • File Watcher: Monitors for output files created by Cursor's AI agent
  • Orchestrator: Coordinates all components and handles the complete workflow

📋 Prerequisites

  • macOS (required for AppleScript-based Cursor automation)
  • Python 3.7+
  • Cursor IDE installed and accessible
  • Google Voice account set up with SMS forwarding to email
  • Gmail account with App Password authentication
  • Active internet connection

🚀 Installation

1. Clone the Repository

git clone <repository-url>
cd sms-2-cursor

2. Create Virtual Environment

python3 -m venv venv
source venv/bin/activate  # On macOS/Linux

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment Variables

cp .env.example .env

Edit .env with your specific configuration:

# Gmail Configuration (use a dedicated account)
EMAIL_ADDRESS=your-dedicated-email@gmail.com
EMAIL_PASSWORD=your-gmail-app-password
IMAP_SERVER=imap.gmail.com
SMTP_SERVER=smtp.gmail.com

# Google Voice Configuration
PHONE_NUMBER=1234567890
GOOGLE_VOICE_EMAIL=txt.voice.google.com

# Cursor IDE Configuration  
CURSOR_SHORTCUT=cmd+i
OUTPUT_DIRECTORY=/absolute/path/to/your/cursor/project

# Optional: Timing Configuration
POLL_INTERVAL=2
FILE_WATCH_TIMEOUT=300

⚙️ Detailed Setup Instructions

Gmail Setup

  1. Create a dedicated Gmail account (recommended for security)
  2. Enable 2-Factor Authentication:
    • Go to Google Account settings
    • Security → 2-Step Verification → Turn On
  3. Generate App Password:
    • Security → 2-Step Verification → App passwords
    • Select "Mail" and generate password
    • Use this App Password (not your regular password) in .env

Google Voice Setup

  1. Set up Google Voice account at voice.google.com
  2. Configure SMS forwarding:
    • Settings → Messages
    • Enable "Get email notifications"
    • Enable "Forward messages to email"
    • Set forwarding address to your dedicated Gmail account
  3. Verify SMS forwarding by sending a test message to your Google Voice number

Cursor IDE Setup

  1. Install Cursor IDE from cursor.sh
  2. Open your project in Cursor
  3. Verify hotkey: Ensure Cmd+I opens the AI agent panel (or configure different shortcut in .env)
  4. Test automation: Make sure Cursor is responsive and the agent panel opens properly

Project Directory Setup

  1. Create project directory if it doesn't exist
  2. Set absolute path in OUTPUT_DIRECTORY environment variable
  3. Ensure write permissions for the automation system
  4. Test file creation by manually creating a test file in the directory

🎯 Usage

Starting the System

# Activate virtual environment
source venv/bin/activate

# Start the orchestrator
python main.py

You should see output similar to:

2024-01-20 10:30:15 - __main__ - INFO - Starting SMS to Cursor orchestrator...
2024-01-20 10:30:15 - __main__ - INFO - Monitoring SMS from: txt.voice.google.com
2024-01-20 10:30:15 - __main__ - INFO - Output directory: /path/to/your/project

Sending Commands

  1. Send SMS to your Google Voice number from your regular phone

  2. Include coding requests like:

    • "Add error handling to the login function"
    • "Create a new React component for user profile"
    • "Fix the bug in the payment processing module"
    • "Add TypeScript types to the API endpoints"
  3. Wait for response (typically 30-60 seconds depending on complexity)

Example SMS Workflows

Simple request:

SMS: "Add console.log statements to debug the user authentication flow"
Response: "Added 3 console.log statements in auth.js for debugging user login, token validation, and session creation."

Complex request:

SMS: "Create a new React hook for managing user preferences with localStorage persistence"
Response: "Created useUserPreferences hook in hooks/useUserPreferences.js with get/set methods, localStorage sync, and TypeScript types."

🔧 Configuration Options

Environment Variables

Variable Required Default Description
EMAIL_ADDRESS ✅ - Gmail address for SMS gateway
EMAIL_PASSWORD ✅ - Gmail App Password
PHONE_NUMBER ✅ - Your 10-digit phone number
GOOGLE_VOICE_EMAIL ✅ txt.voice.google.com Google Voice email domain
OUTPUT_DIRECTORY ✅ - Absolute path to Cursor project
CURSOR_SHORTCUT ❌ cmd+i Hotkey to open Cursor agent panel
POLL_INTERVAL ❌ 2 Email check interval (seconds)
FILE_WATCH_TIMEOUT ❌ 300 Max wait time for Cursor response (seconds)
IMAP_SERVER ❌ imap.gmail.com IMAP server for email
SMTP_SERVER ❌ smtp.gmail.com SMTP server for email

Logging Configuration

Logs are written to both console and sms2cursor.log file with the following levels:

  • INFO: Normal operation, SMS received/sent
  • DEBUG: Detailed automation steps
  • ERROR: Failed operations, connection issues
  • WARNING: Recoverable issues, timeouts

🛠️ How It Works

1. Email Monitoring

  • Continuously polls Gmail IMAP for new messages from txt.voice.google.com
  • Filters messages by your phone number for security
  • Extracts SMS content from Google Voice email format
  • Tracks processed emails to avoid duplicates

2. Cursor Automation

  • Uses AppleScript to activate and focus Cursor IDE
  • Detects if agent panel is already open using multiple methods
  • Sends enhanced prompts that include file output instructions
  • Handles various UI states and error conditions

3. File Watching

  • Monitors project directory for output files created by Cursor
  • Waits for file content to stabilize before reading
  • Implements timeout handling for non-responsive requests
  • Cleans up temporary files after processing

4. Response Handling

  • Truncates responses to manageable SMS length (with smart truncation)
  • Sends replies via SMTP to Google Voice email gateway
  • Maintains email threading for proper conversation flow
  • Includes error handling and retry logic

🚨 Important Considerations

Security

  • Use dedicated Gmail account to isolate SMS automation
  • Phone number filtering prevents unauthorized access
  • App Passwords provide secure authentication without exposing main password
  • No sensitive data should be included in SMS commands

Reliability

  • Keep machine running and logged in during operation
  • Cursor IDE must remain accessible and responsive
  • Stable internet connection required for email polling
  • macOS focus/activation may require user interaction permissions

Limitations

  • SMS character limits - responses truncated to ~10,000 characters
  • Processing time - complex requests may take 60+ seconds
  • macOS only - pyautogui + AppleScript combination requires macOS
  • Single session - one SMS request processed at a time

🐛 Troubleshooting

Common Issues

"Configuration error: Missing required configuration"

  • Verify all required fields in .env are filled
  • Check for typos in environment variable names
  • Ensure no extra spaces or quotes around values

"IMAP connection failed"

  • Verify Gmail App Password is correct
  • Check if 2FA is enabled on Gmail account
  • Ensure Gmail account allows "Less secure app access" or use App Password

"Cursor application not found"

  • Make sure Cursor IDE is installed and in Applications folder
  • Verify Cursor is not renamed or in custom location
  • Check macOS permissions for automation/accessibility

"Timeout waiting for output file"

  • Increase FILE_WATCH_TIMEOUT in configuration
  • Check if Cursor agent is responding to prompts
  • Verify OUTPUT_DIRECTORY path is correct and writable

"No new SMS emails found"

  • Test Google Voice SMS forwarding to email
  • Check Gmail spam/promotions folders
  • Verify phone number format (10 digits, no dashes)

Debug Mode

Enable debug logging by modifying utils.py:

logging.basicConfig(level=logging.DEBUG, ...)

Manual Testing

Test individual components:

# Test email connection
python -c "from email_handler import EmailHandler; from config import Config; eh = EmailHandler(Config()); print('IMAP:', eh.connect_imap()); print('SMTP:', eh.connect_smtp())"

# Test Cursor activation
python -c "from cursor_automation import CursorAutomation; from config import Config; ca = CursorAutomation(Config()); print('Cursor activated:', ca.activate_cursor())"

📈 Performance Tips

  • Reduce POLL_INTERVAL for faster SMS response (but higher resource usage)
  • Use SSD storage for faster file operations
  • Close unnecessary applications to ensure Cursor gets focus reliably
  • Optimize Cursor agent by keeping relevant files open and context clear

🔄 Maintenance

Regular Tasks

  • Monitor log files for errors or unusual patterns
  • Update dependencies periodically with pip install -r requirements.txt --upgrade
  • Clean old log files to prevent disk space issues
  • Test email connectivity if experiencing delivery issues

Updates

  • Check Cursor IDE updates that might change UI or hotkeys
  • Monitor Google Voice changes that could affect email formatting
  • Update Python dependencies for security patches

📜 License

This project is provided as-is for educational and personal use. Please ensure compliance with Terms of Service for Google Voice, Gmail, and Cursor IDE when using this automation system.

🤝 Contributing

For bugs, feature requests, or improvements:

  1. Check existing issues and logs for similar problems
  2. Test with minimal configuration to isolate issues
  3. Include relevant log snippets and configuration (with sensitive data removed)
  4. Describe expected vs actual behavior clearly

⚠️ Disclaimer: This automation system requires careful setup and monitoring. Always test thoroughly in a development environment before using with important projects. The authors are not responsible for any data loss, system issues, or service violations that may result from using this software.

About

A LinkedIn project suggested by Jepson to convert SMS messages into Cursor Agent tasks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages