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. Wider context around conversation-view
console.log('=== CONVERSATION-VIEW (800 chars context) ===');
let idx = content.indexOf('conversation-view');
if (idx >= 0) {
    console.log(content.substring(Math.max(0, idx - 500), idx + 800));
}

console.log('\n\n=== DATA-STEP-INDEX (800 chars context) ===');
idx = content.indexOf('data-step-index');
if (idx >= 0) {
    console.log(content.substring(Math.max(0, idx - 500), idx + 800));
}

// 2. Find ALL occurrences of data-step-index
console.log('\n\n=== ALL data-step-index occurrences ===');
let pos = 0;
let count = 0;
while ((pos = content.indexOf('data-step-index', pos)) >= 0 && count < 5) {
    console.log(`\n--- occurrence ${++count} at offset ${pos} ---`);
    console.log(content.substring(Math.max(0, pos - 200), pos + 300));
    pos += 15;
}

// 3. Find the step type rendering — look for step enums/types  
console.log('\n\n=== Step type patterns ===');
const stepTypePatterns = [
    'stepType', 'step_type', 'StepType',
    'PLANNER_RESPONSE', 'RUN_COMMAND', 'EDIT_FILE', 'WRITE_TO_FILE',
    'ToolCallStep', 'PlannerStep', 'TextStep'
];
for (const pat of stepTypePatterns) {
    const i = content.indexOf(pat);
    if (i >= 0) {
        console.log(`\n--- ${pat} @${i} ---`);
        console.log(content.substring(Math.max(0, i - 100), i + 200).substring(0, 300));
    }
}

// 4. Find how the AI text/response is rendered
console.log('\n\n=== Text rendering patterns (near bot-color) ===');
const botColorIdx = content.indexOf('text-ide-message-block-bot-color');
if (botColorIdx >= 0) {
    console.log(content.substring(Math.max(0, botColorIdx - 800), botColorIdx + 800));
}

// 5. Allow/Deny button  with more context
console.log('\n\n=== Allow/Deny button wider context ===');
idx = content.indexOf('label:"Allow"');
if (idx >= 0) {
    console.log(content.substring(Math.max(0, idx - 800), idx + 600));
}

// 6. Find markdown rendering components
console.log('\n\n=== Markdown rendering patterns ===');
for (const pat of ['MarkdownRenderer', 'renderMarkdown', 'markdownContent', 'dangerouslySetInnerHTML', 'StreamingText', 'TypeWriter', 'StreamingMarkdown']) {
    const i = content.indexOf(pat);
    if (i >= 0) {
        console.log(`\n--- ${pat} @${i} ---`);
        console.log(content.substring(Math.max(0, i - 150), i + 250).substring(0, 400));
    }
}
