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
76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
/**
|
|
* Inspect the most recent session to see what events were captured
|
|
*/
|
|
|
|
import { SessionReader } from './dist/collector/session-reader.js';
|
|
import path from 'path';
|
|
import os from 'os';
|
|
|
|
const sessionStoragePath = path.join(os.homedir(), '.local', 'share', 'opencode');
|
|
const reader = new SessionReader(undefined, sessionStoragePath);
|
|
|
|
// Get session ID from command line or use most recent
|
|
const sessionId = process.argv[2];
|
|
let mostRecent;
|
|
|
|
if (sessionId) {
|
|
console.log(`Looking for session: ${sessionId}`);
|
|
mostRecent = await reader.getSessionInfo(sessionId);
|
|
if (!mostRecent) {
|
|
console.log('Session not found!');
|
|
process.exit(1);
|
|
}
|
|
} else {
|
|
// Get the most recent session
|
|
const sessions = await reader.listSessions();
|
|
mostRecent = sessions[0];
|
|
}
|
|
|
|
console.log('='.repeat(70));
|
|
console.log('Most Recent Session Analysis');
|
|
console.log('='.repeat(70));
|
|
console.log('');
|
|
console.log('Session Info:');
|
|
console.log(' ID:', mostRecent.id);
|
|
console.log(' Title:', mostRecent.title);
|
|
console.log(' Agent:', mostRecent.agent || 'N/A');
|
|
console.log(' Directory:', mostRecent.directory);
|
|
console.log(' Created:', new Date(mostRecent.time.created).toISOString());
|
|
console.log('');
|
|
|
|
// Get messages
|
|
const messages = await reader.getMessages(mostRecent.id);
|
|
console.log(`Messages: ${messages.length}`);
|
|
console.log('');
|
|
|
|
for (let i = 0; i < messages.length; i++) {
|
|
const msg = messages[i];
|
|
console.log('-'.repeat(70));
|
|
console.log(`Message ${i + 1}:`);
|
|
console.log(' ID:', msg.id);
|
|
console.log(' Role:', msg.role);
|
|
console.log(' Agent:', msg.agent || 'N/A');
|
|
console.log(' Model:', msg.model?.modelID || 'N/A');
|
|
console.log(' Created:', new Date(msg.time.created).toISOString());
|
|
|
|
const parts = await reader.getParts(mostRecent.id, msg.id);
|
|
console.log(` Parts: ${parts.length}`);
|
|
console.log('');
|
|
|
|
for (let j = 0; j < parts.length; j++) {
|
|
const part = parts[j];
|
|
console.log(` Part ${j + 1}:`);
|
|
console.log(` Type: ${part.type}`);
|
|
|
|
if (part.type === 'text') {
|
|
const text = part.text || '';
|
|
console.log(` Text: ${text.substring(0, 200)}${text.length > 200 ? '...' : ''}`);
|
|
} else if (part.type === 'tool') {
|
|
console.log(` Tool: ${part.tool}`);
|
|
console.log(` Input: ${JSON.stringify(part.input).substring(0, 100)}...`);
|
|
}
|
|
console.log('');
|
|
}
|
|
}
|
|
|
|
console.log('='.repeat(70));
|