@joseairosa/recall 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,612 @@
1
+ # Recall 🧠
2
+
3
+ **Give Claude perfect recall with persistent memory that survives context limits and session restarts.**
4
+
5
+ Your AI assistant can now remember important context, decisions, and patterns across all conversationsβ€”no more repeating yourself or losing critical information when the context window fills up.
6
+
7
+ ---
8
+
9
+ ## What is This?
10
+
11
+ Recall is a **brain extension** for Claude that stores memories in Redis. It solves the context window problem by:
12
+
13
+ - πŸ“ **Remembering** directives, decisions, code patterns, and important information
14
+ - πŸ” **Retrieving** relevant context automatically when you need it
15
+ - πŸ”„ **Persisting** across sessions - memories survive restarts and context compaction
16
+ - πŸ—‚οΈ **Organizing** by workspace - Project A memories don't pollute Project B
17
+
18
+ ---
19
+
20
+ ## Quick Start (5 Minutes)
21
+
22
+ ### 1. Prerequisites
23
+
24
+ - **Redis** running locally (default: `localhost:6379`)
25
+ - **Node.js** 18 or higher
26
+ - **Claude Code** or **Claude Desktop**
27
+
28
+ **Option 1: Local Redis (Recommended for getting started)**
29
+ ```bash
30
+ # macOS
31
+ brew install redis
32
+ brew services start redis
33
+
34
+ # Ubuntu/Debian
35
+ sudo apt-get install redis-server
36
+ sudo systemctl start redis
37
+
38
+ # Docker
39
+ docker run -d -p 6379:6379 redis:latest
40
+ ```
41
+
42
+ **Option 2: Cloud Redis (No local install needed)**
43
+
44
+ Use a free Redis cloud service:
45
+ - **[Upstash](https://upstash.com/)** - Free tier with 10,000 commands/day
46
+ - **[Redis Cloud](https://redis.com/try-free/)** - Free 30MB database
47
+ - **[Railway](https://railway.app/)** - Free Redis with credit
48
+
49
+ Then use the provided connection URL in your config:
50
+ ```json
51
+ {
52
+ "env": {
53
+ "REDIS_URL": "rediss://default:password@your-redis-host.com:6379"
54
+ }
55
+ }
56
+ ```
57
+
58
+ ### 2. Install
59
+
60
+ ```bash
61
+ npm install -g @joseairosa/recall
62
+ ```
63
+
64
+ Or from source:
65
+ ```bash
66
+ git clone <repo-url>
67
+ cd mem
68
+ npm install
69
+ npm run build
70
+ ```
71
+
72
+ ### 3. Configure Claude
73
+
74
+ Add to your Claude configuration file:
75
+
76
+ **Claude Code** (`~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`):
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "recall": {
81
+ "command": "recall",
82
+ "env": {
83
+ "REDIS_URL": "redis://localhost:6379",
84
+ "ANTHROPIC_API_KEY": "your-api-key-here"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ **Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "recall": {
96
+ "command": "npx",
97
+ "args": ["-y", "@joseairosa/recall"],
98
+ "env": {
99
+ "REDIS_URL": "redis://localhost:6379",
100
+ "ANTHROPIC_API_KEY": "your-api-key-here"
101
+ }
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ ### 4. Restart Claude
108
+
109
+ Restart Claude Code or Claude Desktop to load the MCP server.
110
+
111
+ ### 5. Test It!
112
+
113
+ Ask Claude:
114
+ ```
115
+ "Store a memory that I prefer using TypeScript for all new projects"
116
+ ```
117
+
118
+ Then in a new conversation:
119
+ ```
120
+ "What do you know about my coding preferences?"
121
+ ```
122
+
123
+ ✨ **It remembers!**
124
+
125
+ ---
126
+
127
+ ## How to Use
128
+
129
+ ### Store Important Information
130
+
131
+ Claude can automatically extract and store memories, or you can be explicit:
132
+
133
+ **Natural language:**
134
+ ```
135
+ "Remember that our API base URL is https://api.example.com/v2"
136
+ ```
137
+
138
+ ```
139
+ "Store this as a directive: Always use functional components in React"
140
+ ```
141
+
142
+ **What Claude does:** Uses the `store_memory` tool to save this information with appropriate context type and importance.
143
+
144
+ ### Recall Context
145
+
146
+ Claude automatically retrieves relevant memories, but you can also ask:
147
+
148
+ ```
149
+ "What do you remember about our database schema?"
150
+ ```
151
+
152
+ ```
153
+ "Recall any decisions we made about error handling"
154
+ ```
155
+
156
+ **What Claude does:** Uses `recall_relevant_context` or `search_memories` to find related information.
157
+
158
+ ### Analyze Conversations
159
+
160
+ Before context compaction, preserve important details:
161
+
162
+ ```
163
+ "Analyze our conversation and remember the important parts"
164
+ ```
165
+
166
+ **What Claude does:** Uses `analyze_and_remember` to extract structured memories from the conversation.
167
+
168
+ ### Organize Sessions
169
+
170
+ Group related work:
171
+
172
+ ```
173
+ "Summarize this session and save it as 'Authentication Refactoring'"
174
+ ```
175
+
176
+ **What Claude does:** Uses `summarize_session` to create a session snapshot with all relevant memories.
177
+
178
+ ---
179
+
180
+ ## Memory Types
181
+
182
+ Memories are categorized for better organization:
183
+
184
+ | Type | Purpose | Example |
185
+ |------|---------|---------|
186
+ | **`directive`** | Rules, guidelines, preferences | "Always use TypeScript strict mode" |
187
+ | **`decision`** | Important choices and rationale | "Chose PostgreSQL over MongoDB for ACID" |
188
+ | **`code_pattern`** | Reusable code patterns | "Use async/await, not .then()" |
189
+ | **`requirement`** | Feature requirements | "Must support 10k concurrent users" |
190
+ | **`information`** | General facts and context | "API endpoint is /api/v2/users" |
191
+ | **`heading`** | Project structure markers | "Authentication Module" |
192
+ | **`error`** | Known issues and solutions | "CORS fixed by adding headers" |
193
+ | **`todo`** | Tasks and reminders | "Add rate limiting to API" |
194
+ | **`insight`** | Learnings and observations | "Bottleneck is in database indexes" |
195
+ | **`preference`** | Personal or team preferences | "Prefer concise communication" |
196
+
197
+ ---
198
+
199
+ ## Available Tools (13)
200
+
201
+ Claude has access to these memory tools:
202
+
203
+ ### Core Memory
204
+ - **`store_memory`** - Store a single memory
205
+ - **`store_batch_memories`** - Store multiple memories at once
206
+ - **`update_memory`** - Update existing memory
207
+ - **`delete_memory`** - Remove a memory
208
+ - **`search_memories`** - Search using semantic similarity
209
+ - **`organize_session`** - Create session groups
210
+
211
+ ### Smart Context (v1.1+)
212
+ - **`recall_relevant_context`** - Proactively retrieve relevant memories
213
+ - **`analyze_and_remember`** - Extract and store memories from conversation
214
+ - **`summarize_session`** - Create session snapshot
215
+
216
+ ### Advanced (v1.2+)
217
+ - **`export_memories`** - Backup to JSON
218
+ - **`import_memories`** - Restore from JSON
219
+ - **`find_duplicates`** - Detect similar memories
220
+ - **`consolidate_memories`** - Merge multiple memories
221
+
222
+ ---
223
+
224
+ ## Available Resources (9)
225
+
226
+ Browse memories directly using MCP resources:
227
+
228
+ - **`memory://recent`** - Recent memories (default 50)
229
+ - **`memory://by-type/{type}`** - Filter by context type
230
+ - **`memory://by-tag/{tag}`** - Filter by tag
231
+ - **`memory://important`** - High importance (β‰₯8)
232
+ - **`memory://sessions`** - All sessions
233
+ - **`memory://session/{id}`** - Specific session
234
+ - **`memory://summary`** - Statistics overview
235
+ - **`memory://search?q=query`** - Semantic search
236
+ - **`memory://analytics`** - Usage analytics dashboard (v1.2+)
237
+
238
+ ---
239
+
240
+ ## Workspace Isolation
241
+
242
+ Memories are **automatically isolated by directory**. Working in different projects? No problem:
243
+
244
+ ```
245
+ /Users/you/project-a/ β†’ Workspace A memories
246
+ /Users/you/project-b/ β†’ Workspace B memories
247
+ ```
248
+
249
+ Memories from Project A **never pollute** Project B. Each workspace gets its own isolated memory space.
250
+
251
+ ### Using Remote Redis
252
+
253
+ Want to:
254
+ - **Share memories across machines**? Use cloud Redis with the same `REDIS_URL`
255
+ - **No local install**? Use Upstash, Redis Cloud, or Railway (free tiers available)
256
+ - **Team collaboration**? Share Redis URL and workspace path with your team
257
+
258
+ See [Configuration](#configuration) section for cloud Redis setup.
259
+
260
+ ### Future: Global Memories
261
+
262
+ Coming in v1.3.0: Support for **global memories** that work across all workspaces (e.g., personal preferences, team conventions). See [WORKSPACE_MODES.md](WORKSPACE_MODES.md) for details.
263
+
264
+ ---
265
+
266
+ ## Advanced Features (v1.2)
267
+
268
+ ### TTL (Temporary Memories)
269
+
270
+ Store memories that auto-expire:
271
+
272
+ ```
273
+ "Remember for the next hour: API is in maintenance mode"
274
+ ```
275
+
276
+ Claude will add `ttl_seconds: 3600` and Redis automatically removes it after 1 hour.
277
+
278
+ **Use cases:**
279
+ - Temporary debugging notes
280
+ - Session-specific context
281
+ - Time-sensitive reminders
282
+
283
+ ### Export/Import
284
+
285
+ **Backup your memories:**
286
+ ```
287
+ "Export all important memories to JSON"
288
+ ```
289
+
290
+ **Restore or migrate:**
291
+ ```
292
+ "Import these memories: [paste JSON]"
293
+ ```
294
+
295
+ **Use cases:**
296
+ - Regular backups
297
+ - Move memories between workspaces
298
+ - Share knowledge bases with team
299
+ - Archive old projects
300
+
301
+ ### Duplicate Detection
302
+
303
+ **Find similar memories:**
304
+ ```
305
+ "Find duplicate memories with similarity above 90%"
306
+ ```
307
+
308
+ **Auto-merge duplicates:**
309
+ ```
310
+ "Find and merge duplicate memories automatically"
311
+ ```
312
+
313
+ **Use cases:**
314
+ - Clean up redundant memories
315
+ - Consolidate related information
316
+ - Optimize memory storage
317
+
318
+ ### Analytics Dashboard
319
+
320
+ **See usage patterns:**
321
+ ```
322
+ "Show me memory analytics"
323
+ ```
324
+
325
+ Get insights on:
326
+ - Memory trends (24h, 7d, 30d)
327
+ - Most active types
328
+ - Top tags
329
+ - Importance distribution
330
+ - Daily activity breakdown
331
+
332
+ ---
333
+
334
+ ## Examples
335
+
336
+ ### Example 1: Project Setup
337
+ ```
338
+ You: "Remember: This project uses Prisma for database, tRPC for API, and Next.js for frontend"
339
+
340
+ Claude: [Stores 3 memories with type 'code_pattern']
341
+ βœ“ Stored: Prisma for database (importance: 8)
342
+ βœ“ Stored: tRPC for API (importance: 8)
343
+ βœ“ Stored: Next.js for frontend (importance: 8)
344
+
345
+ You (later): "What's our tech stack?"
346
+
347
+ Claude: [Retrieves memories]
348
+ "Your project uses:
349
+ - Prisma for database
350
+ - tRPC for API
351
+ - Next.js for frontend"
352
+ ```
353
+
354
+ ### Example 2: Code Patterns
355
+ ```
356
+ You: "Store this error handling pattern we use:
357
+ try { ... } catch (error) { logger.error(...); throw new AppError(...) }"
358
+
359
+ Claude: [Stores as 'code_pattern', importance: 9]
360
+ βœ“ Stored: Standard error handling pattern
361
+
362
+ You (in new file): "Add error handling here"
363
+
364
+ Claude: [Recalls pattern]
365
+ "I'll use your standard error handling pattern with logger and AppError..."
366
+ ```
367
+
368
+ ### Example 3: Session Organization
369
+ ```
370
+ You: "We just finished refactoring auth. Summarize and save this session."
371
+
372
+ Claude: [Creates session with all relevant memories]
373
+ βœ“ Session created: "Auth Refactoring - 2025-01-15"
374
+ βœ“ 8 memories captured
375
+ βœ“ Summary: Refactored authentication to use JWT with refresh tokens
376
+
377
+ You (weeks later): "What did we change in the auth refactoring?"
378
+
379
+ Claude: [Retrieves session memories]
380
+ "In the auth refactoring session, you:
381
+ - Switched from sessions to JWT tokens
382
+ - Added refresh token rotation
383
+ - Implemented secure cookie storage
384
+ - Updated middleware for new auth flow"
385
+ ```
386
+
387
+ ---
388
+
389
+ ## Configuration
390
+
391
+ ### Environment Variables
392
+
393
+ - **`REDIS_URL`** - Redis connection (default: `redis://localhost:6379`)
394
+ - **`ANTHROPIC_API_KEY`** - Claude API key for analysis and embeddings
395
+
396
+ ### Redis Setup Options
397
+
398
+ **Local Redis (default):**
399
+ ```bash
400
+ redis-server
401
+ ```
402
+
403
+ **Custom port:**
404
+ ```bash
405
+ redis-server --port 6380
406
+ ```
407
+ Then set: `REDIS_URL=redis://localhost:6380`
408
+
409
+ **Remote Redis:**
410
+ ```json
411
+ {
412
+ "env": {
413
+ "REDIS_URL": "redis://username:password@host:port/db"
414
+ }
415
+ }
416
+ ```
417
+
418
+ **Redis Cloud/AWS ElastiCache:**
419
+ ```json
420
+ {
421
+ "env": {
422
+ "REDIS_URL": "rediss://your-redis-cloud.com:6379"
423
+ }
424
+ }
425
+ ```
426
+
427
+ ---
428
+
429
+ ## How It Works
430
+
431
+ 1. **Storage**: Memories stored in Redis with workspace isolation
432
+ 2. **Embeddings**: Hybrid approach using Claude-extracted keywords + trigrams (128-dim vectors)
433
+ 3. **Search**: Cosine similarity for semantic retrieval
434
+ 4. **Context**: Auto-injected at conversation start via MCP prompts
435
+ 5. **Analysis**: Claude Haiku analyzes conversations for memory extraction
436
+
437
+ ### Cost Estimate
438
+
439
+ Very affordable! Estimated **~$0.20/day** for active development:
440
+ - Uses Claude Haiku (cheapest model) for analysis
441
+ - Hybrid embeddings reduce API calls
442
+ - Redis in-memory storage is fast and free
443
+
444
+ ---
445
+
446
+ ## Troubleshooting
447
+
448
+ ### "Cannot connect to Redis"
449
+
450
+ **Solution 1: Start local Redis**
451
+ ```bash
452
+ redis-server
453
+ ```
454
+
455
+ Test connection:
456
+ ```bash
457
+ redis-cli ping
458
+ # Should return: PONG
459
+ ```
460
+
461
+ **Solution 2: Use cloud Redis (no install needed)**
462
+
463
+ Sign up for free cloud Redis:
464
+ 1. **Upstash** (easiest): https://upstash.com
465
+ - Create database
466
+ - Copy `REDIS_URL` from dashboard
467
+ - Update your config with the URL
468
+
469
+ 2. **Redis Cloud**: https://redis.com/try-free
470
+ - Free 30MB database
471
+ - Get connection string
472
+
473
+ 3. **Railway**: https://railway.app
474
+ - Add Redis service
475
+ - Use provided connection URL
476
+
477
+ ```json
478
+ {
479
+ "env": {
480
+ "REDIS_URL": "rediss://your-upstash-url.upstash.io:6379"
481
+ }
482
+ }
483
+ ```
484
+
485
+ No local Redis installation required! ✨
486
+
487
+ ### "Tools not showing up in Claude"
488
+
489
+ **Solution:**
490
+ 1. Check config file path is correct
491
+ 2. Verify `ANTHROPIC_API_KEY` is set
492
+ 3. Restart Claude **completely** (quit and reopen)
493
+ 4. Check Claude's MCP logs for errors
494
+
495
+ **Config file locations:**
496
+ - **Claude Code**: `~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
497
+ - **Claude Desktop (macOS)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
498
+ - **Claude Desktop (Windows)**: `%APPDATA%\Claude\claude_desktop_config.json`
499
+
500
+ ### "Memories not persisting"
501
+
502
+ **Solution:** Check workspace isolation - you may be in a different directory.
503
+
504
+ Memories are scoped to the working directory where Claude was launched. To see your workspace:
505
+
506
+ ```
507
+ "What's my current memory workspace?"
508
+ ```
509
+
510
+ ### "Out of context" or "Context window full"
511
+
512
+ **Solution:** Use smart context management:
513
+
514
+ ```
515
+ "Analyze our conversation and remember the important parts"
516
+ ```
517
+
518
+ This extracts key information before context compaction.
519
+
520
+ ---
521
+
522
+ ## Performance
523
+
524
+ Typical performance characteristics:
525
+
526
+ - **Store Memory**: ~200ms (includes embedding generation)
527
+ - **Batch Store (10)**: ~500ms
528
+ - **Get by ID**: <1ms (Redis in-memory)
529
+ - **Recent (50)**: ~10ms
530
+ - **Semantic Search (1k memories)**: ~500ms
531
+ - **Semantic Search (10k memories)**: ~2s
532
+
533
+ ---
534
+
535
+ ## Version History
536
+
537
+ - **v1.2.0** (Current) - TTL support, Export/Import, Consolidation, Analytics
538
+ - **v1.1.0** - Smart context management (recall, analyze, summarize)
539
+ - **v1.0.0** - Initial release with core memory operations
540
+
541
+ **[See CHANGELOG.md for detailed changes](CHANGELOG.md)**
542
+
543
+ ---
544
+
545
+ ## Learn More
546
+
547
+ - **[Feature Documentation](FEATURES_V1.2.md)** - Detailed v1.2 feature guide
548
+ - **[Context Management](CONTEXT_MANAGEMENT.md)** - Smart context guide (v1.1)
549
+ - **[Changelog](CHANGELOG.md)** - Complete version history
550
+
551
+ ---
552
+
553
+ ## Development
554
+
555
+ ```bash
556
+ # Clone and install
557
+ git clone <repo-url>
558
+ cd mem
559
+ npm install
560
+
561
+ # Build
562
+ npm run build
563
+
564
+ # Development mode (watch)
565
+ npm run dev
566
+ ```
567
+
568
+ ### Project Structure
569
+ ```
570
+ /mem/
571
+ β”œβ”€β”€ src/
572
+ β”‚ β”œβ”€β”€ index.ts # Server entry point
573
+ β”‚ β”œβ”€β”€ types.ts # TypeScript types & schemas
574
+ β”‚ β”œβ”€β”€ redis/
575
+ β”‚ β”‚ β”œβ”€β”€ client.ts # Redis connection
576
+ β”‚ β”‚ └── memory-store.ts # Storage logic
577
+ β”‚ β”œβ”€β”€ embeddings/
578
+ β”‚ β”‚ └── generator.ts # Claude embeddings
579
+ β”‚ β”œβ”€β”€ analysis/
580
+ β”‚ β”‚ └── conversation-analyzer.ts # AI analysis
581
+ β”‚ β”œβ”€β”€ tools/
582
+ β”‚ β”‚ β”œβ”€β”€ index.ts # Core tools
583
+ β”‚ β”‚ β”œβ”€β”€ context-tools.ts # Smart context tools
584
+ β”‚ β”‚ └── export-import-tools.ts # Advanced tools
585
+ β”‚ β”œβ”€β”€ resources/
586
+ β”‚ β”‚ β”œβ”€β”€ index.ts # MCP resources
587
+ β”‚ β”‚ └── analytics.ts # Analytics resource
588
+ β”‚ └── prompts/
589
+ β”‚ β”œβ”€β”€ index.ts # MCP prompts
590
+ β”‚ └── formatters.ts # Context formatters
591
+ └── dist/ # Built output
592
+ ```
593
+
594
+ ---
595
+
596
+ ## Support
597
+
598
+ - **Issues**: Report bugs or request features on GitHub
599
+ - **Questions**: Open a discussion for help
600
+ - **Documentation**: Check the docs folder for detailed guides
601
+
602
+ ---
603
+
604
+ ## License
605
+
606
+ MIT - See LICENSE file
607
+
608
+ ---
609
+
610
+ **Built with ❀️ by José Airosa for Claude users tired of repeating context**
611
+
612
+ *Powered by: TypeScript, Redis, Anthropic Claude, Model Context Protocol*