import { aiAnalysisService } from '../lib/ai-analysis.js'
import fs from 'fs'

async function testDirectAnalysis() {
  try {
    console.log('🧪 Testing AI analysis with existing screenshot...')
    
    const screenshotDir = '/app/screenshots'
    const screenshots = fs.readdirSync(screenshotDir).filter(f => 
      f.includes('SOLUSD_60') && f.endsWith('.png') && !f.includes('debug')
    )
    
    console.log('📸 Available screenshots:', screenshots)
    
    if (screenshots.length > 0) {
      const filename = screenshots[0]
      console.log(`🔍 Analyzing: ${filename}`)
      
      const result = await aiAnalysisService.analyzeScreenshot(filename)
      
      if (result) {
        console.log('✅ Analysis successful!')
        console.log('📊 Analysis result:')
        console.log(JSON.stringify(result, null, 2))
      } else {
        console.log('❌ Analysis failed - returned null')
      }
    } else {
      console.log('❌ No suitable screenshots found')
    }
    
  } catch (error) {
    console.error('❌ Error in direct analysis test:', error)
  }
}

testDirectAnalysis()
