claude-self-reflect 1.2.0 → 1.3.3

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.
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "self-reflection": {
4
4
  "command": "node",
5
- "args": ["/Users/ramakrishnanannaswamy/memento-stack/qdrant-mcp-stack/claude-self-reflection/dist/index.js"],
5
+ "args": ["/Users/ramakrishnanannaswamy/claude-self-reflect/qdrant-mcp-stack/claude-self-reflection/dist/index.js"],
6
6
  "env": {
7
7
  "QDRANT_URL": "http://localhost:6333",
8
8
  "VOYAGE_KEY": "pa-wdTYGObaxhs-XFKX2r7WCczRwEVNb9eYMTSO3yrQhZI"
package/dist/index.js CHANGED
@@ -5,6 +5,14 @@ import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } f
5
5
  import { QdrantClient } from '@qdrant/js-client-rest';
6
6
  import { createEmbeddingService } from './embeddings.js';
7
7
  import { ProjectIsolationManager } from './project-isolation.js';
8
+ import * as dotenv from 'dotenv';
9
+ import * as path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+ // Get __dirname equivalent for ES modules
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+ // Load environment variables from parent directory
15
+ dotenv.config({ path: path.join(__dirname, '../../.env') });
8
16
  const QDRANT_URL = process.env.QDRANT_URL || 'http://localhost:6333';
9
17
  const COLLECTION_NAME = process.env.COLLECTION_NAME || 'conversations';
10
18
  const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
@@ -12,6 +20,14 @@ const VOYAGE_API_KEY = process.env.VOYAGE_KEY || process.env['VOYAGE_KEY-2'];
12
20
  const PREFER_LOCAL_EMBEDDINGS = process.env.PREFER_LOCAL_EMBEDDINGS === 'true';
13
21
  const ISOLATION_MODE = process.env.ISOLATION_MODE || 'hybrid';
14
22
  const ALLOW_CROSS_PROJECT = process.env.ALLOW_CROSS_PROJECT === 'true';
23
+ const ENABLE_MEMORY_DECAY = process.env.ENABLE_MEMORY_DECAY === 'true';
24
+ const DECAY_WEIGHT = parseFloat(process.env.DECAY_WEIGHT || '0.3');
25
+ const DECAY_SCALE_DAYS = parseFloat(process.env.DECAY_SCALE_DAYS || '90');
26
+ // Debug: Log environment variables on startup
27
+ console.error('🚀 MCP Server starting with environment:');
28
+ console.error(` - ENABLE_MEMORY_DECAY: ${ENABLE_MEMORY_DECAY} (from env: ${process.env.ENABLE_MEMORY_DECAY})`);
29
+ console.error(` - DECAY_WEIGHT: ${DECAY_WEIGHT} (from env: ${process.env.DECAY_WEIGHT})`);
30
+ console.error(` - DECAY_SCALE_DAYS: ${DECAY_SCALE_DAYS} (from env: ${process.env.DECAY_SCALE_DAYS})`);
15
31
  class SelfReflectionServer {
16
32
  server;
17
33
  qdrantClient;
@@ -89,6 +105,10 @@ class SelfReflectionServer {
89
105
  description: 'Minimum similarity score (0-1, default: 0.7)',
90
106
  default: 0.7,
91
107
  },
108
+ useDecay: {
109
+ type: 'boolean',
110
+ description: 'Apply time-based decay to prioritize recent memories (default: uses environment setting)',
111
+ },
92
112
  },
93
113
  required: ['query'],
94
114
  },
@@ -137,7 +157,24 @@ class SelfReflectionServer {
137
157
  }
138
158
  }
