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.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
#!/usr/bin/env npx tsx
|
|
/**
|
|
* Verify timeline builder correctly captures tools from a real session
|
|
*/
|
|
|
|
import { createOpencodeClient } from '@opencode-ai/sdk';
|
|
import { SessionReader } from './src/collector/session-reader.js';
|
|
import { TimelineBuilder } from './src/collector/timeline-builder.js';
|
|
|
|
const sessionId = process.argv[2];
|
|
const baseUrl = process.argv[3] || 'http://127.0.0.1:3000';
|
|
|
|
async function verify() {
|
|
console.log(`Connecting to ${baseUrl}...`);
|
|
const client = createOpencodeClient({ baseUrl });
|
|
|
|
// Create reader with SDK client
|
|
const reader = new SessionReader(client);
|
|
const builder = new TimelineBuilder(reader);
|
|
|
|
// Get session to test
|
|
let targetSessionId = sessionId;
|
|
if (!targetSessionId) {
|
|
const sessions = await client.session.list();
|
|
// Find a session with tools (our current conversation)
|
|
targetSessionId = sessions.data?.find(s => s.title?.includes('Testing eval system'))?.id || sessions.data?.[0]?.id;
|
|
}
|
|
|
|
if (!targetSessionId) {
|
|
console.log('No session found');
|
|
return;
|
|
}
|
|
|
|
console.log(`\nTesting session: ${targetSessionId}`);
|
|
|
|
// Get raw messages with parts
|
|
console.log('\n=== Raw Data ===');
|
|
const messagesWithParts = await reader.getMessagesWithParts(targetSessionId);
|
|
console.log(`Messages: ${messagesWithParts.length}`);
|
|
|
|
let rawToolCount = 0;
|
|
const rawToolNames: string[] = [];
|
|
|
|
for (const msg of messagesWithParts) {
|
|
for (const part of msg.parts || []) {
|
|
if (part.type === 'tool') {
|
|
rawToolCount++;
|
|
rawToolNames.push(part.tool);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log(`Tool parts in raw data: ${rawToolCount}`);
|
|
if (rawToolNames.length > 0) {
|
|
console.log(`Tools: ${[...new Set(rawToolNames)].join(', ')}`);
|
|
}
|
|
|
|
// Build timeline
|
|
console.log('\n=== Timeline ===');
|
|
const timeline = await builder.buildTimeline(targetSessionId);
|
|
const toolCalls = timeline.filter(e => e.type === 'tool_call');
|
|
|
|
console.log(`Total timeline events: ${timeline.length}`);
|
|
console.log(`Tool call events: ${toolCalls.length}`);
|
|
|
|
if (toolCalls.length > 0) {
|
|
console.log('\nTool calls found:');
|
|
toolCalls.slice(0, 10).forEach((tc, i) => {
|
|
console.log(` ${i + 1}. ${tc.data?.tool}: ${JSON.stringify(tc.data?.state?.input || tc.data?.input || {}).substring(0, 100)}`);
|
|
});
|
|
}
|
|
|
|
// Verify
|
|
console.log('\n=== Verification ===');
|
|
if (rawToolCount === toolCalls.length) {
|
|
console.log(`✅ SUCCESS: Raw data has ${rawToolCount} tools, timeline has ${toolCalls.length} tool_call events`);
|
|
} else {
|
|
console.log(`❌ MISMATCH: Raw data has ${rawToolCount} tools, timeline has ${toolCalls.length} tool_call events`);
|
|
}
|
|
}
|
|
|
|
verify().catch(console.error);
|