test-session-reader.mjs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Test script to verify SessionReader can find SDK sessions
  3. *
  4. * This script tests the fix for the session storage path mismatch.
  5. * It should now find sessions created by the SDK in the hash-based directory.
  6. */
  7. import { SessionReader } from './dist/collector/session-reader.js';
  8. import { getProjectHash } from './dist/config.js';
  9. import path from 'path';
  10. import os from 'os';
  11. const projectPath = '/Users/darrenhinde/Documents/GitHub/opencode-agents/evals/framework';
  12. const sessionStoragePath = path.join(os.homedir(), '.local', 'share', 'opencode');
  13. console.log('='.repeat(60));
  14. console.log('Testing SessionReader with SDK storage paths');
  15. console.log('='.repeat(60));
  16. console.log('');
  17. console.log('Project path:', projectPath);
  18. console.log('Project hash:', getProjectHash(projectPath));
  19. console.log('Storage path:', sessionStoragePath);
  20. console.log('');
  21. const reader = new SessionReader(projectPath, sessionStoragePath);
  22. const sessions = reader.listSessions();
  23. console.log('Found', sessions.length, 'sessions');
  24. console.log('');
  25. if (sessions.length > 0) {
  26. console.log('Most recent 5 sessions:');
  27. sessions.slice(0, 5).forEach((session, idx) => {
  28. console.log(`${idx + 1}. ${session.id}`);
  29. console.log(` Title: ${session.title}`);
  30. console.log(` Created: ${new Date(session.time.created).toISOString()}`);
  31. console.log('');
  32. });
  33. } else {
  34. console.log('No sessions found. This might indicate:');
  35. console.log('1. No tests have been run yet');
  36. console.log('2. Sessions are in a different location');
  37. console.log('3. Project hash calculation is incorrect');
  38. }
  39. console.log('='.repeat(60));