<?php
$logPath = 'C:/Users/HP/.gemini/antigravity-ide/brain/d31b1fe2-ad06-4c7a-9ab1-c82bd4c8dd20/.system_generated/logs/transcript.jsonl';
if (!file_exists($logPath)) {
    die("Log not found\n");
}
$handle = fopen($logPath, "r");
$idx = 0;
while (($line = fgets($handle)) !== false) {
    $idx++;
    $data = json_decode($line, true);
    if (!$data) continue;
    
    // Check if step is VIEW_FILE for index.php
    if (isset($data['type']) && $data['type'] === 'VIEW_FILE') {
        $content = $data['content'] ?? '';
        if (stripos($content, 'index.php') !== false) {
            echo "=== Step $idx: VIEW_FILE index.php ===\n";
            echo "Details: " . substr($content, 0, 300) . "\n...\n";
            // Write full content to a scratch file
            $out = 'C:/Users/HP/Downloads/climate-system/climate-system/viewed_step_' . $idx . '.txt';
            file_put_contents($out, $content);
            echo "  Saved to $out\n";
        }
    }
    
    // Also check if any planner response or run command has file content or zip extraction
    if (isset($data['tool_calls'])) {
        foreach ($data['tool_calls'] as $tc) {
            if ($tc['name'] === 'view_file' || $tc['name'] === 'default_api:view_file') {
                $args = $tc['args'] ?? [];
                $tf = $args['AbsolutePath'] ?? '';
                if (stripos($tf, 'index.php') !== false) {
                    echo "=== Step $idx: tool call view_file index.php ===\n";
                    echo "  Args: " . json_encode($args) . "\n";
                }
            }
        }
    }
}
fclose($handle);
