Documentation: - Add ARCHITECTURE.md with comprehensive system review - Add GETTING_STARTED.md for new users - Add DOCUMENTATION_CLEANUP.md tracking cleanup changes - Add SCRIPTS_ORGANIZATION.md documenting script reorganization - Remove outdated docs (TESTING_CONFIDENCE.md, TEST_REVIEW.md, SESSION_STORAGE_FIX.md) - Update README files with current information Script Organization: - Move 12 scripts from framework root to organized directories: - scripts/debug/ (4 files): Session debugging tools - scripts/test/ (6 files): Test execution scripts - scripts/utils/ (2 files): Utility scripts - Add comprehensive scripts/README.md with usage examples Test Infrastructure: - Add 5 new context loading tests for openagent - Add result-saver.ts for test result persistence - Add interactive results dashboard (index.html) - Add error-handling.test.ts for framework testing - Add result-saver.test.ts with comprehensive unit tests Evaluator Improvements: - Enhance context-loading-evaluator with better detection - Update run-sdk-tests.ts with improved result handling Agent Configuration: - Add .opencode/agent/AGENT.md for agent definition Test Utilities: - Add test-agent-manual.mjs for manual testing - Update test_tmp/README.md with usage guidelines This commit consolidates multiple improvements: - Better organization (scripts, docs) - Improved testing infrastructure - Comprehensive documentation - Cleaner codebase structure
82 lines
2.6 KiB
JavaScript
82 lines
2.6 KiB
JavaScript
/**
|
|
* Test the simplified SDK-based session retrieval approach
|
|
*
|
|
* This test verifies that:
|
|
* 1. SessionReader can find sessions using SDK client
|
|
* 2. SessionReader falls back to disk scan when SDK unavailable
|
|
* 3. Works regardless of project path or hash calculation
|
|
*/
|
|
|
|
import { SessionReader } from './dist/collector/session-reader.js';
|
|
import path from 'path';
|
|
import os from 'os';
|
|
|
|
console.log('='.repeat(70));
|
|
console.log('Testing Simplified Session Retrieval Approach');
|
|
console.log('='.repeat(70));
|
|
console.log('');
|
|
|
|
const sessionStoragePath = path.join(os.homedir(), '.local', 'share', 'opencode');
|
|
|
|
// Test 1: Disk-based fallback (no SDK client)
|
|
console.log('Test 1: Disk-based session retrieval (no SDK)');
|
|
console.log('-'.repeat(70));
|
|
|
|
const readerNoSDK = new SessionReader(undefined, sessionStoragePath);
|
|
|
|
// Try to find a known session
|
|
const knownSessionId = 'ses_542a980dbffep8ZGbqIZQ4uF3A';
|
|
console.log(`Looking for session: ${knownSessionId}`);
|
|
|
|
try {
|
|
const session = await readerNoSDK.getSessionInfo(knownSessionId);
|
|
|
|
if (session) {
|
|
console.log('✅ SUCCESS: Found session via disk scan');
|
|
console.log(` ID: ${session.id}`);
|
|
console.log(` Title: ${session.title}`);
|
|
console.log(` Directory: ${session.directory}`);
|
|
console.log(` Project ID: ${session.projectID}`);
|
|
} else {
|
|
console.log('❌ FAILED: Session not found');
|
|
}
|
|
} catch (error) {
|
|
console.log('❌ ERROR:', error.message);
|
|
}
|
|
|
|
console.log('');
|
|
|
|
// Test 2: List all sessions
|
|
console.log('Test 2: List all sessions (disk scan)');
|
|
console.log('-'.repeat(70));
|
|
|
|
try {
|
|
const sessions = await readerNoSDK.listSessions();
|
|
console.log(`✅ Found ${sessions.length} total sessions`);
|
|
|
|
if (sessions.length > 0) {
|
|
console.log('');
|
|
console.log('Most recent 5 sessions:');
|
|
sessions.slice(0, 5).forEach((session, idx) => {
|
|
console.log(`${idx + 1}. ${session.id}`);
|
|
console.log(` Title: ${session.title || 'Untitled'}`);
|
|
console.log(` Directory: ${session.directory || 'N/A'}`);
|
|
console.log(` Created: ${new Date(session.time.created).toISOString()}`);
|
|
console.log('');
|
|
});
|
|
}
|
|
} catch (error) {
|
|
console.log('❌ ERROR:', error.message);
|
|
}
|
|
|
|
console.log('='.repeat(70));
|
|
console.log('Summary:');
|
|
console.log('');
|
|
console.log('✅ Simplified approach working!');
|
|
console.log(' - No complex path calculations');
|
|
console.log(' - No hash discovery needed');
|
|
console.log(' - Just scan for session ID');
|
|
console.log(' - Works for any agent, any project');
|
|
console.log('');
|
|
console.log('Next: Run actual tests with SDK client to verify full integration');
|
|
console.log('='.repeat(70));
|