claude-recall 0.2.19 → 0.3.1

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.
Files changed (78) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +51 -61
  3. package/dist/cli/claude-recall-cli.js +12 -1
  4. package/dist/cli/commands/live-test.js +0 -0
  5. package/dist/cli/commands/migrate.js +0 -0
  6. package/dist/core/pattern-detector.js +0 -0
  7. package/dist/core/patterns.js +0 -0
  8. package/dist/core/retrieval.js +0 -0
  9. package/dist/mcp/memory-capture-middleware.js +136 -0
  10. package/dist/mcp/prompts-handler.js +422 -0
  11. package/dist/mcp/queue-tools.js +0 -0
  12. package/dist/mcp/rate-limiter.js +0 -0
  13. package/dist/mcp/resources-handler.js +374 -0
  14. package/dist/mcp/server.js +101 -2
  15. package/dist/mcp/session-manager.js +98 -1
  16. package/dist/mcp/tools/live-testing-tools.js +0 -0
  17. package/dist/mcp/tools/memory-tools.js +97 -0
  18. package/dist/mcp/tools/test-tools.js +0 -0
  19. package/dist/mcp/transports/stdio.js +0 -0
  20. package/dist/memory/pattern-store.js +0 -0
  21. package/dist/memory/schema.sql +0 -0
  22. package/dist/memory/storage.js +0 -0
  23. package/dist/services/action-pattern-detector.js +0 -0
  24. package/dist/services/claude-json-watcher.js +0 -0
  25. package/dist/services/config.js +0 -0
  26. package/dist/services/context-enhancer.js +215 -0
  27. package/dist/services/conversation-context-manager.js +254 -0
  28. package/dist/services/database-manager.js +10 -0
  29. package/dist/services/keyword-extractor.js +187 -0
  30. package/dist/services/logging.js +0 -0
  31. package/dist/services/memory-enhancer.js +0 -0
  32. package/dist/services/memory-usage-tracker.js +227 -0
  33. package/dist/services/memory.js +0 -0
  34. package/dist/services/pattern-service.js +0 -0
  35. package/dist/services/preference-analyzer.js +242 -0
  36. package/dist/services/preference-extractor.js +0 -0
  37. package/dist/services/queue-api.js +0 -0
  38. package/dist/services/queue-integration.js +0 -0
  39. package/dist/services/queue-migration.js +0 -0
  40. package/dist/services/queue-system.js +28 -4
  41. package/dist/services/restart-continuity.js +11 -1
  42. package/dist/services/search-monitor.js +0 -0
  43. package/dist/services/semantic-preference-extractor.js +0 -0
  44. package/dist/testing/auto-correction-engine.js +0 -0
  45. package/dist/testing/live-testing-manager.js +0 -0
  46. package/dist/testing/mock-claude.js +0 -0
  47. package/dist/testing/observable-database.js +0 -0
  48. package/dist/testing/scenario-runner.js +0 -0
  49. package/dist/testing/test-orchestrator.js +0 -0
  50. package/docs/API_REFERENCE.md +0 -0
  51. package/docs/ARCHITECTURE.md +0 -0
  52. package/docs/Claude-Recall-MCP-Analysis-Manus.md +524 -0
  53. package/docs/REAL-TIME-INTELLIGENCE-ANALYSIS.md +1242 -0
  54. package/docs/TDD-GUIDE.md +513 -0
  55. package/docs/TEST-DOCUMENTATION.md +794 -0
  56. package/package.json +11 -2
  57. package/scripts/postinstall.js +0 -0
  58. package/dist/config/memory-patterns.json +0 -64
  59. package/dist/hooks/minimal/post-tool-trigger.js +0 -117
  60. package/dist/hooks/minimal/pre-tool-trigger.js +0 -117
  61. package/dist/hooks/minimal/user-prompt-submit-trigger.js +0 -117
  62. package/dist/scripts/claude-integration.js +0 -318
  63. package/dist/scripts/fix-test-timeouts.js +0 -77
  64. package/dist/scripts/install.js +0 -138
  65. package/dist/scripts/live-mcp-test.sh +0 -138
  66. package/dist/scripts/mcp-postinstall.js +0 -27
  67. package/dist/scripts/platform-utils.js +0 -258
  68. package/dist/scripts/production-checklist.sh +0 -104
  69. package/dist/scripts/test-claude-code-integration.sh +0 -38
  70. package/dist/scripts/test-memory-search.sh +0 -67
  71. package/dist/scripts/test-persistence.sh +0 -55
  72. package/dist/scripts/test-rate-limiting.sh +0 -63
  73. package/dist/scripts/uninstall.js +0 -100
  74. package/dist/services/hook.js +0 -507
  75. package/dist/services/queue-consolidation.js +0 -303
  76. package/dist/services/queue-system-fixed.js +0 -826
  77. package/dist/tests/memory-management.test.js +0 -254
  78. package/scripts/postinstall-claude-md.js +0 -67
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Claude Recall
2
2
 
