[
  {
    "_comment": "=== Layer 1: Atomic Operations (10 tasks) ==="
  },
  {
    "name": "v2ex-open-home",
    "steps": [
      "opencli browser open https://v2ex.com/"
    ],
    "judge": {
      "type": "contains",
      "value": "Navigated to"
    }
  },
  {
    "name": "v2ex-state-home",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser state"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\[\\d+\\]"
    }
  },
  {
    "name": "v2ex-get-title",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"document.title\""
    ],
    "judge": {
      "type": "contains",
      "value": "V2EX"
    }
  },
  {
    "name": "v2ex-click-tab",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"(() => { const a = document.querySelector('a[href=\\\"/?tab=tech\\\"]'); if(a){a.click(); return 'clicked';} return 'not found'; })()\""
    ],
    "judge": {
      "type": "contains",
      "value": "clicked"
    }
  },
  {
    "name": "v2ex-scroll-down",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser scroll down --amount 500",
      "opencli browser eval \"window.scrollY > 100 ? 'scrolled' : 'not scrolled'\""
    ],
    "judge": {
      "type": "contains",
      "value": "scrolled"
    }
  },
  {
    "name": "v2ex-get-first-topic-text",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"document.querySelector('a[href^=\\\"/t/\\\"]')?.textContent?.trim()\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-eval-extract-titles",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 3
    }
  },
  {
    "name": "v2ex-get-url",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser get url"
    ],
    "judge": {
      "type": "contains",
      "value": "v2ex.com"
    }
  },
  {
    "name": "v2ex-back-navigation",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser back",
      "opencli browser get url"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "v2ex\\.com/?$"
    }
  },
  {
    "name": "v2ex-wait-page-load",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser wait selector \"a[href^='/t/']\"",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length > 0 ? 'loaded' : 'empty'\""
    ],
    "judge": {
      "type": "contains",
      "value": "loaded"
    }
  },
  {
    "_comment": "=== Layer 2: Single Page Tasks (10 tasks) ==="
  },
  {
    "name": "v2ex-hot-topics",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,10).map(a=>({title:a.textContent.trim(),url:a.href})).filter(t=>t.title.length>2))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 5
    }
  },
  {
    "name": "v2ex-node-list",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/go/\\\"]')].map(a=>a.textContent.trim()).filter(t=>t.length>0))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 10
    }
  },
  {
    "name": "v2ex-topic-meta",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');const href=a?.href;return href||'';})()\"",
      "opencli browser eval \"(()=>{const links=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')];const first=links[0];if(!first)return JSON.stringify({error:'no topic'});const title=first.textContent.trim();const row=first.closest('tr')||first.parentElement;const author=row?.querySelector('a[href^=\\\"/member/\\\"]')?.textContent?.trim()||'';return JSON.stringify({title,author});})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"title\":"
    }
  },
  {
    "name": "v2ex-node-topics",
    "steps": [
      "opencli browser open https://v2ex.com/go/python",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 3
    }
  },
  {
    "name": "v2ex-node-pagination-info",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"(()=>{const pages=[...document.querySelectorAll('a[href*=\\\"?p=\\\"]')];if(pages.length===0)return'no pagination';const nums=pages.map(a=>{const m=a.href.match(/p=(\\d+)/);return m?parseInt(m[1]):0}).filter(n=>n>0);return JSON.stringify({pages:nums.length,max:Math.max(...nums)});})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"max\":\\d+"
    }
  },
  {
    "name": "v2ex-tab-content",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=jobs",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 3
    }
  },
  {
    "name": "v2ex-topic-replies-extract",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"(()=>{const link=document.querySelector('a[href^=\\\"/t/\\\"]');if(!link)return'';return link.href;})()\"",
      "opencli browser eval \"(()=>{const link=document.querySelector('a[href^=\\\"/t/\\\"]');if(link)window.location.href=link.href;return'navigating';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('.reply_content')].slice(0,5).map(el=>el.textContent.trim().slice(0,100)))\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-topic-reply-count",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const counts=[...document.querySelectorAll('a[class*=\\\"count\\\"]')].map(a=>parseInt(a.textContent)).filter(n=>!isNaN(n));return JSON.stringify(counts.slice(0,10));})()\" "
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 3
    }
  },
  {
    "name": "v2ex-member-info",
    "steps": [
      "opencli browser open https://v2ex.com/member/Livid",
      "opencli browser eval \"(()=>{const name=document.querySelector('h1')?.textContent?.trim();const bio=document.querySelector('.bigger')?.textContent?.trim()||'';return JSON.stringify({name,bio});})()\" "
    ],
    "judge": {
      "type": "contains",
      "value": "Livid"
    }
  },
  {
    "name": "v2ex-search-results",
    "steps": [
      "opencli browser open https://www.google.com/search?q=site:v2ex.com+TypeScript",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('h3')].slice(0,5).map(h=>h.textContent.trim()))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 2
    }
  },
  {
    "_comment": "=== Layer 3: Multi-Step (10 tasks) ==="
  },
  {
    "name": "v2ex-click-topic-read",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser state",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked '+a.textContent.trim().slice(0,30);}return 'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.querySelector('.topic_content,.markdown_body')?.textContent?.trim()?.slice(0,200)||document.title\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-click-author-profile",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/member/\\\"]');if(a){const name=a.textContent.trim();a.click();return name;}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const h1=document.querySelector('h1');const joined=document.querySelector('.gray')?.textContent||'';return JSON.stringify({name:h1?.textContent?.trim(),info:joined.slice(0,100)});})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"name\":"
    }
  },
  {
    "name": "v2ex-navigate-node-from-home",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href=\\\"/go/programmer\\\"]')||document.querySelector('a[href^=\\\"/go/\\\"]');if(a){a.click();return 'clicked '+a.textContent.trim();}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 3
    }
  },
  {
    "name": "v2ex-pagination-page2",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href*=\\\"?p=2\\\"]');if(a){a.click();return'navigating to page 2';}return'no page 2 link';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"JSON.stringify({url:location.href,topics:[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2)})\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "p=2"
    }
  },
  {
    "name": "v2ex-topic-and-back",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser back",
      "opencli browser wait time 1",
      "opencli browser get url"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "v2ex\\.com/?$"
    }
  },
  {
    "name": "v2ex-tab-then-topic",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=creative",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){const t=a.textContent.trim();a.click();return t;}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.title\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-scroll-find-more",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\"",
      "opencli browser scroll down --amount 1000",
      "opencli browser scroll down --amount 1000",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\d+"
    }
  },
  {
    "name": "v2ex-node-to-topic-content",
    "steps": [
      "opencli browser open https://v2ex.com/go/python",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const title=document.querySelector('h1')?.textContent?.trim()||document.title;const content=document.querySelector('.topic_content,.markdown_body')?.textContent?.trim()?.slice(0,200)||'';return JSON.stringify({title,content});})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"title\":"
    }
  },
  {
    "name": "v2ex-multi-tab-compare",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=tech",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()))\"",
      "opencli browser open https://v2ex.com/?tab=creative",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 2
    }
  },
  {
    "name": "v2ex-topic-reply-to-author",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const replies=document.querySelectorAll('.reply_content');const authors=[...document.querySelectorAll('a[href^=\\\"/member/\\\"]')];if(replies.length>0){const authorLink=document.querySelector('.cell a[href^=\\\"/member/\\\"]');if(authorLink){authorLink.click();return'clicked author';}};return'no replies found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.querySelector('h1')?.textContent?.trim()||document.title\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "_comment": "=== Layer 4: Write Operations (5 tasks, requires login) ==="
  },
  {
    "name": "v2ex-reply-type-text",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const links=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')];const link=links.find(a=>a.closest('tr')?.querySelector('a[class*=\\\"count\\\"]'));if(link){link.click();return'clicked';}if(links[0]){links[0].click();return'clicked first';}return'no topic';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const ta=document.querySelector('textarea#reply_content,textarea[name=\\\"content\\\"]');if(ta){ta.focus();ta.value='AutoResearch test reply - please ignore';ta.dispatchEvent(new Event('input',{bubbles:true}));return ta.value;}return'no textarea';})()\" "
    ],
    "judge": {
      "type": "contains",
      "value": "AutoResearch test reply"
    },
    "note": "Types into reply box but does NOT submit"
  },
  {
    "name": "v2ex-favorite-topic",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const favLink=[...document.querySelectorAll('a')].find(a=>a.textContent.includes('加入收藏')||a.textContent.includes('Favorite'));return favLink?favLink.href:'no fav link';})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "favorite|收藏"
    },
    "note": "Finds favorite link but does NOT click it"
  },
  {
    "name": "v2ex-thank-reply-find",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const thankBtns=document.querySelectorAll('.thank_area,a[onclick*=\\\"thank\\\"],.thank');return JSON.stringify({found:thankBtns.length});})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"found\":\\d+"
    },
    "note": "Finds thank buttons but does NOT click"
  },
  {
    "name": "v2ex-reply-form-detect",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const ta=document.querySelector('textarea#reply_content,textarea[name=\\\"content\\\"]');const btn=document.querySelector('input[type=\\\"submit\\\"],button[type=\\\"submit\\\"]');const once=document.querySelector('input[name=\\\"once\\\"]');return JSON.stringify({textarea:!!ta,submitBtn:!!btn,csrfToken:!!once});})()\" "
    ],
    "judge": {
      "type": "contains",
      "value": "\"textarea\":"
    }
  },
  {
    "name": "v2ex-create-topic-form-detect",
    "steps": [
      "opencli browser open https://v2ex.com/new",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const title=document.querySelector('input[name=\\\"title\\\"],#topic_title');const content=document.querySelector('textarea[name=\\\"content\\\"],#topic_content,textarea#editor');const nodeSelect=document.querySelector('select[name=\\\"node_name\\\"],#node-select');return JSON.stringify({titleInput:!!title,contentArea:!!content,nodeSelect:!!nodeSelect,url:location.href});})()\" "
    ],
    "judge": {
      "type": "nonEmpty"
    },
    "note": "Detects create topic form elements, does NOT submit"
  },
  {
    "_comment": "=== Layer 5: Complex Chain (5 tasks) ==="
  },
  {
    "name": "v2ex-collect-hot-authors",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"JSON.stringify([...new Set([...document.querySelectorAll('a')].filter(a=>a.pathname&&a.pathname.startsWith('/member/')).map(a=>a.textContent.trim()).filter(n=>n.length>1))].slice(0,5))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 2
    }
  },
  {
    "name": "v2ex-multi-node-compare",
    "steps": [
      "opencli browser open https://v2ex.com/go/python",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()).filter(t=>t.length>2))\"",
      "opencli browser open https://v2ex.com/go/go",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 2
    }
  },
  {
    "name": "v2ex-topic-deep-read",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const title=document.querySelector('h1')?.textContent?.trim()||document.title;const author=document.querySelector('.header a[href^=\\\"/member/\\\"]')?.textContent?.trim()||'';const content=document.querySelector('.topic_content,.markdown_body')?.textContent?.trim()?.slice(0,300)||'';const replyCount=document.querySelectorAll('.reply_content').length;return JSON.stringify({title,author,content,replyCount});})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"title\":.+\"author\":"
    }
  },
  {
    "name": "v2ex-cross-page-data-collect",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"(()=>{const titles=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim());window.__collected=titles;return JSON.stringify(titles);})()\"",
      "opencli browser open https://v2ex.com/go/programmer?p=2",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 2
    }
  },
  {
    "name": "v2ex-full-workflow",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(()=>{const topics=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>({title:a.textContent.trim(),href:a.href}));return JSON.stringify(topics);})()\"",
      "opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked: '+a.textContent.trim().slice(0,30);}return'not found';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(()=>{const title=document.querySelector('h1')?.textContent?.trim()||document.title;const replies=[...document.querySelectorAll('.reply_content')].slice(0,3).map(el=>el.textContent.trim().slice(0,80));const author=document.querySelector('.header a[href^=\\\"/member/\\\"]')?.textContent?.trim()||'';return JSON.stringify({title,author,replies,replyCount:replies.length});})()\" "
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"title\":.+\"author\":"
    }
  },
  {
    "_comment": "=== Layer 6: State + Click Interaction (10 tasks) ==="
  },
  {
    "name": "v2ex-state-click-topic",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser state",
      "opencli browser click 1"
    ],
    "judge": {
      "type": "contains",
      "value": "Clicked"
    }
  },
  {
    "name": "v2ex-state-click-tab-tech",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser state",
      "opencli browser eval \"(function(){var links=[...document.querySelectorAll('a')];var tab=links.find(a=>a.href&&a.href.includes('tab=tech'));if(tab){var ref=tab.getAttribute('data-opencli-ref');return ref||'no-ref';}return 'not-found';})()\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\d+|no-ref"
    }
  },
  {
    "name": "v2ex-state-count-interactive",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser state"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "interactive: \\d+"
    }
  },
  {
    "name": "v2ex-state-scroll-state",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser scroll down --amount 500",
      "opencli browser state"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\[\\d+\\]"
    }
  },
  {
    "name": "v2ex-type-search-box",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser state",
      "opencli browser eval \"(function(){var input=document.querySelector('input[type=\\\"text\\\"]');if(input){input.focus();input.value='TypeScript';input.dispatchEvent(new Event('input',{bubbles:true}));return input.value;}return 'no-input';})()\""
    ],
    "judge": {
      "type": "contains",
      "value": "TypeScript"
    }
  },
  {
    "name": "v2ex-get-value-after-type",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a)a.click();return 'clicked';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(function(){var ta=document.querySelector('textarea#reply_content,textarea[name=\\\"content\\\"]');if(ta){ta.focus();ta.value='test message 12345';ta.dispatchEvent(new Event('input',{bubbles:true}));return ta.value;}return 'no-textarea';})()\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-screenshot-exists",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser screenshot /tmp/v2ex-test-screenshot.png"
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-get-html-selector",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser get html --selector h1"
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-keys-escape",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser keys Escape"
    ],
    "judge": {
      "type": "contains",
      "value": "pressed"
    }
  },
  {
    "name": "v2ex-wait-text",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser wait text V2EX"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "found|appeared"
    }
  },
  {
    "_comment": "=== Layer 7: Long Chain Workflows (10 tasks) ==="
  },
  {
    "name": "v2ex-chain-3-pages",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"document.title\"",
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"document.title\"",
      "opencli browser open https://v2ex.com/go/python",
      "opencli browser eval \"document.title\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-chain-navigate-extract-back",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){var t=a.textContent.trim();a.click();return t;}return 'none';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.querySelector('h1')?.textContent?.trim()||document.title\"",
      "opencli browser back",
      "opencli browser wait time 1",
      "opencli browser eval \"document.title\""
    ],
    "judge": {
      "type": "contains",
      "value": "V2EX"
    }
  },
  {
    "name": "v2ex-chain-multi-node-scroll",
    "steps": [
      "opencli browser open https://v2ex.com/go/python",
      "opencli browser scroll down --amount 500",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\"",
      "opencli browser open https://v2ex.com/go/go",
      "opencli browser scroll down --amount 500",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\d+"
    }
  },
  {
    "name": "v2ex-chain-topic-replies-pagination",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(function(){var links=document.querySelectorAll('a[href^=\\\"/t/\\\"]');for(var i=0;i<links.length;i++){var row=links[i].closest('tr')||links[i].parentElement;var count=row?.querySelector('a[class*=\\\"count\\\"]');if(count&&parseInt(count.textContent)>5){links[i].click();return 'clicked topic with '+count.textContent+' replies';}}return 'no high-reply topic';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.querySelectorAll('.reply_content').length\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\d+"
    }
  },
  {
    "name": "v2ex-chain-member-topics",
    "steps": [
      "opencli browser open https://v2ex.com/member/Livid",
      "opencli browser eval \"document.querySelector('h1')?.textContent?.trim()\"",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()))\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-chain-search-navigate-extract",
    "steps": [
      "opencli browser open https://www.google.com/search?q=site:v2ex.com+Python",
      "opencli browser wait time 2",
      "opencli browser eval \"(function(){var links=[...document.querySelectorAll('a')];var v2exLink=links.find(a=>a.href&&a.href.includes('v2ex.com/t/'));if(v2exLink){v2exLink.click();return 'clicked';}return 'no v2ex link found';})()\"",
      "opencli browser wait time 3",
      "opencli browser eval \"document.title\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-chain-tab-topic-author",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=tech",
      "opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"(function(){var author=document.querySelector('.header a[href^=\\\"/member/\\\"]');if(author){var name=author.textContent.trim();author.click();return name;}return 'no author';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.querySelector('h1')?.textContent?.trim()||'no h1'\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-chain-node-page2-extract",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,2).map(a=>a.textContent.trim()))\"",
      "opencli browser open https://v2ex.com/go/programmer?p=2",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,2).map(a=>a.textContent.trim()))\"",
      "opencli browser open https://v2ex.com/go/programmer?p=3",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,2).map(a=>a.textContent.trim()))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 1
    }
  },
  {
    "name": "v2ex-chain-full-interaction",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser state",
      "opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
      "opencli browser wait time 2",
      "opencli browser state",
      "opencli browser eval \"(function(){var ta=document.querySelector('textarea#reply_content');if(ta)return 'reply form found';return 'no reply form';})()\"",
      "opencli browser eval \"JSON.stringify({title:document.querySelector('h1')?.textContent?.trim()||document.title,replies:document.querySelectorAll('.reply_content').length})\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"title\":"
    }
  },
  {
    "name": "v2ex-chain-deep-5-step",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/go/\\\"]').length\"",
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\"",
      "opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.querySelectorAll('.reply_content').length\"",
      "opencli browser back",
      "opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\d+"
    }
  },
  {
    "_comment": "=== Edge Cases: SPA navigation, timing, dynamic content ==="
  },
  {
    "name": "v2ex-rapid-navigate",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser open https://v2ex.com/go/python",
      "opencli browser eval \"location.pathname\""
    ],
    "judge": {
      "type": "contains",
      "value": "/go/python"
    }
  },
  {
    "name": "v2ex-eval-after-click",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
      "opencli browser wait time 1",
      "opencli browser eval \"location.pathname.startsWith('/t/') ? 'on topic page' : 'wrong page: '+location.pathname\""
    ],
    "judge": {
      "type": "contains",
      "value": "on topic page"
    }
  },
  {
    "name": "v2ex-scroll-and-extract",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser scroll down --amount 2000",
      "opencli browser wait time 1",
      "opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(-3).map(a=>a.textContent.trim().slice(0,30)))\""
    ],
    "judge": {
      "type": "arrayMinLength",
      "minLength": 2
    }
  },
  {
    "name": "v2ex-concurrent-eval",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser eval \"JSON.stringify({title:document.title,url:location.href,links:document.querySelectorAll('a').length})\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\"title\":.*\"url\":.*\"links\":"
    }
  },
  {
    "name": "v2ex-unicode-content",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');return a?a.textContent.trim():'none';})()\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "_comment": "=== Agent-Style: state + click + type (no eval for interaction) ==="
  },
  {
    "name": "v2ex-agent-click-first-topic",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser state",
      "opencli browser eval \"(function(){var links=document.querySelectorAll('[data-opencli-ref]');for(var i=0;i<links.length;i++){if(links[i].pathname&&links[i].pathname.startsWith('/t/'))return links[i].getAttribute('data-opencli-ref');}return 'none';})()\""
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "\\d+"
    },
    "note": "Finds the index of first topic link via data-opencli-ref"
  },
  {
    "name": "v2ex-agent-type-search",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser state",
      "opencli browser type 3 TypeScript",
      "opencli browser get value 3"
    ],
    "judge": {
      "type": "contains",
      "value": "TypeScript"
    },
    "note": "Types into search box using state index"
  },
  {
    "name": "v2ex-agent-click-navigate-back",
    "steps": [
      "opencli browser open https://v2ex.com/?tab=hot",
      "opencli browser state",
      "opencli browser eval \"(function(){var links=document.querySelectorAll('[data-opencli-ref]');for(var i=0;i<links.length;i++){if(links[i].pathname&&links[i].pathname.startsWith('/t/')){var ref=links[i].getAttribute('data-opencli-ref');document.querySelector('[data-opencli-ref=\\\"'+ref+'\\\"]').click();return 'clicked '+ref;}}return 'none';})()\"",
      "opencli browser wait time 2",
      "opencli browser eval \"document.title\""
    ],
    "judge": {
      "type": "nonEmpty"
    }
  },
  {
    "name": "v2ex-agent-state-has-interactive",
    "steps": [
      "opencli browser open https://v2ex.com/",
      "opencli browser state"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "interactive: \\d+"
    }
  },
  {
    "name": "v2ex-agent-state-after-scroll",
    "steps": [
      "opencli browser open https://v2ex.com/go/programmer",
      "opencli browser scroll down --amount 800",
      "opencli browser state"
    ],
    "judge": {
      "type": "matchesPattern",
      "pattern": "page_scroll: [\\d.]+↑"
    }
  }
]