diff --git a/cursor-hooks/QUICKSTART.md b/cursor-hooks/QUICKSTART.md index db36c4eb..26661890 100644 --- a/cursor-hooks/QUICKSTART.md +++ b/cursor-hooks/QUICKSTART.md @@ -3,9 +3,15 @@ ## What This Does Connects claude-mem to Cursor so that: -- ✅ Agent actions (MCP tools, shell commands, file edits) are automatically saved -- ✅ Context from past sessions is automatically injected via `.cursor/rules/` -- ✅ Sessions are summarized for future reference +- Agent actions (MCP tools, shell commands, file edits) are automatically saved +- Context from past sessions is automatically injected via `.cursor/rules/` +- Sessions are summarized for future reference + +## Don't Have Claude Code? + +If you're using Cursor without Claude Code, see [STANDALONE-SETUP.md](STANDALONE-SETUP.md) for setup with free-tier providers like Gemini or OpenRouter. + +--- ## Installation (1 minute) @@ -20,6 +26,24 @@ claude-mem cursor install user claude-mem cursor status ``` +## Configure Provider (Required for Standalone) + +If you don't have Claude Code, configure a provider for AI summarization: + +```bash +# Option A: Gemini (free tier available - recommended) +claude-mem settings set CLAUDE_MEM_PROVIDER gemini +claude-mem settings set CLAUDE_MEM_GEMINI_API_KEY your-api-key + +# Option B: OpenRouter (free models available) +claude-mem settings set CLAUDE_MEM_PROVIDER openrouter +claude-mem settings set CLAUDE_MEM_OPENROUTER_API_KEY your-api-key +``` + +**Get free API keys**: +- Gemini: https://aistudio.google.com/apikey +- OpenRouter: https://openrouter.ai/keys + ## Start Worker ```bash diff --git a/cursor-hooks/README.md b/cursor-hooks/README.md index 6dea21eb..68c5cdc1 100644 --- a/cursor-hooks/README.md +++ b/cursor-hooks/README.md @@ -2,6 +2,14 @@ This directory contains Cursor hooks that connect claude-mem to Cursor, enabling persistent memory across Cursor sessions. +## Quick Start for Cursor Users + +**Using Claude Code?** Skip to [Installation](#installation) - everything works automatically. + +**Cursor-only (no Claude Code)?** See [STANDALONE-SETUP.md](STANDALONE-SETUP.md) for free-tier options using Gemini or OpenRouter. + +--- + ## Overview The hooks bridge Cursor's hook system to claude-mem's worker API, allowing: @@ -172,8 +180,7 @@ Install on Ubuntu: `apt-get install jq curl` 3. Restart worker: ```bash - cd ~/.claude/plugins/marketplaces/thedotmack - npm run worker:restart + claude-mem restart ``` ### Observations not being saved diff --git a/cursor-hooks/STANDALONE-SETUP.md b/cursor-hooks/STANDALONE-SETUP.md new file mode 100644 index 00000000..3cabf255 --- /dev/null +++ b/cursor-hooks/STANDALONE-SETUP.md @@ -0,0 +1,193 @@ +# Claude-Mem for Cursor (No Claude Code Required) + +## Overview + +Use claude-mem's persistent memory in Cursor without a Claude Code subscription. Choose between free-tier providers (Gemini, OpenRouter) or paid options. + +**What You Get**: +- AI memory that persists across Cursor sessions +- Automatic capture of MCP tools, shell commands, and file edits +- Context injection via `.cursor/rules/` for every chat +- Web viewer at http://localhost:37777 + +## Prerequisites + +- Cursor IDE +- Node.js 18+ +- Git +- `jq` and `curl`: + - **macOS**: `brew install jq curl` + - **Linux**: `apt install jq curl` + +## Step 1: Clone Claude-Mem + +```bash +# Clone the repository +git clone https://github.com/thedotmack/claude-mem.git +cd claude-mem + +# Install dependencies +npm install + +# Build the project +npm run build +``` + +## Step 2: Configure Provider (Choose One) + +Since you don't have Claude Code, you need to configure an AI provider for claude-mem's summarization engine. + +### Option A: Gemini (Recommended - Free Tier) + +Gemini offers 1500 free requests per day, plenty for typical usage. + +```bash +# Create settings directory +mkdir -p ~/.claude-mem + +# Create settings file +cat > ~/.claude-mem/settings.json << 'EOF' +{ + "CLAUDE_MEM_PROVIDER": "gemini", + "CLAUDE_MEM_GEMINI_API_KEY": "YOUR_GEMINI_API_KEY", + "CLAUDE_MEM_GEMINI_MODEL": "gemini-2.5-flash-lite", + "CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED": true +} +EOF +``` + +**Get your free API key**: https://aistudio.google.com/apikey + +### Option B: OpenRouter (100+ Models) + +OpenRouter provides access to many models, including free options. + +```bash +mkdir -p ~/.claude-mem +cat > ~/.claude-mem/settings.json << 'EOF' +{ + "CLAUDE_MEM_PROVIDER": "openrouter", + "CLAUDE_MEM_OPENROUTER_API_KEY": "YOUR_OPENROUTER_API_KEY" +} +EOF +``` + +**Get your API key**: https://openrouter.ai/keys + +**Free models available**: +- `google/gemini-2.0-flash-exp:free` +- `xiaomi/mimo-v2-flash:free` + +### Option C: Claude API (If You Have API Access) + +If you have Anthropic API credits but not a Claude Code subscription: + +```bash +mkdir -p ~/.claude-mem +cat > ~/.claude-mem/settings.json << 'EOF' +{ + "CLAUDE_MEM_PROVIDER": "claude", + "ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY" +} +EOF +``` + +## Step 3: Install Cursor Hooks + +```bash +# From the claude-mem repo directory +npm run cursor:install + +# Or for user-level (all projects): +npm run cursor:install -- user +``` + +This installs: +- Hook scripts to `.cursor/hooks/` +- Hook configuration to `.cursor/hooks.json` +- Context template to `.cursor/rules/` + +## Step 4: Start the Worker + +```bash +npm run worker:start +``` + +The worker runs in the background and handles: +- Session management +- Observation processing +- AI-powered summarization +- Context file updates + +## Step 5: Restart Cursor & Verify + +1. **Restart Cursor IDE** to load the new hooks + +2. **Check installation status**: + ```bash + npm run cursor:status + ``` + +3. **Verify the worker is running**: + ```bash + curl http://127.0.0.1:37777/api/readiness + ``` + Should return: `{"status":"ready"}` + +4. **Open the web viewer**: http://localhost:37777 + +## How It Works + +1. **Before each prompt**: Hooks initialize a session and ensure the worker is running +2. **During agent work**: MCP tools, shell commands, and file edits are captured +3. **When agent stops**: Summary is generated and context file is updated +4. **Next session**: Fresh context is automatically injected via `.cursor/rules/` + +## Troubleshooting + +### "No provider configured" error + +Verify your settings file exists and has valid credentials: +```bash +cat ~/.claude-mem/settings.json +``` + +### Worker not starting + +Check logs: +```bash +tail -f ~/.claude-mem/logs/worker-$(date +%Y-%m-%d).log +``` + +### Hooks not executing + +1. Check Cursor Settings → Hooks tab for errors +2. Verify scripts are executable: + ```bash + chmod +x ~/.cursor/hooks/*.sh + ``` +3. Check the Hooks output channel in Cursor + +### Rate limiting (Gemini free tier) + +If you hit the 1500 requests/day limit: +- Wait until the next day +- Upgrade to a paid plan +- Switch to OpenRouter with a paid model + +## Next Steps + +- Read [README.md](README.md) for detailed hook documentation +- Check [CONTEXT-INJECTION.md](CONTEXT-INJECTION.md) for context behavior details +- Visit https://docs.claude-mem.ai for full documentation + +## Quick Reference + +| Command | Purpose | +|---------|---------| +| `npm run cursor:install` | Install hooks for current project | +| `npm run cursor:install -- user` | Install hooks for all projects | +| `npm run cursor:status` | Check installation status | +| `npm run worker:start` | Start the background worker | +| `npm run worker:stop` | Stop the background worker | +| `npm run worker:restart` | Restart the worker |