3
- An MCP server that gives Claude persistent memory across conversations, with automatic capture and retrieval of relevant context.
4
-
5
- ## The Story
3
+ An MCP server that gives Claude persistent memory across conversations.
6
4
 
7
5
  Every time you start a new conversation with Claude, you're starting from scratch. Claude doesn't remember your preferences, your project context, or the decisions you've made together. Until now.
8
6
 
@@ -20,37 +18,56 @@ Every time you start a new conversation with Claude, you're starting from scratc
20
18
  - **Categorized storage** - Organizes memories by type (preferences, project knowledge, corrections)
21
19
  - **Priority-based** - More important or frequently used memories are prioritized
22
20
 
23
- ### 🔒 Privacy First
21
+ ### Advanced Features (v0.3.0+)
22
+ - **MCP Resources & Prompts** - Expose memories as subscribable resources and prompt templates
23
+ - **Automatic preference detection** - Detects when you express preferences and suggests analysis
24
+ - **Proactive memory injection** - Relevant memories automatically injected before tool execution
25
+ - **Context-aware tool descriptions** - Tools show relevant preferences in their descriptions
26
+ - **Duplicate detection** - Recognizes when you ask the same question multiple times
27
+ - **Memory usage tracking** - Learns which memories are useful and adjusts relevance scores
28
+
29
+ ### 🔒 Privacy & Security First
24
30
  - **100% Local** - All memories stored locally in SQLite (~/.claude-recall/)
25
31
  - **No cloud sync** - Your data never leaves your machine
26
32
  - **You own your data** - Export, view, or delete memories at any time
27
33
  - **Zero telemetry** - No data collection or phone-home behavior
34
+ - **Security Audited** - Reviewed by Claude Code using `/security-review` command: No exposed secrets, SQL injection protection, 0 npm vulnerabilities
28
35
 
29
36
  ## Quick Start
30
37
 
31
- ### 1. Install via npm
38
+ ### Option 1: Local Project Installation (Recommended)
39
+ For automatic CLAUDE.md integration in your project:
32
40
  ```bash
33
- npm install -g claude-recall@latest
41
+ cd your-project
42
+ npm install claude-recall
34
43
  ```
44
+ This automatically adds Claude Recall instructions to your project's CLAUDE.md file.
35
45
 
36
- ### 2. Verify Installation
46
+ ### Option 2: Global Installation
47
+ For CLI access from anywhere:
37
48
  ```bash
38
- claude-recall --version # Should show 0.2.19 or higher
49
+ npm install -g claude-recall@latest
39
50
  ```
40
51
 
41
- ### 3. Start Using Claude
42
- That's it! Claude Recall works automatically in the background. Your memories are captured and retrieved seamlessly.
52
+ **Note:** You can have both installations. For global installations, manually add this to your `~/.claude/CLAUDE.md`:
53
+ ```markdown
54
+ ## Claude Recall Integration
55
+ - IMPORTANT: Always search memories before creating new files or making decisions
56
+ - Use `mcp__claude-recall__search_memory` to check for stored preferences and project knowledge
57
+ - Memories include: coding preferences, file locations, project patterns, and team conventions
58
+ ```
59
+
60
+ After installation, verify with: `claude-recall --version` (or `npx claude-recall --version` for local installs)
43
61
 
44
62
  ## How It Works
45
63
 
46
- ### Automatic Mode (Default)
47
64
  When you chat with Claude, the system:
48
- 1. **Captures** your preferences and important information automatically
49
- 2. **Stores** them in a local SQLite database
65
+ 1. **Captures** your preferences and important information
66
+ 2. **Stores** them locally in SQLite (`~/.claude-recall/claude-recall.db`)
50
67
  3. **Retrieves** relevant memories when you start new conversations