139
159
  async handleReflectOnPast(args) {
140
- const { query, limit = 5, project, minScore = 0.7, crossProject = false } = args;
160
+ const { query, limit = 5, project, minScore = 0.7, crossProject = false, useDecay } = args;
161
+ const shouldUseDecay = useDecay !== undefined ? useDecay : ENABLE_MEMORY_DECAY;
162
+ // Log debug info but don't return early
163
+ console.error(`🔍 DEBUG: MCP handleReflectOnPast called!
164
+ - query: "${query}"
165
+ - useDecay: ${useDecay} (type: ${typeof useDecay})
166
+ - shouldUseDecay: ${shouldUseDecay}
167
+ - ENABLE_MEMORY_DECAY: ${ENABLE_MEMORY_DECAY}
168
+ - DECAY_WEIGHT: ${DECAY_WEIGHT}
169
+ - DECAY_SCALE_DAYS: ${DECAY_SCALE_DAYS}
170
+ - minScore: ${minScore}`);
171
+ // Extra debug for decay path
172
+ if (shouldUseDecay) {
173
+ console.error(`🔄 DECAY PATH SHOULD BE TAKEN - shouldUseDecay is true`);
174
+ }
175
+ else {
176
+ console.error(`❌ DECAY PATH NOT TAKEN - shouldUseDecay is false`);
177
+ }
141
178
  try {
142
179
  // Initialize if not already done
143
180
  if (!this.embeddingService) {
@@ -162,15 +199,97 @@ class SelfReflectionServer {
162
199
  };
163
200
  }
164
201
  console.error(`Searching across ${voyageCollections.length} Voyage collections: ${voyageCollections.slice(0, 3).join(', ')}...`);
202
+ if (voyageCollections.length === 0) {
203
+ console.error(`⚠️ WARNING: No Voyage collections found!`);
204
+ return {
205
+ content: [{
206
+ type: 'text',
207
+ text: 'No conversation collections found. Please import conversations first.'
208
+ }]
209
+ };
210
+ }
165
211
  // Search across multiple collections
166
212
  const searchPromises = voyageCollections.map(async (collectionName) => {
167
213
  try {
168
- const searchResponse = await this.qdrantClient.search(collectionName, {
169
- vector: queryEmbedding,
170
- limit: Math.ceil(limit * 1.5), // Get extra results per collection
171
- score_threshold: minScore,
172
- with_payload: true,
173
- });
214
+ let searchResponse;
215
+ if (shouldUseDecay) {
216
+ console.error(`🔄 DECAY MODE ACTIVE for collection ${collectionName}`);
217
+ console.error(` - minScore parameter: ${minScore} (will be ignored for initial search)`);
218
+ console.error(` - DECAY_WEIGHT: ${DECAY_WEIGHT}`);
219
+ console.error(` - DECAY_SCALE_DAYS: ${DECAY_SCALE_DAYS}`);
220
+ // IMPORTANT: No score_threshold for decay mode - we need all results to apply decay
221
+ searchResponse = await this.qdrantClient.search(collectionName, {
222
+ vector: queryEmbedding,
223
+ limit: Math.ceil(limit * 3), // Get more candidates for decay filtering
224
+ // NO score_threshold - we'll filter after decay is applied
225
+ with_payload: true,
226
+ });
227
+ console.error(` - Initial results from ${collectionName}: ${searchResponse.length} items`);
228
+ if (searchResponse.length > 0) {
229
+ console.error(` - Score range: ${searchResponse[searchResponse.length - 1].score.toFixed(3)} to ${searchResponse[0].score.toFixed(3)}`);
230
+ }
231
+ // Apply decay scoring with proper formula
232
+ const now = Date.now();
233
+ const scaleMs = DECAY_SCALE_DAYS * 24 * 60 * 60 * 1000;
234
+ try {
235
+ searchResponse = searchResponse.map((point, index) => {
236
+ let ageMs = 0;
237
+ let originalScore = point.score;
238
+ try {
239
+ if (point.payload?.timestamp) {
240
+ const timestamp = new Date(point.payload.timestamp).getTime();
241
+ if (!isNaN(timestamp)) {
242
+ ageMs = now - timestamp;
243
+ }
244
+ else {
245
+ console.error(` - Invalid timestamp for point ${point.id}: ${point.payload.timestamp}`);
246
+ }
247
+ }
248
+ // Calculate exponential decay factor (newer = higher factor)
249
+ const decayFactor = Math.exp(-ageMs / scaleMs);
250
+ // Apply decay formula: base_score + decay_weight * decay_factor
251
+ const adjustedScore = originalScore + (DECAY_WEIGHT * decayFactor);
252
+ if (index < 3) { // Log first 3 items for debugging
253
+ console.error(` Decay calculation for item ${index + 1}:`);
254
+ console.error(` - timestamp: ${point.payload?.timestamp || 'missing'}`);
255
+ console.error(` - age: ${(ageMs / 86400000).toFixed(1)} days`);
256
+ console.error(` - originalScore: ${originalScore.toFixed(3)}`);
257
+ console.error(` - decayFactor: ${decayFactor.toFixed(4)}`);
258
+ console.error(` - adjustedScore: ${adjustedScore.toFixed(3)} (boost: +${(adjustedScore - originalScore).toFixed(3)})`);
259
+ }
260
+ return {
261
+ ...point,
262
+ score: adjustedScore
263
+ };
264
+ }
265
+ catch (decayError) {
266
+ console.error(` Error calculating decay for point ${point.id}:`, decayError);
267
+ // Return original point with original score on error
268
+ return point;
269
+ }
270
+ });
271
+ }
272
+ catch (mapError) {
273
+ console.error(` Fatal error during decay calculation:`, mapError);
274
+ // Fall back to original search results if decay fails completely
275
+ searchResponse = searchResponse;
276
+ }
277
+ // Apply filtering and sorting
278
+ searchResponse = searchResponse
279
+ .filter(point => point.score >= minScore) // Apply minScore filter AFTER decay
280
+ .sort((a, b) => b.score - a.score)
281
+ .slice(0, limit);
282
+ console.error(` - After decay and filtering (>= ${minScore}): ${searchResponse.length} results`);
283
+ }
284
+ else {
285
+ // Standard search without decay
286
+ searchResponse = await this.qdrantClient.search(collectionName, {
287
+ vector: queryEmbedding,
288
+ limit: Math.ceil(limit * 1.5), // Get extra results per collection
289
+ score_threshold: minScore,
290
+ with_payload: true,
291
+ });
292
+ }
174
293
  if (searchResponse.length > 0) {
175
294
  console.error(`Collection ${collectionName}: Found ${searchResponse.length} results`);
176
295
  }
@@ -239,11 +358,24 @@ class SelfReflectionServer {
239
358
  .slice(0, limit);
240
359
  }
241
360
  if (results.length === 0) {
361
+ // For debugging, let's check what collections we have and what the search is actually doing
362
+ const voyageCollections = await this.getVoyageCollections();
242
363
  return {
243
364
  content: [
244
365
  {
245
366
  type: 'text',
246
- text: `No conversations found matching "${query}". Try different keywords or check if conversations have been imported.`,
367
+ text: `🔍 DECAY DEBUG: No results for "${query}"
368
+
369
+ [DEBUG INFO FROM CLAUDE SELF REFLECT MCP]
370
+ - useDecay param: ${useDecay} (type: ${typeof useDecay})
371
+ - shouldUseDecay: ${shouldUseDecay}
372
+ - minScore: ${minScore}
373
+ - embeddingService exists: ${!!this.embeddingService}
374
+ - ENABLE_MEMORY_DECAY env: ${ENABLE_MEMORY_DECAY}
375
+ - DECAY_WEIGHT env: ${DECAY_WEIGHT}
376
+ - collections found: ${voyageCollections.length}
377
+ - first 3: ${voyageCollections.slice(0, 3).join(', ')}
378
+ - MODE: ${shouldUseDecay ? '🔄 DECAY ACTIVE' : '📊 STANDARD SEARCH'}`,
247
379
  },
248
380
  ],
249
381
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EAC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AChB,SAAS,CAAC,aAAa,EACvB,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACxF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG;QACP,qCAAqC;QACrC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAExB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC3D,OAAO,CAAC,KAAK,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;QACtD,OAAO,CAAC,KAAK,CAAC,sBAAsB,IAAI,CAAC,gBAAgB,EAAE,YAAY,EAAE,IAAI,yBAAyB,EAAE,CAAC,CAAC;QAC1G,OAAO,CAAC,KAAK,CAAC,mBAAmB,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAEvE,+BAA+B;QAC/B,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5D,OAAO,CAAC,KAAK,CAAC,SAAS,iBAAiB,CAAC,MAAM,sCAAsC,CAAC,CAAC;IACzF,CAAC;CACF;AAED,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC1C,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "claude-self-reflect",
3
- "version": "1.2.0",
4
- "description": "Give Claude perfect memory of all your conversations - Semantic search across your entire Claude Desktop history",
3
+ "version": "1.3.3",
4
+ "description": "Give Claude perfect memory of all your conversations - Semantic search across your entire Claude Code history",
5
5
  "keywords": [
6
6
  "claude",
7
7
  "mcp",
@@ -11,7 +11,7 @@
11
11
  "qdrant",
12
12
  "vector-search",
13
13
  "ai-memory",
14
- "claude-desktop"
14
+ "claude-code"
15
15
  ],
16
16
  "homepage": "https://github.com/ramakay/claude-self-reflect#readme",
17
17
  "bugs": {
@@ -43,19 +43,20 @@
43
43
  "build": "tsc",
44
44
  "start": "node dist/index.js",
45
45
  "dev": "tsx src/index.ts",
46
- "test": "npm run test:ci",
46
+ "test": "npm run test:integration",
47
47
  "test:ci": "echo 'Integration tests require Qdrant - skipping in CI'",
48
48
  "test:unit": "echo 'No unit tests yet'",
49
49
  "test:integration": "tsx test/search-quality.test.ts",
50
50
  "lint": "tsc --noEmit",
51
51
  "postinstall": "node scripts/install-agent.js",
52
- "prepublishOnly": "npm run build && npm run test",
52
+ "prepublishOnly": "npm run build && npm run test:ci",
53
53
  "version": "git add -A src",
54
54
  "postversion": "git push && git push --tags"
55
55
  },
56
56
  "dependencies": {
57
57
  "@modelcontextprotocol/sdk": "^0.5.0",
58
58
  "@qdrant/js-client-rest": "^1.7.0",
59
+ "dotenv": "^17.2.1",
59
60
  "node-fetch": "^3.3.2"
60
61
  },
61
62
  "devDependencies": {
@@ -322,6 +322,55 @@ async function setupPython() {
322
322
  }
323
323
  }
324
324
 
325
+ async function configureMemoryDecay() {
326
+ header('Configure Memory Decay (Optional)');
327
+
328
+ console.log('Memory Decay helps prioritize recent conversations over older ones.\n');
329
+ console.log('When enabled, search results will favor more recent memories while');
330
+ console.log('still including relevant older content.\n');
331
+
332
+ const enable = await question('Enable memory decay? (y/n) [default: n]: ');
333
+
334
+ if (enable.toLowerCase() === 'y') {
335
+ console.log('\nDecay Configuration:');
336
+ console.log('1. Light decay (30 days) - Minimal recency bias');
337
+ console.log('2. Medium decay (90 days) - Balanced approach (Recommended)');
338
+ console.log('3. Strong decay (180 days) - Strong recency preference');
339
+ console.log('4. Custom configuration\n');
340
+
341
+ const choice = await question('Choose decay configuration (1-4) [default: 2]: ') || '2';
342
+
343
+ let weight = 0.3;
344
+ let scaleDays = 90;
345
+
346
+ switch (choice) {
347
+ case '1':
348
+ weight = 0.1;
349
+ scaleDays = 30;
350
+ break;
351
+ case '2':
352
+ weight = 0.3;
353
+ scaleDays = 90;
354
+ break;
355
+ case '3':
356
+ weight = 0.5;
357
+ scaleDays = 180;
358
+ break;
359
+ case '4':
360
+ const customWeight = await question('Decay weight (0.1-1.0) [default: 0.3]: ');
361
+ const customScale = await question('Decay scale in days [default: 90]: ');
362
+ weight = parseFloat(customWeight) || 0.3;
363
+ scaleDays = parseInt(customScale) || 90;
364
+ break;
365
+ }
366
+
367
+ success(`Memory decay configured: weight=${weight}, scale=${scaleDays} days`);
368
+ return { enabled: true, weight, scaleDays };
369
+ }
370
+
371
+ return { enabled: false };
372
+ }
373
+
325
374
  async function saveConfiguration(config) {
326
375
  const envPath = join(homedir(), '.claude-self-reflect', '.env');
327
376
  const envDir = dirname(envPath);
@@ -345,6 +394,14 @@ async function saveConfiguration(config) {
345
394
 
346
395
  envContent += 'QDRANT_URL=http://localhost:6333\n';
347
396
 
397
+ // Memory decay configuration
398
+ envContent += '\n# Memory Decay Configuration\n';
399
+ envContent += `ENABLE_MEMORY_DECAY=${config.memoryDecay?.enabled ? 'true' : 'false'}\n`;
400
+ if (config.memoryDecay?.enabled) {
401
+ envContent += `DECAY_WEIGHT=${config.memoryDecay.weight}\n`;
402
+ envContent += `DECAY_SCALE_DAYS=${config.memoryDecay.scaleDays}\n`;
403
+ }
404
+
348
405
  writeFileSync(envPath, envContent);
349
406
  success(`Configuration saved to ${envPath}`);
350
407
  }
@@ -394,19 +451,28 @@ async function runImport(pythonConfig, provider, apiKey) {
394
451
  });
395
452
  }
396
453
 
397
- async function setupClaudeDesktop() {
454
+ async function setupClaudeDesktop(memoryDecayConfig) {
398
455
  header('Configure Claude Desktop (Optional)');
399
456
 
400
457
  console.log('To use this with Claude Desktop, add the following to your config:\n');
401
458
 
459
+ const env = {
460
+ QDRANT_URL: 'http://localhost:6333'
461
+ };
462
+
463
+ // Add memory decay configuration if enabled
464
+ if (memoryDecayConfig?.enabled) {
465
+ env.ENABLE_MEMORY_DECAY = 'true';
466
+ env.DECAY_WEIGHT = memoryDecayConfig.weight.toString();
467
+ env.DECAY_SCALE_DAYS = memoryDecayConfig.scaleDays.toString();
468
+ }
469
+
402
470
  const config = {
403
471
  mcpServers: {
404
472
  'claude-self-reflect': {
405
473
  command: 'npx',
406
474
  args: ['claude-self-reflect'],
407
- env: {
408
- QDRANT_URL: 'http://localhost:6333'
409
- }
475
+ env
410
476
  }
411
477
  }
412
478
  };
@@ -485,10 +551,13 @@ async function main() {
485
551
  process.exit(1);
486
552
  }
487
553
 
488
- // Step 5: Save configuration
489
- await saveConfiguration({ provider, apiKey });
554
+ // Step 5: Configure memory decay
555
+ const memoryDecay = await configureMemoryDecay();
556
+
557
+ // Step 6: Save configuration
558
+ await saveConfiguration({ provider, apiKey, memoryDecay });
490
559
 
491
- // Step 6: Run import
560
+ // Step 7: Run import
492
561
  if (apiKey || provider === 'local') {
493
562
  const runImportNow = await question('\nWould you like to import your conversation history now? (y/n): ');
494
563
  if (runImportNow.toLowerCase() === 'y') {
@@ -496,8 +565,8 @@ async function main() {
496
565
  }
497
566
  }
498
567
 
499
- // Step 7: Configure Claude Desktop
500
- await setupClaudeDesktop();
568
+ // Step 8: Configure Claude Desktop
569
+ await setupClaudeDesktop(memoryDecay);
501
570
 
502
571
  // Done!
503
572
  header('✨ Setup Complete!');
package/src/index.ts CHANGED
@@ -10,6 +10,16 @@ import {
10
10
  import { QdrantClient } from '@qdrant/js-client-rest';
11
11
  import { createEmbeddingService, detectEmbeddingModel, EmbeddingService } from './embeddings.js';
12
12
  import { ProjectIsolationManager, ProjectIsolationConfig, DEFAULT_ISOLATION_CONFIG } from './project-isolation.js';
13
+ import * as dotenv from 'dotenv';
14
+ import * as path from 'path';
15
+ import { fileURLToPath } from 'url';
16
+
17
+ // Get __dirname equivalent for ES modules
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
+
21
+ // Load environment variables from parent directory
22
+ dotenv.config({ path: path.join(__dirname, '../../.env') });
13
23
 
14
24
  const QDRANT_URL = process.env.QDRANT_URL || 'http://localhost:6333';
15
25
  const COLLECTION_NAME = process.env.COLLECTION_NAME || 'conversations';
@@ -18,6 +28,15 @@ const VOYAGE_API_KEY = process.env.VOYAGE_KEY || process.env['VOYAGE_KEY-2'];
18
28
  const PREFER_LOCAL_EMBEDDINGS = process.env.PREFER_LOCAL_EMBEDDINGS === 'true';
19
29
  const ISOLATION_MODE = process.env.ISOLATION_MODE || 'hybrid';
20
30
  const ALLOW_CROSS_PROJECT = process.env.ALLOW_CROSS_PROJECT === 'true';
31
+ const ENABLE_MEMORY_DECAY = process.env.ENABLE_MEMORY_DECAY === 'true';
32
+ const DECAY_WEIGHT = parseFloat(process.env.DECAY_WEIGHT || '0.3');
33
+ const DECAY_SCALE_DAYS = parseFloat(process.env.DECAY_SCALE_DAYS || '90');
34
+
35
+ // Debug: Log environment variables on startup
36
+ console.error('🚀 MCP Server starting with environment:');
37
+ console.error(` - ENABLE_MEMORY_DECAY: ${ENABLE_MEMORY_DECAY} (from env: ${process.env.ENABLE_MEMORY_DECAY})`);
38
+ console.error(` - DECAY_WEIGHT: ${DECAY_WEIGHT} (from env: ${process.env.DECAY_WEIGHT})`);
39
+ console.error(` - DECAY_SCALE_DAYS: ${DECAY_SCALE_DAYS} (from env: ${process.env.DECAY_SCALE_DAYS})`);
21
40
 
22
41
  interface SearchResult {
23
42
  id: string;
@@ -115,6 +134,10 @@ class SelfReflectionServer {
115
134
  description: 'Minimum similarity score (0-1, default: 0.7)',
116
135
  default: 0.7,
117
136
  },
137
+ useDecay: {
138
+ type: 'boolean',
139
+ description: 'Apply time-based decay to prioritize recent memories (default: uses environment setting)',
140
+ },
118
141
  },
119
142
  required: ['query'],
120
143
  },
@@ -168,7 +191,25 @@ class SelfReflectionServer {
168
191
  }
169
192
 
170
193
  private async handleReflectOnPast(args: any) {
171
- const { query, limit = 5, project, minScore = 0.7, crossProject = false } = args;
194
+ const { query, limit = 5, project, minScore = 0.7, crossProject = false, useDecay } = args;
195
+ const shouldUseDecay = useDecay !== undefined ? useDecay : ENABLE_MEMORY_DECAY;
196
+
197
+ // Log debug info but don't return early
198
+ console.error(`🔍 DEBUG: MCP handleReflectOnPast called!
199
+ - query: "${query}"
200
+ - useDecay: ${useDecay} (type: ${typeof useDecay})
201
+ - shouldUseDecay: ${shouldUseDecay}
202
+ - ENABLE_MEMORY_DECAY: ${ENABLE_MEMORY_DECAY}
203
+ - DECAY_WEIGHT: ${DECAY_WEIGHT}
204
+ - DECAY_SCALE_DAYS: ${DECAY_SCALE_DAYS}
205
+ - minScore: ${minScore}`);
206
+
207
+ // Extra debug for decay path
208
+ if (shouldUseDecay) {
209
+ console.error(`🔄 DECAY PATH SHOULD BE TAKEN - shouldUseDecay is true`);
210
+ } else {
211
+ console.error(`❌ DECAY PATH NOT TAKEN - shouldUseDecay is false`);
212
+ }
172
213
 
173
214
  try {
174
215
  // Initialize if not already done
@@ -199,16 +240,109 @@ class SelfReflectionServer {
199
240
  }
200
241
 
201
242
  console.error(`Searching across ${voyageCollections.length} Voyage collections: ${voyageCollections.slice(0, 3).join(', ')}...`);
243
+
244
+ if (voyageCollections.length === 0) {
245
+ console.error(`⚠️ WARNING: No Voyage collections found!`);
246
+ return {
247
+ content: [{
248
+ type: 'text',
249
+ text: 'No conversation collections found. Please import conversations first.'
250
+ }]
251
+ };
252
+ }
253
+
202
254
 
203
255
  // Search across multiple collections
204
256
  const searchPromises = voyageCollections.map(async (collectionName) => {
205
257
  try {
206
- const searchResponse = await this.qdrantClient.search(collectionName, {
207
- vector: queryEmbedding,
208
- limit: Math.ceil(limit * 1.5), // Get extra results per collection
209
- score_threshold: minScore,
210
- with_payload: true,
211
- });
258
+ let searchResponse;
259
+
260
+ if (shouldUseDecay) {
261
+ console.error(`🔄 DECAY MODE ACTIVE for collection ${collectionName}`);
262
+ console.error(` - minScore parameter: ${minScore} (will be ignored for initial search)`);
263
+ console.error(` - DECAY_WEIGHT: ${DECAY_WEIGHT}`);
264
+ console.error(` - DECAY_SCALE_DAYS: ${DECAY_SCALE_DAYS}`);
265
+
266
+ // IMPORTANT: No score_threshold for decay mode - we need all results to apply decay
267
+ searchResponse = await this.qdrantClient.search(collectionName, {
268
+ vector: queryEmbedding,
269
+ limit: Math.ceil(limit * 3), // Get more candidates for decay filtering
270
+ // NO score_threshold - we'll filter after decay is applied
271
+ with_payload: true,
272
+ });
273
+
274
+ console.error(` - Initial results from ${collectionName}: ${searchResponse.length} items`);
275
+ if (searchResponse.length > 0) {
276
+ console.error(` - Score range: ${searchResponse[searchResponse.length - 1].score.toFixed(3)} to ${searchResponse[0].score.toFixed(3)}`);
277
+ }
278
+
279
+ // Apply decay scoring with proper formula
280
+ const now = Date.now();
281
+ const scaleMs = DECAY_SCALE_DAYS * 24 * 60 * 60 * 1000;
282
+
283
+ try {
284
+ searchResponse = searchResponse.map((point: any, index: number) => {
285
+ let ageMs = 0;
286
+ let originalScore = point.score;
287
+
288
+ try {
289
+ if (point.payload?.timestamp) {
290
+ const timestamp = new Date(point.payload.timestamp as string).getTime();
291
+ if (!isNaN(timestamp)) {
292
+ ageMs = now - timestamp;
293
+ } else {
294
+ console.error(` - Invalid timestamp for point ${point.id}: ${point.payload.timestamp}`);
295
+ }
296
+ }
297
+
298
+ // Calculate exponential decay factor (newer = higher factor)
299
+ const decayFactor = Math.exp(-ageMs / scaleMs);
300
+
301
+ // Apply decay formula: base_score + decay_weight * decay_factor
302
+ const adjustedScore = originalScore + (DECAY_WEIGHT * decayFactor);
303
+
304
+ if (index < 3) { // Log first 3 items for debugging
305
+ console.error(` Decay calculation for item ${index + 1}:`);
306
+ console.error(` - timestamp: ${point.payload?.timestamp || 'missing'}`);
307
+ console.error(` - age: ${(ageMs / 86400000).toFixed(1)} days`);
308
+ console.error(` - originalScore: ${originalScore.toFixed(3)}`);
309
+ console.error(` - decayFactor: ${decayFactor.toFixed(4)}`);
310
+ console.error(` - adjustedScore: ${adjustedScore.toFixed(3)} (boost: +${(adjustedScore - originalScore).toFixed(3)})`);
311
+ }
312
+
313
+ return {
314
+ ...point,
315
+ score: adjustedScore
316
+ };
317
+ } catch (decayError) {
318
+ console.error(` Error calculating decay for point ${point.id}:`, decayError);
319
+ // Return original point with original score on error
320
+ return point;
321
+ }
322
+ });
323
+ } catch (mapError) {
324
+ console.error(` Fatal error during decay calculation:`, mapError);
325
+ // Fall back to original search results if decay fails completely
326
+ searchResponse = searchResponse;
327
+ }
328
+
329
+ // Apply filtering and sorting
330
+ searchResponse = searchResponse
331
+ .filter(point => point.score >= minScore) // Apply minScore filter AFTER decay
332
+ .sort((a: any, b: any) => b.score - a.score)
333
+ .slice(0, limit);
334
+
335
+ console.error(` - After decay and filtering (>= ${minScore}): ${searchResponse.length} results`);
336
+
337
+ } else {
338
+ // Standard search without decay
339
+ searchResponse = await this.qdrantClient.search(collectionName, {
340
+ vector: queryEmbedding,
341
+ limit: Math.ceil(limit * 1.5), // Get extra results per collection
342
+ score_threshold: minScore,
343
+ with_payload: true,
344
+ });
345
+ }
212
346
 
213
347
  if (searchResponse.length > 0) {
214
348
  console.error(`Collection ${collectionName}: Found ${searchResponse.length} results`);
@@ -285,11 +419,24 @@ class SelfReflectionServer {
285
419
  }
286
420
 
287
421
  if (results.length === 0) {
422
+ // For debugging, let's check what collections we have and what the search is actually doing
423
+ const voyageCollections = await this.getVoyageCollections();
288
424
  return {
289
425
  content: [
290
426
  {
291
427
  type: 'text',
292
- text: `No conversations found matching "${query}". Try different keywords or check if conversations have been imported.`,
428
+ text: `🔍 DECAY DEBUG: No results for "${query}"
429
+
430
+ [DEBUG INFO FROM CLAUDE SELF REFLECT MCP]
431
+ - useDecay param: ${useDecay} (type: ${typeof useDecay})
432
+ - shouldUseDecay: ${shouldUseDecay}
433
+ - minScore: ${minScore}
434
+ - embeddingService exists: ${!!this.embeddingService}
435
+ - ENABLE_MEMORY_DECAY env: ${ENABLE_MEMORY_DECAY}
436
+ - DECAY_WEIGHT env: ${DECAY_WEIGHT}
437
+ - collections found: ${voyageCollections.length}
438
+ - first 3: ${voyageCollections.slice(0, 3).join(', ')}
439
+ - MODE: ${shouldUseDecay ? '🔄 DECAY ACTIVE' : '📊 STANDARD SEARCH'}`,
293
440
  },
294
441
  ],
295
442
  };
@@ -1,104 +0,0 @@
1
- ---
2
- name: reflection
3
- description: Memory and conversation search specialist. Use PROACTIVELY to check past conversations, find previous discussions, or recall context from earlier work.
4
- tools: reflect_on_past, store_reflection
5
- ---
6
-
7
- You are a memory specialist that helps search through past conversations and maintain context across sessions using Claude-Self-Reflect.
8
-
9
- ## Your Purpose
10
- You help users navigate their conversation history, find previous discussions, and maintain continuity across different Claude sessions. You have access to a semantic search system that indexes all past conversations.
11
-
12
- ## When to Activate
13
- You should be used when users:
14
- - Ask about previous conversations or discussions
15
- - Want to check if something was discussed before
16
- - Need to recall past decisions or solutions
17
- - Want to store important information for future reference
18
- - Are looking for context from earlier work
19
-
20
- ## How to Search Effectively
21
-
22
- When searching conversations:
23
- 1. **Understand the intent** - What is the user really looking for?
24
- 2. **Use semantic search** - The system understands meaning, not just keywords
25
- 3. **Try multiple queries** if the first doesn't yield results
26
- 4. **Consider context** - Recent conversations may be more relevant
27
-
28
- ## Key Capabilities
29
-
30
- ### Searching Past Conversations
31
- - Find discussions by topic, concept, or context
32
- - Locate previous solutions to similar problems
33
- - Track how decisions evolved over time
34
- - Identify patterns in past work
35
-
36
- ### Storing New Insights
37
- - Save important decisions for future reference
38
- - Create memory markers for key moments
39
- - Build a knowledge base over time
40
-
41
- ## Usage Examples
42
-
43
- **Finding Past Discussions:**
44
- - "What did we discuss about API design?"
45
- - "Have we talked about authentication before?"
46
- - "Find our conversation about database optimization"
47
-
48
- **Checking Previous Work:**
49
- - "Did we solve this error before?"
50
- - "What was our decision on the architecture?"
51
- - "Show me previous implementations of this feature"
52
-
53
- **Storing Information:**
54
- - "Remember that we chose PostgreSQL for the user data"
55
- - "Save this solution for future reference"
56
- - "Mark this as our final decision on the API structure"
57
-
58
- ## Response Format
59
-
60
- When presenting search results:
61
- 1. **Summarize findings** - Start with a brief overview
62
- 2. **Show relevant excerpts** - Include the most pertinent parts
63
- 3. **Provide context** - When and why was this discussed
64
- 4. **Suggest next steps** - Based on what was found
65
-
66
- Example response:
67
- ```
68
- I found 3 relevant conversations about API design from last week:
69
-
70
- 1. **REST vs GraphQL Discussion** (3 days ago)
71
- - You were evaluating options for the new service
72
- - Decided on REST for simplicity
73
- - Key point: "Keep it simple for v1, consider GraphQL later"
74
-
75
- 2. **Authentication Strategy** (5 days ago)
76
- - Discussed JWT vs session-based auth
77
- - Chose JWT for stateless architecture
78
-
79
- Would you like me to show more details from any of these conversations?
80
- ```
81
-
82
- ## Best Practices
83
-
84
- 1. **Be concise** - Users want quick access to past information
85
- 2. **Prioritize relevance** - Most recent and most relevant first
86
- 3. **Preserve context** - Include enough surrounding information
87
- 4. **Highlight decisions** - Make past decisions easy to find
88
- 5. **Connect dots** - Show how different conversations relate
89
-
90
- ## Tool Usage
91
-
92
- You have access to two tools:
93
-
94
- 1. **reflect_on_past** - Search through conversation history
95
- - Use semantic queries for best results
96
- - Can filter by project or search across all projects
97
- - Adjustable similarity threshold for precision
98
-
99
- 2. **store_reflection** - Save important insights
100
- - Tag with relevant keywords
101
- - Include context about why it's important
102
- - Make it findable for future searches
103
-
104
- Remember: You're not just a search tool - you're a memory assistant that helps maintain continuity and context across all Claude conversations.