<?php
$logPaths = [
    'C:/Users/HP/.gemini/antigravity-ide/brain/dabec389-a1dd-4fd5-add9-97761faf96ae/.system_generated/logs/transcript.jsonl',
    'C:/Users/HP/.gemini/antigravity-ide/brain/d31b1fe2-ad06-4c7a-9ab1-c82bd4c8dd20/.system_generated/logs/transcript.jsonl'
];

foreach ($logPaths as $logPath) {
    if (!file_exists($logPath)) continue;
    echo "=== Scanning $logPath ===\n";
    $handle = fopen($logPath, "r");
    $idx = 0;
    while (($line = fgets($handle)) !== false) {
        $idx++;
        if (strpos($line, 'TS') !== false || strpos($line, 'TimeSeries') !== false || strpos($line, 'Time Series') !== false) {
            $data = json_decode($line, true);
            if (isset($data['tool_calls'])) {
                foreach ($data['tool_calls'] as $tc) {
                    if ($tc['name'] === 'replace_file_content' || $tc['name'] === 'multi_replace_file_content') {
                        $args = $tc['args'];
                        $str = json_encode($args, JSON_PRETTY_PRINT);
                        if (strpos($str, 'TS') !== false || strpos($str, 'TimeSeries') !== false || strpos($str, 'Time Series') !== false) {
                            if (strpos($str, 'filter') !== false || strpos($str, 'select') !== false || strpos($str, 'option') !== false || strpos($str, 'data') !== false) {
                                echo "Step $idx ($tc[name]):\n";
                                echo substr($str, 0, 1000) . "\n...\n";
                            }
                        }
                    }
                }
            }
        }
    }
    fclose($handle);
}