51
68
  4. **Injects** context so Claude remembers your preferences
52
69
 
53
- ### Example Workflow
70
+ ### Example
54
71
  ```
55
72
  You: "I prefer TypeScript with strict mode for all my projects"
56
73
  [Claude Recall automatically stores this preference]
@@ -103,19 +120,12 @@ claude-recall import memories.json
103
120
 
104
121
  # Clear memories (use with caution)
105
122
  claude-recall clear --type preferences # Clear only preferences
106
- claude-recall clear --all # Clear everything
123
+ claude-recall clear --force # Clear everything
107
124
 
108
125
  # Test memory capture (for debugging)
109
126
  claude-recall capture user-prompt '{"content":"your message here"}'
110
127
  ```
111
128
 
112
- ## Privacy & Storage
113
-
114
- - **Local storage only** - All memories stored in `~/.claude-recall/claude-recall.db`
115
- - **No cloud sync** - Your data never leaves your machine
116
- - **User control** - View, export, or delete memories at any time
117
- - **Gitignored by default** - Memory database excluded from version control
118
-
119
129
  ## Memory Management
120
130
 
121
131
  Claude Recall automatically manages memory to prevent unlimited database growth, with user notifications:
@@ -164,12 +174,12 @@ export CLAUDE_RECALL_RETAIN_TOOL_USE=2000 # Keep more tool usage history
164
174
  ## Troubleshooting
165
175
 
166
176
  ### Memories not being retrieved?
167
- 1. Check if claude-recall is installed: `claude-recall --version`
168
- 2. Verify memories exist: `claude-recall stats`
169
- 3. Search manually to test: `claude-recall search "your topic"`
177
+ 1. Verify memories exist: `claude-recall stats`
178
+ 2. Search manually to test: `claude-recall search "your topic"`
170
179
 
171
180
  ### Installation shows old version?
172
- Clear npm cache and reinstall:
181
+
182
+ #### For global installation (CLI usage):
173
183
  ```bash
174
184
  npm cache clean --force
175
185
  npm uninstall -g claude-recall
@@ -177,33 +187,27 @@ npm install -g claude-recall@latest
177
187
  claude-recall --version
178
188
  ```
179
189
 
190
+ #### For local installation (CLAUDE.md integration):
191
+ ```bash
192
+ npm cache clean --force
193
+ npm uninstall claude-recall
194
+ npm install claude-recall@latest
195
+ npx claude-recall --version
196
+ ```
197
+
180
198
  ### Performance issues?
181
199
  - Check database size: `ls -lh ~/.claude-recall/claude-recall.db`
182
200
  - Clear old memories: `claude-recall clear --days 30`
183
201
  - The system uses SQLite with optimized indexes for fast retrieval
184
202
 
185
- ### Diagnostic Commands for Support
186
- If you need help, run these commands and share the output:
203
+ ### Need Help?
204
+ Run this diagnostic script and share the output:
187
205
  ```bash
188
- # Check Installation
189
206
  claude-recall --version
190
- which claude-recall
191
- npm list -g claude-recall
192
-
193
- # Check Database
194
- ls -la ~/.claude-recall/
195
- ls -lh ~/.claude-recall/claude-recall.db
196
-
197
- # Check System Status
198
207
  claude-recall stats
199
-
200
- # Test Basic Functionality
201
- claude-recall search "test"
202
-
203
- # Environment Info
208
+ ls -lh ~/.claude-recall/claude-recall.db
204
209
  node --version
205
210
  npm --version
206
- echo "OS: $(uname -s)"
207
211
  ```
208
212
 
209
213
  ## Best Practices
@@ -213,20 +217,6 @@ echo "OS: $(uname -s)"
213
217
  3. **Review periodically** - Use `claude-recall stats` to see what's being remembered
214
218
  4. **Export important memories** - Backup critical preferences with `claude-recall export`
215
219
 
216
- ## Contributing
217
-
218
- We welcome contributions! Claude Recall is designed to be hackable:
219
-
220
- - **Small Codebase**: Intentionally kept under 3000 lines
221
- - **Clean Architecture**: Easy to understand and modify
222
- - **Well Tested**: Comprehensive test coverage
223
-
224
- ## Support
225
-
226
- For issues or questions:
227
- - GitHub: https://github.com/raoulbia-ai/claude-recall
228
- - npm: https://www.npmjs.com/package/claude-recall
229
-
230
220
  ## Acknowledgements
