claude-self-reflect 1.1.3 → 1.3.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.
@@ -95,10 +95,60 @@ You have access to two tools:
95
95
  - Use semantic queries for best results
96
96
  - Can filter by project or search across all projects
97
97
  - Adjustable similarity threshold for precision
98
+ - Set `useDecay` to true/false to control time-based relevance
98
99
 
99
100
  2. **store_reflection** - Save important insights
100
101
  - Tag with relevant keywords
101
102
  - Include context about why it's important
102
103
  - Make it findable for future searches
103
104
 
105
+ ## Understanding Score Thresholds
106
+
107
+ When using `reflect_on_past`, understanding score ranges is crucial:
108
+
109
+ ### Typical Score Ranges
110
+ - **0.0 - 0.2**: Very low similarity, rarely useful
111
+ - **0.2 - 0.4**: Moderate similarity, often contains relevant results
112
+ - **0.4 - 0.6**: Good similarity, usually highly relevant
113
+ - **0.6 - 0.8**: Strong similarity, very relevant matches
114
+ - **0.8 - 1.0**: Excellent match, nearly identical content
115
+
116
+ ### Important Score Insights
117
+ - Most semantic searches return scores between 0.2 and 0.5
118
+ - Setting minScore to 0.5 often filters out all results
119
+ - Start with minScore=0 to see all results, then adjust
120
+ - With memory decay enabled, scores increase by ~68% (e.g., 0.36 → 0.60)
121
+
122
+ ## MCP Troubleshooting Guide
123
+
124
+ If the MCP tools aren't working, here's what you need to know:
125
+
126
+ ### Common Issues and Solutions
127
+
128
+ 1. **Tools Not Accessible via Standard Format**
129
+ - Issue: `mcp__server__tool` format may not work
130
+ - Solution: Use direct format: `mcp__claude-self-reflection__reflect_on_past`
131
+ - The exact tool names are: `reflect_on_past` and `store_reflection`
132
+
133
+ 2. **Environment Variables Not Loading**
134
+ - The MCP server runs via `run-mcp.sh` which sources the `.env` file
135
+ - Key variables: `ENABLE_MEMORY_DECAY`, `DECAY_WEIGHT`, `DECAY_SCALE_DAYS`
136
+ - These control memory decay behavior
137
+
138
+ 3. **Changes Not Taking Effect**
139
+ - After modifying TypeScript files, run `npm run build`
140
+ - Remove and re-add the MCP server in Claude
141
+ - Use: `claude mcp remove claude-self-reflection`
142
+ - Then: `claude mcp add claude-self-reflection /path/to/run-mcp.sh`
143
+
144
+ 4. **Debugging MCP Connection**
145
+ - Check if server is connected: `claude mcp list`
146
+ - Look for: `claude-self-reflection: ✓ Connected`
147
+ - If failed, check logs for error details
148
+
149
+ ### Memory Decay Configuration
150
+ - **ENABLE_MEMORY_DECAY**: Set to `true` to enable time-based relevance
151
+ - **DECAY_WEIGHT**: 0.3 means 30% weight on recency (0-1 range)
152
+ - **DECAY_SCALE_DAYS**: 90 means 90-day half-life for memory fade
153
+
104
154
  Remember: You're not just a search tool - you're a memory assistant that helps maintain continuity and context across all Claude conversations.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'child_process';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+ import { readFileSync } from 'fs';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ // Handle command line arguments
