const fs = require('fs');
const bundlePath = String.raw`C:\Users\Variet-Worker\AppData\Local\Programs\Antigravity\resources\app\out\jetskiAgent\main.js`;
const content = fs.readFileSync(bundlePath, 'utf-8');

// 1. Find Whi (plannerResponse renderer)
console.log('=== Whi (plannerResponse renderer) ===');
let idx = content.indexOf('Whi=');
if (idx < 0) idx = content.indexOf('Whi =');
if (idx < 0) idx = content.indexOf('function Whi');
if (idx >= 0) {
    console.log(content.substring(idx, idx + 1500));
} else {
    // Try to find it differently
    idx = content.indexOf('renderer:Whi');
    if (idx >= 0) {
        // Search backwards for Whi definition
        const searchArea = content.substring(Math.max(0, idx - 50000), idx);
        const defIdx2 = searchArea.lastIndexOf('Whi');
        if (defIdx2 >= 0) {
            const absIdx = Math.max(0, idx - 50000) + defIdx2;
            console.log(`Found Whi near @${absIdx}:`);
            console.log(content.substring(absIdx, absIdx + 1500));
        }
    }
}

// 2. Find the Put component (trajectory rendering) 
console.log('\n\n=== Put (trajectory/step list renderer) ===');
idx = content.indexOf('Put,{trajectory');
if (idx >= 0) {
    console.log(content.substring(Math.max(0, idx - 200), idx + 600));
}

// 3. Look at how steps are rendered in the conversation view
console.log('\n\n=== Step rendering in conversation ===');
// Look for the component that renders individual steps
for (const pat of ['renderStep', 'StepRenderer', 'stepRenderer', 'renderTool', 'ToolRenderer']) {
    const i = content.indexOf(pat);
    if (i >= 0) {
        console.log(`\n--- ${pat} @${i} ---`);
        console.log(content.substring(Math.max(0, i - 100), i + 400).substring(0, 500));
    }
}

// 4. Find response/message text content rendering
console.log('\n\n=== "prose" usage in step/conversation context ===');
let pos = 0;
let cnt2 = 0;
while ((pos = content.indexOf('prose', pos)) >= 0 && cnt2 < 8) {
    const ctx = content.substring(Math.max(0, pos - 100), pos + 200);
    if (ctx.includes('className') && (ctx.includes('step') || ctx.includes('response') || ctx.includes('message') || ctx.includes('text') || ctx.includes('content') || ctx.includes('bot'))) {
        console.log(`\n--- prose @${pos} ---`);
        console.log(ctx.substring(0, 300));
        cnt2++;
    }
    pos += 5;
}

// 5. the "agent-convo-background" class and its surrounding context
console.log('\n\n=== agent-convo-background context ===');
idx = content.indexOf('agent-convo-background');
if (idx >= 0) {
    console.log(content.substring(Math.max(0, idx - 200), idx + 500));
}

// 6. Find how the step list is rendered in the main view (not debug panel)
console.log('\n\n=== Main view step rendering (near conversation-view) ===');
idx = content.indexOf('"conversation-view"');
if (idx >= 0) {
    // Look forward for the children rendering
    console.log(content.substring(idx, idx + 3000));
}
