feat: Implement Claude-mem MCP Search Server with session and observation search capabilities

- Added search functionality for observations and sessions using full-text search.
- Implemented formatting functions for search results with citations.
- Created multiple tools for searching by various criteria including concept, file, type, and advanced search.
- Integrated structured filters and pagination options for search queries.
- Established error handling for search operations and server initialization.
This commit is contained in:
Alex Newman
2025-10-18 20:45:41 -04:00
parent 115270c35e
commit 56167c47a2
15 changed files with 651 additions and 1349 deletions
+32 -2
View File
@@ -25,8 +25,13 @@ const WORKER_SERVICE = {
source: 'src/services/worker-service.ts'
};
const SEARCH_SERVER = {
name: 'search-server',
source: 'src/servers/search-server.ts'
};
async function buildHooks() {
console.log('🔨 Building claude-mem hooks and worker service...\n');
console.log('🔨 Building claude-mem hooks, worker service, and search server...\n');
try {
// Read version from package.json
@@ -103,9 +108,34 @@ async function buildHooks() {
console.log(`${hook.name} built (${sizeInKB} KB)`);
}
console.log('\n✅ All hooks and worker service built successfully!');
// Build search server
console.log(`\n🔧 Building search server...`);
await build({
entryPoints: [SEARCH_SERVER.source],
bundle: true,
platform: 'node',
target: 'node18',
format: 'esm',
outfile: `${hooksDir}/${SEARCH_SERVER.name}.js`,
minify: true,
external: ['better-sqlite3'],
define: {
'__DEFAULT_PACKAGE_VERSION__': `"${version}"`
},
banner: {
js: '#!/usr/bin/env node'
}
});
// Make search server executable
fs.chmodSync(`${hooksDir}/${SEARCH_SERVER.name}.js`, 0o755);
const searchStats = fs.statSync(`${hooksDir}/${SEARCH_SERVER.name}.js`);
console.log(`✓ search-server built (${(searchStats.size / 1024).toFixed(2)} KB)`);
console.log('\n✅ All hooks, worker service, and search server built successfully!');
console.log(` Hooks: ${hooksDir}/`);
console.log(` Worker: ${distDir}/worker-service.cjs`);
console.log(` Search: ${hooksDir}/search-server.js`);
} catch (error) {
console.error('\n❌ Build failed:', error.message);
+2 -2
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bun
#!/usr/bin/env node
/**
* Transcript Replay Tool
*
@@ -197,7 +197,7 @@ async function replayTranscript(transcriptPath: string, projectName: string = 'c
// Spawn worker exactly as production hooks do
const workerPath = join(process.cwd(), 'scripts/hooks/worker.js');
const worker = spawn('bun', [workerPath, String(sessionId)], {
const worker = spawn('node', [workerPath, String(sessionId)], {
detached: false, // Keep attached to see errors
stdio: ['ignore', 'pipe', 'pipe'] // Pipe output to see what's happening
});