9
+ const args = process.argv.slice(2);
10
+ const command = args[0];
11
+ if (command === 'setup') {
12
+ // Run the setup wizard
13
+ const setupPath = join(__dirname, '..', 'scripts', 'setup-wizard.js');
14
+ const child = spawn('node', [setupPath], {
15
+ stdio: 'inherit'
16
+ });
17
+ child.on('error', (error) => {
18
+ console.error('Failed to start setup wizard:', error);
19
+ process.exit(1);
20
+ });
21
+ child.on('exit', (code) => {
22
+ process.exit(code || 0);
23
+ });
24
+ }
25
+ else if (command === '--version' || command === '-v') {
26
+ // Read package.json to get version
27
+ const packagePath = join(__dirname, '..', 'package.json');
28
+ const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
29
+ console.log(pkg.version);
30
+ }
31
+ else if (command === '--help' || command === '-h' || !command) {
32
+ console.log(`
33
+ Claude Self-Reflect - Give Claude perfect memory of all your conversations
34
+
35
+ Usage:
36
+ claude-self-reflect <command>
37
+
38
+ Commands:
39
+ setup Run the interactive setup wizard
40
+
41
+ Options:
42
+ --version Show version number
43
+ --help Show this help message
44
+
45
+ Examples:
46
+ claude-self-reflect setup # Run interactive setup
47
+ npx claude-self-reflect setup # Run without installing globally
48
+ `);
49
+ }
50
+ else {
51
+ console.error(`Unknown command: ${command}`);
52
+ console.error('Run "claude-self-reflect --help" for usage information');
53
+ process.exit(1);
54
+ }
55
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,gCAAgC;AAChC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAExB,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;IACxB,uBAAuB;IACvB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE;QACvC,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;KAAM,IAAI,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;IACvD,mCAAmC;IACnC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;KAAM,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;CAgBb,CAAC,CAAC;AACH,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;IACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
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 MEMENTO STACK 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,EACtB,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAA0C,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAoD,MAAM,wBAAwB,CAAC;AAEnH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,uBAAuB,CAAC;AACrE,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,eAAe,CAAC;AACvE,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AAClD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAC7E,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,MAAM,CAAC;AAC/E,MAAM,cAAc,GAA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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,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-self-reflect",
3
- "version": "1.1.3",
3
+ "version": "1.3.0",
4
4
  "description": "Give Claude perfect memory of all your conversations - Semantic search across your entire Claude Desktop history",
