claude-self-reflect 1.3.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/README.md +138 -0
- package/.claude/agents/docker-orchestrator.md +264 -0
- package/.claude/agents/documentation-writer.md +262 -0
- package/.claude/agents/import-debugger.md +203 -0
- package/.claude/agents/mcp-integration.md +286 -0
- package/.claude/agents/open-source-maintainer.md +150 -0
- package/.claude/agents/performance-tuner.md +276 -0
- package/.claude/agents/qdrant-specialist.md +138 -0
- package/.claude/agents/reflection-specialist.md +361 -0
- package/.claude/agents/search-optimizer.md +307 -0
- package/LICENSE +21 -0
- package/README.md +363 -0
- package/installer/cli.js +122 -0
- package/installer/postinstall.js +13 -0
- package/installer/setup-wizard.js +204 -0
- package/mcp-server/pyproject.toml +27 -0
- package/mcp-server/run-mcp.sh +21 -0
- package/mcp-server/src/__init__.py +1 -0
- package/mcp-server/src/__main__.py +23 -0
- package/mcp-server/src/server.py +316 -0
- package/mcp-server/src/server_v2.py +240 -0
- package/package.json +12 -36
- package/scripts/import-conversations-isolated.py +311 -0
- package/scripts/import-conversations-voyage-streaming.py +377 -0
- package/scripts/import-conversations-voyage.py +428 -0
- package/scripts/import-conversations.py +240 -0
- package/scripts/import-current-conversation.py +38 -0
- package/scripts/import-live-conversation.py +152 -0
- package/scripts/import-openai-enhanced.py +867 -0
- package/scripts/import-recent-only.py +29 -0
- package/scripts/import-single-project.py +278 -0
- package/scripts/import-watcher.py +169 -0
- package/config/claude-desktop-config.json +0 -12
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -55
- package/dist/cli.js.map +0 -1
- package/dist/embeddings-gemini.d.ts +0 -76
- package/dist/embeddings-gemini.d.ts.map +0 -1
- package/dist/embeddings-gemini.js +0 -158
- package/dist/embeddings-gemini.js.map +0 -1
- package/dist/embeddings.d.ts +0 -67
- package/dist/embeddings.d.ts.map +0 -1
- package/dist/embeddings.js +0 -252
- package/dist/embeddings.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -439
- package/dist/index.js.map +0 -1
- package/dist/project-isolation.d.ts +0 -29
- package/dist/project-isolation.d.ts.map +0 -1
- package/dist/project-isolation.js +0 -78
- package/dist/project-isolation.js.map +0 -1
- package/scripts/install-agent.js +0 -70
- package/scripts/setup-wizard.js +0 -596
- package/src/cli.ts +0 -56
- package/src/embeddings-gemini.ts +0 -176
- package/src/embeddings.ts +0 -296
- package/src/index.ts +0 -513
- package/src/project-isolation.ts +0 -93
package/dist/index.js
DELETED
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
6
|
-
import { createEmbeddingService } from './embeddings.js';
|
|
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') });
|
|
16
|
-
const QDRANT_URL = process.env.QDRANT_URL || 'http://localhost:6333';
|
|
17
|
-
const COLLECTION_NAME = process.env.COLLECTION_NAME || 'conversations';
|
|
18
|
-
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
|
19
|
-
const VOYAGE_API_KEY = process.env.VOYAGE_KEY || process.env['VOYAGE_KEY-2'];
|
|
20
|
-
const PREFER_LOCAL_EMBEDDINGS = process.env.PREFER_LOCAL_EMBEDDINGS === 'true';
|
|
21
|
-
const ISOLATION_MODE = process.env.ISOLATION_MODE || 'hybrid';
|
|
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})`);
|
|
31
|
-
class SelfReflectionServer {
|
|
32
|
-
server;
|
|
33
|
-
qdrantClient;
|
|
34
|
-
embeddingService;
|
|
35
|
-
collectionInfo;
|
|
36
|
-
isolationManager;
|
|
37
|
-
currentProject;
|
|
38
|
-
constructor() {
|
|
39
|
-
this.server = new Server({
|
|
40
|
-
name: 'claude-self-reflection',
|
|
41
|
-
version: '0.1.0',
|
|
42
|
-
}, {
|
|
43
|
-
capabilities: {
|
|
44
|
-
tools: {},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
this.qdrantClient = new QdrantClient({ url: QDRANT_URL });
|
|
48
|
-
// Initialize project isolation
|
|
49
|
-
const isolationConfig = {
|
|
50
|
-
mode: ISOLATION_MODE,
|
|
51
|
-
allowCrossProject: ALLOW_CROSS_PROJECT,
|
|
52
|
-
projectIdentifier: ProjectIsolationManager.detectCurrentProject()
|
|
53
|
-
};
|
|
54
|
-
this.isolationManager = new ProjectIsolationManager(this.qdrantClient, isolationConfig);
|
|
55
|
-
this.currentProject = isolationConfig.projectIdentifier;
|
|
56
|
-
this.setupToolHandlers();
|
|
57
|
-
}
|
|
58
|
-
async initialize() {
|
|
59
|
-
try {
|
|
60
|
-
// Create embedding service with Voyage AI if available
|
|
61
|
-
this.embeddingService = await createEmbeddingService({
|
|
62
|
-
openaiApiKey: OPENAI_API_KEY,
|
|
63
|
-
voyageApiKey: VOYAGE_API_KEY,
|
|
64
|
-
preferLocal: PREFER_LOCAL_EMBEDDINGS,
|
|
65
|
-
});
|
|
66
|
-
// For Voyage collections, we don't need to check dimensions as they're consistent
|
|
67
|
-
if (this.embeddingService.getModelName().includes('voyage')) {
|
|
68
|
-
console.error('Using Voyage AI embeddings for search across project collections');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error('Failed to initialize embedding service:', error);
|
|
73
|
-
console.error('Server will run in degraded mode with text-based search');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
setupToolHandlers() {
|
|
77
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
78
|
-
tools: [
|
|
79
|
-
{
|
|
80
|
-
name: 'reflect_on_past',
|
|
81
|
-
description: 'Search for relevant past conversations using semantic search',
|
|
82
|
-
inputSchema: {
|
|
83
|
-
type: 'object',
|
|
84
|
-
properties: {
|
|
85
|
-
query: {
|
|
86
|
-
type: 'string',
|
|
87
|
-
description: 'The search query to find semantically similar conversations',
|
|
88
|
-
},
|
|
89
|
-
limit: {
|
|
90
|
-
type: 'number',
|
|
91
|
-
description: 'Maximum number of results to return (default: 5)',
|
|
92
|
-
default: 5,
|
|
93
|
-
},
|
|
94
|
-
project: {
|
|
95
|
-
type: 'string',
|
|
96
|
-
description: 'Filter by project name (optional)',
|
|
97
|
-
},
|
|
98
|
-
crossProject: {
|
|
99
|
-
type: 'boolean',
|
|
100
|
-
description: 'Search across all projects (default: false, requires permission)',
|
|
101
|
-
default: false,
|
|
102
|
-
},
|
|
103
|
-
minScore: {
|
|
104
|
-
type: 'number',
|
|
105
|
-
description: 'Minimum similarity score (0-1, default: 0.7)',
|
|
106
|
-
default: 0.7,
|
|
107
|
-
},
|
|
108
|
-
useDecay: {
|
|
109
|
-
type: 'boolean',
|
|
110
|
-
description: 'Apply time-based decay to prioritize recent memories (default: uses environment setting)',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
required: ['query'],
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: 'store_reflection',
|
|
118
|
-
description: 'Store an important insight or reflection for future reference',
|
|
119
|
-
inputSchema: {
|
|
120
|
-
type: 'object',
|
|
121
|
-
properties: {
|
|
122
|
-
content: {
|
|
123
|
-
type: 'string',
|
|
124
|
-
description: 'The insight or reflection to store',
|
|
125
|
-
},
|
|
126
|
-
tags: {
|
|
127
|
-
type: 'array',
|
|
128
|
-
items: { type: 'string' },
|
|
129
|
-
description: 'Tags to categorize this reflection',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
required: ['content'],
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
}));
|
|
137
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
138
|
-
if (request.params.name === 'reflect_on_past') {
|
|
139
|
-
return this.handleReflectOnPast(request.params.arguments);
|
|
140
|
-
}
|
|
141
|
-
else if (request.params.name === 'store_reflection') {
|
|
142
|
-
return this.handleStoreReflection(request.params.arguments);
|
|
143
|
-
}
|
|
144
|
-
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
async getVoyageCollections() {
|
|
148
|
-
try {
|
|
149
|
-
const collections = await this.qdrantClient.getCollections();
|
|
150
|
-
return collections.collections
|
|
151
|
-
.map(c => c.name)
|
|
152
|
-
.filter(name => name.endsWith('_voyage'));
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
console.error('Failed to get Voyage collections:', error);
|
|
156
|
-
return [];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
async handleReflectOnPast(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
|
-
}
|
|
178
|
-
try {
|
|
179
|
-
// Initialize if not already done
|
|
180
|
-
if (!this.embeddingService) {
|
|
181
|
-
await this.initialize();
|
|
182
|
-
}
|
|
183
|
-
let results = [];
|
|
184
|
-
if (this.embeddingService) {
|
|
185
|
-
// Use vector search with embeddings
|
|
186
|
-
console.error(`Generating embedding for query: "${query}"`);
|
|
187
|
-
const queryEmbedding = await this.embeddingService.generateEmbedding(query);
|
|
188
|
-
// Get all Voyage collections
|
|
189
|
-
const voyageCollections = await this.getVoyageCollections();
|
|
190
|
-
if (voyageCollections.length === 0) {
|
|
191
|
-
console.error('No Voyage collections found');
|
|
192
|
-
return {
|
|
193
|
-
content: [
|
|
194
|
-
{
|
|
195
|
-
type: 'text',
|
|
196
|
-
text: `No Voyage collections found. Please run the import process first.`,
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
};
|
|
200
|
-
}
|
|
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
|
-
}
|
|
211
|
-
// Search across multiple collections
|
|
212
|
-
const searchPromises = voyageCollections.map(async (collectionName) => {
|
|
213
|
-
try {
|
|
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
|
-
}
|
|
293
|
-
if (searchResponse.length > 0) {
|
|
294
|
-
console.error(`Collection ${collectionName}: Found ${searchResponse.length} results`);
|
|
295
|
-
}
|
|
296
|
-
return searchResponse.map(point => ({
|
|
297
|
-
id: point.id,
|
|
298
|
-
score: point.score,
|
|
299
|
-
timestamp: point.payload?.timestamp || new Date().toISOString(),
|
|
300
|
-
role: point.payload?.start_role || point.payload?.role || 'unknown',
|
|
301
|
-
excerpt: (point.payload?.text || '').substring(0, 500) + '...',
|
|
302
|
-
projectName: point.payload?.project || point.payload?.project_name || point.payload?.project_id || collectionName.replace('conv_', '').replace('_voyage', ''),
|
|
303
|
-
conversationId: point.payload?.conversation_id,
|
|
304
|
-
collectionName,
|
|
305
|
-
}));
|
|
306
|
-
}
|
|
307
|
-
catch (error) {
|
|
308
|
-
console.error(`Failed to search collection ${collectionName}:`, error);
|
|
309
|
-
return [];
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
// Wait for all searches to complete
|
|
313
|
-
const allResults = await Promise.all(searchPromises);
|
|
314
|
-
// Flatten and sort by score
|
|
315
|
-
const flatResults = allResults.flat();
|
|
316
|
-
console.error(`Found ${flatResults.length} total results across all collections`);
|
|
317
|
-
results = flatResults
|
|
318
|
-
.sort((a, b) => b.score - a.score)
|
|
319
|
-
.slice(0, limit);
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
// Fallback to text search
|
|
323
|
-
console.error('Using fallback text search (no embeddings available)');
|
|
324
|
-
const voyageCollections = await this.getVoyageCollections();
|
|
325
|
-
// Search across all collections with text matching
|
|
326
|
-
const searchPromises = voyageCollections.map(async (collectionName) => {
|
|
327
|
-
try {
|
|
328
|
-
const scrollResponse = await this.qdrantClient.scroll(collectionName, {
|
|
329
|
-
limit: 100,
|
|
330
|
-
with_payload: true,
|
|
331
|
-
with_vector: false,
|
|
332
|
-
});
|
|
333
|
-
const queryWords = query.toLowerCase().split(/\s+/);
|
|
334
|
-
return scrollResponse.points
|
|
335
|
-
.filter(point => {
|
|
336
|
-
const text = (point.payload?.text || '').toLowerCase();
|
|
337
|
-
return queryWords.some((word) => text.includes(word));
|
|
338
|
-
})
|
|
339
|
-
.map(point => ({
|
|
340
|
-
id: point.id,
|
|
341
|
-
score: 0.5,
|
|
342
|
-
timestamp: point.payload?.timestamp || new Date().toISOString(),
|
|
343
|
-
role: point.payload?.start_role || point.payload?.role || 'unknown',
|
|
344
|
-
excerpt: (point.payload?.text || '').substring(0, 500) + '...',
|
|
345
|
-
projectName: point.payload?.project || point.payload?.project_name || point.payload?.project_id || collectionName.replace('conv_', '').replace('_voyage', ''),
|
|
346
|
-
conversationId: point.payload?.conversation_id,
|
|
347
|
-
collectionName,
|
|
348
|
-
}));
|
|
349
|
-
}
|
|
350
|
-
catch (error) {
|
|
351
|
-
console.error(`Failed to search collection ${collectionName}:`, error);
|
|
352
|
-
return [];
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
const allResults = await Promise.all(searchPromises);
|
|
356
|
-
results = allResults
|
|
357
|
-
.flat()
|
|
358
|
-
.slice(0, limit);
|
|
359
|
-
}
|
|
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();
|
|
363
|
-
return {
|
|
364
|
-
content: [
|
|
365
|
-
{
|
|
366
|
-
type: 'text',
|
|
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'}`,
|
|
379
|
-
},
|
|
380
|
-
],
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
const resultText = results
|
|
384
|
-
.map((result, i) => `**Result ${i + 1}** (Score: ${result.score.toFixed(3)})\n` +
|
|
385
|
-
`Time: ${new Date(result.timestamp).toLocaleString()}\n` +
|
|
386
|
-
`Project: ${result.projectName || 'unknown'}\n` +
|
|
387
|
-
`Role: ${result.role}\n` +
|
|
388
|
-
`Excerpt: ${result.excerpt}\n` +
|
|
389
|
-
`---`)
|
|
390
|
-
.join('\n\n');
|
|
391
|
-
return {
|
|
392
|
-
content: [
|
|
393
|
-
{
|
|
394
|
-
type: 'text',
|
|
395
|
-
text: `Found ${results.length} relevant conversation(s) for "${query}":\n\n${resultText}`,
|
|
396
|
-
},
|
|
397
|
-
],
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
catch (error) {
|
|
401
|
-
console.error('Error searching conversations:', error);
|
|
402
|
-
throw new McpError(ErrorCode.InternalError, `Failed to search conversations: ${error instanceof Error ? error.message : String(error)}`);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
async handleStoreReflection(args) {
|
|
406
|
-
const { content, tags = [] } = args;
|
|
407
|
-
try {
|
|
408
|
-
// This is a placeholder for now
|
|
409
|
-
// In production, we'd store this as a special type of conversation chunk
|
|
410
|
-
return {
|
|
411
|
-
content: [
|
|
412
|
-
{
|
|
413
|
-
type: 'text',
|
|
414
|
-
text: `Reflection stored successfully with tags: ${tags.join(', ') || 'none'}`,
|
|
415
|
-
},
|
|
416
|
-
],
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
catch (error) {
|
|
420
|
-
throw new McpError(ErrorCode.InternalError, `Failed to store reflection: ${error instanceof Error ? error.message : String(error)}`);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
async run() {
|
|
424
|
-
// Initialize embedding service early
|
|
425
|
-
await this.initialize();
|
|
426
|
-
const transport = new StdioServerTransport();
|
|
427
|
-
await this.server.connect(transport);
|
|
428
|
-
console.error('Claude Self-Reflection MCP server running');
|
|
429
|
-
console.error(`Connected to Qdrant at ${QDRANT_URL}`);
|
|
430
|
-
console.error(`Embedding service: ${this.embeddingService?.getModelName() || 'none (text search only)'}`);
|
|
431
|
-
console.error(`Voyage API Key: ${VOYAGE_API_KEY ? 'Set' : 'Not set'}`);
|
|
432
|
-
// Check for Voyage collections
|
|
433
|
-
const voyageCollections = await this.getVoyageCollections();
|
|
434
|
-
console.error(`Found ${voyageCollections.length} Voyage collections ready for search`);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
const server = new SelfReflectionServer();
|
|
438
|
-
server.run().catch(console.error);
|
|
439
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AACnH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,0CAA0C;AAC1C,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,mDAAmD;AACnD,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;AAE5D,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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D,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"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
2
|
-
export interface ProjectIsolationConfig {
|
|
3
|
-
mode: 'isolated' | 'shared' | 'hybrid';
|
|
4
|
-
allowCrossProject: boolean;
|
|
5
|
-
projectIdentifier?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class ProjectIsolationManager {
|
|
8
|
-
private client;
|
|
9
|
-
private config;
|
|
10
|
-
constructor(client: QdrantClient, config: ProjectIsolationConfig);
|
|
11
|
-
/**
|
|
12
|
-
* Get collection name based on isolation mode
|
|
13
|
-
*/
|
|
14
|
-
getCollectionName(projectName?: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Get project filter for queries
|
|
17
|
-
*/
|
|
18
|
-
getProjectFilter(projectName?: string): any;
|
|
19
|
-
/**
|
|
20
|
-
* Detect current project from environment
|
|
21
|
-
*/
|
|
22
|
-
static detectCurrentProject(): string | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Ensure collection exists for project
|
|
25
|
-
*/
|
|
26
|
-
ensureProjectCollection(projectName: string, vectorSize: number): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
export declare const DEFAULT_ISOLATION_CONFIG: ProjectIsolationConfig;
|
|
29
|
-
//# sourceMappingURL=project-isolation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-isolation.d.ts","sourceRoot":"","sources":["../src/project-isolation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACvC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAyB;gBAE3B,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,sBAAsB;IAKhE;;OAEG;IACH,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM;IAc/C;;OAEG;IACH,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG;IAe3C;;OAEG;IACH,MAAM,CAAC,oBAAoB,IAAI,MAAM,GAAG,SAAS;IAWjD;;OAEG;IACG,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBtF;AAED,eAAO,MAAM,wBAAwB,EAAE,sBAItC,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'crypto';
|
|
2
|
-
export class ProjectIsolationManager {
|
|
3
|
-
client;
|
|
4
|
-
config;
|
|
5
|
-
constructor(client, config) {
|
|
6
|
-
this.client = client;
|
|
7
|
-
this.config = config;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Get collection name based on isolation mode
|
|
11
|
-
*/
|
|
12
|
-
getCollectionName(projectName) {
|
|
13
|
-
if (this.config.mode === 'isolated' && projectName) {
|
|
14
|
-
// Create project-specific collection name
|
|
15
|
-
const projectHash = createHash('md5')
|
|
16
|
-
.update(projectName)
|
|
17
|
-
.digest('hex')
|
|
18
|
-
.substring(0, 8);
|
|
19
|
-
return `conv_${projectHash}`;
|
|
20
|
-
}
|
|
21
|
-
// Default to shared collection
|
|
22
|
-
return 'conversations';
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get project filter for queries
|
|
26
|
-
*/
|
|
27
|
-
getProjectFilter(projectName) {
|
|
28
|
-
if (!projectName || this.config.mode === 'shared') {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
filter: {
|
|
33
|
-
must: [{
|
|
34
|
-
key: 'project_id',
|
|
35
|
-
match: { value: projectName }
|
|
36
|
-
}]
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Detect current project from environment
|
|
42
|
-
*/
|
|
43
|
-
static detectCurrentProject() {
|
|
44
|
-
// Check environment variables
|
|
45
|
-
const fromEnv = process.env.CLAUDE_PROJECT_NAME;
|
|
46
|
-
if (fromEnv)
|
|
47
|
-
return fromEnv;
|
|
48
|
-
// Try to detect from working directory
|
|
49
|
-
const cwd = process.cwd();
|
|
50
|
-
const projectMatch = cwd.match(/\/([^\/]+)$/);
|
|
51
|
-
return projectMatch ? projectMatch[1] : undefined;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Ensure collection exists for project
|
|
55
|
-
*/
|
|
56
|
-
async ensureProjectCollection(projectName, vectorSize) {
|
|
57
|
-
const collectionName = this.getCollectionName(projectName);
|
|
58
|
-
try {
|
|
59
|
-
await this.client.getCollection(collectionName);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
// Collection doesn't exist, create it
|
|
63
|
-
await this.client.createCollection(collectionName, {
|
|
64
|
-
vectors: {
|
|
65
|
-
size: vectorSize,
|
|
66
|
-
distance: 'Cosine'
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
console.error(`Created project-specific collection: ${collectionName}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export const DEFAULT_ISOLATION_CONFIG = {
|
|
74
|
-
mode: 'hybrid',
|
|
75
|
-
allowCrossProject: false,
|
|
76
|
-
projectIdentifier: ProjectIsolationManager.detectCurrentProject()
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=project-isolation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-isolation.js","sourceRoot":"","sources":["../src/project-isolation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AASpC,MAAM,OAAO,uBAAuB;IAC1B,MAAM,CAAe;IACrB,MAAM,CAAyB;IAEvC,YAAY,MAAoB,EAAE,MAA8B;QAC9D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,WAAoB;QACpC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU,IAAI,WAAW,EAAE,CAAC;YACnD,0CAA0C;YAC1C,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC;iBAClC,MAAM,CAAC,WAAW,CAAC;iBACnB,MAAM,CAAC,KAAK,CAAC;iBACb,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACnB,OAAO,QAAQ,WAAW,EAAE,CAAC;QAC/B,CAAC;QAED,+BAA+B;QAC/B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,WAAoB;QACnC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClD,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,MAAM,EAA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DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { promises as fs } from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
|
|
10
|
-
async function installAgent() {
|
|
11
|
-
try {
|
|
12
|
-
// Get the current working directory (where npm install was run)
|
|
13
|
-
const cwd = process.cwd();
|
|
14
|
-
|
|
15
|
-
// Check if we're in the package directory itself (during development)
|
|
16
|
-
if (cwd.includes('claude-self-reflection')) {
|
|
17
|
-
console.log('📦 Skipping agent installation in package directory');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Define paths
|
|
22
|
-
const agentSource = path.join(__dirname, '..', 'agents', 'reflection.md');
|
|
23
|
-
const claudeDir = path.join(cwd, '.claude');
|
|
24
|
-
const agentsDir = path.join(claudeDir, 'agents');
|
|
25
|
-
const agentDest = path.join(agentsDir, 'reflection.md');
|
|
26
|
-
|
|
27
|
-
// Check if source file exists
|
|
28
|
-
try {
|
|
29
|
-
await fs.access(agentSource);
|
|
30
|
-
} catch {
|
|
31
|
-
console.log('⚠️ Reflection agent source file not found, skipping installation');
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Create directories if they don't exist
|
|
36
|
-
await fs.mkdir(claudeDir, { recursive: true });
|
|
37
|
-
await fs.mkdir(agentsDir, { recursive: true });
|
|
38
|
-
|
|
39
|
-
// Check if agent already exists
|
|
40
|
-
try {
|
|
41
|
-
await fs.access(agentDest);
|
|
42
|
-
console.log('✅ Reflection agent already installed at .claude/agents/reflection.md');
|
|
43
|
-
return;
|
|
44
|
-
} catch {
|
|
45
|
-
// File doesn't exist, proceed with installation
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Copy the agent file
|
|
49
|
-
await fs.copyFile(agentSource, agentDest);
|
|
50
|
-
|
|
51
|
-
console.log('✅ Reflection agent installed at .claude/agents/reflection.md');
|
|
52
|
-
console.log('');
|
|
53
|
-
console.log('🚀 Next Steps:');
|
|
54
|
-
console.log(' 1. Start Qdrant: docker run -d --name qdrant -p 6333:6333 qdrant/qdrant:latest');
|
|
55
|
-
console.log(' 2. Choose embedding provider: https://github.com/ramakay/claude-self-reflect#choose-your-embedding-provider');
|
|
56
|
-
console.log(' 3. Import conversations: Follow the installation guide');
|
|
57
|
-
console.log('');
|
|
58
|
-
console.log('💡 The agent will activate when you ask about past conversations');
|
|
59
|
-
console.log(' Example: "What did we discuss about API design?"');
|
|
60
|
-
console.log(' Note: You\'ll get "No conversations found" until you import your Claude history');
|
|
61
|
-
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error('❌ Error installing reflection agent:', error.message);
|
|
64
|
-
// Don't fail the entire install if agent installation fails
|
|
65
|
-
process.exit(0);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Run the installation
|
|
70
|
-
installAgent();
|