-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-quick.js
More file actions
98 lines (81 loc) · 3.45 KB
/
Copy pathtest-quick.js
File metadata and controls
98 lines (81 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env node
import { EnhancedDatabaseManager } from './dist/core/enhanced-database.js';
import { EnhancedIndexer } from './dist/services/enhanced-indexer.js';
import path from 'path';
import os from 'os';
import dotenv from 'dotenv';
// Load environment variables
dotenv.config();
async function testQuick() {
console.log('🚀 Quick test with just a few files');
// Initialize database (delete existing for clean test)
const dbPath = path.join(os.homedir(), '.claude', 'claude-history-test.db');
// Delete existing database for clean test
const fs = await import('fs/promises');
try {
await fs.unlink(dbPath);
console.log('🗑️ Deleted existing database for clean test');
} catch (e) {
// Database doesn't exist, that's fine
}
const db = new EnhancedDatabaseManager(dbPath);
// Get API key from environment
const apiKey = process.env.OPENAI_API_KEY;
console.log(`🔑 API Key configured: ${apiKey ? 'Yes (AI summaries enabled)' : 'No (using basic extraction)'}`);
if (apiKey) {
console.log(`🤖 Using GPT-4o-mini for intelligent summarization`);
}
// Initialize indexer
const indexer = new EnhancedIndexer(db, apiKey);
// Find just a few test files
const projectPath = path.join(os.homedir(), '.claude', 'projects', '-Users-timkostolansky');
console.log(`📂 Testing with files from: ${projectPath}`);
// Get a few specific JSONL files for testing
const testFiles = [
path.join(projectPath, '07cc291c-aa41-4478-a411-b9a20d0d353c.jsonl'),
path.join(projectPath, '139ddad5-9a63-4992-bec8-7ee5146c65df.jsonl'),
path.join(projectPath, '174ab749-83aa-434d-a93a-ebb1a46105c3.jsonl'),
];
console.log(`\n📄 Testing with ${testFiles.length} files:`);
let successCount = 0;
let errorCount = 0;
for (const file of testFiles) {
try {
console.log(`\n🔍 Indexing: ${path.basename(file)}`);
const conversation = await indexer.indexFile(file);
if (conversation) {
successCount++;
console.log(` ✅ Success! Summary: ${conversation.summary.substring(0, 100)}...`);
if (conversation.tags && conversation.tags.length > 0) {
console.log(` 🏷️ Tags: ${conversation.tags.join(', ')}`);
}
if (conversation.languages && conversation.languages.length > 0) {
console.log(` 💻 Languages: ${conversation.languages.join(', ')}`);
}
console.log(` 📊 Messages: ${conversation.messageCount}, Errors: ${conversation.errorCount}`);
}
} catch (error) {
errorCount++;
console.error(` ❌ Failed: ${error.message}`);
}
}
console.log(`\n✅ Successfully indexed: ${successCount} conversations`);
console.log(`❌ Failed: ${errorCount} conversations`);
// Test search functionality
console.log('\n🔍 Testing search functionality...');
const searchResults = db.searchConversations({ query: '*' });
console.log(` Found ${searchResults.length} conversations in database`);
if (searchResults.length > 0) {
console.log('\n📋 First conversation details:');
const first = searchResults[0];
console.log(` Project: ${first.project_name}`);
console.log(` Summary: ${first.summary}`);
console.log(` Tags: ${first.tags}`);
console.log(` Languages: ${first.languages}`);
}
process.exit(0);
}
testQuick().catch(error => {
console.error('❌ Error:', error);
process.exit(1);
});