5
5
  "keywords": [
6
6
  "claude",
@@ -26,11 +26,15 @@
26
26
  "main": "dist/index.js",
27
27
  "types": "dist/index.d.ts",
28
28
  "type": "module",
29
+ "bin": {
30
+ "claude-self-reflect": "./dist/cli.js"
31
+ },
29
32
  "files": [
30
33
  "dist",
31
34
  "src",
32
35
  "agents",
33
36
  "scripts/install-agent.js",
37
+ "scripts/setup-wizard.js",
34
38
  "README.md",
35
39
  "LICENSE",
36
40
  "config/claude-desktop-config.json"
@@ -52,6 +56,7 @@
52
56
  "dependencies": {
53
57
  "@modelcontextprotocol/sdk": "^0.5.0",
54
58
  "@qdrant/js-client-rest": "^1.7.0",
59
+ "dotenv": "^17.2.1",
55
60
  "node-fetch": "^3.3.2"
56
61
  },
57
62
  "devDependencies": {
@@ -0,0 +1,596 @@
1
+ #!/usr/bin/env node
2
+ import readline from 'readline';
3
+ import { execSync, spawn } from 'child_process';
4
+ import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
5
+ import { join, dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ import { homedir } from 'os';
8
+ import https from 'https';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
12
+
13
+ const rl = readline.createInterface({
14
+ input: process.stdin,
15
+ output: process.stdout
16
+ });
17
+
18
+ // ANSI color codes
19
+ const colors = {
20
+ reset: '\x1b[0m',
21
+ green: '\x1b[32m',
22
+ yellow: '\x1b[33m',
23
+ blue: '\x1b[34m',
24
+ red: '\x1b[31m',
25
+ cyan: '\x1b[36m'
26
+ };
27
+
28
+ function question(prompt) {
29
+ return new Promise((resolve) => {
30
+ rl.question(prompt, resolve);
31
+ });
32
+ }
33
+
34
+ function success(message) {
35
+ console.log(`${colors.green}✅ ${message}${colors.reset}`);
36
+ }
37
+
38
+ function info(message) {
39
+ console.log(`${colors.blue}ℹ️ ${message}${colors.reset}`);
40
+ }
41
+
42
+ function warning(message) {
43
+ console.log(`${colors.yellow}⚠️ ${message}${colors.reset}`);
44
+ }
45
+
46
+ function error(message) {
47
+ console.log(`${colors.red}❌ ${message}${colors.reset}`);
48
+ }
49
+
50
+ function header(message) {
51
+ console.log(`\n${colors.cyan}${'='.repeat(60)}${colors.reset}`);
52
+ console.log(`${colors.cyan}${message}${colors.reset}`);
53
+ console.log(`${colors.cyan}${'='.repeat(60)}${colors.reset}\n`);
54
+ }
55
+
56
+ async function checkCommand(command) {
57
+ try {
58
+ execSync(`which ${command}`, { stdio: 'ignore' });
59
+ return true;
60
+ } catch {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ async function checkDocker() {
66
+ if (!await checkCommand('docker')) {
67
+ return { installed: false };
68
+ }
69
+
70
+ try {
71
+ execSync('docker info', { stdio: 'ignore' });
72
+ return { installed: true, running: true };
73
+ } catch {
74
+ return { installed: true, running: false };
75
+ }
76
+ }
77
+
78
+ async function checkPython() {
79
+ const commands = ['python3', 'python'];
80
+ for (const cmd of commands) {
81
+ if (await checkCommand(cmd)) {
82
+ try {
83
+ const version = execSync(`${cmd} --version`, { encoding: 'utf8' }).trim();
84
+ return { installed: true, command: cmd, version };
85
+ } catch {}
86
+ }
87
+ }
88
+ return { installed: false };
89
+ }
90
+
91
+ async function validateApiKey(provider, apiKey) {
92
+ return new Promise((resolve) => {
93
+ if (!apiKey || apiKey.length < 10) {
94
+ resolve(false);
95
+ return;
96
+ }
97
+
98
+ let options;
99
+ switch (provider) {
100
+ case 'voyage':
101
+ options = {
102
+ hostname: 'api.voyageai.com',
103
+ path: '/v1/models',
104
+ method: 'GET',
105
+ headers: {
106
+ 'Authorization': `Bearer ${apiKey}`
107
+ }
108
+ };
109
+ break;
110
+ case 'openai':
111
+ options = {
112
+ hostname: 'api.openai.com',
113
+ path: '/v1/models',
114
+ method: 'GET',
115
+ headers: {
116
+ 'Authorization': `Bearer ${apiKey}`
117
+ }
118
+ };
119
+ break;
120
+ case 'gemini':
121
+ // Gemini uses a different validation approach
122
+ resolve(apiKey.startsWith('AI') && apiKey.length > 20);
123
+ return;
124
+ default:
125
+ resolve(true);
126
+ return;
127
+ }
128
+
129
+ const req = https.request(options, (res) => {
130
+ resolve(res.statusCode === 200);
131
+ });
132
+
133
+ req.on('error', () => resolve(false));
134
+ req.setTimeout(5000, () => {
135
+ req.destroy();
136
+ resolve(false);
137
+ });
138
+ req.end();
139
+ });
140
+ }
141
+
142
+ async function setupQdrant() {
143
+ header('Setting up Qdrant Vector Database');
144
+
145
+ const docker = await checkDocker();
146
+
147
+ if (!docker.installed) {
148
+ error('Docker is not installed');
149
+ console.log('\nTo install Docker:');
150
+ console.log('1. Visit https://docs.docker.com/get-docker/');
151
+ console.log('2. Download Docker Desktop for your platform');
152
+ console.log('3. Run the installer and start Docker');
153
+ console.log('4. Run this setup again\n');
154
+
155
+ const proceed = await question('Would you like to continue without Docker? (y/n): ');
156
+ if (proceed.toLowerCase() !== 'y') {
157
+ return false;
158
+ }
159
+
160
+ warning('Continuing without vector database - search functionality will be limited');
161
+ return true;
162
+ }
163
+
164
+ if (!docker.running) {
165
+ error('Docker is installed but not running');
166
+ console.log('Please start Docker Desktop and run this setup again\n');
167
+ return false;
168
+ }
169
+
170
+ // Check if Qdrant is already running
171
+ try {
172
+ execSync('docker ps | grep qdrant', { stdio: 'ignore' });
173
+ success('Qdrant is already running');
174
+ return true;
175
+ } catch {
176
+ // Not running, let's start it
177
+ }
178
+
179
+ info('Starting Qdrant container...');
180
+ try {
181
+ execSync('docker run -d --name qdrant -p 6333:6333 --restart always qdrant/qdrant:latest', {
182
+ stdio: 'inherit'
183
+ });
184
+ success('Qdrant started successfully');
185
+ return true;
186
+ } catch (err) {
187
+ // Container might already exist but be stopped
188
+ try {
189
+ execSync('docker start qdrant', { stdio: 'inherit' });
190
+ success('Qdrant restarted successfully');
191
+ return true;
192
+ } catch {
193
+ error('Failed to start Qdrant');
194
+ return false;
195
+ }
196
+ }
197
+ }
198
+
199
+ async function selectEmbeddingProvider() {
200
+ header('Choose Your Embedding Provider');
201
+
202
+ console.log('Embedding models convert your conversations into searchable vectors.\n');
203
+
204
+ console.log(`${colors.green}1. Voyage AI (Recommended)${colors.reset}`);
205
+ console.log(' ✅ 200M tokens FREE - covers most users completely');
206
+ console.log(' ✅ Best quality for conversation search');
207
+ console.log(' ✅ Only $0.02/1M tokens after free tier\n');
208
+
209
+ console.log(`${colors.blue}2. Google Gemini${colors.reset}`);
210
+ console.log(' ✅ Completely FREE (unlimited usage)');
211
+ console.log(' ⚠️ Your data used to improve Google products');
212
+ console.log(' ✅ Good multilingual support\n');
213
+
214
+ console.log(`${colors.yellow}3. Local Processing${colors.reset}`);
215
+ console.log(' ✅ Completely FREE, works offline');
216
+ console.log(' ✅ No API keys, no data sharing');
217
+ console.log(' ⚠️ Lower quality results, slower processing\n');
218
+
219
+ console.log(`${colors.cyan}4. OpenAI${colors.reset}`);
220
+ console.log(' ❌ No free tier');
221
+ console.log(' ✅ $0.02/1M tokens (same as Voyage paid)');
222
+ console.log(' ✅ Good quality, established ecosystem\n');
223
+
224
+ const choice = await question('Enter your choice (1-4): ');
225
+
226
+ switch (choice) {
227
+ case '1': return 'voyage';
228
+ case '2': return 'gemini';
229
+ case '3': return 'local';
230
+ case '4': return 'openai';
231
+ default:
232
+ warning('Invalid choice, defaulting to Voyage AI');
233
+ return 'voyage';
234
+ }
235
+ }
236
+
237
+ async function getApiKey(provider) {
238
+ if (provider === 'local') return null;
239
+
240
+ const urls = {
241
+ voyage: 'https://dash.voyageai.com/',
242
+ gemini: 'https://ai.google.dev/gemini-api/docs',
243
+ openai: 'https://platform.openai.com/api-keys'
244
+ };
245
+
246
+ console.log(`\nTo get your API key, visit: ${colors.blue}${urls[provider]}${colors.reset}`);
247
+
248
+ let apiKey;
249
+ let valid = false;
250
+
251
+ while (!valid) {
252
+ apiKey = await question(`Enter your ${provider.toUpperCase()} API key: `);
253
+
254
+ if (!apiKey) {
255
+ const skip = await question('Skip API key for now? (y/n): ');
256
+ if (skip.toLowerCase() === 'y') {
257
+ return null;
258
+ }
259
+ continue;
260
+ }
261
+
262
+ info('Validating API key...');
263
+ valid = await validateApiKey(provider, apiKey);
264
+
265
+ if (valid) {
266
+ success('API key validated successfully');
267
+ } else {
268
+ error('Invalid API key. Please check and try again.');
269
+ }
270
+ }
271
+
272
+ return apiKey;
273
+ }
274
+
275
+ async function setupPython() {
276
+ header('Setting up Python Dependencies');
277
+
278
+ const python = await checkPython();
279
+
280
+ if (!python.installed) {
281
+ error('Python is not installed');
282
+ console.log('\nTo install Python:');
283
+ console.log('1. Visit https://www.python.org/downloads/');
284
+ console.log('2. Download Python 3.8 or later');
285
+ console.log('3. Run the installer\n');
286
+ return false;
287
+ }
288
+
289
+ success(`Found ${python.version}`);
290
+
291
+ // Clone the repository if needed
292
+ const repoPath = join(homedir(), '.claude-self-reflect');
293
+
294
+ if (!existsSync(repoPath)) {
295
+ info('Downloading import scripts...');
296
+ try {
297
+ execSync(`git clone https://github.com/ramakay/claude-self-reflect.git "${repoPath}"`, {
298
+ stdio: 'inherit'
299
+ });
300
+ success('Downloaded import scripts');
301
+ } catch {
302
+ error('Failed to download import scripts');
303
+ return false;
304
+ }
305
+ }
306
+
307
+ // Install Python dependencies
308
+ info('Installing Python dependencies...');
309
+ const requirementsPath = join(repoPath, 'scripts', 'requirements.txt');
310
+
311
+ try {
312
+ execSync(`${python.command} -m pip install -r "${requirementsPath}"`, {
313
+ stdio: 'inherit',
314
+ cwd: repoPath
315
+ });
316
+ success('Python dependencies installed');
317
+ return { command: python.command, repoPath };
318
+ } catch {
319
+ error('Failed to install Python dependencies');
320
+ warning('You may need to install pip or run with administrator privileges');
321
+ return false;
322
+ }
323
+ }
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
+
374
+ async function saveConfiguration(config) {
375
+ const envPath = join(homedir(), '.claude-self-reflect', '.env');
376
+ const envDir = dirname(envPath);
377
+
378
+ if (!existsSync(envDir)) {
379
+ mkdirSync(envDir, { recursive: true });
380
+ }
381
+
382
+ let envContent = '# Claude Self-Reflect Configuration\n';
383
+ envContent += '# Generated by setup wizard\n\n';
384
+
385
+ if (config.provider === 'voyage' && config.apiKey) {
386
+ envContent += `VOYAGE_API_KEY="${config.apiKey}"\n`;
387
+ } else if (config.provider === 'gemini' && config.apiKey) {
388
+ envContent += `GEMINI_API_KEY="${config.apiKey}"\n`;
389
+ } else if (config.provider === 'openai' && config.apiKey) {
390
+ envContent += `OPENAI_API_KEY="${config.apiKey}"\n`;
391
+ } else if (config.provider === 'local') {
392
+ envContent += 'USE_LOCAL_EMBEDDINGS=true\n';
393
+ }
394
+
395
+ envContent += 'QDRANT_URL=http://localhost:6333\n';
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
+
405
+ writeFileSync(envPath, envContent);
406
+ success(`Configuration saved to ${envPath}`);
407
+ }
408
+
409
+ async function runImport(pythonConfig, provider, apiKey) {
410
+ header('Importing Conversation History');
411
+
412
+ const claudeLogsPath = join(homedir(), '.claude', 'projects');
413
+
414
+ if (!existsSync(claudeLogsPath)) {
415
+ warning('No Claude conversation logs found at ~/.claude/projects');
416
+ console.log('Make sure you have used Claude Desktop and have some conversations');
417
+ return;
418
+ }
419
+
420
+ info('Scanning for conversation files...');
421
+ const scriptPath = join(pythonConfig.repoPath, 'scripts', 'import-openai-enhanced.py');
422
+
423
+ // Set environment variables for the import
424
+ const env = { ...process.env };
425
+ if (provider === 'voyage' && apiKey) {
426
+ env.VOYAGE_API_KEY = apiKey;
427
+ } else if (provider === 'gemini' && apiKey) {
428
+ env.GEMINI_API_KEY = apiKey;
429
+ } else if (provider === 'openai' && apiKey) {
430
+ env.OPENAI_API_KEY = apiKey;
431
+ } else if (provider === 'local') {
432
+ env.USE_LOCAL_EMBEDDINGS = 'true';
433
+ }
434
+
435
+ const importProcess = spawn(pythonConfig.command, [scriptPath], {
436
+ cwd: pythonConfig.repoPath,
437
+ env,
438
+ stdio: 'inherit'
439
+ });
440
+
441
+ return new Promise((resolve) => {
442
+ importProcess.on('close', (code) => {
443
+ if (code === 0) {
444
+ success('Import completed successfully');
445
+ resolve(true);
446
+ } else {
447
+ error('Import failed');
448
+ resolve(false);
449
+ }
450
+ });
451
+ });
452
+ }
453
+
454
+ async function setupClaudeDesktop(memoryDecayConfig) {
455
+ header('Configure Claude Desktop (Optional)');
456
+
457
+ console.log('To use this with Claude Desktop, add the following to your config:\n');
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
+
470
+ const config = {
471
+ mcpServers: {
472
+ 'claude-self-reflect': {
473
+ command: 'npx',
474
+ args: ['claude-self-reflect'],
475
+ env
476
+ }
477
+ }
478
+ };
479
+
480
+ console.log(JSON.stringify(config, null, 2));
481
+
482
+ console.log('\nConfig file location:');
483
+ console.log('- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json');
484
+ console.log('- Windows: %APPDATA%\\Claude\\claude_desktop_config.json');
485
+ console.log('- Linux: ~/.config/Claude/claude_desktop_config.json\n');
486
+
487
+ const configure = await question('Would you like to automatically configure Claude Desktop? (y/n): ');
488
+
489
+ if (configure.toLowerCase() === 'y') {
490
+ // Detect platform and find config file
491
+ const platform = process.platform;
492
+ let configPath;
493
+
494
+ if (platform === 'darwin') {
495
+ configPath = join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
496
+ } else if (platform === 'win32') {
497
+ configPath = join(process.env.APPDATA, 'Claude', 'claude_desktop_config.json');
498
+ } else {
499
+ configPath = join(homedir(), '.config', 'Claude', 'claude_desktop_config.json');
500
+ }
501
+
502
+ try {
503
+ let existingConfig = {};
504
+ if (existsSync(configPath)) {
505
+ existingConfig = JSON.parse(readFileSync(configPath, 'utf8'));
506
+ }
507
+
508
+ // Merge configurations
509
+ existingConfig.mcpServers = existingConfig.mcpServers || {};
510
+ existingConfig.mcpServers['claude-self-reflect'] = config.mcpServers['claude-self-reflect'];
511
+
512
+ // Ensure directory exists
513
+ mkdirSync(dirname(configPath), { recursive: true });
514
+
515
+ // Write config
516
+ writeFileSync(configPath, JSON.stringify(existingConfig, null, 2));
517
+ success('Claude Desktop configured successfully');
518
+ info('Restart Claude Desktop to use the new configuration');
519
+ } catch (err) {
520
+ error('Failed to configure Claude Desktop automatically');
521
+ console.log('Please add the configuration manually');
522
+ }
523
+ }
524
+ }
525
+
526
+ async function main() {
527
+ console.clear();
528
+ header('🚀 Claude Self-Reflect Setup Wizard');
529
+
530
+ console.log('This wizard will help you set up Claude Self-Reflect in just a few minutes.\n');
531
+
532
+ // Step 1: Check and setup Qdrant
533
+ const qdrantOk = await setupQdrant();
534
+ if (!qdrantOk) {
535
+ error('Setup incomplete. Please fix the issues and try again.');
536
+ rl.close();
537
+ process.exit(1);
538
+ }
539
+
540
+ // Step 2: Select embedding provider
541
+ const provider = await selectEmbeddingProvider();
542
+
543
+ // Step 3: Get API key
544
+ const apiKey = await getApiKey(provider);
545
+
546
+ // Step 4: Setup Python
547
+ const pythonConfig = await setupPython();
548
+ if (!pythonConfig) {
549
+ error('Setup incomplete. Please fix the issues and try again.');
550
+ rl.close();
551
+ process.exit(1);
552
+ }
553
+
554
+ // Step 5: Configure memory decay
555
+ const memoryDecay = await configureMemoryDecay();
556
+
557
+ // Step 6: Save configuration
558
+ await saveConfiguration({ provider, apiKey, memoryDecay });
559
+
560
+ // Step 7: Run import
561
+ if (apiKey || provider === 'local') {
562
+ const runImportNow = await question('\nWould you like to import your conversation history now? (y/n): ');
563
+ if (runImportNow.toLowerCase() === 'y') {
564
+ await runImport(pythonConfig, provider, apiKey);
565
+ }
566
+ }
567
+
568
+ // Step 8: Configure Claude Desktop
569
+ await setupClaudeDesktop(memoryDecay);
570
+
571
+ // Done!
572
+ header('✨ Setup Complete!');
573
+
574
+ console.log('Next steps:');
575
+ console.log('1. If using Claude Code, the reflection agent is already available');
576
+ console.log('2. Try asking: "Find our previous discussions about [topic]"');
577
+ console.log('3. To re-run import later: python scripts/import-openai-enhanced.py\n');
578
+
579
+ success('Happy reflecting! 🎉');
580
+
581
+ rl.close();
582
+ }
583
+
584
+ // Handle errors gracefully
585
+ process.on('unhandledRejection', (error) => {
586
+ console.error('\nSetup failed with error:', error);
587
+ rl.close();
588
+ process.exit(1);
589
+ });
590
+
591
+ // Run the wizard
592
+ main().catch((error) => {
593
+ console.error('\nSetup failed:', error);
594
+ rl.close();
595
+ process.exit(1);
596
+ });
package/src/cli.ts ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'child_process';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+ import { readFileSync } from 'fs';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+
10
+ // Handle command line arguments
11
+ const args = process.argv.slice(2);
12
+ const command = args[0];
13
+
14
+ if (command === 'setup') {
15
+ // Run the setup wizard
16
+ const setupPath = join(__dirname, '..', 'scripts', 'setup-wizard.js');
17
+ const child = spawn('node', [setupPath], {
18
+ stdio: 'inherit'
19
+ });
20
+
21
+ child.on('error', (error) => {
22
+ console.error('Failed to start setup wizard:', error);
23
+ process.exit(1);
24
+ });
25
+
26
+ child.on('exit', (code) => {
27
+ process.exit(code || 0);
28
+ });
29
+ } else if (command === '--version' || command === '-v') {
30
+ // Read package.json to get version
31
+ const packagePath = join(__dirname, '..', 'package.json');
32
+ const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
33
+ console.log(pkg.version);
34
+ } else if (command === '--help' || command === '-h' || !command) {
35
+ console.log(`
36
+ Claude Self-Reflect - Give Claude perfect memory of all your conversations
37
+
38
+ Usage:
39
+ claude-self-reflect <command>
40
+
41
+ Commands:
42
+ setup Run the interactive setup wizard
43
+
44
+ Options:
45
+ --version Show version number
46
+ --help Show this help message
47
+
48
+ Examples:
49
+ claude-self-reflect setup # Run interactive setup
50
+ npx claude-self-reflect setup # Run without installing globally
51
+ `);
52
+ } else {
53
+ console.error(`Unknown command: ${command}`);
54
+ console.error('Run "claude-self-reflect --help" for usage information');
55
+ process.exit(1);
56
+ }
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 MEMENTO STACK 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
  };