Skip to main content
Glama

In Memoria

test-caching-issues.js•3.54 kB
#!/usr/bin/env node import { SemanticEngine } from '../dist/engines/semantic-engine.js'; import { SQLiteDatabase } from '../dist/storage/sqlite-db.js'; import { SemanticVectorDB } from '../dist/storage/vector-db.js'; import { tmpdir } from 'os'; import { join } from 'path'; import { writeFileSync, unlinkSync, existsSync, mkdirSync } from 'fs'; async function testCachingConsistency() { console.log('šŸ” Testing caching consistency...\n'); // Create temporary test files const testDir = join(tmpdir(), 'in-memoria-cache-test'); const testFile = join(testDir, 'test.ts'); const dbPath = join(testDir, 'test.db'); const testContent1 = 'export class UserService { getName() { return "test1"; } }'; const testContent2 = 'export class UserService { getName() { return "test2"; } }'; try { // Ensure test directory exists if (!existsSync(testDir)) { console.log('Creating test directory...'); mkdirSync(testDir, { recursive: true }); } // Initialize engines const db = new SQLiteDatabase(dbPath); const vectorDB = new SemanticVectorDB(); const engine = new SemanticEngine(db, vectorDB); console.log('šŸ“ Test 1: Analyze initial content'); writeFileSync(testFile, testContent1); const concepts1 = await engine.analyzeFileContent(testFile, testContent1); console.log(` Found ${concepts1.length} concepts`); concepts1.forEach(c => console.log(` - ${c.name} (${c.type})`)); console.log('\nšŸ“ Test 2: Analyze modified content'); writeFileSync(testFile, testContent2); const concepts2 = await engine.analyzeFileContent(testFile, testContent2); console.log(` Found ${concepts2.length} concepts`); concepts2.forEach(c => console.log(` - ${c.name} (${c.type})`)); console.log('\nšŸ“ Test 3: Re-analyze same content (should be consistent)'); const concepts3 = await engine.analyzeFileContent(testFile, testContent2); console.log(` Found ${concepts3.length} concepts`); concepts3.forEach(c => console.log(` - ${c.name} (${c.type})`)); // Verify consistency const consistent = JSON.stringify(concepts2) === JSON.stringify(concepts3); console.log(`\nāœ… Caching consistency: ${consistent ? 'PASS' : 'FAIL'}`); if (!consistent) { console.log('āŒ Detected caching inconsistency!'); console.log('Test 2 results:', JSON.stringify(concepts2, null, 2)); console.log('Test 3 results:', JSON.stringify(concepts3, null, 2)); } // Test with new SemanticEngine instance (fresh instance) console.log('\nšŸ“ Test 4: New engine instance with same content'); const engine2 = new SemanticEngine(new SQLiteDatabase(dbPath + '2'), new SemanticVectorDB()); const concepts4 = await engine2.analyzeFileContent(testFile, testContent2); console.log(` Found ${concepts4.length} concepts`); concepts4.forEach(c => console.log(` - ${c.name} (${c.type})`)); const freshInstanceConsistent = concepts4.length === concepts2.length; console.log(`\nāœ… Fresh instance consistency: ${freshInstanceConsistent ? 'PASS' : 'FAIL'}`); } catch (error) { console.error('āŒ Test failed:', error); } finally { // Cleanup try { if (existsSync(testFile)) unlinkSync(testFile); if (existsSync(dbPath)) unlinkSync(dbPath); if (existsSync(dbPath + '2')) unlinkSync(dbPath + '2'); } catch (cleanupError) { console.warn('Cleanup failed:', cleanupError.message); } } } testCachingConsistency();

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pi22by7/In-Memoria'

If you have feedback or need assistance with the MCP directory API, please join our Discord server