module.exports=[47125,e=>{"use strict";async function t(e,t){console.log(`[Step 1] Identifying affected pages from ${e.length} changed files...`);let s=[/\/pages\/(.*)\.(tsx?|jsx?)$/,/\/app\/(.*)\/(page|route)\.(tsx?|jsx?)$/,/\/routes\/(.*)\.(tsx?|jsx?)$/,/\/src\/routes\/(.*)\.(svelte|tsx?|jsx?)$/,/\.page\.(tsx?|jsx?)$/,/\.route\.(tsx?|jsx?)$/],a=[];for(let t of e)for(let e of s){let s=t.match(e);if(s){let e=s[1]||"";(e=(e=e.replace(/\/(page|route|index)$/,""))||"/").startsWith("/")||(e=`/${e}`),a.includes(e)||a.push(e);break}}if(console.log(`[Step 1] Detected ${a.length} pages from file patterns`),t&&t.length>10){console.log("[Step 1] Analyzing PR description for mentioned pages...");let s=createGateway({apiKey:process.env.AI_GATEWAY_API_KEY,baseURL:"https://ai-gateway.vercel.sh/v1/ai"})("anthropic/claude-sonnet-4-20250514"),r=`Analyze this PR description and extract any URL paths or routes that are mentioned or affected.

PR Description:
${t}

Changed files:
${e.join("\n")}

Return ONLY a JSON array of paths (e.g., ["/", "/about", "/api/users"]). If no specific paths are mentioned, return an empty array [].
Do not include explanations, just the JSON array.`;try{let{text:e}=await generateText({model:s,prompt:r,maxTokens:500}),t=e.match(/\[.*\]/);if(t){let e=JSON.parse(t[0]);for(let t of e)t&&!a.includes(t)&&a.push(t);console.log(`[Step 1] AI found ${e.length} additional pages`)}}catch(e){console.error("[Step 1] AI analysis failed:",e)}}return 0===a.length&&(console.log("[Step 1] No specific pages detected, checking homepage"),a.push("/")),console.log(`[Step 1] Final pages to check: ${a.join(", ")}`),a}async function s(e,t){console.log(`[Step 2] Crawling ${t.length} pages on ${e}`);let s=[];for(let a of t){console.log(`[Step 2] Crawling: ${a}`);try{let t=`${e}${a}`,r=await fetch(t,{method:"GET",headers:{"User-Agent":"dev3000-pr-checker/1.0",Accept:"text/html,application/json,*/*"}}),o=r.headers.get("content-type")||"",n=o.includes("text/html"),i=o.includes("application/json"),l="";(n||i)&&(l=(await r.text()).substring(0,1e3)),s.push({page:a,url:t,status:r.status,statusText:r.statusText,contentType:o,bodyPreview:l,headers:Object.fromEntries(r.headers.entries())}),console.log(`[Step 2] ${a}: ${r.status} ${r.statusText}`)}catch(t){console.error(`[Step 2] Failed to crawl ${a}:`,t),s.push({page:a,url:`${e}${a}`,status:0,statusText:"Fetch failed",error:t instanceof Error?t.message:String(t)})}}return console.log(`[Step 2] Crawled ${s.length} pages`),s}async function a(e,t,s,a){console.log("[Step 3] Verifying PR claims against actual behavior...");let r=createGateway({apiKey:process.env.AI_GATEWAY_API_KEY,baseURL:"https://ai-gateway.vercel.sh/v1/ai"})("anthropic/claude-sonnet-4-20250514"),o=`You are verifying a Pull Request for accuracy. Compare the PR's claims with the actual deployment behavior.

PR Title: ${e}

PR Description:
${t}

Changed Files:
${a.join("\n")}

Crawl Results from Preview Deployment:
${JSON.stringify(s,null,2)}

Your task:
1. Analyze whether the PR's claimed changes match the actual behavior shown in the crawl results
2. Check if pages load successfully (200 status codes)
3. Identify any errors or unexpected behavior
4. Verify the changes work as described

Respond in this exact JSON format:
{
  "allChecksPassed": boolean,
  "summary": "Brief summary of findings",
  "details": {
    "claimsVerified": ["List of claims that were verified"],
    "issues": ["List of any issues found"],
    "warnings": ["List of warnings"]
  }
}

Only return valid JSON, no additional text.`;try{let{text:e}=await generateText({model:r,prompt:o,maxTokens:1500}),t=e.match(/\{[\s\S]*\}/);if(t){let e=JSON.parse(t[0]);return console.log(`[Step 3] Verification complete: ${e.allChecksPassed?"PASSED":"FAILED"}`),e}return console.error("[Step 3] Failed to parse AI response"),{allChecksPassed:!1,summary:"Verification failed - could not parse AI response",details:{claimsVerified:[],issues:["AI verification returned invalid format"],warnings:[]}}}catch(e){return console.error("[Step 3] Verification failed:",e),{allChecksPassed:!1,summary:`Verification error: ${e instanceof Error?e.message:String(e)}`,details:{claimsVerified:[],issues:[e instanceof Error?e.message:String(e)],warnings:[]}}}}async function r(e,t){console.log(`[Step 4] Checking performance for ${t.length} pages`);let s=[];for(let a of t){console.log(`[Step 4] Measuring performance: ${a}`);try{let t=`${e}${a}`,r=Date.now(),o=await fetch(t,{method:"GET",headers:{"User-Agent":"dev3000-pr-checker/1.0",Accept:"text/html,*/*"}}),n=Date.now()-r,i=Number.parseInt(o.headers.get("content-length")||"0",10);s.push({page:a,loadTime:n,contentLength:i,status:o.status,isSlow:n>2e3}),console.log(`[Step 4] ${a}: ${n}ms, ${i} bytes`)}catch(e){console.error(`[Step 4] Performance check failed for ${a}:`,e),s.push({page:a,loadTime:0,contentLength:0,status:0,error:e instanceof Error?e.message:String(e),isSlow:!1})}}let a=s.filter(e=>e.isSlow);return console.log(`[Step 4] Performance check complete. ${a.length} slow pages found.`),{results:s,slowPagesCount:a.length,summary:{avgLoadTime:s.reduce((e,t)=>e+t.loadTime,0)/s.length,slowPages:a.map(e=>e.page)}}}async function o(e){console.log("[Step 5] Generating comprehensive report...");let{prTitle:t,prBody:s,prNumber:a,previewUrl:r,changedFiles:o,pagesToCheck:n,crawlResults:i,verification:l,performanceResults:c,repoOwner:p,repoName:g}=e,u=`# PR Verification Report

`;for(let e of(u+=`**PR**: #${a} - ${t}
**Repository**: ${p}/${g}
**Preview URL**: ${r}
**Timestamp**: ${new Date().toISOString()}

## Summary

${l.allChecksPassed?"✅":"❌"} ${l.summary}

## Changed Files

`,o))u+=`- ${e}
`;for(let e of(u+=`
## Pages Checked

`,n))u+=`- ${e}
`;if(u+=`
## Verification Results

`,l.details.claimsVerified.length>0){for(let e of(u+=`### Claims Verified ✅

`,l.details.claimsVerified))u+=`- ${e}
`;u+=`
`}if(l.details.issues.length>0){for(let e of(u+=`### Issues Found ❌

`,l.details.issues))u+=`- ${e}
`;u+=`
`}if(l.details.warnings.length>0){for(let e of(u+=`### Warnings ⚠️

`,l.details.warnings))u+=`- ${e}
`;u+=`
`}for(let e of(u+=`## Crawl Results

`,i)){let t=200===e.status?"✅":e.status>=400?"❌":"⚠️";u+=`### ${t} ${e.page}

- **URL**: ${e.url}
- **Status**: ${e.status} ${e.statusText}
`,e.contentType&&(u+=`- **Content-Type**: ${e.contentType}
`),e.error&&(u+=`- **Error**: ${e.error}
`),u+=`
`}if(u+=`## Performance Analysis

**Average Load Time**: ${Math.round(c.summary.avgLoadTime)}ms

`,c.slowPagesCount>0){for(let e of(u+=`⚠️ **Slow Pages** (>2s):
`,c.summary.slowPages))u+=`- ${e}
`;u+=`
`}else u+=`✅ All pages loaded in under 2 seconds

`;for(let e of(u+=`### Detailed Metrics

`,c.results))u+=`- **${e.page}**: ${e.loadTime}ms (${e.contentLength} bytes)
`;return u+=`
## PR Description

${s||"(No description provided)"}

---

*Generated by dev3000 PR Checker*
`,console.log(`[Step 5] Report generated (${u.length} characters)`),u}async function n(e,t,s,a){console.log("[Step 6] Uploading report to blob storage...");let r=new Date().toISOString().replace(/[:.]/g,"-"),o=`pr-check-${t}-${s}-pr${a}-${r}.md`,n=await put(o,e,{access:"public",contentType:"text/markdown"});return console.log(`[Step 6] Report uploaded: ${n.url}`),{blobUrl:n.url,filename:o}}e.s(["checkPerformance",()=>r,"crawlPreviewPages",()=>s,"generateReport",()=>o,"identifyAffectedPages",()=>t,"uploadReport",()=>n,"verifyPRClaims",()=>a])}];

//# sourceMappingURL=mcp-server_app_api_cloud_check-pr_steps_ts_d5661250._.js.map