231
221
 
232
222
  This project makes extensive use of the excellent work from:
@@ -236,12 +226,12 @@ This project makes extensive use of the excellent work from:
236
226
 
237
227
  MIT - Use it, modify it, make it yours.
238
228
 
239
- ## The Future
229
+ ## Disclaimer
240
230
 
241
- Claude Recall is part of a larger vision where AI assistants truly understand and remember their users. By building on open protocols and local-first principles, we're creating a future where your AI tools work together seamlessly, with memory and context that persists across sessions, projects, and time.
231
+ This software is provided "as-is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
242
232
 
243
- Start building with memory. Start building with Claude Recall.
233
+ This project is provided for free to the community. While every effort has been made to ensure quality and security (including automated security reviews), users should review and test the code according to their own requirements before use in production environments.
244
234
 
245
235
  ---
246
236
 
247
- Built with ❤️ by a developer who was tired of repeating himself to Claude.
237
+ Built with ❤️ by a developer who was tired of repeating himself to Claude.
@@ -39,6 +39,7 @@ const config_1 = require("../services/config");
39
39
  const logging_1 = require("../services/logging");
40
40
  const commander_1 = require("commander");
41
41
  const fs = __importStar(require("fs"));
42
+ const path = __importStar(require("path"));
42
43
  const pattern_service_1 = require("../services/pattern-service");
43
44
  const migrate_1 = require("./commands/migrate");
44
45
  const server_1 = require("../mcp/server");
@@ -255,12 +256,22 @@ class ClaudeRecallCLI {
255
256
  return str.substring(0, maxLength) + '...';
256
257
  }
257
258
  }
259
+ // Get version from package.json
260
+ function getVersion() {
261
+ try {
262
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf-8'));
263
+ return packageJson.version;
264
+ }
265
+ catch (error) {
266
+ return '0.3.0'; // Fallback
267
+ }
268
+ }
258
269
  // Setup CLI commands
