Add comprehensive documentation for claude-mem codebase and create a test worker script

- Introduced CODEMAP.md detailing project overview, architecture, directory structure, core components, commands, hooks system, SDK, services, shared components, utilities, and key workflows.
- Added a test-worker.sh script to automate testing of the SDK worker, including session creation, worker initiation, socket communication, and cleanup after finalization.
This commit is contained in:
Alex Newman
2025-10-16 13:56:18 -04:00
parent 18aa4f2538
commit 6e9be84a01
10 changed files with 2074 additions and 228 deletions
+2 -20
View File
@@ -1,7 +1,6 @@
import { HooksDatabase } from '../services/sqlite/HooksDatabase.js';
import path from 'path';
import { spawn } from 'child_process';
import fs from 'fs';
export interface UserPromptSubmitInput {
session_id: string;
@@ -37,25 +36,8 @@ export function newHook(input: UserPromptSubmitInput): void {
db.close();
// Start SDK worker in background as detached process
// Try source first (development), then fall back to dist (production)
const srcWorkerPath = path.join(__dirname, '..', 'sdk', 'worker.ts');
const distWorkerPath = path.join(__dirname, '..', 'sdk', 'worker.js');
let workerPath: string;
if (fs.existsSync(srcWorkerPath)) {
workerPath = srcWorkerPath;
} else if (fs.existsSync(distWorkerPath)) {
workerPath = distWorkerPath;
} else {
// Fallback: assume we're in the bundled CLI
// In this case, we can't spawn the worker since it's bundled
// This is a limitation we'll need to address
console.error('[claude-mem] Worker not found, skipping background processing');
console.log('{"continue": true, "suppressOutput": true}');
process.exit(0);
}
const child = spawn('bun', [workerPath, sessionId.toString()], {
// Use 'claude-mem worker' CLI command which is always available
const child = spawn('claude-mem', ['worker', sessionId.toString()], {
detached: true,
stdio: 'ignore'
});