Files
claude-mem/experiment/test-mcp-direct.js
T
Alex Newman 633f89a5fb feat: Implement user prompt syncing to Chroma and enhance timeline querying
- Added `getObservationById` method to retrieve observations by ID in SessionStore.
- Introduced `getSessionSummariesByIds` and `getUserPromptsByIds` methods for fetching session summaries and user prompts by IDs.
- Developed `getTimelineAroundTimestamp` and `getTimelineAroundObservation` methods to provide a unified timeline of observations, sessions, and prompts around a specified anchor point.
- Enhanced ChromaSync to format and sync user prompts, including a new `syncUserPrompt` method.
- Updated WorkerService to sync the latest user prompt to Chroma after updating the worker port.
- Created tests for timeline querying and MCP handler logic to ensure functionality.
- Documented the implementation plan for user prompts and timeline context tool in the Chroma search completion plan.
2025-11-03 16:55:33 -05:00

55 lines
1.5 KiB
JavaScript

import { SessionStore } from '../src/services/sqlite/SessionStore.js';
const store = new SessionStore();
// Simulate what the MCP handler does
const args = {
anchor: 3300,
depth_before: 10,
depth_after: 10
};
console.log('Testing MCP handler logic with anchor:', args.anchor);
try {
let timeline;
const anchor = args.anchor;
const depth_before = args.depth_before;
const depth_after = args.depth_after;
if (typeof anchor === 'number') {
console.log('Anchor is number, getting observation...');
const obs = store.getObservationById(anchor);
if (!obs) {
console.error('Observation not found!');
process.exit(1);
}
console.log('Found observation:', obs.id, 'at epoch:', obs.created_at_epoch);
console.log('Calling getTimelineAroundObservation...');
timeline = store.getTimelineAroundObservation(anchor, obs.created_at_epoch, depth_before, depth_after);
console.log('Timeline result:', {
observations: timeline.observations?.length,
sessions: timeline.sessions?.length,
prompts: timeline.prompts?.length
});
console.log('Timeline observations type:', typeof timeline.observations);
console.log('Timeline sessions type:', typeof timeline.sessions);
console.log('Timeline prompts type:', typeof timeline.prompts);
if (timeline.observations) {
console.log('First observation:', timeline.observations[0]);
}
}
console.log('\n✓ No errors!');
} catch (err) {
console.error('ERROR:', err.message);
console.error(err.stack);
process.exit(1);
}
store.close();