259
270
  async function main() {
260
271
  program
261
272
  .name('claude-recall')
262
273
  .description('Memory-enhanced Claude Code via MCP')
263
- .version('0.2.19')
274
+ .version(getVersion())
264
275
  .option('--verbose', 'Enable verbose logging')
265
276
  .option('--config <path>', 'Path to custom config file');
266
277
  // MCP command
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -38,6 +38,8 @@ const preference_extractor_1 = require("../services/preference-extractor");
38
38
  const action_pattern_detector_1 = require("../services/action-pattern-detector");
39
39
  const memory_1 = require("../services/memory");
40
40
  const logging_1 = require("../services/logging");
41
+ const keyword_extractor_1 = require("../services/keyword-extractor");
42
+ const memory_usage_tracker_1 = require("../services/memory-usage-tracker");
41
43
  const fs = __importStar(require("fs"));
42
44
  const path = __importStar(require("path"));
43
45
  class MemoryCaptureMiddleware {
@@ -48,6 +50,8 @@ class MemoryCaptureMiddleware {
48
50
  this.actionDetector = new action_pattern_detector_1.ActionPatternDetector();
49
51
  this.memoryService = memory_1.MemoryService.getInstance();
50
52
  this.logger = logging_1.LoggingService.getInstance();
53
+ this.keywordExtractor = keyword_extractor_1.KeywordExtractor.getInstance();
54
+ this.usageTracker = memory_usage_tracker_1.MemoryUsageTracker.getInstance();
51
55
  this.loadConfig();
52
56
  }
53
57
  loadConfig() {
@@ -310,5 +314,137 @@ class MemoryCaptureMiddleware {
310
314
  this.loadConfig();
311
315
  this.logger.info('MemoryCaptureMiddleware', 'Configuration reloaded');
312
316
  }
317
+ /**
318
+ * Phase 3B: Proactively retrieve and inject relevant memories
319
+ * Call this BEFORE executing tool to inject memory context
320
+ */
321
+ async enhanceRequestWithMemories(request) {
322
+ try {
323
+ // Only enhance tool calls
324
+ if (request.method !== 'tools/call') {
325
+ return request;
326
+ }
327
+ // Don't enhance memory-related tools to avoid loops
328
+ if (request.params?.name?.includes('memory')) {
329
+ return request;
330
+ }
331
+ // Extract keywords from tool arguments
332
+ const toolArgs = request.params?.arguments || {};
333
+ const searchQuery = this.keywordExtractor.extractAsQuery(toolArgs);
334
+ if (!searchQuery) {
335
+ return request; // No keywords found
336
+ }
337
+ // Search for relevant memories
338
+ const memories = this.memoryService.search(searchQuery);
339
+ // Filter to top 3 most relevant
340
+ const topMemories = memories.slice(0, 3);
341
+ if (topMemories.length === 0) {
342
+ return request; // No relevant memories
343
+ }
344
+ // Format memories as context
345
+ const memoryContext = this.formatMemoriesForContext(topMemories);
346
+ // Inject into request
347
+ // Store in a special field that tools can access
348
+ if (!request.params) {
349
+ request.params = {};
350
+ }
351
+ request.params._memoryContext = memoryContext;
352
+ request.params._injectedMemories = topMemories.map(m => ({
353
+ key: m.key,
354
+ type: m.type,
355
+ confidence: this.extractConfidence(m)
356
+ }));
357
+ // Phase 3C: Track memory injections
358
+ const sessionId = request.params?.sessionId || 'unknown';
359
+ for (const memory of topMemories) {
360
+ this.usageTracker.recordInjection(memory.key, request.params.name, sessionId);
361
+ }
362
+ this.logger.info('MemoryCaptureMiddleware', 'Injected memories into request', {
363
+ toolName: request.params.name,
364
+ memoryCount: topMemories.length,
365
+ keywords: searchQuery
366
+ });
367
+ return request;
368
+ }
369
+ catch (error) {
370
+ this.logger.error('MemoryCaptureMiddleware', 'Failed to enhance request', error);
371
+ return request; // Return original on error
372
+ }
373
+ }
374
+ /**
375
+ * Format memories as readable context string
376
+ */
377
+ formatMemoriesForContext(memories) {
378
+ const lines = ['📝 Relevant Memories:'];
379
+ for (const memory of memories) {
380
+ const formatted = this.formatSingleMemoryForContext(memory);
381
+ if (formatted) {
382
+ lines.push(`- ${formatted}`);
383
+ }
384
+ }
385
+ return lines.join('\n');
386
+ }
387
+ /**
388
+ * Format a single memory for context injection
389
+ */
390
+ formatSingleMemoryForContext(memory) {
391
+ try {
392
+ const value = memory.value;
393
+ // Handle different value formats
394
+ if (typeof value === 'string') {
395
+ return value;
396
+ }
397
+ if (typeof value === 'object' && value !== null) {
398
+ // Extract meaningful information
399
+ if (value.preference)
400
+ return value.preference;
401
+ if (value.value) {
402
+ const val = value.value;
403
+ if (typeof val === 'string')
404
+ return val;
405
+ if (typeof val === 'object' && val.framework) {
406
+ return `Use ${val.framework}`;
407
+ }
408
+ }
409
+ if (value.content)
410
+ return value.content;
411
+ if (value.message)
412
+ return value.message;
413
+ if (value.raw)
414
+ return value.raw;
415
+ // Fallback: extract key info from memory key
416
+ return this.extractKeyInfo(memory.key, value);
417
+ }
418
+ return null;
419
+ }
420
+ catch (error) {
421
+ return null;
422
+ }
423
+ }
424
+ /**
425
+ * Extract key information from memory
426
+ */
427
+ extractKeyInfo(key, value) {
428
+ const cleanKey = key
429
+ .replace(/auto_|pref_/g, '')
430
+ .replace(/_\d+$/g, '')
431
+ .replace(/_/g, ' ');
432
+ if (value.framework)
433
+ return `${cleanKey}: ${value.framework}`;
434
+ if (value.location)
435
+ return `${cleanKey}: ${value.location}`;
436
+ if (value.style)
437
+ return `${cleanKey}: ${value.style}`;
438
+ return cleanKey;
439
+ }
440
+ /**
441
+ * Extract confidence from memory value
442
+ */
443
+ extractConfidence(memory) {
444
+ if (typeof memory.value === 'object' && memory.value !== null) {
445
+ return memory.value.confidence || 0.5;
446
+ }
447
+ return 0.5;
448
+ }
313
449
  }
314
450
  exports.MemoryCaptureMiddleware = MemoryCaptureMiddleware;