@better-vibe/branch-narrator 1.2.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -2
  2. package/dist/analyzers/angular-components.d.ts +7 -0
  3. package/dist/analyzers/angular-components.d.ts.map +1 -0
  4. package/dist/analyzers/angular-routes.d.ts +40 -0
  5. package/dist/analyzers/angular-routes.d.ts.map +1 -0
  6. package/dist/analyzers/index.d.ts +3 -0
  7. package/dist/analyzers/index.d.ts.map +1 -1
  8. package/dist/analyzers/vite-config.d.ts +13 -0
  9. package/dist/analyzers/vite-config.d.ts.map +1 -0
  10. package/dist/analyzers/vitest.d.ts.map +1 -1
  11. package/dist/cli.js +328 -239
  12. package/dist/commands/facts/highlights.d.ts.map +1 -1
  13. package/dist/commands/integrate/shared.d.ts +1 -1
  14. package/dist/commands/integrate/shared.d.ts.map +1 -1
  15. package/dist/commands/snap/index.d.ts +1 -1
  16. package/dist/core/ids.d.ts.map +1 -1
  17. package/dist/core/types.d.ts +39 -2
  18. package/dist/core/types.d.ts.map +1 -1
  19. package/dist/git/collector.d.ts +1 -2
  20. package/dist/git/collector.d.ts.map +1 -1
  21. package/dist/index.js +240 -196
  22. package/dist/profiles/angular.d.ts +9 -0
  23. package/dist/profiles/angular.d.ts.map +1 -0
  24. package/dist/profiles/index.d.ts +19 -1
  25. package/dist/profiles/index.d.ts.map +1 -1
  26. package/dist/profiles/vite.d.ts +21 -0
  27. package/dist/profiles/vite.d.ts.map +1 -0
  28. package/dist/render/index.d.ts +1 -0
  29. package/dist/render/index.d.ts.map +1 -1
  30. package/dist/render/markdown.d.ts +2 -0
  31. package/dist/render/markdown.d.ts.map +1 -1
  32. package/dist/render/summary.d.ts +61 -0
  33. package/dist/render/summary.d.ts.map +1 -0
  34. package/dist/render/terminal.d.ts +2 -0
  35. package/dist/render/terminal.d.ts.map +1 -1
  36. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,58 +1,62 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as _Z}from"node:module";var GZ=Object.create;var{getPrototypeOf:OZ,defineProperty:b0,getOwnPropertyNames:MZ}=Object;var HZ=Object.prototype.hasOwnProperty;var D1=($,Z,Q)=>{Q=$!=null?GZ(OZ($)):{};let X=Z||!$||!$.__esModule?b0(Q,"default",{value:$,enumerable:!0}):Q;for(let K of MZ($))if(!HZ.call(X,K))b0(X,K,{get:()=>$[K],enumerable:!0});return X};var A1=($,Z)=>{for(var Q in Z)b0($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:(X)=>Z[Q]=()=>X})};var x=($,Z)=>()=>($&&(Z=$($=0)),Z);var N1=_Z(import.meta.url);var v,q$,M1,zZ,d;var H1=x(()=>{v=class v extends Error{exitCode;constructor($,Z=1){super($);this.exitCode=Z;this.name="BranchNarratorError"}};q$=class q$ extends v{constructor($=process.cwd()){super(`Not a git repository: ${$}
3
- Please run this command from within a git repository.`,1);this.name="NotAGitRepoError"}};M1=class M1 extends v{constructor($){super(`Invalid git reference: ${$}
4
- Please ensure the branch or commit exists.`,1);this.name="InvalidRefError"}};zZ=class zZ extends v{constructor($,Z){super(`No differences found between ${$} and ${Z}.
5
- The branches may be identical or one may not exist.`,1);this.name="NoDiffError"}};d=class d extends v{stderr;constructor($,Z){super(`Git command failed: ${$}
6
- ${Z}`,1);this.stderr=Z;this.name="GitCommandError"}}});import{readFile as LZ}from"node:fs/promises";import{join as C0,dirname as jZ}from"node:path";import{fileURLToPath as DZ}from"node:url";async function NZ($){try{let Z=await LZ($,"utf-8");return JSON.parse(Z).version||null}catch{return null}}async function g$(){if(h$)return h$;let $=[C0(P0,"..","package.json"),C0(P0,"..","..","package.json"),C0(P0,"package.json")];for(let Z of $){let Q=await NZ(Z);if(Q)return h$=Q,Q}return"unknown"}function o2(){return h$??"unknown"}var AZ,P0,h$=null;var l$=x(()=>{AZ=DZ(import.meta.url),P0=jZ(AZ)});async function I1($,Z){return(await Promise.all($.map((X)=>X.analyze(Z)))).flat()}function uZ($){let Z=$.trim().split(`
7
- `).filter(Boolean),Q=[];for(let X of Z){let K=X.split("\t"),Y=K[0];if(Y.startsWith("R"))Q.push({path:K[2],status:"renamed",oldPath:K[1]});else if(Y==="A")Q.push({path:K[1],status:"added"});else if(Y==="M")Q.push({path:K[1],status:"modified"});else if(Y==="D")Q.push({path:K[1],status:"deleted"})}return Q}function hZ($,Z){let Q=new Map,X=new Map;for(let K of Z)if(Q.set(K.path,K.status),K.oldPath)X.set(K.path,K.oldPath),Q.set(K.oldPath,K.status);return $.map((K)=>{let W=(K.to==="/dev/null"?K.from:K.to).replace(/^[ab]\//,""),q=Q.get(W)??"modified",V=(K.chunks||[]).map((U)=>{let J=[],B=[];for(let G of U.changes||[])if(G.type==="add")J.push(G.content.slice(1));else if(G.type==="del")B.push(G.content.slice(1));return{oldStart:U.oldStart,oldLines:U.oldLines,newStart:U.newStart,newLines:U.newLines,content:U.content,additions:J,deletions:B}});return{path:W,status:q,oldPath:X.get(W),hunks:V}})}function c0($){let Z=uZ($.nameStatusOutput),Q=hZ($.parsedDiffs,Z);return{base:$.base,head:$.head,files:Z,diffs:Q,basePackageJson:$.basePackageJson,headPackageJson:$.headPackageJson}}function MK($={}){return{base:"main",head:"HEAD",files:[],diffs:[],...$}}function HK($,Z,Q="modified"){return{path:$,status:Q,hunks:[{oldStart:1,oldLines:0,newStart:1,newLines:Z.length,content:"@@ -0,0 +1 @@",additions:Z,deletions:[]}]}}var G5={};A1(G5,{refExists:()=>U$,isWorkingDirDirty:()=>J$,isGitRepo:()=>f0,getUntrackedFiles:()=>d0,getUnifiedDiffByMode:()=>U5,getUnifiedDiff:()=>J5,getRepoRoot:()=>V$,getNameStatusByMode:()=>W5,getNameStatus:()=>V5,getFileAtRef:()=>g1,getDefaultBranch:()=>p0,collectChangeSet:()=>l1});import{execa as T1}from"execa";import q5 from"parse-diff";async function f0($=process.cwd()){try{let Z=await T1("git",["rev-parse","--is-inside-work-tree"],{cwd:$,reject:!1});return Z.exitCode===0&&Z.stdout.trim()==="true"}catch{return!1}}async function p0($=process.cwd()){try{let Z=await T1("git",["symbolic-ref","refs/remotes/origin/HEAD"],{cwd:$,reject:!1});if(Z.exitCode===0){let Q=Z.stdout.trim().split("/");if(Q.length>0)return Q[Q.length-1]}}catch{}return"main"}async function U$($,Z=process.cwd()){try{return(await T1("git",["rev-parse","--verify",$],{cwd:Z,reject:!1})).exitCode===0}catch{return!1}}function gZ($){let Z=["diff","--name-status","--find-renames"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}return Z}function lZ($){let Z=["diff","--unified=3"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}return Z}async function W5($,Z=process.cwd()){let Q=gZ($);try{return(await T1("git",Q,{cwd:Z})).stdout}catch(X){if(X instanceof Error&&"stderr"in X)throw new d(`git ${Q.join(" ")}`,String(X.stderr));throw X}}async function U5($,Z=process.cwd()){let Q=lZ($);try{return(await T1("git",Q,{cwd:Z})).stdout}catch(X){if(X instanceof Error&&"stderr"in X)throw new d(`git ${Q.join(" ")}`,String(X.stderr));throw X}}async function V5($,Z,Q=process.cwd()){try{let X=Z?["diff","--name-status","--find-renames",`${$}..${Z}`]:["diff","--name-status","--find-renames",$];return(await T1("git",X,{cwd:Q})).stdout}catch(X){if(X instanceof Error&&"stderr"in X){let K=Z?`${$}..${Z}`:$;throw new d(`git diff --name-status ${K}`,String(X.stderr))}throw X}}async function J5($,Z,Q=process.cwd()){try{let X=Z?["diff","--unified=3",`${$}..${Z}`]:["diff","--unified=3",$];return(await T1("git",X,{cwd:Q})).stdout}catch(X){if(X instanceof Error&&"stderr"in X){let K=Z?`${$}..${Z}`:$;throw new d(`git diff ${K}`,String(X.stderr))}throw X}}async function g1($,Z,Q=process.cwd()){try{let X=await T1("git",["show",`${$}:${Z}`],{cwd:Q,reject:!1});if(X.exitCode===0)return X.stdout;return null}catch{return null}}function n1($){if(!$)return;try{return JSON.parse($)}catch{return}}async function d0($=process.cwd()){try{return(await T1("git",["ls-files","--others","--exclude-standard"],{cwd:$})).stdout.trim().split(`
8
- `).filter(Boolean)}catch{return[]}}async function cZ($,Z){try{let{readFile:Q}=await import("node:fs/promises"),{join:X}=await import("node:path");return await Q(X(Z,$),"utf-8")}catch{return null}}async function B5($,Z){let Q=[],X=[];for(let K of $){if(pZ(K)){Q.push(`A ${K}`);continue}let Y=await cZ(K,Z);if(Y===null)continue;Q.push(`A ${K}`);let W=Y.split(`
9
- `),q=W.map((V,U)=>({type:"add",content:"+"+V,ln:U+1}));X.push({from:"/dev/null",to:K,chunks:[{content:`@@ -0,0 +1,${W.length} @@`,oldStart:0,oldLines:0,newStart:1,newLines:W.length,changes:q}],deletions:0,additions:W.length})}return{nameStatus:Q.join(`
10
- `),diffs:X}}function pZ($){let Z=$.toLowerCase(),Q=Z.lastIndexOf(".");if(Q===-1)return!1;let X=Z.slice(Q);return fZ.has(X)}async function w$($){try{let{readFile:Z}=await import("node:fs/promises"),{join:Q}=await import("node:path"),X=await Z(Q($,"package.json"),"utf-8");return JSON.parse(X)}catch{return}}async function l1($,Z,Q=process.cwd()){if(typeof $==="object"&&"mode"in $)return dZ($);let X;if(typeof $==="string")X={base:$,head:Z,cwd:Q};else X=$,Q=X.cwd??process.cwd();let{base:K,uncommitted:Y}=X,W=Y?null:X.head;if(!await f0(Q))throw new q$(Q);if(!await U$(K,Q))throw new M1(K);if(W&&!await U$(W,Q))throw new M1(W);let[q,V,U]=await Promise.all([V5(K,W,Q),J5(K,W,Q),g1(K,"package.json",Q)]),J=q5(V),B=q;if(Y){let M=await d0(Q);if(M.length>0){let H=await B5(M,Q);if(H.nameStatus)B=B?`${B}
11
- ${H.nameStatus}`:H.nameStatus;J=[...J,...H.diffs]}}let G=Y?await w$(Q):n1(await g1(W,"package.json",Q));return c0({base:K,head:Y?"WORKING":X.head,nameStatusOutput:B,parsedDiffs:J,basePackageJson:n1(U),headPackageJson:Y?G:n1(await g1(X.head,"package.json",Q))})}async function dZ($){let Z=$.cwd??process.cwd(),Q=$.includeUntracked??($.mode==="all"||$.mode==="unstaged");if(!await f0(Z))throw new q$(Z);if($.mode==="branch"){if(!$.base)throw new M1("base (required for branch mode)");if(!$.head)throw new M1("head (required for branch mode)");if(!await U$($.base,Z))throw new M1($.base);if(!await U$($.head,Z))throw new M1($.head)}if($.mode==="staged"||$.mode==="all"){if(!await U$("HEAD",Z))throw new M1("HEAD")}let[X,K]=await Promise.all([W5($,Z),U5($,Z)]),Y=q5(K),W=X;if(Q&&$.mode!=="branch"){let B=await d0(Z);if(B.length>0){let G=await B5(B,Z);if(G.nameStatus)W=W?`${W}
12
- ${G.nameStatus}`:G.nameStatus;Y=[...Y,...G.diffs]}}let q,V,U,J;switch($.mode){case"branch":q=$.base,V=$.head,U=n1(await g1(q,"package.json",Z)),J=n1(await g1(V,"package.json",Z));break;case"unstaged":q="INDEX",V="WORKING",U=await w$(Z),J=await w$(Z);break;case"staged":q="HEAD",V="INDEX",U=n1(await g1("HEAD","package.json",Z)),J=await w$(Z);break;case"all":q="HEAD",V="WORKING",U=n1(await g1("HEAD","package.json",Z)),J=await w$(Z);break}return c0({base:q,head:V,nameStatusOutput:W,parsedDiffs:Y,basePackageJson:U,headPackageJson:J})}async function V$($=process.cwd()){try{return(await T1("git",["rev-parse","--show-toplevel"],{cwd:$})).stdout.trim()}catch{return $}}async function J$($=process.cwd()){try{return(await T1("git",["diff-index","--quiet","HEAD","--"],{cwd:$,reject:!1})).exitCode!==0}catch{return!1}}var fZ;var B$=x(()=>{H1();fZ=new Set([".png",".jpg",".jpeg",".gif",".webp",".ico",".svg",".woff",".woff2",".ttf",".eot",".otf",".zip",".tar",".gz",".tgz",".rar",".pdf",".doc",".docx",".xls",".xlsx",".exe",".dll",".so",".dylib",".mp3",".mp4",".wav",".avi",".mov",".lockb"])});function E$($){return rZ.some((Z)=>Z.test($))}var O5,rZ;var s$=x(()=>{O5=["**/*.d.ts","**/*.map","**/*.min.js","**/*.min.css","**/node_modules/**","**/dist/**","**/build/**","**/.next/**","**/.svelte-kit/**","**/.nuxt/**","**/out/**","**/.cache/**","**/.parcel-cache/**","**/vendor/**","**/*.log","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/bun.lock","**/*.tgz","**/*.tar.gz","**/*.zip"],rZ=[/^dist\//,/^build\//,/^\.next\//,/^\.svelte-kit\//,/^\.nuxt\//,/^out\//,/^node_modules\//,/^vendor\//,/\.map$/,/\.d\.ts$/,/\.min\.(js|css)$/,/^\.cache\//,/^\.parcel-cache\//]});function aZ($,Z,Q){let X=[],K=$.matchAll(/(?:export\s+)?(?:async\s+)?function\s+(\w+)/g);for(let w of K){let T=w[1];if(Z.includes(`function ${T}`))X.push({description:`Modified function: ${T}()`,priority:100});else if(Q==="modified")X.push({description:`Added function: ${T}()`,priority:100});else X.push({description:`Added function: ${T}()`,priority:100})}let Y=$.matchAll(/export\s+const\s+(\w+)\s*=\s*(?:async\s*)?\([^)]*\)\s*(?::\s*[^=]+)?\s*=>/g);for(let w of Y){let T=w[1];if(Z.includes(`const ${T}`))X.push({description:`Modified: ${T}()`,priority:95});else X.push({description:`Added: ${T}()`,priority:95})}let W=$.matchAll(/(?:export\s+)?class\s+(\w+)/g);for(let w of W){let T=w[1];if(Z.includes(`class ${T}`))X.push({description:`Modified class: ${T}`,priority:90});else X.push({description:`Added class: ${T}`,priority:90})}let q=$.matchAll(/(?:export\s+)?interface\s+(\w+)/g);for(let w of q){let T=w[1];if(Z.includes(`interface ${T}`))X.push({description:`Modified interface: ${T}`,priority:80});else X.push({description:`Added interface: ${T}`,priority:80})}let V=$.matchAll(/(?:export\s+)?type\s+(\w+)\s*=/g);for(let w of V){let T=w[1];if(Z.includes(`type ${T}`))X.push({description:`Modified type: ${T}`,priority:80});else X.push({description:`Added type: ${T}`,priority:80})}let U=$.matchAll(/(?:export\s+)?enum\s+(\w+)/g);for(let w of U){let T=w[1];if(Z.includes(`enum ${T}`))X.push({description:`Modified enum: ${T}`,priority:75});else X.push({description:`Added enum: ${T}`,priority:75})}let J=$.matchAll(/export\s+const\s+(\w+)\s*(?::\s*[^=]+)?\s*=/g);for(let w of J){let T=w[1];if(new RegExp(`export\\s+const\\s+${T}\\s*=\\s*(?:async\\s*)?\\(`).test($))continue;if(Z.includes(`const ${T}`))X.push({description:`Modified const: ${T}`,priority:70});else X.push({description:`Added const: ${T}`,priority:70})}let B=$.match(/export\s+\*\s+from\s+['"]([^'"]+)['"]/);if(B)X.push({description:`Re-exports from: ${B[1]}`,priority:60});let G=$.match(/export\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(G){let w=G[1].split(",").map((A)=>A.trim().split(" ")[0]).slice(0,3),T=G[1].split(",").length>3?" ...":"";X.push({description:`Re-exports: ${w.join(", ")}${T}`,priority:60})}let M=$.matchAll(/^\s*(?:async\s+)?(\w+)\s*\([^)]*\)\s*\{/gm);for(let w of M){let T=w[1];if(["if","for","while","switch","catch","function"].includes(T))continue;if(new RegExp(`\\b${T}\\s*\\(`).test(Z))X.push({description:`Modified method: ${T}()`,priority:65});else if(Q==="added")X.push({description:`Added method: ${T}()`,priority:65})}let H=$.matchAll(/^import\s+(?:\{[^}]+\}|[^{}\s]+)\s+from\s+['"]([^'"]+)['"]/gm),O=[];for(let w of H){let T=w[1];if(!Z.includes(T))O.push(T)}if(O.length>0){let w=O.slice(0,2).map((A)=>A.split("/").pop()||A),T=O.length>2?` (+${O.length-2} more)`:"";X.push({description:`New imports: ${w.join(", ")}${T}`,priority:40})}let z=$.matchAll(/case\s+['"]?([^'":\s]+)['"]?\s*:/g),_=[];for(let w of z){let T=w[1];if(!Z.includes(`case ${T}`)&&!Z.includes(`case "${T}"`)&&!Z.includes(`case '${T}'`))_.push(T)}if(_.length>0){let w=_.slice(0,2),T=_.length>2?` (+${_.length-2} more)`:"";X.push({description:`Added cases: ${w.join(", ")}${T}`,priority:50})}let D=$.matchAll(/\.option\s*\(\s*['"]([^'"]+)['"]/g),L=[];for(let w of D){let T=w[1];if(!Z.includes(T))L.push(T)}if(L.length>0){let w=L.slice(0,2),T=L.length>2?` (+${L.length-2} more)`:"";X.push({description:`Added CLI options: ${w.join(", ")}${T}`,priority:85})}if(/<[A-Z]\w+/.test($)&&($.includes("return")||$.includes("=>")))X.push({description:"Component JSX updated",priority:30});return X}function sZ($){let Z=$.hunks.flatMap((V)=>V.additions).join(`
2
+ import{createRequire as hZ}from"node:module";var CZ=Object.create;var{getPrototypeOf:FZ,defineProperty:F0,getOwnPropertyNames:yZ}=Object;var mZ=Object.prototype.hasOwnProperty;var b1=($,Z,Q)=>{Q=$!=null?CZ(FZ($)):{};let X=Z||!$||!$.__esModule?F0(Q,"default",{value:$,enumerable:!0}):Q;for(let Y of yZ($))if(!mZ.call(X,Y))F0(X,Y,{get:()=>$[Y],enumerable:!0});return X};var P1=($,Z)=>{for(var Q in Z)F0($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:(X)=>Z[Q]=()=>X})};var x=($,Z)=>()=>($&&(Z=$($=0)),Z);var k1=hZ(import.meta.url);var F,V$,T1,uZ,G1;var w1=x(()=>{F=class F extends Error{exitCode;constructor($,Z=1){super($);this.exitCode=Z;this.name="BranchNarratorError"}};V$=class V$ extends F{constructor($=process.cwd()){super(`Not a git repository: ${$}
3
+ Please run this command from within a git repository.`,1);this.name="NotAGitRepoError"}};T1=class T1 extends F{constructor($){super(`Invalid git reference: ${$}
4
+ Please ensure the branch or commit exists.`,1);this.name="InvalidRefError"}};uZ=class uZ extends F{constructor($,Z){super(`No differences found between ${$} and ${Z}.
5
+ The branches may be identical or one may not exist.`,1);this.name="NoDiffError"}};G1=class G1 extends F{stderr;constructor($,Z){super(`Git command failed: ${$}
6
+ ${Z}`,1);this.stderr=Z;this.name="GitCommandError"}}});import{readFile as gZ}from"node:fs/promises";import{join as y0,dirname as cZ}from"node:path";import{fileURLToPath as lZ}from"node:url";async function pZ($){try{let Z=await gZ($,"utf-8");return JSON.parse(Z).version||null}catch{return null}}async function a$(){if(r$)return r$;let $=[y0(m0,"..","package.json"),y0(m0,"..","..","package.json"),y0(m0,"package.json")];for(let Z of $){let Q=await pZ(Z);if(Q)return r$=Q,Q}return"unknown"}function U5(){return r$??"unknown"}var fZ,m0,r$=null;var s$=x(()=>{fZ=lZ(import.meta.url),m0=cZ(fZ)});async function F1($,Z){return(await Promise.all($.map((X)=>X.analyze(Z)))).flat()}function W4($){let Z=$.trim().split(`
7
+ `).filter(Boolean),Q=[];for(let X of Z){let Y=X.split("\t"),K=Y[0];if(K.startsWith("R"))Q.push({path:Y[2],status:"renamed",oldPath:Y[1]});else if(K==="A")Q.push({path:Y[1],status:"added"});else if(K==="M")Q.push({path:Y[1],status:"modified"});else if(K==="D")Q.push({path:Y[1],status:"deleted"})}return Q}function q4($,Z){let Q=new Map,X=new Map;for(let Y of Z)if(Q.set(Y.path,Y.status),Y.oldPath)X.set(Y.path,Y.oldPath),Q.set(Y.oldPath,Y.status);return $.map((Y)=>{let q=(Y.to==="/dev/null"?Y.from:Y.to).replace(/^[ab]\//,""),W=Q.get(q)??"modified",V=(Y.chunks||[]).map((U)=>{let J=[],G=[];for(let B of U.changes||[])if(B.type==="add")J.push(B.content.slice(1));else if(B.type==="del")G.push(B.content.slice(1));return{oldStart:U.oldStart,oldLines:U.oldLines,newStart:U.newStart,newLines:U.newLines,content:U.content,additions:J,deletions:G}});return{path:q,status:W,oldPath:X.get(q),hunks:V}})}function s0($){let Z=W4($.nameStatusOutput),Q=q4($.parsedDiffs,Z);return{base:$.base,head:$.head,files:Z,diffs:Q,basePackageJson:$.basePackageJson,headPackageJson:$.headPackageJson}}function SK($={}){return{base:"main",head:"HEAD",files:[],diffs:[],...$}}function CK($,Z,Q="modified"){return{path:$,status:Q,hunks:[{oldStart:1,oldLines:0,newStart:1,newLines:Z.length,content:"@@ -0,0 +1 @@",additions:Z,deletions:[]}]}}var w5={};P1(w5,{refExists:()=>O$,isWorkingDirDirty:()=>_$,isGitRepo:()=>o0,getUntrackedFiles:()=>T5,getUnifiedDiffByMode:()=>N5,getUnifiedDiff:()=>R5,getRepoRoot:()=>H$,getNameStatusByMode:()=>D5,getNameStatus:()=>A5,getFileAtRef:()=>X$,getDefaultBranch:()=>i0,collectChangeSet:()=>n1});import{execa as S1}from"execa";import L5 from"parse-diff";async function o0($=process.cwd()){try{let Z=await S1("git",["rev-parse","--is-inside-work-tree"],{cwd:$,reject:!1});return Z.exitCode===0&&Z.stdout.trim()==="true"}catch{return!1}}async function i0($=process.cwd()){try{let Z=await S1("git",["symbolic-ref","refs/remotes/origin/HEAD"],{cwd:$,reject:!1});if(Z.exitCode===0){let Q=Z.stdout.trim().split("/");if(Q.length>0)return Q[Q.length-1]}}catch{}return"main"}async function O$($,Z=process.cwd()){try{return(await S1("git",["rev-parse","--verify",$],{cwd:Z,reject:!1})).exitCode===0}catch{return!1}}function U4($){let Z=["diff","--name-status","--find-renames"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}return Z}function V4($){let Z=["diff","--unified=3"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}return Z}async function D5($,Z=process.cwd()){let Q=U4($);try{return(await S1("git",Q,{cwd:Z})).stdout}catch(X){if(X instanceof Error&&"stderr"in X)throw new G1(`git ${Q.join(" ")}`,String(X.stderr));throw X}}async function N5($,Z=process.cwd()){let Q=V4($);try{return(await S1("git",Q,{cwd:Z})).stdout}catch(X){if(X instanceof Error&&"stderr"in X)throw new G1(`git ${Q.join(" ")}`,String(X.stderr));throw X}}async function A5($,Z,Q=process.cwd()){try{let X=Z?["diff","--name-status","--find-renames",`${$}..${Z}`]:["diff","--name-status","--find-renames",$];return(await S1("git",X,{cwd:Q})).stdout}catch(X){if(X instanceof Error&&"stderr"in X){let Y=Z?`${$}..${Z}`:$;throw new G1(`git diff --name-status ${Y}`,String(X.stderr))}throw X}}async function R5($,Z,Q=process.cwd()){try{let X=Z?["diff","--unified=3",`${$}..${Z}`]:["diff","--unified=3",$];return(await S1("git",X,{cwd:Q})).stdout}catch(X){if(X instanceof Error&&"stderr"in X){let Y=Z?`${$}..${Z}`:$;throw new G1(`git diff ${Y}`,String(X.stderr))}throw X}}async function X$($,Z,Q=process.cwd()){try{let X=await S1("git",["show",`${$}:${Z}`],{cwd:Q,reject:!1});if(X.exitCode===0)return X.stdout;return null}catch{return null}}function B$($){if(!$)return;try{return JSON.parse($)}catch{return}}async function T5($=process.cwd()){try{return(await S1("git",["ls-files","--others","--exclude-standard"],{cwd:$})).stdout.trim().split(`
8
+ `).filter(Boolean)}catch{return[]}}async function J4($,Z){try{let{readFile:Q}=await import("node:fs/promises"),{join:X}=await import("node:path");return await Q(X(Z,$),"utf-8")}catch{return null}}async function G4($,Z){let Q=[],X=[];for(let Y of $){if(O4(Y)){Q.push(`A ${Y}`);continue}let K=await J4(Y,Z);if(K===null)continue;Q.push(`A ${Y}`);let q=K.split(`
9
+ `),W=q.map((V,U)=>({type:"add",content:"+"+V,ln:U+1}));X.push({from:"/dev/null",to:Y,chunks:[{content:`@@ -0,0 +1,${q.length} @@`,oldStart:0,oldLines:0,newStart:1,newLines:q.length,changes:W}],deletions:0,additions:q.length})}return{nameStatus:Q.join(`
10
+ `),diffs:X}}function O4($){let Z=$.toLowerCase(),Q=Z.lastIndexOf(".");if(Q===-1)return!1;let X=Z.slice(Q);return B4.has(X)}async function Z0($){try{let{readFile:Z}=await import("node:fs/promises"),{join:Q}=await import("node:path"),X=await Z(Q($,"package.json"),"utf-8");return JSON.parse(X)}catch{return}}async function n1($,Z,Q=process.cwd()){if(typeof $==="object"&&"mode"in $)return H4($);let X;if(typeof $==="string")X={base:$,head:Z,cwd:Q};else X=$,Q=X.cwd??process.cwd();let{base:Y}=X,K=X.head;if(!await o0(Q))throw new V$(Q);if(!await O$(Y,Q))throw new T1(Y);if(K&&!await O$(K,Q))throw new T1(K);let[q,W,V]=await Promise.all([A5(Y,K,Q),R5(Y,K,Q),X$(Y,"package.json",Q)]),U=L5(W),J=B$(await X$(K,"package.json",Q));return s0({base:Y,head:X.head,nameStatusOutput:q,parsedDiffs:U,basePackageJson:B$(V),headPackageJson:J})}async function H4($){let Z=$.cwd??process.cwd(),Q=$.includeUntracked??($.mode==="all"||$.mode==="unstaged");if(!await o0(Z))throw new V$(Z);if($.mode==="branch"){if(!$.base)throw new T1("base (required for branch mode)");if(!$.head)throw new T1("head (required for branch mode)");if(!await O$($.base,Z))throw new T1($.base);if(!await O$($.head,Z))throw new T1($.head)}if($.mode==="staged"||$.mode==="all"){if(!await O$("HEAD",Z))throw new T1("HEAD")}let[X,Y]=await Promise.all([D5($,Z),N5($,Z)]),K=L5(Y),q=X;if(Q&&$.mode!=="branch"){let G=await T5(Z);if(G.length>0){let B=await G4(G,Z);if(B.nameStatus)q=q?`${q}
11
+ ${B.nameStatus}`:B.nameStatus;K=[...K,...B.diffs]}}let W,V,U,J;switch($.mode){case"branch":W=$.base,V=$.head,U=B$(await X$(W,"package.json",Z)),J=B$(await X$(V,"package.json",Z));break;case"unstaged":W="INDEX",V="WORKING",U=await Z0(Z),J=await Z0(Z);break;case"staged":W="HEAD",V="INDEX",U=B$(await X$("HEAD","package.json",Z)),J=await Z0(Z);break;case"all":W="HEAD",V="WORKING",U=B$(await X$("HEAD","package.json",Z)),J=await Z0(Z);break}return s0({base:W,head:V,nameStatusOutput:q,parsedDiffs:K,basePackageJson:U,headPackageJson:J})}async function H$($=process.cwd()){try{return(await S1("git",["rev-parse","--show-toplevel"],{cwd:$})).stdout.trim()}catch{return $}}async function _$($=process.cwd()){try{return(await S1("git",["diff-index","--quiet","HEAD","--"],{cwd:$,reject:!1})).exitCode!==0}catch{return!1}}var B4;var M$=x(()=>{w1();B4=new Set([".png",".jpg",".jpeg",".gif",".webp",".ico",".svg",".woff",".woff2",".ttf",".eot",".otf",".zip",".tar",".gz",".tgz",".rar",".pdf",".doc",".docx",".xls",".xlsx",".exe",".dll",".so",".dylib",".mp3",".mp4",".wav",".avi",".mov",".lockb"])});function v$($){return _4.some((Z)=>Z.test($))}var x5,_4;var Q0=x(()=>{x5=["**/*.d.ts","**/*.map","**/*.min.js","**/*.min.css","**/node_modules/**","**/dist/**","**/build/**","**/.next/**","**/.svelte-kit/**","**/.nuxt/**","**/out/**","**/.cache/**","**/.parcel-cache/**","**/vendor/**","**/*.log","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/bun.lock","**/*.tgz","**/*.tar.gz","**/*.zip"],_4=[/^dist\//,/^build\//,/^\.next\//,/^\.svelte-kit\//,/^\.nuxt\//,/^out\//,/^node_modules\//,/^vendor\//,/\.map$/,/\.d\.ts$/,/\.min\.(js|css)$/,/^\.cache\//,/^\.parcel-cache\//]});function M4($,Z,Q){let X=[],Y=$.matchAll(/(?:export\s+)?(?:async\s+)?function\s+(\w+)/g);for(let E of Y){let w=E[1];if(Z.includes(`function ${w}`))X.push({description:`Modified function: ${w}()`,priority:100});else if(Q==="modified")X.push({description:`Added function: ${w}()`,priority:100});else X.push({description:`Added function: ${w}()`,priority:100})}let K=$.matchAll(/export\s+const\s+(\w+)\s*=\s*(?:async\s*)?\([^)]*\)\s*(?::\s*[^=]+)?\s*=>/g);for(let E of K){let w=E[1];if(Z.includes(`const ${w}`))X.push({description:`Modified: ${w}()`,priority:95});else X.push({description:`Added: ${w}()`,priority:95})}let q=$.matchAll(/(?:export\s+)?class\s+(\w+)/g);for(let E of q){let w=E[1];if(Z.includes(`class ${w}`))X.push({description:`Modified class: ${w}`,priority:90});else X.push({description:`Added class: ${w}`,priority:90})}let W=$.matchAll(/(?:export\s+)?interface\s+(\w+)/g);for(let E of W){let w=E[1];if(Z.includes(`interface ${w}`))X.push({description:`Modified interface: ${w}`,priority:80});else X.push({description:`Added interface: ${w}`,priority:80})}let V=$.matchAll(/(?:export\s+)?type\s+(\w+)\s*=/g);for(let E of V){let w=E[1];if(Z.includes(`type ${w}`))X.push({description:`Modified type: ${w}`,priority:80});else X.push({description:`Added type: ${w}`,priority:80})}let U=$.matchAll(/(?:export\s+)?enum\s+(\w+)/g);for(let E of U){let w=E[1];if(Z.includes(`enum ${w}`))X.push({description:`Modified enum: ${w}`,priority:75});else X.push({description:`Added enum: ${w}`,priority:75})}let J=$.matchAll(/export\s+const\s+(\w+)\s*(?::\s*[^=]+)?\s*=/g);for(let E of J){let w=E[1];if(new RegExp(`export\\s+const\\s+${w}\\s*=\\s*(?:async\\s*)?\\(`).test($))continue;if(Z.includes(`const ${w}`))X.push({description:`Modified const: ${w}`,priority:70});else X.push({description:`Added const: ${w}`,priority:70})}let G=$.match(/export\s+\*\s+from\s+['"]([^'"]+)['"]/);if(G)X.push({description:`Re-exports from: ${G[1]}`,priority:60});let B=$.match(/export\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(B){let E=B[1].split(",").map((T)=>T.trim().split(" ")[0]).slice(0,3),w=B[1].split(",").length>3?" ...":"";X.push({description:`Re-exports: ${E.join(", ")}${w}`,priority:60})}let H=$.matchAll(/^\s*(?:async\s+)?(\w+)\s*\([^)]*\)\s*\{/gm);for(let E of H){let w=E[1];if(["if","for","while","switch","catch","function"].includes(w))continue;if(new RegExp(`\\b${w}\\s*\\(`).test(Z))X.push({description:`Modified method: ${w}()`,priority:65});else if(Q==="added")X.push({description:`Added method: ${w}()`,priority:65})}let _=$.matchAll(/^import\s+(?:\{[^}]+\}|[^{}\s]+)\s+from\s+['"]([^'"]+)['"]/gm),O=[];for(let E of _){let w=E[1];if(!Z.includes(w))O.push(w)}if(O.length>0){let E=O.slice(0,2).map((T)=>T.split("/").pop()||T),w=O.length>2?` (+${O.length-2} more)`:"";X.push({description:`New imports: ${E.join(", ")}${w}`,priority:40})}let M=$.matchAll(/case\s+['"]?([^'":\s]+)['"]?\s*:/g),z=[];for(let E of M){let w=E[1];if(!Z.includes(`case ${w}`)&&!Z.includes(`case "${w}"`)&&!Z.includes(`case '${w}'`))z.push(w)}if(z.length>0){let E=z.slice(0,2),w=z.length>2?` (+${z.length-2} more)`:"";X.push({description:`Added cases: ${E.join(", ")}${w}`,priority:50})}let A=$.matchAll(/\.option\s*\(\s*['"]([^'"]+)['"]/g),N=[];for(let E of A){let w=E[1];if(!Z.includes(w))N.push(w)}if(N.length>0){let E=N.slice(0,2),w=N.length>2?` (+${N.length-2} more)`:"";X.push({description:`Added CLI options: ${E.join(", ")}${w}`,priority:85})}if(/<[A-Z]\w+/.test($)&&($.includes("return")||$.includes("=>")))X.push({description:"Component JSX updated",priority:30});return X}function z4($){let Z=$.hunks.flatMap((V)=>V.additions).join(`
13
12
  `),Q=$.hunks.flatMap((V)=>V.deletions).join(`
14
- `);if($.path.startsWith("src/commands/")&&$.status==="added"){if($.path.endsWith("index.ts"))return"New command module";return"New command helper"}if(/\.test\.[jt]sx?$/.test($.path)||/\.spec\.[jt]sx?$/.test($.path)){if($.status==="added")return"New test file";return"Updated tests"}if($.path.endsWith(".md")||$.path.startsWith("docs/")){if($.status==="added")return"New documentation";return"Documentation update"}if($.path.includes("config")||$.path.endsWith(".json")||$.path.endsWith(".yaml")||$.path.endsWith(".yml")||$.path.endsWith(".toml")||$.path.includes(".env")){if($.status==="added")return"New configuration";return"Configuration update"}let K=aZ(Z,Q,$.status);if(K.length===0)return null;K.sort((V,U)=>U.priority-V.priority);let Y=new Set,W=K.filter((V)=>{if(Y.has(V.description))return!1;return Y.add(V.description),!0}),q=W[0];if(W.length>1)return`${q.description} (+${W.length-1} more)`;return q.description}var a;var M5=x(()=>{s$();a={name:"file-summary",analyze($){let Z=[],Q=[],X=[],K=[],Y=[];for(let q of $.files){if(E$(q.path))continue;switch(q.status){case"added":Z.push(q.path);break;case"modified":Q.push(q.path);break;case"deleted":X.push(q.path);break;case"renamed":K.push({from:q.oldPath??q.path,to:q.path});break}}for(let q of $.diffs){if(E$(q.path))continue;let V=sZ(q);if(V)Y.push({file:q.path,description:V})}if(Z.length===0&&Q.length===0&&X.length===0&&K.length===0)return[];return[{type:"file-summary",kind:"file-summary",category:"unknown",confidence:"high",evidence:[],added:Z,modified:Q,deleted:X,renamed:K,changeDescriptions:Y.length>0?Y:void 0}]}}});function nZ($){for(let Z of oZ)if(Z.patterns.some((Q)=>Q.test($)))return Z.category;return"other"}function o$($){return{product:"Product Code",tests:"Tests",ci:"CI/CD",infra:"Infrastructure",database:"Database",docs:"Documentation",dependencies:"Dependencies",config:"Configuration",artifacts:"Build Artifacts",other:"Other"}[$]}var oZ,s;var n$=x(()=>{oZ=[{category:"tests",patterns:[/^tests?\//i,/^__tests__\//i,/\/tests?\//i,/\/__tests__\//i,/\.test\.[jt]sx?$/i,/\.spec\.[jt]sx?$/i,/\.e2e\.[jt]sx?$/i,/vitest\.config/i,/jest\.config/i,/cypress\//i,/playwright\//i]},{category:"ci",patterns:[/^\.github\/workflows\//,/^\.github\/actions\//,/^\.gitlab-ci\.yml$/,/^\.circleci\//,/^Jenkinsfile$/,/^\.travis\.yml$/,/^azure-pipelines\.yml$/,/^bitbucket-pipelines\.yml$/]},{category:"infra",patterns:[/^Dockerfile/i,/^docker-compose/i,/^\.dockerignore$/,/^helm\//i,/^charts?\//i,/^terraform\//i,/^\.tf$/,/^k8s\//i,/^kubernetes\//i,/^pulumi\//i,/^ansible\//i,/^Vagrantfile$/]},{category:"database",patterns:[/^supabase\/migrations\//,/^supabase\/seed/,/^prisma\/migrations\//,/^prisma\/schema\.prisma$/,/^drizzle\/migrations\//,/^drizzle\.config/,/^migrations?\//i,/\/migrations?\//i,/\.sql$/i]},{category:"docs",patterns:[/^docs?\//i,/^documentation\//i,/\.md$/i,/\.mdx$/i,/^README/i,/^CHANGELOG/i,/^CONTRIBUTING/i,/^LICENSE/i,/^\.all-contributorsrc$/]},{category:"dependencies",patterns:[/^package\.json$/,/^package-lock\.json$/,/^yarn\.lock$/,/^pnpm-lock\.yaml$/,/^bun\.lock$/,/^bun\.lockb$/,/^requirements\.txt$/,/^Pipfile(\.lock)?$/,/^poetry\.lock$/,/^pyproject\.toml$/,/^Cargo\.(toml|lock)$/,/^go\.(mod|sum)$/,/^Gemfile(\.lock)?$/,/^composer\.(json|lock)$/]},{category:"config",patterns:[/^\.[a-z]+rc(\.json|\.js|\.cjs|\.mjs|\.yaml|\.yml)?$/i,/\.config\.[jt]s$/i,/\.config\.[a-z]+\.[jt]s$/i,/^\.env/i,/^wrangler\.(toml|json)$/i,/^tsconfig.*\.json$/i,/^\.eslintrc/i,/^\.prettierrc/i,/^\.editorconfig$/,/^\.gitignore$/,/^\.nvmrc$/,/^\.node-version$/]},{category:"artifacts",patterns:[/\.tgz$/i,/\.tar\.gz$/i,/\.zip$/i,/\.whl$/i,/\.jar$/i,/\.war$/i,/\.gem$/i,/\.nupkg$/i,/\.deb$/i,/\.rpm$/i,/\.dmg$/i,/\.exe$/i,/\.dll$/i,/\.so$/i,/\.dylib$/i,/\.a$/i,/\.o$/i,/\.wasm$/i]},{category:"product",patterns:[/^src\//,/^lib\//,/^app\//,/^pages\//,/^components\//,/^hooks\//,/^utils\//,/^services\//,/^api\//,/^server\//,/^client\//,/\.[jt]sx?$/,/\.svelte$/,/\.vue$/,/\.astro$/]}];s={name:"file-category",analyze($){let Z={product:[],tests:[],ci:[],infra:[],database:[],docs:[],dependencies:[],config:[],artifacts:[],other:[]};for(let K of $.files){let Y=nZ(K.path);Z[Y].push(K.path)}let Q=Object.entries(Z).filter(([,K])=>K.length>0).map(([K,Y])=>({category:K,count:Y.length})).sort((K,Y)=>Y.count-K.count);if(Q.length===0)return[];return[{type:"file-category",kind:"file-category",category:"unknown",confidence:"high",evidence:[],categories:Z,summary:Q}]}}});function P($){return $.hunks.flatMap((Z)=>Z.additions)}function r0($){let Z=[];for(let Q of $.hunks){let X=Q.newStart,K=Q.content.split(`
15
- `);for(let Y of K){if(Y.startsWith("@@"))continue;if(Y.startsWith("+")&&!Y.startsWith("+++"))Z.push({line:Y.slice(1),lineNumber:X}),X++;else if(!Y.startsWith("-"))X++}}return Z}function G1($){return $.hunks.flatMap((Z)=>Z.deletions)}function xK($){let Z=[];for(let Q of $.hunks)Z.push(...Q.additions,...Q.deletions);return Z}function wK($){return $.map((Z)=>[...Z.additions,...Z.deletions].join(`
13
+ `);if($.path.startsWith("src/commands/")&&$.status==="added"){if($.path.endsWith("index.ts"))return"New command module";return"New command helper"}if(/\.test\.[jt]sx?$/.test($.path)||/\.spec\.[jt]sx?$/.test($.path)){if($.status==="added")return"New test file";return"Updated tests"}if($.path.endsWith(".md")||$.path.startsWith("docs/")){if($.status==="added")return"New documentation";return"Documentation update"}if($.path.includes("config")||$.path.endsWith(".json")||$.path.endsWith(".yaml")||$.path.endsWith(".yml")||$.path.endsWith(".toml")||$.path.includes(".env")){if($.status==="added")return"New configuration";return"Configuration update"}let Y=M4(Z,Q,$.status);if(Y.length===0)return null;Y.sort((V,U)=>U.priority-V.priority);let K=new Set,q=Y.filter((V)=>{if(K.has(V.description))return!1;return K.add(V.description),!0}),W=q[0];if(q.length>1)return`${W.description} (+${q.length-1} more)`;return W.description}var s;var E5=x(()=>{Q0();s={name:"file-summary",analyze($){let Z=[],Q=[],X=[],Y=[],K=[];for(let W of $.files){if(v$(W.path))continue;switch(W.status){case"added":Z.push(W.path);break;case"modified":Q.push(W.path);break;case"deleted":X.push(W.path);break;case"renamed":Y.push({from:W.oldPath??W.path,to:W.path});break}}for(let W of $.diffs){if(v$(W.path))continue;let V=z4(W);if(V)K.push({file:W.path,description:V})}if(Z.length===0&&Q.length===0&&X.length===0&&Y.length===0)return[];return[{type:"file-summary",kind:"file-summary",category:"unknown",confidence:"high",evidence:[],added:Z,modified:Q,deleted:X,renamed:Y,changeDescriptions:K.length>0?K:void 0}]}}});function L4($){for(let Z of j4)if(Z.patterns.some((Q)=>Q.test($)))return Z.category;return"other"}function I5($){return{product:"Product Code",tests:"Tests",ci:"CI/CD",infra:"Infrastructure",database:"Database",docs:"Documentation",dependencies:"Dependencies",config:"Configuration",artifacts:"Build Artifacts",other:"Other"}[$]}var j4,o;var n0=x(()=>{j4=[{category:"tests",patterns:[/^tests?\//i,/^__tests__\//i,/\/tests?\//i,/\/__tests__\//i,/\.test\.[jt]sx?$/i,/\.spec\.[jt]sx?$/i,/\.e2e\.[jt]sx?$/i,/vitest\.config/i,/jest\.config/i,/cypress\//i,/playwright\//i]},{category:"ci",patterns:[/^\.github\/workflows\//,/^\.github\/actions\//,/^\.gitlab-ci\.yml$/,/^\.circleci\//,/^Jenkinsfile$/,/^\.travis\.yml$/,/^azure-pipelines\.yml$/,/^bitbucket-pipelines\.yml$/]},{category:"infra",patterns:[/^Dockerfile/i,/^docker-compose/i,/^\.dockerignore$/,/^helm\//i,/^charts?\//i,/^terraform\//i,/^\.tf$/,/^k8s\//i,/^kubernetes\//i,/^pulumi\//i,/^ansible\//i,/^Vagrantfile$/]},{category:"database",patterns:[/^supabase\/migrations\//,/^supabase\/seed/,/^prisma\/migrations\//,/^prisma\/schema\.prisma$/,/^drizzle\/migrations\//,/^drizzle\.config/,/^migrations?\//i,/\/migrations?\//i,/\.sql$/i]},{category:"docs",patterns:[/^docs?\//i,/^documentation\//i,/\.md$/i,/\.mdx$/i,/^README/i,/^CHANGELOG/i,/^CONTRIBUTING/i,/^LICENSE/i,/^\.all-contributorsrc$/]},{category:"dependencies",patterns:[/^package\.json$/,/^package-lock\.json$/,/^yarn\.lock$/,/^pnpm-lock\.yaml$/,/^bun\.lock$/,/^bun\.lockb$/,/^requirements\.txt$/,/^Pipfile(\.lock)?$/,/^poetry\.lock$/,/^pyproject\.toml$/,/^Cargo\.(toml|lock)$/,/^go\.(mod|sum)$/,/^Gemfile(\.lock)?$/,/^composer\.(json|lock)$/]},{category:"config",patterns:[/^\.[a-z]+rc(\.json|\.js|\.cjs|\.mjs|\.yaml|\.yml)?$/i,/\.config\.[jt]s$/i,/\.config\.[a-z]+\.[jt]s$/i,/^\.env/i,/^wrangler\.(toml|json)$/i,/^tsconfig.*\.json$/i,/^\.eslintrc/i,/^\.prettierrc/i,/^\.editorconfig$/,/^\.gitignore$/,/^\.nvmrc$/,/^\.node-version$/]},{category:"artifacts",patterns:[/\.tgz$/i,/\.tar\.gz$/i,/\.zip$/i,/\.whl$/i,/\.jar$/i,/\.war$/i,/\.gem$/i,/\.nupkg$/i,/\.deb$/i,/\.rpm$/i,/\.dmg$/i,/\.exe$/i,/\.dll$/i,/\.so$/i,/\.dylib$/i,/\.a$/i,/\.o$/i,/\.wasm$/i]},{category:"product",patterns:[/^src\//,/^lib\//,/^app\//,/^pages\//,/^components\//,/^hooks\//,/^utils\//,/^services\//,/^api\//,/^server\//,/^client\//,/\.[jt]sx?$/,/\.svelte$/,/\.vue$/,/\.astro$/]}];o={name:"file-category",analyze($){let Z={product:[],tests:[],ci:[],infra:[],database:[],docs:[],dependencies:[],config:[],artifacts:[],other:[]};for(let Y of $.files){let K=L4(Y.path);Z[K].push(Y.path)}let Q=Object.entries(Z).filter(([,Y])=>Y.length>0).map(([Y,K])=>({category:Y,count:K.length})).sort((Y,K)=>K.count-Y.count);if(Q.length===0)return[];return[{type:"file-category",kind:"file-category",category:"unknown",confidence:"high",evidence:[],categories:Z,summary:Q}]}}});function v($){return $.hunks.flatMap((Z)=>Z.additions)}function t0($){let Z=[];for(let Q of $.hunks){let X=Q.newStart,Y=Q.content.split(`
14
+ `);for(let K of Y){if(K.startsWith("@@"))continue;if(K.startsWith("+")&&!K.startsWith("+++"))Z.push({line:K.slice(1),lineNumber:X}),X++;else if(!K.startsWith("-"))X++}}return Z}function L1($){return $.hunks.flatMap((Z)=>Z.deletions)}function pK($){let Z=[];for(let Q of $.hunks)Z.push(...Q.additions,...Q.deletions);return Z}function dK($){return $.map((Z)=>[...Z.additions,...Z.deletions].join(`
16
15
  `)).join(`
17
- `)}function iZ($,Z){return Z.test($)}function EK($,Z){return $.filter((Q)=>iZ(Q.path,Z))}function IK($,Z){return P($).some((Q)=>Z.test(Q))}function bK($,Z){let Q=[],X=new RegExp(Z.source,"g"+Z.flags.replace("g",""));for(let K of P($)){X.lastIndex=0;let Y;while((Y=X.exec(K))!==null)Q.push(Y)}return Q}function CK($,Z){let Q=[],X=new RegExp(Z.source,"g"+Z.flags.replace("g","")),K=r0($);for(let{line:Y,lineNumber:W}of K){X.lastIndex=0;let q;while((q=X.exec(Y))!==null)Q.push({match:q,lineNumber:W,line:Y})}return Q}function N($,Z,Q){return{file:$,excerpt:Z.trim(),line:Q?.line,hunk:Q?.hunk?{oldStart:Q.hunk.oldStart,oldLines:Q.hunk.oldLines,newStart:Q.hunk.newStart,newLines:Q.hunk.newLines}:void 0}}function _5($){return{...$,excerpt:i$($.excerpt)}}function i$($){let Z=$;return Z=Z.replace(/\b(sk|pk|rk)_(live|test)_[A-Za-z0-9]{24,}/g,"$1_$2_***REDACTED***"),Z=Z.replace(/\beyJ[A-Za-z0-9_-]{30,}\.[A-Za-z0-9_-]{30,}\.[A-Za-z0-9_-]{30,}/g,"eyJ***REDACTED***"),Z=Z.replace(/\bAKIA[0-9A-Z]{16}\b/g,"AKIA***REDACTED***"),Z=Z.replace(/(password|secret|token|apikey|api_key)(\s*[:=]\s*)(["'])(?!.*\*\*\*REDACTED\*\*\*)([^"']+?)\3/gi,"$1$2$3***REDACTED***$3"),Z=Z.replace(/(password|secret|token|apikey|api_key)(\s*[:=]\s*)(?!.*\*\*\*REDACTED\*\*\*)([^\s"',;)]+)/gi,"$1$2***REDACTED***"),Z}function H5($,Z=200){if($.length<=Z)return $;return $.substring(0,Z-3)+"..."}function k($,Z=200){if($.length===0)return"";for(let Q of $){let X=Q.trim();if(X.length>0&&!X.startsWith("//")&&!X.startsWith("/*")&&!X.startsWith("*")&&!X.startsWith("#"))return H5(X,Z)}return H5($[0].trim(),Z)}function z5($){return $.startsWith("src/routes/")&&eZ($)}function eZ($){let Z=$.split("/").pop()??"";return Object.keys(L5).some((Q)=>Z.startsWith(Q.replace(".svelte","").replace(".ts",""))&&(Z.endsWith(".svelte")||Z.endsWith(".ts")))}function $4($){let Z=$.split("/").pop()??"";for(let[Q,X]of Object.entries(L5))if(Z===Q)return X;return"unknown"}function Z4($){let Z=$.replace(/^src\/routes/,""),Q=Z.split("/");if(Q.pop(),Z=Q.join("/"),Z===""||Z==="/")return"/";if(!Z.startsWith("/"))Z="/"+Z;return Z}function c1($){return $.replace(/\/\([^)]+\)/g,"")}function Q4($){let Z=new Set,Q=P($).join(`
18
- `),X,K=new RegExp(tZ.source,"g");while((X=K.exec(Q))!==null)Z.add(X[1]);return Array.from(Z).sort()}var L5,tZ,j5;var t$=x(()=>{L5={"+page.svelte":"page","+page.ts":"page","+page.server.ts":"page","+layout.svelte":"layout","+layout.ts":"layout","+layout.server.ts":"layout","+server.ts":"endpoint","+error.svelte":"error"},tZ=/export\s+const\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/g;j5={name:"route-detector",analyze($){let Z=[],Q=new Map;for(let X of $.files)if(z5(X.path))Q.set(X.path,{status:X.status});for(let X of $.diffs)if(z5(X.path)){let K=Q.get(X.path);if(K)K.diff=X;else Q.set(X.path,{diff:X,status:X.status})}for(let[X,{diff:K,status:Y}]of Q){let W=Z4(X),q=$4(X),V=[];if(K&&K.hunks.length>0){let J=P(K);if(J.length>0){let B=k(J);if(B)V.push(N(X,B))}}let U={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:V,routeId:W,file:X,change:Y,routeType:q};if(q==="endpoint"&&K){let J=Q4(K);if(J.length>0){U.methods=J;let B=J.map((G)=>`export const ${G}`).join(", ");if(!V.length)V.push(N(X,B))}}Z.push(U)}return Z}}});function Y4($){return X4.test($)}function q4($){return K4.test($)}function W4($){let Z=[];for(let{pattern:Q,description:X}of D5)if(Q.test($))Z.push({pattern:Q.source,description:X});return Z}function U4($,Z){let Q=[],X=[],K=!1;for(let W of $){let q=Z.diffs.find((B)=>B.path===W);if(!q)continue;let V=P(q),U=V.join(`
19
- `),J=W4(U);for(let{description:B}of J){K=!0,Q.push(`${B} detected in ${W}`);let G=V.find((M)=>D5.some((H)=>H.pattern.test(M)));if(G)X.push({file:W,excerpt:G.trim()})}}if(K)return{risk:"high",reasons:Q,evidence:X};if($.every((W)=>q4(W)))return{risk:"low",reasons:["Only seed/config files changed"],evidence:X};return{risk:"medium",reasons:["Migration files changed"],evidence:X}}var X4,K4,D5,A5;var N5=x(()=>{X4=/^supabase\/migrations\/.*\.sql$/,K4=/^supabase\/(seed|config)/,D5=[{pattern:/DROP\s+TABLE/i,description:"DROP TABLE"},{pattern:/DROP\s+COLUMN/i,description:"DROP COLUMN"},{pattern:/TRUNCATE/i,description:"TRUNCATE"},{pattern:/ALTER\s+COLUMN/i,description:"ALTER COLUMN"},{pattern:/ALTER\s+TABLE\s+\w+\s+.*\s+TYPE/i,description:"ALTER TYPE"},{pattern:/DELETE\s+FROM\s+\w+\s*(?:;|$)/i,description:"DELETE without WHERE"}];A5={name:"supabase",analyze($){let Z=[],Q=[],X=[];for(let U of $.files)if(U.path.startsWith("supabase/")){if(X.push(U.path),Y4(U.path))Q.push(U.path)}if(X.length===0)return[];let{risk:K,reasons:Y,evidence:W}=U4(Q.length>0?Q:X,$),q=W.map((U)=>N(U.file,U.excerpt)),V={type:"db-migration",kind:"db-migration",category:"database",confidence:"high",evidence:q,tool:"supabase",files:Q.length>0?Q:X,risk:K,reasons:Y};if(Z.push(V),K==="high"){let U={type:"risk-flag",kind:"risk-flag",category:"database",confidence:"high",evidence:q,risk:"high",evidenceText:`Destructive SQL detected: ${Y.join(", ")}`};Z.push(U)}return Z}}});function B4($){if($.endsWith(".md")||$.startsWith("docs/"))return!1;if($.includes("/tests/")||$.includes("/__tests__/")||$.includes(".test.")||$.includes(".spec.")||$.startsWith("tests/"))return!1;if($.includes("/fixtures/")||$.includes("/__fixtures__/"))return!1;for(let Q of J4)if(Q.test($))return!0;let Z=$.substring($.lastIndexOf("."));return V4.has(Z)}function G4($){return $.split(",").map((Z)=>Z.trim()).filter((Z)=>Z.length>0).map((Z)=>{return Z.split(/\s+as\s+/)[0].trim()})}function O4($){let Z=new Set;C1.processEnv.lastIndex=0;let Q;while((Q=C1.processEnv.exec($))!==null)Z.add(Q[1]);C1.viteEnv.lastIndex=0;while((Q=C1.viteEnv.exec($))!==null)Z.add(`VITE_${Q[1]}`);C1.publicVar.lastIndex=0;while((Q=C1.publicVar.exec($))!==null)Z.add(`PUBLIC_${Q[1]}`);let X=[C1.envStaticPublic,C1.envStaticPrivate,C1.envDynamicPublic,C1.envDynamicPrivate];for(let K of X){K.lastIndex=0;while((Q=K.exec($))!==null){let Y=G4(Q[1]);for(let W of Y)Z.add(W)}}return Z}var V4,J4,C1,X1;var R5=x(()=>{s$();V4=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".svelte",".vue",".astro"]),J4=[/\.env(\..+)?$/,/vite\.config\.(ts|js|mjs)$/,/svelte\.config\.(ts|js|mjs)$/,/next\.config\.(ts|js|mjs)$/,/nuxt\.config\.(ts|js|mjs)$/,/astro\.config\.(ts|js|mjs)$/];C1={processEnv:/process\.env\.([A-Z_][A-Z0-9_]*)/g,viteEnv:/import\.meta\.env\.VITE_([A-Z0-9_]+)/g,publicVar:/\bPUBLIC_([A-Z0-9_]+)/g,envStaticPublic:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/static\/public["']/g,envStaticPrivate:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/static\/private["']/g,envDynamicPublic:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/dynamic\/public["']/g,envDynamicPrivate:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/dynamic\/private["']/g};X1={name:"env-var",analyze($){let Z=[],Q=new Map;for(let X of $.diffs){if(E$(X.path))continue;if(!B4(X.path))continue;let K=P(X),Y=K.join(`
20
- `),W=O4(Y);for(let q of W){if(!Q.has(q))Q.set(q,[]);let V=K.find((J)=>J.includes(q)),U=V?V.trim():k(K);Q.get(q).push({file:X.path,excerpt:U})}}for(let[X,K]of Q){let Y=Array.from(new Set(K.map((V)=>V.file))),q={type:"env-var",kind:"env-var",category:"config_env",confidence:"high",evidence:K.slice(0,3).map((V)=>N(V.file,V.excerpt)),name:X,change:"added",evidenceFiles:Y};Z.push(q)}return Z}}});function z4($){return M4.some((Z)=>Z.test($))}function L4($){return H4.test($)}function j4($){return _4.test($)}var M4,H4,_4,J1;var T5=x(()=>{M4=[/^wrangler\.toml$/,/^wrangler\.json$/],H4=/^\.github\/workflows\/.*\.(yml|yaml)$/,_4=/\b(wrangler|cloudflare|workers|pages)\b/i;J1={name:"cloudflare",analyze($){let Z=[],Q=new Map;for(let X of $.files)if(z4(X.path)){if(!Q.has("wrangler"))Q.set("wrangler",[]);let K=$.diffs.find((W)=>W.path===X.path),Y=K?k(P(K)):X.path;Q.get("wrangler").push({file:X.path,excerpt:Y})}for(let X of $.diffs)if(L4(X.path)){let K=P(X),Y=K.join(`
21
- `);if(j4(Y)){if(!Q.has("ci"))Q.set("ci",[]);let W=k(K);Q.get("ci").push({file:X.path,excerpt:W})}}for(let[X,K]of Q){let Y=K.map((V)=>V.file),q={type:"cloudflare-change",kind:"cloudflare-change",category:"cloudflare",confidence:"high",evidence:K.slice(0,3).map((V)=>N(V.file,V.excerpt)),area:X,files:Y};Z.push(q)}return Z}}});function e$($){return D4.some((Z)=>Z.test($))}function N4($){return A4.some((Z)=>Z.test($))}var D4,A4,K1;var a0=x(()=>{D4=[/\.test\.ts$/,/\.spec\.ts$/,/\.test\.js$/,/\.spec\.js$/,/^tests?\//],A4=[/^vitest\.config(\.[a-z0-9]+)?\.(ts|js|mts|mjs)$/,/^vite\.config(\.[a-z0-9]+)?\.(ts|js|mts|mjs)$/];K1={name:"vitest",analyze($){let Z=[];for(let K of $.files)if(e$(K.path)||N4(K.path))Z.push(K.path);if(Z.length===0)return[];return[{type:"test-change",kind:"test-change",category:"tests",confidence:"high",evidence:Z.slice(0,3).map((K)=>N(K,`Test file ${K}`)),framework:"vitest",files:Z}]}}});import*as s0 from"semver";function x4($){return T4.get($)}function x5($){return $.replace(w4,"").trim()}function E4($,Z){if(!$||!Z)return"unknown";let Q=x5($),X=x5(Z),K=s0.parse(Q),Y=s0.parse(X);if(!K||!Y)return"unknown";if(Y.major>K.major)return"major";if(Y.minor>K.minor)return"minor";if(Y.patch>K.patch)return"patch";return"unknown"}function I4($,Z){let Q=[],X=["dependencies","devDependencies"];for(let K of X){let Y=$?.[K]??{},W=Z?.[K]??{},q=new Set([...Object.keys(Y),...Object.keys(W)]);for(let V of q){let U=Y[V],J=W[V];if(U===J)continue;let B=x4(V);if(!U&&J){let G=`"${V}": "${J}"`;Q.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[N("package.json",G)],name:V,section:K,to:J,impact:"new",riskCategory:B})}else if(U&&!J){let G=`"${V}": "${U}" (removed)`;Q.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[N("package.json",G)],name:V,section:K,from:U,impact:"removed",riskCategory:B})}else{let G=E4(U,J),M=`"${V}": "${U}" → "${J}"`;Q.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[N("package.json",M)],name:V,section:K,from:U,to:J,impact:G,riskCategory:B})}}}return Q}var R4,T4,w4,Y1;var w5=x(()=>{R4=["@sveltejs/kit","svelte","vite"],T4=new Map([...["passport","jsonwebtoken","bcrypt","bcryptjs","oauth","auth0","@auth0/auth0-spa-js","clerk","@clerk/clerk-sdk-node","@clerk/nextjs","next-auth","@auth/core","@auth/sveltekit","lucia","lucia-auth","arctic","oslo","express-session","cookie-session","passport-local","passport-jwt","passport-oauth2","jose","jwks-rsa","supertokens-node","@supabase/auth-helpers-sveltekit","@supabase/ssr"].map(($)=>[$,"auth"]),...["prisma","@prisma/client","drizzle-orm","typeorm","sequelize","knex","mongoose","pg","mysql","mysql2","sqlite3","better-sqlite3","mongodb","redis","ioredis","@neondatabase/serverless","@planetscale/database","@libsql/client","kysely"].map(($)=>[$,"database"]),...["sharp","canvas","node-gyp","node-pre-gyp","node-addon-api","nan","ffi-napi","ref-napi","argon2","libsodium-wrappers","sodium-native","cpu-features","usb","serialport"].map(($)=>[$,"native"]),...["stripe","@stripe/stripe-js","paypal-rest-sdk","@paypal/checkout-server-sdk","braintree","square","@square/web-sdk","adyen-api-library","razorpay","mollie-api-node","lemon-squeezy","@polar-sh/sdk","polar-sdk"].map(($)=>[$,"payment"])]);w4=/^[\^~>=<]+/;Y1={name:"dependencies",analyze($){let Z=[],Q=I4($.basePackageJson,$.headPackageJson);Z.push(...Q);for(let X of Q){if(R4.includes(X.name)&&X.impact==="major"&&X.from&&X.to){let K=`${X.name}: ${X.from} → ${X.to}`,Y={type:"risk-flag",kind:"risk-flag",category:"dependencies",confidence:"high",evidence:[N("package.json",K)],risk:"high",evidenceText:`Major version bump: ${X.name} ${X.from} → ${X.to}`};Z.push(Y)}if(X.riskCategory&&X.impact==="new"){let K={auth:"Authentication/Security",database:"Database/ORM",native:"Native Module",payment:"Payment Processing"},Y=`${X.name}: ${X.to}`,W={type:"risk-flag",kind:"risk-flag",category:"dependencies",confidence:"medium",evidence:[N("package.json",Y)],risk:"medium",evidenceText:`New ${K[X.riskCategory]} package: ${X.name}`};Z.push(W)}}return Z}}});function C4($){for(let{pattern:Z,reason:Q}of b4)if(Z.test($))return Q;return null}function P4($){return{"auth-path":"Authentication","session-path":"Session/Token","permission-path":"Permissions/RBAC",middleware:"Middleware",guard:"Route Guard",policy:"Policy"}[$]}var b4,q1;var E5=x(()=>{b4=[{pattern:/\bauth\b/i,reason:"auth-path"},{pattern:/\blogin\b/i,reason:"auth-path"},{pattern:/\blogout\b/i,reason:"auth-path"},{pattern:/\bsignin\b/i,reason:"auth-path"},{pattern:/\bsignout\b/i,reason:"auth-path"},{pattern:/\bsignup\b/i,reason:"auth-path"},{pattern:/\bregister\b/i,reason:"auth-path"},{pattern:/\bsession\b/i,reason:"session-path"},{pattern:/\bjwt\b/i,reason:"session-path"},{pattern:/\btoken\b/i,reason:"session-path"},{pattern:/\bcookie\b/i,reason:"session-path"},{pattern:/\boauth\b/i,reason:"session-path"},{pattern:/\bpermission\b/i,reason:"permission-path"},{pattern:/\brbac\b/i,reason:"permission-path"},{pattern:/\bacl\b/i,reason:"permission-path"},{pattern:/\brole\b/i,reason:"permission-path"},{pattern:/\bauthoriz/i,reason:"permission-path"},{pattern:/middleware\.[jt]sx?$/i,reason:"middleware"},{pattern:/\/middleware\//,reason:"middleware"},{pattern:/guard\.[jt]sx?$/i,reason:"guard"},{pattern:/\/guards?\//,reason:"guard"},{pattern:/policy\.[jt]sx?$/i,reason:"policy"},{pattern:/\/policies\//,reason:"policy"}];q1={name:"security-files",analyze($){let Z=[],Q=[],X=new Set;for(let V of $.files){let U=C4(V.path);if(U)Q.push(V.path),X.add(U)}if(Q.length===0)return[];let K=Q.slice(0,3).map((V)=>N(V,`Security file: ${V}`)),Y={type:"security-file",kind:"security-file",category:"infra",confidence:"medium",evidence:K,files:Q,reasons:Array.from(X)};Z.push(Y);let W=Array.from(X).map(P4).join(", "),q={type:"risk-flag",kind:"risk-flag",category:"infra",confidence:"medium",evidence:K,risk:"medium",evidenceText:`Security-sensitive files changed (${W}): ${Q.length} file(s)`};return Z.push(q),Z}}});import{execa as y4}from"execa";async function $0($,Z=process.cwd(),Q=y4){if($.length===0)return new Map;let X=new Map,K=$.map((W)=>`${W.ref}:${W.path}`),Y=K.join(`
16
+ `)}function D4($,Z){return Z.test($)}function rK($,Z){return $.filter((Q)=>D4(Q.path,Z))}function aK($,Z){return v($).some((Q)=>Z.test(Q))}function sK($,Z){let Q=[],X=new RegExp(Z.source,"g"+Z.flags.replace("g",""));for(let Y of v($)){X.lastIndex=0;let K;while((K=X.exec(Y))!==null)Q.push(K)}return Q}function oK($,Z){let Q=[],X=new RegExp(Z.source,"g"+Z.flags.replace("g","")),Y=t0($);for(let{line:K,lineNumber:q}of Y){X.lastIndex=0;let W;while((W=X.exec(K))!==null)Q.push({match:W,lineNumber:q,line:K})}return Q}function R($,Z,Q){return{file:$,excerpt:Z.trim(),line:Q?.line,hunk:Q?.hunk?{oldStart:Q.hunk.oldStart,oldLines:Q.hunk.oldLines,newStart:Q.hunk.newStart,newLines:Q.hunk.newLines}:void 0}}function P5($){return{...$,excerpt:X0($.excerpt)}}function X0($){let Z=$;return Z=Z.replace(/\b(sk|pk|rk)_(live|test)_[A-Za-z0-9]{24,}/g,"$1_$2_***REDACTED***"),Z=Z.replace(/\beyJ[A-Za-z0-9_-]{30,}\.[A-Za-z0-9_-]{30,}\.[A-Za-z0-9_-]{30,}/g,"eyJ***REDACTED***"),Z=Z.replace(/\bAKIA[0-9A-Z]{16}\b/g,"AKIA***REDACTED***"),Z=Z.replace(/(password|secret|token|apikey|api_key)(\s*[:=]\s*)(["'])(?!.*\*\*\*REDACTED\*\*\*)([^"']+?)\3/gi,"$1$2$3***REDACTED***$3"),Z=Z.replace(/(password|secret|token|apikey|api_key)(\s*[:=]\s*)(?!.*\*\*\*REDACTED\*\*\*)([^\s"',;)]+)/gi,"$1$2***REDACTED***"),Z}function b5($,Z=200){if($.length<=Z)return $;return $.substring(0,Z-3)+"..."}function S($,Z=200){if($.length===0)return"";for(let Q of $){let X=Q.trim();if(X.length>0&&!X.startsWith("//")&&!X.startsWith("/*")&&!X.startsWith("*")&&!X.startsWith("#"))return b5(X,Z)}return b5($[0].trim(),Z)}function k5($){return $.startsWith("src/routes/")&&A4($)}function A4($){let Z=$.split("/").pop()??"";return Object.keys(v5).some((Q)=>Z.startsWith(Q.replace(".svelte","").replace(".ts",""))&&(Z.endsWith(".svelte")||Z.endsWith(".ts")))}function R4($){let Z=$.split("/").pop()??"";for(let[Q,X]of Object.entries(v5))if(Z===Q)return X;return"unknown"}function T4($){let Z=$.replace(/^src\/routes/,""),Q=Z.split("/");if(Q.pop(),Z=Q.join("/"),Z===""||Z==="/")return"/";if(!Z.startsWith("/"))Z="/"+Z;return Z}function m1($){return $.replace(/\/\([^)]+\)/g,"")}function w4($){let Z=new Set,Q=v($).join(`
17
+ `),X,Y=new RegExp(N4.source,"g");while((X=Y.exec(Q))!==null)Z.add(X[1]);return Array.from(Z).sort()}var v5,N4,S5;var S$=x(()=>{v5={"+page.svelte":"page","+page.ts":"page","+page.server.ts":"page","+layout.svelte":"layout","+layout.ts":"layout","+layout.server.ts":"layout","+server.ts":"endpoint","+error.svelte":"error"},N4=/export\s+const\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/g;S5={name:"route-detector",analyze($){let Z=[],Q=new Map;for(let X of $.files)if(k5(X.path))Q.set(X.path,{status:X.status});for(let X of $.diffs)if(k5(X.path)){let Y=Q.get(X.path);if(Y)Y.diff=X;else Q.set(X.path,{diff:X,status:X.status})}for(let[X,{diff:Y,status:K}]of Q){let q=T4(X),W=R4(X),V=[];if(Y&&Y.hunks.length>0){let J=v(Y);if(J.length>0){let G=S(J);if(G)V.push(R(X,G))}}let U={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:V,routeId:q,file:X,change:K,routeType:W};if(W==="endpoint"&&Y){let J=w4(Y);if(J.length>0){U.methods=J;let G=J.map((B)=>`export const ${B}`).join(", ");if(!V.length)V.push(R(X,G))}}Z.push(U)}return Z}}});function I4($){return x4.test($)}function b4($){return E4.test($)}function P4($){let Z=[];for(let{pattern:Q,description:X}of C5)if(Q.test($))Z.push({pattern:Q.source,description:X});return Z}function k4($,Z){let Q=[],X=[],Y=!1;for(let q of $){let W=Z.diffs.find((G)=>G.path===q);if(!W)continue;let V=v(W),U=V.join(`
18
+ `),J=P4(U);for(let{description:G}of J){Y=!0,Q.push(`${G} detected in ${q}`);let B=V.find((H)=>C5.some((_)=>_.pattern.test(H)));if(B)X.push({file:q,excerpt:B.trim()})}}if(Y)return{risk:"high",reasons:Q,evidence:X};if($.every((q)=>b4(q)))return{risk:"low",reasons:["Only seed/config files changed"],evidence:X};return{risk:"medium",reasons:["Migration files changed"],evidence:X}}var x4,E4,C5,F5;var y5=x(()=>{x4=/^supabase\/migrations\/.*\.sql$/,E4=/^supabase\/(seed|config)/,C5=[{pattern:/DROP\s+TABLE/i,description:"DROP TABLE"},{pattern:/DROP\s+COLUMN/i,description:"DROP COLUMN"},{pattern:/TRUNCATE/i,description:"TRUNCATE"},{pattern:/ALTER\s+COLUMN/i,description:"ALTER COLUMN"},{pattern:/ALTER\s+TABLE\s+\w+\s+.*\s+TYPE/i,description:"ALTER TYPE"},{pattern:/DELETE\s+FROM\s+\w+\s*(?:;|$)/i,description:"DELETE without WHERE"}];F5={name:"supabase",analyze($){let Z=[],Q=[],X=[];for(let U of $.files)if(U.path.startsWith("supabase/")){if(X.push(U.path),I4(U.path))Q.push(U.path)}if(X.length===0)return[];let{risk:Y,reasons:K,evidence:q}=k4(Q.length>0?Q:X,$),W=q.map((U)=>R(U.file,U.excerpt)),V={type:"db-migration",kind:"db-migration",category:"database",confidence:"high",evidence:W,tool:"supabase",files:Q.length>0?Q:X,risk:Y,reasons:K};if(Z.push(V),Y==="high"){let U={type:"risk-flag",kind:"risk-flag",category:"database",confidence:"high",evidence:W,risk:"high",evidenceText:`Destructive SQL detected: ${K.join(", ")}`};Z.push(U)}return Z}}});function C4($){if($.endsWith(".md")||$.startsWith("docs/"))return!1;if($.includes("/tests/")||$.includes("/__tests__/")||$.includes(".test.")||$.includes(".spec.")||$.startsWith("tests/"))return!1;if($.includes("/fixtures/")||$.includes("/__fixtures__/"))return!1;for(let Q of S4)if(Q.test($))return!0;let Z=$.substring($.lastIndexOf("."));return v4.has(Z)}function F4($){return $.split(",").map((Z)=>Z.trim()).filter((Z)=>Z.length>0).map((Z)=>{return Z.split(/\s+as\s+/)[0].trim()})}function y4($){let Z=new Set;h1.processEnv.lastIndex=0;let Q;while((Q=h1.processEnv.exec($))!==null)Z.add(Q[1]);h1.viteEnv.lastIndex=0;while((Q=h1.viteEnv.exec($))!==null)Z.add(`VITE_${Q[1]}`);h1.publicVar.lastIndex=0;while((Q=h1.publicVar.exec($))!==null)Z.add(`PUBLIC_${Q[1]}`);let X=[h1.envStaticPublic,h1.envStaticPrivate,h1.envDynamicPublic,h1.envDynamicPrivate];for(let Y of X){Y.lastIndex=0;while((Q=Y.exec($))!==null){let K=F4(Q[1]);for(let q of K)Z.add(q)}}return Z}var v4,S4,h1,X1;var m5=x(()=>{Q0();v4=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".svelte",".vue",".astro"]),S4=[/\.env(\..+)?$/,/vite\.config\.(ts|js|mjs)$/,/svelte\.config\.(ts|js|mjs)$/,/next\.config\.(ts|js|mjs)$/,/nuxt\.config\.(ts|js|mjs)$/,/astro\.config\.(ts|js|mjs)$/];h1={processEnv:/process\.env\.([A-Z_][A-Z0-9_]*)/g,viteEnv:/import\.meta\.env\.VITE_([A-Z0-9_]+)/g,publicVar:/\bPUBLIC_([A-Z0-9_]+)/g,envStaticPublic:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/static\/public["']/g,envStaticPrivate:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/static\/private["']/g,envDynamicPublic:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/dynamic\/public["']/g,envDynamicPrivate:/import\s*\{([^}]+)\}\s*from\s*["']\$env\/dynamic\/private["']/g};X1={name:"env-var",analyze($){let Z=[],Q=new Map;for(let X of $.diffs){if(v$(X.path))continue;if(!C4(X.path))continue;let Y=v(X),K=Y.join(`
19
+ `),q=y4(K);for(let W of q){if(!Q.has(W))Q.set(W,[]);let V=Y.find((J)=>J.includes(W)),U=V?V.trim():S(Y);Q.get(W).push({file:X.path,excerpt:U})}}for(let[X,Y]of Q){let K=Array.from(new Set(Y.map((V)=>V.file))),W={type:"env-var",kind:"env-var",category:"config_env",confidence:"high",evidence:Y.slice(0,3).map((V)=>R(V.file,V.excerpt)),name:X,change:"added",evidenceFiles:K};Z.push(W)}return Z}}});function g4($){return m4.some((Z)=>Z.test($))}function c4($){return h4.test($)}function l4($){return u4.test($)}var m4,h4,u4,B1;var h5=x(()=>{m4=[/^wrangler\.toml$/,/^wrangler\.json$/],h4=/^\.github\/workflows\/.*\.(yml|yaml)$/,u4=/\b(wrangler|cloudflare|workers|pages)\b/i;B1={name:"cloudflare",analyze($){let Z=[],Q=new Map;for(let X of $.files)if(g4(X.path)){if(!Q.has("wrangler"))Q.set("wrangler",[]);let Y=$.diffs.find((q)=>q.path===X.path),K=Y?S(v(Y)):X.path;Q.get("wrangler").push({file:X.path,excerpt:K})}for(let X of $.diffs)if(c4(X.path)){let Y=v(X),K=Y.join(`
20
+ `);if(l4(K)){if(!Q.has("ci"))Q.set("ci",[]);let q=S(Y);Q.get("ci").push({file:X.path,excerpt:q})}}for(let[X,Y]of Q){let K=Y.map((V)=>V.file),W={type:"cloudflare-change",kind:"cloudflare-change",category:"cloudflare",confidence:"high",evidence:Y.slice(0,3).map((V)=>R(V.file,V.excerpt)),area:X,files:K};Z.push(W)}return Z}}});function Y0($){return f4.some((Z)=>Z.test($))}function d4($){return p4.some((Z)=>Z.test($))}var f4,p4,Y1;var e0=x(()=>{f4=[/\.test\.ts$/,/\.spec\.ts$/,/\.test\.js$/,/\.spec\.js$/,/^tests?\//],p4=[/^vitest\.config(\.[a-z0-9]+)?\.(ts|js|mts|mjs)$/,/^vite\.config(\.[a-z0-9]+)?\.(ts|js|mts|mjs)$/];Y1={name:"vitest",analyze($){let Z=[],Q=[],X=[],Y=[];for(let W of $.files)if(Y0(W.path)||d4(W.path))switch(Z.push(W.path),W.status){case"added":Q.push(W.path);break;case"modified":X.push(W.path);break;case"deleted":Y.push(W.path);break;case"renamed":X.push(W.path);break}if(Z.length===0)return[];return[{type:"test-change",kind:"test-change",category:"tests",confidence:"high",evidence:Z.slice(0,3).map((W)=>{let V=Q.includes(W)?"added":Y.includes(W)?"deleted":"modified";return R(W,`Test file ${V}: ${W}`)}),framework:"vitest",files:Z,added:Q,modified:X,deleted:Y}]}}});import*as $2 from"semver";function s4($){return a4.get($)}function u5($){return $.replace(o4,"").trim()}function i4($,Z){if(!$||!Z)return"unknown";let Q=u5($),X=u5(Z),Y=$2.parse(Q),K=$2.parse(X);if(!Y||!K)return"unknown";if(K.major>Y.major)return"major";if(K.minor>Y.minor)return"minor";if(K.patch>Y.patch)return"patch";return"unknown"}function n4($,Z){let Q=[],X=["dependencies","devDependencies"];for(let Y of X){let K=$?.[Y]??{},q=Z?.[Y]??{},W=new Set([...Object.keys(K),...Object.keys(q)]);for(let V of W){let U=K[V],J=q[V];if(U===J)continue;let G=s4(V);if(!U&&J){let B=`"${V}": "${J}"`;Q.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[R("package.json",B)],name:V,section:Y,to:J,impact:"new",riskCategory:G})}else if(U&&!J){let B=`"${V}": "${U}" (removed)`;Q.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[R("package.json",B)],name:V,section:Y,from:U,impact:"removed",riskCategory:G})}else{let B=i4(U,J),H=`"${V}": "${U}" → "${J}"`;Q.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[R("package.json",H)],name:V,section:Y,from:U,to:J,impact:B,riskCategory:G})}}}return Q}var r4,a4,o4,K1;var g5=x(()=>{r4=["@sveltejs/kit","svelte","vite"],a4=new Map([...["passport","jsonwebtoken","bcrypt","bcryptjs","oauth","auth0","@auth0/auth0-spa-js","clerk","@clerk/clerk-sdk-node","@clerk/nextjs","next-auth","@auth/core","@auth/sveltekit","lucia","lucia-auth","arctic","oslo","express-session","cookie-session","passport-local","passport-jwt","passport-oauth2","jose","jwks-rsa","supertokens-node","@supabase/auth-helpers-sveltekit","@supabase/ssr"].map(($)=>[$,"auth"]),...["prisma","@prisma/client","drizzle-orm","typeorm","sequelize","knex","mongoose","pg","mysql","mysql2","sqlite3","better-sqlite3","mongodb","redis","ioredis","@neondatabase/serverless","@planetscale/database","@libsql/client","kysely"].map(($)=>[$,"database"]),...["sharp","canvas","node-gyp","node-pre-gyp","node-addon-api","nan","ffi-napi","ref-napi","argon2","libsodium-wrappers","sodium-native","cpu-features","usb","serialport"].map(($)=>[$,"native"]),...["stripe","@stripe/stripe-js","paypal-rest-sdk","@paypal/checkout-server-sdk","braintree","square","@square/web-sdk","adyen-api-library","razorpay","mollie-api-node","lemon-squeezy","@polar-sh/sdk","polar-sdk"].map(($)=>[$,"payment"])]);o4=/^[\^~>=<]+/;K1={name:"dependencies",analyze($){let Z=[],Q=n4($.basePackageJson,$.headPackageJson);Z.push(...Q);for(let X of Q){if(r4.includes(X.name)&&X.impact==="major"&&X.from&&X.to){let Y=`${X.name}: ${X.from} → ${X.to}`,K={type:"risk-flag",kind:"risk-flag",category:"dependencies",confidence:"high",evidence:[R("package.json",Y)],risk:"high",evidenceText:`Major version bump: ${X.name} ${X.from} → ${X.to}`};Z.push(K)}if(X.riskCategory&&X.impact==="new"){let Y={auth:"Authentication/Security",database:"Database/ORM",native:"Native Module",payment:"Payment Processing"},K=`${X.name}: ${X.to}`,q={type:"risk-flag",kind:"risk-flag",category:"dependencies",confidence:"medium",evidence:[R("package.json",K)],risk:"medium",evidenceText:`New ${Y[X.riskCategory]} package: ${X.name}`};Z.push(q)}}return Z}}});function e4($){for(let{pattern:Z,reason:Q}of t4)if(Z.test($))return Q;return null}function Z2($){return{"auth-path":"Authentication","session-path":"Session/Token","permission-path":"Permissions/RBAC",middleware:"Middleware",guard:"Route Guard",policy:"Policy"}[$]}var t4,W1;var Q2=x(()=>{t4=[{pattern:/\bauth\b/i,reason:"auth-path"},{pattern:/\blogin\b/i,reason:"auth-path"},{pattern:/\blogout\b/i,reason:"auth-path"},{pattern:/\bsignin\b/i,reason:"auth-path"},{pattern:/\bsignout\b/i,reason:"auth-path"},{pattern:/\bsignup\b/i,reason:"auth-path"},{pattern:/\bregister\b/i,reason:"auth-path"},{pattern:/\bsession\b/i,reason:"session-path"},{pattern:/\bjwt\b/i,reason:"session-path"},{pattern:/\btoken\b/i,reason:"session-path"},{pattern:/\bcookie\b/i,reason:"session-path"},{pattern:/\boauth\b/i,reason:"session-path"},{pattern:/\bpermission\b/i,reason:"permission-path"},{pattern:/\brbac\b/i,reason:"permission-path"},{pattern:/\bacl\b/i,reason:"permission-path"},{pattern:/\brole\b/i,reason:"permission-path"},{pattern:/\bauthoriz/i,reason:"permission-path"},{pattern:/middleware\.[jt]sx?$/i,reason:"middleware"},{pattern:/\/middleware\//,reason:"middleware"},{pattern:/guard\.[jt]sx?$/i,reason:"guard"},{pattern:/\/guards?\//,reason:"guard"},{pattern:/policy\.[jt]sx?$/i,reason:"policy"},{pattern:/\/policies\//,reason:"policy"}];W1={name:"security-files",analyze($){let Z=[],Q=[],X=new Set;for(let V of $.files){let U=e4(V.path);if(U)Q.push(V.path),X.add(U)}if(Q.length===0)return[];let Y=Q.slice(0,3).map((V)=>R(V,`Security file: ${V}`)),K={type:"security-file",kind:"security-file",category:"infra",confidence:"medium",evidence:Y,files:Q,reasons:Array.from(X)};Z.push(K);let q=Array.from(X).map(Z2).join(", "),W={type:"risk-flag",kind:"risk-flag",category:"infra",confidence:"medium",evidence:Y,risk:"medium",evidenceText:`Security-sensitive files changed (${q}): ${Q.length} file(s)`};return Z.push(W),Z}}});import{execa as $6}from"execa";async function z$($,Z=process.cwd(),Q=$6){if($.length===0)return new Map;let X=new Map,Y=$.map((q)=>`${q.ref}:${q.path}`),K=Y.join(`
22
21
  `)+`
23
- `;try{let W=Q("git",["cat-file","--batch"],{cwd:Z,input:Y}),{stdout:q}=await W,V=Buffer.isBuffer(q)?q:Buffer.from(String(q),"utf-8"),U=0;for(let J of K){if(U>=V.length)break;let B=V.indexOf(`
24
- `,U);if(B===-1)break;let M=V.subarray(U,B).toString("utf-8"),[H,O,z]=M.split(" ");if(!H||!O||!z){U=B+1;continue}if(O==="missing"){U=B+1;continue}let _=parseInt(z,10),D=B+1,L=D+_,w=V.subarray(D,L);X.set(J,w.toString("utf-8")),U=L+1}}catch(W){console.warn("Failed to batch fetch files:",W)}return X}var o0=()=>{};import{parse as k4}from"@babel/parser";import n0 from"@babel/traverse";import*as S from"@babel/types";function v4($){if(![".ts",".tsx",".js",".jsx"].some((Q)=>$.endsWith(Q)))return!1;return!0}function Z0($){let Z=$.replace(/\/+/g,"/");if(Z!=="/"&&Z.endsWith("/"))Z=Z.slice(0,-1);return Z}function b5($,Z){if(Z.startsWith("/"))return Z0(Z);let Q=$==="/"?`/${Z}`:`${$}/${Z}`;return Z0(Q)}function C5($,Z,Q="/"){let X=[];return n0($,{JSXElement(K){let Y=K.node.openingElement,W=Y.name;if(S.isJSXIdentifier(W)&&W.name==="Route"){let q=null,V=!1,U=[];for(let J of Y.attributes)if(S.isJSXAttribute(J)&&S.isJSXIdentifier(J.name)){if(J.name.name==="path"&&J.value){if(S.isStringLiteral(J.value))q=J.value.value;else if(S.isJSXExpressionContainer(J.value)&&S.isStringLiteral(J.value.expression))q=J.value.expression.value}else if(J.name.name==="index")V=!0}if(V)X.push({path:Z0(Q),file:Z});else if(q){let J=b5(Q,q);X.push({path:J,file:Z});for(let B of K.node.children)if(S.isJSXElement(B))U.push(B);for(let B of U){let G=S.file(S.program([S.expressionStatement(B)])),M=C5(G,Z,J);X.push(...M)}}K.skip()}}}),X}function F4($,Z,Q="/"){let X=[],K=new Map;return n0($,{VariableDeclarator(Y){if(S.isIdentifier(Y.node.id)&&(S.isArrayExpression(Y.node.init)||S.isObjectExpression(Y.node.init)))K.set(Y.node.id.name,Y.node.init)}}),n0($,{CallExpression(Y){let W=Y.node.callee;if(S.isIdentifier(W)&&(W.name==="createBrowserRouter"||W.name==="createHashRouter"||W.name==="createMemoryRouter")){let q=Y.node.arguments[0],V=null;if(S.isArrayExpression(q))V=q;else if(S.isIdentifier(q)){let U=K.get(q.name);if(U&&S.isArrayExpression(U))V=U}if(V){let U=P5(V,Z,Q);X.push(...U)}}}}),X}function P5($,Z,Q="/"){let X=[];for(let K of $.elements)if(S.isObjectExpression(K)){let Y=m4(K);if(Y.index)X.push({path:Z0(Q),file:Z});else if(Y.path){let W=b5(Q,Y.path);if(X.push({path:W,file:Z}),Y.children){let q=P5(Y.children,Z,W);X.push(...q)}}}return X}function m4($){let Z={};for(let Q of $.properties)if(S.isObjectProperty(Q)&&S.isIdentifier(Q.key)){if(Q.key.name==="path"&&S.isStringLiteral(Q.value))Z.path=Q.value.value;else if(Q.key.name==="index"){if(S.isBooleanLiteral(Q.value)&&Q.value.value)Z.index=!0}else if(Q.key.name==="children"&&S.isArrayExpression(Q.value))Z.children=Q.value}return Z}function I5($,Z){try{let Q=k4($,{sourceType:"module",plugins:["typescript","jsx"]}),X=C5(Q,Z),K=F4(Q,Z);return[...X,...K]}catch(Q){return[]}}var S4,i0;var y5=x(()=>{o0();S4={batchGetFileContent:$0};i0={name:"react-router-routes",async analyze($){let Z=[],Q=$.files.filter((W)=>{return v4(W.path)});if(Q.length===0)return[];let X=[];for(let W of Q)X.push({ref:$.base,path:W.path}),X.push({ref:$.head,path:W.path});let K=await S4.batchGetFileContent(X);for(let W of Q){let q=`${$.base}:${W.path}`,V=`${$.head}:${W.path}`,U=K.get(q),J=K.get(V),B=(z)=>z.includes("react-router")||z.includes("<Route")||z.includes("createBrowserRouter")||z.includes("createHashRouter")||z.includes("createMemoryRouter");if(U&&!B(U)&&J&&!B(J))continue;let G=U?I5(U,W.path):[],M=J?I5(J,W.path):[],H=new Set(G.map((z)=>z.path)),O=new Set(M.map((z)=>z.path));for(let z of M)if(!H.has(z.path)){let _={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:[N(W.path,`Route: ${z.path}`)],routeId:z.path,file:W.path,change:"added",routeType:"page"};Z.push(_)}for(let z of G)if(!O.has(z.path)){let _={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:[N(W.path,`Route: ${z.path}`)],routeId:z.path,file:W.path,change:"deleted",routeType:"page"};Z.push(_)}}return Array.from(new Map(Z.map((W)=>{return[`${W.routeId}-${W.change}-${W.file}`,W]})).values()).sort((W,q)=>{let V=W.routeId,U=q.routeId;return V.localeCompare(U)})}}});var e0={};A1(e0,{testParityAnalyzer:()=>n4,createTestParityAnalyzer:()=>v5,_resetCacheForTesting:()=>f4});import o from"node:path";import{execa as u4}from"execa";function f4(){t0.clear(),I$=null}async function p4($,Z){let Q=new Set,X=[];for(let K of $){let Y=t0.get(K);if(Y)for(let W of Y)Q.add(W);else X.push(K)}if(X.length===0)return Q;try{let{stdout:K}=await Z("git",["ls-files","--cached","--others","--exclude-standard","--",...X],{reject:!1}),Y=K.split(`
25
- `).filter(Boolean);for(let W of X){let q=new Set;for(let V of Y)if(V.startsWith(W+"/")||V.startsWith(W+o.sep))q.add(V),Q.add(V);t0.set(W,q)}for(let W of Y)if(!W.includes("/")&&!W.includes(o.sep))Q.add(W);return Q}catch{return d4(Z)}}async function d4($){if(I$)return I$;try{let{stdout:Z}=await $("git",["ls-files","--cached","--others","--exclude-standard"],{reject:!1});return I$=new Set(Z.split(`
26
- `).filter(Boolean)),I$}catch{return new Set}}function r4($){return{testPatterns:$?.testPatterns??g4,excludePatterns:[...h4,...$?.excludePatterns??[]],testDirectories:$?.testDirectories??l4,sourceDirectories:$?.sourceDirectories??c4}}function k5($,Z){if(e$($))return!1;if(Z.some((Q)=>Q.test($)))return!1;return/\.(ts|js|tsx|jsx|mts|mjs)$/.test($)}function a4($,Z){if(/utils?|helpers?|lib|shared/i.test($))return"medium";if(Z&&Z.additions+Z.deletions<10)return"low";if(/services?|controllers?|handlers?|api|routes|commands?|analyzers?/i.test($))return"high";return"medium"}function S5($,Z,Q,X){let K=[],Y=o.extname($),W=o.basename($,Y),q=o.dirname($);for(let J of Z)K.push(o.join(q,`${W}${J}`));let V=$;for(let J of X)if($.startsWith(`${J}/`)){V=$.slice(J.length+1);break}for(let J of Q)for(let B of Z)K.push(o.join(J,o.dirname(V),`${W}${B}`)),K.push(o.join(J,`${W}${B}`)),K.push(o.join(J,q,`${W}${B}`));let U=V.split(o.sep);if(U.length>1){let J=U[U.length-2],B=`${J}-${W}`,G=`${W}-${J}`;for(let M of Q)for(let H of Z)K.push(o.join(M,`${B}${H}`)),K.push(o.join(M,`${G}${H}`))}return[...new Set(K.map((J)=>o.normalize(J)))]}async function s4($,Z,Q,X,K){let Y=S5($,Z,Q,X);for(let W of Y)if(K.has(W))return W;return null}function o4($,Z){let Q=o.basename($,o.extname($));return Z.files.some((X)=>e$(X.path)&&X.path.includes(Q)&&X.status!=="deleted")}function v5($,Z){let Q=r4($),X=Z?.exec??u4;return{name:"test-parity",async analyze(K){let Y=[],W=new Set;for(let V of K.files){if(V.status==="deleted")continue;if(!k5(V.path,Q.excludePatterns))continue;let U=o.dirname(V.path);if(U&&U!==".")W.add(U.split(o.sep)[0])}for(let V of Q.testDirectories)W.add(V);let q=await p4([...W],X);for(let V of K.files)if(V.status!=="deleted")q.add(V.path);for(let V of K.files){if(V.status==="deleted")continue;if(!k5(V.path,Q.excludePatterns))continue;if(await s4(V.path,Q.testPatterns,Q.testDirectories,Q.sourceDirectories,q))continue;if(o4(V.path,K))continue;let J=K.diffs.find((O)=>O.path===V.path),B=J?{additions:J.hunks.reduce((O,z)=>O+z.additions.length,0),deletions:J.hunks.reduce((O,z)=>O+z.deletions.length,0)}:void 0,G=a4(V.path,B),M=S5(V.path,Q.testPatterns,Q.testDirectories,Q.sourceDirectories).slice(0,5),H={type:"test-parity-violation",kind:"test-parity-violation",category:"tests",confidence:G,evidence:[N(V.path,`Source file modified without corresponding test: ${V.path}`)],sourceFile:V.path,expectedTestLocations:M};Y.push(H)}return Y}}}var h4,g4,l4,c4,t0,I$=null,n4;var Q0=x(()=>{a0();h4=[/\.d\.ts$/,/\.config\.(ts|js|mts|mjs|cjs)$/,/index\.(ts|js|tsx|jsx)$/,/^docs\//,/^tests\//,/^test\//,/^__tests__\//,/^scripts\//,/^dist\//,/^build\//,/^\./,/types?\.(ts|js)$/,/constants?\.(ts|js)$/],g4=[".test.ts",".spec.ts",".test.js",".spec.js",".test.tsx",".spec.tsx"],l4=["tests","test","__tests__","spec"],c4=["src","lib","app"],t0=new Map;n4=v5()});import G$ from"node:path";import F5 from"node:fs/promises";import{execa as m5}from"execa";async function e4($,Z=process.cwd(),Q=m5){let X=new Map;if($.forEach((q)=>X.set(q.path,[])),$.length===0)return X;let K=new Map;for(let q of $){if(!K.has(q.baseName))K.set(q.baseName,[]);K.get(q.baseName).push(q.path)}let Y=Array.from(K.keys()),W=50;for(let q=0;q<Y.length;q+=W){let V=Y.slice(q,q+W),U=["grep","-I","-F","--null"];for(let J of V)U.push("-e"),U.push(J);try{let{stdout:J}=await Q("git",U,{cwd:Z,maxBuffer:20971520,reject:!1});if(!J)continue;let B=J.split(`
27
- `);for(let G of B){if(!G)continue;let M=G.indexOf("\x00");if(M===-1)continue;let H=G.slice(0,M),O=G.slice(M+1);if(u5.some((z)=>z.test(H)))continue;if(!t4.test(H))continue;for(let z of V)if(O.includes(z)){let _=K.get(z)||[];for(let D of _)if(D!==H){let L=X.get(D);if(!L.includes(H))L.push(H)}}}}catch(J){}}return X}async function $6($,Z,Q=process.cwd(),X=F5.readFile){try{let K=await X(G$.join(Q,$),"utf-8"),Y=G$.basename(Z,G$.extname(Z)),W=K.split(`
28
- `),q=[],V="";for(let U of W)if(U.includes(Y)&&(U.trim().startsWith("import")||U.trim().startsWith("export"))){V=V?`${V}
29
- ${U.trim()}`:U.trim();let J=U.match(/\{([^}]+)\}/);if(J){let B=J[1].split(",").map((G)=>{return G.trim().split(" as ")[0].trim().replace(/^type\s+/,"")});q.push(...B)}if(!J&&U.trim().startsWith("import")){let B=U.split("from");if(B.length>1){let G=B[0].replace("import","").trim();if(G){let M=G.match(/\*\s+as\s+([A-Za-z0-9_$]+)/);if(M)q.push(M[1].trim());else if(!G.includes("{")&&!G.includes("*"))q.push(G.split(" as ")[0].trim())}}}}return{importedSymbols:q,usageContext:V}}catch(K){return null}}function Z6($){let Z=$?.cwd??process.cwd(),Q=$?.exec??m5,X=$?.readFile??F5.readFile;return{name:"impact",async analyze(K){let Y=[],W=K.files.filter((U)=>{if(U.status!=="modified"&&U.status!=="renamed")return!1;if(u5.some((B)=>B.test(U.path)))return!1;let J=G$.extname(U.path).toLowerCase();return i4.has(J)});if(W.length===0)return[];let q=W.map((U)=>{let J=G$.extname(U.path),B=G$.basename(U.path,J);return{path:U.path,baseName:B}}),V=await e4(q,Z,Q);for(let U of W){let J=V.get(U.path)||[];if(J.length>0){let B=[];for(let O of J)if(B.length<20){let z=await $6(O,U.path,Z,X);if(z)B.push({file:O,details:z});else B.push({file:O,details:{importedSymbols:[],usageContext:""}})}else B.push({file:O,details:{importedSymbols:[],usageContext:""}});let G=J.length>10?"High":J.length>3?"Medium":"Low",M=[N(U.path,`${G} blast radius: ${J.length} file(s) depend on this module`),...B.slice(0,5).map((O)=>{let z=O.details.importedSymbols?.length>0?`Imports: ${O.details.importedSymbols.slice(0,3).join(", ")}${O.details.importedSymbols.length>3?` (+${O.details.importedSymbols.length-3} more)`:""}`:"Imports module";return N(O.file,z)})],H=new Set;B.forEach((O)=>O.details.importedSymbols?.forEach((z)=>H.add(z))),Y.push({type:"impact-analysis",kind:"impact-analysis",category:"impact",confidence:"medium",evidence:M,sourceFile:U.path,affectedFiles:J,importedSymbols:Array.from(H),usageContext:B[0]?.details.usageContext,blastRadius:J.length>10?"high":J.length>3?"medium":"low",tags:["impact","dependency"]})}}return Y}}}var u5,i4,t4,n;var h5=x(()=>{u5=[/node_modules/,/\.d\.ts$/,/^dist\//,/^build\//,/^\.git\//],i4=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".vue",".svelte"]),t4=/\.(js|jsx|ts|tsx|mjs|cjs|mts|cts|vue|svelte)$/i;n=Z6()});var i;var g5=x(()=>{i={name:"large-diff",analyze($){let Z=[],Q=$.files.length,X=0;for(let K of $.diffs)for(let Y of K.hunks)X+=Y.additions.length+Y.deletions.length;if(Q>30||X>1000)Z.push({type:"large-diff",kind:"large-diff",category:"unknown",confidence:"high",evidence:[],filesChanged:Q,linesChanged:X});return Z}}});function l5($){return $==="package.json"}function Q6($){return $==="package-lock.json"||$==="yarn.lock"||$==="pnpm-lock.yaml"||$==="bun.lockb"||$==="bun.lock"}function q6($){let Z=$.match(/^\s*"([^"]+)"\s*:/);return Z?Z[1]:null}function W6($){if(!/^\s*"[^"]+"\s*:\s*"/.test($))return!1;let Z=q6($);if(Z&&K6.includes(Z))return!1;return Y6.some((Q)=>Q.test($))}function U6($){for(let Z of $.hunks){let Q=[...Z.additions,...Z.deletions];for(let X of Q){for(let K of X6)if(X.includes(K))return!0;if(W6(X))return!0}}return!1}var X6,K6,Y6,t;var c5=x(()=>{X6=['"dependencies"','"devDependencies"','"peerDependencies"','"optionalDependencies"','"bundledDependencies"','"bundleDependencies"'],K6=["name","version","description","main","module","types","typings","exports","bin","scripts","repository","keywords","author","license","bugs","homepage","funding","files","engines","os","cpu","private","publishConfig","workspaces","packageManager","type","sideEffects","browser","unpkg","jsdelivr"],Y6=[/"\s*[\^~>=<]?\d+\.\d+/,/"\s*[\*x]\s*"/,/"\s*\d+\.x/,/"\s*npm:/,/"\s*git(\+https?|\+ssh)?:/,/"\s*github:/,/"\s*(file|link):/,/"\s*workspace:/,/"\s*https?:\/\//];t={name:"lockfiles",analyze($){let Z=[],Q=$.files.find((Y)=>l5(Y.path)),X=$.files.some((Y)=>Q6(Y.path)),K=!1;if(Q){let Y=$.diffs.find((W)=>l5(W.path));if(Y)K=U6(Y);else K=Q.status==="added"}if(K&&!X||!Q&&X)Z.push({type:"lockfile-mismatch",kind:"lockfile-mismatch",category:"dependencies",confidence:"high",evidence:[],manifestChanged:!!Q,lockfileChanged:X});return Z}}});function V6($){return $.includes("/tests/")||$.includes("/__tests__/")||$.includes(".test.")||$.includes(".spec.")||$.startsWith("tests/")}function J6($){return $.endsWith(".md")||$.startsWith("docs/")}function B6($){let Z=$.split("/").pop()||"";return Z==="package.json"||Z==="package-lock.json"||Z==="yarn.lock"||Z==="pnpm-lock.yaml"||Z==="bun.lockb"||Z.endsWith(".config.js")||Z.endsWith(".config.ts")||Z.endsWith(".config.mjs")||Z.endsWith(".config.cjs")||Z.endsWith(".toml")||$.split("/").length===1&&Z.startsWith(".")}var e;var f5=x(()=>{e={name:"test-gaps",analyze($){let Z=[],Q=0,X=0,K=[];for(let Y of $.files){if(J6(Y.path)||B6(Y.path))continue;if(V6(Y.path))X++;else Q++,K.push(Y.path)}if(Q>=3&&X===0){let Y=K.slice(0,5).map((W,q)=>N(W,q===0?`${Q} production file(s) changed with no test updates`:"No corresponding test changes"));Z.push({type:"test-gap",kind:"test-gap",category:"quality",confidence:"medium",evidence:Y,prodFilesChanged:Q,testFilesChanged:X})}return Z}}});function G6($){return $.includes("/migrations/")||$.includes("/migrate/")||$.endsWith(".sql")}var W1;var p5=x(()=>{W1={name:"sql-risks",analyze($){let Z=[];for(let Q of $.diffs){if(!G6(Q.path))continue;for(let X of Q.hunks){let K=X.additions.join(`
30
- `);if(/\b(DROP\s+TABLE|DROP\s+COLUMN|TRUNCATE)\b/gi.test(K)){let V=k(X.additions,200);Z.push({type:"sql-risk",kind:"sql-risk",category:"database",confidence:"high",evidence:[N(Q.path,V,{hunk:X})],file:Q.path,riskType:"destructive",details:"Contains DROP TABLE/COLUMN or TRUNCATE"});continue}if(/ALTER\s+TABLE[^;]+\b(ALTER\s+COLUMN|TYPE)\b/gi.test(K)){let V=k(X.additions,200);Z.push({type:"sql-risk",kind:"sql-risk",category:"database",confidence:"high",evidence:[N(Q.path,V,{hunk:X})],file:Q.path,riskType:"schema_change",details:"Contains ALTER COLUMN or TYPE change"});continue}if(/(UPDATE|DELETE)\s+(?![^;\n]*\bWHERE\b)/gi.test(K)){let V=k(X.additions,200);Z.push({type:"sql-risk",kind:"sql-risk",category:"database",confidence:"medium",evidence:[N(Q.path,V,{hunk:X})],file:Q.path,riskType:"unscoped_modification",details:"Contains UPDATE/DELETE without WHERE clause"})}}}return Z}}});function O6($){return $.includes(".github/workflows/")&&($.endsWith(".yml")||$.endsWith(".yaml"))||$===".gitlab-ci.yml"||$==="Jenkinsfile"||$==="azure-pipelines.yml"}var $1;var d5=x(()=>{$1={name:"ci-workflows",analyze($){let Z=[],Q=new Set;for(let X of $.diffs){if(!O6(X.path))continue;let K=!1,Y=!1,W=!1;for(let q of X.hunks){let V=q.additions.join(`
31
- `);if(!K&&/permissions:[\s\S]{0,500}?\b(contents|id-token|actions|packages|deployments|security-events)\b\s*:\s*write/gi.test(V)){K=!0;let G=k(q.additions,200);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"high",evidence:[N(X.path,G,{hunk:q})],file:X.path,riskType:"permissions_broadened",details:"Workflow has broadened permissions (write access)"})}if(!Y&&/pull_request_target/i.test(V)){Y=!0;let G=k(q.additions,200);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"high",evidence:[N(X.path,G,{hunk:q})],file:X.path,riskType:"pull_request_target",details:"Workflow uses pull_request_target event (can expose secrets)"})}if(!W&&/(curl|wget)\s+[^\s]+\s*\|\s*(sh|bash)/gi.test(V)){W=!0;let G=k(q.additions,200);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"high",evidence:[N(X.path,G,{hunk:q})],file:X.path,riskType:"remote_script_download",details:"Workflow downloads and pipes to shell (supply chain risk)"})}}if(!Q.has(X.path)&&X.hunks.length>0){Q.add(X.path);let q=k(X.hunks[0].additions,150);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"medium",evidence:[N(X.path,q)],file:X.path,riskType:"pipeline_changed",details:"CI/CD pipeline configuration modified"})}}return Z}}});var U1;var r5=x(()=>{U1={name:"infra",analyze($){let Z=[],Q=[],X=[],K=[];for(let Y of $.files)if(Y.path.toLowerCase().includes("dockerfile"))Q.push(Y.path);else if(Y.path.endsWith(".tf")||Y.path.endsWith(".tfvars"))X.push(Y.path);else if(Y.path.includes("kubernetes/")||Y.path.includes("k8s/")||Y.path.endsWith(".yaml")&&(Y.path.includes("deployment")||Y.path.includes("service")||Y.path.includes("ingress")))K.push(Y.path);if(Q.length>0)Z.push({type:"infra-change",kind:"infra-change",category:"infra",confidence:"high",evidence:[],infraType:"dockerfile",files:Q});if(X.length>0)Z.push({type:"infra-change",kind:"infra-change",category:"infra",confidence:"high",evidence:[],infraType:"terraform",files:X});if(K.length>0)Z.push({type:"infra-change",kind:"infra-change",category:"infra",confidence:"high",evidence:[],infraType:"k8s",files:K});return Z}}});function M6($){return $.includes("openapi")||$.includes("swagger")||$.endsWith(".proto")||$.includes("/api/")&&($.endsWith(".yaml")||$.endsWith(".yml")||$.endsWith(".json"))}var Z1;var a5=x(()=>{Z1={name:"api-contracts",analyze($){let Z=[],Q=$.files.filter((X)=>M6(X.path)).map((X)=>X.path);if(Q.length>0)Z.push({type:"api-contract-change",kind:"api-contract-change",category:"api",confidence:"high",evidence:[],files:Q});return Z}}});import{parse as H6}from"@babel/parser";import s5 from"@babel/traverse";import*as I from"@babel/types";function z6($){return $.endsWith(".tsx")||$.endsWith(".ts")}function o5($){if($==="default")return"<slot />";else if($==="boolean")return"<slot name />";else if($==="dynamic")return"<slot name={...} />";else return`<slot name="${$}" />`}function n5($,Z){let Q=[];try{let X=H6($,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"]});s5(X,{ClassDeclaration(K){let W=(K.node.decorators||[]).find((H)=>I.isCallExpression(H.expression)&&I.isIdentifier(H.expression.callee)&&H.expression.callee.name==="Component");if(!W)return;let q="",V=!1,U=K.node.loc?.start.line??1;if(I.isCallExpression(W.expression)){let H=W.expression.arguments[0];if(I.isObjectExpression(H)){for(let O of H.properties)if(I.isObjectProperty(O)&&I.isIdentifier(O.key)){if(O.key.name==="tag"){if(I.isStringLiteral(O.value))q=O.value.value}else if(O.key.name==="shadow"){if(I.isBooleanLiteral(O.value))V=O.value.value}}}}if(!q)return;let J=new Map,B=new Map,G=new Map,M=new Set;for(let H of K.node.body.body){if(I.isClassProperty(H)||I.isClassMethod(H)){let O=H.decorators||[],z=O.find((L)=>I.isCallExpression(L.expression)&&I.isIdentifier(L.expression.callee)&&L.expression.callee.name==="Prop"||I.isIdentifier(L.expression)&&L.expression.name==="Prop");if(z&&I.isIdentifier(H.key)){let L=H.key.name,w=H.loc?.start.line??1,T,A=!1,b=!1,R;if(I.isClassProperty(H)&&H.typeAnnotation&&I.isTSTypeAnnotation(H.typeAnnotation));if(I.isCallExpression(z.expression)){let h=z.expression.arguments[0];if(I.isObjectExpression(h)){for(let y of h.properties)if(I.isObjectProperty(y)&&I.isIdentifier(y.key)){if(y.key.name==="attribute"&&I.isStringLiteral(y.value))T=y.value.value;if(y.key.name==="reflect"&&I.isBooleanLiteral(y.value))A=y.value.value;if(y.key.name==="mutable"&&I.isBooleanLiteral(y.value))b=y.value.value}}}J.set(L,{name:L,attribute:T,reflect:A,mutable:b,typeText:R,line:w})}let _=O.find((L)=>I.isCallExpression(L.expression)&&I.isIdentifier(L.expression.callee)&&L.expression.callee.name==="Event"||I.isIdentifier(L.expression)&&L.expression.name==="Event");if(_&&I.isIdentifier(H.key)){let L=H.key.name,w=L,T=H.loc?.start.line??1,A=!0,b=!0,R=!0;if(I.isCallExpression(_.expression)){let h=_.expression.arguments[0];if(I.isObjectExpression(h)){for(let y of h.properties)if(I.isObjectProperty(y)&&I.isIdentifier(y.key)){if(y.key.name==="eventName"&&I.isStringLiteral(y.value))w=y.value.value;if(y.key.name==="bubbles"&&I.isBooleanLiteral(y.value))A=y.value.value;if(y.key.name==="composed"&&I.isBooleanLiteral(y.value))b=y.value.value;if(y.key.name==="cancelable"&&I.isBooleanLiteral(y.value))R=y.value.value}}}B.set(w,{name:w,memberName:L,bubbles:A,composed:b,cancelable:R,line:T})}if(O.find((L)=>I.isCallExpression(L.expression)&&I.isIdentifier(L.expression.callee)&&L.expression.callee.name==="Method"||I.isIdentifier(L.expression)&&L.expression.name==="Method")&&I.isIdentifier(H.key)){let L=H.key.name,w=H.loc?.start.line??1;G.set(L,{name:L,line:w})}}if(I.isClassMethod(H)&&I.isIdentifier(H.key)&&H.key.name==="render")s5(H,{JSXElement(O){let z=O.node.openingElement;if(I.isJSXIdentifier(z.name)&&z.name.name==="slot"){let _="default";for(let D of z.attributes)if(I.isJSXAttribute(D)&&I.isJSXIdentifier(D.name)&&D.name.name==="name")if(I.isStringLiteral(D.value))_=D.value.value;else if(D.value===null)_="boolean";else _="dynamic";M.add(_)}}},K.scope,K)}Q.push({tag:q,shadow:V,file:Z,line:U,props:J,events:B,methods:G,slots:M})}})}catch(X){}return Q}var _6,$2;var i5=x(()=>{o0();_6={batchGetFileContent:$0};$2={name:"stencil",async analyze($){let Z=[],Q=$.files.filter((Y)=>z6(Y.path));if(Q.length===0)return[];let X=[];for(let Y of Q)X.push({ref:$.base,path:Y.path}),X.push({ref:$.head,path:Y.path});let K=await _6.batchGetFileContent(X);for(let Y of Q){let W=`${$.base}:${Y.path}`,q=`${$.head}:${Y.path}`,V=K.get(W),U=K.get(q);if(!V&&!U)continue;let J=V?n5(V,Y.path):[],B=U?n5(U,Y.path):[],G=new Map(J.map((O)=>[O.tag,O])),M=new Map(B.map((O)=>[O.tag,O])),H=new Set([...G.keys(),...M.keys()]);for(let O of H){let z=G.get(O),_=M.get(O);if(z&&!_)Z.push({type:"stencil-component-change",kind:"stencil-component-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Component({ tag: "${O}" })`,{line:z.line})],tag:O,change:"removed",file:Y.path});else if(!z&&_)Z.push({type:"stencil-component-change",kind:"stencil-component-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Component({ tag: "${O}" })`,{line:_.line})],tag:O,change:"added",file:Y.path});else if(z&&_){if(z.shadow!==_.shadow)Z.push({type:"stencil-component-change",kind:"stencil-component-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Component({ tag: "${O}", shadow: ${_.shadow} })`,{line:_.line})],tag:O,change:"shadow-changed",file:Y.path,fromShadow:z.shadow,toShadow:_.shadow});let D=new Set([...z.props.keys(),..._.props.keys()]);for(let A of D){let b=z.props.get(A),R=_.props.get(A);if(b&&!R)Z.push({type:"stencil-prop-change",kind:"stencil-prop-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Prop() ${A}`,{line:b.line})],tag:O,propName:A,change:"removed",file:Y.path});else if(!b&&R)Z.push({type:"stencil-prop-change",kind:"stencil-prop-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Prop() ${A}`,{line:R.line})],tag:O,propName:A,change:"added",file:Y.path,details:{attribute:R.attribute,reflect:R.reflect,mutable:R.mutable}});else if(b&&R){if(b.attribute!==R.attribute||b.reflect!==R.reflect||b.mutable!==R.mutable)Z.push({type:"stencil-prop-change",kind:"stencil-prop-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Prop() ${A}`,{line:R.line})],tag:O,propName:A,change:"changed",file:Y.path,details:{attribute:R.attribute,reflect:R.reflect,mutable:R.mutable}})}}let L=new Set([...z.events.keys(),..._.events.keys()]);for(let A of L){let b=z.events.get(A),R=_.events.get(A);if(b&&!R)Z.push({type:"stencil-event-change",kind:"stencil-event-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Event() ${b.memberName}`,{line:b.line})],tag:O,eventName:A,change:"removed",file:Y.path});else if(!b&&R)Z.push({type:"stencil-event-change",kind:"stencil-event-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Event() ${R.memberName}`,{line:R.line})],tag:O,eventName:A,change:"added",file:Y.path,details:{bubbles:R.bubbles,composed:R.composed,cancelable:R.cancelable}});else if(b&&R){if(b.bubbles!==R.bubbles||b.composed!==R.composed||b.cancelable!==R.cancelable)Z.push({type:"stencil-event-change",kind:"stencil-event-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Event() ${R.memberName}`,{line:R.line})],tag:O,eventName:A,change:"changed",file:Y.path,details:{bubbles:R.bubbles,composed:R.composed,cancelable:R.cancelable}})}}let w=new Set([...z.methods.keys(),..._.methods.keys()]);for(let A of w){let b=z.methods.get(A),R=_.methods.get(A);if(b&&!R)Z.push({type:"stencil-method-change",kind:"stencil-method-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Method() ${A}`,{line:b.line})],tag:O,methodName:A,change:"removed",file:Y.path});else if(!b&&R)Z.push({type:"stencil-method-change",kind:"stencil-method-change",category:"api",confidence:"high",evidence:[N(Y.path,`@Method() ${A}`,{line:R.line})],tag:O,methodName:A,change:"added",file:Y.path})}let T=new Set([...z.slots,..._.slots]);for(let A of T){let b=z.slots.has(A),R=_.slots.has(A);if(b&&!R)Z.push({type:"stencil-slot-change",kind:"stencil-slot-change",category:"api",confidence:"high",evidence:[N(Y.path,o5(A),{line:z.line})],tag:O,slotName:A,change:"removed",file:Y.path});else if(!b&&R)Z.push({type:"stencil-slot-change",kind:"stencil-slot-change",category:"api",confidence:"high",evidence:[N(Y.path,o5(A),{line:_.line})],tag:O,slotName:A,change:"added",file:Y.path})}}}}return Z}}});function t5($){if(!$.startsWith("app/")&&!$.startsWith("src/app/"))return!1;return D6($)}function D6($){let Z=$.split("/").pop()??"";return Object.keys(e5).includes(Z)}function A6($){let Z=$.split("/").pop()??"";return e5[Z]??"unknown"}function N6($){let Z=$.replace(/^src\/app/,"").replace(/^app/,""),Q=Z.split("/");if(Q.pop(),Z=Q.join("/"),Z=Z.replace(/\/\([^)]+\)/g,""),Z===""||Z==="/")return"/";if(!Z.startsWith("/"))Z="/"+Z;if(Z.length>1&&Z.endsWith("/"))Z=Z.slice(0,-1);return Z}function R6($){let Z=new Set,Q=P($).join(`
32
- `),X,K=new RegExp(j6.source,"g");while((X=K.exec(Q))!==null)Z.add(X[1]);return Array.from(Z).sort()}function T6($){return L6.includes($)}var e5,L6,j6,Z2;var Q2=x(()=>{e5={"page.tsx":"page","page.ts":"page","page.jsx":"page","page.js":"page","layout.tsx":"layout","layout.ts":"layout","layout.jsx":"layout","layout.js":"layout","loading.tsx":"page","loading.ts":"page","loading.jsx":"page","loading.js":"page","error.tsx":"error","error.ts":"error","error.jsx":"error","error.js":"error","not-found.tsx":"error","not-found.ts":"error","not-found.jsx":"error","not-found.js":"error","route.ts":"endpoint","route.tsx":"endpoint","route.js":"endpoint","route.jsx":"endpoint"},L6=["middleware.ts","middleware.js","middleware.tsx","middleware.jsx","src/middleware.ts","src/middleware.js","src/middleware.tsx","src/middleware.jsx"],j6=/export\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s*\(/g;Z2={name:"next-routes",analyze($){let Z=[],Q=new Map;for(let X of $.files){if(t5(X.path))Q.set(X.path,{status:X.status});if(T6(X.path)){let K=$.diffs.find((q)=>q.path===X.path),Y=[];if(K&&K.hunks.length>0){let q=P(K);if(q.length>0){let V=k(q);if(V)Y.push(N(X.path,V))}}let W={type:"security-file",kind:"security-file",category:"routes",confidence:"high",evidence:Y,files:[X.path],reasons:["middleware"]};Z.push(W)}}for(let X of $.diffs)if(t5(X.path)){let K=Q.get(X.path);if(K)K.diff=X;else Q.set(X.path,{diff:X,status:X.status})}for(let[X,{diff:K,status:Y}]of Q){let W=N6(X),q=A6(X),V=[];if(K&&K.hunks.length>0){let J=P(K);if(J.length>0){let B=k(J);if(B)V.push(N(X,B))}}let U={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:V,routeId:W,file:X,change:Y,routeType:q};if(q==="endpoint"&&K){let J=R6(K);if(J.length>0){U.methods=J;let B=J.map((G)=>`export function ${G}`).join(", ");if(!V.length)V.push(N(X,B))}}Z.push(U)}return Z}}});function w6($){return x6.some((Z)=>Z.test($))}function E6($){let Z=[],Q=$.join(`
33
- `),X=Q.match(/type\s+(\w+)\s*[{@]/g);if(X)for(let q of X){let V=q.match(/type\s+(\w+)/)?.[1];if(V)Z.push(`Removed type: ${V}`)}let K=Q.match(/enum\s+(\w+)\s*{/g);if(K)for(let q of K){let V=q.match(/enum\s+(\w+)/)?.[1];if(V)Z.push(`Removed enum: ${V}`)}let Y=Q.match(/interface\s+(\w+)\s*[{@]/g);if(Y)for(let q of Y){let V=q.match(/interface\s+(\w+)/)?.[1];if(V)Z.push(`Removed interface: ${V}`)}let W=Q.match(/input\s+(\w+)\s*{/g);if(W)for(let q of W){let V=q.match(/input\s+(\w+)/)?.[1];if(V)Z.push(`Removed input type: ${V}`)}return Z}function I6($){let Z=[],Q=$.join(`
34
- `),X=Q.match(/type\s+(\w+)\s*[{@]/g);if(X)for(let Y of X){let W=Y.match(/type\s+(\w+)/)?.[1];if(W&&!["Query","Mutation","Subscription"].includes(W))Z.push(`Added type: ${W}`)}let K=Q.match(/enum\s+(\w+)\s*{/g);if(K)for(let Y of K){let W=Y.match(/enum\s+(\w+)/)?.[1];if(W)Z.push(`Added enum: ${W}`)}return Z}var x6,X2;var $8=x(()=>{x6=[/\.graphql$/,/\.gql$/,/schema\.graphqls$/,/schema\.sdl$/];X2={name:"graphql",analyze($){let Z=[];for(let Q of $.diffs){if(!w6(Q.path))continue;let X=P(Q),K=G1(Q),Y=E6(K),W=I6(X),q=Y.length>0,V=W.length>0,U=K.length>0,J=q?k(K):k(X),B="medium";if(q)B="high";else if(V&&!U)B="low";let G={type:"graphql-change",kind:"graphql-change",category:"api",confidence:B,evidence:[N(Q.path,J)],file:Q.path,status:Q.status,isBreaking:q,breakingChanges:Y.slice(0,5),addedElements:W.slice(0,5)};Z.push(G)}return Z}}});function y6($){return b6.some((Z)=>Z.test($))}function k6($,Z){let Q=[],X=[],K=[],Y=/"(\w+)":\s*/,W=new Set,q=new Set;for(let V of $){let U=V.match(Y);if(U)W.add(U[1])}for(let V of Z){let U=V.match(Y);if(U)q.add(U[1])}for(let V of W)if(q.has(V))K.push(V);else Q.push(V);for(let V of q)if(!W.has(V))X.push(V);return{added:Q,removed:X,modified:K}}function S6($,Z,Q){for(let X of[...$,...Z,...Q])if(C6.has(X))return!0;return!1}function v6($,Z,Q){let X=[],K=[...$,...Z,...Q];for(let Y of K)if(P6.has(Y))if($.includes(Y))X.push(`Added ${Y}`);else if(Z.includes(Y))X.push(`Removed ${Y}`);else X.push(`Modified ${Y}`);return X}var b6,C6,P6,x1;var i1=x(()=>{b6=[/^tsconfig\.json$/,/^tsconfig\.\w+\.json$/,/\/tsconfig\.json$/,/\/tsconfig\.\w+\.json$/],C6=new Set(["strict","strictNullChecks","strictFunctionTypes","strictBindCallApply","strictPropertyInitialization","noImplicitAny","noImplicitThis","noImplicitReturns","noUncheckedIndexedAccess","target","module","moduleResolution","lib","jsx","esModuleInterop","allowSyntheticDefaultImports","skipLibCheck","isolatedModules","verbatimModuleSyntax","baseUrl","paths","outDir","rootDir","declaration","declarationMap","sourceMap","composite","incremental","emitDecoratorMetadata","experimentalDecorators"]),P6=new Set(["strict","strictNullChecks","strictFunctionTypes","strictBindCallApply","strictPropertyInitialization","noImplicitAny","noImplicitThis","noImplicitReturns","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","exactOptionalPropertyTypes"]);x1={name:"typescript-config",analyze($){let Z=[];for(let Q of $.diffs){if(!y6(Q.path))continue;let X=P(Q),K=G1(Q),{added:Y,removed:W,modified:q}=k6(X,K);if(Y.length===0&&W.length===0&&q.length===0){if(X.length>0||K.length>0){let M={type:"typescript-config",kind:"typescript-config",category:"config_env",confidence:"low",evidence:[N(Q.path,k(X.length>0?X:K))],file:Q.path,status:Q.status,isBreaking:!1,changedOptions:{added:[],removed:[],modified:[]},strictnessChanges:[]};Z.push(M)}continue}let V=S6(Y,W,q),U=v6(Y,W,q),J=V?"high":"medium",B=k(X.length>0?X:K),G={type:"typescript-config",kind:"typescript-config",category:"config_env",confidence:J,evidence:[N(Q.path,B)],file:Q.path,status:Q.status,isBreaking:V,changedOptions:{added:Y,removed:W,modified:q},strictnessChanges:U};Z.push(G)}return Z}}});function g6($){return F6.some((Z)=>Z.test($))}function l6($){return m6.some((Z)=>Z.test($))}function c6($){let Z=new Set,Q=$.join(`
35
- `);for(let X of u6)if(new RegExp(`\\b${X}\\s*[:{]`,"i").test(Q))Z.add(X);for(let X of h6)if(new RegExp(`\\b${X}\\s*[:{]`,"i").test(Q))Z.add(`theme.${X}`);return Array.from(Z)}function f6($,Z){let Q=[],X=$.join(`
36
- `),K=Z.join(`
37
- `);if(/\bcontent\s*[:{]/.test(K)||/\bcontent\s*[:{]/.test(X)){if(Z.length>0)Q.push("Content paths modified (may affect CSS purging)")}if(/\bprefix\s*[:{]/.test(K)&&/\bprefix\s*[:{]/.test(X))Q.push("Class prefix changed (requires updating all class names)");if(/colors\s*[:{]/.test(K))Q.push("Theme colors modified (may break existing color classes)");if(/screens\s*[:{]/.test(K))Q.push("Screen breakpoints modified (may affect responsive design)");if(/plugins\s*[:{]/.test(K)&&Z.some((Y)=>Y.includes("require(")))Q.push("Plugins removed (may remove utility classes)");if(/darkMode\s*[:{]/.test(K)||/darkMode\s*[:{]/.test(X))Q.push("Dark mode configuration changed");return{isBreaking:Q.length>0,reasons:Q}}var F6,m6,u6,h6,w1;var t1=x(()=>{F6=[/^tailwind\.config\.(js|cjs|mjs|ts)$/,/\/tailwind\.config\.(js|cjs|mjs|ts)$/],m6=[/^postcss\.config\.(js|cjs|mjs)$/,/\/postcss\.config\.(js|cjs|mjs)$/],u6=["theme","content","plugins","presets","prefix","important","darkMode","safelist"],h6=["colors","spacing","screens","fontFamily","fontSize","fontWeight","extend","borderRadius","boxShadow","animation","keyframes"];w1={name:"tailwind",analyze($){let Z=[];for(let Q of $.diffs){let X=g6(Q.path),K=l6(Q.path);if(!X&&!K)continue;let Y=P(Q),W=G1(Q),q=c6([...Y,...W]),{isBreaking:V,reasons:U}=f6(Y,W),J=V?"high":q.length>0?"medium":"low",B=k(Y.length>0?Y:W),G={type:"tailwind-config",kind:"tailwind-config",category:"config_env",confidence:J,evidence:[N(Q.path,B)],file:Q.path,status:Q.status,configType:X?"tailwind":"postcss",isBreaking:V,affectedSections:q,breakingReasons:U};Z.push(G)}return Z}}});function r6($){for(let[Z,Q]of Object.entries(p6))if(Q.some((X)=>X.test($))){if(Z==="npm"&&!$.endsWith("package.json"))continue;return Z}return null}function a6($,Z){let Q=[...$,...Z].join(`
38
- `);return/["']workspaces["']/.test(Q)}function s6($,Z){let Q=d6[Z]||[],X=[],K=$.join(`
39
- `);for(let Y of Q)if(new RegExp(`["']?${Y}["']?\\s*[:{[]`,"i").test(K))X.push(Y);return X}function o6($,Z,Q){let X=[],K=Z.join(`
40
- `),Y=Q.join(`
41
- `);switch($){case"turborepo":if(/pipeline|tasks/.test(Y))X.push("Build pipeline configuration changed");if(/cache\s*[:=]\s*false/.test(K))X.push("Caching disabled for tasks");if(/globalDependencies/.test(K)||/globalDependencies/.test(Y))X.push("Global dependencies changed (affects cache invalidation)");break;case"pnpm":if(/packages/.test(Y))X.push("Workspace packages configuration changed");break;case"lerna":if(/version/.test(K)&&/independent/.test(K))X.push("Switching to independent versioning");if(/npmClient/.test(K)||/npmClient/.test(Y))X.push("npm client configuration changed");break;case"nx":if(/targetDefaults/.test(Y))X.push("Default target configuration changed");if(/plugins/.test(K)||/plugins/.test(Y))X.push("Nx plugins configuration changed");break;case"yarn":if(/nodeLinker/.test(K)||/nodeLinker/.test(Y))X.push("Node linker strategy changed (affects dependency resolution)");break;case"npm":if(/workspaces/.test(Y))X.push("Workspace packages configuration changed");break;case"changesets":if(/baseBranch/.test(K)||/baseBranch/.test(Y))X.push("Base branch for changesets modified");if(/access/.test(K))X.push("Package publish access level changed");break}return X}var p6,d6,K2;var Y2=x(()=>{p6={turborepo:[/^turbo\.json$/],pnpm:[/^pnpm-workspace\.yaml$/,/^pnpm-workspace\.yml$/],lerna:[/^lerna\.json$/],nx:[/^nx\.json$/,/^project\.json$/],yarn:[/^\.yarnrc\.yml$/,/^\.yarnrc$/],npm:[/^package\.json$/],changesets:[/^\.changeset\/config\.json$/]},d6={turborepo:["pipeline","globalDependencies","globalEnv","tasks"],pnpm:["packages"],lerna:["packages","version","npmClient","useWorkspaces"],nx:["targetDefaults","namedInputs","plugins","defaultProject"],yarn:["nodeLinker","enableGlobalCache","nmMode"],npm:["workspaces"],changesets:["baseBranch","access","changelog"]};K2={name:"monorepo",analyze($){let Z=[];for(let Q of $.diffs){let X=r6(Q.path);if(!X)continue;let K=P(Q),Y=G1(Q);if(X==="npm"&&!a6(K,Y))continue;let W=s6([...K,...Y],X),q=o6(X,K,Y);if(W.length===0&&q.length===0)continue;let U=q.length>0?"high":"medium",J=k(K.length>0?K:Y),B={type:"monorepo-config",kind:"monorepo-config",category:"config_env",confidence:U,evidence:[N(Q.path,J)],file:Q.path,status:Q.status,tool:X,affectedFields:W,impacts:q};Z.push(B)}return Z}}});function X0($,Z=""){if(!$)return[];if(typeof $==="string")return[Z||"."];if(typeof $==="object"){let Q=[];for(let[X,K]of Object.entries($))if(X.startsWith("."))Q.push(...X0(K,X));else if(typeof K==="string"||typeof K==="object")Q.push(...X0(K,Z));return[...new Set(Q)]}return[]}function n6($,Z){let Q=X0($),X=X0(Z),K=new Set(Q),Y=new Set(X),W=X.filter((V)=>!K.has(V)),q=Q.filter((V)=>!Y.has(V));return{added:W,removed:q,hasExportsField:{base:$!==void 0&&$!==null,head:Z!==void 0&&Z!==null}}}function i6($,Z){let Q=["main","module","types","typings","browser"],X=[];for(let K of Q){let Y=$?.[K],W=Z?.[K];if(Y!==W)X.push({field:K,from:Y,to:W})}return X}function t6($,Z){let Q=$?.bin,X=Z?.bin,K=(q)=>{if(typeof q==="string")return["(default)"];if(typeof q==="object"&&q!==null)return Object.keys(q);return[]},Y=new Set(K(Q)),W=new Set(K(X));return{added:[...W].filter((q)=>!Y.has(q)),removed:[...Y].filter((q)=>!W.has(q))}}var q2;var W2=x(()=>{q2={name:"package-exports",analyze($){let Z=[],Q=$.basePackageJson,X=$.headPackageJson;if(!Q&&!X)return Z;let K=Q?.exports,Y=X?.exports,W=n6(K??null,Y??null),q=i6(Q,X),V=t6(Q,X),U=W.removed.length>0,J=V.removed.length>0,B=q.some((L)=>L.from!==void 0&&L.to===void 0),G=U||J||B,M=W.added.length>0||W.removed.length>0,H=q.length>0,O=V.added.length>0||V.removed.length>0;if(!M&&!H&&!O)return Z;let z="medium";if(G)z="high";else if(W.added.length>0||V.added.length>0)z="low";let _=[];if(W.removed.length>0)_.push(`Removed exports: ${W.removed.slice(0,3).join(", ")}`);if(W.added.length>0)_.push(`Added exports: ${W.added.slice(0,3).join(", ")}`);if(q.length>0)_.push(`Changed fields: ${q.map((L)=>L.field).join(", ")}`);if(V.removed.length>0)_.push(`Removed bins: ${V.removed.join(", ")}`);if(V.added.length>0)_.push(`Added bins: ${V.added.join(", ")}`);let D={type:"package-exports",kind:"package-exports",category:"api",confidence:z,evidence:[N("package.json",_.join("; "))],isBreaking:G,addedExports:W.added,removedExports:W.removed,legacyFieldChanges:q,binChanges:{added:V.added,removed:V.removed}};return Z.push(D),Z}}});function Q3($){return Z8.test($)}function Q8($){return e6.test($)}function X8($){return $3.test($)}function X3($){return Z3.some((Z)=>Z.test($))}function K3($){let Z=$.match(Z8);if(!Z)return $;let Q=Z[2];return Q=Q.replace(/\.(get|post|put|delete|patch)$/i,""),Q=Q.replace(/\/index$/,"").replace(/^index$/,"").replace(/\[\.\.\.(\w+)\]/g,":$1*").replace(/\[(\w+)\]/g,":$1"),"/"+Q}function Y3($){let Z=[],Q=$.match(/\.(\w+)\.(ts|js)$/);if(Q){let X=Q[1].toUpperCase();if(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].includes(X))Z.push(X)}if(Z.length===0)Z.push("*");return Z}function q3($){if(Q8($))return"endpoint";if(X8($))return"layout";if($.includes("error.vue")||$.includes("404.vue")||$.includes("500.vue"))return"error";return"page"}var Z8,e6,$3,Z3,U2;var V2=x(()=>{Z8=/^(pages|src\/pages)\/(.+)\.(vue|ts|tsx|js|jsx)$/,e6=/^server\/(api|routes|middleware)\/(.+)\.(ts|js)$/,$3=/^(layouts|src\/layouts)\/(.+)\.vue$/,Z3=[/router\.(ts|js)$/,/routes\.(ts|js)$/,/router\/index\.(ts|js)$/];U2={name:"vue-routes",analyze($){let Z=[];for(let Q of $.files){let X=Q3(Q.path),K=Q8(Q.path),Y=X8(Q.path),W=X3(Q.path);if(!X&&!K&&!Y&&!W)continue;if(W){let O=$.diffs.find((L)=>L.path===Q.path),z=O?P(O):[],_=k(z),D={type:"route-change",kind:"route-change",category:"routes",confidence:"medium",evidence:[N(Q.path,_||"Vue Router config changed")],routeId:"vue-router-config",file:Q.path,change:Q.status,routeType:"unknown"};Z.push(D);continue}let q=X?K3(Q.path):Q.path,V=q3(Q.path),U=K?Y3(Q.path):void 0,J=$.diffs.find((O)=>O.path===Q.path),B=J?P(J):[],G=k(B),M=[];if(G)M.push(N(Q.path,G));let H={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:M,routeId:q,file:Q.path,change:Q.status,routeType:V,methods:U};Z.push(H)}return Z}}});function J3($){return J2.test($)}function K8($){return J2.test($)&&/\.(ts|js)$/.test($)}function Y8($){return W3.test($)}function B3($){return U3.test($)}function G3($){return V3.test($)}function O3($){let Z=$.match(J2);if(!Z)return $;let Q=Z[1];return Q=Q.replace(/\.(astro|md|mdx|html|ts|js)$/,""),Q=Q.replace(/\/index$/,"").replace(/^index$/,"").replace(/\[\.\.\.(\w+)\]/g,":$1*").replace(/\[(\w+)\]/g,":$1"),"/"+Q}function M3($){let Z=[],Q=$.join(`
42
- `),X=[{pattern:/export\s+(const|function|async function)\s+GET\b/,method:"GET"},{pattern:/export\s+(const|function|async function)\s+POST\b/,method:"POST"},{pattern:/export\s+(const|function|async function)\s+PUT\b/,method:"PUT"},{pattern:/export\s+(const|function|async function)\s+DELETE\b/,method:"DELETE"},{pattern:/export\s+(const|function|async function)\s+PATCH\b/,method:"PATCH"},{pattern:/export\s+(const|function|async function)\s+ALL\b/,method:"*"}];for(let{pattern:K,method:Y}of X)if(K.test(Q))Z.push(Y);return Z}function H3($){if(Y8($))return"layout";if(K8($))return"endpoint";if($.includes("404.")||$.includes("500."))return"error";return"page"}var J2,W3,U3,V3,B2;var G2=x(()=>{J2=/^src\/pages\/(.+)\.(astro|md|mdx|html|ts|js)$/,W3=/^src\/layouts\/(.+)\.astro$/,U3=/^src\/content\/(.+)\.(md|mdx|json|yaml|yml)$/,V3=/^astro\.config\.(mjs|ts|js)$/;B2={name:"astro-routes",analyze($){let Z=[];for(let Q of $.files){let X=J3(Q.path),K=Y8(Q.path),Y=B3(Q.path),W=G3(Q.path);if(!X&&!K&&!Y&&!W)continue;let q=$.diffs.find((z)=>z.path===Q.path),V=q?P(q):[],U=k(V);if(W){let z={type:"route-change",kind:"route-change",category:"routes",confidence:"medium",evidence:[N(Q.path,U||"Astro config changed")],routeId:"astro-config",file:Q.path,change:Q.status,routeType:"unknown"};Z.push(z);continue}if(Y){let z={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:U?[N(Q.path,U)]:[],routeId:Q.path.replace(/^src\/content\//,"/content/"),file:Q.path,change:Q.status,routeType:"page",tags:["content-collection"]};Z.push(z);continue}let J=X?O3(Q.path):Q.path,B=H3(Q.path),G=K8(Q.path)?M3(V):[],M=G.length>0?G:void 0,H=[];if(U)H.push(N(Q.path,U));let O={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:H,routeId:J,file:Q.path,change:Q.status,routeType:B,methods:M};Z.push(O)}return Z}}});function z3($){let Z=$.split("/").pop()??"";return q8.test(Z)||W8.test(Z)||U8.test(Z)||V8.test(Z)||J8.test(Z)}function L3($){let Z=$.split("/").pop()??"";if(q8.test(Z))return"requirements";if(W8.test(Z))return"pyproject";if(U8.test(Z))return"setup";if(V8.test(Z))return"pipfile";if(J8.test(Z))return"poetry";return"unknown"}function B8($){let Z=$.trim();if(!Z||Z.startsWith("#")||Z.startsWith("-"))return null;if(Z.startsWith("-r "))return null;let Q=Z.match(/^([a-zA-Z0-9_-]+)(?:\[[^\]]+\])?(?:[><=~!]+(.+))?/);if(Q)return{name:Q[1].toLowerCase(),version:Q[2]?.trim()};return null}function G8($){let Z=$.match(/["']([a-zA-Z0-9_-]+)(?:\[[^\]]+\])?(?:[><=~!]+([^"']+))?["']/);if(Z)return{name:Z[1].toLowerCase(),version:Z[2]?.trim()};let Q=$.match(/^([a-zA-Z0-9_-]+)\s*=/);if(Q)return{name:Q[1].toLowerCase(),version:void 0};return null}function j3($,Z){let Q=P($),X=[];for(let K of Q){let Y=null;if(Z==="requirements")Y=B8(K);else if(Z==="pyproject"||Z==="pipfile"||Z==="poetry")Y=G8(K);if(Y)X.push(Y)}return X}function D3($,Z){let Q=G1($),X=[];for(let K of Q){let Y=null;if(Z==="requirements")Y=B8(K);else if(Z==="pyproject"||Z==="pipfile"||Z==="poetry")Y=G8(K);if(Y)X.push(Y)}return X}var q8,W8,U8,V8,J8,_3,O2;var O8=x(()=>{q8=/requirements.*\.txt$/,W8=/pyproject\.toml$/,U8=/^setup\.(py|cfg)$/,V8=/^Pipfile(\.lock)?$/,J8=/^poetry\.lock$/,_3={"django-allauth":"auth","python-social-auth":"auth",authlib:"auth",oauthlib:"auth","python-jose":"auth",pyjwt:"auth",passlib:"auth","argon2-cffi":"auth",bcrypt:"auth",django:"database",sqlalchemy:"database",alembic:"database",psycopg2:"database","psycopg2-binary":"database",asyncpg:"database",pymysql:"database",mysqlclient:"database",pymongo:"database",motor:"database",redis:"database",aioredis:"database","tortoise-orm":"database",peewee:"database",sqlmodel:"database",databases:"database",prisma:"database",numpy:"native",pandas:"native",scipy:"native",pillow:"native","opencv-python":"native",tensorflow:"native",torch:"native",cryptography:"native",pycryptodome:"native",pynacl:"native",stripe:"payment",braintree:"payment",paypalrestsdk:"payment"};O2={name:"python-dependencies",analyze($){let Z=[];for(let Q of $.files){if(!z3(Q.path))continue;let X=$.diffs.find((Y)=>Y.path===Q.path),K=L3(Q.path);if(X){let Y=j3(X,K),W=D3(X,K),q=new Set(W.map((U)=>U.name)),V=new Set(Y.map((U)=>U.name));for(let U of Y){let J=q.has(U.name),B=J?W.find((z)=>z.name===U.name):void 0,G="new";if(J&&B?.version&&U.version){let z=parseInt(B.version.match(/(\d+)/)?.[1]??"0",10);if(parseInt(U.version.match(/(\d+)/)?.[1]??"0",10)>z)G="major";else G="minor"}else if(J)G="unknown";let M=_3[U.name],O=P(X).find((z)=>z.toLowerCase().includes(U.name))??U.name;Z.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[N(Q.path,O)],name:U.name,section:"dependencies",from:B?.version,to:U.version,impact:G,riskCategory:M})}for(let U of W){if(V.has(U.name))continue;let B=G1(X).find((G)=>G.toLowerCase().includes(U.name))??U.name;Z.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[N(Q.path,B)],name:U.name,section:"dependencies",from:U.version,to:void 0,impact:"removed"})}}else if(Q.status==="added"||Q.status==="deleted")Z.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"medium",evidence:[N(Q.path,`${K} file ${Q.status}`)],name:Q.path,section:"dependencies",impact:Q.status==="added"?"new":"removed"})}return Z}}});function M8($,Z){let Q=$.split("/").pop()??"";if(/urls\.py$/.test(Q))return"django";if(Z.includes("from fastapi")||Z.includes("import fastapi")||Z.includes("APIRouter"))return"fastapi";if(Z.includes("from django")||Z.includes("urlpatterns"))return"django";if(Z.includes("from flask")||Z.includes("Flask(")||Z.includes("Blueprint("))return"flask";for(let X of j8)if(X.test(Q))return"django";for(let X of L8)if(X.test(Q))return"fastapi";for(let X of D8)if(X.test(Q))return"flask";return null}function H8($){if(!$.endsWith(".py"))return!1;let Z=$.split("/").pop()??"";return[...L8,...j8,...D8].some((X)=>X.test(Z))}function x3($){let Z=[],Q=new RegExp(N3.source,"gi"),X;while((X=Q.exec($))!==null){let K=X[1].toLowerCase(),Y=X[2],W=K==="api_route"?["GET"]:[K.toUpperCase()];Z.push({path:Y,methods:W})}return Z}function w3($){let Z=[],Q=new RegExp(R3.source,"gi"),X;while((X=Q.exec($))!==null){let K=X[1];Z.push({path:K,methods:[]})}return Z}function E3($){let Z=[],Q=new RegExp(T3.source,"gi"),X;while((X=Q.exec($))!==null){let K=X[1],Y=X[2],W=["GET"];if(Y)W=Y.replace(/["']/g,"").split(",").map((q)=>q.trim().toUpperCase()).filter((q)=>q.length>0);Z.push({path:K,methods:W})}return Z}function _8($,Z){switch(Z){case"fastapi":return x3($);case"django":return w3($);case"flask":return E3($)}}function z8($,Z){return"endpoint"}function M2($,Z){let Q=$;if(Z==="django")Q=Q.replace(/^\^/,"").replace(/\$$/,""),Q=Q.replace(/\(\?P<(\w+)>[^)]+\)/g,":{$1}");if(!Q.startsWith("/"))Q="/"+Q;if(Q.length>1&&Q.endsWith("/"))Q=Q.slice(0,-1);return Q}var A3,N3,R3,T3,L8,j8,D8,H2;var A8=x(()=>{A3=["get","post","put","patch","delete","head","options"],N3=new RegExp(`@\\w+\\.(${A3.join("|")}|api_route)\\s*\\(\\s*["']([^"']+)["']`,"gi"),R3=/(?:path|re_path|url)\s*\(\s*(?:r)?["']([^"']+)["']/gi,T3=/@\w+\.route\s*\(\s*["']([^"']+)["'](?:.*?methods\s*=\s*\[([^\]]+)\])?/gi,L8=[/routers?\.py$/,/endpoints?\.py$/,/api\.py$/,/main\.py$/,/app\.py$/,/routes?\.py$/],j8=[/urls\.py$/,/views\.py$/],D8=[/views?\.py$/,/routes?\.py$/,/app\.py$/,/api\.py$/,/__init__\.py$/];H2={name:"python-routes",analyze($){let Z=[],Q=new Map;for(let X of $.files)if(H8(X.path))Q.set(X.path,{status:X.status});for(let X of $.diffs)if(H8(X.path)){let K=Q.get(X.path);if(K)K.diff=X;else Q.set(X.path,{diff:X,status:X.status})}for(let[X,{diff:K}]of Q){if(!K)continue;let Y=P(K),W=G1(K),q=Y.join(`
43
- `),V=W.join(`
44
- `),U=M8(X,q)??M8(X,V);if(!U)continue;let J=_8(q,U),B=_8(V,U),G=new Set;for(let M of J){let H=M2(M.path,U);if(G.has(H))continue;G.add(H);let z=B.some((w)=>M2(w.path,U)===H)?"modified":"added",_=[],D=Y.find((w)=>w.includes(M.path));if(D)_.push(N(X,D));let L={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:_,routeId:H,file:X,change:z,routeType:z8(U,M.path),methods:M.methods.length>0?M.methods:void 0};Z.push(L)}for(let M of B){let H=M2(M.path,U);if(G.has(H))continue;G.add(H);let O=[],z=W.find((D)=>D.includes(M.path));if(z)O.push(N(X,z));let _={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:O,routeId:H,file:X,change:"deleted",routeType:z8(U,M.path),methods:M.methods.length>0?M.methods:void 0};Z.push(_)}}return Z}}});function P3($){return I3.some((Z)=>Z.test($))}function y3($){return b3.test($)}function k3($){let Z=[];for(let{pattern:Q,description:X}of R8)if(Q.test($))Z.push({description:X});return Z}function S3($){let Z=[];for(let{pattern:Q,description:X}of C3)if(Q.test($))Z.push({description:X});return Z}function N8($,Z){let Q=[],X=[],K=!1,Y=!1;for(let W of $){let q=Z.diffs.find((G)=>G.path===W);if(!q)continue;let V=P(q),U=V.join(`
45
- `),J=k3(U);for(let{description:G}of J){K=!0,Q.push(`${G} detected in ${W}`);let M=V.find((H)=>R8.some((O)=>O.pattern.test(H)));if(M)X.push({file:W,excerpt:M.trim()})}let B=S3(U);for(let{description:G}of B)if(Y=!0,!K)Q.push(`${G} detected in ${W}`)}if(K)return{risk:"high",reasons:Q,evidence:X};if(Y)return{risk:"medium",reasons:Q.length>0?Q:["Schema changes detected"],evidence:X};return{risk:"low",reasons:["Migration files changed"],evidence:X}}var I3,b3,R8,C3,_2;var T8=x(()=>{I3=[/alembic\/versions\/.*\.py$/,/migrations\/versions\/.*\.py$/,/db\/versions\/.*\.py$/],b3=/\/migrations\/\d{4}_.*\.py$/,R8=[{pattern:/op\.drop_table\s*\(/i,description:"drop_table"},{pattern:/op\.drop_column\s*\(/i,description:"drop_column"},{pattern:/op\.drop_index\s*\(/i,description:"drop_index"},{pattern:/op\.drop_constraint\s*\(/i,description:"drop_constraint"},{pattern:/op\.execute\s*\(\s*["'].*DROP/i,description:"raw DROP SQL"},{pattern:/op\.execute\s*\(\s*["'].*TRUNCATE/i,description:"raw TRUNCATE SQL"},{pattern:/op\.execute\s*\(\s*["'].*DELETE\s+FROM\s+\w+\s*["']\s*\)/i,description:"raw DELETE without WHERE"},{pattern:/DeleteModel\s*\(/i,description:"Django DeleteModel"},{pattern:/RemoveField\s*\(/i,description:"Django RemoveField"},{pattern:/AlterField.*null\s*=\s*False/i,description:"Django make field non-nullable"},{pattern:/migrations\.RunSQL\s*\(.*DROP/i,description:"Django raw DROP SQL"},{pattern:/migrations\.RunSQL\s*\(.*TRUNCATE/i,description:"Django raw TRUNCATE SQL"}],C3=[{pattern:/op\.alter_column\s*\(/i,description:"alter_column"},{pattern:/op\.create_table\s*\(/i,description:"create_table"},{pattern:/op\.add_column\s*\(/i,description:"add_column"},{pattern:/op\.create_index\s*\(/i,description:"create_index"},{pattern:/op\.create_foreign_key\s*\(/i,description:"create_foreign_key"},{pattern:/op\.create_unique_constraint\s*\(/i,description:"create_unique_constraint"},{pattern:/CreateModel\s*\(/i,description:"Django CreateModel"},{pattern:/AddField\s*\(/i,description:"Django AddField"},{pattern:/AlterField\s*\(/i,description:"Django AlterField"},{pattern:/RenameField\s*\(/i,description:"Django RenameField"},{pattern:/RenameModel\s*\(/i,description:"Django RenameModel"},{pattern:/AddIndex\s*\(/i,description:"Django AddIndex"},{pattern:/AddConstraint\s*\(/i,description:"Django AddConstraint"}];_2={name:"python-migrations",analyze($){let Z=[],Q=[],X=[];for(let K of $.files)if(P3(K.path))Q.push(K.path);else if(y3(K.path))X.push(K.path);if(Q.length>0){let{risk:K,reasons:Y,evidence:W}=N8(Q,$),q=W.map((U)=>N(U.file,U.excerpt)),V={type:"python-migration",kind:"python-migration",category:"database",confidence:"high",evidence:q,tool:"alembic",files:Q,risk:K,reasons:Y};if(Z.push(V),K==="high"){let U={type:"risk-flag",kind:"risk-flag",category:"database",confidence:"high",evidence:q,risk:"high",evidenceText:`Destructive migration detected: ${Y.join(", ")}`};Z.push(U)}}if(X.length>0){let{risk:K,reasons:Y,evidence:W}=N8(X,$),q=W.map((U)=>N(U.file,U.excerpt)),V={type:"python-migration",kind:"python-migration",category:"database",confidence:"high",evidence:q,tool:"django",files:X,risk:K,reasons:Y};if(Z.push(V),K==="high"){let U={type:"risk-flag",kind:"risk-flag",category:"database",confidence:"high",evidence:q,risk:"high",evidenceText:`Destructive migration detected: ${Y.join(", ")}`};Z.push(U)}}return Z}}});function u3($){let Z=$.split("/").pop()??"";for(let{pattern:Q,configType:X,category:K}of v3)if(Q.test(Z))return{configType:X,category:K};return null}function h3($){let Z=[];for(let{pattern:Q,description:X}of F3)if(Q.test($))Z.push(X);for(let Q of m3)if($.includes(Q)){let X=`${Q} section modified`;if(!Z.some((K)=>K.includes(Q)))Z.push(X)}return Z}function g3($){let Z=[],Q=/^\s*\[([^\]]+)\]/gm,X;while((X=Q.exec($))!==null){let K=X[1].trim();if(!Z.includes(K))Z.push(K)}return Z}var v3,F3,m3,z2;var x8=x(()=>{v3=[{pattern:/^pyproject\.toml$/,configType:"pyproject",category:"build"},{pattern:/^setup\.cfg$/,configType:"setup",category:"build"},{pattern:/^setup\.py$/,configType:"setup",category:"build"},{pattern:/^MANIFEST\.in$/,configType:"manifest",category:"build"},{pattern:/^tox\.ini$/,configType:"tox",category:"testing"},{pattern:/^pytest\.ini$/,configType:"pytest",category:"testing"},{pattern:/^conftest\.py$/,configType:"pytest",category:"testing"},{pattern:/^\.coveragerc$/,configType:"coverage",category:"testing"},{pattern:/^\.noxfile\.py$/,configType:"nox",category:"testing"},{pattern:/^\.?mypy\.ini$/,configType:"mypy",category:"typing"},{pattern:/^pyrightconfig\.json$/,configType:"pyright",category:"typing"},{pattern:/^\.flake8$/,configType:"flake8",category:"linting"},{pattern:/^\.pylintrc$/,configType:"pylint",category:"linting"},{pattern:/^\.ruff\.toml$/,configType:"ruff",category:"linting"},{pattern:/^ruff\.toml$/,configType:"ruff",category:"linting"},{pattern:/^\.isort\.cfg$/,configType:"isort",category:"linting"},{pattern:/^\.bandit$/,configType:"bandit",category:"security"},{pattern:/^\.?black$/,configType:"black",category:"formatting"},{pattern:/^\.editorconfig$/,configType:"editorconfig",category:"formatting"},{pattern:/^\.pre-commit-config\.yaml$/,configType:"pre-commit",category:"hooks"},{pattern:/^\.python-version$/,configType:"python-version",category:"environment"},{pattern:/^runtime\.txt$/,configType:"runtime",category:"environment"}],F3=[{pattern:/python\s*=\s*["'][<>=!~]+\s*3\./i,description:"Python version constraint changed"},{pattern:/requires-python\s*=\s*["'][<>=!~]+/i,description:"requires-python changed"},{pattern:/\[tool\.poetry\.dependencies\]/i,description:"Poetry dependencies section changed"},{pattern:/\[project\.dependencies\]/i,description:"Project dependencies section changed"},{pattern:/\[build-system\]/i,description:"Build system configuration changed"},{pattern:/\[project\.scripts\]/i,description:"CLI scripts changed"},{pattern:/\[project\.entry-points\]/i,description:"Entry points changed"}],m3=["[project]","[tool.poetry]","[build-system]","[project.scripts]","[project.entry-points]","[project.optional-dependencies]"];z2={name:"python-config",analyze($){let Z=[];for(let Q of $.files){let X=u3(Q.path);if(!X)continue;let K=$.diffs.find((G)=>G.path===Q.path),Y=K?P(K):[],W=Y.join(`
46
- `),q=[];if(Y.length>0){let G=k(Y);if(G)q.push(N(Q.path,G))}let V=!1,U=[];if(X.configType==="pyproject")U=h3(W),V=U.length>0;let J=g3(W),B={type:"python-config",kind:"python-config",category:"config_env",confidence:"high",evidence:q,file:Q.path,status:Q.status,configType:X.configType,configCategory:X.category,isBreaking:V,affectedSections:J,breakingReasons:U};Z.push(B)}return Z}}});var P1=x(()=>{y5();i5();Q2();$8();i1();t1();Y2();W2();V2();G2();O8();A8();T8();x8();M5();n$();t$();N5();R5();T5();a0();w5();E5();Q0();h5();g5();c5();f5();p5();d5();r5();a5()});var L2;var w8=x(()=>{P1();L2={name:"auto",analyzers:[a,s,X1,J1,K1,Y1,q1,n,X2,i,t,e,W1,$1,U1,Z1]}});var E8;var I8=x(()=>{P1();t1();E8={name:"sveltekit",analyzers:[a,s,j5,A5,X1,J1,K1,Y1,q1,n,w1,i,t,e,W1,$1,U1,Z1]}});var b8;var C8=x(()=>{P1();t1();i1();b8={name:"react",analyzers:[a,s,i0,X1,J1,K1,Y1,q1,n,w1,x1,i,t,e,W1,$1,U1,Z1]}});var P8;var y8=x(()=>{P1();i1();P8={name:"stencil",analyzers:[a,s,$2,X1,J1,K1,Y1,q1,n,x1,i,t,e,W1,$1,U1,Z1]}});var k8;var S8=x(()=>{P1();Q2();t1();k8={name:"next",analyzers:[a,s,Z2,X1,J1,K1,Y1,q1,n,w1,i,t,e,W1,$1,U1,Z1]}});var v8;var F8=x(()=>{P1();V2();t1();i1();v8={name:"vue",analyzers:[a,s,U2,X1,J1,K1,Y1,q1,n,w1,x1,i,t,e,W1,$1,U1,Z1]}});var m8;var u8=x(()=>{P1();G2();t1();i1();m8={name:"astro",analyzers:[a,s,B2,X1,J1,K1,Y1,q1,n,w1,x1,i,t,e,W1,$1,U1,Z1]}});var h8;var g8=x(()=>{P1();W2();i1();Y2();h8={name:"library",analyzers:[a,s,q2,x1,Y1,K1,n,K2,i,t,e,$1,Z1]}});var l8;var c8=x(()=>{P1();l8={name:"python",analyzers:[a,s,O2,H2,_2,z2,X1,q1,n,i,t,e,W1,$1,U1,Z1]}});import{existsSync as _1}from"node:fs";import{join as z1}from"node:path";function l3($=process.cwd()){if(_1(z1($,"src","routes")))return!0;return!1}function c3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.["@sveltejs/kit"]||Q?.["@sveltejs/kit"])}function f3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.react&&Z?.["react-dom"]||Q?.react&&Q?.["react-dom"])}function p3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.["react-router"]||Z?.["react-router-dom"]||Q?.["react-router"]||Q?.["react-router-dom"])}function d3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.next||Q?.next)}function r3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.["@stencil/core"]||Q?.["@stencil/core"])}function a3($=process.cwd()){return _1(z1($,"stencil.config.ts"))||_1(z1($,"stencil.config.js"))}function s3($=process.cwd()){if(_1(z1($,"app")))return!0;if(_1(z1($,"src","app")))return!0;return!1}function o3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.vue||Q?.vue)}function n3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.nuxt||Q?.nuxt)}function i3($=process.cwd()){return _1(z1($,"pages"))||_1(z1($,"src","pages"))}function t3($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.astro||Q?.astro)}function e3($=process.cwd()){return _1(z1($,"astro.config.mjs"))||_1(z1($,"astro.config.ts"))||_1(z1($,"astro.config.js"))}function $7($){if(!$)return!1;if($.exports)return!0;if($.publishConfig)return!0;if($.private===!1)return!0;if($.bin)return!0;return!1}function Z7($=process.cwd()){return["pyproject.toml","setup.py","setup.cfg","requirements.txt","Pipfile","poetry.lock"].some((Q)=>_1(z1($,Q)))}function Q7($=process.cwd()){return["manage.py","app/main.py","src/main.py","app/__init__.py"].some((Q)=>_1(z1($,Q)))}function X7($){for(let Z of $.files){if(Z.path.includes("/migrations/")&&Z.path.endsWith(".py"))return"django";if(Z.path==="manage.py"||Z.path.includes("urls.py"))return"django";if(Z.path.includes("routers/")||Z.path.includes("endpoints/"))return"fastapi";if(Z.path.includes("alembic/versions/"))return"alembic"}return null}function b$($,Z=process.cwd()){let Q=[],X=l3(Z),K=c3($.headPackageJson);if(X||K){if(X)Q.push("Found src/routes/ directory (SvelteKit file-based routing)");if(K)Q.push("Found @sveltejs/kit in package.json dependencies");return{profile:"sveltekit",confidence:X&&K?"high":"high",reasons:Q}}let Y=r3($.headPackageJson),W=a3(Z);if(Y||W){if(Y)Q.push("Found @stencil/core in package.json dependencies");if(W)Q.push("Found stencil.config.ts or stencil.config.js");return{profile:"stencil",confidence:Y&&W?"high":"high",reasons:Q}}let q=d3($.headPackageJson),V=s3(Z);if(q&&V)return Q.push("Found next in package.json dependencies"),Q.push("Found app/ directory (Next.js App Router)"),{profile:"next",confidence:"high",reasons:Q};if(q)return Q.push("Found next in package.json dependencies"),{profile:"next",confidence:"medium",reasons:Q};let U=f3($.headPackageJson),J=p3($.headPackageJson);if(U&&J)return Q.push("Found react and react-dom in package.json dependencies"),Q.push("Found react-router or react-router-dom in package.json dependencies"),{profile:"react",confidence:"high",reasons:Q};let B=o3($.headPackageJson),G=n3($.headPackageJson),M=i3(Z);if(G||B&&M){if(G)Q.push("Found nuxt in package.json dependencies");if(B)Q.push("Found vue in package.json dependencies");if(M)Q.push("Found pages/ directory (Nuxt file-based routing)");return{profile:"vue",confidence:"high",reasons:Q}}if(B)return Q.push("Found vue in package.json dependencies"),{profile:"vue",confidence:"medium",reasons:Q};let H=t3($.headPackageJson),O=e3(Z);if(H||O){if(H)Q.push("Found astro in package.json dependencies");if(O)Q.push("Found astro.config.{mjs,ts,js}");return{profile:"astro",confidence:H&&O?"high":"medium",reasons:Q}}if($7($.headPackageJson)){if($.headPackageJson?.exports)Q.push("Found exports field in package.json");if($.headPackageJson?.publishConfig)Q.push("Found publishConfig in package.json");if($.headPackageJson?.bin)Q.push("Found bin field in package.json (CLI tool)");if($.headPackageJson?.private===!1)Q.push("Package marked as public (private: false)");return{profile:"library",confidence:"medium",reasons:Q}}let _=Z7(Z),D=Q7(Z),L=X7($);if(_||D||L){if(_)Q.push("Found Python project files (pyproject.toml, requirements.txt, etc.)");if(D)Q.push("Found Python web framework markers (manage.py, main.py, etc.)");if(L)Q.push(`Detected ${L} framework from changed files`);return{profile:"python",confidence:_&&(D||L)?"high":"medium",reasons:Q}}return Q.push("No framework-specific markers detected, using default analyzers"),{profile:"auto",confidence:"medium",reasons:Q}}function K7($,Z=process.cwd()){return b$($,Z).profile}function y1($){switch($){case"sveltekit":return E8;case"react":return b8;case"stencil":return P8;case"next":return k8;case"vue":return v8;case"astro":return m8;case"library":return h8;case"python":return l8;case"auto":return L2;default:return L2}}function e1($,Z,Q=process.cwd()){if($==="auto")return K7(Z,Q);return $}var C$=x(()=>{w8();I8();C8();y8();S8();F8();u8();g8();c8()});function P7($){let Z=$.find((Y)=>Y.type==="file-category");if(!Z)return{isLowRisk:!1,category:null};let{categories:Q}=Z;if(["product","infra","ci","dependencies"].some((Y)=>Q[Y].length>0))return{isLowRisk:!1,category:null};if(Q.docs.length>0&&Q.tests.length===0)return{isLowRisk:!0,category:"docs"};if(Q.tests.length>0&&Q.docs.length===0)return{isLowRisk:!0,category:"tests"};if(Q.config.length>0&&Q.docs.length===0&&Q.tests.length===0)return{isLowRisk:!0,category:"config"};if(Q.docs.length>0||Q.tests.length>0||Q.config.length>0)return{isLowRisk:!0,category:"docs/tests/config"};return{isLowRisk:!1,category:null}}function O$($){let Z=0,Q=[],X=[],{isLowRisk:K,category:Y}=P7($);if(K&&Y){let J={docs:-15,tests:-10,config:-5,"docs/tests/config":-10}[Y]??0;Z+=J,Q.push(`✅ Changes are only in ${Y} (lower risk)`),X.push({kind:"low-risk-category",weight:J,explanation:`Changes are only in ${Y} (lower risk)`,evidence:[]})}for(let U of $)switch(U.type){case"risk-flag":{let J=U.risk==="high"?40:U.risk==="medium"?20:5;Z+=J;let B=U.risk==="high"?"⚠️":U.risk==="medium"?"⚡":"ℹ️";Q.push(`${B} ${U.evidenceText}`),X.push({kind:`risk-${U.risk}`,weight:J,explanation:U.evidenceText,evidence:U.evidence})}break;case"db-migration":{let J=U.risk==="high"?30:U.risk==="medium"?15:0;if(J>0){Z+=J;let B=U.risk==="high"?`High-risk database migration: ${U.reasons.join(", ")}`:`Database migration detected: ${U.files.join(", ")}`;Q.push(U.risk==="high"?`⚠️ ${B}`:`⚡ ${B}`),X.push({kind:"db-migration",weight:J,explanation:B,evidence:U.evidence})}}break;case"route-change":if(U.change==="added")Z+=5,X.push({kind:"route-added",weight:5,explanation:`Route added: ${U.routeId}`,evidence:U.evidence});else if(U.change==="deleted")Z+=10,Q.push(`ℹ️ Route deleted: ${U.routeId}`),X.push({kind:"route-deleted",weight:10,explanation:`Route deleted: ${U.routeId}`,evidence:U.evidence});break;case"dependency-change":{let J=0;if(U.impact==="major")J=15;else if(U.impact==="minor")J=5;if(U.riskCategory&&U.impact==="new")J+=10;if(J>0)Z+=J,X.push({kind:`dependency-${U.impact}`,weight:J,explanation:`${U.name}: ${U.from??"new"} → ${U.to??"removed"}`,evidence:U.evidence})}break;case"env-var":if(U.change==="added")Z+=5,Q.push(`ℹ️ New env var: ${U.name}`),X.push({kind:"env-var-added",weight:5,explanation:`New env var: ${U.name}`,evidence:U.evidence});break;case"security-file":Z+=15,X.push({kind:"security-file",weight:15,explanation:`Security-sensitive files changed: ${U.files.length} file(s)`,evidence:U.evidence});break;case"convention-violation":{let J=U,B=J.files.length;if(B>5)Z+=10,Q.push(`⚡ ${B} source files lack test coverage`),X.push({kind:"test-coverage-gap",weight:10,explanation:`${B} source files lack test coverage`,evidence:J.evidence.slice(0,3)})}break;case"large-diff":{let J=U,B=J.linesChanged>1000?15:J.linesChanged>500?10:5;Z+=B,Q.push(`ℹ️ Large diff: ${J.filesChanged} files, ${J.linesChanged} lines`),X.push({kind:"large-diff",weight:B,explanation:`Large diff: ${J.filesChanged} files, ${J.linesChanged} lines`,evidence:J.evidence})}break}let W=[/\/types\.ts$/,/\/core\/.*\.ts$/,/\/index\.ts$/],q=$.find((U)=>U.type==="file-summary");if(q){let U=q.modified.filter((J)=>W.some((B)=>B.test(J)));if(U.length>0)Z+=10,Q.push(`⚡ Core module files modified: ${U.join(", ")}`),X.push({kind:"core-module-change",weight:10,explanation:`Core module files modified (types.ts, index.ts): ${U.length} file(s)`,evidence:[]})}Z=Math.max(0,Math.min(Z,100));let V;if(Z>=50)V="high";else if(Z>=20)V="medium";else V="low";return{score:Z,level:V,factors:X,evidenceBullets:Q}}function f7($){if($.includes("db-migration")||$.includes("database")||$.includes("sql"))return"database";if($.includes("dependency")||$.includes("deps"))return"dependencies";if($.includes("route"))return"routes";if($.includes("env-var")||$.includes("config"))return"config_env";if($.includes("security")||$.includes("infra")||$.includes("docker")||$.includes("k8s")||$.includes("terraform"))return"infra";if($.includes("cloudflare")||$.includes("wrangler")||$.includes("workers"))return"cloudflare";if($.includes("ci")||$.includes("workflow")||$.includes("pipeline"))return"ci";if($.includes("test")&&!$.includes("test-gap")&&!$.includes("test-coverage"))return"tests";if($.includes("test-gap")||$.includes("test-coverage")||$.includes("quality"))return"quality";if($.includes("api")||$.includes("contract"))return"api";if($.includes("core-module")||$.includes("impact")||$.includes("blast-radius")||$.includes("large-diff")||$.includes("churn"))return"impact";if($.includes("doc"))return"docs";return"unknown"}function d8($){let Z=$.excerpt.toLowerCase(),Q=0;if(/\d+/.test(Z))Q+=10;if(Z.includes("blast radius"))Q+=15;if(Z.includes("high"))Q+=5;if(Z.includes("critical"))Q+=8;if(Z.includes("breaking"))Q+=8;if(Z.includes("added")||Z.includes("removed")||Z.includes("modified"))Q+=3;if(Z==="imports module")Q-=10;if(Z.startsWith("depends on"))Q-=5;return Q}function K0($,Z){let Q=new Map;for(let K of $){if(K.kind==="file-summary"||K.kind==="file-category")continue;let Y=K.category;if(!Q.has(Y))Q.set(Y,{count:0,riskWeight:0,evidence:[]});let W=Q.get(Y);W.count+=1,W.evidence.push(...K.evidence)}for(let K of Z){let Y="unknown";for(let q of $)if(q.evidence.length>0&&K.evidence.length>0){let V=new Set(q.evidence.map((B)=>B.file)),U=new Set(K.evidence.map((B)=>B.file));if(Array.from(V).some((B)=>U.has(B))){Y=q.category;break}}if(Y==="unknown")Y=f7(K.kind);if(!Q.has(Y))Q.set(Y,{count:0,riskWeight:0,evidence:[]});let W=Q.get(Y);W.riskWeight+=K.weight,W.evidence.push(...K.evidence)}let X=Array.from(Q.entries()).filter(([K,Y])=>Y.count>0).map(([K,Y])=>{let W=[...Y.evidence].sort((U,J)=>{let B=d8(U),G=d8(J);if(G!==B)return G-B;return U.file.localeCompare(J.file)}),q=new Set,V=[];for(let U of W){if(!q.has(U.file))q.add(U.file),V.push(U);if(V.length>=3)break}return{id:K,count:Y.count,riskWeight:Y.riskWeight,topEvidence:V}});return X.sort((K,Y)=>{if(Y.riskWeight!==K.riskWeight)return Y.riskWeight-K.riskWeight;if(Y.count!==K.count)return Y.count-K.count;return K.id.localeCompare(Y.id)}),X}function Y0($){let Z={};for(let Q of $)Z[Q.id]=Q.count;return Z}function q0($,Z){let Q=[];if(Z==="sveltekit"){let U=$.some((J)=>J.type==="route-change");if(U||$.length>0){let J=[];if(U)J.push("Route files changed");if($.length>0&&!U)J.push("Source files changed");Q.push({id:"sveltekit-check",category:"types",blocking:!0,reason:"Run SvelteKit type checker to verify no type errors were introduced",triggers:J})}}let X=$.filter((U)=>U.type==="test-change"),K=X.length>0;if(K||$.length>0){let U=[];if(K){let J=X.reduce((B,G)=>B+G.files.length,0);U.push(`${J} test file(s) changed`)}if($.length>0&&!K)U.push("Source files changed without corresponding test changes");Q.push({id:"run-tests",category:"tests",blocking:!0,reason:"Run test suite to verify functionality and catch regressions",triggers:U})}let Y=$.filter((U)=>U.type==="db-migration");if(Y.length>0){let U=Y.some((M)=>M.risk==="high"),J=Y.flatMap((M)=>M.files),B=[...new Set(Y.flatMap((M)=>M.reasons))],G=[`${J.length} migration file(s) changed`,...B];if(U)G.push("DANGEROUS SQL DETECTED (DROP, TRUNCATE, or destructive operations)");if(Q.push({id:"apply-migrations",category:"database",blocking:U,reason:U?"Apply database migrations in a safe environment and verify data integrity before production":"Apply and test database migrations in development environment",triggers:G}),U)Q.push({id:"backup-db",category:"database",blocking:!0,reason:"Create database backup before applying destructive migrations",triggers:["High-risk SQL operations detected in migrations"]})}let W=$.filter((U)=>U.type==="cloudflare-change");if(W.length>0){let U=[...new Set(W.map((B)=>B.area))],J=W.flatMap((B)=>B.files);Q.push({id:"verify-cloudflare-config",category:"cloudflare",blocking:!1,reason:"Verify Cloudflare configuration and bindings match across environments",triggers:[`Cloudflare ${U.join(", ")} configuration changed`,`Files: ${J.join(", ")}`]})}let q=$.filter((U)=>U.type==="env-var");if(q.length>0){let U=q.map((G)=>G.name),J=q.filter((G)=>G.change==="added"),B=[];if(J.length>0)B.push(`New environment variable(s): ${J.map((G)=>G.name).join(", ")}`);if(q.length>J.length)B.push(`Modified environment variable(s): ${U.filter((G)=>!J.some((M)=>M.name===G)).join(", ")}`);Q.push({id:"update-env-docs",category:"environment",blocking:!1,reason:"Update .env.example and documentation with new or changed environment variables",triggers:B})}let V=$.filter((U)=>U.type==="dependency-change"&&U.impact==="major");if(V.length>0){let U=V.map((J)=>{let B=J.from||"new",G=J.to||"removed";return`${J.name} (${B} → ${G})`});Q.push({id:"review-dependencies",category:"dependencies",blocking:!1,reason:"Review major dependency changes for breaking changes and update migration guides if needed",triggers:[`Major version changes: ${U.join(", ")}`,"Check CHANGELOG and migration guides for breaking changes"]})}return Q.sort((U,J)=>{if(U.blocking!==J.blocking)return U.blocking?-1:1;return U.id.localeCompare(J.id)}),Q}function r8($){let Z=[],Q=0,X=(j,C)=>{Z.push({text:j,priority:C,order:Q++})},K=$.filter((j)=>j.type==="impact-analysis"),Y=K.filter((j)=>j.blastRadius==="high"),W=K.filter((j)=>j.blastRadius==="medium");if(Y.length>0)X(`${Y.length} file(s) with high blast radius`,F.HIGH_BLAST_RADIUS);if(W.length>0)X(`${W.length} file(s) with medium blast radius`,F.MEDIUM_BLAST_RADIUS);let q=$.filter((j)=>j.type==="typescript-config");if(q.length>0){let j=q.some((C)=>C.isBreaking);X(j?"TypeScript config changed (breaking)":"TypeScript config modified",j?F.BREAKING_CONFIG:F.NON_BREAKING_CONFIG)}let V=$.filter((j)=>j.type==="tailwind-config");if(V.length>0){let j=V.some((C)=>C.isBreaking);X(j?"Tailwind config changed (breaking)":"Tailwind config modified",j?F.BREAKING_CONFIG:F.NON_BREAKING_CONFIG)}let U=$.filter((j)=>j.type==="graphql-change");if(U.length>0){let j=U.some((C)=>C.isBreaking);X(j?"GraphQL schema changed (breaking)":"GraphQL schema modified",j?F.BREAKING_CONFIG:F.NON_BREAKING_CONFIG)}let J=$.filter((j)=>j.type==="package-exports");if(J.length>0){if(J.some((C)=>C.isBreaking))X("Package exports changed (breaking)",F.BREAKING_CONFIG);else if(J.filter((O1)=>O1.binChanges&&(O1.binChanges.added.length>0||O1.binChanges.removed.length>0)).length>0)X("Package bin/exports modified",F.NON_BREAKING_CONFIG)}let G=$.filter((j)=>j.type==="risk-flag").filter((j)=>j.risk==="high");if(G.length>0)X(`${G.length} high-risk condition(s) detected`,F.HIGH_RISK_FLAGS);let H=$.filter((j)=>j.type==="sql-risk").filter((j)=>j.riskType==="destructive");if(H.length>0)X(`Destructive SQL detected in ${H.length} file(s)`,F.DESTRUCTIVE_SQL);let O=$.filter((j)=>j.type==="db-migration");if(O.length>0){let j=O.some((C)=>C.risk==="high");X(j?"Database migrations (HIGH RISK)":"Database migrations",j?F.HIGH_RISK_DB_MIGRATION:F.DB_MIGRATION)}let z=$.filter((j)=>j.type==="ci-workflow");if(z.length>0)if(z.filter((C)=>C.riskType==="permissions_broadened"||C.riskType==="pull_request_target").length>0)X("CI workflow security changes detected",F.CI_SECURITY);else X(`${z.length} CI workflow(s) modified`,F.CI_WORKFLOW);if($.filter((j)=>j.type==="security-file").length>0)X("Security-sensitive files changed",F.SECURITY_FILES);let D=$.find((j)=>j.type==="lockfile-mismatch");if(D){if(D.manifestChanged&&!D.lockfileChanged)X("Lockfile mismatch: package.json changed but lockfile not updated",F.LOCKFILE_MISMATCH);else if(!D.manifestChanged&&D.lockfileChanged)X("Lockfile mismatch: lockfile changed but package.json not updated",F.LOCKFILE_MISMATCH)}let L=$.filter((j)=>j.type==="infra-change");if(L.length>0){let j=[...new Set(L.map((C)=>C.infraType))];X(`Infrastructure changes: ${j.join(", ")}`,F.INFRA_CHANGES)}let w=$.filter((j)=>j.type==="dependency-change"),T=w.filter((j)=>j.impact==="major");if(T.length>0)X(`${T.length} major dependency update(s)`,F.MAJOR_DEPS);let A=$.filter((j)=>j.type==="route-change");if(A.length>0)X(`${A.length} route(s) changed`,F.ROUTE_CHANGES);let b=$.filter((j)=>j.type==="api-contract-change");if(b.length>0)X(`${b.length} API contract(s) modified`,F.API_CONTRACTS);let R=$.filter((j)=>j.type==="cloudflare-change");if(R.length>0){let j=[...new Set(R.map((C)=>C.area))];X(`Cloudflare ${j.join("/")} configuration changed`,F.CLOUDFLARE)}let h=$.filter((j)=>j.type==="stencil-component-change"||j.type==="stencil-prop-change"||j.type==="stencil-event-change"||j.type==="stencil-method-change"||j.type==="stencil-slot-change");if(h.length>0){let j=new Set(h.map((C)=>C.tag));X(`${j.size} Stencil component(s) with API changes`,F.STENCIL_API)}let y=$.filter((j)=>j.type==="monorepo-config");if(y.length>0){let j=[...new Set(y.map((C)=>C.tool))];X(`Monorepo config changed: ${j.join(", ")}`,F.MONOREPO_CONFIG)}let r1=$.filter((j)=>j.type==="env-var");if(r1.length>0){let j=r1.filter((C)=>C.change==="added");X(j.length>0?`${j.length} new environment variable(s)`:`${r1.length} environment variable(s) touched`,F.ENV_VARS)}let a1=w.filter((j)=>j.impact==="new");if(a1.length>0)X(`${a1.length} new dependency(ies) added`,F.NEW_DEPS);let K$=$.filter((j)=>j.type==="test-change");if(K$.length>0){let j=K$.flatMap((C)=>C.files);X(`${j.length} test file(s) modified`,F.TEST_CHANGES)}let Y$=$.filter((j)=>j.type==="convention-violation");if(Y$.length>0){let j=Y$.reduce((C,O1)=>C+O1.files.length,0);X(`${j} source file(s) missing corresponding tests`,F.CONVENTION_VIOLATIONS)}let r=$.filter((j)=>j.type==="test-gap");if(r.length>0){let j=r.reduce((C,O1)=>C+O1.prodFilesChanged,0);X(`${j} modified file(s) lack test coverage`,F.TEST_GAPS)}if(Z.length===0&&$.length>0){let j=$.find((C)=>C.type==="file-summary");if(j){let C=j.added.length+j.modified.length+j.deleted.length+j.renamed.length;if(C>0)X(`${C} ${j.category} file(s) changed`,F.FALLBACK)}if(Z.length===0&&K.length>0){let C=K.reduce((O1,I0)=>O1+I0.affectedFiles.length,0);X(`${K.length} file(s) analyzed, ${C} dependent file(s)`,F.FALLBACK)}if(Z.length===0)X(`${$.length} finding(s) detected`,F.FALLBACK)}return Z.sort((j,C)=>{if(C.priority!==j.priority)return C.priority-j.priority;return j.order-C.order}),Z.map((j)=>j.text)}var F;var a8=x(()=>{F={HIGH_BLAST_RADIUS:100,MEDIUM_BLAST_RADIUS:95,BREAKING_CONFIG:90,HIGH_RISK_FLAGS:85,DESTRUCTIVE_SQL:85,HIGH_RISK_DB_MIGRATION:85,CI_SECURITY:85,SECURITY_FILES:85,LOCKFILE_MISMATCH:80,INFRA_CHANGES:70,MAJOR_DEPS:70,ROUTE_CHANGES:70,API_CONTRACTS:70,CLOUDFLARE:70,STENCIL_API:60,MONOREPO_CONFIG:60,ENV_VARS:60,NEW_DEPS:60,NON_BREAKING_CONFIG:60,DB_MIGRATION:55,CI_WORKFLOW:55,TEST_CHANGES:50,TEST_GAPS:50,CONVENTION_VIOLATIONS:50,FALLBACK:10}});function s8($){return $.replace(/\\/g,"/").toLowerCase()}function W0($,Z){let Q=s8($),X=s8(Z);return Q.localeCompare(X)}function o8($){return[...$].sort((Z,Q)=>{let X=Z.category.localeCompare(Q.category);if(X!==0)return X;let K=Q.effectiveScore-Z.effectiveScore;if(K!==0)return K;let Y=Z.ruleKey.localeCompare(Q.ruleKey);if(Y!==0)return Y;return Z.flagId.localeCompare(Q.flagId)})}function n8($){return[...$].sort((Z,Q)=>{let X=Z.type.localeCompare(Q.type);if(X!==0)return X;let K=(J)=>{if(J.evidence&&J.evidence.length>0)return J.evidence[0].file;return""},Y=K(Z),W=K(Q);if(Y&&W){let J=W0(Y,W);if(J!==0)return J}let q=(J)=>{if(J.evidence&&J.evidence.length>0){let B=J.evidence[0];if(B.line!==void 0)return B.line;if(B.hunk?.newStart!==void 0)return B.hunk.newStart}return 0},V=q(Z),U=q(Q);return V-U})}function N2($){return[...$].sort((Z,Q)=>{let X=W0(Z.file,Q.file);if(X!==0)return X;let K=Z.line??(Z.hunk?.newStart??0),Y=Q.line??(Q.hunk?.newStart??0);return K-Y})}function R2($){return[...$].sort((Z,Q)=>{let X=W0(Z.file,Q.file);if(X!==0)return X;if(Z.hunk&&Q.hunk){let K=(Y)=>{let W=Y.match(/\+(\d+)/);return W?parseInt(W[1],10):0};return K(Z.hunk)-K(Q.hunk)}return 0})}function $U($){return[...$].sort(W0)}function ZU($){let Z=[...$].sort((X,K)=>X[0].localeCompare(K[0])),Q={};for(let[X,K]of Z)Q[X]=K;return Q}import{createHash as p7}from"node:crypto";function m($){return $.replace(/\\/g,"/")}function i8($){return p7("sha256").update($).digest("hex").slice(0,12)}function u($){return[...$].sort()}function d7($){let Z;switch($.type){case"env-var":{let X=u($.evidenceFiles.map(m));Z=`env-var:${$.name}:${X.join(",")}`;break}case"dependency-change":{Z=`dependency-change:${$.name}:${$.from||"null"}:${$.to||"null"}:${$.section}`;break}case"route-change":{Z=`route-change:${m($.routeId)}:${$.change}:${$.routeType}`;break}case"db-migration":{let X=u($.files.map(m));Z=`db-migration:${$.tool}:${X.join(",")}`;break}case"cloudflare-change":{let X=u($.files.map(m));Z=`cloudflare-change:${$.area}:${X.join(",")}`;break}case"test-change":{let X=u($.files.map(m));Z=`test-change:${$.framework}:${X.join(",")}`;break}case"security-file":{let X=u($.files.map(m)),K=u($.reasons);Z=`security-file:${X.join(",")}:${K.join(",")}`;break}case"file-category":{Z=`file-category:${Object.entries($.categories).map(([K,Y])=>`${K}:${u(Y.map(m)).join(",")}`).sort().join("|")}`;break}case"file-summary":{let X=u($.added.map(m)).join(","),K=u($.modified.map(m)).join(","),Y=u($.deleted.map(m)).join(","),W=u($.renamed.map((q)=>`${m(q.from)}->${m(q.to)}`)).join(",");Z=`file-summary:${$.category}:a=${X}:m=${K}:d=${Y}:r=${W}`;break}case"convention-violation":{let X=u($.files.map(m));Z=`convention-violation:${$.message}:${X.join(",")}`;break}case"test-parity-violation":{let X=m($.sourceFile),K=u($.expectedTestLocations.map(m));Z=`test-parity-violation:${X}:${K.join(",")}`;break}case"impact-analysis":{let X=m($.sourceFile),K=u($.affectedFiles.map(m));Z=`impact-analysis:${X}:${K.join(",")}`;break}case"ci-workflow":{Z=`ci-workflow:${m($.file)}:${$.riskType}`;break}case"sql-risk":{Z=`sql-risk:${m($.file)}:${$.riskType}`;break}case"infra-change":{let X=u($.files.map(m));Z=`infra-change:${$.infraType}:${X.join(",")}`;break}case"api-contract-change":{Z=`api-contract-change:${u($.files.map(m)).join(",")}`;break}case"large-diff":{Z=`large-diff:${$.filesChanged}:${$.linesChanged}`;break}case"lockfile-mismatch":{Z=`lockfile-mismatch:${$.manifestChanged}:${$.lockfileChanged}`;break}case"test-gap":{Z=`test-gap:${$.prodFilesChanged}:${$.testFilesChanged}`;break}case"stencil-component-change":{let X=m($.file);Z=`stencil-component-change:${$.tag}:${$.change}:${X}:${$.fromTag||""}:${$.toTag||""}`;break}case"stencil-prop-change":{let X=m($.file);Z=`stencil-prop-change:${$.tag}:${$.propName}:${$.change}:${X}`;break}case"stencil-event-change":{let X=m($.file);Z=`stencil-event-change:${$.tag}:${$.eventName}:${$.change}:${X}`;break}case"stencil-method-change":{let X=m($.file);Z=`stencil-method-change:${$.tag}:${$.methodName}:${$.change}:${X}`;break}case"stencil-slot-change":{let X=m($.file);Z=`stencil-slot-change:${$.tag}:${$.slotName}:${$.change}:${X}`;break}case"risk-flag":{Z=`risk-flag:${$.risk}:${$.evidenceText}`;break}case"graphql-change":{let X=m($.file),K=u($.breakingChanges).join(","),Y=u($.addedElements).join(",");Z=`graphql-change:${X}:${$.isBreaking}:${K}:${Y}`;break}case"typescript-config":{let X=m($.file),K=u($.changedOptions.added).join(","),Y=u($.changedOptions.removed).join(","),W=u($.changedOptions.modified).join(",");Z=`typescript-config:${X}:${$.isBreaking}:a=${K}:r=${Y}:m=${W}`;break}case"tailwind-config":{let X=m($.file),K=u($.affectedSections).join(",");Z=`tailwind-config:${X}:${$.configType}:${$.isBreaking}:${K}`;break}case"monorepo-config":{let X=m($.file),K=u($.affectedFields).join(",");Z=`monorepo-config:${X}:${$.tool}:${K}`;break}case"package-exports":{let X=u($.addedExports).join(","),K=u($.removedExports).join(",");Z=`package-exports:${$.isBreaking}:a=${X}:r=${K}`;break}case"python-migration":{let X=u($.files.map(m));Z=`python-migration:${$.tool}:${$.risk}:${X.join(",")}`;break}case"python-config":{let X=m($.file),K=u($.affectedSections).join(",");Z=`python-config:${X}:${$.configType}:${$.isBreaking}:${K}`;break}default:throw Error(`Unknown finding type: ${$.type}`)}let Q=i8(Z);return`finding.${$.type}#${Q}`}function g($,Z){let Q=u(Z),X=`${$}:${Q.join(",")}`,K=i8(X);return`flag.${$}#${K}`}function $$($){let Z=d7($);return{...$,findingId:Z}}var P$=()=>{};function r7($,Z){let Q=0,X=0;for(let K of $.diffs)for(let Y of K.hunks)Q+=Y.additions.length,X+=Y.deletions.length;return{filesChanged:$.files.length,insertions:Q,deletions:X,skippedFilesCount:Z.length}}function s7($){return a7.has($.type)}function o7($){let Z=$.find((B)=>B.type==="file-summary"),Q=$.find((B)=>B.type==="file-category"),X=$.find((B)=>B.type==="large-diff"),K=$.find((B)=>B.type==="lockfile-mismatch"),Y={added:Z?.added??[],modified:Z?.modified??[],deleted:Z?.deleted??[],renamed:Z?.renamed??[]},W={product:[],tests:[],ci:[],infra:[],database:[],docs:[],dependencies:[],config:[],artifacts:[],other:[]},q=Q?.categories??W,V=Q?.summary??[],U=[];if(X)U.push({type:"large-diff",filesChanged:X.filesChanged,linesChanged:X.linesChanged});if(K)U.push({type:"lockfile-mismatch",manifestChanged:K.manifestChanged,lockfileChanged:K.lockfileChanged});let J=Z?.changeDescriptions;return{files:Y,byCategory:q,categorySummary:V,changeDescriptions:J,warnings:U}}async function M$($){let{changeSet:Z,findings:Q,riskScore:X,requestedProfile:K,detectedProfile:Y,profileConfidence:W,profileReasons:q,filters:V,skippedFiles:U,warnings:J,noTimestamp:B,repoRoot:G,isDirty:M,mode:H}=$,O=n8(Q);if(O=O.map($$),V?.maxFindings&&O.length>V.maxFindings)O=O.slice(0,V.maxFindings);if(V?.redact)O=O.map((r)=>({...r,evidence:N2(r.evidence.map(_5))}));else O=O.map((r)=>({...r,evidence:N2(r.evidence)}));let z,_;if(G!==void 0&&M!==void 0)z=G,_=M;else if(G!==void 0)z=G,_=await J$();else if(M!==void 0)z=await V$(),_=M;else[z,_]=await Promise.all([V$(),J$()]);let D={base:Z.base,head:Z.head,range:`${Z.base}..${Z.head}`,repoRoot:z,isDirty:_,mode:H},L={requested:K,detected:Y,confidence:W,reasons:q},w=U??[],T=r7(Z,w),A={defaultExcludes:O5,excludes:V?.excludes??[],includes:V?.includes??[],redact:V?.redact??!1,maxFileBytes:V?.maxFileBytes??1048576,maxDiffBytes:V?.maxDiffBytes??5242880,maxFindings:V?.maxFindings},b=o7(O),R=O.filter((r)=>!s7(r)),h=K0(R,X.factors),y=Y0(h),r1=r8(R),a1={byArea:y,highlights:r1},K$=q0(O,Y),Y$=J??[];return{schemaVersion:"2.1",generatedAt:B?void 0:new Date().toISOString(),git:D,profile:L,stats:T,filters:A,summary:a1,categories:h,changeset:b,risk:X,findings:R,actions:K$,skippedFiles:w,warnings:Y$}}var a7;var U0=x(()=>{a8();s$();B$();P$();a7=new Set(["file-summary","file-category","large-diff","lockfile-mismatch"])});import{readFile as n7}from"node:fs/promises";async function V0($){let Z=await n7($,"utf-8");return JSON.parse(Z)}function t8($){let Z={...$};return delete Z.generatedAt,Z}function i7($,Z){let Q=(X)=>{if(X===null||typeof X!=="object")return X;if(Array.isArray(X))return X.map(Q);let K={};return Object.keys(X).sort().forEach((Y)=>{K[Y]=Q(X[Y])}),K};return JSON.stringify(Q($))===JSON.stringify(Q(Z))}function e8($){let Z=new Map;for(let Q of $){let X=Q.findingId||Q.flagId;if(X)Z.set(X,Q)}return Z}function J0($){let Z=e8($.beforeItems),Q=e8($.afterItems),X=[],K=[],Y=[];for(let[W,q]of Q){let V=Z.get(W);if(!V)X.push(W);else{let U=t8(V),J=t8(q);if(!i7(U,J))Y.push({id:W,before:V,after:q})}}for(let W of Z.keys())if(!Q.has(W))K.push(W);return X.sort(),K.sort(),Y.sort((W,q)=>W.id.localeCompare(q.id)),{added:X,removed:K,changed:Y}}function B0($,Z){let Q=[];if($.mode!==Z.mode)Q.push({code:"scope-mismatch",message:`Previous run used mode=${$.mode}, current is mode=${Z.mode}`});if($.base!==Z.base)Q.push({code:"scope-mismatch",message:`Previous run used base=${$.base}, current is base=${Z.base}`});if($.head!==Z.head)Q.push({code:"scope-mismatch",message:`Previous run used head=${$.head}, current is head=${Z.head}`});if($.profile!==Z.profile)Q.push({code:"scope-mismatch",message:`Previous run used profile=${$.profile}, current is profile=${Z.profile}`});let X=JSON.stringify($.include||[]),K=JSON.stringify(Z.include||[]);if(X!==K)Q.push({code:"scope-mismatch",message:"Include filters differ between runs"});let Y=JSON.stringify($.exclude||[]),W=JSON.stringify(Z.exclude||[]);if(Y!==W)Q.push({code:"scope-mismatch",message:"Exclude filters differ between runs"});if($.only!==void 0||Z.only!==void 0){let q=JSON.stringify($.only||null),V=JSON.stringify(Z.only||null);if(q!==V)Q.push({code:"scope-mismatch",message:"Category filters differ between runs"})}return Q}function $9($){let Z;if($.git.mode)Z=$.git.mode;else Z=$.git.base?"branch":"unstaged";return{mode:Z,base:$.git.base||null,head:$.git.head||null,profile:$.profile.detected,include:$.filters.includes,exclude:$.filters.excludes}}function Z9($){let Z;if($.range.mode)Z=$.range.mode;else Z=$.range.base?"branch":"unstaged";return{mode:Z,base:$.range.base||null,head:$.range.head||null,only:$.filters?.only||null,exclude:$.filters?.exclude}}var T2=()=>{};var Q9={};A1(Q9,{computeFactsDelta:()=>x2});async function x2($){let{sincePath:Z,currentFacts:Q,mode:X,base:K,head:Y,profile:W,include:q,exclude:V,sinceStrict:U}=$,J;try{J=await V0(Z)}catch(L){let w=L instanceof Error?L.message:String(L);throw new v(`Failed to load previous facts from ${Z}: ${w}`,1)}if(!J.schemaVersion||!J.findings)throw new v(`File ${Z} does not appear to be a valid facts output`,1);let B={mode:X,base:K,head:Y,profile:W,include:q,exclude:V},G=$9(J),M=B0(G,B);if(U&&M.length>0)throw new v(`Scope mismatch detected (--since-strict): ${M.map((L)=>L.message).join("; ")}`,1);let{added:H,removed:O,changed:z}=J0({beforeItems:J.findings,afterItems:Q.findings}),_=z.map((L)=>({findingId:L.id,before:L.before,after:L.after})),D=["--mode",X];if(K)D.push("--base",K);if(Y)D.push("--head",Y);if(D.push("--since",Z),U)D.push("--since-strict");return{schemaVersion:"1.0",generatedAt:new Date().toISOString(),command:{name:"facts",args:D},since:{path:Z,schemaVersion:J.schemaVersion},current:{schemaVersion:Q.schemaVersion},scope:B,warnings:M,delta:{added:H,removed:O,changed:_},summary:{addedCount:H.length,removedCount:O.length,changedCount:_.length}}}var w2=x(()=>{T2();H1()});var X9={};A1(X9,{executeFacts:()=>t7,deriveActions:()=>q0,computeFactsDelta:()=>x2,buildSummaryByArea:()=>Y0,buildFacts:()=>M$,aggregateCategories:()=>K0});async function t7($){return M$($)}var K9=x(()=>{U0();U0();w2()});var q9={};A1(q9,{renderSarif:()=>ZQ,SARIF_RULES:()=>Y9});function $Q($){return"file:///"+$.replace(/\\/g,"/")+"/"}function ZQ($,Z){let Q=XQ($.findings,Z),X=new Set(Q.map((Y)=>Y.ruleId)),K=Array.from(X).sort().map((Y)=>{let W=Y9[Y];if(!W)throw Error(`Unknown SARIF rule ID: ${Y}`);return QQ(W)});return{version:"2.1.0",$schema:"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",runs:[{tool:{driver:{name:"branch-narrator",version:o2(),informationUri:"https://github.com/better-vibe/branch-narrator",rules:K}},results:Q,originalUriBaseIds:{SRCROOT:{uri:$Q($.git.repoRoot)}}}]}}function QQ($){return{id:$.id,name:$.name,shortDescription:{text:$.shortDescription},fullDescription:{text:$.fullDescription},defaultConfiguration:{level:$.defaultLevel},properties:{category:$.category}}}function XQ($,Z){let Q=[],X=[...$].sort((K,Y)=>{if(K.type!==Y.type)return K.type.localeCompare(Y.type);return(K.findingId||"").localeCompare(Y.findingId||"")});for(let K of X){let Y=KQ(K,Z);if(Y)Q.push(Y)}return Q}function KQ($,Z){switch($.type){case"db-migration":return YQ($);case"dependency-change":return qQ($);case"env-var":return WQ($,Z);case"cloudflare-change":return UQ($);case"route-change":return VQ($);case"ci-workflow":return JQ($);case"security-file":return BQ($);case"graphql-change":return GQ($);case"package-exports":return OQ($);case"stencil-component-change":return MQ($);case"stencil-prop-change":return HQ($);case"stencil-event-change":return _Q($);case"stencil-method-change":return zQ($);case"stencil-slot-change":return LQ($);case"typescript-config":return jQ($);case"sql-risk":return DQ($);case"infra-change":return AQ($);case"test-gap":return NQ($);case"large-diff":return RQ($);default:return null}}function YQ($){let Z=$.risk==="high"?"BNR001":"BNR002",Q=$.risk==="high"?"error":"warning",X=$.evidence.map((W)=>({physicalLocation:{artifactLocation:{uri:W.file,uriBaseId:"SRCROOT"},region:W.line?{startLine:W.line}:void 0}})),K=$.reasons.join(", "),Y=$.risk==="high"?`Dangerous SQL migration detected: ${K}`:`Database migration changed: ${K}`;return{ruleId:Z,level:Q,message:{text:Y},locations:X,partialFingerprints:{findingId:$.findingId||""},properties:{tool:$.tool,files:$.files,risk:$.risk}}}function qQ($){if($.impact!=="major"||!e7.includes($.name))return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR003",level:"warning",message:{text:`Major version bump: ${$.name} ${$.from||"?"} → ${$.to||"?"}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{dependency:$.name,from:$.from,to:$.to,section:$.section}}}function WQ($,Z){let Q=[];for(let X of $.evidence){let K=X.line;if(K==null&&X.excerpt){let Y=Z.diffs.find((W)=>W.path===X.file);if(Y){let q=r0(Y).find((V)=>V.line.includes(X.excerpt));if(q)K=q.lineNumber}}Q.push({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:K!=null?{startLine:K}:void 0}})}return{ruleId:"BNR004",level:"warning",message:{text:`New environment variable referenced: ${$.name}`},locations:Q,partialFingerprints:{findingId:$.findingId||""},properties:{envVar:$.name,change:$.change,evidenceFiles:$.evidenceFiles}}}function UQ($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR005",level:"note",message:{text:`Cloudflare configuration changed in ${$.files.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{area:$.area,files:$.files}}}function VQ($){let Z=$.evidence.map((K)=>({physicalLocation:{artifactLocation:{uri:K.file,uriBaseId:"SRCROOT"},region:K.line?{startLine:K.line}:void 0}})),Q=$.methods?` (${$.methods.join(", ")})`:"";return{ruleId:"BNR006",level:"note",message:{text:`API endpoint ${$.change==="added"?"added":$.change==="deleted"?"deleted":"modified"}: ${$.routeId}${Q}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{routeId:$.routeId,file:$.file,change:$.change,routeType:$.routeType,methods:$.methods}}}function JQ($){if($.riskType!=="permissions_broadened"&&$.riskType!=="pull_request_target")return null;let Z=$.riskType==="permissions_broadened"?"BNR007":"BNR008",Q=$.evidence.map((K)=>({physicalLocation:{artifactLocation:{uri:K.file,uriBaseId:"SRCROOT"},region:K.line?{startLine:K.line}:void 0}})),X=$.riskType==="permissions_broadened"?`CI workflow permissions broadened in ${$.file}: ${$.details}`:`CI workflow uses pull_request_target in ${$.file}: ${$.details}`;return{ruleId:Z,level:"error",message:{text:X},locations:Q,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,riskType:$.riskType,details:$.details}}}function BQ($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR009",level:"warning",message:{text:`Security-sensitive files changed: ${$.files.join(", ")}. Reasons: ${$.reasons.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{files:$.files,reasons:$.reasons}}}function GQ($){if(!$.isBreaking)return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR010",level:"error",message:{text:`Breaking GraphQL schema changes in ${$.file}: ${$.breakingChanges.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,breakingChanges:$.breakingChanges,addedElements:$.addedElements}}}function OQ($){if(!$.isBreaking)return null;let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}})),Q=[];if($.removedExports.length>0)Q.push(`removed exports: ${$.removedExports.join(", ")}`);if($.binChanges.removed.length>0)Q.push(`removed bins: ${$.binChanges.removed.join(", ")}`);return{ruleId:"BNR011",level:"error",message:{text:`Breaking package exports changes: ${Q.join("; ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{removedExports:$.removedExports,addedExports:$.addedExports,binChanges:$.binChanges}}}function MQ($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil component removed: <${$.tag}>`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,change:$.change,file:$.file}}}function HQ($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil prop removed: <${$.tag}> @Prop() ${$.propName}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,propName:$.propName,change:$.change,file:$.file}}}function _Q($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil event removed: <${$.tag}> @Event() ${$.eventName}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,eventName:$.eventName,change:$.change,file:$.file}}}function zQ($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil method removed: <${$.tag}> @Method() ${$.methodName}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,methodName:$.methodName,change:$.change,file:$.file}}}function LQ($){if($.change!=="removed")return null;let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil ${$.slotName==="default"?"default slot":`slot "${$.slotName}"`} removed from <${$.tag}>`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,slotName:$.slotName,change:$.change,file:$.file}}}function jQ($){if(!$.isBreaking)return null;let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}})),Q=[];if($.strictnessChanges.length>0)Q.push($.strictnessChanges.join(", "));if($.changedOptions.removed.length>0)Q.push(`removed: ${$.changedOptions.removed.join(", ")}`);return{ruleId:"BNR013",level:"warning",message:{text:`Breaking TypeScript config changes in ${$.file}: ${Q.join("; ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,changedOptions:$.changedOptions,strictnessChanges:$.strictnessChanges}}}function DQ($){if($.riskType!=="destructive")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR014",level:"error",message:{text:`Destructive SQL operation in ${$.file}: ${$.details}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,riskType:$.riskType,details:$.details}}}function AQ($){let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}}));return{ruleId:"BNR015",level:"warning",message:{text:`${{dockerfile:"Dockerfile",terraform:"Terraform",k8s:"Kubernetes"}[$.infraType]} configuration changed: ${$.files.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{infraType:$.infraType,files:$.files}}}function NQ($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR016",level:"note",message:{text:`Test coverage gap: ${$.prodFilesChanged} production files changed, ${$.testFilesChanged} test files changed`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{prodFilesChanged:$.prodFilesChanged,testFilesChanged:$.testFilesChanged}}}function RQ($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR017",level:"note",message:{text:`Large diff detected: ${$.filesChanged} files changed, ${$.linesChanged} lines modified`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{filesChanged:$.filesChanged,linesChanged:$.linesChanged}}}var Y9,e7;var W9=x(()=>{l$();Y9={BNR001:{id:"BNR001",name:"DangerousSqlInMigration",shortDescription:"Dangerous SQL detected in migration",fullDescription:"Database migration contains potentially destructive SQL operations (DROP, TRUNCATE, ALTER TYPE, etc.) that could cause data loss or service disruption.",defaultLevel:"error",category:"database"},BNR002:{id:"BNR002",name:"MigrationChanged",shortDescription:"Migration changed (non-destructive)",fullDescription:"Database migration file has been modified or added. Review schema changes for compatibility and rollback safety.",defaultLevel:"warning",category:"database"},BNR003:{id:"BNR003",name:"MajorDependencyBump",shortDescription:"Major bump in critical dependencies",fullDescription:"Major version bump detected in critical framework dependencies (e.g., @sveltejs/kit, svelte, vite, react, next). Major upgrades may introduce breaking changes.",defaultLevel:"warning",category:"dependencies"},BNR004:{id:"BNR004",name:"NewEnvVarReference",shortDescription:"New environment variable reference detected",fullDescription:"Code references a new environment variable. Ensure this variable is documented and configured in all deployment environments.",defaultLevel:"warning",category:"config_env"},BNR005:{id:"BNR005",name:"CloudflareConfigChanged",shortDescription:"Cloudflare configuration changed",fullDescription:"Cloudflare configuration files (wrangler.toml, Pages workflows) have been modified. Review deployment settings and worker configurations.",defaultLevel:"note",category:"infra"},BNR006:{id:"BNR006",name:"EndpointChanged",shortDescription:"API endpoint changed",fullDescription:"API endpoint file has been added, modified, or deleted. Verify API contract compatibility and update client code if needed.",defaultLevel:"note",category:"api"},BNR007:{id:"BNR007",name:"CIWorkflowPermissionsBroadened",shortDescription:"CI workflow permissions broadened",fullDescription:"GitHub Actions workflow has broadened permissions, which could allow unauthorized access to secrets or repository data. Review the permission changes carefully.",defaultLevel:"error",category:"security"},BNR008:{id:"BNR008",name:"CIWorkflowPullRequestTarget",shortDescription:"CI workflow uses pull_request_target",fullDescription:"GitHub Actions workflow uses pull_request_target trigger, which runs with write permissions on the base repository. This can be exploited if the workflow checks out or runs code from the PR.",defaultLevel:"error",category:"security"},BNR009:{id:"BNR009",name:"SecurityFileChanged",shortDescription:"Security-sensitive file changed",fullDescription:"A file related to authentication, authorization, or security configuration has been modified. Review these changes carefully for potential vulnerabilities.",defaultLevel:"warning",category:"security"},BNR010:{id:"BNR010",name:"GraphQLBreakingChange",shortDescription:"Breaking change in GraphQL schema",fullDescription:"GraphQL schema contains breaking changes such as removed types, fields, or arguments. This may break existing clients consuming the API.",defaultLevel:"error",category:"api"},BNR011:{id:"BNR011",name:"PackageExportsBreakingChange",shortDescription:"Breaking change in package exports",fullDescription:"Package exports have breaking changes such as removed exports or modified bin entries. This may break downstream consumers of this package.",defaultLevel:"error",category:"api"},BNR012:{id:"BNR012",name:"StencilAPIBreakingChange",shortDescription:"Breaking change in Stencil component API",fullDescription:"Stencil web component has breaking API changes such as removed props, events, methods, or slots. This may break consumers of the component library.",defaultLevel:"warning",category:"api"},BNR013:{id:"BNR013",name:"TypeScriptConfigBreaking",shortDescription:"Breaking TypeScript configuration change",fullDescription:"TypeScript configuration has breaking changes that may cause compilation errors in the codebase, such as stricter type checking options.",defaultLevel:"warning",category:"config_env"},BNR014:{id:"BNR014",name:"DestructiveSQL",shortDescription:"Destructive SQL operation detected",fullDescription:"SQL file contains destructive operations (DROP, TRUNCATE, DELETE without WHERE) that could cause data loss. Review carefully before execution.",defaultLevel:"error",category:"database"},BNR015:{id:"BNR015",name:"InfrastructureChanged",shortDescription:"Infrastructure configuration changed",fullDescription:"Infrastructure files (Dockerfile, Terraform, Kubernetes) have been modified. Review for security implications and deployment impact.",defaultLevel:"warning",category:"infra"},BNR016:{id:"BNR016",name:"TestGapDetected",shortDescription:"Test coverage gap detected",fullDescription:"Production code was modified but no corresponding test files were changed. Consider adding tests to cover the new or modified functionality.",defaultLevel:"note",category:"quality"},BNR017:{id:"BNR017",name:"LargeDiff",shortDescription:"Large diff detected",fullDescription:"This change has a large number of modified files or lines, which may indicate a refactoring or generated code. Consider breaking into smaller PRs for easier review.",defaultLevel:"note",category:"quality"}},e7=["@sveltejs/kit","svelte","vite","react","react-dom","next","@stencil/core"]});function E2($){if($==="pnpm-lock.yaml"||$==="package-lock.json"||$==="yarn.lock"||$==="bun.lockb")return{skip:!0,reason:"lockfile"};if($.endsWith(".d.ts"))return{skip:!0,reason:"generated file"};if($.endsWith(".log"))return{skip:!0,reason:"log file"};let Z=["dist/","build/","coverage/",".turbo/",".next/","out/",".cache/"];for(let Q of Z)if($.includes(Q))return{skip:!0,reason:"build artifact"};return{skip:!1}}var TQ;var I2=x(()=>{TQ=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lockb","**/*.d.ts","**/*.log","dist/**","build/**","coverage/**",".turbo/**",".next/**","out/**",".cache/**"]});function U9($){let Z=$;Z=Z.replace(EQ,"<redacted-github-token>");for(let{eqPattern:Q,colonPattern:X}of wQ)Q.lastIndex=0,X.lastIndex=0,Z=Z.replace(Q,(K,Y)=>`${Y}=<redacted>`),Z=Z.replace(X,(K,Y)=>`${Y}: <redacted>`);if(!Z.includes("<redacted")&&!Z.includes("hash")&&!Z.includes("checksum"))Z=Z.replace(IQ,"<redacted-value>");return Z}function b2($){return $.map(U9)}var xQ,wQ,EQ,IQ;var C2=x(()=>{xQ=[/token/i,/secret/i,/password/i,/api[_-]?key/i,/private[_-]?key/i,/access[_-]?key/i,/auth[_-]?token/i],wQ=xQ.map(($)=>({eqPattern:new RegExp(`(${$.source})\\s*=\\s*['"]?([^'"\\s}<]+)['"]?`,"gi"),colonPattern:new RegExp(`(${$.source})\\s*:\\s*['"]?([^'"\\s,}<]+)['"]?`,"gi")})),EQ=/(ghp_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9_]+)/g,IQ=/\b[a-zA-Z0-9+/=]{32,}\b/g});function bQ($){let Z={api:0,churn:0,ci:0,db:0,deps:0,infra:0,security:0,tests:0};for(let Q of $)Z[Q.category]+=Q.effectiveScore;for(let Q of Object.keys(Z))Z[Q]=Math.min(100,Z[Q]);return Z}function CQ($){let Z=Object.values($);if(Z.length===0)return 0;let Q=Math.max(...Z),K=[...Z].sort((q,V)=>V-q).slice(0,3);while(K.length<3)K.push(0);let Y=K.reduce((q,V)=>q+V,0)/3,W=0.6*Q+0.4*Y;return Math.round(Math.max(0,Math.min(100,W)))}function PQ($){if($>=81)return"critical";if($>=61)return"high";if($>=41)return"elevated";if($>=21)return"moderate";return"low"}function yQ($){let Q=Object.entries($).sort((U,J)=>J[1]-U[1]),X=Q.length>0?Q[0]:["security",0],K=Q.slice(0,3).map(([U,J])=>({category:U,score:J})),Y=X[1],W=K.map((U)=>U.score);while(W.length<3)W.push(0);let q=W.reduce((U,J)=>U+J,0)/3,V=`riskScore = round(0.6 * ${Y} + 0.4 * ${q.toFixed(2)})`;return{maxCategory:{category:X[0],score:Y},topCategories:K,formula:V}}function P2($,Z,Q){let X=$;if(Z&&Z.length>0)X=X.filter((K)=>Z.includes(K.category));if(Q&&Q.length>0)X=X.filter((K)=>!Q.includes(K.category));return X}function y2($,Z,Q,X,K){let Y=bQ(Q),W=CQ(Y),q=PQ(W),V={schemaVersion:"2.0",range:{base:$,head:Z,mode:K?.mode},riskScore:W,riskLevel:q,categoryScores:Y,flags:o8(Q),skippedFiles:X};if(!K?.noTimestamp)V.generatedAt=new Date().toISOString();if(K?.explainScore)V.scoreBreakdown=yQ(Y);if(K?.only||K?.exclude)V.filters={only:K.only,exclude:K.exclude};return V}var k2=()=>{};function V1($){return $.evidence.map((Z)=>({file:Z.file,hunk:Z.hunk?`@@ -${Z.hunk.oldStart},${Z.hunk.oldLines} +${Z.hunk.newStart},${Z.hunk.newLines} @@`:void 0,lines:Z.excerpt.split(`
47
- `).slice(0,5)}))}function kQ($){let Z=[];for(let Q of $){let X=[Q.findingId];switch(Q.riskType){case"permissions_broadened":{Z.push({ruleKey:"security.workflow_permissions_broadened",flagId:g("security.workflow_permissions_broadened",X),relatedFindingIds:X,category:"security",score:35,confidence:0.9,title:"Workflow permissions broadened",summary:`Workflow ${Q.file} has broadened permissions (write access)`,evidence:V1(Q),suggestedChecks:["Review if write permissions are necessary","Ensure principle of least privilege","Check if GITHUB_TOKEN usage is secure"],effectiveScore:Math.round(31.5)});break}case"pull_request_target":{Z.push({ruleKey:"security.workflow_uses_pull_request_target",flagId:g("security.workflow_uses_pull_request_target",X),relatedFindingIds:X,category:"security",score:40,confidence:0.9,title:"Workflow uses pull_request_target",summary:`Workflow ${Q.file} uses pull_request_target event (can expose secrets)`,evidence:V1(Q),suggestedChecks:["Ensure no untrusted code is executed in this context","Review if pull_request_target is necessary (vs pull_request)","Verify secrets are not exposed to PR authors"],effectiveScore:Math.round(36)});break}case"remote_script_download":{Z.push({ruleKey:"security.workflow_downloads_remote_script",flagId:g("security.workflow_downloads_remote_script",X),relatedFindingIds:X,category:"security",score:45,confidence:0.85,title:"Workflow downloads and executes remote scripts",summary:`Workflow ${Q.file} downloads and pipes to shell (supply chain risk)`,evidence:V1(Q),suggestedChecks:["Pin script sources to specific commit SHAs","Verify script integrity with checksums","Consider vendoring the script instead"],effectiveScore:Math.round(38.25)});break}case"pipeline_changed":{Z.push({ruleKey:"ci.pipeline_changed",flagId:g("ci.pipeline_changed",X),relatedFindingIds:X,category:"ci",score:10,confidence:0.7,title:"CI/CD pipeline configuration changed",summary:`Pipeline ${Q.file} was modified`,evidence:V1(Q),suggestedChecks:["Review pipeline changes for security implications","Test pipeline changes in a non-production environment"],effectiveScore:Math.round(7)});break}}}return Z}function SQ($){let Z=[];for(let Q of $){let X=[Q.findingId];switch(Q.riskType){case"destructive":{Z.push({ruleKey:"db.destructive_sql",flagId:g("db.destructive_sql",X),relatedFindingIds:X,category:"db",score:45,confidence:0.9,title:"Destructive SQL detected",summary:`Migration ${Q.file} contains DROP TABLE/COLUMN or TRUNCATE`,evidence:V1(Q),suggestedChecks:["Backup data before running migration","Verify this is intentional data deletion","Test migration rollback procedure","Consider making column nullable instead of dropping"],effectiveScore:Math.round(40.5)});break}case"schema_change":{Z.push({ruleKey:"db.schema_change_risky",flagId:g("db.schema_change_risky",X),relatedFindingIds:X,category:"db",score:30,confidence:0.85,title:"Risky schema change detected",summary:`Migration ${Q.file} contains ALTER COLUMN or TYPE change`,evidence:V1(Q),suggestedChecks:["Test schema changes on production-like data","Check for data type compatibility","Monitor migration execution time (may lock table)"],effectiveScore:Math.round(25.5)});break}case"unscoped_modification":{Z.push({ruleKey:"db.unscoped_data_modification",flagId:g("db.unscoped_data_modification",X),relatedFindingIds:X,category:"db",score:35,confidence:0.75,title:"Unscoped data modification detected",summary:`Migration ${Q.file} contains UPDATE/DELETE without WHERE clause`,evidence:V1(Q),suggestedChecks:["Verify this affects all rows intentionally","Add WHERE clause if only subset should be modified","Test on staging data first"],effectiveScore:Math.round(26.25)});break}}}return Z}function vQ($){let Z=[],Q=$.filter((q)=>q.type==="stencil-component-change"),X=$.filter((q)=>q.type==="stencil-prop-change"),K=$.filter((q)=>q.type==="stencil-event-change"),Y=$.filter((q)=>q.type==="stencil-method-change"),W=$.filter((q)=>q.type==="stencil-slot-change");for(let q of Q){if(q.change==="tag-changed"){let U=[q.findingId];Z.push({ruleKey:"stencil.tag_changed",flagId:g("stencil.tag_changed",U),relatedFindingIds:U,category:"api",score:45,confidence:0.95,title:"Component tag changed",summary:`Tag changed from "${q.fromTag}" to "${q.toTag}"`,evidence:V1(q),suggestedChecks:["Update all usages of this component","This is a breaking change"],effectiveScore:Math.round(42.75)})}if(q.change==="shadow-changed"){let U=[q.findingId];Z.push({ruleKey:"stencil.shadow_changed",flagId:g("stencil.shadow_changed",U),relatedFindingIds:U,category:"api",score:25,confidence:0.9,title:"Shadow DOM configuration changed",summary:`Shadow DOM enabled changed from ${q.fromShadow} to ${q.toShadow}`,evidence:V1(q),suggestedChecks:["Check styles and global styling impact"],effectiveScore:Math.round(22.5)})}}for(let q of X)if(q.change==="removed"){let U=[q.findingId];Z.push({ruleKey:"stencil.prop_removed",flagId:g("stencil.prop_removed",U),relatedFindingIds:U,category:"api",score:40,confidence:0.95,title:"Component prop removed",summary:`Prop "${q.propName}" removed from <${q.tag}>`,evidence:V1(q),suggestedChecks:["This is a breaking change","Check usages"],effectiveScore:Math.round(38)})}else if(q.change==="changed"){let U=[q.findingId];Z.push({ruleKey:"stencil.prop_changed",flagId:g("stencil.prop_changed",U),relatedFindingIds:U,category:"api",score:35,confidence:0.9,title:"Component prop modified",summary:`Prop "${q.propName}" options changed`,evidence:V1(q),suggestedChecks:["Check for attribute/reflect/mutable changes"],effectiveScore:Math.round(31.5)})}for(let q of K)if(q.change==="removed"){let U=[q.findingId];Z.push({ruleKey:"stencil.event_removed",flagId:g("stencil.event_removed",U),relatedFindingIds:U,category:"api",score:40,confidence:0.95,title:"Component event removed",summary:`Event "${q.eventName}" removed from <${q.tag}>`,evidence:V1(q),suggestedChecks:["This is a breaking change","Check event listeners"],effectiveScore:Math.round(38)})}else if(q.change==="changed"){let U=[q.findingId];Z.push({ruleKey:"stencil.event_changed",flagId:g("stencil.event_changed",U),relatedFindingIds:U,category:"api",score:35,confidence:0.9,title:"Component event modified",summary:`Event "${q.eventName}" options changed`,evidence:V1(q),suggestedChecks:["Check bubbles/composed/cancelable options"],effectiveScore:Math.round(31.5)})}for(let q of Y)if(q.change==="removed"){let U=[q.findingId];Z.push({ruleKey:"stencil.method_removed",flagId:g("stencil.method_removed",U),relatedFindingIds:U,category:"api",score:40,confidence:0.95,title:"Component method removed",summary:`Method "${q.methodName}" removed from <${q.tag}>`,evidence:V1(q),suggestedChecks:["This is a breaking change","Check usages"],effectiveScore:Math.round(38)})}else if(q.change==="changed");for(let q of W)if(q.change==="removed"){let U=[q.findingId];Z.push({ruleKey:"stencil.slot_removed",flagId:g("stencil.slot_removed",U),relatedFindingIds:U,category:"api",score:35,confidence:0.9,title:"Component slot removed",summary:`Slot "${q.slotName}" removed from <${q.tag}>`,evidence:V1(q),suggestedChecks:["Check content projection usages"],effectiveScore:Math.round(31.5)})}return Z}function S2($){let Z=[],Q=$.filter((O)=>O.type==="ci-workflow"),X=$.filter((O)=>O.type==="sql-risk"),K=$.filter((O)=>O.type==="infra-change"),Y=$.filter((O)=>O.type==="api-contract-change"),W=$.filter((O)=>O.type==="large-diff"),q=$.filter((O)=>O.type==="lockfile-mismatch"),V=$.filter((O)=>O.type==="test-gap"),U=$.filter((O)=>O.type==="dependency-change"),J=$.filter((O)=>O.type==="db-migration"),B=$.filter((O)=>O.type==="test-change");Z.push(...kQ(Q)),Z.push(...SQ(X)),Z.push(...vQ($));for(let O of K){let z=[O.findingId],_=`infra.${O.infraType}_changed`,D={dockerfile:"Dockerfile changed",terraform:"Terraform configuration changed",k8s:"Kubernetes manifest changed"};Z.push({ruleKey:_,flagId:g(_,z),relatedFindingIds:z,category:"infra",score:20,confidence:0.8,title:D[O.infraType],summary:`${O.files.length} ${O.infraType} ${O.files.length===1?"file":"files"} changed`,evidence:O.files.slice(0,3).map((L)=>({file:L,lines:["File changed"]})),suggestedChecks:["Review infrastructure changes carefully","Test in staging environment","Verify no unintended resource changes"],effectiveScore:Math.round(16)})}if(Y.length>0){let O=Y.map((D)=>D.findingId),z="api.contract_changed",_=Y.flatMap((D)=>D.files);Z.push({ruleKey:"api.contract_changed",flagId:g("api.contract_changed",O),relatedFindingIds:O,category:"api",score:25,confidence:0.85,title:"API contract changed",summary:`${_.length} API ${_.length===1?"file":"files"} changed`,evidence:_.slice(0,3).map((D)=>({file:D,lines:["File changed"]})),suggestedChecks:["Verify backwards compatibility","Update API documentation","Notify API consumers of changes"],effectiveScore:Math.round(21.25)})}if(W.length>0){let O=W[0],z=[O.findingId],_="churn.large_diff";Z.push({ruleKey:"churn.large_diff",flagId:g("churn.large_diff",z),relatedFindingIds:z,category:"churn",score:15,confidence:0.9,title:"Large diff detected",summary:`${O.filesChanged} files changed, ${O.linesChanged} lines modified`,evidence:[],suggestedChecks:["Consider breaking into smaller PRs","Ensure adequate test coverage","Review carefully for unintended changes"],effectiveScore:Math.round(13.5)})}for(let O of q){let z=[O.findingId],_="deps.lockfile_without_manifest";Z.push({ruleKey:"deps.lockfile_without_manifest",flagId:g("deps.lockfile_without_manifest",z),relatedFindingIds:z,category:"deps",score:20,confidence:0.9,title:"Lockfile changed without manifest",summary:O.manifestChanged?"package.json changed without lockfile update":"Lockfile changed without package.json update",evidence:[],suggestedChecks:["Run package manager install to sync lockfile","Verify dependencies are correctly resolved"],effectiveScore:Math.round(18)})}for(let O of V){let z=[O.findingId],_="tests.possible_gap";Z.push({ruleKey:"tests.possible_gap",flagId:g("tests.possible_gap",z),relatedFindingIds:z,category:"tests",score:18,confidence:0.7,title:"Possible test coverage gap",summary:`${O.prodFilesChanged} production files changed with no test updates`,evidence:[],suggestedChecks:["Add tests for new functionality","Update existing tests if behavior changed"],effectiveScore:Math.round(12.6)})}let G=U.filter((O)=>O.section==="dependencies"&&!O.from);if(G.length>0){let O=G.map((_)=>_.findingId),z="deps.new_prod_dependency";Z.push({ruleKey:"deps.new_prod_dependency",flagId:g("deps.new_prod_dependency",O),relatedFindingIds:O,category:"deps",score:15,confidence:0.85,title:"New production dependencies added",summary:`${G.length} new production ${G.length===1?"dependency":"dependencies"} added`,evidence:G.slice(0,5).map((_)=>({file:"package.json",lines:[`+ "${_.name}": "${_.to}"`]})),suggestedChecks:["Review new dependencies for security vulnerabilities","Check license compatibility","Verify dependencies are actively maintained"],tags:G.map((_)=>_.name),effectiveScore:Math.round(12.75)})}let M=U.filter((O)=>O.impact==="major");if(M.length>0){let O=M.map((_)=>_.findingId),z="deps.major_version_bump";Z.push({ruleKey:"deps.major_version_bump",flagId:g("deps.major_version_bump",O),relatedFindingIds:O,category:"deps",score:25,confidence:0.9,title:"Major dependency version bump",summary:`${M.length} ${M.length===1?"dependency":"dependencies"} with major version changes`,evidence:M.slice(0,5).map((_)=>({file:"package.json",lines:[`"${_.name}": "${_.from}" -> "${_.to}"`]})),suggestedChecks:["Review breaking changes in dependency changelogs","Update code for API changes","Run full test suite"],tags:M.map((_)=>_.name),effectiveScore:Math.round(22.5)})}if(J.length>0){let O=J.map((_)=>_.findingId),z="db.migrations_changed";Z.push({ruleKey:"db.migrations_changed",flagId:g("db.migrations_changed",O),relatedFindingIds:O,category:"db",score:12,confidence:0.8,title:"Database migrations changed",summary:`${J.length} migration/SQL ${J.length===1?"file":"files"} changed`,evidence:J.slice(0,3).flatMap((_)=>_.files.map((D)=>({file:D,lines:["Migration file changed"]}))),suggestedChecks:["Test migrations on a staging database","Ensure migrations are reversible","Check for data loss or downtime impact"],effectiveScore:Math.round(9.600000000000001)})}if(B.length>0){let O=B.map((_)=>_.findingId),z="tests.changed";Z.push({ruleKey:"tests.changed",flagId:g("tests.changed",O),relatedFindingIds:O,category:"tests",score:5,confidence:0.8,title:"Test files changed",summary:`${B.length} test ${B.length===1?"file":"files"} modified`,evidence:B.slice(0,3).flatMap((_)=>_.files.map((D)=>({file:D,lines:["Test file changed"]}))),suggestedChecks:["Verify tests still pass","Review test coverage changes"],effectiveScore:Math.round(4)})}let H=$.filter((O)=>O.type==="test-parity-violation");if(H.length>0){let O=H.map((A)=>A.findingId),z="tests.missing_parity",_=H.filter((A)=>A.confidence==="high").length,D=H.filter((A)=>A.confidence==="medium").length,L=12+_*2+D*1,w=Math.min(L,25),T=_>D?0.85:0.7;Z.push({ruleKey:"tests.missing_parity",flagId:g("tests.missing_parity",O),relatedFindingIds:O,category:"tests",score:w,confidence:T,title:"Source files without test coverage",summary:`${H.length} source ${H.length===1?"file":"files"} modified without corresponding tests`,evidence:H.slice(0,5).map((A)=>({file:A.sourceFile,lines:[`No test file found (expected: ${A.expectedTestLocations[0]||"unknown"})`]})),suggestedChecks:["Add tests for new/changed code","Verify existing tests cover the changes","Consider if these files need unit tests"],effectiveScore:Math.round(w*T)})}return Z}var v2=x(()=>{P$()});function FQ($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}function mQ($){let Z=[];Z.push("# Risk Report"),Z.push(""),Z.push(`**Range:** \`${$.range.base}..${$.range.head}\``),Z.push("");let Q=hQ($.riskLevel);Z.push(`## Overall Risk: ${Q} ${$.riskLevel.toUpperCase()}`),Z.push(""),Z.push(`**Score:** ${$.riskScore}/100`),Z.push(""),Z.push("### Category Scores"),Z.push("");let X=Object.entries($.categoryScores).sort((K,Y)=>Y[1]-K[1]);for(let[K,Y]of X)if(Y>0){let W="█".repeat(Math.floor(Y/10));Z.push(`- **${K}**: ${Y}/100 ${W}`)}if(Z.push(""),$.flags.length>0){Z.push("## Risk Flags"),Z.push("");let K=gQ($.flags);for(let[Y,W]of Object.entries(K)){if(W.length===0)continue;Z.push(`### ${Y.toUpperCase()}`),Z.push("");for(let q of W){if(Z.push(`#### ${q.title}`),Z.push(""),Z.push(`**Rule:** \`${q.ruleKey}\``),Z.push(`**Flag ID:** \`${q.flagId}\``),Z.push(`**Score:** ${q.effectiveScore}/100 (base: ${q.score}, confidence: ${q.confidence})`),Z.push(""),Z.push(q.summary),Z.push(""),q.evidence.length>0){Z.push("**Evidence:**"),Z.push("");for(let V of q.evidence){if(Z.push(`- **${V.file}**`),V.hunk)Z.push(` \`${V.hunk}\``);if(V.lines.length>0){Z.push(" ```");for(let U of V.lines)Z.push(` ${U}`);Z.push(" ```")}}Z.push("")}if(q.suggestedChecks.length>0){Z.push("**Suggested Checks:**"),Z.push("");for(let V of q.suggestedChecks)Z.push(`- ${V}`);Z.push("")}}}}if($.scoreBreakdown){Z.push("## Score Breakdown"),Z.push(""),Z.push(`**Max Category:** ${$.scoreBreakdown.maxCategory.category} (${$.scoreBreakdown.maxCategory.score})`),Z.push(""),Z.push("**Top 3 Categories:**");for(let K of $.scoreBreakdown.topCategories)Z.push(`- ${K.category}: ${K.score}`);Z.push(""),Z.push(`**Formula:** \`${$.scoreBreakdown.formula}\``),Z.push("")}if($.skippedFiles.length>0){Z.push("## Skipped Files"),Z.push(""),Z.push(`${$.skippedFiles.length} files were skipped:`),Z.push("");for(let K of $.skippedFiles.slice(0,20))Z.push(`- \`${K.file}\` (${K.reason})`);if($.skippedFiles.length>20)Z.push(`- ... and ${$.skippedFiles.length-20} more`);Z.push("")}return Z.join(`
48
- `)}function uQ($){let Z=[];Z.push("RISK REPORT"),Z.push("=".repeat(60)),Z.push(""),Z.push(`Range: ${$.range.base}..${$.range.head}`),Z.push(""),Z.push(`Overall Risk: ${$.riskLevel.toUpperCase()}`),Z.push(`Score: ${$.riskScore}/100`),Z.push(""),Z.push("Category Scores:"),Z.push("-".repeat(40));let Q=Object.entries($.categoryScores).sort((X,K)=>K[1]-X[1]);for(let[X,K]of Q)if(K>0){let Y="#".repeat(Math.floor(K/5));Z.push(` ${X.padEnd(12)} ${K.toString().padStart(3)}/100 ${Y}`)}if(Z.push(""),$.flags.length>0){Z.push("Risk Flags:"),Z.push("-".repeat(40));for(let X of $.flags)if(Z.push(""),Z.push(`[${X.ruleKey}] ${X.title}`),Z.push(` Score: ${X.effectiveScore}/100`),Z.push(` ${X.summary}`),X.evidence.length>0){Z.push(` Evidence: ${X.evidence.length} location(s)`);for(let K of X.evidence.slice(0,2))Z.push(` - ${K.file}`)}Z.push("")}if($.skippedFiles.length>0)Z.push(`Skipped Files: ${$.skippedFiles.length}`),Z.push("");return Z.join(`
49
- `)}function hQ($){switch($){case"critical":return"\uD83D\uDD34";case"high":return"\uD83D\uDFE0";case"elevated":return"\uD83D\uDFE1";case"moderate":return"\uD83D\uDD35";case"low":return"\uD83D\uDFE2";default:return"⚪"}}function gQ($){let Z={};for(let Q of $){if(!Z[Q.category])Z[Q.category]=[];Z[Q.category].push(Q)}return Z}var V9={};A1(V9,{computeRiskReportDelta:()=>F2});async function F2($){let{sincePath:Z,currentReport:Q,mode:X,base:K,head:Y,only:W,exclude:q,sinceStrict:V}=$,U;try{U=await V0(Z)}catch(L){let w=L instanceof Error?L.message:String(L);throw new v(`Failed to load previous risk report from ${Z}: ${w}`,1)}if(!U.schemaVersion||!U.flags||U.riskScore===void 0)throw new v(`File ${Z} does not appear to be a valid risk report output`,1);let J={mode:X,base:K,head:Y,only:W},B=Z9(U),G=B0(B,J);if(V&&G.length>0)throw new v(`Scope mismatch detected (--since-strict): ${G.map((L)=>L.message).join("; ")}`,1);let{added:M,removed:H,changed:O}=J0({beforeItems:U.flags,afterItems:Q.flags}),z=O.map((L)=>({flagId:L.id,before:L.before,after:L.after})),_={from:U.riskScore,to:Q.riskScore,delta:Q.riskScore-U.riskScore},D=["--mode",X];if(K)D.push("--base",K);if(Y)D.push("--head",Y);if(W)D.push("--only",W.join(","));if(q)D.push("--exclude",q.join(","));if(D.push("--since",Z),V)D.push("--since-strict");return{schemaVersion:"1.0",generatedAt:new Date().toISOString(),command:{name:"risk-report",args:D},since:{path:Z,schemaVersion:U.schemaVersion},current:{schemaVersion:Q.schemaVersion},scope:J,delta:{riskScore:_,flags:{added:M,removed:H,changed:z}},summary:{flagAddedCount:M.length,flagRemovedCount:H.length,flagChangedCount:z.length}}}var m2=x(()=>{T2();H1()});var J9={};A1(J9,{shouldSkipFile:()=>E2,renderRiskReportText:()=>uQ,renderRiskReportMarkdown:()=>mQ,renderRiskReportJSON:()=>FQ,redactLines:()=>b2,redactLine:()=>U9,generateRiskReport:()=>H$,findingsToFlags:()=>S2,filterFlagsByCategory:()=>P2,executeRiskReport:()=>lQ,computeRiskReportDelta:()=>F2,computeRiskReport:()=>y2,DEFAULT_EXCLUSIONS:()=>TQ});async function H$($,Z={}){let{only:Q,exclude:X,maxEvidenceLines:K=5,redact:Y=!1,explainScore:W=!1,noTimestamp:q=!1,profile:V="auto",cwd:U=process.cwd(),mode:J,testParity:B=!1}=Z,G=[];for(let D of $.files){let L=E2(D.path);if(L.skip)G.push({file:D.path,reason:L.reason||"excluded"})}let M=e1(V,$,U),H=y1(M),O=await I1(H.analyzers,$);if(B){let{testParityAnalyzer:D}=await Promise.resolve().then(() => (Q0(),e0)),L=await D.analyze($);O.push(...L)}let z=O.map($$),_=S2(z);if(_=P2(_,Q,X),Y||K!==5)_=_.map((D)=>({...D,evidence:R2(D.evidence.map((L)=>({...L,lines:Y?b2(L.lines.slice(0,K)):L.lines.slice(0,K)})))}));else _=_.map((D)=>({...D,evidence:R2(D.evidence)}));return y2($.base,$.head,_,G,{explainScore:W,noTimestamp:q,mode:J,only:Q,exclude:X})}async function lQ($,Z={}){return await H$($,Z)}var G0=x(()=>{I2();C2();k2();C$();P$();v2();m2();I2();C2();k2();v2()});var G9={};A1(G9,{executeZoom:()=>cQ});async function cQ($,Z){if(Z.findingId&&Z.flagId)throw new v("Cannot specify both --finding and --flag. Use only one.",1);if(!Z.findingId&&!Z.flagId)throw new v("Must specify either --finding <id> or --flag <id>",1);if(Z.findingId)return fQ($,Z);else return pQ($,Z)}async function fQ($,Z){let Q=Z.findingId,X=e1(Z.profile,$,process.cwd()),K=y1(X),q=(await I1(K.analyzers,$)).map($$).find((B)=>B.findingId===Q);if(!q)throw new v(`Finding not found: ${Q}. Run 'facts' or 'risk-report' to see available findings.`,1);let V=q.evidence.slice(0,Z.maxEvidenceLines).map((B)=>({file:B.file,excerpt:Z.redact?i$(B.excerpt):B.excerpt,line:B.line,hunk:B.hunk})),U;if(Z.includePatch)U=await dQ($,q,Z.unified,Z.redact);return{schemaVersion:"1.0",generatedAt:Z.noTimestamp?void 0:new Date().toISOString(),range:{base:$.base,head:$.head},itemType:"finding",findingId:Q,finding:q,evidence:V,patchContext:U}}async function pQ($,Z){let Q=Z.flagId,X=e1(Z.profile,$,process.cwd()),K=y1(X),W=(await I1(K.analyzers,$)).map($$),V=(await H$($,{profile:Z.profile,redact:Z.redact,maxEvidenceLines:Z.maxEvidenceLines,noTimestamp:Z.noTimestamp})).flags.find((G)=>G.flagId===Q);if(!V)throw new v(`Flag not found: ${Q}. Run 'risk-report' to see available flags.`,1);let U=W.filter((G)=>V.relatedFindingIds.includes(G.findingId)),J;if(Z.includePatch&&V.evidence.length>0)J=await B9($,V.evidence.map((G)=>G.file),Z.unified,Z.redact);return{schemaVersion:"1.0",generatedAt:Z.noTimestamp?void 0:new Date().toISOString(),range:{base:$.base,head:$.head},itemType:"flag",flagId:Q,flag:V,evidence:V.evidence.slice(0,Z.maxEvidenceLines),relatedFindings:U,patchContext:J}}async function dQ($,Z,Q,X){let K=new Set;for(let Y of Z.evidence)K.add(Y.file);return B9($,Array.from(K),Q,X)}async function B9($,Z,Q,X){let K=[];for(let Y of Z){let W=$.diffs.find((q)=>q.path===Y);if(!W)continue;K.push({file:W.path,status:W.status,hunks:W.hunks.map((q)=>({oldStart:q.oldStart,oldLines:q.oldLines,newStart:q.newStart,newLines:q.newLines,content:X?i$(q.content):q.content}))})}return K}var O9=x(()=>{H1();C$();P$();G0()});var M9={};A1(M9,{renderZoomText:()=>nQ,renderZoomMarkdown:()=>aQ,renderZoomJSON:()=>rQ});function rQ($,Z){return Z?JSON.stringify($,null,2):JSON.stringify($)}function aQ($){if($.itemType==="finding")return sQ($);else return oQ($)}function sQ($){let Z=[];if(Z.push(`# Finding: ${$.findingId}`),Z.push(""),Z.push(`**Type:** ${$.finding.type}`),Z.push(`**Category:** ${$.finding.category}`),Z.push(`**Confidence:** ${$.finding.confidence}`),Z.push(""),Z.push(`**Range:** ${$.range.base}..${$.range.head}`),Z.push(""),Z.push("## Details"),Z.push(""),Z.push("```json"),Z.push(JSON.stringify($.finding,null,2)),Z.push("```"),Z.push(""),$.evidence.length>0){Z.push("## Evidence"),Z.push("");for(let Q of $.evidence){if(Z.push(`### ${Q.file}`),Q.line!==void 0)Z.push(`Line ${Q.line}`);if(Q.hunk)Z.push(`Hunk: @@ -${Q.hunk.oldStart},${Q.hunk.oldLines} +${Q.hunk.newStart},${Q.hunk.newLines} @@`);Z.push(""),Z.push("```"),Z.push(Q.excerpt),Z.push("```"),Z.push("")}}if($.patchContext&&$.patchContext.length>0){Z.push("## Patch Context"),Z.push("");for(let Q of $.patchContext){Z.push(`### ${Q.file} (${Q.status})`),Z.push("");for(let X of Q.hunks)Z.push("```diff"),Z.push(`@@ -${X.oldStart},${X.oldLines} +${X.newStart},${X.newLines} @@`),Z.push(X.content),Z.push("```"),Z.push("")}}return Z.join(`
50
- `)}function oQ($){let Z=[];if(Z.push(`# Flag: ${$.flagId}`),Z.push(""),Z.push(`**Rule:** ${$.flag.ruleKey}`),Z.push(`**Category:** ${$.flag.category}`),Z.push(`**Score:** ${$.flag.effectiveScore} (base: ${$.flag.score}, confidence: ${$.flag.confidence})`),Z.push(""),Z.push(`**Range:** ${$.range.base}..${$.range.head}`),Z.push(""),Z.push("## Details"),Z.push(""),Z.push(`**Title:** ${$.flag.title}`),Z.push(""),Z.push(`**Summary:** ${$.flag.summary}`),Z.push(""),$.flag.suggestedChecks&&$.flag.suggestedChecks.length>0){Z.push("### Suggested Checks"),Z.push("");for(let Q of $.flag.suggestedChecks)Z.push(`- ${Q}`);Z.push("")}if($.evidence.length>0){Z.push("## Evidence"),Z.push("");for(let Q of $.evidence){if(Z.push(`### ${Q.file}`),Q.hunk)Z.push(`Hunk: ${Q.hunk}`);Z.push(""),Z.push("```"),Z.push(Q.lines.join(`
22
+ `;try{let q=Q("git",["cat-file","--batch"],{cwd:Z,input:K}),{stdout:W}=await q,V=Buffer.isBuffer(W)?W:Buffer.from(String(W),"utf-8"),U=0;for(let J of Y){if(U>=V.length)break;let G=V.indexOf(`
23
+ `,U);if(G===-1)break;let H=V.subarray(U,G).toString("utf-8"),[_,O,M]=H.split(" ");if(!_||!O||!M){U=G+1;continue}if(O==="missing"){U=G+1;continue}let z=parseInt(M,10),A=G+1,N=A+z,E=V.subarray(A,N);X.set(J,E.toString("utf-8")),U=N+1}}catch(q){console.warn("Failed to batch fetch files:",q)}return X}var K0=()=>{};import{parse as Z6}from"@babel/parser";import X2 from"@babel/traverse";import*as C from"@babel/types";function X6($){if(![".ts",".tsx",".js",".jsx"].some((Q)=>$.endsWith(Q)))return!1;return!0}function W0($){let Z=$.replace(/\/+/g,"/");if(Z!=="/"&&Z.endsWith("/"))Z=Z.slice(0,-1);return Z}function l5($,Z){if(Z.startsWith("/"))return W0(Z);let Q=$==="/"?`/${Z}`:`${$}/${Z}`;return W0(Q)}function f5($,Z,Q="/"){let X=[];return X2($,{JSXElement(Y){let K=Y.node.openingElement,q=K.name;if(C.isJSXIdentifier(q)&&q.name==="Route"){let W=null,V=!1,U=[];for(let J of K.attributes)if(C.isJSXAttribute(J)&&C.isJSXIdentifier(J.name)){if(J.name.name==="path"&&J.value){if(C.isStringLiteral(J.value))W=J.value.value;else if(C.isJSXExpressionContainer(J.value)&&C.isStringLiteral(J.value.expression))W=J.value.expression.value}else if(J.name.name==="index")V=!0}if(V)X.push({path:W0(Q),file:Z});else if(W){let J=l5(Q,W);X.push({path:J,file:Z});for(let G of Y.node.children)if(C.isJSXElement(G))U.push(G);for(let G of U){let B=C.file(C.program([C.expressionStatement(G)])),H=f5(B,Z,J);X.push(...H)}}Y.skip()}}}),X}function Y6($,Z,Q="/"){let X=[],Y=new Map;return X2($,{VariableDeclarator(K){if(C.isIdentifier(K.node.id)&&(C.isArrayExpression(K.node.init)||C.isObjectExpression(K.node.init)))Y.set(K.node.id.name,K.node.init)}}),X2($,{CallExpression(K){let q=K.node.callee;if(C.isIdentifier(q)&&(q.name==="createBrowserRouter"||q.name==="createHashRouter"||q.name==="createMemoryRouter")){let W=K.node.arguments[0],V=null;if(C.isArrayExpression(W))V=W;else if(C.isIdentifier(W)){let U=Y.get(W.name);if(U&&C.isArrayExpression(U))V=U}if(V){let U=p5(V,Z,Q);X.push(...U)}}}}),X}function p5($,Z,Q="/"){let X=[];for(let Y of $.elements)if(C.isObjectExpression(Y)){let K=K6(Y);if(K.index)X.push({path:W0(Q),file:Z});else if(K.path){let q=l5(Q,K.path);if(X.push({path:q,file:Z}),K.children){let W=p5(K.children,Z,q);X.push(...W)}}}return X}function K6($){let Z={};for(let Q of $.properties)if(C.isObjectProperty(Q)&&C.isIdentifier(Q.key)){if(Q.key.name==="path"&&C.isStringLiteral(Q.value))Z.path=Q.value.value;else if(Q.key.name==="index"){if(C.isBooleanLiteral(Q.value)&&Q.value.value)Z.index=!0}else if(Q.key.name==="children"&&C.isArrayExpression(Q.value))Z.children=Q.value}return Z}function c5($,Z){try{let Q=Z6($,{sourceType:"module",plugins:["typescript","jsx"]}),X=f5(Q,Z),Y=Y6(Q,Z);return[...X,...Y]}catch(Q){return[]}}var Q6,Y2;var d5=x(()=>{K0();Q6={batchGetFileContent:z$};Y2={name:"react-router-routes",async analyze($){let Z=[],Q=$.files.filter((q)=>{return X6(q.path)});if(Q.length===0)return[];let X=[];for(let q of Q)X.push({ref:$.base,path:q.path}),X.push({ref:$.head,path:q.path});let Y=await Q6.batchGetFileContent(X);for(let q of Q){let W=`${$.base}:${q.path}`,V=`${$.head}:${q.path}`,U=Y.get(W),J=Y.get(V),G=(M)=>M.includes("react-router")||M.includes("<Route")||M.includes("createBrowserRouter")||M.includes("createHashRouter")||M.includes("createMemoryRouter");if(U&&!G(U)&&J&&!G(J))continue;let B=U?c5(U,q.path):[],H=J?c5(J,q.path):[],_=new Set(B.map((M)=>M.path)),O=new Set(H.map((M)=>M.path));for(let M of H)if(!_.has(M.path)){let z={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:[R(q.path,`Route: ${M.path}`)],routeId:M.path,file:q.path,change:"added",routeType:"page"};Z.push(z)}for(let M of B)if(!O.has(M.path)){let z={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:[R(q.path,`Route: ${M.path}`)],routeId:M.path,file:q.path,change:"deleted",routeType:"page"};Z.push(z)}}return Array.from(new Map(Z.map((q)=>{return[`${q.routeId}-${q.change}-${q.file}`,q]})).values()).sort((q,W)=>{let V=q.routeId,U=W.routeId;return V.localeCompare(U)})}}});var W2={};P1(W2,{testParityAnalyzer:()=>j6,createTestParityAnalyzer:()=>s5,_resetCacheForTesting:()=>G6});import O1 from"node:path";import{execa as W6}from"execa";function G6(){K2.clear(),C$=null}async function B6($,Z){let Q=new Set,X=[];for(let Y of $){let K=K2.get(Y);if(K)for(let q of K)Q.add(q);else X.push(Y)}if(X.length===0)return Q;try{let{stdout:Y}=await Z("git",["ls-files","--cached","--others","--exclude-standard","--",...X],{reject:!1}),K=Y.split(`
24
+ `).filter(Boolean);for(let q of X){let W=new Set;for(let V of K)if(V.startsWith(q+"/")||V.startsWith(q+O1.sep))W.add(V),Q.add(V);K2.set(q,W)}for(let q of K)if(!q.includes("/")&&!q.includes(O1.sep))Q.add(q);return Q}catch{return O6(Z)}}async function O6($){if(C$)return C$;try{let{stdout:Z}=await $("git",["ls-files","--cached","--others","--exclude-standard"],{reject:!1});return C$=new Set(Z.split(`
25
+ `).filter(Boolean)),C$}catch{return new Set}}function H6($){return{testPatterns:$?.testPatterns??U6,excludePatterns:[...q6,...$?.excludePatterns??[]],testDirectories:$?.testDirectories??V6,sourceDirectories:$?.sourceDirectories??J6}}function r5($,Z){if(Y0($))return!1;if(Z.some((Q)=>Q.test($)))return!1;return/\.(ts|js|tsx|jsx|mts|mjs)$/.test($)}function _6($,Z){if(/utils?|helpers?|lib|shared/i.test($))return"medium";if(Z&&Z.additions+Z.deletions<10)return"low";if(/services?|controllers?|handlers?|api|routes|commands?|analyzers?/i.test($))return"high";return"medium"}function a5($,Z,Q,X){let Y=[],K=O1.extname($),q=O1.basename($,K),W=O1.dirname($);for(let J of Z)Y.push(O1.join(W,`${q}${J}`));let V=$;for(let J of X)if($.startsWith(`${J}/`)){V=$.slice(J.length+1);break}for(let J of Q)for(let G of Z)Y.push(O1.join(J,O1.dirname(V),`${q}${G}`)),Y.push(O1.join(J,`${q}${G}`)),Y.push(O1.join(J,W,`${q}${G}`));let U=V.split(O1.sep);if(U.length>1){let J=U[U.length-2],G=`${J}-${q}`,B=`${q}-${J}`;for(let H of Q)for(let _ of Z)Y.push(O1.join(H,`${G}${_}`)),Y.push(O1.join(H,`${B}${_}`))}return[...new Set(Y.map((J)=>O1.normalize(J)))]}async function M6($,Z,Q,X,Y){let K=a5($,Z,Q,X);for(let q of K)if(Y.has(q))return q;return null}function z6($,Z){let Q=O1.basename($,O1.extname($));return Z.files.some((X)=>Y0(X.path)&&X.path.includes(Q)&&X.status!=="deleted")}function s5($,Z){let Q=H6($),X=Z?.exec??W6;return{name:"test-parity",async analyze(Y){let K=[],q=new Set;for(let V of Y.files){if(V.status==="deleted")continue;if(!r5(V.path,Q.excludePatterns))continue;let U=O1.dirname(V.path);if(U&&U!==".")q.add(U.split(O1.sep)[0])}for(let V of Q.testDirectories)q.add(V);let W=await B6([...q],X);for(let V of Y.files)if(V.status!=="deleted")W.add(V.path);for(let V of Y.files){if(V.status==="deleted")continue;if(!r5(V.path,Q.excludePatterns))continue;if(await M6(V.path,Q.testPatterns,Q.testDirectories,Q.sourceDirectories,W))continue;if(z6(V.path,Y))continue;let J=Y.diffs.find((O)=>O.path===V.path),G=J?{additions:J.hunks.reduce((O,M)=>O+M.additions.length,0),deletions:J.hunks.reduce((O,M)=>O+M.deletions.length,0)}:void 0,B=_6(V.path,G),H=a5(V.path,Q.testPatterns,Q.testDirectories,Q.sourceDirectories).slice(0,5),_={type:"test-parity-violation",kind:"test-parity-violation",category:"tests",confidence:B,evidence:[R(V.path,`Source file modified without corresponding test: ${V.path}`)],sourceFile:V.path,expectedTestLocations:H};K.push(_)}return K}}}var q6,U6,V6,J6,K2,C$=null,j6;var q0=x(()=>{e0();q6=[/\.d\.ts$/,/\.config\.(ts|js|mts|mjs|cjs)$/,/index\.(ts|js|tsx|jsx)$/,/^docs\//,/^tests\//,/^test\//,/^__tests__\//,/^scripts\//,/^dist\//,/^build\//,/^\./,/types?\.(ts|js)$/,/constants?\.(ts|js)$/],U6=[".test.ts",".spec.ts",".test.js",".spec.js",".test.tsx",".spec.tsx"],V6=["tests","test","__tests__","spec"],J6=["src","lib","app"],K2=new Map;j6=s5()});import j$ from"node:path";import o5 from"node:fs/promises";import{execa as i5}from"execa";async function N6($,Z=process.cwd(),Q=i5){let X=new Map;if($.forEach((W)=>X.set(W.path,[])),$.length===0)return X;let Y=new Map;for(let W of $){if(!Y.has(W.baseName))Y.set(W.baseName,[]);Y.get(W.baseName).push(W.path)}let K=Array.from(Y.keys()),q=50;for(let W=0;W<K.length;W+=q){let V=K.slice(W,W+q),U=["grep","-I","-F","--null"];for(let J of V)U.push("-e"),U.push(J);try{let{stdout:J}=await Q("git",U,{cwd:Z,maxBuffer:20971520,reject:!1});if(!J)continue;let G=J.split(`
26
+ `);for(let B of G){if(!B)continue;let H=B.indexOf("\x00");if(H===-1)continue;let _=B.slice(0,H),O=B.slice(H+1);if(n5.some((M)=>M.test(_)))continue;if(!D6.test(_))continue;for(let M of V)if(O.includes(M)){let z=Y.get(M)||[];for(let A of z)if(A!==_){let N=X.get(A);if(!N.includes(_))N.push(_)}}}}catch(J){}}return X}async function A6($,Z,Q=process.cwd(),X=o5.readFile){try{let Y=await X(j$.join(Q,$),"utf-8"),K=j$.basename(Z,j$.extname(Z)),q=Y.split(`
27
+ `),W=[],V="";for(let U of q)if(U.includes(K)&&(U.trim().startsWith("import")||U.trim().startsWith("export"))){V=V?`${V}
28
+ ${U.trim()}`:U.trim();let J=U.match(/\{([^}]+)\}/);if(J){let G=J[1].split(",").map((B)=>{return B.trim().split(" as ")[0].trim().replace(/^type\s+/,"")});W.push(...G)}if(!J&&U.trim().startsWith("import")){let G=U.split("from");if(G.length>1){let B=G[0].replace("import","").trim();if(B){let H=B.match(/\*\s+as\s+([A-Za-z0-9_$]+)/);if(H)W.push(H[1].trim());else if(!B.includes("{")&&!B.includes("*"))W.push(B.split(" as ")[0].trim())}}}}return{importedSymbols:W,usageContext:V}}catch(Y){return null}}function R6($){let Z=$?.cwd??process.cwd(),Q=$?.exec??i5,X=$?.readFile??o5.readFile;return{name:"impact",async analyze(Y){let K=[],q=Y.files.filter((U)=>{if(U.status!=="modified"&&U.status!=="renamed")return!1;if(n5.some((G)=>G.test(U.path)))return!1;let J=j$.extname(U.path).toLowerCase();return L6.has(J)});if(q.length===0)return[];let W=q.map((U)=>{let J=j$.extname(U.path),G=j$.basename(U.path,J);return{path:U.path,baseName:G}}),V=await N6(W,Z,Q);for(let U of q){let J=V.get(U.path)||[];if(J.length>0){let G=[];for(let O of J)if(G.length<20){let M=await A6(O,U.path,Z,X);if(M)G.push({file:O,details:M});else G.push({file:O,details:{importedSymbols:[],usageContext:""}})}else G.push({file:O,details:{importedSymbols:[],usageContext:""}});let B=J.length>10?"High":J.length>3?"Medium":"Low",H=[R(U.path,`${B} blast radius: ${J.length} file(s) depend on this module`),...G.slice(0,5).map((O)=>{let M=O.details.importedSymbols?.length>0?`Imports: ${O.details.importedSymbols.slice(0,3).join(", ")}${O.details.importedSymbols.length>3?` (+${O.details.importedSymbols.length-3} more)`:""}`:"Imports module";return R(O.file,M)})],_=new Set;G.forEach((O)=>O.details.importedSymbols?.forEach((M)=>_.add(M))),K.push({type:"impact-analysis",kind:"impact-analysis",category:"impact",confidence:"medium",evidence:H,sourceFile:U.path,affectedFiles:J,importedSymbols:Array.from(_),usageContext:G[0]?.details.usageContext,blastRadius:J.length>10?"high":J.length>3?"medium":"low",tags:["impact","dependency"]})}}return K}}}var n5,L6,D6,i;var t5=x(()=>{n5=[/node_modules/,/\.d\.ts$/,/^dist\//,/^build\//,/^\.git\//],L6=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".vue",".svelte"]),D6=/\.(js|jsx|ts|tsx|mjs|cjs|mts|cts|vue|svelte)$/i;i=R6()});var n;var e5=x(()=>{n={name:"large-diff",analyze($){let Z=[],Q=$.files.length,X=0;for(let Y of $.diffs)for(let K of Y.hunks)X+=K.additions.length+K.deletions.length;if(Q>30||X>1000)Z.push({type:"large-diff",kind:"large-diff",category:"unknown",confidence:"high",evidence:[],filesChanged:Q,linesChanged:X});return Z}}});function $8($){return $==="package.json"}function T6($){return $==="package-lock.json"||$==="yarn.lock"||$==="pnpm-lock.yaml"||$==="bun.lockb"||$==="bun.lock"}function I6($){let Z=$.match(/^\s*"([^"]+)"\s*:/);return Z?Z[1]:null}function b6($){if(!/^\s*"[^"]+"\s*:\s*"/.test($))return!1;let Z=I6($);if(Z&&x6.includes(Z))return!1;return E6.some((Q)=>Q.test($))}function P6($){for(let Z of $.hunks){let Q=[...Z.additions,...Z.deletions];for(let X of Q){for(let Y of w6)if(X.includes(Y))return!0;if(b6(X))return!0}}return!1}var w6,x6,E6,t;var Z8=x(()=>{w6=['"dependencies"','"devDependencies"','"peerDependencies"','"optionalDependencies"','"bundledDependencies"','"bundleDependencies"'],x6=["name","version","description","main","module","types","typings","exports","bin","scripts","repository","keywords","author","license","bugs","homepage","funding","files","engines","os","cpu","private","publishConfig","workspaces","packageManager","type","sideEffects","browser","unpkg","jsdelivr"],E6=[/"\s*[\^~>=<]?\d+\.\d+/,/"\s*[\*x]\s*"/,/"\s*\d+\.x/,/"\s*npm:/,/"\s*git(\+https?|\+ssh)?:/,/"\s*github:/,/"\s*(file|link):/,/"\s*workspace:/,/"\s*https?:\/\//];t={name:"lockfiles",analyze($){let Z=[],Q=$.files.find((K)=>$8(K.path)),X=$.files.some((K)=>T6(K.path)),Y=!1;if(Q){let K=$.diffs.find((q)=>$8(q.path));if(K)Y=P6(K);else Y=Q.status==="added"}if(Y&&!X||!Q&&X)Z.push({type:"lockfile-mismatch",kind:"lockfile-mismatch",category:"dependencies",confidence:"high",evidence:[],manifestChanged:!!Q,lockfileChanged:X});return Z}}});function k6($){return $.includes("/tests/")||$.includes("/__tests__/")||$.includes(".test.")||$.includes(".spec.")||$.startsWith("tests/")}function v6($){return $.endsWith(".md")||$.startsWith("docs/")}function S6($){let Z=$.split("/").pop()||"";return Z==="package.json"||Z==="package-lock.json"||Z==="yarn.lock"||Z==="pnpm-lock.yaml"||Z==="bun.lockb"||Z.endsWith(".config.js")||Z.endsWith(".config.ts")||Z.endsWith(".config.mjs")||Z.endsWith(".config.cjs")||Z.endsWith(".toml")||$.split("/").length===1&&Z.startsWith(".")}var e;var Q8=x(()=>{e={name:"test-gaps",analyze($){let Z=[],Q=0,X=0,Y=[];for(let K of $.files){if(v6(K.path)||S6(K.path))continue;if(k6(K.path))X++;else Q++,Y.push(K.path)}if(Q>=3&&X===0){let K=Y.slice(0,5).map((q,W)=>R(q,W===0?`${Q} production file(s) changed with no test updates`:"No corresponding test changes"));Z.push({type:"test-gap",kind:"test-gap",category:"quality",confidence:"medium",evidence:K,prodFilesChanged:Q,testFilesChanged:X})}return Z}}});function C6($){return $.includes("/migrations/")||$.includes("/migrate/")||$.endsWith(".sql")}var q1;var X8=x(()=>{q1={name:"sql-risks",analyze($){let Z=[];for(let Q of $.diffs){if(!C6(Q.path))continue;for(let X of Q.hunks){let Y=X.additions.join(`
29
+ `);if(/\b(DROP\s+TABLE|DROP\s+COLUMN|TRUNCATE)\b/gi.test(Y)){let V=S(X.additions,200);Z.push({type:"sql-risk",kind:"sql-risk",category:"database",confidence:"high",evidence:[R(Q.path,V,{hunk:X})],file:Q.path,riskType:"destructive",details:"Contains DROP TABLE/COLUMN or TRUNCATE"});continue}if(/ALTER\s+TABLE[^;]+\b(ALTER\s+COLUMN|TYPE)\b/gi.test(Y)){let V=S(X.additions,200);Z.push({type:"sql-risk",kind:"sql-risk",category:"database",confidence:"high",evidence:[R(Q.path,V,{hunk:X})],file:Q.path,riskType:"schema_change",details:"Contains ALTER COLUMN or TYPE change"});continue}if(/(UPDATE|DELETE)\s+(?![^;\n]*\bWHERE\b)/gi.test(Y)){let V=S(X.additions,200);Z.push({type:"sql-risk",kind:"sql-risk",category:"database",confidence:"medium",evidence:[R(Q.path,V,{hunk:X})],file:Q.path,riskType:"unscoped_modification",details:"Contains UPDATE/DELETE without WHERE clause"})}}}return Z}}});function F6($){return $.includes(".github/workflows/")&&($.endsWith(".yml")||$.endsWith(".yaml"))||$===".gitlab-ci.yml"||$==="Jenkinsfile"||$==="azure-pipelines.yml"}var $1;var Y8=x(()=>{$1={name:"ci-workflows",analyze($){let Z=[],Q=new Set;for(let X of $.diffs){if(!F6(X.path))continue;let Y=!1,K=!1,q=!1;for(let W of X.hunks){let V=W.additions.join(`
30
+ `);if(!Y&&/permissions:[\s\S]{0,500}?\b(contents|id-token|actions|packages|deployments|security-events)\b\s*:\s*write/gi.test(V)){Y=!0;let B=S(W.additions,200);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"high",evidence:[R(X.path,B,{hunk:W})],file:X.path,riskType:"permissions_broadened",details:"Workflow has broadened permissions (write access)"})}if(!K&&/pull_request_target/i.test(V)){K=!0;let B=S(W.additions,200);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"high",evidence:[R(X.path,B,{hunk:W})],file:X.path,riskType:"pull_request_target",details:"Workflow uses pull_request_target event (can expose secrets)"})}if(!q&&/(curl|wget)\s+[^\s]+\s*\|\s*(sh|bash)/gi.test(V)){q=!0;let B=S(W.additions,200);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"high",evidence:[R(X.path,B,{hunk:W})],file:X.path,riskType:"remote_script_download",details:"Workflow downloads and pipes to shell (supply chain risk)"})}}if(!Q.has(X.path)&&X.hunks.length>0){Q.add(X.path);let W=S(X.hunks[0].additions,150);Z.push({type:"ci-workflow",kind:"ci-workflow",category:"ci",confidence:"medium",evidence:[R(X.path,W)],file:X.path,riskType:"pipeline_changed",details:"CI/CD pipeline configuration modified"})}}return Z}}});var U1;var K8=x(()=>{U1={name:"infra",analyze($){let Z=[],Q=[],X=[],Y=[];for(let K of $.files)if(K.path.toLowerCase().includes("dockerfile"))Q.push(K.path);else if(K.path.endsWith(".tf")||K.path.endsWith(".tfvars"))X.push(K.path);else if(K.path.includes("kubernetes/")||K.path.includes("k8s/")||K.path.endsWith(".yaml")&&(K.path.includes("deployment")||K.path.includes("service")||K.path.includes("ingress")))Y.push(K.path);if(Q.length>0)Z.push({type:"infra-change",kind:"infra-change",category:"infra",confidence:"high",evidence:[],infraType:"dockerfile",files:Q});if(X.length>0)Z.push({type:"infra-change",kind:"infra-change",category:"infra",confidence:"high",evidence:[],infraType:"terraform",files:X});if(Y.length>0)Z.push({type:"infra-change",kind:"infra-change",category:"infra",confidence:"high",evidence:[],infraType:"k8s",files:Y});return Z}}});function y6($){return $.includes("openapi")||$.includes("swagger")||$.endsWith(".proto")||$.includes("/api/")&&($.endsWith(".yaml")||$.endsWith(".yml")||$.endsWith(".json"))}var Z1;var W8=x(()=>{Z1={name:"api-contracts",analyze($){let Z=[],Q=$.files.filter((X)=>y6(X.path)).map((X)=>X.path);if(Q.length>0)Z.push({type:"api-contract-change",kind:"api-contract-change",category:"api",confidence:"high",evidence:[],files:Q});return Z}}});import{parse as m6}from"@babel/parser";import q8 from"@babel/traverse";import*as b from"@babel/types";function u6($){return $.endsWith(".tsx")||$.endsWith(".ts")}function U8($){if($==="default")return"<slot />";else if($==="boolean")return"<slot name />";else if($==="dynamic")return"<slot name={...} />";else return`<slot name="${$}" />`}function V8($,Z){let Q=[];try{let X=m6($,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"]});q8(X,{ClassDeclaration(Y){let q=(Y.node.decorators||[]).find((_)=>b.isCallExpression(_.expression)&&b.isIdentifier(_.expression.callee)&&_.expression.callee.name==="Component");if(!q)return;let W="",V=!1,U=Y.node.loc?.start.line??1;if(b.isCallExpression(q.expression)){let _=q.expression.arguments[0];if(b.isObjectExpression(_)){for(let O of _.properties)if(b.isObjectProperty(O)&&b.isIdentifier(O.key)){if(O.key.name==="tag"){if(b.isStringLiteral(O.value))W=O.value.value}else if(O.key.name==="shadow"){if(b.isBooleanLiteral(O.value))V=O.value.value}}}}if(!W)return;let J=new Map,G=new Map,B=new Map,H=new Set;for(let _ of Y.node.body.body){if(b.isClassProperty(_)||b.isClassMethod(_)){let O=_.decorators||[],M=O.find((N)=>b.isCallExpression(N.expression)&&b.isIdentifier(N.expression.callee)&&N.expression.callee.name==="Prop"||b.isIdentifier(N.expression)&&N.expression.name==="Prop");if(M&&b.isIdentifier(_.key)){let N=_.key.name,E=_.loc?.start.line??1,w,T=!1,P=!1,I;if(b.isClassProperty(_)&&_.typeAnnotation&&b.isTSTypeAnnotation(_.typeAnnotation));if(b.isCallExpression(M.expression)){let f=M.expression.arguments[0];if(b.isObjectExpression(f)){for(let j of f.properties)if(b.isObjectProperty(j)&&b.isIdentifier(j.key)){if(j.key.name==="attribute"&&b.isStringLiteral(j.value))w=j.value.value;if(j.key.name==="reflect"&&b.isBooleanLiteral(j.value))T=j.value.value;if(j.key.name==="mutable"&&b.isBooleanLiteral(j.value))P=j.value.value}}}J.set(N,{name:N,attribute:w,reflect:T,mutable:P,typeText:I,line:E})}let z=O.find((N)=>b.isCallExpression(N.expression)&&b.isIdentifier(N.expression.callee)&&N.expression.callee.name==="Event"||b.isIdentifier(N.expression)&&N.expression.name==="Event");if(z&&b.isIdentifier(_.key)){let N=_.key.name,E=N,w=_.loc?.start.line??1,T=!0,P=!0,I=!0;if(b.isCallExpression(z.expression)){let f=z.expression.arguments[0];if(b.isObjectExpression(f)){for(let j of f.properties)if(b.isObjectProperty(j)&&b.isIdentifier(j.key)){if(j.key.name==="eventName"&&b.isStringLiteral(j.value))E=j.value.value;if(j.key.name==="bubbles"&&b.isBooleanLiteral(j.value))T=j.value.value;if(j.key.name==="composed"&&b.isBooleanLiteral(j.value))P=j.value.value;if(j.key.name==="cancelable"&&b.isBooleanLiteral(j.value))I=j.value.value}}}G.set(E,{name:E,memberName:N,bubbles:T,composed:P,cancelable:I,line:w})}if(O.find((N)=>b.isCallExpression(N.expression)&&b.isIdentifier(N.expression.callee)&&N.expression.callee.name==="Method"||b.isIdentifier(N.expression)&&N.expression.name==="Method")&&b.isIdentifier(_.key)){let N=_.key.name,E=_.loc?.start.line??1;B.set(N,{name:N,line:E})}}if(b.isClassMethod(_)&&b.isIdentifier(_.key)&&_.key.name==="render")q8(_,{JSXElement(O){let M=O.node.openingElement;if(b.isJSXIdentifier(M.name)&&M.name.name==="slot"){let z="default";for(let A of M.attributes)if(b.isJSXAttribute(A)&&b.isJSXIdentifier(A.name)&&A.name.name==="name")if(b.isStringLiteral(A.value))z=A.value.value;else if(A.value===null)z="boolean";else z="dynamic";H.add(z)}}},Y.scope,Y)}Q.push({tag:W,shadow:V,file:Z,line:U,props:J,events:G,methods:B,slots:H})}})}catch(X){}return Q}var h6,q2;var J8=x(()=>{K0();h6={batchGetFileContent:z$};q2={name:"stencil",async analyze($){let Z=[],Q=$.files.filter((K)=>u6(K.path));if(Q.length===0)return[];let X=[];for(let K of Q)X.push({ref:$.base,path:K.path}),X.push({ref:$.head,path:K.path});let Y=await h6.batchGetFileContent(X);for(let K of Q){let q=`${$.base}:${K.path}`,W=`${$.head}:${K.path}`,V=Y.get(q),U=Y.get(W);if(!V&&!U)continue;let J=V?V8(V,K.path):[],G=U?V8(U,K.path):[],B=new Map(J.map((O)=>[O.tag,O])),H=new Map(G.map((O)=>[O.tag,O])),_=new Set([...B.keys(),...H.keys()]);for(let O of _){let M=B.get(O),z=H.get(O);if(M&&!z)Z.push({type:"stencil-component-change",kind:"stencil-component-change",category:"api",confidence:"high",evidence:[R(K.path,`@Component({ tag: "${O}" })`,{line:M.line})],tag:O,change:"removed",file:K.path});else if(!M&&z)Z.push({type:"stencil-component-change",kind:"stencil-component-change",category:"api",confidence:"high",evidence:[R(K.path,`@Component({ tag: "${O}" })`,{line:z.line})],tag:O,change:"added",file:K.path});else if(M&&z){if(M.shadow!==z.shadow)Z.push({type:"stencil-component-change",kind:"stencil-component-change",category:"api",confidence:"high",evidence:[R(K.path,`@Component({ tag: "${O}", shadow: ${z.shadow} })`,{line:z.line})],tag:O,change:"shadow-changed",file:K.path,fromShadow:M.shadow,toShadow:z.shadow});let A=new Set([...M.props.keys(),...z.props.keys()]);for(let T of A){let P=M.props.get(T),I=z.props.get(T);if(P&&!I)Z.push({type:"stencil-prop-change",kind:"stencil-prop-change",category:"api",confidence:"high",evidence:[R(K.path,`@Prop() ${T}`,{line:P.line})],tag:O,propName:T,change:"removed",file:K.path});else if(!P&&I)Z.push({type:"stencil-prop-change",kind:"stencil-prop-change",category:"api",confidence:"high",evidence:[R(K.path,`@Prop() ${T}`,{line:I.line})],tag:O,propName:T,change:"added",file:K.path,details:{attribute:I.attribute,reflect:I.reflect,mutable:I.mutable}});else if(P&&I){if(P.attribute!==I.attribute||P.reflect!==I.reflect||P.mutable!==I.mutable)Z.push({type:"stencil-prop-change",kind:"stencil-prop-change",category:"api",confidence:"high",evidence:[R(K.path,`@Prop() ${T}`,{line:I.line})],tag:O,propName:T,change:"changed",file:K.path,details:{attribute:I.attribute,reflect:I.reflect,mutable:I.mutable}})}}let N=new Set([...M.events.keys(),...z.events.keys()]);for(let T of N){let P=M.events.get(T),I=z.events.get(T);if(P&&!I)Z.push({type:"stencil-event-change",kind:"stencil-event-change",category:"api",confidence:"high",evidence:[R(K.path,`@Event() ${P.memberName}`,{line:P.line})],tag:O,eventName:T,change:"removed",file:K.path});else if(!P&&I)Z.push({type:"stencil-event-change",kind:"stencil-event-change",category:"api",confidence:"high",evidence:[R(K.path,`@Event() ${I.memberName}`,{line:I.line})],tag:O,eventName:T,change:"added",file:K.path,details:{bubbles:I.bubbles,composed:I.composed,cancelable:I.cancelable}});else if(P&&I){if(P.bubbles!==I.bubbles||P.composed!==I.composed||P.cancelable!==I.cancelable)Z.push({type:"stencil-event-change",kind:"stencil-event-change",category:"api",confidence:"high",evidence:[R(K.path,`@Event() ${I.memberName}`,{line:I.line})],tag:O,eventName:T,change:"changed",file:K.path,details:{bubbles:I.bubbles,composed:I.composed,cancelable:I.cancelable}})}}let E=new Set([...M.methods.keys(),...z.methods.keys()]);for(let T of E){let P=M.methods.get(T),I=z.methods.get(T);if(P&&!I)Z.push({type:"stencil-method-change",kind:"stencil-method-change",category:"api",confidence:"high",evidence:[R(K.path,`@Method() ${T}`,{line:P.line})],tag:O,methodName:T,change:"removed",file:K.path});else if(!P&&I)Z.push({type:"stencil-method-change",kind:"stencil-method-change",category:"api",confidence:"high",evidence:[R(K.path,`@Method() ${T}`,{line:I.line})],tag:O,methodName:T,change:"added",file:K.path})}let w=new Set([...M.slots,...z.slots]);for(let T of w){let P=M.slots.has(T),I=z.slots.has(T);if(P&&!I)Z.push({type:"stencil-slot-change",kind:"stencil-slot-change",category:"api",confidence:"high",evidence:[R(K.path,U8(T),{line:M.line})],tag:O,slotName:T,change:"removed",file:K.path});else if(!P&&I)Z.push({type:"stencil-slot-change",kind:"stencil-slot-change",category:"api",confidence:"high",evidence:[R(K.path,U8(T),{line:z.line})],tag:O,slotName:T,change:"added",file:K.path})}}}}return Z}}});function G8($){if(!$.startsWith("app/")&&!$.startsWith("src/app/"))return!1;return l6($)}function l6($){let Z=$.split("/").pop()??"";return Object.keys(B8).includes(Z)}function f6($){let Z=$.split("/").pop()??"";return B8[Z]??"unknown"}function p6($){let Z=$.replace(/^src\/app/,"").replace(/^app/,""),Q=Z.split("/");if(Q.pop(),Z=Q.join("/"),Z=Z.replace(/\/\([^)]+\)/g,""),Z===""||Z==="/")return"/";if(!Z.startsWith("/"))Z="/"+Z;if(Z.length>1&&Z.endsWith("/"))Z=Z.slice(0,-1);return Z}function d6($){let Z=new Set,Q=v($).join(`
31
+ `),X,Y=new RegExp(c6.source,"g");while((X=Y.exec(Q))!==null)Z.add(X[1]);return Array.from(Z).sort()}function r6($){return g6.includes($)}var B8,g6,c6,U2;var V2=x(()=>{B8={"page.tsx":"page","page.ts":"page","page.jsx":"page","page.js":"page","layout.tsx":"layout","layout.ts":"layout","layout.jsx":"layout","layout.js":"layout","loading.tsx":"page","loading.ts":"page","loading.jsx":"page","loading.js":"page","error.tsx":"error","error.ts":"error","error.jsx":"error","error.js":"error","not-found.tsx":"error","not-found.ts":"error","not-found.jsx":"error","not-found.js":"error","route.ts":"endpoint","route.tsx":"endpoint","route.js":"endpoint","route.jsx":"endpoint"},g6=["middleware.ts","middleware.js","middleware.tsx","middleware.jsx","src/middleware.ts","src/middleware.js","src/middleware.tsx","src/middleware.jsx"],c6=/export\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s*\(/g;U2={name:"next-routes",analyze($){let Z=[],Q=new Map;for(let X of $.files){if(G8(X.path))Q.set(X.path,{status:X.status});if(r6(X.path)){let Y=$.diffs.find((W)=>W.path===X.path),K=[];if(Y&&Y.hunks.length>0){let W=v(Y);if(W.length>0){let V=S(W);if(V)K.push(R(X.path,V))}}let q={type:"security-file",kind:"security-file",category:"routes",confidence:"high",evidence:K,files:[X.path],reasons:["middleware"]};Z.push(q)}}for(let X of $.diffs)if(G8(X.path)){let Y=Q.get(X.path);if(Y)Y.diff=X;else Q.set(X.path,{diff:X,status:X.status})}for(let[X,{diff:Y,status:K}]of Q){let q=p6(X),W=f6(X),V=[];if(Y&&Y.hunks.length>0){let J=v(Y);if(J.length>0){let G=S(J);if(G)V.push(R(X,G))}}let U={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:V,routeId:q,file:X,change:K,routeType:W};if(W==="endpoint"&&Y){let J=d6(Y);if(J.length>0){U.methods=J;let G=J.map((B)=>`export function ${B}`).join(", ");if(!V.length)V.push(R(X,G))}}Z.push(U)}return Z}}});function s6($){return a6.some((Z)=>Z.test($))}function o6($){let Z=[],Q=$.join(`
32
+ `),X=Q.match(/type\s+(\w+)\s*[{@]/g);if(X)for(let W of X){let V=W.match(/type\s+(\w+)/)?.[1];if(V)Z.push(`Removed type: ${V}`)}let Y=Q.match(/enum\s+(\w+)\s*{/g);if(Y)for(let W of Y){let V=W.match(/enum\s+(\w+)/)?.[1];if(V)Z.push(`Removed enum: ${V}`)}let K=Q.match(/interface\s+(\w+)\s*[{@]/g);if(K)for(let W of K){let V=W.match(/interface\s+(\w+)/)?.[1];if(V)Z.push(`Removed interface: ${V}`)}let q=Q.match(/input\s+(\w+)\s*{/g);if(q)for(let W of q){let V=W.match(/input\s+(\w+)/)?.[1];if(V)Z.push(`Removed input type: ${V}`)}return Z}function i6($){let Z=[],Q=$.join(`
33
+ `),X=Q.match(/type\s+(\w+)\s*[{@]/g);if(X)for(let K of X){let q=K.match(/type\s+(\w+)/)?.[1];if(q&&!["Query","Mutation","Subscription"].includes(q))Z.push(`Added type: ${q}`)}let Y=Q.match(/enum\s+(\w+)\s*{/g);if(Y)for(let K of Y){let q=K.match(/enum\s+(\w+)/)?.[1];if(q)Z.push(`Added enum: ${q}`)}return Z}var a6,F$;var J2=x(()=>{a6=[/\.graphql$/,/\.gql$/,/schema\.graphqls$/,/schema\.sdl$/];F$={name:"graphql",analyze($){let Z=[];for(let Q of $.diffs){if(!s6(Q.path))continue;let X=v(Q),Y=L1(Q),K=o6(Y),q=i6(X),W=K.length>0,V=q.length>0,U=Y.length>0,J=W?S(Y):S(X),G="medium";if(W)G="high";else if(V&&!U)G="low";let B={type:"graphql-change",kind:"graphql-change",category:"api",confidence:G,evidence:[R(Q.path,J)],file:Q.path,status:Q.status,isBreaking:W,breakingChanges:K.slice(0,5),addedElements:q.slice(0,5)};Z.push(B)}return Z}}});function $3($){return n6.some((Z)=>Z.test($))}function Z3($,Z){let Q=[],X=[],Y=[],K=/"(\w+)":\s*/,q=new Set,W=new Set;for(let V of $){let U=V.match(K);if(U)q.add(U[1])}for(let V of Z){let U=V.match(K);if(U)W.add(U[1])}for(let V of q)if(W.has(V))Y.push(V);else Q.push(V);for(let V of W)if(!q.has(V))X.push(V);return{added:Q,removed:X,modified:Y}}function Q3($,Z,Q){for(let X of[...$,...Z,...Q])if(t6.has(X))return!0;return!1}function X3($,Z,Q){let X=[],Y=[...$,...Z,...Q];for(let K of Y)if(e6.has(K))if($.includes(K))X.push(`Added ${K}`);else if(Z.includes(K))X.push(`Removed ${K}`);else X.push(`Modified ${K}`);return X}var n6,t6,e6,D1;var l1=x(()=>{n6=[/^tsconfig\.json$/,/^tsconfig\.\w+\.json$/,/\/tsconfig\.json$/,/\/tsconfig\.\w+\.json$/],t6=new Set(["strict","strictNullChecks","strictFunctionTypes","strictBindCallApply","strictPropertyInitialization","noImplicitAny","noImplicitThis","noImplicitReturns","noUncheckedIndexedAccess","target","module","moduleResolution","lib","jsx","esModuleInterop","allowSyntheticDefaultImports","skipLibCheck","isolatedModules","verbatimModuleSyntax","baseUrl","paths","outDir","rootDir","declaration","declarationMap","sourceMap","composite","incremental","emitDecoratorMetadata","experimentalDecorators"]),e6=new Set(["strict","strictNullChecks","strictFunctionTypes","strictBindCallApply","strictPropertyInitialization","noImplicitAny","noImplicitThis","noImplicitReturns","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","exactOptionalPropertyTypes"]);D1={name:"typescript-config",analyze($){let Z=[];for(let Q of $.diffs){if(!$3(Q.path))continue;let X=v(Q),Y=L1(Q),{added:K,removed:q,modified:W}=Z3(X,Y);if(K.length===0&&q.length===0&&W.length===0){if(X.length>0||Y.length>0){let H={type:"typescript-config",kind:"typescript-config",category:"config_env",confidence:"low",evidence:[R(Q.path,S(X.length>0?X:Y))],file:Q.path,status:Q.status,isBreaking:!1,changedOptions:{added:[],removed:[],modified:[]},strictnessChanges:[]};Z.push(H)}continue}let V=Q3(K,q,W),U=X3(K,q,W),J=V?"high":"medium",G=S(X.length>0?X:Y),B={type:"typescript-config",kind:"typescript-config",category:"config_env",confidence:J,evidence:[R(Q.path,G)],file:Q.path,status:Q.status,isBreaking:V,changedOptions:{added:K,removed:q,modified:W},strictnessChanges:U};Z.push(B)}return Z}}});function U3($){return Y3.some((Z)=>Z.test($))}function V3($){return K3.some((Z)=>Z.test($))}function J3($){let Z=new Set,Q=$.join(`
34
+ `);for(let X of W3)if(new RegExp(`\\b${X}\\s*[:{]`,"i").test(Q))Z.add(X);for(let X of q3)if(new RegExp(`\\b${X}\\s*[:{]`,"i").test(Q))Z.add(`theme.${X}`);return Array.from(Z)}function G3($,Z){let Q=[],X=$.join(`
35
+ `),Y=Z.join(`
36
+ `);if(/\bcontent\s*[:{]/.test(Y)||/\bcontent\s*[:{]/.test(X)){if(Z.length>0)Q.push("Content paths modified (may affect CSS purging)")}if(/\bprefix\s*[:{]/.test(Y)&&/\bprefix\s*[:{]/.test(X))Q.push("Class prefix changed (requires updating all class names)");if(/colors\s*[:{]/.test(Y))Q.push("Theme colors modified (may break existing color classes)");if(/screens\s*[:{]/.test(Y))Q.push("Screen breakpoints modified (may affect responsive design)");if(/plugins\s*[:{]/.test(Y)&&Z.some((K)=>K.includes("require(")))Q.push("Plugins removed (may remove utility classes)");if(/darkMode\s*[:{]/.test(Y)||/darkMode\s*[:{]/.test(X))Q.push("Dark mode configuration changed");return{isBreaking:Q.length>0,reasons:Q}}var Y3,K3,W3,q3,N1;var f1=x(()=>{Y3=[/^tailwind\.config\.(js|cjs|mjs|ts)$/,/\/tailwind\.config\.(js|cjs|mjs|ts)$/],K3=[/^postcss\.config\.(js|cjs|mjs)$/,/\/postcss\.config\.(js|cjs|mjs)$/],W3=["theme","content","plugins","presets","prefix","important","darkMode","safelist"],q3=["colors","spacing","screens","fontFamily","fontSize","fontWeight","extend","borderRadius","boxShadow","animation","keyframes"];N1={name:"tailwind",analyze($){let Z=[];for(let Q of $.diffs){let X=U3(Q.path),Y=V3(Q.path);if(!X&&!Y)continue;let K=v(Q),q=L1(Q),W=J3([...K,...q]),{isBreaking:V,reasons:U}=G3(K,q),J=V?"high":W.length>0?"medium":"low",G=S(K.length>0?K:q),B={type:"tailwind-config",kind:"tailwind-config",category:"config_env",confidence:J,evidence:[R(Q.path,G)],file:Q.path,status:Q.status,configType:X?"tailwind":"postcss",isBreaking:V,affectedSections:W,breakingReasons:U};Z.push(B)}return Z}}});function H3($){for(let[Z,Q]of Object.entries(B3))if(Q.some((X)=>X.test($))){if(Z==="npm"&&!$.endsWith("package.json"))continue;return Z}return null}function _3($,Z){let Q=[...$,...Z].join(`
37
+ `);return/["']workspaces["']/.test(Q)}function M3($,Z){let Q=O3[Z]||[],X=[],Y=$.join(`
38
+ `);for(let K of Q)if(new RegExp(`["']?${K}["']?\\s*[:{[]`,"i").test(Y))X.push(K);return X}function z3($,Z,Q){let X=[],Y=Z.join(`
39
+ `),K=Q.join(`
40
+ `);switch($){case"turborepo":if(/pipeline|tasks/.test(K))X.push("Build pipeline configuration changed");if(/cache\s*[:=]\s*false/.test(Y))X.push("Caching disabled for tasks");if(/globalDependencies/.test(Y)||/globalDependencies/.test(K))X.push("Global dependencies changed (affects cache invalidation)");break;case"pnpm":if(/packages/.test(K))X.push("Workspace packages configuration changed");break;case"lerna":if(/version/.test(Y)&&/independent/.test(Y))X.push("Switching to independent versioning");if(/npmClient/.test(Y)||/npmClient/.test(K))X.push("npm client configuration changed");break;case"nx":if(/targetDefaults/.test(K))X.push("Default target configuration changed");if(/plugins/.test(Y)||/plugins/.test(K))X.push("Nx plugins configuration changed");break;case"yarn":if(/nodeLinker/.test(Y)||/nodeLinker/.test(K))X.push("Node linker strategy changed (affects dependency resolution)");break;case"npm":if(/workspaces/.test(K))X.push("Workspace packages configuration changed");break;case"changesets":if(/baseBranch/.test(Y)||/baseBranch/.test(K))X.push("Base branch for changesets modified");if(/access/.test(Y))X.push("Package publish access level changed");break}return X}var B3,O3,G2;var B2=x(()=>{B3={turborepo:[/^turbo\.json$/],pnpm:[/^pnpm-workspace\.yaml$/,/^pnpm-workspace\.yml$/],lerna:[/^lerna\.json$/],nx:[/^nx\.json$/,/^project\.json$/],yarn:[/^\.yarnrc\.yml$/,/^\.yarnrc$/],npm:[/^package\.json$/],changesets:[/^\.changeset\/config\.json$/]},O3={turborepo:["pipeline","globalDependencies","globalEnv","tasks"],pnpm:["packages"],lerna:["packages","version","npmClient","useWorkspaces"],nx:["targetDefaults","namedInputs","plugins","defaultProject"],yarn:["nodeLinker","enableGlobalCache","nmMode"],npm:["workspaces"],changesets:["baseBranch","access","changelog"]};G2={name:"monorepo",analyze($){let Z=[];for(let Q of $.diffs){let X=H3(Q.path);if(!X)continue;let Y=v(Q),K=L1(Q);if(X==="npm"&&!_3(Y,K))continue;let q=M3([...Y,...K],X),W=z3(X,Y,K);if(q.length===0&&W.length===0)continue;let U=W.length>0?"high":"medium",J=S(Y.length>0?Y:K),G={type:"monorepo-config",kind:"monorepo-config",category:"config_env",confidence:U,evidence:[R(Q.path,J)],file:Q.path,status:Q.status,tool:X,affectedFields:q,impacts:W};Z.push(G)}return Z}}});function U0($,Z=""){if(!$)return[];if(typeof $==="string")return[Z||"."];if(typeof $==="object"){let Q=[];for(let[X,Y]of Object.entries($))if(X.startsWith("."))Q.push(...U0(Y,X));else if(typeof Y==="string"||typeof Y==="object")Q.push(...U0(Y,Z));return[...new Set(Q)]}return[]}function j3($,Z){let Q=U0($),X=U0(Z),Y=new Set(Q),K=new Set(X),q=X.filter((V)=>!Y.has(V)),W=Q.filter((V)=>!K.has(V));return{added:q,removed:W,hasExportsField:{base:$!==void 0&&$!==null,head:Z!==void 0&&Z!==null}}}function L3($,Z){let Q=["main","module","types","typings","browser"],X=[];for(let Y of Q){let K=$?.[Y],q=Z?.[Y];if(K!==q)X.push({field:Y,from:K,to:q})}return X}function D3($,Z){let Q=$?.bin,X=Z?.bin,Y=(W)=>{if(typeof W==="string")return["(default)"];if(typeof W==="object"&&W!==null)return Object.keys(W);return[]},K=new Set(Y(Q)),q=new Set(Y(X));return{added:[...q].filter((W)=>!K.has(W)),removed:[...K].filter((W)=>!q.has(W))}}var O2;var H2=x(()=>{O2={name:"package-exports",analyze($){let Z=[],Q=$.basePackageJson,X=$.headPackageJson;if(!Q&&!X)return Z;let Y=Q?.exports,K=X?.exports,q=j3(Y??null,K??null),W=L3(Q,X),V=D3(Q,X),U=q.removed.length>0,J=V.removed.length>0,G=W.some((N)=>N.from!==void 0&&N.to===void 0),B=U||J||G,H=q.added.length>0||q.removed.length>0,_=W.length>0,O=V.added.length>0||V.removed.length>0;if(!H&&!_&&!O)return Z;let M="medium";if(B)M="high";else if(q.added.length>0||V.added.length>0)M="low";let z=[];if(q.removed.length>0)z.push(`Removed exports: ${q.removed.slice(0,3).join(", ")}`);if(q.added.length>0)z.push(`Added exports: ${q.added.slice(0,3).join(", ")}`);if(W.length>0)z.push(`Changed fields: ${W.map((N)=>N.field).join(", ")}`);if(V.removed.length>0)z.push(`Removed bins: ${V.removed.join(", ")}`);if(V.added.length>0)z.push(`Added bins: ${V.added.join(", ")}`);let A={type:"package-exports",kind:"package-exports",category:"api",confidence:M,evidence:[R("package.json",z.join("; "))],isBreaking:B,addedExports:q.added,removedExports:q.removed,legacyFieldChanges:W,binChanges:{added:V.added,removed:V.removed}};return Z.push(A),Z}}});function T3($){return O8.test($)}function H8($){return N3.test($)}function _8($){return A3.test($)}function w3($){return R3.some((Z)=>Z.test($))}function x3($){let Z=$.match(O8);if(!Z)return $;let Q=Z[2];return Q=Q.replace(/\.(get|post|put|delete|patch)$/i,""),Q=Q.replace(/\/index$/,"").replace(/^index$/,"").replace(/\[\.\.\.(\w+)\]/g,":$1*").replace(/\[(\w+)\]/g,":$1"),"/"+Q}function E3($){let Z=[],Q=$.match(/\.(\w+)\.(ts|js)$/);if(Q){let X=Q[1].toUpperCase();if(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].includes(X))Z.push(X)}if(Z.length===0)Z.push("*");return Z}function I3($){if(H8($))return"endpoint";if(_8($))return"layout";if($.includes("error.vue")||$.includes("404.vue")||$.includes("500.vue"))return"error";return"page"}var O8,N3,A3,R3,_2;var M2=x(()=>{O8=/^(pages|src\/pages)\/(.+)\.(vue|ts|tsx|js|jsx)$/,N3=/^server\/(api|routes|middleware)\/(.+)\.(ts|js)$/,A3=/^(layouts|src\/layouts)\/(.+)\.vue$/,R3=[/router\.(ts|js)$/,/routes\.(ts|js)$/,/router\/index\.(ts|js)$/];_2={name:"vue-routes",analyze($){let Z=[];for(let Q of $.files){let X=T3(Q.path),Y=H8(Q.path),K=_8(Q.path),q=w3(Q.path);if(!X&&!Y&&!K&&!q)continue;if(q){let O=$.diffs.find((N)=>N.path===Q.path),M=O?v(O):[],z=S(M),A={type:"route-change",kind:"route-change",category:"routes",confidence:"medium",evidence:[R(Q.path,z||"Vue Router config changed")],routeId:"vue-router-config",file:Q.path,change:Q.status,routeType:"unknown"};Z.push(A);continue}let W=X?x3(Q.path):Q.path,V=I3(Q.path),U=Y?E3(Q.path):void 0,J=$.diffs.find((O)=>O.path===Q.path),G=J?v(J):[],B=S(G),H=[];if(B)H.push(R(Q.path,B));let _={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:H,routeId:W,file:Q.path,change:Q.status,routeType:V,methods:U};Z.push(_)}return Z}}});function v3($){return z2.test($)}function M8($){return z2.test($)&&/\.(ts|js)$/.test($)}function z8($){return b3.test($)}function S3($){return P3.test($)}function C3($){return k3.test($)}function F3($){let Z=$.match(z2);if(!Z)return $;let Q=Z[1];return Q=Q.replace(/\.(astro|md|mdx|html|ts|js)$/,""),Q=Q.replace(/\/index$/,"").replace(/^index$/,"").replace(/\[\.\.\.(\w+)\]/g,":$1*").replace(/\[(\w+)\]/g,":$1"),"/"+Q}function y3($){let Z=[],Q=$.join(`
41
+ `),X=[{pattern:/export\s+(const|function|async function)\s+GET\b/,method:"GET"},{pattern:/export\s+(const|function|async function)\s+POST\b/,method:"POST"},{pattern:/export\s+(const|function|async function)\s+PUT\b/,method:"PUT"},{pattern:/export\s+(const|function|async function)\s+DELETE\b/,method:"DELETE"},{pattern:/export\s+(const|function|async function)\s+PATCH\b/,method:"PATCH"},{pattern:/export\s+(const|function|async function)\s+ALL\b/,method:"*"}];for(let{pattern:Y,method:K}of X)if(Y.test(Q))Z.push(K);return Z}function m3($){if(z8($))return"layout";if(M8($))return"endpoint";if($.includes("404.")||$.includes("500."))return"error";return"page"}var z2,b3,P3,k3,j2;var L2=x(()=>{z2=/^src\/pages\/(.+)\.(astro|md|mdx|html|ts|js)$/,b3=/^src\/layouts\/(.+)\.astro$/,P3=/^src\/content\/(.+)\.(md|mdx|json|yaml|yml)$/,k3=/^astro\.config\.(mjs|ts|js)$/;j2={name:"astro-routes",analyze($){let Z=[];for(let Q of $.files){let X=v3(Q.path),Y=z8(Q.path),K=S3(Q.path),q=C3(Q.path);if(!X&&!Y&&!K&&!q)continue;let W=$.diffs.find((M)=>M.path===Q.path),V=W?v(W):[],U=S(V);if(q){let M={type:"route-change",kind:"route-change",category:"routes",confidence:"medium",evidence:[R(Q.path,U||"Astro config changed")],routeId:"astro-config",file:Q.path,change:Q.status,routeType:"unknown"};Z.push(M);continue}if(K){let M={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:U?[R(Q.path,U)]:[],routeId:Q.path.replace(/^src\/content\//,"/content/"),file:Q.path,change:Q.status,routeType:"page",tags:["content-collection"]};Z.push(M);continue}let J=X?F3(Q.path):Q.path,G=m3(Q.path),B=M8(Q.path)?y3(V):[],H=B.length>0?B:void 0,_=[];if(U)_.push(R(Q.path,U));let O={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:_,routeId:J,file:Q.path,change:Q.status,routeType:G,methods:H};Z.push(O)}return Z}}});function u3($){let Z=$.split("/").pop()??"";return j8.test(Z)||L8.test(Z)||D8.test(Z)||N8.test(Z)||A8.test(Z)}function g3($){let Z=$.split("/").pop()??"";if(j8.test(Z))return"requirements";if(L8.test(Z))return"pyproject";if(D8.test(Z))return"setup";if(N8.test(Z))return"pipfile";if(A8.test(Z))return"poetry";return"unknown"}function R8($){let Z=$.trim();if(!Z||Z.startsWith("#")||Z.startsWith("-"))return null;if(Z.startsWith("-r "))return null;let Q=Z.match(/^([a-zA-Z0-9_-]+)(?:\[[^\]]+\])?(?:[><=~!]+(.+))?/);if(Q)return{name:Q[1].toLowerCase(),version:Q[2]?.trim()};return null}function T8($){let Z=$.match(/["']([a-zA-Z0-9_-]+)(?:\[[^\]]+\])?(?:[><=~!]+([^"']+))?["']/);if(Z)return{name:Z[1].toLowerCase(),version:Z[2]?.trim()};let Q=$.match(/^([a-zA-Z0-9_-]+)\s*=/);if(Q)return{name:Q[1].toLowerCase(),version:void 0};return null}function c3($,Z){let Q=v($),X=[];for(let Y of Q){let K=null;if(Z==="requirements")K=R8(Y);else if(Z==="pyproject"||Z==="pipfile"||Z==="poetry")K=T8(Y);if(K)X.push(K)}return X}function l3($,Z){let Q=L1($),X=[];for(let Y of Q){let K=null;if(Z==="requirements")K=R8(Y);else if(Z==="pyproject"||Z==="pipfile"||Z==="poetry")K=T8(Y);if(K)X.push(K)}return X}var j8,L8,D8,N8,A8,h3,D2;var w8=x(()=>{j8=/requirements.*\.txt$/,L8=/pyproject\.toml$/,D8=/^setup\.(py|cfg)$/,N8=/^Pipfile(\.lock)?$/,A8=/^poetry\.lock$/,h3={"django-allauth":"auth","python-social-auth":"auth",authlib:"auth",oauthlib:"auth","python-jose":"auth",pyjwt:"auth",passlib:"auth","argon2-cffi":"auth",bcrypt:"auth",django:"database",sqlalchemy:"database",alembic:"database",psycopg2:"database","psycopg2-binary":"database",asyncpg:"database",pymysql:"database",mysqlclient:"database",pymongo:"database",motor:"database",redis:"database",aioredis:"database","tortoise-orm":"database",peewee:"database",sqlmodel:"database",databases:"database",prisma:"database",numpy:"native",pandas:"native",scipy:"native",pillow:"native","opencv-python":"native",tensorflow:"native",torch:"native",cryptography:"native",pycryptodome:"native",pynacl:"native",stripe:"payment",braintree:"payment",paypalrestsdk:"payment"};D2={name:"python-dependencies",analyze($){let Z=[];for(let Q of $.files){if(!u3(Q.path))continue;let X=$.diffs.find((K)=>K.path===Q.path),Y=g3(Q.path);if(X){let K=c3(X,Y),q=l3(X,Y),W=new Set(q.map((U)=>U.name)),V=new Set(K.map((U)=>U.name));for(let U of K){let J=W.has(U.name),G=J?q.find((M)=>M.name===U.name):void 0,B="new";if(J&&G?.version&&U.version){let M=parseInt(G.version.match(/(\d+)/)?.[1]??"0",10);if(parseInt(U.version.match(/(\d+)/)?.[1]??"0",10)>M)B="major";else B="minor"}else if(J)B="unknown";let H=h3[U.name],O=v(X).find((M)=>M.toLowerCase().includes(U.name))??U.name;Z.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[R(Q.path,O)],name:U.name,section:"dependencies",from:G?.version,to:U.version,impact:B,riskCategory:H})}for(let U of q){if(V.has(U.name))continue;let G=L1(X).find((B)=>B.toLowerCase().includes(U.name))??U.name;Z.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"high",evidence:[R(Q.path,G)],name:U.name,section:"dependencies",from:U.version,to:void 0,impact:"removed"})}}else if(Q.status==="added"||Q.status==="deleted")Z.push({type:"dependency-change",kind:"dependency-change",category:"dependencies",confidence:"medium",evidence:[R(Q.path,`${Y} file ${Q.status}`)],name:Q.path,section:"dependencies",impact:Q.status==="added"?"new":"removed"})}return Z}}});function x8($,Z){let Q=$.split("/").pop()??"";if(/urls\.py$/.test(Q))return"django";if(Z.includes("from fastapi")||Z.includes("import fastapi")||Z.includes("APIRouter"))return"fastapi";if(Z.includes("from django")||Z.includes("urlpatterns"))return"django";if(Z.includes("from flask")||Z.includes("Flask(")||Z.includes("Blueprint("))return"flask";for(let X of k8)if(X.test(Q))return"django";for(let X of P8)if(X.test(Q))return"fastapi";for(let X of v8)if(X.test(Q))return"flask";return null}function E8($){if(!$.endsWith(".py"))return!1;let Z=$.split("/").pop()??"";return[...P8,...k8,...v8].some((X)=>X.test(Z))}function a3($){let Z=[],Q=new RegExp(p3.source,"gi"),X;while((X=Q.exec($))!==null){let Y=X[1].toLowerCase(),K=X[2],q=Y==="api_route"?["GET"]:[Y.toUpperCase()];Z.push({path:K,methods:q})}return Z}function s3($){let Z=[],Q=new RegExp(d3.source,"gi"),X;while((X=Q.exec($))!==null){let Y=X[1];Z.push({path:Y,methods:[]})}return Z}function o3($){let Z=[],Q=new RegExp(r3.source,"gi"),X;while((X=Q.exec($))!==null){let Y=X[1],K=X[2],q=["GET"];if(K)q=K.replace(/["']/g,"").split(",").map((W)=>W.trim().toUpperCase()).filter((W)=>W.length>0);Z.push({path:Y,methods:q})}return Z}function I8($,Z){switch(Z){case"fastapi":return a3($);case"django":return s3($);case"flask":return o3($)}}function b8($,Z){return"endpoint"}function N2($,Z){let Q=$;if(Z==="django")Q=Q.replace(/^\^/,"").replace(/\$$/,""),Q=Q.replace(/\(\?P<(\w+)>[^)]+\)/g,":{$1}");if(!Q.startsWith("/"))Q="/"+Q;if(Q.length>1&&Q.endsWith("/"))Q=Q.slice(0,-1);return Q}var f3,p3,d3,r3,P8,k8,v8,A2;var S8=x(()=>{f3=["get","post","put","patch","delete","head","options"],p3=new RegExp(`@\\w+\\.(${f3.join("|")}|api_route)\\s*\\(\\s*["']([^"']+)["']`,"gi"),d3=/(?:path|re_path|url)\s*\(\s*(?:r)?["']([^"']+)["']/gi,r3=/@\w+\.route\s*\(\s*["']([^"']+)["'](?:.*?methods\s*=\s*\[([^\]]+)\])?/gi,P8=[/routers?\.py$/,/endpoints?\.py$/,/api\.py$/,/main\.py$/,/app\.py$/,/routes?\.py$/],k8=[/urls\.py$/,/views\.py$/],v8=[/views?\.py$/,/routes?\.py$/,/app\.py$/,/api\.py$/,/__init__\.py$/];A2={name:"python-routes",analyze($){let Z=[],Q=new Map;for(let X of $.files)if(E8(X.path))Q.set(X.path,{status:X.status});for(let X of $.diffs)if(E8(X.path)){let Y=Q.get(X.path);if(Y)Y.diff=X;else Q.set(X.path,{diff:X,status:X.status})}for(let[X,{diff:Y}]of Q){if(!Y)continue;let K=v(Y),q=L1(Y),W=K.join(`
42
+ `),V=q.join(`
43
+ `),U=x8(X,W)??x8(X,V);if(!U)continue;let J=I8(W,U),G=I8(V,U),B=new Set;for(let H of J){let _=N2(H.path,U);if(B.has(_))continue;B.add(_);let M=G.some((E)=>N2(E.path,U)===_)?"modified":"added",z=[],A=K.find((E)=>E.includes(H.path));if(A)z.push(R(X,A));let N={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:z,routeId:_,file:X,change:M,routeType:b8(U,H.path),methods:H.methods.length>0?H.methods:void 0};Z.push(N)}for(let H of G){let _=N2(H.path,U);if(B.has(_))continue;B.add(_);let O=[],M=q.find((A)=>A.includes(H.path));if(M)O.push(R(X,M));let z={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:O,routeId:_,file:X,change:"deleted",routeType:b8(U,H.path),methods:H.methods.length>0?H.methods:void 0};Z.push(z)}}return Z}}});function e3($){return i3.some((Z)=>Z.test($))}function $7($){return n3.test($)}function Z7($){let Z=[];for(let{pattern:Q,description:X}of F8)if(Q.test($))Z.push({description:X});return Z}function Q7($){let Z=[];for(let{pattern:Q,description:X}of t3)if(Q.test($))Z.push({description:X});return Z}function C8($,Z){let Q=[],X=[],Y=!1,K=!1;for(let q of $){let W=Z.diffs.find((B)=>B.path===q);if(!W)continue;let V=v(W),U=V.join(`
44
+ `),J=Z7(U);for(let{description:B}of J){Y=!0,Q.push(`${B} detected in ${q}`);let H=V.find((_)=>F8.some((O)=>O.pattern.test(_)));if(H)X.push({file:q,excerpt:H.trim()})}let G=Q7(U);for(let{description:B}of G)if(K=!0,!Y)Q.push(`${B} detected in ${q}`)}if(Y)return{risk:"high",reasons:Q,evidence:X};if(K)return{risk:"medium",reasons:Q.length>0?Q:["Schema changes detected"],evidence:X};return{risk:"low",reasons:["Migration files changed"],evidence:X}}var i3,n3,F8,t3,R2;var y8=x(()=>{i3=[/alembic\/versions\/.*\.py$/,/migrations\/versions\/.*\.py$/,/db\/versions\/.*\.py$/],n3=/\/migrations\/\d{4}_.*\.py$/,F8=[{pattern:/op\.drop_table\s*\(/i,description:"drop_table"},{pattern:/op\.drop_column\s*\(/i,description:"drop_column"},{pattern:/op\.drop_index\s*\(/i,description:"drop_index"},{pattern:/op\.drop_constraint\s*\(/i,description:"drop_constraint"},{pattern:/op\.execute\s*\(\s*["'].*DROP/i,description:"raw DROP SQL"},{pattern:/op\.execute\s*\(\s*["'].*TRUNCATE/i,description:"raw TRUNCATE SQL"},{pattern:/op\.execute\s*\(\s*["'].*DELETE\s+FROM\s+\w+\s*["']\s*\)/i,description:"raw DELETE without WHERE"},{pattern:/DeleteModel\s*\(/i,description:"Django DeleteModel"},{pattern:/RemoveField\s*\(/i,description:"Django RemoveField"},{pattern:/AlterField.*null\s*=\s*False/i,description:"Django make field non-nullable"},{pattern:/migrations\.RunSQL\s*\(.*DROP/i,description:"Django raw DROP SQL"},{pattern:/migrations\.RunSQL\s*\(.*TRUNCATE/i,description:"Django raw TRUNCATE SQL"}],t3=[{pattern:/op\.alter_column\s*\(/i,description:"alter_column"},{pattern:/op\.create_table\s*\(/i,description:"create_table"},{pattern:/op\.add_column\s*\(/i,description:"add_column"},{pattern:/op\.create_index\s*\(/i,description:"create_index"},{pattern:/op\.create_foreign_key\s*\(/i,description:"create_foreign_key"},{pattern:/op\.create_unique_constraint\s*\(/i,description:"create_unique_constraint"},{pattern:/CreateModel\s*\(/i,description:"Django CreateModel"},{pattern:/AddField\s*\(/i,description:"Django AddField"},{pattern:/AlterField\s*\(/i,description:"Django AlterField"},{pattern:/RenameField\s*\(/i,description:"Django RenameField"},{pattern:/RenameModel\s*\(/i,description:"Django RenameModel"},{pattern:/AddIndex\s*\(/i,description:"Django AddIndex"},{pattern:/AddConstraint\s*\(/i,description:"Django AddConstraint"}];R2={name:"python-migrations",analyze($){let Z=[],Q=[],X=[];for(let Y of $.files)if(e3(Y.path))Q.push(Y.path);else if($7(Y.path))X.push(Y.path);if(Q.length>0){let{risk:Y,reasons:K,evidence:q}=C8(Q,$),W=q.map((U)=>R(U.file,U.excerpt)),V={type:"python-migration",kind:"python-migration",category:"database",confidence:"high",evidence:W,tool:"alembic",files:Q,risk:Y,reasons:K};if(Z.push(V),Y==="high"){let U={type:"risk-flag",kind:"risk-flag",category:"database",confidence:"high",evidence:W,risk:"high",evidenceText:`Destructive migration detected: ${K.join(", ")}`};Z.push(U)}}if(X.length>0){let{risk:Y,reasons:K,evidence:q}=C8(X,$),W=q.map((U)=>R(U.file,U.excerpt)),V={type:"python-migration",kind:"python-migration",category:"database",confidence:"high",evidence:W,tool:"django",files:X,risk:Y,reasons:K};if(Z.push(V),Y==="high"){let U={type:"risk-flag",kind:"risk-flag",category:"database",confidence:"high",evidence:W,risk:"high",evidenceText:`Destructive migration detected: ${K.join(", ")}`};Z.push(U)}}return Z}}});function W7($){let Z=$.split("/").pop()??"";for(let{pattern:Q,configType:X,category:Y}of X7)if(Q.test(Z))return{configType:X,category:Y};return null}function q7($){let Z=[];for(let{pattern:Q,description:X}of Y7)if(Q.test($))Z.push(X);for(let Q of K7)if($.includes(Q)){let X=`${Q} section modified`;if(!Z.some((Y)=>Y.includes(Q)))Z.push(X)}return Z}function U7($){let Z=[],Q=/^\s*\[([^\]]+)\]/gm,X;while((X=Q.exec($))!==null){let Y=X[1].trim();if(!Z.includes(Y))Z.push(Y)}return Z}var X7,Y7,K7,T2;var m8=x(()=>{X7=[{pattern:/^pyproject\.toml$/,configType:"pyproject",category:"build"},{pattern:/^setup\.cfg$/,configType:"setup",category:"build"},{pattern:/^setup\.py$/,configType:"setup",category:"build"},{pattern:/^MANIFEST\.in$/,configType:"manifest",category:"build"},{pattern:/^tox\.ini$/,configType:"tox",category:"testing"},{pattern:/^pytest\.ini$/,configType:"pytest",category:"testing"},{pattern:/^conftest\.py$/,configType:"pytest",category:"testing"},{pattern:/^\.coveragerc$/,configType:"coverage",category:"testing"},{pattern:/^\.noxfile\.py$/,configType:"nox",category:"testing"},{pattern:/^\.?mypy\.ini$/,configType:"mypy",category:"typing"},{pattern:/^pyrightconfig\.json$/,configType:"pyright",category:"typing"},{pattern:/^\.flake8$/,configType:"flake8",category:"linting"},{pattern:/^\.pylintrc$/,configType:"pylint",category:"linting"},{pattern:/^\.ruff\.toml$/,configType:"ruff",category:"linting"},{pattern:/^ruff\.toml$/,configType:"ruff",category:"linting"},{pattern:/^\.isort\.cfg$/,configType:"isort",category:"linting"},{pattern:/^\.bandit$/,configType:"bandit",category:"security"},{pattern:/^\.?black$/,configType:"black",category:"formatting"},{pattern:/^\.editorconfig$/,configType:"editorconfig",category:"formatting"},{pattern:/^\.pre-commit-config\.yaml$/,configType:"pre-commit",category:"hooks"},{pattern:/^\.python-version$/,configType:"python-version",category:"environment"},{pattern:/^runtime\.txt$/,configType:"runtime",category:"environment"}],Y7=[{pattern:/python\s*=\s*["'][<>=!~]+\s*3\./i,description:"Python version constraint changed"},{pattern:/requires-python\s*=\s*["'][<>=!~]+/i,description:"requires-python changed"},{pattern:/\[tool\.poetry\.dependencies\]/i,description:"Poetry dependencies section changed"},{pattern:/\[project\.dependencies\]/i,description:"Project dependencies section changed"},{pattern:/\[build-system\]/i,description:"Build system configuration changed"},{pattern:/\[project\.scripts\]/i,description:"CLI scripts changed"},{pattern:/\[project\.entry-points\]/i,description:"Entry points changed"}],K7=["[project]","[tool.poetry]","[build-system]","[project.scripts]","[project.entry-points]","[project.optional-dependencies]"];T2={name:"python-config",analyze($){let Z=[];for(let Q of $.files){let X=W7(Q.path);if(!X)continue;let Y=$.diffs.find((B)=>B.path===Q.path),K=Y?v(Y):[],q=K.join(`
45
+ `),W=[];if(K.length>0){let B=S(K);if(B)W.push(R(Q.path,B))}let V=!1,U=[];if(X.configType==="pyproject")U=q7(q),V=U.length>0;let J=U7(q),G={type:"python-config",kind:"python-config",category:"config_env",confidence:"high",evidence:W,file:Q.path,status:Q.status,configType:X.configType,configCategory:X.category,isBreaking:V,affectedSections:J,breakingReasons:U};Z.push(G)}return Z}}});import{parse as V7}from"@babel/parser";import h8 from"@babel/traverse";import*as u from"@babel/types";function G7($){if(![".ts",".js"].some((Y)=>$.endsWith(Y)))return!1;let Q=$.includes("-routing.module")||$.includes(".routing.module")||$.includes("app.routes")||$.includes(".routes.ts"),X=$.includes(".module.")||$.includes(".component.");return Q||X}function w2($){let Z=$.replace(/\/+/g,"/");if(Z!=="/"&&Z.endsWith("/"))Z=Z.slice(0,-1);return Z}function B7($,Z){if(Z.startsWith("/"))return w2(Z);if(Z==="")return w2($);let Q=$==="/"?`/${Z}`:`${$}/${Z}`;return w2(Q)}function O7($){let Z={};for(let Q of $.properties)if(u.isObjectProperty(Q)&&u.isIdentifier(Q.key)){if(Q.key.name==="path"&&u.isStringLiteral(Q.value))Z.path=Q.value.value;else if(Q.key.name==="redirectTo"&&u.isStringLiteral(Q.value))Z.redirectTo=Q.value.value;else if(Q.key.name==="loadChildren")Z.loadChildren=!0;else if(Q.key.name==="children"&&u.isArrayExpression(Q.value))Z.children=Q.value}return Z}function x2($,Z,Q="/"){let X=[];for(let Y of $.elements)if(u.isObjectExpression(Y)){let K=O7(Y);if(K.path!==void 0){let q=B7(Q,K.path);if(X.push({path:q,file:Z,loadChildren:K.loadChildren,redirectTo:K.redirectTo}),K.children){let W=x2(K.children,Z,q);X.push(...W)}}}return X}function H7($){if(!$)return!1;let Z=$.typeAnnotation||$;if(u.isTSTypeReference(Z)&&u.isIdentifier(Z.typeName))return Z.typeName.name==="Routes";if(u.isTSArrayType(Z)){let Q=Z.elementType;if(u.isTSTypeReference(Q)&&u.isIdentifier(Q.typeName))return Q.typeName.name==="Route"}return!1}function _7($,Z){let Q=[],X=new Map,Y=new Set;if(h8($,{VariableDeclarator(K){if(u.isIdentifier(K.node.id)&&u.isArrayExpression(K.node.init)){let q=H7(K.node.id.typeAnnotation),W=/routes/i.test(K.node.id.name);if(q||W)X.set(K.node.id.name,K.node.init)}}}),h8($,{CallExpression(K){let q=null,W=null;if(u.isMemberExpression(K.node.callee)){let V=K.node.callee.object,U=K.node.callee.property;if(u.isIdentifier(V)&&V.name==="RouterModule"&&u.isIdentifier(U)&&(U.name==="forRoot"||U.name==="forChild")){let J=K.node.arguments[0];if(u.isArrayExpression(J))q=J;else if(u.isIdentifier(J)){W=J.name;let G=X.get(J.name);if(G)q=G}}}else if(u.isIdentifier(K.node.callee)){if(K.node.callee.name==="provideRouter"){let V=K.node.arguments[0];if(u.isArrayExpression(V))q=V;else if(u.isIdentifier(V)){W=V.name;let U=X.get(V.name);if(U)q=U}}}if(q){let V=x2(q,Z);if(Q.push(...V),W)Y.add(W)}}}),Q.length===0){for(let[K,q]of X)if(!Y.has(K)){let W=x2(q,Z);Q.push(...W)}}return Q}function u8($,Z){try{let Q=V7($,{sourceType:"module",plugins:["typescript","decorators-legacy"]});return _7(Q,Z)}catch(Q){return[]}}var J7,E2;var I2=x(()=>{K0();J7={batchGetFileContent:z$};E2={name:"angular-routes",async analyze($){let Z=[],Q=$.files.filter((q)=>{return G7(q.path)});if(Q.length===0)return[];let X=[];for(let q of Q)X.push({ref:$.base,path:q.path}),X.push({ref:$.head,path:q.path});let Y=await J7.batchGetFileContent(X);for(let q of Q){let W=`${$.base}:${q.path}`,V=`${$.head}:${q.path}`,U=Y.get(W),J=Y.get(V),G=(M)=>M.includes("RouterModule")||M.includes("provideRouter")||M.includes("Routes")||M.includes("@angular/router");if(U&&!G(U)&&J&&!G(J))continue;let B=U?u8(U,q.path):[],H=J?u8(J,q.path):[],_=new Set(B.map((M)=>M.path)),O=new Set(H.map((M)=>M.path));for(let M of H)if(!_.has(M.path)){let z=M.loadChildren?"lazy":M.redirectTo?"redirect":"page",A=M.redirectTo?`Route: ${M.path} → ${M.redirectTo}`:`Route: ${M.path}`,N={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:[R(q.path,A)],routeId:M.path,file:q.path,change:"added",routeType:z};Z.push(N)}for(let M of B)if(!O.has(M.path)){let z=M.loadChildren?"lazy":M.redirectTo?"redirect":"page",A=M.redirectTo?`Route: ${M.path} → ${M.redirectTo}`:`Route: ${M.path}`,N={type:"route-change",kind:"route-change",category:"routes",confidence:"high",evidence:[R(q.path,A)],routeId:M.path,file:q.path,change:"deleted",routeType:z};Z.push(N)}}return Array.from(new Map(Z.map((q)=>{return[`${q.routeId}-${q.change}-${q.file}`,q]})).values()).sort((q,W)=>{let V=q.routeId,U=W.routeId;return V.localeCompare(U)})}}});import{parse as M7}from"@babel/parser";import z7 from"@babel/traverse";import*as M1 from"@babel/types";function j7($){if(![".ts",".js"].some((X)=>$.endsWith(X)))return!1;return[".component.",".module.",".service.",".directive.",".pipe.",".guard.",".interceptor."].some((X)=>$.includes(X))}function L7($){if($.includes(".component."))return"component";if($.includes(".module."))return"module";if($.includes(".service."))return"service";if($.includes(".directive."))return"directive";if($.includes(".pipe."))return"pipe";if($.includes(".guard."))return"guard";if($.includes(".interceptor."))return"interceptor";return"unknown"}function D7($){let Z=$.match(/@(Component|NgModule|Injectable|Directive|Pipe)\s*\(\s*\{/);if(!Z)return null;let Q={name:Z[1]},X=$.match(/selector\s*:\s*['"]([^'"]+)['"]/);if(X)Q.selector=X[1];let Y=$.match(/standalone\s*:\s*(true|false)/);if(Y)Q.standalone=Y[1]==="true";return Q}function N7($){try{let Z=M7($,{sourceType:"module",plugins:["typescript","decorators-legacy"]}),Q=null;if(z7(Z,{ClassDeclaration(X){let Y=X.node.decorators||[];for(let K of Y){let q=K.expression;if(M1.isCallExpression(q)&&M1.isIdentifier(q.callee)){let W=q.callee.name;if(["Component","NgModule","Injectable","Directive","Pipe"].includes(W)){let V={name:W},U=q.arguments[0];if(M1.isObjectExpression(U)){for(let J of U.properties)if(M1.isObjectProperty(J)&&M1.isIdentifier(J.key)){if(J.key.name==="selector"&&M1.isStringLiteral(J.value))V.selector=J.value.value;else if(J.key.name==="standalone"&&M1.isBooleanLiteral(J.value))V.standalone=J.value.value;else if(J.key.name==="providers"&&M1.isArrayExpression(J.value))V.providers=J.value.elements.map((G)=>{if(M1.isIdentifier(G))return G.name;return null}).filter((G)=>G!==null)}}Q=V;break}}}}}),Q)return Q}catch(Z){}return D7($)}var b2;var P2=x(()=>{b2={name:"angular-components",analyze($){let Z=[];for(let Q of $.files){if(!j7(Q.path))continue;let X=L7(Q.path),Y=$.diffs.find((G)=>G.path===Q.path),K=Y?v(Y):[],q=S(K),W=[];if(q)W.push(R(Q.path,q));let V=K.join(`
46
+ `),U=N7(V),J={type:"angular-component-change",kind:"angular-component-change",category:"api",confidence:"high",evidence:W,file:Q.path,change:Q.status==="added"?"added":Q.status==="deleted"?"deleted":"modified",componentType:X,selector:U?.selector,standalone:U?.standalone,providers:U?.providers};Z.push(J)}return Z}}});function x7($){return A7.some((Z)=>Z.test($))}function E7($){let Z=new Set,Q=$.join(`
47
+ `);for(let X of R7)if(new RegExp(`\\b${X}\\s*[:{]`,"i").test(Q))Z.add(X);for(let X of T7)if(new RegExp(`\\b${X}\\s*[:{]`,"i").test(Q))Z.add(`build.${X}`);for(let X of w7)if(new RegExp(`\\b${X}\\s*[:{]`,"i").test(Q))Z.add(`server.${X}`);return Array.from(Z)}function I7($,Z){let Q=[],X=$.join(`
48
+ `),Y=Z.join(`
49
+ `);if(/\bbase\s*[:{]/.test(Y)||/\bbase\s*[:{]/.test(X)){if(Z.length>0&&$.length>0)Q.push("Base path changed (affects all asset URLs)")}if(/\boutDir\s*[:{]/.test(Y)||/\boutDir\s*[:{]/.test(X))Q.push("Output directory changed (may affect deployment)");if(/\btarget\s*[:{]/.test(Y)||/\btarget\s*[:{]/.test(X))Q.push("Build target changed (affects browser compatibility)");if(/plugins\s*[:{]/.test(Y)&&Z.some((K)=>K.includes("import(")||K.includes("require(")))Q.push("Plugins modified (may affect build behavior)");if(/resolve\s*[:{]/.test(Y)&&/alias\s*[:{]/.test(Y))Q.push("Path aliases modified (may break imports)");if(/\benvPrefix\s*[:{]/.test(Y)||/\benvPrefix\s*[:{]/.test(X))Q.push("Environment prefix changed (affects env variable exposure)");if(/\bdefine\s*[:{]/.test(Y))Q.push("Build-time constants modified");if(/\bsourcemap\s*[:{]/.test(X)||/\bsourcemap\s*[:{]/.test(Y))Q.push("Sourcemap configuration changed");if(/\bssr\s*[:{]/.test(Y)||/\bssr\s*[:{]/.test(X))Q.push("SSR configuration changed (affects server rendering)");return{isBreaking:Q.length>0,reasons:Q}}function b7($,Z){let Q=[],X=[...$,...Z].join(`
50
+ `),Y=[{pattern:/@vitejs\/plugin-react/,name:"React"},{pattern:/@vitejs\/plugin-vue/,name:"Vue"},{pattern:/@vitejs\/plugin-vue-jsx/,name:"Vue JSX"},{pattern:/@vitejs\/plugin-legacy/,name:"Legacy Browser Support"},{pattern:/@sveltejs\/vite-plugin-svelte/,name:"Svelte"},{pattern:/vite-plugin-pwa/,name:"PWA"},{pattern:/vite-tsconfig-paths/,name:"TypeScript Paths"},{pattern:/vitest/,name:"Vitest"},{pattern:/@angular\/build/,name:"Angular"},{pattern:/vite-plugin-solid/,name:"Solid"},{pattern:/vite-plugin-qwik/,name:"Qwik"}];for(let{pattern:K,name:q}of Y)if(K.test(X))Q.push(q);return Q}var A7,R7,T7,w7,k2;var g8=x(()=>{A7=[/^vite\.config\.(js|cjs|mjs|ts|mts)$/],R7=["build","server","preview","resolve","plugins","define","base","publicDir","envPrefix","optimizeDeps","esbuild","ssr"],T7=["target","outDir","assetsDir","assetsInlineLimit","cssCodeSplit","sourcemap","minify","rollupOptions","lib","manifest","cssMinify","modulePreload","chunkSizeWarningLimit"],w7=["host","port","proxy","cors","https","hmr","watch","middlewareMode"];k2={name:"vite-config",analyze($){let Z=[];for(let Q of $.diffs){if(!x7(Q.path))continue;let X=v(Q),Y=L1(Q),K=E7([...X,...Y]),{isBreaking:q,reasons:W}=I7(X,Y),V=b7(X,Y),U=q?"high":K.length>0?"medium":"low",J=S(X.length>0?X:Y),G={type:"vite-config",kind:"vite-config",category:"config_env",confidence:U,evidence:[R(Q.path,J)],file:Q.path,status:Q.status,isBreaking:q,affectedSections:K,breakingReasons:W,pluginsDetected:V};Z.push(G)}return Z}}});var x1=x(()=>{d5();J8();V2();J2();l1();f1();B2();H2();M2();L2();w8();S8();y8();m8();I2();P2();g8();E5();n0();S$();y5();m5();h5();e0();g5();Q2();q0();t5();e5();Z8();Q8();X8();Y8();K8();W8()});var v2;var c8=x(()=>{x1();v2={name:"auto",analyzers:[s,o,X1,B1,Y1,K1,W1,i,F$,n,t,e,q1,$1,U1,Z1]}});var l8;var f8=x(()=>{x1();f1();l8={name:"sveltekit",analyzers:[s,o,S5,F5,X1,B1,Y1,K1,W1,i,N1,n,t,e,q1,$1,U1,Z1]}});var p8;var d8=x(()=>{x1();f1();l1();p8={name:"react",analyzers:[s,o,Y2,X1,B1,Y1,K1,W1,i,N1,D1,n,t,e,q1,$1,U1,Z1]}});var r8;var a8=x(()=>{x1();l1();r8={name:"stencil",analyzers:[s,o,q2,X1,B1,Y1,K1,W1,i,D1,n,t,e,q1,$1,U1,Z1]}});var s8;var o8=x(()=>{x1();V2();f1();s8={name:"next",analyzers:[s,o,U2,X1,B1,Y1,K1,W1,i,N1,n,t,e,q1,$1,U1,Z1]}});var i8;var n8=x(()=>{x1();M2();f1();l1();i8={name:"vue",analyzers:[s,o,_2,X1,B1,Y1,K1,W1,i,N1,D1,n,t,e,q1,$1,U1,Z1]}});var t8;var e8=x(()=>{x1();L2();f1();l1();t8={name:"astro",analyzers:[s,o,j2,X1,B1,Y1,K1,W1,i,N1,D1,n,t,e,q1,$1,U1,Z1]}});var $9;var Z9=x(()=>{x1();I2();P2();f1();l1();J2();$9={name:"angular",analyzers:[s,o,E2,b2,X1,B1,Y1,K1,W1,i,N1,D1,F$,n,t,e,q1,$1,U1,Z1]}});var Q9;var X9=x(()=>{x1();H2();l1();B2();Q9={name:"library",analyzers:[s,o,O2,D1,K1,Y1,i,G2,n,t,e,$1,Z1]}});var Y9;var K9=x(()=>{x1();Y9={name:"python",analyzers:[s,o,D2,A2,R2,T2,X1,W1,i,n,t,e,q1,$1,U1,Z1]}});var W9;var q9=x(()=>{x1();f1();l1();W9={name:"vite",analyzers:[s,o,X1,B1,Y1,K1,W1,i,k2,N1,D1,n,t,e,q1,$1,U1,Z1]}});import{existsSync as H1}from"node:fs";import{join as _1}from"node:path";function P7($=process.cwd()){if(H1(_1($,"src","routes")))return!0;return!1}function k7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.["@sveltejs/kit"]||Q?.["@sveltejs/kit"])}function v7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.react&&Z?.["react-dom"]||Q?.react&&Q?.["react-dom"])}function S7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.["react-router"]||Z?.["react-router-dom"]||Q?.["react-router"]||Q?.["react-router-dom"])}function C7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.next||Q?.next)}function F7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.["@stencil/core"]||Q?.["@stencil/core"])}function y7($=process.cwd()){return H1(_1($,"stencil.config.ts"))||H1(_1($,"stencil.config.js"))}function m7($=process.cwd()){if(H1(_1($,"app")))return!0;if(H1(_1($,"src","app")))return!0;return!1}function h7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.vue||Q?.vue)}function u7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.nuxt||Q?.nuxt)}function g7($=process.cwd()){return H1(_1($,"pages"))||H1(_1($,"src","pages"))}function c7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.astro||Q?.astro)}function l7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.["@angular/core"]||Z?.["@angular/common"]||Q?.["@angular/core"]||Q?.["@angular/common"])}function f7($=process.cwd()){return H1(_1($,"angular.json"))||H1(_1($,".angular-cli.json"))}function p7($=process.cwd()){return H1(_1($,"astro.config.mjs"))||H1(_1($,"astro.config.ts"))||H1(_1($,"astro.config.js"))}function d7($){if(!$)return!1;if($.exports)return!0;if($.publishConfig)return!0;if($.private===!1)return!0;if($.bin)return!0;return!1}function r7($=process.cwd()){return["pyproject.toml","setup.py","setup.cfg","requirements.txt","Pipfile","poetry.lock"].some((Q)=>H1(_1($,Q)))}function a7($){if(!$)return!1;let{dependencies:Z,devDependencies:Q}=$;return Boolean(Z?.vite||Q?.vite)}function s7($=process.cwd()){return H1(_1($,"vite.config.ts"))||H1(_1($,"vite.config.js"))||H1(_1($,"vite.config.mjs"))||H1(_1($,"vite.config.mts"))}function o7($=process.cwd()){return["manage.py","app/main.py","src/main.py","app/__init__.py"].some((Q)=>H1(_1($,Q)))}function i7($){for(let Z of $.files){if(Z.path.includes("/migrations/")&&Z.path.endsWith(".py"))return"django";if(Z.path==="manage.py"||Z.path.includes("urls.py"))return"django";if(Z.path.includes("routers/")||Z.path.includes("endpoints/"))return"fastapi";if(Z.path.includes("alembic/versions/"))return"alembic"}return null}function y$($,Z=process.cwd()){let Q=[],X=P7(Z),Y=k7($.headPackageJson);if(X||Y){if(X)Q.push("Found src/routes/ directory (SvelteKit file-based routing)");if(Y)Q.push("Found @sveltejs/kit in package.json dependencies");return{profile:"sveltekit",confidence:X&&Y?"high":"high",reasons:Q}}let K=F7($.headPackageJson),q=y7(Z);if(K||q){if(K)Q.push("Found @stencil/core in package.json dependencies");if(q)Q.push("Found stencil.config.ts or stencil.config.js");return{profile:"stencil",confidence:K&&q?"high":"high",reasons:Q}}let W=C7($.headPackageJson),V=m7(Z);if(W&&V)return Q.push("Found next in package.json dependencies"),Q.push("Found app/ directory (Next.js App Router)"),{profile:"next",confidence:"high",reasons:Q};if(W)return Q.push("Found next in package.json dependencies"),{profile:"next",confidence:"medium",reasons:Q};let U=v7($.headPackageJson),J=S7($.headPackageJson);if(U&&J)return Q.push("Found react and react-dom in package.json dependencies"),Q.push("Found react-router or react-router-dom in package.json dependencies"),{profile:"react",confidence:"high",reasons:Q};let G=h7($.headPackageJson),B=u7($.headPackageJson),H=g7(Z);if(B||G&&H){if(B)Q.push("Found nuxt in package.json dependencies");if(G)Q.push("Found vue in package.json dependencies");if(H)Q.push("Found pages/ directory (Nuxt file-based routing)");return{profile:"vue",confidence:"high",reasons:Q}}if(G)return Q.push("Found vue in package.json dependencies"),{profile:"vue",confidence:"medium",reasons:Q};let _=c7($.headPackageJson),O=p7(Z);if(_||O){if(_)Q.push("Found astro in package.json dependencies");if(O)Q.push("Found astro.config.{mjs,ts,js}");return{profile:"astro",confidence:_&&O?"high":"medium",reasons:Q}}let M=l7($.headPackageJson),z=f7(Z);if(M||z){if(M)Q.push("Found @angular/core or @angular/common in package.json dependencies");if(z)Q.push("Found angular.json or .angular-cli.json");return{profile:"angular",confidence:M&&z?"high":"medium",reasons:Q}}let A=a7($.headPackageJson),N=s7(Z);if(A&&N)return Q.push("Found vite in package.json dependencies"),Q.push("Found vite.config.{ts,js,mjs,mts}"),{profile:"vite",confidence:"high",reasons:Q};if(A)return Q.push("Found vite in package.json dependencies"),{profile:"vite",confidence:"medium",reasons:Q};if(d7($.headPackageJson)){if($.headPackageJson?.exports)Q.push("Found exports field in package.json");if($.headPackageJson?.publishConfig)Q.push("Found publishConfig in package.json");if($.headPackageJson?.bin)Q.push("Found bin field in package.json (CLI tool)");if($.headPackageJson?.private===!1)Q.push("Package marked as public (private: false)");return{profile:"library",confidence:"medium",reasons:Q}}let w=r7(Z),T=o7(Z),P=i7($);if(w||T||P){if(w)Q.push("Found Python project files (pyproject.toml, requirements.txt, etc.)");if(T)Q.push("Found Python web framework markers (manage.py, main.py, etc.)");if(P)Q.push(`Detected ${P} framework from changed files`);return{profile:"python",confidence:w&&(T||P)?"high":"medium",reasons:Q}}return Q.push("No framework-specific markers detected, using default analyzers"),{profile:"auto",confidence:"medium",reasons:Q}}function n7($,Z=process.cwd()){return y$($,Z).profile}function u1($){switch($){case"sveltekit":return l8;case"react":return p8;case"stencil":return r8;case"next":return s8;case"vue":return i8;case"astro":return t8;case"angular":return $9;case"library":return Q9;case"python":return Y9;case"vite":return W9;case"auto":return v2;default:return v2}}function Y$($,Z,Q=process.cwd()){if($==="auto")return n7(Z,Q);return $}var m$=x(()=>{c8();f8();d8();a8();o8();n8();e8();Z9();X9();K9();q9()});function gQ($){let Z=$.find((K)=>K.type==="file-category");if(!Z)return{isLowRisk:!1,category:null};let{categories:Q}=Z;if(["product","infra","ci","dependencies"].some((K)=>Q[K].length>0))return{isLowRisk:!1,category:null};if(Q.docs.length>0&&Q.tests.length===0)return{isLowRisk:!0,category:"docs"};if(Q.tests.length>0&&Q.docs.length===0)return{isLowRisk:!0,category:"tests"};if(Q.config.length>0&&Q.docs.length===0&&Q.tests.length===0)return{isLowRisk:!0,category:"config"};if(Q.docs.length>0||Q.tests.length>0||Q.config.length>0)return{isLowRisk:!0,category:"docs/tests/config"};return{isLowRisk:!1,category:null}}function L$($){let Z=0,Q=[],X=[],{isLowRisk:Y,category:K}=gQ($);if(Y&&K){let J={docs:-15,tests:-10,config:-5,"docs/tests/config":-10}[K]??0;Z+=J,Q.push(`✅ Changes are only in ${K} (lower risk)`),X.push({kind:"low-risk-category",weight:J,explanation:`Changes are only in ${K} (lower risk)`,evidence:[]})}for(let U of $)switch(U.type){case"risk-flag":{let J=U.risk==="high"?40:U.risk==="medium"?20:5;Z+=J;let G=U.risk==="high"?"⚠️":U.risk==="medium"?"⚡":"ℹ️";Q.push(`${G} ${U.evidenceText}`),X.push({kind:`risk-${U.risk}`,weight:J,explanation:U.evidenceText,evidence:U.evidence})}break;case"db-migration":{let J=U.risk==="high"?30:U.risk==="medium"?15:0;if(J>0){Z+=J;let G=U.risk==="high"?`High-risk database migration: ${U.reasons.join(", ")}`:`Database migration detected: ${U.files.join(", ")}`;Q.push(U.risk==="high"?`⚠️ ${G}`:`⚡ ${G}`),X.push({kind:"db-migration",weight:J,explanation:G,evidence:U.evidence})}}break;case"route-change":if(U.change==="added")Z+=5,X.push({kind:"route-added",weight:5,explanation:`Route added: ${U.routeId}`,evidence:U.evidence});else if(U.change==="deleted")Z+=10,Q.push(`ℹ️ Route deleted: ${U.routeId}`),X.push({kind:"route-deleted",weight:10,explanation:`Route deleted: ${U.routeId}`,evidence:U.evidence});break;case"dependency-change":{let J=0;if(U.impact==="major")J=15;else if(U.impact==="minor")J=5;if(U.riskCategory&&U.impact==="new")J+=10;if(J>0)Z+=J,X.push({kind:`dependency-${U.impact}`,weight:J,explanation:`${U.name}: ${U.from??"new"} → ${U.to??"removed"}`,evidence:U.evidence})}break;case"env-var":if(U.change==="added")Z+=5,Q.push(`ℹ️ New env var: ${U.name}`),X.push({kind:"env-var-added",weight:5,explanation:`New env var: ${U.name}`,evidence:U.evidence});break;case"security-file":Z+=15,X.push({kind:"security-file",weight:15,explanation:`Security-sensitive files changed: ${U.files.length} file(s)`,evidence:U.evidence});break;case"convention-violation":{let J=U,G=J.files.length;if(G>5)Z+=10,Q.push(`⚡ ${G} source files lack test coverage`),X.push({kind:"test-coverage-gap",weight:10,explanation:`${G} source files lack test coverage`,evidence:J.evidence.slice(0,3)})}break;case"large-diff":{let J=U,G=J.linesChanged>1000?15:J.linesChanged>500?10:5;Z+=G,Q.push(`ℹ️ Large diff: ${J.filesChanged} files, ${J.linesChanged} lines`),X.push({kind:"large-diff",weight:G,explanation:`Large diff: ${J.filesChanged} files, ${J.linesChanged} lines`,evidence:J.evidence})}break}let q=[/\/types\.ts$/,/\/core\/.*\.ts$/,/\/index\.ts$/],W=$.find((U)=>U.type==="file-summary");if(W){let U=W.modified.filter((J)=>q.some((G)=>G.test(J)));if(U.length>0)Z+=10,Q.push(`ℹ️ Core module files modified: ${U.join(", ")}`),X.push({kind:"core-module-change",weight:10,explanation:`Core module files modified (types.ts, index.ts): ${U.length} file(s)`,evidence:[]})}Z=Math.max(0,Math.min(Z,100));let V;if(Z>=50)V="high";else if(Z>=20)V="medium";else V="low";return{score:Z,level:V,factors:X,evidenceBullets:Q}}function UX($){if($.includes("db-migration")||$.includes("database")||$.includes("sql"))return"database";if($.includes("dependency")||$.includes("deps"))return"dependencies";if($.includes("route"))return"routes";if($.includes("env-var")||$.includes("config"))return"config_env";if($.includes("security")||$.includes("infra")||$.includes("docker")||$.includes("k8s")||$.includes("terraform"))return"infra";if($.includes("cloudflare")||$.includes("wrangler")||$.includes("workers"))return"cloudflare";if($.includes("ci")||$.includes("workflow")||$.includes("pipeline"))return"ci";if($.includes("test")&&!$.includes("test-gap")&&!$.includes("test-coverage"))return"tests";if($.includes("test-gap")||$.includes("test-coverage")||$.includes("quality"))return"quality";if($.includes("api")||$.includes("contract"))return"api";if($.includes("core-module")||$.includes("impact")||$.includes("blast-radius")||$.includes("large-diff")||$.includes("churn"))return"impact";if($.includes("doc"))return"docs";return"unknown"}function O9($){let Z=$.excerpt.toLowerCase(),Q=0;if(/\d+/.test(Z))Q+=10;if(Z.includes("blast radius"))Q+=15;if(Z.includes("high"))Q+=5;if(Z.includes("critical"))Q+=8;if(Z.includes("breaking"))Q+=8;if(Z.includes("added")||Z.includes("removed")||Z.includes("modified"))Q+=3;if(Z==="imports module")Q-=10;if(Z.startsWith("depends on"))Q-=5;return Q}function G0($,Z){let Q=new Map;for(let Y of $){if(Y.kind==="file-summary"||Y.kind==="file-category")continue;let K=Y.category;if(!Q.has(K))Q.set(K,{count:0,riskWeight:0,evidence:[]});let q=Q.get(K);q.count+=1,q.evidence.push(...Y.evidence)}for(let Y of Z){let K="unknown";for(let W of $)if(W.evidence.length>0&&Y.evidence.length>0){let V=new Set(W.evidence.map((G)=>G.file)),U=new Set(Y.evidence.map((G)=>G.file));if(Array.from(V).some((G)=>U.has(G))){K=W.category;break}}if(K==="unknown")K=UX(Y.kind);if(!Q.has(K))Q.set(K,{count:0,riskWeight:0,evidence:[]});let q=Q.get(K);q.riskWeight+=Y.weight,q.evidence.push(...Y.evidence)}let X=Array.from(Q.entries()).filter(([Y,K])=>K.count>0).map(([Y,K])=>{let q=[...K.evidence].sort((U,J)=>{let G=O9(U),B=O9(J);if(B!==G)return B-G;return U.file.localeCompare(J.file)}),W=new Set,V=[];for(let U of q){if(!W.has(U.file))W.add(U.file),V.push(U);if(V.length>=3)break}return{id:Y,count:K.count,riskWeight:K.riskWeight,topEvidence:V}});return X.sort((Y,K)=>{if(K.riskWeight!==Y.riskWeight)return K.riskWeight-Y.riskWeight;if(K.count!==Y.count)return K.count-Y.count;return Y.id.localeCompare(K.id)}),X}function B0($){let Z={};for(let Q of $)Z[Q.id]=Q.count;return Z}function O0($,Z){let Q=[];if(Z==="sveltekit"){let U=$.some((J)=>J.type==="route-change");if(U||$.length>0){let J=[];if(U)J.push("Route files changed");if($.length>0&&!U)J.push("Source files changed");Q.push({id:"sveltekit-check",category:"types",blocking:!0,reason:"Run SvelteKit type checker to verify no type errors were introduced",triggers:J})}}let X=$.filter((U)=>U.type==="test-change"),Y=X.length>0;if(Y||$.length>0){let U=[];if(Y){let J=X.reduce((G,B)=>G+B.files.length,0);U.push(`${J} test file(s) changed`)}if($.length>0&&!Y)U.push("Source files changed without corresponding test changes");Q.push({id:"run-tests",category:"tests",blocking:!0,reason:"Run test suite to verify functionality and catch regressions",triggers:U})}let K=$.filter((U)=>U.type==="db-migration");if(K.length>0){let U=K.some((H)=>H.risk==="high"),J=K.flatMap((H)=>H.files),G=[...new Set(K.flatMap((H)=>H.reasons))],B=[`${J.length} migration file(s) changed`,...G];if(U)B.push("DANGEROUS SQL DETECTED (DROP, TRUNCATE, or destructive operations)");if(Q.push({id:"apply-migrations",category:"database",blocking:U,reason:U?"Apply database migrations in a safe environment and verify data integrity before production":"Apply and test database migrations in development environment",triggers:B}),U)Q.push({id:"backup-db",category:"database",blocking:!0,reason:"Create database backup before applying destructive migrations",triggers:["High-risk SQL operations detected in migrations"]})}let q=$.filter((U)=>U.type==="cloudflare-change");if(q.length>0){let U=[...new Set(q.map((G)=>G.area))],J=q.flatMap((G)=>G.files);Q.push({id:"verify-cloudflare-config",category:"cloudflare",blocking:!1,reason:"Verify Cloudflare configuration and bindings match across environments",triggers:[`Cloudflare ${U.join(", ")} configuration changed`,`Files: ${J.join(", ")}`]})}let W=$.filter((U)=>U.type==="env-var");if(W.length>0){let U=W.map((B)=>B.name),J=W.filter((B)=>B.change==="added"),G=[];if(J.length>0)G.push(`New environment variable(s): ${J.map((B)=>B.name).join(", ")}`);if(W.length>J.length)G.push(`Modified environment variable(s): ${U.filter((B)=>!J.some((H)=>H.name===B)).join(", ")}`);Q.push({id:"update-env-docs",category:"environment",blocking:!1,reason:"Update .env.example and documentation with new or changed environment variables",triggers:G})}let V=$.filter((U)=>U.type==="dependency-change"&&U.impact==="major");if(V.length>0){let U=V.map((J)=>{let G=J.from||"new",B=J.to||"removed";return`${J.name} (${G} → ${B})`});Q.push({id:"review-dependencies",category:"dependencies",blocking:!1,reason:"Review major dependency changes for breaking changes and update migration guides if needed",triggers:[`Major version changes: ${U.join(", ")}`,"Check CHANGELOG and migration guides for breaking changes"]})}return Q.sort((U,J)=>{if(U.blocking!==J.blocking)return U.blocking?-1:1;return U.id.localeCompare(J.id)}),Q}function H9($){let Z=[],Q=0,X=(D,k)=>{Z.push({text:D,priority:k,order:Q++})},Y=$.filter((D)=>D.type==="impact-analysis"),K=Y.filter((D)=>D.blastRadius==="high"),q=Y.filter((D)=>D.blastRadius==="medium");if(K.length>0)X(`${K.length} file(s) with high blast radius`,y.HIGH_BLAST_RADIUS);if(q.length>0)X(`${q.length} file(s) with medium blast radius`,y.MEDIUM_BLAST_RADIUS);let W=$.filter((D)=>D.type==="typescript-config");if(W.length>0){let D=W.some((k)=>k.isBreaking);X(D?"TypeScript config changed (breaking)":"TypeScript config modified",D?y.BREAKING_CONFIG:y.NON_BREAKING_CONFIG)}let V=$.filter((D)=>D.type==="tailwind-config");if(V.length>0){let D=V.some((k)=>k.isBreaking);X(D?"Tailwind config changed (breaking)":"Tailwind config modified",D?y.BREAKING_CONFIG:y.NON_BREAKING_CONFIG)}let U=$.filter((D)=>D.type==="graphql-change");if(U.length>0){let D=U.some((k)=>k.isBreaking);X(D?"GraphQL schema changed (breaking)":"GraphQL schema modified",D?y.BREAKING_CONFIG:y.NON_BREAKING_CONFIG)}let J=$.filter((D)=>D.type==="package-exports");if(J.length>0){if(J.some((k)=>k.isBreaking))X("Package exports changed (breaking)",y.BREAKING_CONFIG);else if(J.filter((j1)=>j1.binChanges&&(j1.binChanges.added.length>0||j1.binChanges.removed.length>0)).length>0)X("Package bin/exports modified",y.NON_BREAKING_CONFIG)}let B=$.filter((D)=>D.type==="risk-flag").filter((D)=>D.risk==="high");if(B.length>0)X(`${B.length} high-risk condition(s) detected`,y.HIGH_RISK_FLAGS);let _=$.filter((D)=>D.type==="sql-risk").filter((D)=>D.riskType==="destructive");if(_.length>0)X(`Destructive SQL detected in ${_.length} file(s)`,y.DESTRUCTIVE_SQL);let O=$.filter((D)=>D.type==="db-migration");if(O.length>0){let D=O.some((k)=>k.risk==="high");X(D?"Database migrations (HIGH RISK)":"Database migrations",D?y.HIGH_RISK_DB_MIGRATION:y.DB_MIGRATION)}let M=$.filter((D)=>D.type==="ci-workflow");if(M.length>0)if(M.filter((k)=>k.riskType==="permissions_broadened"||k.riskType==="pull_request_target").length>0)X("CI workflow security changes detected",y.CI_SECURITY);else X(`${M.length} CI workflow(s) modified`,y.CI_WORKFLOW);if($.filter((D)=>D.type==="security-file").length>0)X("Security-sensitive files changed",y.SECURITY_FILES);let A=$.find((D)=>D.type==="lockfile-mismatch");if(A){if(A.manifestChanged&&!A.lockfileChanged)X("Lockfile mismatch: package.json changed but lockfile not updated",y.LOCKFILE_MISMATCH);else if(!A.manifestChanged&&A.lockfileChanged)X("Lockfile mismatch: lockfile changed but package.json not updated",y.LOCKFILE_MISMATCH)}let N=$.filter((D)=>D.type==="infra-change");if(N.length>0){let D=[...new Set(N.map((k)=>k.infraType))];X(`Infrastructure changes: ${D.join(", ")}`,y.INFRA_CHANGES)}let E=$.filter((D)=>D.type==="dependency-change"),w=E.filter((D)=>D.impact==="major");if(w.length>0)X(`${w.length} major dependency update(s)`,y.MAJOR_DEPS);let T=$.filter((D)=>D.type==="route-change");if(T.length>0)X(`${T.length} route(s) changed`,y.ROUTE_CHANGES);let P=$.filter((D)=>D.type==="api-contract-change");if(P.length>0)X(`${P.length} API contract(s) modified`,y.API_CONTRACTS);let I=$.filter((D)=>D.type==="cloudflare-change");if(I.length>0){let D=[...new Set(I.map((k)=>k.area))];X(`Cloudflare ${D.join("/")} configuration changed`,y.CLOUDFLARE)}let f=$.filter((D)=>D.type==="stencil-component-change"||D.type==="stencil-prop-change"||D.type==="stencil-event-change"||D.type==="stencil-method-change"||D.type==="stencil-slot-change");if(f.length>0){let D=new Set(f.map((k)=>k.tag));X(`${D.size} Stencil component(s) with API changes`,y.STENCIL_API)}let j=$.filter((D)=>D.type==="monorepo-config");if(j.length>0){let D=[...new Set(j.map((k)=>k.tool))];X(`Monorepo config changed: ${D.join(", ")}`,y.MONOREPO_CONFIG)}let g=$.filter((D)=>D.type==="env-var");if(g.length>0){let D=g.filter((k)=>k.change==="added");X(D.length>0?`${D.length} new environment variable(s)`:`${g.length} environment variable(s) touched`,y.ENV_VARS)}let c=E.filter((D)=>D.impact==="new");if(c.length>0)X(`${c.length} new dependency(ies) added`,y.NEW_DEPS);let p=$.filter((D)=>D.type==="test-change");if(p.length>0){let D=p.reduce(($$,Z$)=>$$+Z$.added.length,0),k=p.reduce(($$,Z$)=>$$+Z$.modified.length,0),j1=p.reduce(($$,Z$)=>$$+Z$.deleted.length,0),c1=[];if(D>0)c1.push(`${D} added`);if(k>0)c1.push(`${k} modified`);if(j1>0)c1.push(`${j1} deleted`);if(c1.length>0)X(`Test files: ${c1.join(", ")}`,y.TEST_CHANGES);else{let $$=p.flatMap((Z$)=>Z$.files).length;X(`${$$} test file(s) changed`,y.TEST_CHANGES)}}let s1=$.filter((D)=>D.type==="convention-violation");if(s1.length>0){let D=s1.reduce((k,j1)=>k+j1.files.length,0);X(`${D} source file(s) missing corresponding tests`,y.CONVENTION_VIOLATIONS)}let Q1=$.filter((D)=>D.type==="test-gap");if(Q1.length>0){let D=Q1.reduce((k,j1)=>k+j1.prodFilesChanged,0);X(`${D} modified file(s) lack test coverage`,y.TEST_GAPS)}if(Z.length===0&&$.length>0){let D=$.find((k)=>k.type==="file-summary");if(D){let k=D.added.length+D.modified.length+D.deleted.length+D.renamed.length;if(k>0)X(`${k} ${D.category} file(s) changed`,y.FALLBACK)}if(Z.length===0&&Y.length>0){let k=Y.reduce((j1,c1)=>j1+c1.affectedFiles.length,0);X(`${Y.length} file(s) analyzed, ${k} dependent file(s)`,y.FALLBACK)}if(Z.length===0)X(`${$.length} finding(s) detected`,y.FALLBACK)}return Z.sort((D,k)=>{if(k.priority!==D.priority)return k.priority-D.priority;return D.order-k.order}),Z.map((D)=>D.text)}var y;var _9=x(()=>{y={HIGH_BLAST_RADIUS:100,MEDIUM_BLAST_RADIUS:95,BREAKING_CONFIG:90,HIGH_RISK_FLAGS:85,DESTRUCTIVE_SQL:85,HIGH_RISK_DB_MIGRATION:85,CI_SECURITY:85,SECURITY_FILES:85,LOCKFILE_MISMATCH:80,INFRA_CHANGES:70,MAJOR_DEPS:70,ROUTE_CHANGES:70,API_CONTRACTS:70,CLOUDFLARE:70,STENCIL_API:60,MONOREPO_CONFIG:60,ENV_VARS:60,NEW_DEPS:60,NON_BREAKING_CONFIG:60,DB_MIGRATION:55,CI_WORKFLOW:55,TEST_CHANGES:50,TEST_GAPS:50,CONVENTION_VIOLATIONS:50,FALLBACK:10}});function M9($){return $.replace(/\\/g,"/").toLowerCase()}function H0($,Z){let Q=M9($),X=M9(Z);return Q.localeCompare(X)}function z9($){return[...$].sort((Z,Q)=>{let X=Z.category.localeCompare(Q.category);if(X!==0)return X;let Y=Q.effectiveScore-Z.effectiveScore;if(Y!==0)return Y;let K=Z.ruleKey.localeCompare(Q.ruleKey);if(K!==0)return K;return Z.flagId.localeCompare(Q.flagId)})}function j9($){return[...$].sort((Z,Q)=>{let X=Z.type.localeCompare(Q.type);if(X!==0)return X;let Y=(J)=>{if(J.evidence&&J.evidence.length>0)return J.evidence[0].file;return""},K=Y(Z),q=Y(Q);if(K&&q){let J=H0(K,q);if(J!==0)return J}let W=(J)=>{if(J.evidence&&J.evidence.length>0){let G=J.evidence[0];if(G.line!==void 0)return G.line;if(G.hunk?.newStart!==void 0)return G.hunk.newStart}return 0},V=W(Z),U=W(Q);return V-U})}function F2($){return[...$].sort((Z,Q)=>{let X=H0(Z.file,Q.file);if(X!==0)return X;let Y=Z.line??(Z.hunk?.newStart??0),K=Q.line??(Q.hunk?.newStart??0);return Y-K})}function y2($){return[...$].sort((Z,Q)=>{let X=H0(Z.file,Q.file);if(X!==0)return X;if(Z.hunk&&Q.hunk){let Y=(K)=>{let q=K.match(/\+(\d+)/);return q?parseInt(q[1],10):0};return Y(Z.hunk)-Y(Q.hunk)}return 0})}function eV($){return[...$].sort(H0)}function $J($){let Z=[...$].sort((X,Y)=>X[0].localeCompare(Y[0])),Q={};for(let[X,Y]of Z)Q[X]=Y;return Q}import{createHash as VX}from"node:crypto";function m($){return $.replace(/\\/g,"/")}function L9($){return VX("sha256").update($).digest("hex").slice(0,12)}function h($){return[...$].sort()}function JX($){let Z;switch($.type){case"env-var":{let X=h($.evidenceFiles.map(m));Z=`env-var:${$.name}:${X.join(",")}`;break}case"dependency-change":{Z=`dependency-change:${$.name}:${$.from||"null"}:${$.to||"null"}:${$.section}`;break}case"route-change":{Z=`route-change:${m($.routeId)}:${$.change}:${$.routeType}`;break}case"db-migration":{let X=h($.files.map(m));Z=`db-migration:${$.tool}:${X.join(",")}`;break}case"cloudflare-change":{let X=h($.files.map(m));Z=`cloudflare-change:${$.area}:${X.join(",")}`;break}case"test-change":{let X=h($.files.map(m));Z=`test-change:${$.framework}:${X.join(",")}`;break}case"security-file":{let X=h($.files.map(m)),Y=h($.reasons);Z=`security-file:${X.join(",")}:${Y.join(",")}`;break}case"file-category":{Z=`file-category:${Object.entries($.categories).map(([Y,K])=>`${Y}:${h(K.map(m)).join(",")}`).sort().join("|")}`;break}case"file-summary":{let X=h($.added.map(m)).join(","),Y=h($.modified.map(m)).join(","),K=h($.deleted.map(m)).join(","),q=h($.renamed.map((W)=>`${m(W.from)}->${m(W.to)}`)).join(",");Z=`file-summary:${$.category}:a=${X}:m=${Y}:d=${K}:r=${q}`;break}case"convention-violation":{let X=h($.files.map(m));Z=`convention-violation:${$.message}:${X.join(",")}`;break}case"test-parity-violation":{let X=m($.sourceFile),Y=h($.expectedTestLocations.map(m));Z=`test-parity-violation:${X}:${Y.join(",")}`;break}case"impact-analysis":{let X=m($.sourceFile),Y=h($.affectedFiles.map(m));Z=`impact-analysis:${X}:${Y.join(",")}`;break}case"ci-workflow":{Z=`ci-workflow:${m($.file)}:${$.riskType}`;break}case"sql-risk":{Z=`sql-risk:${m($.file)}:${$.riskType}`;break}case"infra-change":{let X=h($.files.map(m));Z=`infra-change:${$.infraType}:${X.join(",")}`;break}case"api-contract-change":{Z=`api-contract-change:${h($.files.map(m)).join(",")}`;break}case"large-diff":{Z=`large-diff:${$.filesChanged}:${$.linesChanged}`;break}case"lockfile-mismatch":{Z=`lockfile-mismatch:${$.manifestChanged}:${$.lockfileChanged}`;break}case"test-gap":{Z=`test-gap:${$.prodFilesChanged}:${$.testFilesChanged}`;break}case"stencil-component-change":{let X=m($.file);Z=`stencil-component-change:${$.tag}:${$.change}:${X}:${$.fromTag||""}:${$.toTag||""}`;break}case"stencil-prop-change":{let X=m($.file);Z=`stencil-prop-change:${$.tag}:${$.propName}:${$.change}:${X}`;break}case"stencil-event-change":{let X=m($.file);Z=`stencil-event-change:${$.tag}:${$.eventName}:${$.change}:${X}`;break}case"stencil-method-change":{let X=m($.file);Z=`stencil-method-change:${$.tag}:${$.methodName}:${$.change}:${X}`;break}case"stencil-slot-change":{let X=m($.file);Z=`stencil-slot-change:${$.tag}:${$.slotName}:${$.change}:${X}`;break}case"risk-flag":{Z=`risk-flag:${$.risk}:${$.evidenceText}`;break}case"graphql-change":{let X=m($.file),Y=h($.breakingChanges).join(","),K=h($.addedElements).join(",");Z=`graphql-change:${X}:${$.isBreaking}:${Y}:${K}`;break}case"typescript-config":{let X=m($.file),Y=h($.changedOptions.added).join(","),K=h($.changedOptions.removed).join(","),q=h($.changedOptions.modified).join(",");Z=`typescript-config:${X}:${$.isBreaking}:a=${Y}:r=${K}:m=${q}`;break}case"tailwind-config":{let X=m($.file),Y=h($.affectedSections).join(",");Z=`tailwind-config:${X}:${$.configType}:${$.isBreaking}:${Y}`;break}case"monorepo-config":{let X=m($.file),Y=h($.affectedFields).join(",");Z=`monorepo-config:${X}:${$.tool}:${Y}`;break}case"package-exports":{let X=h($.addedExports).join(","),Y=h($.removedExports).join(",");Z=`package-exports:${$.isBreaking}:a=${X}:r=${Y}`;break}case"python-migration":{let X=h($.files.map(m));Z=`python-migration:${$.tool}:${$.risk}:${X.join(",")}`;break}case"python-config":{let X=m($.file),Y=h($.affectedSections).join(",");Z=`python-config:${X}:${$.configType}:${$.isBreaking}:${Y}`;break}case"angular-component-change":{Z=`angular-component-change:${m($.file)}:${$.change}:${$.componentType}:${$.selector||""}`;break}case"vite-config":{let X=m($.file),Y=h($.affectedSections).join(","),K=h($.pluginsDetected).join(",");Z=`vite-config:${X}:${$.isBreaking}:${Y}:${K}`;break}default:throw Error(`Unknown finding type: ${$.type}`)}let Q=L9(Z);return`finding.${$.type}#${Q}`}function l($,Z){let Q=h(Z),X=`${$}:${Q.join(",")}`,Y=L9(X);return`flag.${$}#${Y}`}function K$($){let Z=JX($);return{...$,findingId:Z}}var h$=()=>{};function GX($,Z){let Q=0,X=0;for(let Y of $.diffs)for(let K of Y.hunks)Q+=K.additions.length,X+=K.deletions.length;return{filesChanged:$.files.length,insertions:Q,deletions:X,skippedFilesCount:Z.length}}function OX($){return BX.has($.type)}function HX($){let Z=$.find((G)=>G.type==="file-summary"),Q=$.find((G)=>G.type==="file-category"),X=$.find((G)=>G.type==="large-diff"),Y=$.find((G)=>G.type==="lockfile-mismatch"),K={added:Z?.added??[],modified:Z?.modified??[],deleted:Z?.deleted??[],renamed:Z?.renamed??[]},q={product:[],tests:[],ci:[],infra:[],database:[],docs:[],dependencies:[],config:[],artifacts:[],other:[]},W=Q?.categories??q,V=Q?.summary??[],U=[];if(X)U.push({type:"large-diff",filesChanged:X.filesChanged,linesChanged:X.linesChanged});if(Y)U.push({type:"lockfile-mismatch",manifestChanged:Y.manifestChanged,lockfileChanged:Y.lockfileChanged});let J=Z?.changeDescriptions;return{files:K,byCategory:W,categorySummary:V,changeDescriptions:J,warnings:U}}async function D$($){let{changeSet:Z,findings:Q,riskScore:X,requestedProfile:Y,detectedProfile:K,profileConfidence:q,profileReasons:W,filters:V,skippedFiles:U,warnings:J,noTimestamp:G,repoRoot:B,isDirty:H,mode:_}=$,O=j9(Q);if(O=O.map(K$),V?.maxFindings&&O.length>V.maxFindings)O=O.slice(0,V.maxFindings);if(V?.redact)O=O.map((Q1)=>({...Q1,evidence:F2(Q1.evidence.map(P5))}));else O=O.map((Q1)=>({...Q1,evidence:F2(Q1.evidence)}));let M,z;if(B!==void 0&&H!==void 0)M=B,z=H;else if(B!==void 0)M=B,z=await _$();else if(H!==void 0)M=await H$(),z=H;else[M,z]=await Promise.all([H$(),_$()]);let A={base:Z.base,head:Z.head,range:`${Z.base}..${Z.head}`,repoRoot:M,isDirty:z,mode:_},N={requested:Y,detected:K,confidence:q,reasons:W},E=U??[],w=GX(Z,E),T={defaultExcludes:x5,excludes:V?.excludes??[],includes:V?.includes??[],redact:V?.redact??!1,maxFileBytes:V?.maxFileBytes??1048576,maxDiffBytes:V?.maxDiffBytes??5242880,maxFindings:V?.maxFindings},P=HX(O),I=O.filter((Q1)=>!OX(Q1)),f=G0(I,X.factors),j=B0(f),g=H9(I),c={byArea:j,highlights:g},p=O0(O,K),s1=J??[];return{schemaVersion:"2.1",generatedAt:G?void 0:new Date().toISOString(),git:A,profile:N,stats:w,filters:T,summary:c,categories:f,changeset:P,risk:X,findings:I,actions:p,skippedFiles:E,warnings:s1}}var BX;var _0=x(()=>{_9();Q0();M$();h$();BX=new Set(["file-summary","file-category","large-diff","lockfile-mismatch"])});import{readFile as _X}from"node:fs/promises";async function M0($){let Z=await _X($,"utf-8");return JSON.parse(Z)}function D9($){let Z={...$};return delete Z.generatedAt,Z}function MX($,Z){let Q=(X)=>{if(X===null||typeof X!=="object")return X;if(Array.isArray(X))return X.map(Q);let Y={};return Object.keys(X).sort().forEach((K)=>{Y[K]=Q(X[K])}),Y};return JSON.stringify(Q($))===JSON.stringify(Q(Z))}function N9($){let Z=new Map;for(let Q of $){let X=Q.findingId||Q.flagId;if(X)Z.set(X,Q)}return Z}function z0($){let Z=N9($.beforeItems),Q=N9($.afterItems),X=[],Y=[],K=[];for(let[q,W]of Q){let V=Z.get(q);if(!V)X.push(q);else{let U=D9(V),J=D9(W);if(!MX(U,J))K.push({id:q,before:V,after:W})}}for(let q of Z.keys())if(!Q.has(q))Y.push(q);return X.sort(),Y.sort(),K.sort((q,W)=>q.id.localeCompare(W.id)),{added:X,removed:Y,changed:K}}function j0($,Z){let Q=[];if($.mode!==Z.mode)Q.push({code:"scope-mismatch",message:`Previous run used mode=${$.mode}, current is mode=${Z.mode}`});if($.base!==Z.base)Q.push({code:"scope-mismatch",message:`Previous run used base=${$.base}, current is base=${Z.base}`});if($.head!==Z.head)Q.push({code:"scope-mismatch",message:`Previous run used head=${$.head}, current is head=${Z.head}`});if($.profile!==Z.profile)Q.push({code:"scope-mismatch",message:`Previous run used profile=${$.profile}, current is profile=${Z.profile}`});let X=JSON.stringify($.include||[]),Y=JSON.stringify(Z.include||[]);if(X!==Y)Q.push({code:"scope-mismatch",message:"Include filters differ between runs"});let K=JSON.stringify($.exclude||[]),q=JSON.stringify(Z.exclude||[]);if(K!==q)Q.push({code:"scope-mismatch",message:"Exclude filters differ between runs"});if($.only!==void 0||Z.only!==void 0){let W=JSON.stringify($.only||null),V=JSON.stringify(Z.only||null);if(W!==V)Q.push({code:"scope-mismatch",message:"Category filters differ between runs"})}return Q}function A9($){let Z;if($.git.mode)Z=$.git.mode;else Z=$.git.base?"branch":"unstaged";return{mode:Z,base:$.git.base||null,head:$.git.head||null,profile:$.profile.detected,include:$.filters.includes,exclude:$.filters.excludes}}function R9($){let Z;if($.range.mode)Z=$.range.mode;else Z=$.range.base?"branch":"unstaged";return{mode:Z,base:$.range.base||null,head:$.range.head||null,only:$.filters?.only||null,exclude:$.filters?.exclude}}var m2=()=>{};var T9={};P1(T9,{computeFactsDelta:()=>h2});async function h2($){let{sincePath:Z,currentFacts:Q,mode:X,base:Y,head:K,profile:q,include:W,exclude:V,sinceStrict:U}=$,J;try{J=await M0(Z)}catch(N){let E=N instanceof Error?N.message:String(N);throw new F(`Failed to load previous facts from ${Z}: ${E}`,1)}if(!J.schemaVersion||!J.findings)throw new F(`File ${Z} does not appear to be a valid facts output`,1);let G={mode:X,base:Y,head:K,profile:q,include:W,exclude:V},B=A9(J),H=j0(B,G);if(U&&H.length>0)throw new F(`Scope mismatch detected (--since-strict): ${H.map((N)=>N.message).join("; ")}`,1);let{added:_,removed:O,changed:M}=z0({beforeItems:J.findings,afterItems:Q.findings}),z=M.map((N)=>({findingId:N.id,before:N.before,after:N.after})),A=["--mode",X];if(Y)A.push("--base",Y);if(K)A.push("--head",K);if(A.push("--since",Z),U)A.push("--since-strict");return{schemaVersion:"1.0",generatedAt:new Date().toISOString(),command:{name:"facts",args:A},since:{path:Z,schemaVersion:J.schemaVersion},current:{schemaVersion:Q.schemaVersion},scope:G,warnings:H,delta:{added:_,removed:O,changed:z},summary:{addedCount:_.length,removedCount:O.length,changedCount:z.length}}}var u2=x(()=>{m2();w1()});var w9={};P1(w9,{executeFacts:()=>zX,deriveActions:()=>O0,computeFactsDelta:()=>h2,buildSummaryByArea:()=>B0,buildFacts:()=>D$,aggregateCategories:()=>G0});async function zX($){return D$($)}var x9=x(()=>{_0();_0();u2()});var I9={};P1(I9,{renderSarif:()=>DX,SARIF_RULES:()=>E9});function LX($){return"file:///"+$.replace(/\\/g,"/")+"/"}function DX($,Z){let Q=AX($.findings,Z),X=new Set(Q.map((K)=>K.ruleId)),Y=Array.from(X).sort().map((K)=>{let q=E9[K];if(!q)throw Error(`Unknown SARIF rule ID: ${K}`);return NX(q)});return{version:"2.1.0",$schema:"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",runs:[{tool:{driver:{name:"branch-narrator",version:U5(),informationUri:"https://github.com/better-vibe/branch-narrator",rules:Y}},results:Q,originalUriBaseIds:{SRCROOT:{uri:LX($.git.repoRoot)}}}]}}function NX($){return{id:$.id,name:$.name,shortDescription:{text:$.shortDescription},fullDescription:{text:$.fullDescription},defaultConfiguration:{level:$.defaultLevel},properties:{category:$.category}}}function AX($,Z){let Q=[],X=[...$].sort((Y,K)=>{if(Y.type!==K.type)return Y.type.localeCompare(K.type);return(Y.findingId||"").localeCompare(K.findingId||"")});for(let Y of X){let K=RX(Y,Z);if(K)Q.push(K)}return Q}function RX($,Z){switch($.type){case"db-migration":return TX($);case"dependency-change":return wX($);case"env-var":return xX($,Z);case"cloudflare-change":return EX($);case"route-change":return IX($);case"ci-workflow":return bX($);case"security-file":return PX($);case"graphql-change":return kX($);case"package-exports":return vX($);case"stencil-component-change":return SX($);case"stencil-prop-change":return CX($);case"stencil-event-change":return FX($);case"stencil-method-change":return yX($);case"stencil-slot-change":return mX($);case"typescript-config":return hX($);case"sql-risk":return uX($);case"infra-change":return gX($);case"test-gap":return cX($);case"large-diff":return lX($);default:return null}}function TX($){let Z=$.risk==="high"?"BNR001":"BNR002",Q=$.risk==="high"?"error":"warning",X=$.evidence.map((q)=>({physicalLocation:{artifactLocation:{uri:q.file,uriBaseId:"SRCROOT"},region:q.line?{startLine:q.line}:void 0}})),Y=$.reasons.join(", "),K=$.risk==="high"?`Dangerous SQL migration detected: ${Y}`:`Database migration changed: ${Y}`;return{ruleId:Z,level:Q,message:{text:K},locations:X,partialFingerprints:{findingId:$.findingId||""},properties:{tool:$.tool,files:$.files,risk:$.risk}}}function wX($){if($.impact!=="major"||!jX.includes($.name))return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR003",level:"warning",message:{text:`Major version bump: ${$.name} ${$.from||"?"} → ${$.to||"?"}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{dependency:$.name,from:$.from,to:$.to,section:$.section}}}function xX($,Z){let Q=[];for(let X of $.evidence){let Y=X.line;if(Y==null&&X.excerpt){let K=Z.diffs.find((q)=>q.path===X.file);if(K){let W=t0(K).find((V)=>V.line.includes(X.excerpt));if(W)Y=W.lineNumber}}Q.push({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:Y!=null?{startLine:Y}:void 0}})}return{ruleId:"BNR004",level:"warning",message:{text:`New environment variable referenced: ${$.name}`},locations:Q,partialFingerprints:{findingId:$.findingId||""},properties:{envVar:$.name,change:$.change,evidenceFiles:$.evidenceFiles}}}function EX($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR005",level:"note",message:{text:`Cloudflare configuration changed in ${$.files.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{area:$.area,files:$.files}}}function IX($){let Z=$.evidence.map((Y)=>({physicalLocation:{artifactLocation:{uri:Y.file,uriBaseId:"SRCROOT"},region:Y.line?{startLine:Y.line}:void 0}})),Q=$.methods?` (${$.methods.join(", ")})`:"";return{ruleId:"BNR006",level:"note",message:{text:`API endpoint ${$.change==="added"?"added":$.change==="deleted"?"deleted":"modified"}: ${$.routeId}${Q}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{routeId:$.routeId,file:$.file,change:$.change,routeType:$.routeType,methods:$.methods}}}function bX($){if($.riskType!=="permissions_broadened"&&$.riskType!=="pull_request_target")return null;let Z=$.riskType==="permissions_broadened"?"BNR007":"BNR008",Q=$.evidence.map((Y)=>({physicalLocation:{artifactLocation:{uri:Y.file,uriBaseId:"SRCROOT"},region:Y.line?{startLine:Y.line}:void 0}})),X=$.riskType==="permissions_broadened"?`CI workflow permissions broadened in ${$.file}: ${$.details}`:`CI workflow uses pull_request_target in ${$.file}: ${$.details}`;return{ruleId:Z,level:"error",message:{text:X},locations:Q,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,riskType:$.riskType,details:$.details}}}function PX($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR009",level:"warning",message:{text:`Security-sensitive files changed: ${$.files.join(", ")}. Reasons: ${$.reasons.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{files:$.files,reasons:$.reasons}}}function kX($){if(!$.isBreaking)return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR010",level:"error",message:{text:`Breaking GraphQL schema changes in ${$.file}: ${$.breakingChanges.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,breakingChanges:$.breakingChanges,addedElements:$.addedElements}}}function vX($){if(!$.isBreaking)return null;let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}})),Q=[];if($.removedExports.length>0)Q.push(`removed exports: ${$.removedExports.join(", ")}`);if($.binChanges.removed.length>0)Q.push(`removed bins: ${$.binChanges.removed.join(", ")}`);return{ruleId:"BNR011",level:"error",message:{text:`Breaking package exports changes: ${Q.join("; ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{removedExports:$.removedExports,addedExports:$.addedExports,binChanges:$.binChanges}}}function SX($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil component removed: <${$.tag}>`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,change:$.change,file:$.file}}}function CX($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil prop removed: <${$.tag}> @Prop() ${$.propName}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,propName:$.propName,change:$.change,file:$.file}}}function FX($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil event removed: <${$.tag}> @Event() ${$.eventName}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,eventName:$.eventName,change:$.change,file:$.file}}}function yX($){if($.change!=="removed")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil method removed: <${$.tag}> @Method() ${$.methodName}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,methodName:$.methodName,change:$.change,file:$.file}}}function mX($){if($.change!=="removed")return null;let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}}));return{ruleId:"BNR012",level:"warning",message:{text:`Stencil ${$.slotName==="default"?"default slot":`slot "${$.slotName}"`} removed from <${$.tag}>`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{tag:$.tag,slotName:$.slotName,change:$.change,file:$.file}}}function hX($){if(!$.isBreaking)return null;let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}})),Q=[];if($.strictnessChanges.length>0)Q.push($.strictnessChanges.join(", "));if($.changedOptions.removed.length>0)Q.push(`removed: ${$.changedOptions.removed.join(", ")}`);return{ruleId:"BNR013",level:"warning",message:{text:`Breaking TypeScript config changes in ${$.file}: ${Q.join("; ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,changedOptions:$.changedOptions,strictnessChanges:$.strictnessChanges}}}function uX($){if($.riskType!=="destructive")return null;let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR014",level:"error",message:{text:`Destructive SQL operation in ${$.file}: ${$.details}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{file:$.file,riskType:$.riskType,details:$.details}}}function gX($){let Z=$.evidence.map((X)=>({physicalLocation:{artifactLocation:{uri:X.file,uriBaseId:"SRCROOT"},region:X.line?{startLine:X.line}:void 0}}));return{ruleId:"BNR015",level:"warning",message:{text:`${{dockerfile:"Dockerfile",terraform:"Terraform",k8s:"Kubernetes"}[$.infraType]} configuration changed: ${$.files.join(", ")}`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{infraType:$.infraType,files:$.files}}}function cX($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR016",level:"note",message:{text:`Test coverage gap: ${$.prodFilesChanged} production files changed, ${$.testFilesChanged} test files changed`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{prodFilesChanged:$.prodFilesChanged,testFilesChanged:$.testFilesChanged}}}function lX($){let Z=$.evidence.map((Q)=>({physicalLocation:{artifactLocation:{uri:Q.file,uriBaseId:"SRCROOT"},region:Q.line?{startLine:Q.line}:void 0}}));return{ruleId:"BNR017",level:"note",message:{text:`Large diff detected: ${$.filesChanged} files changed, ${$.linesChanged} lines modified`},locations:Z,partialFingerprints:{findingId:$.findingId||""},properties:{filesChanged:$.filesChanged,linesChanged:$.linesChanged}}}var E9,jX;var b9=x(()=>{s$();E9={BNR001:{id:"BNR001",name:"DangerousSqlInMigration",shortDescription:"Dangerous SQL detected in migration",fullDescription:"Database migration contains potentially destructive SQL operations (DROP, TRUNCATE, ALTER TYPE, etc.) that could cause data loss or service disruption.",defaultLevel:"error",category:"database"},BNR002:{id:"BNR002",name:"MigrationChanged",shortDescription:"Migration changed (non-destructive)",fullDescription:"Database migration file has been modified or added. Review schema changes for compatibility and rollback safety.",defaultLevel:"warning",category:"database"},BNR003:{id:"BNR003",name:"MajorDependencyBump",shortDescription:"Major bump in critical dependencies",fullDescription:"Major version bump detected in critical framework dependencies (e.g., @sveltejs/kit, svelte, vite, react, next). Major upgrades may introduce breaking changes.",defaultLevel:"warning",category:"dependencies"},BNR004:{id:"BNR004",name:"NewEnvVarReference",shortDescription:"New environment variable reference detected",fullDescription:"Code references a new environment variable. Ensure this variable is documented and configured in all deployment environments.",defaultLevel:"warning",category:"config_env"},BNR005:{id:"BNR005",name:"CloudflareConfigChanged",shortDescription:"Cloudflare configuration changed",fullDescription:"Cloudflare configuration files (wrangler.toml, Pages workflows) have been modified. Review deployment settings and worker configurations.",defaultLevel:"note",category:"infra"},BNR006:{id:"BNR006",name:"EndpointChanged",shortDescription:"API endpoint changed",fullDescription:"API endpoint file has been added, modified, or deleted. Verify API contract compatibility and update client code if needed.",defaultLevel:"note",category:"api"},BNR007:{id:"BNR007",name:"CIWorkflowPermissionsBroadened",shortDescription:"CI workflow permissions broadened",fullDescription:"GitHub Actions workflow has broadened permissions, which could allow unauthorized access to secrets or repository data. Review the permission changes carefully.",defaultLevel:"error",category:"security"},BNR008:{id:"BNR008",name:"CIWorkflowPullRequestTarget",shortDescription:"CI workflow uses pull_request_target",fullDescription:"GitHub Actions workflow uses pull_request_target trigger, which runs with write permissions on the base repository. This can be exploited if the workflow checks out or runs code from the PR.",defaultLevel:"error",category:"security"},BNR009:{id:"BNR009",name:"SecurityFileChanged",shortDescription:"Security-sensitive file changed",fullDescription:"A file related to authentication, authorization, or security configuration has been modified. Review these changes carefully for potential vulnerabilities.",defaultLevel:"warning",category:"security"},BNR010:{id:"BNR010",name:"GraphQLBreakingChange",shortDescription:"Breaking change in GraphQL schema",fullDescription:"GraphQL schema contains breaking changes such as removed types, fields, or arguments. This may break existing clients consuming the API.",defaultLevel:"error",category:"api"},BNR011:{id:"BNR011",name:"PackageExportsBreakingChange",shortDescription:"Breaking change in package exports",fullDescription:"Package exports have breaking changes such as removed exports or modified bin entries. This may break downstream consumers of this package.",defaultLevel:"error",category:"api"},BNR012:{id:"BNR012",name:"StencilAPIBreakingChange",shortDescription:"Breaking change in Stencil component API",fullDescription:"Stencil web component has breaking API changes such as removed props, events, methods, or slots. This may break consumers of the component library.",defaultLevel:"warning",category:"api"},BNR013:{id:"BNR013",name:"TypeScriptConfigBreaking",shortDescription:"Breaking TypeScript configuration change",fullDescription:"TypeScript configuration has breaking changes that may cause compilation errors in the codebase, such as stricter type checking options.",defaultLevel:"warning",category:"config_env"},BNR014:{id:"BNR014",name:"DestructiveSQL",shortDescription:"Destructive SQL operation detected",fullDescription:"SQL file contains destructive operations (DROP, TRUNCATE, DELETE without WHERE) that could cause data loss. Review carefully before execution.",defaultLevel:"error",category:"database"},BNR015:{id:"BNR015",name:"InfrastructureChanged",shortDescription:"Infrastructure configuration changed",fullDescription:"Infrastructure files (Dockerfile, Terraform, Kubernetes) have been modified. Review for security implications and deployment impact.",defaultLevel:"warning",category:"infra"},BNR016:{id:"BNR016",name:"TestGapDetected",shortDescription:"Test coverage gap detected",fullDescription:"Production code was modified but no corresponding test files were changed. Consider adding tests to cover the new or modified functionality.",defaultLevel:"note",category:"quality"},BNR017:{id:"BNR017",name:"LargeDiff",shortDescription:"Large diff detected",fullDescription:"This change has a large number of modified files or lines, which may indicate a refactoring or generated code. Consider breaking into smaller PRs for easier review.",defaultLevel:"note",category:"quality"}},jX=["@sveltejs/kit","svelte","vite","react","react-dom","next","@stencil/core"]});function g2($){if($==="pnpm-lock.yaml"||$==="package-lock.json"||$==="yarn.lock"||$==="bun.lockb")return{skip:!0,reason:"lockfile"};if($.endsWith(".d.ts"))return{skip:!0,reason:"generated file"};if($.endsWith(".log"))return{skip:!0,reason:"log file"};let Z=["dist/","build/","coverage/",".turbo/",".next/","out/",".cache/"];for(let Q of Z)if($.includes(Q))return{skip:!0,reason:"build artifact"};return{skip:!1}}var fX;var c2=x(()=>{fX=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lockb","**/*.d.ts","**/*.log","dist/**","build/**","coverage/**",".turbo/**",".next/**","out/**",".cache/**"]});function P9($){let Z=$;Z=Z.replace(rX,"<redacted-github-token>");for(let{eqPattern:Q,colonPattern:X}of dX)Q.lastIndex=0,X.lastIndex=0,Z=Z.replace(Q,(Y,K)=>`${K}=<redacted>`),Z=Z.replace(X,(Y,K)=>`${K}: <redacted>`);if(!Z.includes("<redacted")&&!Z.includes("hash")&&!Z.includes("checksum"))Z=Z.replace(aX,"<redacted-value>");return Z}function l2($){return $.map(P9)}var pX,dX,rX,aX;var f2=x(()=>{pX=[/token/i,/secret/i,/password/i,/api[_-]?key/i,/private[_-]?key/i,/access[_-]?key/i,/auth[_-]?token/i],dX=pX.map(($)=>({eqPattern:new RegExp(`(${$.source})\\s*=\\s*['"]?([^'"\\s}<]+)['"]?`,"gi"),colonPattern:new RegExp(`(${$.source})\\s*:\\s*['"]?([^'"\\s,}<]+)['"]?`,"gi")})),rX=/(ghp_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9_]+)/g,aX=/\b[a-zA-Z0-9+/=]{32,}\b/g});function sX($){let Z={api:0,churn:0,ci:0,db:0,deps:0,infra:0,security:0,tests:0};for(let Q of $)Z[Q.category]+=Q.effectiveScore;for(let Q of Object.keys(Z))Z[Q]=Math.min(100,Z[Q]);return Z}function oX($){let Z=Object.values($);if(Z.length===0)return 0;let Q=Math.max(...Z),Y=[...Z].sort((W,V)=>V-W).slice(0,3);while(Y.length<3)Y.push(0);let K=Y.reduce((W,V)=>W+V,0)/3,q=0.6*Q+0.4*K;return Math.round(Math.max(0,Math.min(100,q)))}function iX($){if($>=81)return"critical";if($>=61)return"high";if($>=41)return"elevated";if($>=21)return"moderate";return"low"}function nX($){let Q=Object.entries($).sort((U,J)=>J[1]-U[1]),X=Q.length>0?Q[0]:["security",0],Y=Q.slice(0,3).map(([U,J])=>({category:U,score:J})),K=X[1],q=Y.map((U)=>U.score);while(q.length<3)q.push(0);let W=q.reduce((U,J)=>U+J,0)/3,V=`riskScore = round(0.6 * ${K} + 0.4 * ${W.toFixed(2)})`;return{maxCategory:{category:X[0],score:K},topCategories:Y,formula:V}}function p2($,Z,Q){let X=$;if(Z&&Z.length>0)X=X.filter((Y)=>Z.includes(Y.category));if(Q&&Q.length>0)X=X.filter((Y)=>!Q.includes(Y.category));return X}function d2($,Z,Q,X,Y){let K=sX(Q),q=oX(K),W=iX(q),V={schemaVersion:"2.0",range:{base:$,head:Z,mode:Y?.mode},riskScore:q,riskLevel:W,categoryScores:K,flags:z9(Q),skippedFiles:X};if(!Y?.noTimestamp)V.generatedAt=new Date().toISOString();if(Y?.explainScore)V.scoreBreakdown=nX(K);if(Y?.only||Y?.exclude)V.filters={only:Y.only,exclude:Y.exclude};return V}var r2=()=>{};function A1($){return $.evidence.map((Z)=>({file:Z.file,hunk:Z.hunk?`@@ -${Z.hunk.oldStart},${Z.hunk.oldLines} +${Z.hunk.newStart},${Z.hunk.newLines} @@`:void 0,lines:Z.excerpt.split(`
51
+ `).slice(0,5)}))}function tX($){let Z=[];for(let Q of $){let X=[Q.findingId];switch(Q.riskType){case"permissions_broadened":{Z.push({ruleKey:"security.workflow_permissions_broadened",flagId:l("security.workflow_permissions_broadened",X),relatedFindingIds:X,category:"security",score:35,confidence:0.9,title:"Workflow permissions broadened",summary:`Workflow ${Q.file} has broadened permissions (write access)`,evidence:A1(Q),suggestedChecks:["Review if write permissions are necessary","Ensure principle of least privilege","Check if GITHUB_TOKEN usage is secure"],effectiveScore:Math.round(31.5)});break}case"pull_request_target":{Z.push({ruleKey:"security.workflow_uses_pull_request_target",flagId:l("security.workflow_uses_pull_request_target",X),relatedFindingIds:X,category:"security",score:40,confidence:0.9,title:"Workflow uses pull_request_target",summary:`Workflow ${Q.file} uses pull_request_target event (can expose secrets)`,evidence:A1(Q),suggestedChecks:["Ensure no untrusted code is executed in this context","Review if pull_request_target is necessary (vs pull_request)","Verify secrets are not exposed to PR authors"],effectiveScore:Math.round(36)});break}case"remote_script_download":{Z.push({ruleKey:"security.workflow_downloads_remote_script",flagId:l("security.workflow_downloads_remote_script",X),relatedFindingIds:X,category:"security",score:45,confidence:0.85,title:"Workflow downloads and executes remote scripts",summary:`Workflow ${Q.file} downloads and pipes to shell (supply chain risk)`,evidence:A1(Q),suggestedChecks:["Pin script sources to specific commit SHAs","Verify script integrity with checksums","Consider vendoring the script instead"],effectiveScore:Math.round(38.25)});break}case"pipeline_changed":{Z.push({ruleKey:"ci.pipeline_changed",flagId:l("ci.pipeline_changed",X),relatedFindingIds:X,category:"ci",score:10,confidence:0.7,title:"CI/CD pipeline configuration changed",summary:`Pipeline ${Q.file} was modified`,evidence:A1(Q),suggestedChecks:["Review pipeline changes for security implications","Test pipeline changes in a non-production environment"],effectiveScore:Math.round(7)});break}}}return Z}function eX($){let Z=[];for(let Q of $){let X=[Q.findingId];switch(Q.riskType){case"destructive":{Z.push({ruleKey:"db.destructive_sql",flagId:l("db.destructive_sql",X),relatedFindingIds:X,category:"db",score:45,confidence:0.9,title:"Destructive SQL detected",summary:`Migration ${Q.file} contains DROP TABLE/COLUMN or TRUNCATE`,evidence:A1(Q),suggestedChecks:["Backup data before running migration","Verify this is intentional data deletion","Test migration rollback procedure","Consider making column nullable instead of dropping"],effectiveScore:Math.round(40.5)});break}case"schema_change":{Z.push({ruleKey:"db.schema_change_risky",flagId:l("db.schema_change_risky",X),relatedFindingIds:X,category:"db",score:30,confidence:0.85,title:"Risky schema change detected",summary:`Migration ${Q.file} contains ALTER COLUMN or TYPE change`,evidence:A1(Q),suggestedChecks:["Test schema changes on production-like data","Check for data type compatibility","Monitor migration execution time (may lock table)"],effectiveScore:Math.round(25.5)});break}case"unscoped_modification":{Z.push({ruleKey:"db.unscoped_data_modification",flagId:l("db.unscoped_data_modification",X),relatedFindingIds:X,category:"db",score:35,confidence:0.75,title:"Unscoped data modification detected",summary:`Migration ${Q.file} contains UPDATE/DELETE without WHERE clause`,evidence:A1(Q),suggestedChecks:["Verify this affects all rows intentionally","Add WHERE clause if only subset should be modified","Test on staging data first"],effectiveScore:Math.round(26.25)});break}}}return Z}function $Y($){let Z=[],Q=$.filter((W)=>W.type==="stencil-component-change"),X=$.filter((W)=>W.type==="stencil-prop-change"),Y=$.filter((W)=>W.type==="stencil-event-change"),K=$.filter((W)=>W.type==="stencil-method-change"),q=$.filter((W)=>W.type==="stencil-slot-change");for(let W of Q){if(W.change==="tag-changed"){let U=[W.findingId];Z.push({ruleKey:"stencil.tag_changed",flagId:l("stencil.tag_changed",U),relatedFindingIds:U,category:"api",score:45,confidence:0.95,title:"Component tag changed",summary:`Tag changed from "${W.fromTag}" to "${W.toTag}"`,evidence:A1(W),suggestedChecks:["Update all usages of this component","This is a breaking change"],effectiveScore:Math.round(42.75)})}if(W.change==="shadow-changed"){let U=[W.findingId];Z.push({ruleKey:"stencil.shadow_changed",flagId:l("stencil.shadow_changed",U),relatedFindingIds:U,category:"api",score:25,confidence:0.9,title:"Shadow DOM configuration changed",summary:`Shadow DOM enabled changed from ${W.fromShadow} to ${W.toShadow}`,evidence:A1(W),suggestedChecks:["Check styles and global styling impact"],effectiveScore:Math.round(22.5)})}}for(let W of X)if(W.change==="removed"){let U=[W.findingId];Z.push({ruleKey:"stencil.prop_removed",flagId:l("stencil.prop_removed",U),relatedFindingIds:U,category:"api",score:40,confidence:0.95,title:"Component prop removed",summary:`Prop "${W.propName}" removed from <${W.tag}>`,evidence:A1(W),suggestedChecks:["This is a breaking change","Check usages"],effectiveScore:Math.round(38)})}else if(W.change==="changed"){let U=[W.findingId];Z.push({ruleKey:"stencil.prop_changed",flagId:l("stencil.prop_changed",U),relatedFindingIds:U,category:"api",score:35,confidence:0.9,title:"Component prop modified",summary:`Prop "${W.propName}" options changed`,evidence:A1(W),suggestedChecks:["Check for attribute/reflect/mutable changes"],effectiveScore:Math.round(31.5)})}for(let W of Y)if(W.change==="removed"){let U=[W.findingId];Z.push({ruleKey:"stencil.event_removed",flagId:l("stencil.event_removed",U),relatedFindingIds:U,category:"api",score:40,confidence:0.95,title:"Component event removed",summary:`Event "${W.eventName}" removed from <${W.tag}>`,evidence:A1(W),suggestedChecks:["This is a breaking change","Check event listeners"],effectiveScore:Math.round(38)})}else if(W.change==="changed"){let U=[W.findingId];Z.push({ruleKey:"stencil.event_changed",flagId:l("stencil.event_changed",U),relatedFindingIds:U,category:"api",score:35,confidence:0.9,title:"Component event modified",summary:`Event "${W.eventName}" options changed`,evidence:A1(W),suggestedChecks:["Check bubbles/composed/cancelable options"],effectiveScore:Math.round(31.5)})}for(let W of K)if(W.change==="removed"){let U=[W.findingId];Z.push({ruleKey:"stencil.method_removed",flagId:l("stencil.method_removed",U),relatedFindingIds:U,category:"api",score:40,confidence:0.95,title:"Component method removed",summary:`Method "${W.methodName}" removed from <${W.tag}>`,evidence:A1(W),suggestedChecks:["This is a breaking change","Check usages"],effectiveScore:Math.round(38)})}else if(W.change==="changed");for(let W of q)if(W.change==="removed"){let U=[W.findingId];Z.push({ruleKey:"stencil.slot_removed",flagId:l("stencil.slot_removed",U),relatedFindingIds:U,category:"api",score:35,confidence:0.9,title:"Component slot removed",summary:`Slot "${W.slotName}" removed from <${W.tag}>`,evidence:A1(W),suggestedChecks:["Check content projection usages"],effectiveScore:Math.round(31.5)})}return Z}function a2($){let Z=[],Q=$.filter((O)=>O.type==="ci-workflow"),X=$.filter((O)=>O.type==="sql-risk"),Y=$.filter((O)=>O.type==="infra-change"),K=$.filter((O)=>O.type==="api-contract-change"),q=$.filter((O)=>O.type==="large-diff"),W=$.filter((O)=>O.type==="lockfile-mismatch"),V=$.filter((O)=>O.type==="test-gap"),U=$.filter((O)=>O.type==="dependency-change"),J=$.filter((O)=>O.type==="db-migration"),G=$.filter((O)=>O.type==="test-change");Z.push(...tX(Q)),Z.push(...eX(X)),Z.push(...$Y($));for(let O of Y){let M=[O.findingId],z=`infra.${O.infraType}_changed`,A={dockerfile:"Dockerfile changed",terraform:"Terraform configuration changed",k8s:"Kubernetes manifest changed"};Z.push({ruleKey:z,flagId:l(z,M),relatedFindingIds:M,category:"infra",score:20,confidence:0.8,title:A[O.infraType],summary:`${O.files.length} ${O.infraType} ${O.files.length===1?"file":"files"} changed`,evidence:O.files.slice(0,3).map((N)=>({file:N,lines:["File changed"]})),suggestedChecks:["Review infrastructure changes carefully","Test in staging environment","Verify no unintended resource changes"],effectiveScore:Math.round(16)})}if(K.length>0){let O=K.map((A)=>A.findingId),M="api.contract_changed",z=K.flatMap((A)=>A.files);Z.push({ruleKey:"api.contract_changed",flagId:l("api.contract_changed",O),relatedFindingIds:O,category:"api",score:25,confidence:0.85,title:"API contract changed",summary:`${z.length} API ${z.length===1?"file":"files"} changed`,evidence:z.slice(0,3).map((A)=>({file:A,lines:["File changed"]})),suggestedChecks:["Verify backwards compatibility","Update API documentation","Notify API consumers of changes"],effectiveScore:Math.round(21.25)})}if(q.length>0){let O=q[0],M=[O.findingId],z="churn.large_diff";Z.push({ruleKey:"churn.large_diff",flagId:l("churn.large_diff",M),relatedFindingIds:M,category:"churn",score:15,confidence:0.9,title:"Large diff detected",summary:`${O.filesChanged} files changed, ${O.linesChanged} lines modified`,evidence:[],suggestedChecks:["Consider breaking into smaller PRs","Ensure adequate test coverage","Review carefully for unintended changes"],effectiveScore:Math.round(13.5)})}for(let O of W){let M=[O.findingId],z="deps.lockfile_without_manifest";Z.push({ruleKey:"deps.lockfile_without_manifest",flagId:l("deps.lockfile_without_manifest",M),relatedFindingIds:M,category:"deps",score:20,confidence:0.9,title:"Lockfile changed without manifest",summary:O.manifestChanged?"package.json changed without lockfile update":"Lockfile changed without package.json update",evidence:[],suggestedChecks:["Run package manager install to sync lockfile","Verify dependencies are correctly resolved"],effectiveScore:Math.round(18)})}for(let O of V){let M=[O.findingId],z="tests.possible_gap";Z.push({ruleKey:"tests.possible_gap",flagId:l("tests.possible_gap",M),relatedFindingIds:M,category:"tests",score:18,confidence:0.7,title:"Possible test coverage gap",summary:`${O.prodFilesChanged} production files changed with no test updates`,evidence:[],suggestedChecks:["Add tests for new functionality","Update existing tests if behavior changed"],effectiveScore:Math.round(12.6)})}let B=U.filter((O)=>O.section==="dependencies"&&!O.from);if(B.length>0){let O=B.map((z)=>z.findingId),M="deps.new_prod_dependency";Z.push({ruleKey:"deps.new_prod_dependency",flagId:l("deps.new_prod_dependency",O),relatedFindingIds:O,category:"deps",score:15,confidence:0.85,title:"New production dependencies added",summary:`${B.length} new production ${B.length===1?"dependency":"dependencies"} added`,evidence:B.slice(0,5).map((z)=>({file:"package.json",lines:[`+ "${z.name}": "${z.to}"`]})),suggestedChecks:["Review new dependencies for security vulnerabilities","Check license compatibility","Verify dependencies are actively maintained"],tags:B.map((z)=>z.name),effectiveScore:Math.round(12.75)})}let H=U.filter((O)=>O.impact==="major");if(H.length>0){let O=H.map((z)=>z.findingId),M="deps.major_version_bump";Z.push({ruleKey:"deps.major_version_bump",flagId:l("deps.major_version_bump",O),relatedFindingIds:O,category:"deps",score:25,confidence:0.9,title:"Major dependency version bump",summary:`${H.length} ${H.length===1?"dependency":"dependencies"} with major version changes`,evidence:H.slice(0,5).map((z)=>({file:"package.json",lines:[`"${z.name}": "${z.from}" -> "${z.to}"`]})),suggestedChecks:["Review breaking changes in dependency changelogs","Update code for API changes","Run full test suite"],tags:H.map((z)=>z.name),effectiveScore:Math.round(22.5)})}if(J.length>0){let O=J.map((z)=>z.findingId),M="db.migrations_changed";Z.push({ruleKey:"db.migrations_changed",flagId:l("db.migrations_changed",O),relatedFindingIds:O,category:"db",score:12,confidence:0.8,title:"Database migrations changed",summary:`${J.length} migration/SQL ${J.length===1?"file":"files"} changed`,evidence:J.slice(0,3).flatMap((z)=>z.files.map((A)=>({file:A,lines:["Migration file changed"]}))),suggestedChecks:["Test migrations on a staging database","Ensure migrations are reversible","Check for data loss or downtime impact"],effectiveScore:Math.round(9.600000000000001)})}if(G.length>0){let O=G.map((z)=>z.findingId),M="tests.changed";Z.push({ruleKey:"tests.changed",flagId:l("tests.changed",O),relatedFindingIds:O,category:"tests",score:5,confidence:0.8,title:"Test files changed",summary:`${G.length} test ${G.length===1?"file":"files"} modified`,evidence:G.slice(0,3).flatMap((z)=>z.files.map((A)=>({file:A,lines:["Test file changed"]}))),suggestedChecks:["Verify tests still pass","Review test coverage changes"],effectiveScore:Math.round(4)})}let _=$.filter((O)=>O.type==="test-parity-violation");if(_.length>0){let O=_.map((T)=>T.findingId),M="tests.missing_parity",z=_.filter((T)=>T.confidence==="high").length,A=_.filter((T)=>T.confidence==="medium").length,N=12+z*2+A*1,E=Math.min(N,25),w=z>A?0.85:0.7;Z.push({ruleKey:"tests.missing_parity",flagId:l("tests.missing_parity",O),relatedFindingIds:O,category:"tests",score:E,confidence:w,title:"Source files without test coverage",summary:`${_.length} source ${_.length===1?"file":"files"} modified without corresponding tests`,evidence:_.slice(0,5).map((T)=>({file:T.sourceFile,lines:[`No test file found (expected: ${T.expectedTestLocations[0]||"unknown"})`]})),suggestedChecks:["Add tests for new/changed code","Verify existing tests cover the changes","Consider if these files need unit tests"],effectiveScore:Math.round(E*w)})}return Z}var s2=x(()=>{h$()});function ZY($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}function QY($){let Z=[];Z.push("# Risk Report"),Z.push(""),Z.push(`**Range:** \`${$.range.base}..${$.range.head}\``),Z.push("");let Q=YY($.riskLevel);Z.push(`## Overall Risk: ${Q} ${$.riskLevel.toUpperCase()}`),Z.push(""),Z.push(`**Score:** ${$.riskScore}/100`),Z.push(""),Z.push("### Category Scores"),Z.push("");let X=Object.entries($.categoryScores).sort((Y,K)=>K[1]-Y[1]);for(let[Y,K]of X)if(K>0){let q="█".repeat(Math.floor(K/10));Z.push(`- **${Y}**: ${K}/100 ${q}`)}if(Z.push(""),$.flags.length>0){Z.push("## Risk Flags"),Z.push("");let Y=KY($.flags);for(let[K,q]of Object.entries(Y)){if(q.length===0)continue;Z.push(`### ${K.toUpperCase()}`),Z.push("");for(let W of q){if(Z.push(`#### ${W.title}`),Z.push(""),Z.push(`**Rule:** \`${W.ruleKey}\``),Z.push(`**Flag ID:** \`${W.flagId}\``),Z.push(`**Score:** ${W.effectiveScore}/100 (base: ${W.score}, confidence: ${W.confidence})`),Z.push(""),Z.push(W.summary),Z.push(""),W.evidence.length>0){Z.push("**Evidence:**"),Z.push("");for(let V of W.evidence){if(Z.push(`- **${V.file}**`),V.hunk)Z.push(` \`${V.hunk}\``);if(V.lines.length>0){Z.push(" ```");for(let U of V.lines)Z.push(` ${U}`);Z.push(" ```")}}Z.push("")}if(W.suggestedChecks.length>0){Z.push("**Suggested Checks:**"),Z.push("");for(let V of W.suggestedChecks)Z.push(`- ${V}`);Z.push("")}}}}if($.scoreBreakdown){Z.push("## Score Breakdown"),Z.push(""),Z.push(`**Max Category:** ${$.scoreBreakdown.maxCategory.category} (${$.scoreBreakdown.maxCategory.score})`),Z.push(""),Z.push("**Top 3 Categories:**");for(let Y of $.scoreBreakdown.topCategories)Z.push(`- ${Y.category}: ${Y.score}`);Z.push(""),Z.push(`**Formula:** \`${$.scoreBreakdown.formula}\``),Z.push("")}if($.skippedFiles.length>0){Z.push("## Skipped Files"),Z.push(""),Z.push(`${$.skippedFiles.length} files were skipped:`),Z.push("");for(let Y of $.skippedFiles.slice(0,20))Z.push(`- \`${Y.file}\` (${Y.reason})`);if($.skippedFiles.length>20)Z.push(`- ... and ${$.skippedFiles.length-20} more`);Z.push("")}return Z.join(`
52
+ `)}function XY($){let Z=[];Z.push("RISK REPORT"),Z.push("=".repeat(60)),Z.push(""),Z.push(`Range: ${$.range.base}..${$.range.head}`),Z.push(""),Z.push(`Overall Risk: ${$.riskLevel.toUpperCase()}`),Z.push(`Score: ${$.riskScore}/100`),Z.push(""),Z.push("Category Scores:"),Z.push("-".repeat(40));let Q=Object.entries($.categoryScores).sort((X,Y)=>Y[1]-X[1]);for(let[X,Y]of Q)if(Y>0){let K="#".repeat(Math.floor(Y/5));Z.push(` ${X.padEnd(12)} ${Y.toString().padStart(3)}/100 ${K}`)}if(Z.push(""),$.flags.length>0){Z.push("Risk Flags:"),Z.push("-".repeat(40));for(let X of $.flags)if(Z.push(""),Z.push(`[${X.ruleKey}] ${X.title}`),Z.push(` Score: ${X.effectiveScore}/100`),Z.push(` ${X.summary}`),X.evidence.length>0){Z.push(` Evidence: ${X.evidence.length} location(s)`);for(let Y of X.evidence.slice(0,2))Z.push(` - ${Y.file}`)}Z.push("")}if($.skippedFiles.length>0)Z.push(`Skipped Files: ${$.skippedFiles.length}`),Z.push("");return Z.join(`
53
+ `)}function YY($){switch($){case"critical":return"\uD83D\uDD34";case"high":return"\uD83D\uDFE0";case"elevated":return"\uD83D\uDFE1";case"moderate":return"\uD83D\uDD35";case"low":return"\uD83D\uDFE2";default:return"⚪"}}function KY($){let Z={};for(let Q of $){if(!Z[Q.category])Z[Q.category]=[];Z[Q.category].push(Q)}return Z}var k9={};P1(k9,{computeRiskReportDelta:()=>o2});async function o2($){let{sincePath:Z,currentReport:Q,mode:X,base:Y,head:K,only:q,exclude:W,sinceStrict:V}=$,U;try{U=await M0(Z)}catch(N){let E=N instanceof Error?N.message:String(N);throw new F(`Failed to load previous risk report from ${Z}: ${E}`,1)}if(!U.schemaVersion||!U.flags||U.riskScore===void 0)throw new F(`File ${Z} does not appear to be a valid risk report output`,1);let J={mode:X,base:Y,head:K,only:q},G=R9(U),B=j0(G,J);if(V&&B.length>0)throw new F(`Scope mismatch detected (--since-strict): ${B.map((N)=>N.message).join("; ")}`,1);let{added:H,removed:_,changed:O}=z0({beforeItems:U.flags,afterItems:Q.flags}),M=O.map((N)=>({flagId:N.id,before:N.before,after:N.after})),z={from:U.riskScore,to:Q.riskScore,delta:Q.riskScore-U.riskScore},A=["--mode",X];if(Y)A.push("--base",Y);if(K)A.push("--head",K);if(q)A.push("--only",q.join(","));if(W)A.push("--exclude",W.join(","));if(A.push("--since",Z),V)A.push("--since-strict");return{schemaVersion:"1.0",generatedAt:new Date().toISOString(),command:{name:"risk-report",args:A},since:{path:Z,schemaVersion:U.schemaVersion},current:{schemaVersion:Q.schemaVersion},scope:J,delta:{riskScore:z,flags:{added:H,removed:_,changed:M}},summary:{flagAddedCount:H.length,flagRemovedCount:_.length,flagChangedCount:M.length}}}var i2=x(()=>{m2();w1()});var v9={};P1(v9,{shouldSkipFile:()=>g2,renderRiskReportText:()=>XY,renderRiskReportMarkdown:()=>QY,renderRiskReportJSON:()=>ZY,redactLines:()=>l2,redactLine:()=>P9,generateRiskReport:()=>N$,findingsToFlags:()=>a2,filterFlagsByCategory:()=>p2,executeRiskReport:()=>WY,computeRiskReportDelta:()=>o2,computeRiskReport:()=>d2,DEFAULT_EXCLUSIONS:()=>fX});async function N$($,Z={}){let{only:Q,exclude:X,maxEvidenceLines:Y=5,redact:K=!1,explainScore:q=!1,noTimestamp:W=!1,profile:V="auto",cwd:U=process.cwd(),mode:J,testParity:G=!1}=Z,B=[];for(let A of $.files){let N=g2(A.path);if(N.skip)B.push({file:A.path,reason:N.reason||"excluded"})}let H=Y$(V,$,U),_=u1(H),O=await F1(_.analyzers,$);if(G){let{testParityAnalyzer:A}=await Promise.resolve().then(() => (q0(),W2)),N=await A.analyze($);O.push(...N)}let M=O.map(K$),z=a2(M);if(z=p2(z,Q,X),K||Y!==5)z=z.map((A)=>({...A,evidence:y2(A.evidence.map((N)=>({...N,lines:K?l2(N.lines.slice(0,Y)):N.lines.slice(0,Y)})))}));else z=z.map((A)=>({...A,evidence:y2(A.evidence)}));return d2($.base,$.head,z,B,{explainScore:q,noTimestamp:W,mode:J,only:Q,exclude:X})}async function WY($,Z={}){return await N$($,Z)}var L0=x(()=>{c2();f2();r2();m$();h$();s2();i2();c2();f2();r2();s2()});var C9={};P1(C9,{executeZoom:()=>qY});async function qY($,Z){if(Z.findingId&&Z.flagId)throw new F("Cannot specify both --finding and --flag. Use only one.",1);if(!Z.findingId&&!Z.flagId)throw new F("Must specify either --finding <id> or --flag <id>",1);if(Z.findingId)return UY($,Z);else return VY($,Z)}async function UY($,Z){let Q=Z.findingId,X=Y$(Z.profile,$,process.cwd()),Y=u1(X),W=(await F1(Y.analyzers,$)).map(K$).find((G)=>G.findingId===Q);if(!W)throw new F(`Finding not found: ${Q}. Run 'facts' or 'risk-report' to see available findings.`,1);let V=W.evidence.slice(0,Z.maxEvidenceLines).map((G)=>({file:G.file,excerpt:Z.redact?X0(G.excerpt):G.excerpt,line:G.line,hunk:G.hunk})),U;if(Z.includePatch)U=await JY($,W,Z.unified,Z.redact);return{schemaVersion:"1.0",generatedAt:Z.noTimestamp?void 0:new Date().toISOString(),range:{base:$.base,head:$.head},itemType:"finding",findingId:Q,finding:W,evidence:V,patchContext:U}}async function VY($,Z){let Q=Z.flagId,X=Y$(Z.profile,$,process.cwd()),Y=u1(X),q=(await F1(Y.analyzers,$)).map(K$),V=(await N$($,{profile:Z.profile,redact:Z.redact,maxEvidenceLines:Z.maxEvidenceLines,noTimestamp:Z.noTimestamp})).flags.find((B)=>B.flagId===Q);if(!V)throw new F(`Flag not found: ${Q}. Run 'risk-report' to see available flags.`,1);let U=q.filter((B)=>V.relatedFindingIds.includes(B.findingId)),J;if(Z.includePatch&&V.evidence.length>0)J=await S9($,V.evidence.map((B)=>B.file),Z.unified,Z.redact);return{schemaVersion:"1.0",generatedAt:Z.noTimestamp?void 0:new Date().toISOString(),range:{base:$.base,head:$.head},itemType:"flag",flagId:Q,flag:V,evidence:V.evidence.slice(0,Z.maxEvidenceLines),relatedFindings:U,patchContext:J}}async function JY($,Z,Q,X){let Y=new Set;for(let K of Z.evidence)Y.add(K.file);return S9($,Array.from(Y),Q,X)}async function S9($,Z,Q,X){let Y=[];for(let K of Z){let q=$.diffs.find((W)=>W.path===K);if(!q)continue;Y.push({file:q.path,status:q.status,hunks:q.hunks.map((W)=>({oldStart:W.oldStart,oldLines:W.oldLines,newStart:W.newStart,newLines:W.newLines,content:X?X0(W.content):W.content}))})}return Y}var F9=x(()=>{w1();m$();h$();L0()});var y9={};P1(y9,{renderZoomText:()=>_Y,renderZoomMarkdown:()=>BY,renderZoomJSON:()=>GY});function GY($,Z){return Z?JSON.stringify($,null,2):JSON.stringify($)}function BY($){if($.itemType==="finding")return OY($);else return HY($)}function OY($){let Z=[];if(Z.push(`# Finding: ${$.findingId}`),Z.push(""),Z.push(`**Type:** ${$.finding.type}`),Z.push(`**Category:** ${$.finding.category}`),Z.push(`**Confidence:** ${$.finding.confidence}`),Z.push(""),Z.push(`**Range:** ${$.range.base}..${$.range.head}`),Z.push(""),Z.push("## Details"),Z.push(""),Z.push("```json"),Z.push(JSON.stringify($.finding,null,2)),Z.push("```"),Z.push(""),$.evidence.length>0){Z.push("## Evidence"),Z.push("");for(let Q of $.evidence){if(Z.push(`### ${Q.file}`),Q.line!==void 0)Z.push(`Line ${Q.line}`);if(Q.hunk)Z.push(`Hunk: @@ -${Q.hunk.oldStart},${Q.hunk.oldLines} +${Q.hunk.newStart},${Q.hunk.newLines} @@`);Z.push(""),Z.push("```"),Z.push(Q.excerpt),Z.push("```"),Z.push("")}}if($.patchContext&&$.patchContext.length>0){Z.push("## Patch Context"),Z.push("");for(let Q of $.patchContext){Z.push(`### ${Q.file} (${Q.status})`),Z.push("");for(let X of Q.hunks)Z.push("```diff"),Z.push(`@@ -${X.oldStart},${X.oldLines} +${X.newStart},${X.newLines} @@`),Z.push(X.content),Z.push("```"),Z.push("")}}return Z.join(`
54
+ `)}function HY($){let Z=[];if(Z.push(`# Flag: ${$.flagId}`),Z.push(""),Z.push(`**Rule:** ${$.flag.ruleKey}`),Z.push(`**Category:** ${$.flag.category}`),Z.push(`**Score:** ${$.flag.effectiveScore} (base: ${$.flag.score}, confidence: ${$.flag.confidence})`),Z.push(""),Z.push(`**Range:** ${$.range.base}..${$.range.head}`),Z.push(""),Z.push("## Details"),Z.push(""),Z.push(`**Title:** ${$.flag.title}`),Z.push(""),Z.push(`**Summary:** ${$.flag.summary}`),Z.push(""),$.flag.suggestedChecks&&$.flag.suggestedChecks.length>0){Z.push("### Suggested Checks"),Z.push("");for(let Q of $.flag.suggestedChecks)Z.push(`- ${Q}`);Z.push("")}if($.evidence.length>0){Z.push("## Evidence"),Z.push("");for(let Q of $.evidence){if(Z.push(`### ${Q.file}`),Q.hunk)Z.push(`Hunk: ${Q.hunk}`);Z.push(""),Z.push("```"),Z.push(Q.lines.join(`
51
55
  `)),Z.push("```"),Z.push("")}}if($.relatedFindings&&$.relatedFindings.length>0){Z.push("## Related Findings"),Z.push("");for(let Q of $.relatedFindings)Z.push(`- **${Q.findingId}** (${Q.type}, ${Q.category})`);Z.push("")}if($.patchContext&&$.patchContext.length>0){Z.push("## Patch Context"),Z.push("");for(let Q of $.patchContext){Z.push(`### ${Q.file} (${Q.status})`),Z.push("");for(let X of Q.hunks)Z.push("```diff"),Z.push(`@@ -${X.oldStart},${X.oldLines} +${X.newStart},${X.newLines} @@`),Z.push(X.content),Z.push("```"),Z.push("")}}return Z.join(`
52
- `)}function nQ($){if($.itemType==="finding")return iQ($);else return tQ($)}function iQ($){let Z=[];if(Z.push(`Finding: ${$.findingId}`),Z.push("=".repeat(60)),Z.push(""),Z.push(`Type: ${$.finding.type}`),Z.push(`Category: ${$.finding.category}`),Z.push(`Confidence: ${$.finding.confidence}`),Z.push(`Range: ${$.range.base}..${$.range.head}`),Z.push(""),$.evidence.length>0){Z.push("Evidence:"),Z.push("-".repeat(60));for(let Q of $.evidence){if(Z.push(`File: ${Q.file}`),Q.line!==void 0)Z.push(` Line: ${Q.line}`);if(Q.hunk)Z.push(` Hunk: @@ -${Q.hunk.oldStart},${Q.hunk.oldLines} +${Q.hunk.newStart},${Q.hunk.newLines} @@`);Z.push(""),Z.push(Q.excerpt),Z.push("")}}if($.patchContext&&$.patchContext.length>0){Z.push("Patch Context:"),Z.push("-".repeat(60));for(let Q of $.patchContext){Z.push(`File: ${Q.file} (${Q.status})`),Z.push("");for(let X of Q.hunks)Z.push(`@@ -${X.oldStart},${X.oldLines} +${X.newStart},${X.newLines} @@`),Z.push(X.content),Z.push("")}}return Z.join(`
53
- `)}function tQ($){let Z=[];if(Z.push(`Flag: ${$.flagId}`),Z.push("=".repeat(60)),Z.push(""),Z.push(`Rule: ${$.flag.ruleKey}`),Z.push(`Category: ${$.flag.category}`),Z.push(`Score: ${$.flag.effectiveScore} (base: ${$.flag.score}, confidence: ${$.flag.confidence})`),Z.push(`Range: ${$.range.base}..${$.range.head}`),Z.push(""),Z.push(`Title: ${$.flag.title}`),Z.push(`Summary: ${$.flag.summary}`),Z.push(""),$.flag.suggestedChecks&&$.flag.suggestedChecks.length>0){Z.push("Suggested Checks:");for(let Q of $.flag.suggestedChecks)Z.push(` - ${Q}`);Z.push("")}if($.evidence.length>0){Z.push("Evidence:"),Z.push("-".repeat(60));for(let Q of $.evidence){if(Z.push(`File: ${Q.file}`),Q.hunk)Z.push(` Hunk: ${Q.hunk}`);Z.push(""),Z.push(Q.lines.join(`
56
+ `)}function _Y($){if($.itemType==="finding")return MY($);else return zY($)}function MY($){let Z=[];if(Z.push(`Finding: ${$.findingId}`),Z.push("=".repeat(60)),Z.push(""),Z.push(`Type: ${$.finding.type}`),Z.push(`Category: ${$.finding.category}`),Z.push(`Confidence: ${$.finding.confidence}`),Z.push(`Range: ${$.range.base}..${$.range.head}`),Z.push(""),$.evidence.length>0){Z.push("Evidence:"),Z.push("-".repeat(60));for(let Q of $.evidence){if(Z.push(`File: ${Q.file}`),Q.line!==void 0)Z.push(` Line: ${Q.line}`);if(Q.hunk)Z.push(` Hunk: @@ -${Q.hunk.oldStart},${Q.hunk.oldLines} +${Q.hunk.newStart},${Q.hunk.newLines} @@`);Z.push(""),Z.push(Q.excerpt),Z.push("")}}if($.patchContext&&$.patchContext.length>0){Z.push("Patch Context:"),Z.push("-".repeat(60));for(let Q of $.patchContext){Z.push(`File: ${Q.file} (${Q.status})`),Z.push("");for(let X of Q.hunks)Z.push(`@@ -${X.oldStart},${X.oldLines} +${X.newStart},${X.newLines} @@`),Z.push(X.content),Z.push("")}}return Z.join(`
57
+ `)}function zY($){let Z=[];if(Z.push(`Flag: ${$.flagId}`),Z.push("=".repeat(60)),Z.push(""),Z.push(`Rule: ${$.flag.ruleKey}`),Z.push(`Category: ${$.flag.category}`),Z.push(`Score: ${$.flag.effectiveScore} (base: ${$.flag.score}, confidence: ${$.flag.confidence})`),Z.push(`Range: ${$.range.base}..${$.range.head}`),Z.push(""),Z.push(`Title: ${$.flag.title}`),Z.push(`Summary: ${$.flag.summary}`),Z.push(""),$.flag.suggestedChecks&&$.flag.suggestedChecks.length>0){Z.push("Suggested Checks:");for(let Q of $.flag.suggestedChecks)Z.push(` - ${Q}`);Z.push("")}if($.evidence.length>0){Z.push("Evidence:"),Z.push("-".repeat(60));for(let Q of $.evidence){if(Z.push(`File: ${Q.file}`),Q.hunk)Z.push(` Hunk: ${Q.hunk}`);Z.push(""),Z.push(Q.lines.join(`
54
58
  `)),Z.push("")}}if($.relatedFindings&&$.relatedFindings.length>0){Z.push("Related Findings:"),Z.push("-".repeat(60));for(let Q of $.relatedFindings)Z.push(` - ${Q.findingId} (${Q.type}, ${Q.category})`);Z.push("")}if($.patchContext&&$.patchContext.length>0){Z.push("Patch Context:"),Z.push("-".repeat(60));for(let Q of $.patchContext){Z.push(`File: ${Q.file} (${Q.status})`),Z.push("");for(let X of Q.hunks)Z.push(`@@ -${X.oldStart},${X.oldLines} +${X.newStart},${X.newLines} @@`),Z.push(X.content),Z.push("")}}return Z.join(`
55
- `)}var L1=`# branch-narrator CLI Reference
59
+ `)}var E1=`# branch-narrator CLI Reference
56
60
 
57
61
  Use \`branch-narrator\` to get deterministic, repo-grounded context about changes
58
62
  between git refs. It does not use an LLM and will not invent intent.
@@ -199,10 +203,10 @@ Before risky/experimental changes → run \`snap save\`
199
203
 
200
204
  ## Default Behavior
201
205
 
202
- - **Mode:** Defaults to \`unstaged\` (local uncommitted changes) if no mode specified
206
+ - **Mode:** Defaults to \`unstaged\` (local unstaged changes) if no mode specified
203
207
  - **Base/Head:** For branch mode, defaults to \`main\` and \`HEAD\` if not specified
204
208
  - **For PR descriptions:** Always use \`--mode branch\`
205
- `,u2=`# PR Description (use branch-narrator)
209
+ `,n2=`# PR Description (use branch-narrator)
206
210
 
207
211
  When the user asks to write a PR description, generate a Markdown PR body they
208
212
  can copy-paste directly. Ground everything in the repo diff; do not invent
@@ -251,227 +255,275 @@ Env vars, migrations, infrastructure changes (if applicable).
251
255
 
252
256
  ### Risks & Mitigations
253
257
  Concrete risks with evidence and verification steps.
254
- `;import{stat as H9}from"node:fs/promises";async function Z$($){try{return(await H9($)).isFile()}catch{return!1}}async function Q$($){try{return(await H9($)).isDirectory()}catch{return!1}}var _$=()=>{};import{join as eQ}from"node:path";var _9="CLAUDE.md",z9;var L9=x(()=>{_$();z9={name:"claude",description:"Integrate with CLAUDE.md (Claude Code)",detect:async($)=>Z$(eQ($,_9)),generate:()=>{let $=`
258
+ `;import{stat as m9}from"node:fs/promises";async function W$($){try{return(await m9($)).isFile()}catch{return!1}}async function q$($){try{return(await m9($)).isDirectory()}catch{return!1}}var A$=()=>{};import{join as jY}from"node:path";var h9="CLAUDE.md",u9;var g9=x(()=>{A$();u9={name:"claude",description:"Integrate with CLAUDE.md (Claude Code)",detect:async($)=>W$(jY($,h9)),generate:()=>{let $=`
255
259
 
256
260
  ## Branch Narrator Usage
257
261
 
258
- ${L1}`;return[{path:_9,content:$}]}}});import{readdir as $X}from"node:fs/promises";import{join as D9}from"node:path";async function ZX($){try{let Z=D9($,".cursor","rules");return(await $X(Z)).some((K)=>K.endsWith(".mdc"))?"mdc":"md"}catch{return"md"}}function j9($){return`---
262
+ ${E1}`;return[{path:h9,content:$}]}}});import{readdir as LY}from"node:fs/promises";import{join as l9}from"node:path";async function DY($){try{let Z=l9($,".cursor","rules");return(await LY(Z)).some((Y)=>Y.endsWith(".mdc"))?"mdc":"md"}catch{return"md"}}function c9($){return`---
259
263
  alwaysApply: true
260
264
  ---
261
265
 
262
- ${$}`}var O0;var h2=x(()=>{_$();O0={name:"cursor",description:"Generate Cursor rules (.cursor/rules/*.md or *.mdc)",detect:async($)=>Q$(D9($,".cursor","rules")),generate:async($)=>{let Z=await ZX($),Q=Z==="mdc"?".mdc":".md",X=Z==="mdc"?j9(L1):L1,K=Z==="mdc"?j9(u2):u2;return[{path:`.cursor/rules/branch-narrator${Q}`,content:X},{path:`.cursor/rules/pr-description${Q}`,content:K}]}}});import{join as QX}from"node:path";var A9;var N9=x(()=>{_$();A9={name:"jules-rules",description:"Generate Jules rules in .jules/rules/branch-narrator.md",detect:async($)=>Q$(QX($,".jules")),generate:()=>[{path:".jules/rules/branch-narrator.md",content:L1}]}});import{join as XX}from"node:path";var R9;var T9=x(()=>{_$();R9={name:"jules",description:"Integrate with AGENTS.md (Jules)",detect:async($)=>Z$(XX($,"AGENTS.md")),generate:()=>{return[{path:"AGENTS.md",content:`
266
+ ${$}`}var D0;var t2=x(()=>{A$();D0={name:"cursor",description:"Generate Cursor rules (.cursor/rules/*.md or *.mdc)",detect:async($)=>q$(l9($,".cursor","rules")),generate:async($)=>{let Z=await DY($),Q=Z==="mdc"?".mdc":".md",X=Z==="mdc"?c9(E1):E1,Y=Z==="mdc"?c9(n2):n2;return[{path:`.cursor/rules/branch-narrator${Q}`,content:X},{path:`.cursor/rules/pr-description${Q}`,content:Y}]}}});import{join as NY}from"node:path";var f9;var p9=x(()=>{A$();f9={name:"jules-rules",description:"Generate Jules rules in .jules/rules/branch-narrator.md",detect:async($)=>q$(NY($,".jules")),generate:()=>[{path:".jules/rules/branch-narrator.md",content:E1}]}});import{join as AY}from"node:path";var d9;var r9=x(()=>{A$();d9={name:"jules",description:"Integrate with AGENTS.md (Jules)",detect:async($)=>W$(AY($,"AGENTS.md")),generate:()=>{return[{path:"AGENTS.md",content:`
263
267
 
264
268
  ## Branch Narrator Usage
265
269
 
266
- ${L1}`}]}}});import{join as M0}from"node:path";async function KX($){for(let Z of x9)if(await Z$(M0($,Z)))return{path:Z,useSection:!0};if(await Q$(M0($,".opencode")))return{path:".opencode/branch-narrator.md",useSection:!1};return{path:"OPENCODE.md",useSection:!0}}var x9,w9;var E9=x(()=>{_$();x9=["OPENCODE.md","opencode.md"];w9={name:"opencode",description:"Integrate with OPENCODE.md or .opencode/",detect:async($)=>{for(let Z of x9)if(await Z$(M0($,Z)))return!0;return Q$(M0($,".opencode"))},generate:async($)=>{let Z=await KX($),Q=Z.useSection?`
270
+ ${E1}`}]}}});import{join as N0}from"node:path";async function RY($){for(let Z of a9)if(await W$(N0($,Z)))return{path:Z,useSection:!0};if(await q$(N0($,".opencode")))return{path:".opencode/branch-narrator.md",useSection:!1};return{path:"OPENCODE.md",useSection:!0}}var a9,s9;var o9=x(()=>{A$();a9=["OPENCODE.md","opencode.md"];s9={name:"opencode",description:"Integrate with OPENCODE.md or .opencode/",detect:async($)=>{for(let Z of a9)if(await W$(N0($,Z)))return!0;return q$(N0($,".opencode"))},generate:async($)=>{let Z=await RY($),Q=Z.useSection?`
267
271
 
268
272
  ## Branch Narrator Usage
269
273
 
270
- ${L1}`:L1;return[{path:Z.path,content:Q}]}}});async function I9(){return await O0.generate("")}var b9=x(()=>{h2()});var y9={};A1(y9,{generateCursorRules:()=>I9,executeIntegrate:()=>OX});import{mkdir as YX,writeFile as C9,access as qX,readFile as WX}from"node:fs/promises";import{dirname as UX,join as VX}from"node:path";async function JX($){try{return await qX($),!0}catch{return!1}}async function BX($,Z,Q){for(let X of $){let K=VX(Z,X.path),Y=await JX(K);if(await YX(UX(K),{recursive:!0}),Y&&!Q){let W=await WX(K,"utf-8"),q=W.endsWith(`
274
+ ${E1}`:E1;return[{path:Z.path,content:Q}]}}});async function i9(){return await D0.generate("")}var n9=x(()=>{t2()});var $Z={};P1($Z,{generateCursorRules:()=>i9,executeIntegrate:()=>vY});import{mkdir as TY,writeFile as t9,access as wY,readFile as xY}from"node:fs/promises";import{dirname as EY,join as IY}from"node:path";async function bY($){try{return await wY($),!0}catch{return!1}}async function PY($,Z,Q){for(let X of $){let Y=IY(Z,X.path),K=await bY(Y);if(await TY(EY(Y),{recursive:!0}),K&&!Q){let q=await xY(Y,"utf-8"),W=q.endsWith(`
271
275
  `)?"":`
272
- `,V=W+q+X.content;await C9(K,V,"utf-8"),console.log(` - ${X.path} (appended)`)}else{await C9(K,X.content,"utf-8");let W=Y?"overwritten":"created";console.log(` - ${X.path} (${W})`)}}}async function P9($,Z,Q){let X=await $.generate(Q);if(Z.dryRun){console.log("=".repeat(80)),console.log(`DRY RUN: Integration for ${$.name}`),console.log("=".repeat(80)),console.log();for(let K of X)console.log(`File: ${K.path}`),console.log("-".repeat(80)),console.log(K.content),console.log("-".repeat(80)),console.log();return}console.log(`Integration for ${$.name}:`),await BX(X,Q,Z.force)}async function GX($){let Z=[];for(let[Q,X]of Object.entries(H0)){if(!X.detect)continue;try{if(await X.detect($))Z.push(Q)}catch{}}return Z}async function OX($){let Z=$.cwd??process.cwd(),Q=Object.keys(H0);if(!$.target){let K=await GX(Z);if(K.length===0){console.log("No supported agent guide files detected in this repo."),console.log(`Run "branch-narrator integrate <target>" with one of: ${Q.join(", ")}`);return}console.log(`Auto-detected guides: ${K.join(", ")}`);for(let Y of K){let W=H0[Y];await P9(W,$,Z)}return}let X=H0[$.target];if(!X)throw new v(`Unknown integration target: ${$.target}
273
- Supported targets: ${Q.join(", ")}`,1);await P9(X,$,Z)}var H0;var k9=x(()=>{H1();L9();h2();N9();T9();E9();b9();H0={cursor:O0,jules:R9,claude:z9,"jules-rules":A9,opencode:w9}});import{mkdir as _0,readFile as y$,writeFile as k$,readdir as FV,rm as mV,stat as MX}from"node:fs/promises";import{join as E1,dirname as HX}from"node:path";import{createHash as S9}from"node:crypto";function S$($=process.cwd()){return E1($,_X,zX)}function m9($=process.cwd()){return E1(S$($),LX)}function p1($,Z=process.cwd()){return E1(S$(Z),$)}function c2($,Z=process.cwd()){return E1(p1($,Z),jX)}function AX($,Z=process.cwd()){return E1(p1($,Z),v9)}function NX($,Z=process.cwd()){return E1(p1($,Z),F9)}function u9($,Z=process.cwd()){return E1(p1($,Z),g2)}function h9($,Z=process.cwd()){return E1(u9($,Z),l2)}function g9($,Z=process.cwd()){return E1(u9($,Z),DX)}function l9($,Z,Q=process.cwd()){return E1(g9($,Q),Z)}function S1($){return S9("sha256").update($).digest("hex")}function z0($,Z,Q,X){let K=`${$}:${Z}:${Q}:${X}`;return S9("sha256").update(K).digest("hex").slice(0,12)}async function RX($=process.cwd()){await _0(S$($),{recursive:!0})}async function L0($,Z=process.cwd()){let Q=p1($,Z);await _0(Q,{recursive:!0}),await _0(g9($,Z),{recursive:!0})}async function v1($,Z=process.cwd()){try{let Q=c2($,Z);return await MX(Q),!0}catch{return!1}}async function v$($=process.cwd()){try{let Z=m9($),Q=await y$(Z,"utf-8");return JSON.parse(Q)}catch{return{schemaVersion:"1.0",snapshots:[]}}}async function TX($,Z=process.cwd()){await RX(Z);let Q=m9(Z);await k$(Q,JSON.stringify($,null,2),"utf-8")}async function c9($,Z=process.cwd()){let Q=await v$(Z);Q.snapshots=Q.snapshots.filter((X)=>X.snapshotId!==$.snapshotId),Q.snapshots.push($),Q.snapshots.sort((X,K)=>K.createdAt.localeCompare(X.createdAt)),await TX(Q,Z)}async function F1($,Z=process.cwd()){let Q=c2($,Z),X=await y$(Q,"utf-8");return JSON.parse(X)}async function f9($,Z,Q=process.cwd()){await L0($,Q);let X=c2($,Q);await k$(X,JSON.stringify(Z,null,2),"utf-8")}async function f2($,Z,Q,X=process.cwd()){await L0($,X);let K=Z==="staged"?v9:F9,Y=E1(p1($,X),K);return await k$(Y,Q),{path:K,sha256:S1(Q),bytes:Q.length}}async function p2($,Z,Q=process.cwd()){let X=Z==="staged"?AX($,Q):NX($,Q);return await y$(X)}async function F$($,Z=process.cwd()){try{let Q=h9($,Z),X=await y$(Q,"utf-8");return JSON.parse(X)}catch{return{entries:[]}}}async function p9($,Z,Q=process.cwd()){await L0($,Q);let X=h9($,Q);await _0(HX(X),{recursive:!0}),await k$(X,JSON.stringify(Z,null,2),"utf-8")}async function d9($,Z,Q=process.cwd()){await L0($,Q);let X=S1(Z),K=l9($,X,Q);return await k$(K,Z),X}async function r9($,Z,Q=process.cwd()){let X=l9($,Z,Q);return await y$(X)}function a9($){return{snapshotId:$.snapshotId,label:$.label,createdAt:$.createdAt,headSha:$.git.headSha,branch:$.git.branch,filesChanged:$.analysis.facts.stats.filesChanged,riskScore:$.analysis.riskReport.riskScore,flagCount:$.analysis.riskReport.flags.length,findingCount:$.analysis.facts.findings.length}}function d2(){return new Date().toISOString().replace(/[:.]/g,"-")}function s9(){return`auto/pre-restore/${d2()}`}var _X=".branch-narrator",zX="snapshots",LX="index.json",jX="snapshot.json",v9="staged.patch",F9="unstaged.patch",g2="untracked",l2="manifest.json",DX="blobs";var X$=()=>{};import{execa as d1}from"execa";import{readFile as xX,stat as wX,chmod as EX,unlink as fV,readdir as pV,rmdir as dV}from"node:fs/promises";import{join as r2,dirname as IX}from"node:path";async function z$($=process.cwd()){try{return(await d1("git",["rev-parse","HEAD"],{cwd:$})).stdout.trim()}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new d("git rev-parse HEAD",String(Z.stderr));throw Z}}async function j0($=process.cwd()){try{let Q=(await d1("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:$})).stdout.trim();return Q==="HEAD"?"":Q}catch{return""}}async function L$($=process.cwd()){try{let Z=await d1("git",["diff","--binary","--staged"],{cwd:$,maxBuffer:104857600});return Buffer.from(Z.stdout,"utf-8")}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new d("git diff --binary --staged",String(Z.stderr));throw Z}}async function j$($=process.cwd()){try{let Z=await d1("git",["diff","--binary"],{cwd:$,maxBuffer:104857600});return Buffer.from(Z.stdout,"utf-8")}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new d("git diff --binary",String(Z.stderr));throw Z}}async function D0($,Z={},Q=process.cwd()){if($.length===0)return;let X=["apply"];if(Z.cached)X.push("--cached");if(Z.check)X.push("--check");X.push("-");try{await d1("git",X,{cwd:Q,input:$})}catch(K){if(K instanceof Error&&"stderr"in K)throw new d(`git ${X.join(" ")}`,String(K.stderr));throw K}}async function A0($=process.cwd()){try{let Q=(await d1("git",["ls-files","--others","--exclude-standard","-z"],{cwd:$})).stdout;if(!Q)return[];return Q.split("\x00").filter(Boolean)}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new d("git ls-files --others --exclude-standard -z",String(Z.stderr));throw Z}}async function o9($,Z=process.cwd()){let Q=r2(Z,$);return await xX(Q)}async function n9($,Z=process.cwd()){let Q=r2(Z,$);return(await wX(Q)).mode}async function i9($=process.cwd()){try{await d1("git",["reset","--hard","HEAD"],{cwd:$})}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new d("git reset --hard HEAD",String(Z.stderr));throw Z}}async function t9($=process.cwd()){try{await d1("git",["clean","-fd","--exclude=.branch-narrator"],{cwd:$})}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new d("git clean -fd --exclude=.branch-narrator",String(Z.stderr));throw Z}}async function e9($,Z,Q,X=process.cwd()){let{writeFile:K,mkdir:Y}=await import("node:fs/promises"),W=r2(X,$);await Y(IX(W),{recursive:!0}),await K(W,Z),await EX(W,Q)}var N0=x(()=>{H1()});import{writeFile as bX,mkdir as CX}from"node:fs/promises";import{dirname as PX}from"node:path";async function R0($={}){let Z=$.cwd??process.cwd(),Q=$.label??`snapshot-${d2()}`,[X,K]=await Promise.all([z$(Z),j0(Z)]),[Y,W]=await Promise.all([L$(Z),j$(Z)]),q=await A0(Z),V={entries:[]},U=new Map,J=0;for(let r of q)try{let j=await o9(r,Z),C=await n9(r,Z),O1=S1(j),I0={path:r,blobSha256:O1,mode:C,bytes:j.length};V.entries.push(I0),U.set(O1,j),J+=j.length}catch{continue}V.entries.sort((r,j)=>r.path.localeCompare(j.path));let B=S1(Y),G=S1(W),M=JSON.stringify(V),H=z0(X,B,G,M),O=await l1({mode:"all",cwd:Z,includeUntracked:!0}),[z,_]=await Promise.all([V$(Z),J$(Z)]),D="auto",L=b$(O,Z),w=L.profile,T=y1(w),A=await I1(T.analyzers,O),b=O$(A),R=await M$({changeSet:O,findings:A,riskScore:b,requestedProfile:D,detectedProfile:w,profileConfidence:L.confidence,profileReasons:L.reasons,filters:{excludes:[],includes:[],redact:!1,maxFileBytes:1048576,maxDiffBytes:5242880},skippedFiles:[],warnings:[],noTimestamp:!0,repoRoot:z,isDirty:_,mode:"all"}),h=await H$(O,{noTimestamp:!0,mode:"all",cwd:Z}),y=await g$(),r1=new Date().toISOString(),a1={schemaVersion:"1.0",snapshotId:H,label:Q,createdAt:r1,tool:{name:"branch-narrator",version:y},git:{headSha:X,branch:K},workspace:{patches:{staged:{path:"staged.patch",sha256:B,bytes:Y.length},unstaged:{path:"unstaged.patch",sha256:G,bytes:W.length}},untracked:{manifestPath:`${g2}/${l2}`,fileCount:V.entries.length,totalBytes:J}},analysis:{facts:R,riskReport:h}};await f2(H,"staged",Y,Z),await f2(H,"unstaged",W,Z),await p9(H,V,Z);for(let[,r]of U)await d9(H,r,Z);await f9(H,a1,Z);let K$=a9(a1);await c9(K$,Z);let Y$={snapshotId:H,label:Q,snapshotPath:`.branch-narrator/snapshots/${H}`};if($.out)await CX(PX($.out),{recursive:!0}),await bX($.out,H,"utf-8");return Y$}var a2=x(()=>{X$();N0();l$();B$();C$();U0();G0();B$()});async function $Z($={}){let Z=$.cwd??process.cwd(),Q=await v$(Z);return Q.snapshots.sort((X,K)=>K.createdAt.localeCompare(X.createdAt)),Q}function ZZ($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}var QZ=x(()=>{X$()});async function XZ($,Z={}){let Q=Z.cwd??process.cwd();if(!await v1($,Q))throw new m1($);return await F1($,Q)}function KZ($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}var m1;var T0=x(()=>{X$();H1();m1=class m1 extends v{constructor($){super(`Snapshot not found: ${$}`,1);this.name="SnapshotNotFoundError"}}});async function YZ($,Z,Q={}){let X=Q.cwd??process.cwd();if(!await v1($,X))throw new m1($);if(!await v1(Z,X))throw new m1(Z);let[K,Y]=await Promise.all([F1($,X),F1(Z,X)]),[W,q]=await Promise.all([F$($,X),F$(Z,X)]),V=yX(K.analysis.facts.findings,Y.analysis.facts.findings),U=kX(K.analysis.riskReport.flags,Y.analysis.riskReport.flags),J=SX(K,Y,W.entries,q.entries);return{schemaVersion:"1.0",from:$,to:Z,delta:{riskScore:{from:K.analysis.riskReport.riskScore,to:Y.analysis.riskReport.riskScore,delta:Y.analysis.riskReport.riskScore-K.analysis.riskReport.riskScore},findings:V,flags:U,files:J},summary:{findingsAdded:V.added.length,findingsRemoved:V.removed.length,findingsChanged:V.changed.length,flagsAdded:U.added.length,flagsRemoved:U.removed.length,flagsChanged:U.changed.length,filesAdded:J.added.length,filesRemoved:J.removed.length,filesModified:J.modified.length}}}function yX($,Z){let Q=new Map,X=new Map;for(let q of $)if(q.findingId)Q.set(q.findingId,q);for(let q of Z)if(q.findingId)X.set(q.findingId,q);let K=[],Y=[],W=[];for(let q of Q.keys())if(!X.has(q))Y.push(q);for(let[q,V]of X){let U=Q.get(q);if(!U)K.push(q);else if(!x0(U,V))W.push({findingId:q,before:U,after:V})}return K.sort(),Y.sort(),W.sort((q,V)=>q.findingId.localeCompare(V.findingId)),{added:K,removed:Y,changed:W}}function kX($,Z){let Q=new Map,X=new Map;for(let q of $)if(q.flagId)Q.set(q.flagId,q);for(let q of Z)if(q.flagId)X.set(q.flagId,q);let K=[],Y=[],W=[];for(let q of Q.keys())if(!X.has(q))Y.push(q);for(let[q,V]of X){let U=Q.get(q);if(!U)K.push(q);else if(!x0(U,V))W.push({flagId:q,before:U,after:V})}return K.sort(),Y.sort(),W.sort((q,V)=>q.flagId.localeCompare(V.flagId)),{added:K,removed:Y,changed:W}}function SX($,Z,Q,X){let K=new Set,Y=new Set,W=new Map,q=new Map,V=$.analysis.facts.changeset,U=Z.analysis.facts.changeset;for(let M of V.files.added)K.add(M),W.set(M,"added");for(let M of V.files.modified)K.add(M),W.set(M,"modified");for(let M of V.files.deleted)K.add(M),W.set(M,"deleted");for(let{from:M,to:H}of V.files.renamed)K.add(M),K.add(H),W.set(M,`renamed:${H}`);for(let M of U.files.added)Y.add(M),q.set(M,"added");for(let M of U.files.modified)Y.add(M),q.set(M,"modified");for(let M of U.files.deleted)Y.add(M),q.set(M,"deleted");for(let{from:M,to:H}of U.files.renamed)Y.add(M),Y.add(H),q.set(M,`renamed:${H}`);for(let M of Q)K.add(M.path),W.set(M.path,M.blobSha256);for(let M of X)Y.add(M.path),q.set(M.path,M.blobSha256);let J=[],B=[],G=[];for(let M of K)if(!Y.has(M))B.push(M);for(let M of Y)if(!K.has(M))J.push(M);else{let H=W.get(M),O=q.get(M);if(H!==O)G.push(M)}return J.sort(),B.sort(),G.sort(),{added:J,removed:B,modified:G}}function x0($,Z){if($===Z)return!0;if($===null||Z===null)return!1;if(typeof $!=="object"||typeof Z!=="object")return!1;if(Array.isArray($)&&Array.isArray(Z)){if($.length!==Z.length)return!1;for(let K=0;K<$.length;K++)if(!x0($[K],Z[K]))return!1;return!0}if(Array.isArray($)||Array.isArray(Z))return!1;let Q=Object.keys($).sort(),X=Object.keys(Z).sort();if(Q.length!==X.length)return!1;if(!Q.every((K,Y)=>K===X[Y]))return!1;for(let K of Q)if(!x0($[K],Z[K]))return!1;return!0}function qZ($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}var WZ=x(()=>{X$();T0()});async function UZ($,Z={}){let Q=Z.cwd??process.cwd();if(!await v1($,Q))throw new m1($);let X=await F1($,Q),K=await z$(Q);if(K!==X.git.headSha)throw new w0(X.git.headSha,K);let Y=s9(),W=await R0({label:Y,cwd:Q});await i9(Q),await t9(Q);let q=await p2($,"staged",Q);if(q.length>0)try{await D0(q,{cached:!0},Q),await D0(q,{},Q)}catch(B){throw new m$("staged",B instanceof Error?B.message:String(B))}let V=await p2($,"unstaged",Q);if(V.length>0)try{await D0(V,{},Q)}catch(B){throw new m$("unstaged",B instanceof Error?B.message:String(B))}let U=await F$($,Q);for(let B of U.entries){let G=await r9($,B.blobSha256,Q);await e9(B.path,G,B.mode,Q)}let J=await vX(X,Q);return{snapshotId:$,backupSnapshotId:W.snapshotId,success:!0,verified:J}}async function vX($,Z){try{let[Q,X]=await Promise.all([L$(Z),j$(Z)]),K=S1(Q),Y=S1(X),W=K===$.workspace.patches.staged.sha256,q=Y===$.workspace.patches.unstaged.sha256;return W&&q}catch{return!1}}var w0,m$,s2;var VZ=x(()=>{X$();N0();a2();T0();H1();w0=class w0 extends v{constructor($,Z){super(`HEAD mismatch: snapshot was created at ${$.slice(0,8)} but current HEAD is ${Z.slice(0,8)}. Snapshots can only be restored when HEAD matches the original commit.`,1);this.name="HeadMismatchError"}};m$=class m$ extends v{constructor($,Z){super(`Failed to apply ${$} patch: ${Z}`,1);this.name="PatchApplicationError"}};s2=class s2 extends v{constructor($){super(`Restore verification failed: ${$}`,1);this.name="RestoreVerificationError"}}});var D$={};A1(D$,{snapshotExists:()=>v1,renderSnapShowJSON:()=>KZ,renderSnapListJSON:()=>ZZ,renderSnapDiffJSON:()=>qZ,readSnapshotJson:()=>F1,readIndex:()=>v$,getUntrackedFiles:()=>A0,getUnstagedPatch:()=>j$,getStagedPatch:()=>L$,getSnapshotsDir:()=>S$,getSnapshotDir:()=>p1,getHeadSha:()=>z$,getCurrentBranch:()=>j0,executeSnapShow:()=>XZ,executeSnapSave:()=>R0,executeSnapRestore:()=>UZ,executeSnapList:()=>$Z,executeSnapDiff:()=>YZ,computeSnapshotId:()=>z0,SnapshotNotFoundError:()=>m1,RestoreVerificationError:()=>s2,PatchApplicationError:()=>m$,HeadMismatchError:()=>w0});var A$=x(()=>{X$();N0();a2();QZ();T0();WZ();VZ()});H1();l$();import{Command as FX}from"commander";import{createInterface as mX}from"readline";import uX from"ora";import hX from"chalk";H1();import{mkdir as X5,writeFile as K5}from"node:fs/promises";import{dirname as IZ,join as bZ}from"node:path";var R1={quiet:!1,debug:!1};function n2($){if($.quiet)R1.quiet=!0,R1.debug=!1;else R1.quiet=!1,R1.debug=$.debug??!1}function oX(){return{...R1}}function nX(){R1.quiet=!1,R1.debug=!1}function s1($){if(!R1.quiet)console.error($)}function l($){if(!R1.quiet)console.error($)}function iX($){if(!R1.quiet&&R1.debug)console.error(`[DEBUG] ${$}`)}function c($){console.error($)}import RZ from"picomatch";var o1=["**/pnpm-lock.yaml","**/package-lock.json","**/yarn.lock","**/bun.lock","**/bun.lockb","**/*.d.ts","**/*.log","**/*.logs","**/dist/**","**/build/**","**/.svelte-kit/**","**/.next/**","**/.turbo/**","**/coverage/**","**/.cache/**","**/*.min.*","**/*.map"];function k0($){let Z=["diff","--name-status","--find-renames"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}return Z}function S0($){let Z=["diff",`--unified=${$.unified}`,"--find-renames"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}if(Z.push("--"),$.oldPath)Z.push($.oldPath);return Z.push($.path),Z}function v0($,Z){return["diff","--no-index",`--unified=${Z}`,"--","/dev/null",$]}function F0($){if(!$)return[];return $.split("\x00").filter(Boolean)}function y0($){if($.length===0)return()=>!1;let Z=$.map((Q)=>RZ(Q,{dot:!0}));return(Q)=>Z.some((X)=>X(Q))}function W$($){let{files:Z,includeGlobs:Q,excludeGlobs:X,defaultExcludes:K}=$,Y=y0(Q),W=y0(X),q=y0(K),V=Q.length>0,U=[],J=[];for(let B of Z){let G=B.path;if(W(G)){J.push({path:G,reason:"excluded-by-glob"});continue}if(V){if(!Y(G)){J.push({path:G,reason:"not-included"});continue}U.push(B);continue}if(q(G)){J.push({path:G,reason:"excluded-by-default"});continue}U.push(B)}return U.sort((B,G)=>B.path.localeCompare(G.path)),{included:U,skipped:J}}function m0($,Z){if($.length===0)return[];let Q=[],X=[],K=0;for(let Y of $){let W=Y.diff.length;if(W>Z){if(X.length>0)Q.push(X),X=[],K=0;Q.push([Y]);continue}if(K+W>Z&&X.length>0)Q.push(X),X=[],K=0;X.push(Y),K+=W}if(X.length>0)Q.push(X);return Q}function c$($){return $.map((Z)=>Z.diff).join(`
274
- `)}function TZ($){switch($.mode){case"branch":return`Git Diff: ${$.base}..${$.head}`;case"unstaged":return"Git Diff: Unstaged Changes (working tree vs index)";case"staged":return"Git Diff: Staged Changes (index vs HEAD)";case"all":return"Git Diff: All Changes (working tree vs HEAD)"}}function f$($,Z){let Q=[];if(Q.push(`# ${TZ(Z)}`),Q.push(""),Q.push(`**Mode:** ${Z.mode}`),Q.push(`**Unified context:** ${Z.unified} lines`),Z.excludePatterns.length>0)Q.push(`**Excluded patterns:** ${Z.excludePatterns.join(", ")}`);Q.push(`**Files included:** ${$.length}`),Q.push(""),Q.push("## Files"),Q.push("");for(let X of $){let K=xZ(X.status),Y=X.untracked?" [untracked]":"";Q.push(`- \`${X.path}\` (${K}${Y})`)}return Q.push(""),Q.push("## Diff"),Q.push(""),Q.push("```diff"),Q.push($.map((X)=>X.diff).join(`
276
+ `,V=q+W+X.content;await t9(Y,V,"utf-8"),console.log(` - ${X.path} (appended)`)}else{await t9(Y,X.content,"utf-8");let q=K?"overwritten":"created";console.log(` - ${X.path} (${q})`)}}}async function e9($,Z,Q){let X=await $.generate(Q);if(Z.dryRun){console.log("=".repeat(80)),console.log(`DRY RUN: Integration for ${$.name}`),console.log("=".repeat(80)),console.log();for(let Y of X)console.log(`File: ${Y.path}`),console.log("-".repeat(80)),console.log(Y.content),console.log("-".repeat(80)),console.log();return}console.log(`Integration for ${$.name}:`),await PY(X,Q,Z.force)}async function kY($){let Z=[];for(let[Q,X]of Object.entries(A0)){if(!X.detect)continue;try{if(await X.detect($))Z.push(Q)}catch{}}return Z}async function vY($){let Z=$.cwd??process.cwd(),Q=Object.keys(A0);if(!$.target){let Y=await kY(Z);if(Y.length===0){console.log("No supported agent guide files detected in this repo."),console.log(`Run "branch-narrator integrate <target>" with one of: ${Q.join(", ")}`);return}console.log(`Auto-detected guides: ${Y.join(", ")}`);for(let K of Y){let q=A0[K];await e9(q,$,Z)}return}let X=A0[$.target];if(!X)throw new F(`Unknown integration target: ${$.target}
277
+ Supported targets: ${Q.join(", ")}`,1);await e9(X,$,Z)}var A0;var ZZ=x(()=>{w1();g9();t2();p9();r9();o9();n9();A0={cursor:D0,jules:d9,claude:u9,"jules-rules":f9,opencode:s9}});import{mkdir as R0,readFile as u$,writeFile as g$,readdir as FG,rm as yG,stat as SY}from"node:fs/promises";import{join as C1,dirname as CY}from"node:path";import{createHash as QZ}from"node:crypto";function c$($=process.cwd()){return C1($,FY,yY)}function KZ($=process.cwd()){return C1(c$($),mY)}function t1($,Z=process.cwd()){return C1(c$(Z),$)}function Z5($,Z=process.cwd()){return C1(t1($,Z),hY)}function gY($,Z=process.cwd()){return C1(t1($,Z),XZ)}function cY($,Z=process.cwd()){return C1(t1($,Z),YZ)}function WZ($,Z=process.cwd()){return C1(t1($,Z),e2)}function qZ($,Z=process.cwd()){return C1(WZ($,Z),$5)}function UZ($,Z=process.cwd()){return C1(WZ($,Z),uY)}function VZ($,Z,Q=process.cwd()){return C1(UZ($,Q),Z)}function p1($){return QZ("sha256").update($).digest("hex")}function T0($,Z,Q,X){let Y=`${$}:${Z}:${Q}:${X}`;return QZ("sha256").update(Y).digest("hex").slice(0,12)}async function lY($=process.cwd()){await R0(c$($),{recursive:!0})}async function w0($,Z=process.cwd()){let Q=t1($,Z);await R0(Q,{recursive:!0}),await R0(UZ($,Z),{recursive:!0})}async function d1($,Z=process.cwd()){try{let Q=Z5($,Z);return await SY(Q),!0}catch{return!1}}async function l$($=process.cwd()){try{let Z=KZ($),Q=await u$(Z,"utf-8");return JSON.parse(Q)}catch{return{schemaVersion:"1.0",snapshots:[]}}}async function fY($,Z=process.cwd()){await lY(Z);let Q=KZ(Z);await g$(Q,JSON.stringify($,null,2),"utf-8")}async function JZ($,Z=process.cwd()){let Q=await l$(Z);Q.snapshots=Q.snapshots.filter((X)=>X.snapshotId!==$.snapshotId),Q.snapshots.push($),Q.snapshots.sort((X,Y)=>Y.createdAt.localeCompare(X.createdAt)),await fY(Q,Z)}async function r1($,Z=process.cwd()){let Q=Z5($,Z),X=await u$(Q,"utf-8");return JSON.parse(X)}async function GZ($,Z,Q=process.cwd()){await w0($,Q);let X=Z5($,Q);await g$(X,JSON.stringify(Z,null,2),"utf-8")}async function Q5($,Z,Q,X=process.cwd()){await w0($,X);let Y=Z==="staged"?XZ:YZ,K=C1(t1($,X),Y);return await g$(K,Q),{path:Y,sha256:p1(Q),bytes:Q.length}}async function X5($,Z,Q=process.cwd()){let X=Z==="staged"?gY($,Q):cY($,Q);return await u$(X)}async function f$($,Z=process.cwd()){try{let Q=qZ($,Z),X=await u$(Q,"utf-8");return JSON.parse(X)}catch{return{entries:[]}}}async function BZ($,Z,Q=process.cwd()){await w0($,Q);let X=qZ($,Q);await R0(CY(X),{recursive:!0}),await g$(X,JSON.stringify(Z,null,2),"utf-8")}async function OZ($,Z,Q=process.cwd()){await w0($,Q);let X=p1(Z),Y=VZ($,X,Q);return await g$(Y,Z),X}async function HZ($,Z,Q=process.cwd()){let X=VZ($,Z,Q);return await u$(X)}function _Z($){return{snapshotId:$.snapshotId,label:$.label,createdAt:$.createdAt,headSha:$.git.headSha,branch:$.git.branch,filesChanged:$.analysis.facts.stats.filesChanged,riskScore:$.analysis.riskReport.riskScore,flagCount:$.analysis.riskReport.flags.length,findingCount:$.analysis.facts.findings.length}}function Y5(){return new Date().toISOString().replace(/[:.]/g,"-")}function MZ(){return`auto/pre-restore/${Y5()}`}var FY=".branch-narrator",yY="snapshots",mY="index.json",hY="snapshot.json",XZ="staged.patch",YZ="unstaged.patch",e2="untracked",$5="manifest.json",uY="blobs";var U$=()=>{};import{execa as e1}from"execa";import{readFile as pY,stat as dY,chmod as rY,unlink as lG,readdir as fG,rmdir as pG}from"node:fs/promises";import{join as K5,dirname as aY}from"node:path";async function R$($=process.cwd()){try{return(await e1("git",["rev-parse","HEAD"],{cwd:$})).stdout.trim()}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new G1("git rev-parse HEAD",String(Z.stderr));throw Z}}async function x0($=process.cwd()){try{let Q=(await e1("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:$})).stdout.trim();return Q==="HEAD"?"":Q}catch{return""}}async function T$($=process.cwd()){try{let Z=await e1("git",["diff","--binary","--staged"],{cwd:$,maxBuffer:104857600});return Buffer.from(Z.stdout,"utf-8")}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new G1("git diff --binary --staged",String(Z.stderr));throw Z}}async function w$($=process.cwd()){try{let Z=await e1("git",["diff","--binary"],{cwd:$,maxBuffer:104857600});return Buffer.from(Z.stdout,"utf-8")}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new G1("git diff --binary",String(Z.stderr));throw Z}}async function E0($,Z={},Q=process.cwd()){if($.length===0)return;let X=["apply"];if(Z.cached)X.push("--cached");if(Z.check)X.push("--check");X.push("-");try{await e1("git",X,{cwd:Q,input:$})}catch(Y){if(Y instanceof Error&&"stderr"in Y)throw new G1(`git ${X.join(" ")}`,String(Y.stderr));throw Y}}async function I0($=process.cwd()){try{let Q=(await e1("git",["ls-files","--others","--exclude-standard","-z"],{cwd:$})).stdout;if(!Q)return[];return Q.split("\x00").filter(Boolean)}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new G1("git ls-files --others --exclude-standard -z",String(Z.stderr));throw Z}}async function zZ($,Z=process.cwd()){let Q=K5(Z,$);return await pY(Q)}async function jZ($,Z=process.cwd()){let Q=K5(Z,$);return(await dY(Q)).mode}async function LZ($=process.cwd()){try{await e1("git",["reset","--hard","HEAD"],{cwd:$})}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new G1("git reset --hard HEAD",String(Z.stderr));throw Z}}async function DZ($=process.cwd()){try{await e1("git",["clean","-fd","--exclude=.branch-narrator"],{cwd:$})}catch(Z){if(Z instanceof Error&&"stderr"in Z)throw new G1("git clean -fd --exclude=.branch-narrator",String(Z.stderr));throw Z}}async function NZ($,Z,Q,X=process.cwd()){let{writeFile:Y,mkdir:K}=await import("node:fs/promises"),q=K5(X,$);await K(aY(q),{recursive:!0}),await Y(q,Z),await rY(q,Q)}var b0=x(()=>{w1()});import{writeFile as sY,mkdir as oY}from"node:fs/promises";import{dirname as iY}from"node:path";async function P0($={}){let Z=$.cwd??process.cwd(),Q=$.label??`snapshot-${Y5()}`,[X,Y]=await Promise.all([R$(Z),x0(Z)]),[K,q]=await Promise.all([T$(Z),w$(Z)]),W=await I0(Z),V={entries:[]},U=new Map,J=0;for(let Q1 of W)try{let D=await zZ(Q1,Z),k=await jZ(Q1,Z),j1=p1(D),c1={path:Q1,blobSha256:j1,mode:k,bytes:D.length};V.entries.push(c1),U.set(j1,D),J+=D.length}catch{continue}V.entries.sort((Q1,D)=>Q1.path.localeCompare(D.path));let G=p1(K),B=p1(q),H=JSON.stringify(V),_=T0(X,G,B,H),O=await n1({mode:"all",cwd:Z,includeUntracked:!0}),[M,z]=await Promise.all([H$(Z),_$(Z)]),A="auto",N=y$(O,Z),E=N.profile,w=u1(E),T=await F1(w.analyzers,O),P=L$(T),I=await D$({changeSet:O,findings:T,riskScore:P,requestedProfile:A,detectedProfile:E,profileConfidence:N.confidence,profileReasons:N.reasons,filters:{excludes:[],includes:[],redact:!1,maxFileBytes:1048576,maxDiffBytes:5242880},skippedFiles:[],warnings:[],noTimestamp:!0,repoRoot:M,isDirty:z,mode:"all"}),f=await N$(O,{noTimestamp:!0,mode:"all",cwd:Z}),j=await a$(),g=new Date().toISOString(),c={schemaVersion:"1.0",snapshotId:_,label:Q,createdAt:g,tool:{name:"branch-narrator",version:j},git:{headSha:X,branch:Y},workspace:{patches:{staged:{path:"staged.patch",sha256:G,bytes:K.length},unstaged:{path:"unstaged.patch",sha256:B,bytes:q.length}},untracked:{manifestPath:`${e2}/${$5}`,fileCount:V.entries.length,totalBytes:J}},analysis:{facts:I,riskReport:f}};await Q5(_,"staged",K,Z),await Q5(_,"unstaged",q,Z),await BZ(_,V,Z);for(let[,Q1]of U)await OZ(_,Q1,Z);await GZ(_,c,Z);let p=_Z(c);await JZ(p,Z);let s1={snapshotId:_,label:Q,snapshotPath:`.branch-narrator/snapshots/${_}`};if($.out)await oY(iY($.out),{recursive:!0}),await sY($.out,_,"utf-8");return s1}var W5=x(()=>{U$();b0();s$();M$();m$();_0();L0();M$()});async function AZ($={}){let Z=$.cwd??process.cwd(),Q=await l$(Z);return Q.snapshots.sort((X,Y)=>Y.createdAt.localeCompare(X.createdAt)),Q}function RZ($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}var TZ=x(()=>{U$()});async function wZ($,Z={}){let Q=Z.cwd??process.cwd();if(!await d1($,Q))throw new a1($);return await r1($,Q)}function xZ($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}var a1;var k0=x(()=>{U$();w1();a1=class a1 extends F{constructor($){super(`Snapshot not found: ${$}`,1);this.name="SnapshotNotFoundError"}}});async function EZ($,Z,Q={}){let X=Q.cwd??process.cwd();if(!await d1($,X))throw new a1($);if(!await d1(Z,X))throw new a1(Z);let[Y,K]=await Promise.all([r1($,X),r1(Z,X)]),[q,W]=await Promise.all([f$($,X),f$(Z,X)]),V=nY(Y.analysis.facts.findings,K.analysis.facts.findings),U=tY(Y.analysis.riskReport.flags,K.analysis.riskReport.flags),J=eY(Y,K,q.entries,W.entries);return{schemaVersion:"1.0",from:$,to:Z,delta:{riskScore:{from:Y.analysis.riskReport.riskScore,to:K.analysis.riskReport.riskScore,delta:K.analysis.riskReport.riskScore-Y.analysis.riskReport.riskScore},findings:V,flags:U,files:J},summary:{findingsAdded:V.added.length,findingsRemoved:V.removed.length,findingsChanged:V.changed.length,flagsAdded:U.added.length,flagsRemoved:U.removed.length,flagsChanged:U.changed.length,filesAdded:J.added.length,filesRemoved:J.removed.length,filesModified:J.modified.length}}}function nY($,Z){let Q=new Map,X=new Map;for(let W of $)if(W.findingId)Q.set(W.findingId,W);for(let W of Z)if(W.findingId)X.set(W.findingId,W);let Y=[],K=[],q=[];for(let W of Q.keys())if(!X.has(W))K.push(W);for(let[W,V]of X){let U=Q.get(W);if(!U)Y.push(W);else if(!v0(U,V))q.push({findingId:W,before:U,after:V})}return Y.sort(),K.sort(),q.sort((W,V)=>W.findingId.localeCompare(V.findingId)),{added:Y,removed:K,changed:q}}function tY($,Z){let Q=new Map,X=new Map;for(let W of $)if(W.flagId)Q.set(W.flagId,W);for(let W of Z)if(W.flagId)X.set(W.flagId,W);let Y=[],K=[],q=[];for(let W of Q.keys())if(!X.has(W))K.push(W);for(let[W,V]of X){let U=Q.get(W);if(!U)Y.push(W);else if(!v0(U,V))q.push({flagId:W,before:U,after:V})}return Y.sort(),K.sort(),q.sort((W,V)=>W.flagId.localeCompare(V.flagId)),{added:Y,removed:K,changed:q}}function eY($,Z,Q,X){let Y=new Set,K=new Set,q=new Map,W=new Map,V=$.analysis.facts.changeset,U=Z.analysis.facts.changeset;for(let H of V.files.added)Y.add(H),q.set(H,"added");for(let H of V.files.modified)Y.add(H),q.set(H,"modified");for(let H of V.files.deleted)Y.add(H),q.set(H,"deleted");for(let{from:H,to:_}of V.files.renamed)Y.add(H),Y.add(_),q.set(H,`renamed:${_}`);for(let H of U.files.added)K.add(H),W.set(H,"added");for(let H of U.files.modified)K.add(H),W.set(H,"modified");for(let H of U.files.deleted)K.add(H),W.set(H,"deleted");for(let{from:H,to:_}of U.files.renamed)K.add(H),K.add(_),W.set(H,`renamed:${_}`);for(let H of Q)Y.add(H.path),q.set(H.path,H.blobSha256);for(let H of X)K.add(H.path),W.set(H.path,H.blobSha256);let J=[],G=[],B=[];for(let H of Y)if(!K.has(H))G.push(H);for(let H of K)if(!Y.has(H))J.push(H);else{let _=q.get(H),O=W.get(H);if(_!==O)B.push(H)}return J.sort(),G.sort(),B.sort(),{added:J,removed:G,modified:B}}function v0($,Z){if($===Z)return!0;if($===null||Z===null)return!1;if(typeof $!=="object"||typeof Z!=="object")return!1;if(Array.isArray($)&&Array.isArray(Z)){if($.length!==Z.length)return!1;for(let Y=0;Y<$.length;Y++)if(!v0($[Y],Z[Y]))return!1;return!0}if(Array.isArray($)||Array.isArray(Z))return!1;let Q=Object.keys($).sort(),X=Object.keys(Z).sort();if(Q.length!==X.length)return!1;if(!Q.every((Y,K)=>Y===X[K]))return!1;for(let Y of Q)if(!v0($[Y],Z[Y]))return!1;return!0}function IZ($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}var bZ=x(()=>{U$();k0()});async function PZ($,Z={}){let Q=Z.cwd??process.cwd();if(!await d1($,Q))throw new a1($);let X=await r1($,Q),Y=await R$(Q);if(Y!==X.git.headSha)throw new S0(X.git.headSha,Y);let K=MZ(),q=await P0({label:K,cwd:Q});await LZ(Q),await DZ(Q);let W=await X5($,"staged",Q);if(W.length>0)try{await E0(W,{cached:!0},Q),await E0(W,{},Q)}catch(G){throw new p$("staged",G instanceof Error?G.message:String(G))}let V=await X5($,"unstaged",Q);if(V.length>0)try{await E0(V,{},Q)}catch(G){throw new p$("unstaged",G instanceof Error?G.message:String(G))}let U=await f$($,Q);for(let G of U.entries){let B=await HZ($,G.blobSha256,Q);await NZ(G.path,B,G.mode,Q)}let J=await $K(X,Q);return{snapshotId:$,backupSnapshotId:q.snapshotId,success:!0,verified:J}}async function $K($,Z){try{let[Q,X]=await Promise.all([T$(Z),w$(Z)]),Y=p1(Q),K=p1(X),q=Y===$.workspace.patches.staged.sha256,W=K===$.workspace.patches.unstaged.sha256;return q&&W}catch{return!1}}var S0,p$,q5;var kZ=x(()=>{U$();b0();W5();k0();w1();S0=class S0 extends F{constructor($,Z){super(`HEAD mismatch: snapshot was created at ${$.slice(0,8)} but current HEAD is ${Z.slice(0,8)}. Snapshots can only be restored when HEAD matches the original commit.`,1);this.name="HeadMismatchError"}};p$=class p$ extends F{constructor($,Z){super(`Failed to apply ${$} patch: ${Z}`,1);this.name="PatchApplicationError"}};q5=class q5 extends F{constructor($){super(`Restore verification failed: ${$}`,1);this.name="RestoreVerificationError"}}});var x$={};P1(x$,{snapshotExists:()=>d1,renderSnapShowJSON:()=>xZ,renderSnapListJSON:()=>RZ,renderSnapDiffJSON:()=>IZ,readSnapshotJson:()=>r1,readIndex:()=>l$,getUntrackedFiles:()=>I0,getUnstagedPatch:()=>w$,getStagedPatch:()=>T$,getSnapshotsDir:()=>c$,getSnapshotDir:()=>t1,getHeadSha:()=>R$,getCurrentBranch:()=>x0,executeSnapShow:()=>wZ,executeSnapSave:()=>P0,executeSnapRestore:()=>PZ,executeSnapList:()=>AZ,executeSnapDiff:()=>EZ,computeSnapshotId:()=>T0,SnapshotNotFoundError:()=>a1,RestoreVerificationError:()=>q5,PatchApplicationError:()=>p$,HeadMismatchError:()=>S0});var E$=x(()=>{U$();b0();W5();TZ();k0();bZ();kZ()});w1();s$();import{Command as ZK}from"commander";import{createInterface as QK}from"readline";import XK from"ora";import YK from"chalk";w1();import{mkdir as M5,writeFile as z5}from"node:fs/promises";import{dirname as iZ,join as nZ}from"node:path";var v1={quiet:!1,debug:!1};function V5($){if($.quiet)v1.quiet=!0,v1.debug=!1;else v1.quiet=!1,v1.debug=$.debug??!1}function HK(){return{...v1}}function _K(){v1.quiet=!1,v1.debug=!1}function J$($){if(!v1.quiet)console.error($)}function d($){if(!v1.quiet)console.error($)}function MK($){if(!v1.quiet&&v1.debug)console.error(`[DEBUG] ${$}`)}function r($){console.error($)}import dZ from"picomatch";var Q$=["**/pnpm-lock.yaml","**/package-lock.json","**/yarn.lock","**/bun.lock","**/bun.lockb","**/*.d.ts","**/*.log","**/*.logs","**/dist/**","**/build/**","**/.svelte-kit/**","**/.next/**","**/.turbo/**","**/coverage/**","**/.cache/**","**/*.min.*","**/*.map"];function u0($){let Z=["diff","--name-status","--find-renames"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}return Z}function g0($){let Z=["diff",`--unified=${$.unified}`,"--find-renames"];switch($.mode){case"branch":Z.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Z.push("--staged");break;case"all":Z.push("HEAD");break}if(Z.push("--"),$.oldPath)Z.push($.oldPath);return Z.push($.path),Z}function c0($,Z){return["diff","--no-index",`--unified=${Z}`,"--","/dev/null",$]}function l0($){if(!$)return[];return $.split("\x00").filter(Boolean)}function h0($){if($.length===0)return()=>!1;let Z=$.map((Q)=>dZ(Q,{dot:!0}));return(Q)=>Z.some((X)=>X(Q))}function G$($){let{files:Z,includeGlobs:Q,excludeGlobs:X,defaultExcludes:Y}=$,K=h0(Q),q=h0(X),W=h0(Y),V=Q.length>0,U=[],J=[];for(let G of Z){let B=G.path;if(q(B)){J.push({path:B,reason:"excluded-by-glob"});continue}if(V){if(!K(B)){J.push({path:B,reason:"not-included"});continue}U.push(G);continue}if(W(B)){J.push({path:B,reason:"excluded-by-default"});continue}U.push(G)}return U.sort((G,B)=>G.path.localeCompare(B.path)),{included:U,skipped:J}}function f0($,Z){if($.length===0)return[];let Q=[],X=[],Y=0;for(let K of $){let q=K.diff.length;if(q>Z){if(X.length>0)Q.push(X),X=[],Y=0;Q.push([K]);continue}if(Y+q>Z&&X.length>0)Q.push(X),X=[],Y=0;X.push(K),Y+=q}if(X.length>0)Q.push(X);return Q}function o$($){return $.map((Z)=>Z.diff).join(`
278
+ `)}function rZ($){switch($.mode){case"branch":return`Git Diff: ${$.base}..${$.head}`;case"unstaged":return"Git Diff: Unstaged Changes (working tree vs index)";case"staged":return"Git Diff: Staged Changes (index vs HEAD)";case"all":return"Git Diff: All Changes (working tree vs HEAD)"}}function i$($,Z){let Q=[];if(Q.push(`# ${rZ(Z)}`),Q.push(""),Q.push(`**Mode:** ${Z.mode}`),Q.push(`**Unified context:** ${Z.unified} lines`),Z.excludePatterns.length>0)Q.push(`**Excluded patterns:** ${Z.excludePatterns.join(", ")}`);Q.push(`**Files included:** ${$.length}`),Q.push(""),Q.push("## Files"),Q.push("");for(let X of $){let Y=aZ(X.status),K=X.untracked?" [untracked]":"";Q.push(`- \`${X.path}\` (${Y}${K})`)}return Q.push(""),Q.push("## Diff"),Q.push(""),Q.push("```diff"),Q.push($.map((X)=>X.diff).join(`
275
279
  `)),Q.push("```"),Q.join(`
276
- `)}function xZ($){switch($){case"A":return"added";case"M":return"modified";case"D":return"deleted";case"R":return"renamed";case"C":return"copied";case"T":return"type-changed";case"U":return"unmerged";case"?":return"untracked";case"unknown":return"unknown";default:return"unknown"}}function p$($){return $.reduce((Z,Q)=>Z+Q.diff.length,0)}function i2($){let Z=$.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);if(!Z)return null;return{oldStart:parseInt(Z[1],10),oldLines:Z[2]?parseInt(Z[2],10):1,newStart:parseInt(Z[3],10),newLines:Z[4]?parseInt(Z[4],10):1}}function u0($){if(!$.trim())return[];let Z=$.split(`
277
- `),Q=[],X=null;for(let K of Z)if(K.startsWith("@@")){if(X)Q.push(X);let Y=i2(K);X={header:K,oldStart:Y?.oldStart,oldLines:Y?.oldLines,newStart:Y?.newStart,newLines:Y?.newLines,lines:[]}}else if(X){if(K.startsWith("\\"))continue;let Y;if(K.startsWith("+"))Y="add";else if(K.startsWith("-"))Y="del";else Y="context";X.lines.push({kind:Y,text:K})}if(X)Q.push(X);return Q}function wZ($){let Z=[];if(Z.push("--mode",$.mode),$.mode==="branch"){if($.base)Z.push("--base",$.base);if($.head)Z.push("--head",$.head)}if(Z.push("--format","json"),$.unified!==0)Z.push("--unified",String($.unified));for(let Q of $.include)Z.push("--include",Q);for(let Q of $.exclude)Z.push("--exclude",Q);if(!$.includeUntracked)Z.push("--no-untracked");if($.nameOnly)Z.push("--name-only");if($.stat)Z.push("--stat");if($.patchFor)Z.push("--patch-for",$.patchFor);return Z}function u1($,Z,Q,X){let K={schemaVersion:"2.0",generatedAt:$.noTimestamp?void 0:new Date().toISOString(),command:{name:"dump-diff",args:wZ($)},git:{mode:$.mode,base:$.mode==="branch"?$.base??null:null,head:$.mode==="branch"?$.head??null:null,isDirty:$.mode!=="branch"},options:{unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:$.nameOnly,stat:$.stat,patchFor:$.patchFor},files:Z,skippedFiles:Q,summary:{changedFileCount:X,includedFileCount:Z.length,skippedFileCount:Q.length}};if(K.generatedAt===void 0)delete K.generatedAt;return K}function h1($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}function t2($){if(!$.trim())return[];let Z=[],Q=$.split(`
278
- `),X=null,K,Y=[],W=()=>{if(X&&Y.length>0)Z.push({path:X,oldPath:K,diffText:Y.join(`
279
- `)});X=null,K=void 0,Y=[]};for(let q=0;q<Q.length;q++){let V=Q[q];if(V.startsWith("diff --git ")){W();let U=V.match(/^diff --git a\/(.+) b\/(.+)$/);if(U){X=U[2];let B=q+1;while(B<Q.length&&!Q[B].startsWith("diff --git ")){let G=Q[B];if(G.startsWith("rename from ")){K=G.substring(12);break}if(G.startsWith("@@"))break;B++}}Y.push(V)}else if(X)Y.push(V)}return W(),Z}async function d$($,Z=4){if($.length===0)return[];let Q=Array($.length),X=0,K=0;return new Promise((Y,W)=>{let q=()=>{if(X>=$.length&&K===0){Y(Q);return}while(K<Z&&X<$.length){let V=X++,U=$[V];K++,U().then((J)=>{Q[V]=J,K--,q()}).catch(W)}};q()})}H1();import{execa as b1}from"execa";async function EZ($=process.cwd()){try{let Z=await b1("git",["rev-parse","--is-inside-work-tree"],{cwd:$,reject:!1});return Z.exitCode===0&&Z.stdout.trim()==="true"}catch{return!1}}async function e2($,Z=process.cwd()){try{return(await b1("git",["rev-parse","--verify",$],{cwd:Z,reject:!1})).exitCode===0}catch{return!1}}function $5($){if(!$.trim())return[];let Z=[],Q=$.trim().split(`
280
- `);for(let X of Q){if(!X.trim())continue;let K=X.split("\t"),Y=K[0]?.charAt(0);if(Y==="R"&&K.length>=3)Z.push({path:K[2],oldPath:K[1],status:"R"});else if(K.length>=2)Z.push({path:K[1],status:Y})}return Z}async function R$($){let Z=$.cwd??process.cwd();if(!await EZ(Z))throw new q$(Z);if($.mode==="branch"){if(!$.base||!await e2($.base,Z))throw new M1($.base??"undefined");if(!$.head||!await e2($.head,Z))throw new M1($.head??"undefined")}let Q=k0({mode:$.mode,base:$.base,head:$.head});try{let X=await b1("git",Q,{cwd:Z});return $5(X.stdout)}catch(X){if(X instanceof Error&&"stderr"in X)throw new d(`git ${Q.join(" ")}`,String(X.stderr));throw X}}async function r$($){let Z=$.cwd??process.cwd(),Q=$.unified??0,X=S0({mode:$.mode,base:$.base,head:$.head,unified:Q,path:$.path,oldPath:$.oldPath});try{return(await b1("git",X,{cwd:Z})).stdout}catch(K){if(K instanceof Error&&"stderr"in K)throw new d(`git ${X.join(" ")}`,String(K.stderr));throw K}}async function Z5($){let Z=$.cwd??process.cwd(),Q=["diff","--numstat","--find-renames"];switch($.mode){case"branch":Q.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Q.push("--staged");break;case"all":Q.push("HEAD");break}Q.push("--",$.path);try{let K=(await b1("git",Q,{cwd:Z,reject:!1})).stdout.trim();if(!K)return!1;let Y=K.split("\t");return Y[0]==="-"&&Y[1]==="-"}catch{return!1}}async function T$($=process.cwd()){try{let Z=await b1("git",["ls-files","--others","--exclude-standard","-z"],{cwd:$});return F0(Z.stdout)}catch{return[]}}async function h0($,Z=0,Q=process.cwd()){let X=v0($,Z);try{return(await b1("git",X,{cwd:Q,reject:!1})).stdout}catch{return""}}async function a$($,Z=process.cwd()){try{return(await b1("git",["diff","--no-index","--","/dev/null",$],{cwd:Z,reject:!1})).stdout.includes("Binary files")}catch{return!1}}async function g0($){let Z=$.cwd??process.cwd(),Q=$.unified??0;if($.paths.length===0)return"";let X=["diff",`--unified=${Q}`,"--find-renames"];switch($.mode){case"branch":X.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":X.push("--staged");break;case"all":X.push("HEAD");break}X.push("--",...$.paths);try{return(await b1("git",X,{cwd:Z})).stdout}catch(K){if(K instanceof Error&&"stderr"in K)throw new d(`git ${X.join(" ")}`,String(K.stderr));throw K}}async function x$($){let Z=$.cwd??process.cwd(),Q=["diff","--numstat","--find-renames"];switch($.mode){case"branch":Q.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Q.push("--staged");break;case"all":Q.push("HEAD");break}try{let X=await b1("git",Q,{cwd:Z});return Q5(X.stdout)}catch(X){if(X instanceof Error&&"stderr"in X)throw new d(`git ${Q.join(" ")}`,String(X.stderr));throw X}}function Q5($){let Z=new Map;if(!$.trim())return Z;let Q=$.trim().split(`
281
- `);for(let X of Q){if(!X.trim())continue;let K=X.split("\t");if(K.length<3)continue;let Y=K[0],W=K[1],q=Y==="-"&&W==="-",V=K.length>=4,U,J;if(V)J=K[2],U=K[3];else U=K[2];let B={path:U,oldPath:J,added:q?0:parseInt(Y,10),removed:q?0:parseInt(W,10),binary:q};Z.set(U,B)}return Z}var l0=8;async function Y5($){let Z=$.cwd??process.cwd();if($.mode!=="branch"){let Q=$.base!=="main",X=$.head!=="HEAD";if(Q||X)s1(`Warning: --base and --head are ignored when --mode is "${$.mode}"`)}if($.patchFor){await kZ($,Z);return}if($.nameOnly){await PZ($,Z);return}if($.stat){await yZ($,Z);return}await CZ($,Z)}async function CZ($,Z){let Q=await R$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),X=[];if($.includeUntracked&&$.mode!=="branch")X=(await T$(Z)).map((D)=>({path:D,status:"A",untracked:!0}));let K=[...Q,...X];if(K.length===0){if($.format==="json"){let _=u1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:null,noTimestamp:$.noTimestamp??!1},[],[],0),D=h1(_,$.pretty);if($.out)await B1($.out,D),l(`Wrote JSON output to ${$.out}`);else console.log(D);return}console.log("No changes found.");return}let{included:Y,skipped:W}=W$({files:K,includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:o1}),q=[],V=[],U=Y.filter((_)=>!_.untracked),J=Y.filter((_)=>_.untracked),B=new Map;if(U.length>0)B=await x$({mode:$.mode,base:$.base,head:$.head,cwd:Z});for(let _ of U)if(B.get(_.path)?.binary)V.push({path:_.path,reason:"binary"});else q.push(_);if(J.length>0){let _=J.map((L)=>async()=>{let w=await a$(L.path,Z);return{file:L,isBinary:w}}),D=await d$(_,l0);for(let{file:L,isBinary:w}of D)if(w)V.push({path:L.path,reason:"binary"});else q.push(L)}let G=[...W,...V];if($.dryRun){await vZ($,q,G,Z);return}let M=await SZ($,q,Z),H=[],O=[];for(let _ of M)if(_.diff.trim()==="")O.push({path:_.path,reason:"diff-empty"});else H.push(_);let z=[...G,...O];if($.format==="json"){let _=p$(H);if($.maxChars!==void 0&&_>$.maxChars)throw new v(`JSON output (${_.toLocaleString()} chars) exceeds --max-chars (${$.maxChars.toLocaleString()}). JSON format does not support chunking. Use --format text or --format md for chunked output, or increase --max-chars.`,1);let D=H.map((A)=>({path:A.path,oldPath:A.oldPath,status:A.status,untracked:A.untracked,patch:{text:A.diff}})),L=z.map((A)=>({path:A.path,status:A.status,reason:A.reason,note:A.note})),w=u1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:null,noTimestamp:$.noTimestamp??!1},D,L,K.length),T=h1(w,$.pretty);if($.out)await B1($.out,T),l(`Wrote JSON output to ${$.out}`);else console.log(T)}else await FZ($,H,z,K.length,Z)}async function PZ($,Z){let Q=await R$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),X=[];if($.includeUntracked&&$.mode!=="branch")X=(await T$(Z)).map((H)=>({path:H,status:"A",untracked:!0}));let K=[...Q,...X],{included:Y,skipped:W}=W$({files:K,includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:o1}),q=Y.filter((M)=>!M.untracked),V=Y.filter((M)=>M.untracked),U=new Map;if(q.length>0)U=await x$({mode:$.mode,base:$.base,head:$.head,cwd:Z});for(let M of q)if(U.get(M.path)?.binary)W.push({path:M.path,status:M.status,reason:"binary"});if(V.length>0){let M=V.map((O)=>async()=>{let z=await a$(O.path,Z);return{file:O,isBinary:z}}),H=await d$(M,l0);for(let{file:O,isBinary:z}of H)if(z)W.push({path:O.path,status:O.status,reason:"binary"})}let B=Y.filter((M)=>{return!W.some((H)=>H.path===M.path&&H.reason==="binary")}).sort((M,H)=>M.path.localeCompare(H.path)),G=W.sort((M,H)=>M.path.localeCompare(H.path));if($.format==="json"){let M=B.map((_)=>({path:_.path,oldPath:_.oldPath,status:_.status,untracked:_.untracked})),H=G.map((_)=>({path:_.path,status:_.status,reason:_.reason,note:_.note})),O=u1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!0,stat:!1,patchFor:null,noTimestamp:$.noTimestamp??!1},M,H,K.length),z=h1(O,$.pretty);if($.out)await B1($.out,z),l(`Wrote JSON output to ${$.out}`);else console.log(z)}else if($.format==="md"){let M=[];M.push(`# Changed Files
282
- `);for(let O of B)M.push(`- \`${O.path}\``);let H=M.join(`
283
- `);if($.out)await B1($.out,H),l(`Wrote markdown output to ${$.out}`);else console.log(H)}else{let H=B.map((O)=>O.path).join(`
284
- `);if($.out)await B1($.out,H),l(`Wrote text output to ${$.out}`);else console.log(H)}}async function yZ($,Z){let Q=await R$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),X=[];if($.includeUntracked&&$.mode!=="branch")X=(await T$(Z)).map((G)=>({path:G,status:"A",untracked:!0}));let K=[...Q,...X],Y=await x$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),{included:W,skipped:q}=W$({files:K,includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:o1});for(let B of W)if(Y.get(B.path)?.binary)q.push({path:B.path,status:B.status,reason:"binary"});let U=W.filter((B)=>{return!Y.get(B.path)?.binary}).map((B)=>{let G=Y.get(B.path);return{path:B.path,oldPath:B.oldPath,status:B.status,stats:G?{added:G.added,removed:G.removed}:{added:0,removed:0}}}).sort((B,G)=>B.path.localeCompare(G.path)),J=q.sort((B,G)=>B.path.localeCompare(G.path));if($.format==="json"){let B=U.map((O)=>({path:O.path,oldPath:O.oldPath,status:O.status,stats:O.stats})),G=J.map((O)=>({path:O.path,status:O.status,reason:O.reason,note:O.note})),M=u1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!0,patchFor:null,noTimestamp:$.noTimestamp??!1},B,G,K.length),H=h1(M,$.pretty);if($.out)await B1($.out,H),l(`Wrote JSON output to ${$.out}`);else console.log(H)}else if($.format==="md"){let B=[];B.push(`# File Statistics
285
- `),B.push("| File | Added | Removed |"),B.push("| ---- | -----:| -------:|");for(let M of U)B.push(`| \`${M.path}\` | ${M.stats.added} | ${M.stats.removed} |`);let G=B.join(`
286
- `);if($.out)await B1($.out,G),l(`Wrote markdown output to ${$.out}`);else console.log(G)}else{let G=U.map((M)=>`${M.stats.added} ${M.stats.removed} ${M.path}`).join(`
287
- `);if($.out)await B1($.out,G),l(`Wrote text output to ${$.out}`);else console.log(G)}}async function kZ($,Z){if(!$.patchFor)throw new v("--patch-for requires a file path",1);let Q=$.patchFor,X=await R$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),K=[];if($.includeUntracked&&$.mode!=="branch")K=(await T$(Z)).map((M)=>({path:M,status:"A",untracked:!0}));let W=[...X,...K].find((G)=>G.path===Q||G.oldPath===Q);if(!W)throw new v(`File not found in changes: ${Q}. Run 'branch-narrator dump-diff --name-only' to see changed files.`,1);let{included:q,skipped:V}=W$({files:[W],includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:o1});if(q.length===0){let G=V[0]?.reason||"excluded";throw new v(`File is excluded: ${Q} (reason: ${G}). Use --include "${Q}" to include it.`,1)}let U;if(W.untracked)U=await a$(W.path,Z);else U=await Z5({mode:$.mode,base:$.base,head:$.head,path:W.path,cwd:Z});if(U){if($.format==="json"){let G=[{path:W.path,status:W.status,reason:"binary"}],M=u1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:Q,noTimestamp:$.noTimestamp??!1},[],G,1),H=h1(M,$.pretty);if($.out)await B1($.out,H),l(`Wrote JSON output to ${$.out}`);else console.log(H)}else throw new v(`File is binary: ${Q}`,1);return}let J;if(W.untracked)J=await h0(W.path,$.unified,Z);else J=await r$({mode:$.mode,base:$.base,head:$.head,path:W.path,oldPath:W.oldPath,unified:$.unified,cwd:Z});let B;if($.format==="json"){let M=(await x$({mode:$.mode,base:$.base,head:$.head,cwd:Z})).get(W.path);if(M&&!M.binary)B={added:M.added,removed:M.removed}}if($.format==="json"){let G=u0(J),M=[{path:W.path,oldPath:W.oldPath,status:W.status,untracked:W.untracked,stats:B,patch:{text:J,hunks:G}}],H=u1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:Q,noTimestamp:$.noTimestamp??!1},M,[],1),O=h1(H,$.pretty);if($.out)await B1($.out,O),l(`Wrote JSON output to ${$.out}`);else console.log(O)}else if($.format==="md"){let G=[];G.push(`# Diff for \`${W.path}\`
288
- `),G.push("```diff"),G.push(J),G.push("```");let M=G.join(`
289
- `);if($.out)await B1($.out,M),l(`Wrote markdown output to ${$.out}`);else console.log(M)}else if($.out)await B1($.out,J),l(`Wrote text output to ${$.out}`);else console.log(J)}async function SZ($,Z,Q){let X=[],K=Z.filter((W)=>!W.untracked),Y=Z.filter((W)=>W.untracked);if(K.length>0){let W=K.map((q)=>q.path);try{let q=await g0({mode:$.mode,base:$.base,head:$.head,paths:W,unified:$.unified,cwd:Q}),V=t2(q),U=new Map;for(let J of V)if(U.set(J.path,J.diffText),J.oldPath)U.set(J.oldPath,J.diffText);for(let J of K){let B=U.get(J.path);if(!B||B.trim()==="")B=await r$({mode:$.mode,base:$.base,head:$.head,path:J.path,oldPath:J.oldPath,unified:$.unified,cwd:Q});X.push({path:J.path,oldPath:J.oldPath,status:J.status,diff:B||"",untracked:!1})}}catch(q){s1(`Batch diff failed, falling back to per-file diffs: ${q instanceof Error?q.message:String(q)}`);for(let V of K){let U=await r$({mode:$.mode,base:$.base,head:$.head,path:V.path,oldPath:V.oldPath,unified:$.unified,cwd:Q});X.push({path:V.path,oldPath:V.oldPath,status:V.status,diff:U,untracked:!1})}}}if(Y.length>0){let W=Y.map((V)=>async()=>{let U=await h0(V.path,$.unified,Q);return{path:V.path,oldPath:V.oldPath,status:V.status,diff:U,untracked:!0}}),q=await d$(W,l0);X.push(...q)}return X}async function vZ($,Z,Q,X){let K=0;if(Z.length>0){let W=Z.filter((V)=>!V.untracked).map((V)=>V.path);if(W.length>0){let V=await g0({mode:$.mode,base:$.base,head:$.head,paths:W,unified:$.unified,cwd:X});K+=V.length}let q=Z.filter((V)=>V.untracked).length;if(q>0)K+=q*500}let Y=$.maxChars!==void 0&&K>$.maxChars;if(console.log(`=== Dry Run ===
290
- `),console.log(`Mode: ${$.mode}`),$.mode==="branch")console.log(`Base: ${$.base}`),console.log(`Head: ${$.head}`);console.log(`Format: ${$.format}`),console.log(`Unified context: ${$.unified} lines`),console.log(`Include untracked: ${$.includeUntracked}`),console.log(""),console.log(`Files included (${Z.length}):`);for(let W of Z){let q=mZ(W.status),V=W.untracked?" [untracked]":"";console.log(` ${q} ${W.path}${V}`)}console.log(""),console.log(`Files skipped (${Q.length}):`);for(let W of Q)console.log(` - ${W.path} (${W.reason})`);if(console.log(""),console.log(`Estimated output size: ${K.toLocaleString()} chars`),$.maxChars!==void 0){if(console.log(`Max chars: ${$.maxChars.toLocaleString()}`),console.log(`Would chunk: ${Y?"yes":"no"}`),Y){let W=Math.ceil(K/$.maxChars);console.log(`Estimated chunks: ~${W}`)}}if($.out)console.log(`
291
- Output would be written to: ${$.out}`);else if(Y)console.log(`
292
- Chunks would be written to: ${$.chunkDir}/`)}async function FZ($,Z,Q,X,K){let Y={mode:$.mode,base:$.mode==="branch"?$.base:null,head:$.mode==="branch"?$.head:null,unified:$.unified,excludePatterns:[...o1,...$.exclude]},W=p$(Z);if($.maxChars!==void 0&&W>$.maxChars){let V=m0(Z,$.maxChars),U=$.format==="md"?"md":"txt";await X5($.chunkDir,{recursive:!0});for(let J=0;J<V.length;J++){let B=V[J],G=String(J+1).padStart(3,"0"),M=`${$.name}-${G}.${U}`,H=bZ($.chunkDir,M),O;if($.format==="md"){let z={...Y,base:$.mode==="branch"?`${$.base} (chunk ${J+1}/${V.length})`:null};O=f$(B,z)}else O=c$(B);await K5(H,O,"utf-8"),l(`Wrote chunk ${J+1}/${V.length} to ${H}`)}l(`
293
- Total: ${V.length} chunks, ${Z.length} files, ${W.toLocaleString()} chars`)}else{let V;if($.format==="md")V=f$(Z,Y);else V=c$(Z);if($.out)await B1($.out,V),l(`Wrote ${$.format} output to ${$.out}`);else console.log(V)}}async function B1($,Z){let Q=IZ($);await X5(Q,{recursive:!0}),await K5($,Z,"utf-8")}function mZ($){switch($){case"A":return"+";case"M":return"~";case"D":return"-";case"R":return"→";default:return"?"}}B$();C$();t$();n$();function Y7($){let Z=new Map;for(let Q of $){if(!Z.has(Q.type))Z.set(Q.type,[]);Z.get(Q.type).push(Q)}return Z}function q7($){if(!$.interactive?.context)return"";return`## Context
280
+ `)}function aZ($){switch($){case"A":return"added";case"M":return"modified";case"D":return"deleted";case"R":return"renamed";case"C":return"copied";case"T":return"type-changed";case"U":return"unmerged";case"?":return"untracked";case"unknown":return"unknown";default:return"unknown"}}function n$($){return $.reduce((Z,Q)=>Z+Q.diff.length,0)}function J5($){let Z=$.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);if(!Z)return null;return{oldStart:parseInt(Z[1],10),oldLines:Z[2]?parseInt(Z[2],10):1,newStart:parseInt(Z[3],10),newLines:Z[4]?parseInt(Z[4],10):1}}function p0($){if(!$.trim())return[];let Z=$.split(`
281
+ `),Q=[],X=null;for(let Y of Z)if(Y.startsWith("@@")){if(X)Q.push(X);let K=J5(Y);X={header:Y,oldStart:K?.oldStart,oldLines:K?.oldLines,newStart:K?.newStart,newLines:K?.newLines,lines:[]}}else if(X){if(Y.startsWith("\\"))continue;let K;if(Y.startsWith("+"))K="add";else if(Y.startsWith("-"))K="del";else K="context";X.lines.push({kind:K,text:Y})}if(X)Q.push(X);return Q}function sZ($){let Z=[];if(Z.push("--mode",$.mode),$.mode==="branch"){if($.base)Z.push("--base",$.base);if($.head)Z.push("--head",$.head)}if(Z.push("--format","json"),$.unified!==0)Z.push("--unified",String($.unified));for(let Q of $.include)Z.push("--include",Q);for(let Q of $.exclude)Z.push("--exclude",Q);if(!$.includeUntracked)Z.push("--no-untracked");if($.nameOnly)Z.push("--name-only");if($.stat)Z.push("--stat");if($.patchFor)Z.push("--patch-for",$.patchFor);return Z}function o1($,Z,Q,X){let Y={schemaVersion:"2.0",generatedAt:$.noTimestamp?void 0:new Date().toISOString(),command:{name:"dump-diff",args:sZ($)},git:{mode:$.mode,base:$.mode==="branch"?$.base??null:null,head:$.mode==="branch"?$.head??null:null,isDirty:$.mode!=="branch"},options:{unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:$.nameOnly,stat:$.stat,patchFor:$.patchFor},files:Z,skippedFiles:Q,summary:{changedFileCount:X,includedFileCount:Z.length,skippedFileCount:Q.length}};if(Y.generatedAt===void 0)delete Y.generatedAt;return Y}function i1($,Z=!1){return Z?JSON.stringify($,null,2):JSON.stringify($)}function G5($){if(!$.trim())return[];let Z=[],Q=$.split(`
282
+ `),X=null,Y,K=[],q=()=>{if(X&&K.length>0)Z.push({path:X,oldPath:Y,diffText:K.join(`
283
+ `)});X=null,Y=void 0,K=[]};for(let W=0;W<Q.length;W++){let V=Q[W];if(V.startsWith("diff --git ")){q();let U=V.match(/^diff --git a\/(.+) b\/(.+)$/);if(U){X=U[2];let G=W+1;while(G<Q.length&&!Q[G].startsWith("diff --git ")){let B=Q[G];if(B.startsWith("rename from ")){Y=B.substring(12);break}if(B.startsWith("@@"))break;G++}}K.push(V)}else if(X)K.push(V)}return q(),Z}async function t$($,Z=4){if($.length===0)return[];let Q=Array($.length),X=0,Y=0;return new Promise((K,q)=>{let W=()=>{if(X>=$.length&&Y===0){K(Q);return}while(Y<Z&&X<$.length){let V=X++,U=$[V];Y++,U().then((J)=>{Q[V]=J,Y--,W()}).catch(q)}};W()})}w1();import{execa as y1}from"execa";async function oZ($=process.cwd()){try{let Z=await y1("git",["rev-parse","--is-inside-work-tree"],{cwd:$,reject:!1});return Z.exitCode===0&&Z.stdout.trim()==="true"}catch{return!1}}async function B5($,Z=process.cwd()){try{return(await y1("git",["rev-parse","--verify",$],{cwd:Z,reject:!1})).exitCode===0}catch{return!1}}function O5($){if(!$.trim())return[];let Z=[],Q=$.trim().split(`
284
+ `);for(let X of Q){if(!X.trim())continue;let Y=X.split("\t"),K=Y[0]?.charAt(0);if(K==="R"&&Y.length>=3)Z.push({path:Y[2],oldPath:Y[1],status:"R"});else if(Y.length>=2)Z.push({path:Y[1],status:K})}return Z}async function b$($){let Z=$.cwd??process.cwd();if(!await oZ(Z))throw new V$(Z);if($.mode==="branch"){if(!$.base||!await B5($.base,Z))throw new T1($.base??"undefined");if(!$.head||!await B5($.head,Z))throw new T1($.head??"undefined")}let Q=u0({mode:$.mode,base:$.base,head:$.head});try{let X=await y1("git",Q,{cwd:Z});return O5(X.stdout)}catch(X){if(X instanceof Error&&"stderr"in X)throw new G1(`git ${Q.join(" ")}`,String(X.stderr));throw X}}async function e$($){let Z=$.cwd??process.cwd(),Q=$.unified??0,X=g0({mode:$.mode,base:$.base,head:$.head,unified:Q,path:$.path,oldPath:$.oldPath});try{return(await y1("git",X,{cwd:Z})).stdout}catch(Y){if(Y instanceof Error&&"stderr"in Y)throw new G1(`git ${X.join(" ")}`,String(Y.stderr));throw Y}}async function H5($){let Z=$.cwd??process.cwd(),Q=["diff","--numstat","--find-renames"];switch($.mode){case"branch":Q.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Q.push("--staged");break;case"all":Q.push("HEAD");break}Q.push("--",$.path);try{let Y=(await y1("git",Q,{cwd:Z,reject:!1})).stdout.trim();if(!Y)return!1;let K=Y.split("\t");return K[0]==="-"&&K[1]==="-"}catch{return!1}}async function P$($=process.cwd()){try{let Z=await y1("git",["ls-files","--others","--exclude-standard","-z"],{cwd:$});return l0(Z.stdout)}catch{return[]}}async function d0($,Z=0,Q=process.cwd()){let X=c0($,Z);try{return(await y1("git",X,{cwd:Q,reject:!1})).stdout}catch{return""}}async function $0($,Z=process.cwd()){try{return(await y1("git",["diff","--no-index","--","/dev/null",$],{cwd:Z,reject:!1})).stdout.includes("Binary files")}catch{return!1}}async function r0($){let Z=$.cwd??process.cwd(),Q=$.unified??0;if($.paths.length===0)return"";let X=["diff",`--unified=${Q}`,"--find-renames"];switch($.mode){case"branch":X.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":X.push("--staged");break;case"all":X.push("HEAD");break}X.push("--",...$.paths);try{return(await y1("git",X,{cwd:Z})).stdout}catch(Y){if(Y instanceof Error&&"stderr"in Y)throw new G1(`git ${X.join(" ")}`,String(Y.stderr));throw Y}}async function k$($){let Z=$.cwd??process.cwd(),Q=["diff","--numstat","--find-renames"];switch($.mode){case"branch":Q.push(`${$.base}..${$.head}`);break;case"unstaged":break;case"staged":Q.push("--staged");break;case"all":Q.push("HEAD");break}try{let X=await y1("git",Q,{cwd:Z});return _5(X.stdout)}catch(X){if(X instanceof Error&&"stderr"in X)throw new G1(`git ${Q.join(" ")}`,String(X.stderr));throw X}}function _5($){let Z=new Map;if(!$.trim())return Z;let Q=$.trim().split(`
285
+ `);for(let X of Q){if(!X.trim())continue;let Y=X.split("\t");if(Y.length<3)continue;let K=Y[0],q=Y[1],W=K==="-"&&q==="-",V=Y.length>=4,U,J;if(V)J=Y[2],U=Y[3];else U=Y[2];let G={path:U,oldPath:J,added:W?0:parseInt(K,10),removed:W?0:parseInt(q,10),binary:W};Z.set(U,G)}return Z}var a0=8;async function j5($){let Z=$.cwd??process.cwd();if($.mode!=="branch"){let Q=$.base!=="main",X=$.head!=="HEAD";if(Q||X)J$(`Warning: --base and --head are ignored when --mode is "${$.mode}"`)}if($.patchFor){await Z4($,Z);return}if($.nameOnly){await eZ($,Z);return}if($.stat){await $4($,Z);return}await tZ($,Z)}async function tZ($,Z){let Q=await b$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),X=[];if($.includeUntracked&&$.mode!=="branch")X=(await P$(Z)).map((A)=>({path:A,status:"A",untracked:!0}));let Y=[...Q,...X];if(Y.length===0){if($.format==="json"){let z=o1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:null,noTimestamp:$.noTimestamp??!1},[],[],0),A=i1(z,$.pretty);if($.out)await R1($.out,A),d(`Wrote JSON output to ${$.out}`);else console.log(A);return}console.log("No changes found.");return}let{included:K,skipped:q}=G$({files:Y,includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:Q$}),W=[],V=[],U=K.filter((z)=>!z.untracked),J=K.filter((z)=>z.untracked),G=new Map;if(U.length>0)G=await k$({mode:$.mode,base:$.base,head:$.head,cwd:Z});for(let z of U)if(G.get(z.path)?.binary)V.push({path:z.path,reason:"binary"});else W.push(z);if(J.length>0){let z=J.map((N)=>async()=>{let E=await $0(N.path,Z);return{file:N,isBinary:E}}),A=await t$(z,a0);for(let{file:N,isBinary:E}of A)if(E)V.push({path:N.path,reason:"binary"});else W.push(N)}let B=[...q,...V];if($.dryRun){await X4($,W,B,Z);return}let H=await Q4($,W,Z),_=[],O=[];for(let z of H)if(z.diff.trim()==="")O.push({path:z.path,reason:"diff-empty"});else _.push(z);let M=[...B,...O];if($.format==="json"){let z=n$(_);if($.maxChars!==void 0&&z>$.maxChars)throw new F(`JSON output (${z.toLocaleString()} chars) exceeds --max-chars (${$.maxChars.toLocaleString()}). JSON format does not support chunking. Use --format text or --format md for chunked output, or increase --max-chars.`,1);let A=_.map((T)=>({path:T.path,oldPath:T.oldPath,status:T.status,untracked:T.untracked,patch:{text:T.diff}})),N=M.map((T)=>({path:T.path,status:T.status,reason:T.reason,note:T.note})),E=o1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:null,noTimestamp:$.noTimestamp??!1},A,N,Y.length),w=i1(E,$.pretty);if($.out)await R1($.out,w),d(`Wrote JSON output to ${$.out}`);else console.log(w)}else await Y4($,_,M,Y.length,Z)}async function eZ($,Z){let Q=await b$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),X=[];if($.includeUntracked&&$.mode!=="branch")X=(await P$(Z)).map((_)=>({path:_,status:"A",untracked:!0}));let Y=[...Q,...X],{included:K,skipped:q}=G$({files:Y,includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:Q$}),W=K.filter((H)=>!H.untracked),V=K.filter((H)=>H.untracked),U=new Map;if(W.length>0)U=await k$({mode:$.mode,base:$.base,head:$.head,cwd:Z});for(let H of W)if(U.get(H.path)?.binary)q.push({path:H.path,status:H.status,reason:"binary"});if(V.length>0){let H=V.map((O)=>async()=>{let M=await $0(O.path,Z);return{file:O,isBinary:M}}),_=await t$(H,a0);for(let{file:O,isBinary:M}of _)if(M)q.push({path:O.path,status:O.status,reason:"binary"})}let G=K.filter((H)=>{return!q.some((_)=>_.path===H.path&&_.reason==="binary")}).sort((H,_)=>H.path.localeCompare(_.path)),B=q.sort((H,_)=>H.path.localeCompare(_.path));if($.format==="json"){let H=G.map((z)=>({path:z.path,oldPath:z.oldPath,status:z.status,untracked:z.untracked})),_=B.map((z)=>({path:z.path,status:z.status,reason:z.reason,note:z.note})),O=o1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!0,stat:!1,patchFor:null,noTimestamp:$.noTimestamp??!1},H,_,Y.length),M=i1(O,$.pretty);if($.out)await R1($.out,M),d(`Wrote JSON output to ${$.out}`);else console.log(M)}else if($.format==="md"){let H=[];H.push(`# Changed Files
286
+ `);for(let O of G)H.push(`- \`${O.path}\``);let _=H.join(`
287
+ `);if($.out)await R1($.out,_),d(`Wrote markdown output to ${$.out}`);else console.log(_)}else{let _=G.map((O)=>O.path).join(`
288
+ `);if($.out)await R1($.out,_),d(`Wrote text output to ${$.out}`);else console.log(_)}}async function $4($,Z){let Q=await b$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),X=[];if($.includeUntracked&&$.mode!=="branch")X=(await P$(Z)).map((B)=>({path:B,status:"A",untracked:!0}));let Y=[...Q,...X],K=await k$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),{included:q,skipped:W}=G$({files:Y,includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:Q$});for(let G of q)if(K.get(G.path)?.binary)W.push({path:G.path,status:G.status,reason:"binary"});let U=q.filter((G)=>{return!K.get(G.path)?.binary}).map((G)=>{let B=K.get(G.path);return{path:G.path,oldPath:G.oldPath,status:G.status,stats:B?{added:B.added,removed:B.removed}:{added:0,removed:0}}}).sort((G,B)=>G.path.localeCompare(B.path)),J=W.sort((G,B)=>G.path.localeCompare(B.path));if($.format==="json"){let G=U.map((O)=>({path:O.path,oldPath:O.oldPath,status:O.status,stats:O.stats})),B=J.map((O)=>({path:O.path,status:O.status,reason:O.reason,note:O.note})),H=o1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!0,patchFor:null,noTimestamp:$.noTimestamp??!1},G,B,Y.length),_=i1(H,$.pretty);if($.out)await R1($.out,_),d(`Wrote JSON output to ${$.out}`);else console.log(_)}else if($.format==="md"){let G=[];G.push(`# File Statistics
289
+ `),G.push("| File | Added | Removed |"),G.push("| ---- | -----:| -------:|");for(let H of U)G.push(`| \`${H.path}\` | ${H.stats.added} | ${H.stats.removed} |`);let B=G.join(`
290
+ `);if($.out)await R1($.out,B),d(`Wrote markdown output to ${$.out}`);else console.log(B)}else{let B=U.map((H)=>`${H.stats.added} ${H.stats.removed} ${H.path}`).join(`
291
+ `);if($.out)await R1($.out,B),d(`Wrote text output to ${$.out}`);else console.log(B)}}async function Z4($,Z){if(!$.patchFor)throw new F("--patch-for requires a file path",1);let Q=$.patchFor,X=await b$({mode:$.mode,base:$.base,head:$.head,cwd:Z}),Y=[];if($.includeUntracked&&$.mode!=="branch")Y=(await P$(Z)).map((H)=>({path:H,status:"A",untracked:!0}));let q=[...X,...Y].find((B)=>B.path===Q||B.oldPath===Q);if(!q)throw new F(`File not found in changes: ${Q}. Run 'branch-narrator dump-diff --name-only' to see changed files.`,1);let{included:W,skipped:V}=G$({files:[q],includeGlobs:$.include,excludeGlobs:$.exclude,defaultExcludes:Q$});if(W.length===0){let B=V[0]?.reason||"excluded";throw new F(`File is excluded: ${Q} (reason: ${B}). Use --include "${Q}" to include it.`,1)}let U;if(q.untracked)U=await $0(q.path,Z);else U=await H5({mode:$.mode,base:$.base,head:$.head,path:q.path,cwd:Z});if(U){if($.format==="json"){let B=[{path:q.path,status:q.status,reason:"binary"}],H=o1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:Q,noTimestamp:$.noTimestamp??!1},[],B,1),_=i1(H,$.pretty);if($.out)await R1($.out,_),d(`Wrote JSON output to ${$.out}`);else console.log(_)}else throw new F(`File is binary: ${Q}`,1);return}let J;if(q.untracked)J=await d0(q.path,$.unified,Z);else J=await e$({mode:$.mode,base:$.base,head:$.head,path:q.path,oldPath:q.oldPath,unified:$.unified,cwd:Z});let G;if($.format==="json"){let H=(await k$({mode:$.mode,base:$.base,head:$.head,cwd:Z})).get(q.path);if(H&&!H.binary)G={added:H.added,removed:H.removed}}if($.format==="json"){let B=p0(J),H=[{path:q.path,oldPath:q.oldPath,status:q.status,untracked:q.untracked,stats:G,patch:{text:J,hunks:B}}],_=o1({mode:$.mode,base:$.base,head:$.head,unified:$.unified,include:$.include,exclude:$.exclude,includeUntracked:$.includeUntracked,nameOnly:!1,stat:!1,patchFor:Q,noTimestamp:$.noTimestamp??!1},H,[],1),O=i1(_,$.pretty);if($.out)await R1($.out,O),d(`Wrote JSON output to ${$.out}`);else console.log(O)}else if($.format==="md"){let B=[];B.push(`# Diff for \`${q.path}\`
292
+ `),B.push("```diff"),B.push(J),B.push("```");let H=B.join(`
293
+ `);if($.out)await R1($.out,H),d(`Wrote markdown output to ${$.out}`);else console.log(H)}else if($.out)await R1($.out,J),d(`Wrote text output to ${$.out}`);else console.log(J)}async function Q4($,Z,Q){let X=[],Y=Z.filter((q)=>!q.untracked),K=Z.filter((q)=>q.untracked);if(Y.length>0){let q=Y.map((W)=>W.path);try{let W=await r0({mode:$.mode,base:$.base,head:$.head,paths:q,unified:$.unified,cwd:Q}),V=G5(W),U=new Map;for(let J of V)if(U.set(J.path,J.diffText),J.oldPath)U.set(J.oldPath,J.diffText);for(let J of Y){let G=U.get(J.path);if(!G||G.trim()==="")G=await e$({mode:$.mode,base:$.base,head:$.head,path:J.path,oldPath:J.oldPath,unified:$.unified,cwd:Q});X.push({path:J.path,oldPath:J.oldPath,status:J.status,diff:G||"",untracked:!1})}}catch(W){J$(`Batch diff failed, falling back to per-file diffs: ${W instanceof Error?W.message:String(W)}`);for(let V of Y){let U=await e$({mode:$.mode,base:$.base,head:$.head,path:V.path,oldPath:V.oldPath,unified:$.unified,cwd:Q});X.push({path:V.path,oldPath:V.oldPath,status:V.status,diff:U,untracked:!1})}}}if(K.length>0){let q=K.map((V)=>async()=>{let U=await d0(V.path,$.unified,Q);return{path:V.path,oldPath:V.oldPath,status:V.status,diff:U,untracked:!0}}),W=await t$(q,a0);X.push(...W)}return X}async function X4($,Z,Q,X){let Y=0;if(Z.length>0){let q=Z.filter((V)=>!V.untracked).map((V)=>V.path);if(q.length>0){let V=await r0({mode:$.mode,base:$.base,head:$.head,paths:q,unified:$.unified,cwd:X});Y+=V.length}let W=Z.filter((V)=>V.untracked).length;if(W>0)Y+=W*500}let K=$.maxChars!==void 0&&Y>$.maxChars;if(console.log(`=== Dry Run ===
294
+ `),console.log(`Mode: ${$.mode}`),$.mode==="branch")console.log(`Base: ${$.base}`),console.log(`Head: ${$.head}`);console.log(`Format: ${$.format}`),console.log(`Unified context: ${$.unified} lines`),console.log(`Include untracked: ${$.includeUntracked}`),console.log(""),console.log(`Files included (${Z.length}):`);for(let q of Z){let W=K4(q.status),V=q.untracked?" [untracked]":"";console.log(` ${W} ${q.path}${V}`)}console.log(""),console.log(`Files skipped (${Q.length}):`);for(let q of Q)console.log(` - ${q.path} (${q.reason})`);if(console.log(""),console.log(`Estimated output size: ${Y.toLocaleString()} chars`),$.maxChars!==void 0){if(console.log(`Max chars: ${$.maxChars.toLocaleString()}`),console.log(`Would chunk: ${K?"yes":"no"}`),K){let q=Math.ceil(Y/$.maxChars);console.log(`Estimated chunks: ~${q}`)}}if($.out)console.log(`
295
+ Output would be written to: ${$.out}`);else if(K)console.log(`
296
+ Chunks would be written to: ${$.chunkDir}/`)}async function Y4($,Z,Q,X,Y){let K={mode:$.mode,base:$.mode==="branch"?$.base:null,head:$.mode==="branch"?$.head:null,unified:$.unified,excludePatterns:[...Q$,...$.exclude]},q=n$(Z);if($.maxChars!==void 0&&q>$.maxChars){let V=f0(Z,$.maxChars),U=$.format==="md"?"md":"txt";await M5($.chunkDir,{recursive:!0});for(let J=0;J<V.length;J++){let G=V[J],B=String(J+1).padStart(3,"0"),H=`${$.name}-${B}.${U}`,_=nZ($.chunkDir,H),O;if($.format==="md"){let M={...K,base:$.mode==="branch"?`${$.base} (chunk ${J+1}/${V.length})`:null};O=i$(G,M)}else O=o$(G);await z5(_,O,"utf-8"),d(`Wrote chunk ${J+1}/${V.length} to ${_}`)}d(`
297
+ Total: ${V.length} chunks, ${Z.length} files, ${q.toLocaleString()} chars`)}else{let V;if($.format==="md")V=i$(Z,K);else V=o$(Z);if($.out)await R1($.out,V),d(`Wrote ${$.format} output to ${$.out}`);else console.log(V)}}async function R1($,Z){let Q=iZ($);await M5(Q,{recursive:!0}),await z5($,Z,"utf-8")}function K4($){switch($){case"A":return"+";case"M":return"~";case"D":return"-";case"R":return"→";default:return"?"}}M$();m$();S$();n0();Q2();S$();var t7=5,V1=5,e7=3;function $Q($){let Z=$.find((W)=>W.type==="file-summary");if(!Z)return{total:0,added:0,modified:0,deleted:0,renamed:0};let Q=Z.added.length,X=Z.modified.length,Y=Z.deleted.length,K=Z.renamed.length;return{total:Q+X+Y+K,added:Q,modified:X,deleted:Y,renamed:K}}function ZQ($){let Z=$.filter((Y)=>Y.type==="impact-analysis"),Q=Z.some((Y)=>Y.blastRadius==="high"),X=Z.some((Y)=>Y.blastRadius==="medium");if(Q)return"HIGH";if(X)return"MEDIUM";return"LOW"}function QQ($){let Z=$.find((Y)=>Y.type==="file-category"),Q={code:0,tests:0,docs:0,config:0,infra:0,ci:0,deps:0,db:0,other:0};if(!Z)return Q;let{categories:X}=Z;return Q.code=X.product.length,Q.tests=X.tests.length,Q.docs=X.docs.length,Q.config=X.config.length,Q.infra=X.infra.length,Q.ci=X.ci.length,Q.deps=X.dependencies.length,Q.db=X.database?.length??0,Q.other=X.other.length+(X.artifacts?.length??0),Q}function XQ($){let Z=[],Q=$.filter((j)=>j.type==="impact-analysis"),X=Q.filter((j)=>j.blastRadius==="high");for(let j of X){let g=j.affectedFiles.slice(0,V1),c=Math.max(0,j.affectedFiles.length-V1);Z.push({description:`High blast radius: ${j.sourceFile} (${j.affectedFiles.length} dependents)`,examples:g,moreCount:c})}let Y=Q.filter((j)=>j.blastRadius==="medium");for(let j of Y){let g=j.affectedFiles.slice(0,V1),c=Math.max(0,j.affectedFiles.length-V1);Z.push({description:`Medium blast radius: ${j.sourceFile} (${j.affectedFiles.length} dependents)`,examples:g,moreCount:c})}let q=$.filter((j)=>j.type==="db-migration").filter((j)=>j.risk==="high");if(q.length>0){let j=q.flatMap((p)=>p.files),g=j.slice(0,V1),c=Math.max(0,j.length-V1);Z.push({description:`High-risk database migrations (${j.length} files)`,examples:g,moreCount:c})}let V=$.filter((j)=>j.type==="sql-risk").filter((j)=>j.riskType==="destructive");if(V.length>0){let j=V.map((p)=>p.file),g=j.slice(0,V1),c=Math.max(0,j.length-V1);Z.push({description:`Destructive SQL detected (${j.length} files)`,examples:g,moreCount:c})}let J=$.filter((j)=>j.type==="ci-workflow").filter((j)=>j.riskType==="permissions_broadened"||j.riskType==="pull_request_target");if(J.length>0){let j=J.map((p)=>p.file),g=j.slice(0,V1),c=Math.max(0,j.length-V1);Z.push({description:`CI workflow security changes (${j.length} files)`,examples:g,moreCount:c})}let G=[],H=$.filter((j)=>j.type==="typescript-config").filter((j)=>j.isBreaking);if(H.length>0)G.push({type:"TypeScript",files:H.map((j)=>j.file)});let O=$.filter((j)=>j.type==="tailwind-config").filter((j)=>j.isBreaking);if(O.length>0)G.push({type:"Tailwind",files:O.map((j)=>j.file)});let z=$.filter((j)=>j.type==="graphql-change").filter((j)=>j.isBreaking);if(z.length>0)G.push({type:"GraphQL",files:z.map((j)=>j.file)});if($.filter((j)=>j.type==="package-exports").filter((j)=>j.isBreaking).length>0)G.push({type:"Package exports",files:["package.json"]});for(let j of G){let g=j.files.slice(0,V1),c=Math.max(0,j.files.length-V1);Z.push({description:`Breaking ${j.type} config change`,examples:g,moreCount:c})}let E=$.find((j)=>j.type==="lockfile-mismatch");if(E){if(E.manifestChanged&&!E.lockfileChanged)Z.push({description:"Lockfile mismatch: package.json changed but lockfile not updated",examples:["package.json"],moreCount:0});else if(!E.manifestChanged&&E.lockfileChanged)Z.push({description:"Lockfile mismatch: lockfile changed but package.json not updated",examples:[],moreCount:0})}let w=$.filter((j)=>j.type==="security-file");if(w.length>0){let j=w.flatMap((p)=>p.files),g=j.slice(0,V1),c=Math.max(0,j.length-V1);Z.push({description:`Security-sensitive files changed (${j.length} files)`,examples:g,moreCount:c})}let P=$.filter((j)=>j.type==="dependency-change").filter((j)=>j.impact==="major");if(P.length>0){let j=P.map((p)=>p.name),g=j.slice(0,V1),c=Math.max(0,j.length-V1);Z.push({description:`Major dependency updates (${j.length} packages)`,examples:g,moreCount:c})}let I=$.filter((j)=>j.type==="route-change");if(I.length>0){let j=I.map((p)=>m1(p.routeId)),g=j.slice(0,V1),c=Math.max(0,j.length-V1);Z.push({description:`Route changes (${j.length} routes)`,examples:g,moreCount:c})}let f=$.filter((j)=>j.type==="test-change");if(f.length>0){let j=f.flatMap((D)=>D.files),g=f.reduce((D,k)=>D+k.added.length,0),c=f.reduce((D,k)=>D+k.modified.length,0),p=[];if(g>0)p.push(`${g} added`);if(c>0)p.push(`${c} modified`);let s1=j.slice(0,V1),Q1=Math.max(0,j.length-V1);Z.push({description:`Test files changed (${p.join(", ")||j.length+" files"})`,examples:s1,moreCount:Q1})}return Z.slice(0,t7)}function YQ($){let Z=$.find((X)=>X.type==="file-category");if(!Z)return[];let Q=Z.categories.product;if(Q.length>e7)return[];return Q}function KQ($){let Z=$.find((X)=>X.type==="file-category");if(!Z)return[];return Z.categories.docs.filter((X)=>X.startsWith(".changeset/"))}function V0($){let Z=KQ($);return{diffstat:$Q($),reviewAttention:ZQ($),findingsByCategory:QQ($),topFindings:XQ($),primaryFiles:YQ($),hasChangesets:Z.length>0,changesetFiles:Z}}function J0($){let Z=[];if($.added>0)Z.push(`${$.added} added`);if($.modified>0)Z.push(`${$.modified} modified`);if($.deleted>0)Z.push(`${$.deleted} deleted`);if($.renamed>0)Z.push(`${$.renamed} renamed`);if(Z.length===0)return"0 changed";return`${$.total} changed (${Z.join(", ")})`}function U9($){let Z=[];if($.code>0)Z.push(`code=${$.code}`);if($.tests>0)Z.push(`tests=${$.tests}`);if($.docs>0)Z.push(`docs=${$.docs}`);if($.config>0)Z.push(`config=${$.config}`);if($.infra>0)Z.push(`infra=${$.infra}`);if($.ci>0)Z.push(`ci=${$.ci}`);if($.deps>0)Z.push(`deps=${$.deps}`);if($.db>0)Z.push(`db=${$.db}`);if($.other>0)Z.push(`other=${$.other}`);if(Z.length===0)return"none";return Z.join(", ")}function V9($){return`${$.level.toUpperCase()} (${$.score}/100)`}function WQ($){let Z=new Map;for(let Q of $){if(!Z.has(Q.type))Z.set(Q.type,[]);Z.get(Q.type).push(Q)}return Z}function qQ($){if(!$.interactive?.context)return"";return`## Context
294
298
 
295
299
  ${$.interactive.context}
296
300
 
297
- `}function W7($){let Z=[],Q=$.get("file-summary")?.[0];if(Q){let G=Q.added.length+Q.modified.length+Q.deleted.length+Q.renamed.length;if(Z.push(`${G} file(s) changed`),Q.added.length>0)Z.push(`${Q.added.length} file(s) added`);if(Q.deleted.length>0)Z.push(`${Q.deleted.length} file(s) deleted`)}let X=$.get("route-change");if(X&&X.length>0){let G=X.filter((M)=>M.change==="added");if(G.length>0)Z.push(`${G.length} new route(s)`)}let K=$.get("db-migration");if(K&&K.length>0)Z.push("Database migrations detected");let Y=$.get("dependency-change");if(Y&&Y.length>0){let G=Y.filter((M)=>M.impact==="major");if(G.length>0)Z.push(`${G.length} major dependency update(s)`)}let W=$.get("security-file");if(W&&W.length>0){let G=W.reduce((M,H)=>M+H.files.length,0);Z.push(`${G} security-sensitive file(s) changed`)}let q=$.get("graphql-change");if(q&&q.length>0){let G=q.filter((M)=>M.isBreaking).length;if(G>0)Z.push(`${G} GraphQL breaking change(s)`)}let V=$.get("ci-workflow");if(V&&V.length>0)Z.push(`${V.length} CI workflow change(s) detected`);let U=$.get("stencil-component-change");if(U&&U.length>0)Z.push(`${U.length} component API change(s)`);let J=$.get("package-exports");if(J&&J.length>0){if(J.filter((M)=>M.isBreaking).length>0)Z.push("Package API breaking changes detected")}if(Z.length===0)Z.push("Minor changes detected");return`## Summary
301
+ `}function UQ($,Z){let{diffstat:Q,reviewAttention:X,topFindings:Y,hasChangesets:K}=Z,q=[];if(q.push(`Files: ${J0(Q)}`),X==="HIGH"||X==="MEDIUM")q.push(`Review attention: ${X} (blast radius)`);for(let W of Y.slice(0,3))q.push(W.description);if(K)q.push("Changeset added");return`## Summary
298
302
 
299
- `+Z.slice(0,6).map((G)=>`- ${G}`).join(`
300
- `)+`
303
+ ${q.map((W)=>`- ${W}`).join(`
304
+ `)}
305
+
306
+ `}function VQ($){if($.length===0)return"";let Z=`## Top findings
307
+
308
+ `,Q=1;for(let X of $){if(Z+=`${Q}) ${X.description}`,X.examples.length>0){let Y=X.examples.map((q)=>`\`${q}\``).join(", "),K=X.moreCount>0?` (+${X.moreCount} more)`:"";Z+=`
309
+ ${Y}${K}`}Z+=`
310
+
311
+ `,Q++}return Z}function JQ($,Z,Q){if(!$||!Z)return"";let{categories:X,summary:Y}=$,{primaryFiles:K,changesetFiles:q}=Q;if(Y.reduce((J,G)=>J+G.count,0)===0)return"";let V=`## What changed
301
312
 
302
- `}function U7($,Z){if(!$||!Z)return"";let{categories:Q,summary:X}=$;if(X.length<=1)return"";let K=`## What Changed
313
+ `;if(K.length>0){V+=`### Primary files
303
314
 
304
- `,Y=X.filter((W)=>W.count>0).sort((W,q)=>q.count-W.count);for(let{category:W,count:q}of Y){let V=o$(W),U=Q[W];K+=`### ${V} (${q})
315
+ `;for(let J of K){let G=Z.added.includes(J)?" (new)":Z.modified.includes(J)?" (modified)":"";V+=`- \`${J}\`${G}
316
+ `}V+=`
317
+ `}let U=Y.filter((J)=>J.count>0).sort((J,G)=>G.count-J.count);for(let{category:J}of U){let G=X[J],B=I5(J);if(J==="docs"){let _=G.filter((O)=>!O.startsWith(".changeset/"));if(_.length===0&&q.length>0)continue;if(G=_,G.length===0)continue}V+=`### ${B} (${G.length})
305
318
 
306
- `;let J=U.slice(0,10);for(let B of J){let G="";if(Z.added.includes(B))G=" *(new)*";else if(Z.deleted.includes(B))G=" *(deleted)*";K+=`- \`${B}\`${G}
307
- `}if(U.length>10)K+=`- *...and ${U.length-10} more*
308
- `;K+=`
309
- `}return K}function V7($){if($.length===0)return"";let Z=`## Routes / API
319
+ `;let H=G.slice(0,10);for(let _ of H){let O="";if(Z.added.includes(_))O=" *(new)*";else if(Z.deleted.includes(_))O=" *(deleted)*";V+=`- \`${_}\`${O}
320
+ `}if(G.length>10)V+=`- *...and ${G.length-10} more*
321
+ `;V+=`
322
+ `}if(q.length>0){V+=`### Changesets (${q.length})
323
+
324
+ `;for(let J of q){let G=Z.added.includes(J)?" *(new)*":"";V+=`- \`${J}\`${G}
325
+ `}V+=`
326
+ `}return V}function GQ($,Z){let Q=[],X=Z.get("test-change");if(X&&X.length>0){let U=X.flatMap((J)=>J.files);if(U.length===1)Q.push({cmd:`bun test ${U[0]}`,rationale:"targeted"});else Q.push({cmd:"bun test",rationale:`${U.length} test files changed`})}let K={sveltekit:[{cmd:"bun run check",rationale:"SvelteKit profile"}],next:[{cmd:"bun run build",rationale:"Next.js profile"}],vue:[{cmd:"bun run build",rationale:"Vue profile"}],astro:[{cmd:"bun run build",rationale:"Astro profile"}],stencil:[{cmd:"bun run build",rationale:"Stencil profile"}],angular:[{cmd:"ng build",rationale:"Angular profile"}],library:[{cmd:"bun run build",rationale:"library profile"}],python:[{cmd:"pytest",rationale:"Python profile"}],vite:[{cmd:"bun run build",rationale:"Vite profile"}]}[$.profile]??[];for(let{cmd:U,rationale:J}of K)Q.push({cmd:U,rationale:J});let q=Z.get("route-change");if(q){let U=q.filter((G)=>G.routeType==="endpoint");for(let G of U.slice(0,3)){let B=m1(G.routeId),H=G.methods?.join("/")||"GET";Q.push({cmd:`Test \`${H} ${B}\` endpoint`,rationale:"route changed"})}let J=q.filter((G)=>G.routeType==="page"&&G.change!=="deleted");for(let G of J.slice(0,3)){let B=m1(G.routeId);Q.push({cmd:`Verify \`${B}\` page renders correctly`,rationale:"page changed"})}}let W=Z.get("test-gap");if(W&&W.length>0){let U=W.reduce((J,G)=>J+G.prodFilesChanged,0);Q.push({cmd:`Add tests for ${U} modified file(s) lacking coverage`,rationale:"test gap"})}if($.interactive?.testNotes)Q.push({cmd:$.interactive.testNotes,rationale:"user note"});if(Q.length===0)return"";let V=`## Suggested test plan
327
+
328
+ `;for(let{cmd:U,rationale:J}of Q)V+=`- [ ] \`${U}\` (${J})
329
+ `;return V+=`
330
+ `,V}function BQ($){let{riskScore:Z}=$,Q=`## Notes
331
+
332
+ `;Q+=`- Risk: ${V9(Z)}
333
+ `;let X=Z.evidenceBullets??[];if(X.length===0&&Z.level==="low")Q+=`- No elevated risks detected.
334
+ `;else for(let Y of X){let K=Y.replace(/^[⚠️⚡ℹ️✅]\s*/,"").replace(/^[\u2600-\u27FF]\s*/,"");Q+=`- ${K}
335
+ `}return Q+=`
336
+ `,Q}function OQ($){if($.length===0)return"";let Z=`### Routes / API
310
337
 
311
338
  `;Z+=`| Route | Type | Change | Methods |
312
339
  `,Z+=`|-------|------|--------|--------|
313
- `;for(let Q of $){let X=c1(Q.routeId),K=Q.methods?.join(", ")||"-";Z+=`| \`${X}\` | ${Q.routeType} | ${Q.change} | ${K} |
340
+ `;for(let Q of $){let X=m1(Q.routeId),Y=Q.methods?.join(", ")||"-";Z+=`| \`${X}\` | ${Q.routeType} | ${Q.change} | ${Y} |
314
341
  `}return Z+`
315
- `}function J7($){if($.length===0)return"";let Z=`## API Contracts
342
+ `}function HQ($){if($.length===0)return"";let Z=`### API Contracts
316
343
 
317
344
  `;Z+=`The following API specification files have changed:
318
345
 
319
346
  `;for(let Q of $)for(let X of Q.files)Z+=`- \`${X}\`
320
347
  `;return Z+=`
321
- `,Z}function B7($){if($.length===0)return"";let Z=`## Database (Supabase)
348
+ `,Z}function _Q($){if($.length===0)return"";let Z=`### Database (Supabase)
322
349
 
323
- `;for(let Q of $){let X=Q.risk==="high"?"\uD83D\uDD34":Q.risk==="medium"?"\uD83D\uDFE1":"\uD83D\uDFE2";Z+=`**Risk Level:** ${X} ${Q.risk.toUpperCase()}
350
+ `;for(let Q of $){Z+=`**Risk Level:** ${Q.risk.toUpperCase()}
324
351
 
325
352
  `,Z+=`**Files:**
326
- `;for(let K of Q.files)Z+=`- \`${K}\`
353
+ `;for(let X of Q.files)Z+=`- \`${X}\`
327
354
  `;if(Z+=`
328
355
  `,Q.reasons.length>0){Z+=`**Detected patterns:**
329
- `;for(let K of Q.reasons)Z+=`- ${K}
356
+ `;for(let X of Q.reasons)Z+=`- ${X}
330
357
  `;Z+=`
331
- `}}return Z}function G7($){if($.length===0)return"";let Z=`## Config / Env
358
+ `}}return Z}function MQ($){if($.length===0)return"";let Z=`### Config / Env
332
359
 
333
360
  `;Z+=`| Variable | Status | Evidence |
334
361
  `,Z+=`|----------|--------|----------|
335
362
  `;for(let Q of $){let X=Q.evidenceFiles.slice(0,2).join(", ");Z+=`| \`${Q.name}\` | ${Q.change} | ${X} |
336
363
  `}return Z+`
337
- `}function O7($){if($.length===0)return"";let Z=`## Cloudflare
364
+ `}function zQ($){if($.length===0)return"";let Z=`### Cloudflare
338
365
 
339
366
  `;for(let Q of $){Z+=`**Area:** ${Q.area}
340
367
  `,Z+=`**Files:**
341
368
  `;for(let X of Q.files)Z+=`- \`${X}\`
342
369
  `;Z+=`
343
- `}return Z}function M7($){if($.length===0)return"";let Z=$.filter((K)=>K.section==="dependencies"),Q=$.filter((K)=>K.section==="devDependencies"),X=`## Dependencies
370
+ `}return Z}function jQ($){if($.length===0)return"";let Z=$.filter((Y)=>Y.section==="dependencies"),Q=$.filter((Y)=>Y.section==="devDependencies"),X=`### Dependencies
344
371
 
345
- `;if(Z.length>0){X+=`### Production
372
+ `;if(Z.length>0){X+=`**Production**
346
373
 
347
374
  `,X+=`| Package | From | To | Impact |
348
375
  `,X+=`|---------|------|-----|--------|
349
- `;for(let K of Z)X+=`| \`${K.name}\` | ${K.from??"-"} | ${K.to??"-"} | ${K.impact??"-"} |
376
+ `;for(let Y of Z)X+=`| \`${Y.name}\` | ${Y.from??"-"} | ${Y.to??"-"} | ${Y.impact??"-"} |
350
377
  `;X+=`
351
- `}if(Q.length>0){X+=`### Dev Dependencies
378
+ `}if(Q.length>0){X+=`**Dev Dependencies**
352
379
 
353
380
  `,X+=`| Package | From | To | Impact |
354
381
  `,X+=`|---------|------|-----|--------|
355
- `;for(let K of Q)X+=`| \`${K.name}\` | ${K.from??"-"} | ${K.to??"-"} | ${K.impact??"-"} |
382
+ `;for(let Y of Q)X+=`| \`${Y.name}\` | ${Y.from??"-"} | ${Y.to??"-"} | ${Y.impact??"-"} |
356
383
  `;X+=`
357
- `}return X}function H7($){if($.length===0)return"";let Z=`## GraphQL Schema
384
+ `}return X}function LQ($){if($.length===0)return"";let Z=`### Security-Sensitive Files
358
385
 
359
- `,Q=$.filter((K)=>K.isBreaking);if(Q.length>0){Z+=`### \uD83D\uDD34 Breaking Changes
386
+ `;Z+=`The following files touch authentication, authorization, or security-critical code:
360
387
 
361
- `;for(let K of Q){if(Z+=`**File:** \`${K.file}\`
362
- `,K.breakingChanges.length>0)for(let Y of K.breakingChanges)Z+=`- ${Y}
388
+ `;let Q=new Map;for(let Y of $)for(let K of Y.files){if(!Q.has(K))Q.set(K,[]);for(let q of Y.reasons)if(!Q.get(K).includes(q))Q.get(K).push(q)}let X=[...Q.entries()].sort((Y,K)=>Y[0].localeCompare(K[0]));for(let[Y,K]of X.slice(0,10)){let q=K.map((W)=>Z2(W)).join(", ");Z+=`- \`${Y}\` *(${q})*
389
+ `}if(X.length>10)Z+=`- ...and ${X.length-10} more
390
+ `;return Z+=`
391
+ `,Z}function DQ($){if($.length===0)return"";let Z=`### GraphQL Schema
392
+
393
+ `,Q=$.filter((Y)=>Y.isBreaking);if(Q.length>0){Z+=`**Breaking Changes**
394
+
395
+ `;for(let Y of Q){if(Z+=`**File:** \`${Y.file}\`
396
+ `,Y.breakingChanges.length>0)for(let K of Y.breakingChanges)Z+=`- ${K}
363
397
  `;Z+=`
364
- `}}let X=$.filter((K)=>K.addedElements.length>0);if(X.length>0){Z+=`### Added Elements
398
+ `}}let X=$.filter((Y)=>Y.addedElements.length>0);if(X.length>0){Z+=`**Added Elements**
365
399
 
366
- `;for(let K of X){Z+=`**File:** \`${K.file}\`
367
- `;for(let Y of K.addedElements.slice(0,10))Z+=`- ${Y}
368
- `;if(K.addedElements.length>10)Z+=`- ...and ${K.addedElements.length-10} more
400
+ `;for(let Y of X){Z+=`**File:** \`${Y.file}\`
401
+ `;for(let K of Y.addedElements.slice(0,10))Z+=`- ${K}
402
+ `;if(Y.addedElements.length>10)Z+=`- ...and ${Y.addedElements.length-10} more
369
403
  `;Z+=`
370
- `}}Z+=`### All Schema Changes
404
+ `}}Z+=`**All Schema Changes**
371
405
 
372
406
  `,Z+=`| File | Status | Breaking |
373
407
  `,Z+=`|------|--------|----------|
374
- `;for(let K of $){let Y=K.isBreaking?"\uD83D\uDD34 Yes":"\uD83D\uDFE2 No";Z+=`| \`${K.file}\` | ${K.status} | ${Y} |
408
+ `;for(let Y of $){let K=Y.isBreaking?"Yes":"No";Z+=`| \`${Y.file}\` | ${Y.status} | ${K} |
375
409
  `}return Z+=`
376
- `,Z}function _7($){if($.length===0)return"";let Z=`### TypeScript Configuration
410
+ `,Z}function NQ($){if($.length===0)return"";let Z=`**TypeScript Configuration**
377
411
 
378
- `;for(let Q of $){let X=Q.isBreaking?"\uD83D\uDD34":"\uD83D\uDFE2";if(Z+=`**File:** \`${Q.file}\` ${X}
412
+ `;for(let Q of $){let X=Q.isBreaking?"(BREAKING)":"";if(Z+=`**File:** \`${Q.file}\` ${X}
379
413
 
380
- `,Q.strictnessChanges.length>0){Z+=`**Strictness Changes:**
381
- `;for(let q of Q.strictnessChanges)Z+=`- ${q}
414
+ `,Q.strictnessChanges.length>0){Z+=`Strictness Changes:
415
+ `;for(let W of Q.strictnessChanges)Z+=`- ${W}
382
416
  `;Z+=`
383
- `}let{added:K,removed:Y,modified:W}=Q.changedOptions;if(K.length>0)Z+=`**Added:** ${K.map((q)=>`\`${q}\``).join(", ")}
384
- `;if(Y.length>0)Z+=`**Removed:** ${Y.map((q)=>`\`${q}\``).join(", ")}
385
- `;if(W.length>0)Z+=`**Modified:** ${W.map((q)=>`\`${q}\``).join(", ")}
417
+ `}let{added:Y,removed:K,modified:q}=Q.changedOptions;if(Y.length>0)Z+=`**Added:** ${Y.map((W)=>`\`${W}\``).join(", ")}
418
+ `;if(K.length>0)Z+=`**Removed:** ${K.map((W)=>`\`${W}\``).join(", ")}
419
+ `;if(q.length>0)Z+=`**Modified:** ${q.map((W)=>`\`${W}\``).join(", ")}
386
420
  `;Z+=`
387
- `}return Z}function z7($){if($.length===0)return"";let Z=`### Tailwind Configuration
421
+ `}return Z}function AQ($){if($.length===0)return"";let Z=`**Tailwind Configuration**
388
422
 
389
- `;for(let Q of $){let X=Q.isBreaking?"\uD83D\uDD34":"\uD83D\uDFE2";if(Z+=`**File:** \`${Q.file}\` (${Q.configType}) ${X}
423
+ `;for(let Q of $){let X=Q.isBreaking?"(BREAKING)":"";if(Z+=`**File:** \`${Q.file}\` (${Q.configType}) ${X}
390
424
 
391
- `,Q.affectedSections.length>0){Z+=`**Affected Sections:**
392
- `;for(let K of Q.affectedSections)Z+=`- ${K}
425
+ `,Q.affectedSections.length>0){Z+=`Affected Sections:
426
+ `;for(let Y of Q.affectedSections)Z+=`- ${Y}
393
427
  `;Z+=`
394
- `}if(Q.isBreaking&&Q.breakingReasons.length>0){Z+=`**Breaking Changes:**
395
- `;for(let K of Q.breakingReasons)Z+=`- ${K}
428
+ `}if(Q.isBreaking&&Q.breakingReasons.length>0){Z+=`Breaking Changes:
429
+ `;for(let Y of Q.breakingReasons)Z+=`- ${Y}
396
430
  `;Z+=`
397
- `}}return Z}function L7($){if($.length===0)return"";let Z=`### Monorepo Configuration
431
+ `}}return Z}function RQ($){if($.length===0)return"";let Z=`**Monorepo Configuration**
398
432
 
399
433
  `;for(let Q of $){if(Z+=`**Tool:** ${Q.tool}
400
434
  `,Z+=`**File:** \`${Q.file}\`
401
435
 
402
- `,Q.affectedFields.length>0){Z+=`**Changed Fields:**
436
+ `,Q.affectedFields.length>0){Z+=`Changed Fields:
403
437
  `;for(let X of Q.affectedFields)Z+=`- ${X}
404
438
  `;Z+=`
405
- `}if(Q.impacts.length>0){Z+=`**Impacts:**
439
+ `}if(Q.impacts.length>0){Z+=`Impacts:
406
440
  `;for(let X of Q.impacts)Z+=`- ${X}
407
441
  `;Z+=`
408
- `}}return Z}function j7($,Z,Q){let X=$.length>0,K=Z.length>0,Y=Q.length>0;if(!X&&!K&&!Y)return"";let W=`## Configuration Changes
442
+ `}}return Z}function TQ($){if($.length===0)return"";let Z=`**Vite Configuration**
443
+
444
+ `;for(let Q of $){let X=Q.isBreaking?"(BREAKING)":"";if(Z+=`**File:** \`${Q.file}\` ${X}
445
+
446
+ `,Q.pluginsDetected.length>0)Z+=`**Plugins:** ${Q.pluginsDetected.map((Y)=>`\`${Y}\``).join(", ")}
447
+ `;if(Q.affectedSections.length>0){Z+=`Affected Sections:
448
+ `;for(let Y of Q.affectedSections.slice(0,5))Z+=`- ${Y}
449
+ `;if(Q.affectedSections.length>5)Z+=`- ...and ${Q.affectedSections.length-5} more
450
+ `;Z+=`
451
+ `}if(Q.isBreaking&&Q.breakingReasons.length>0){Z+=`Breaking Changes:
452
+ `;for(let Y of Q.breakingReasons)Z+=`- ${Y}
453
+ `;Z+=`
454
+ `}}return Z}function wQ($,Z,Q,X){let Y=$.length>0,K=Z.length>0,q=Q.length>0,W=X.length>0;if(!Y&&!K&&!q&&!W)return"";let V=`### Configuration Changes
409
455
 
410
- `;if(X)W+=_7($);if(K)W+=z7(Z);if(Y)W+=L7(Q);return W}function D7($){if($.length===0)return"";let Z=`## Package API
456
+ `;if(Y)V+=NQ($);if(K)V+=AQ(Z);if(W)V+=TQ(X);if(q)V+=RQ(Q);return V}function xQ($){if($.length===0)return"";let Z=`### Package API
411
457
 
412
- `;for(let Q of $){let X=Q.isBreaking?"\uD83D\uDD34 Breaking":"\uD83D\uDFE2 Non-breaking";if(Z+=`**Status:** ${X}
458
+ `;for(let Q of $){let X=Q.isBreaking?"Breaking":"Non-breaking";if(Z+=`**Status:** ${X}
413
459
 
414
- `,Q.removedExports.length>0){Z+=`### Removed Exports
460
+ `,Q.removedExports.length>0){Z+=`**Removed Exports**
415
461
 
416
- `;for(let K of Q.removedExports)Z+=`- \uD83D\uDD34 \`${K}\`
462
+ `;for(let Y of Q.removedExports)Z+=`- \`${Y}\`
417
463
  `;Z+=`
418
- `}if(Q.addedExports.length>0){Z+=`### Added Exports
464
+ `}if(Q.addedExports.length>0){Z+=`**Added Exports**
419
465
 
420
- `;for(let K of Q.addedExports)Z+=`- \uD83D\uDFE2 \`${K}\`
466
+ `;for(let Y of Q.addedExports)Z+=`- \`${Y}\`
421
467
  `;Z+=`
422
- `}if(Q.legacyFieldChanges.length>0){Z+=`### Entry Point Changes
468
+ `}if(Q.legacyFieldChanges.length>0){Z+=`**Entry Point Changes**
423
469
 
424
470
  `,Z+=`| Field | From | To |
425
471
  `,Z+=`|-------|------|----|
426
- `;for(let K of Q.legacyFieldChanges)Z+=`| \`${K.field}\` | ${K.from??"-"} | ${K.to??"-"} |
472
+ `;for(let Y of Q.legacyFieldChanges)Z+=`| \`${Y.field}\` | ${Y.from??"-"} | ${Y.to??"-"} |
427
473
  `;Z+=`
428
- `}if(Q.binChanges.added.length>0||Q.binChanges.removed.length>0){if(Z+=`### Binary Commands
474
+ `}if(Q.binChanges.added.length>0||Q.binChanges.removed.length>0){if(Z+=`**Binary Commands**
429
475
 
430
- `,Q.binChanges.added.length>0)Z+=`**Added:** ${Q.binChanges.added.map((K)=>`\`${K}\``).join(", ")}
431
- `;if(Q.binChanges.removed.length>0)Z+=`**Removed:** ${Q.binChanges.removed.map((K)=>`\`${K}\``).join(", ")}
476
+ `,Q.binChanges.added.length>0)Z+=`**Added:** ${Q.binChanges.added.map((Y)=>`\`${Y}\``).join(", ")}
477
+ `;if(Q.binChanges.removed.length>0)Z+=`**Removed:** ${Q.binChanges.removed.map((Y)=>`\`${Y}\``).join(", ")}
432
478
  `;Z+=`
433
- `}}return Z}function A7($){let Z=$.get("stencil-component-change")??[],Q=$.get("stencil-prop-change")??[],X=$.get("stencil-event-change")??[],K=$.get("stencil-method-change")??[],Y=$.get("stencil-slot-change")??[];if(!(Z.length>0||Q.length>0||X.length>0||K.length>0||Y.length>0))return"";let q=`## Component API (Stencil)
434
-
435
- `,V=new Map,U=(J)=>{if(!V.has(J))V.set(J,{props:[],events:[],methods:[],slots:[]})};for(let J of Z)U(J.tag),V.get(J.tag).component=J;for(let J of Q)U(J.tag),V.get(J.tag).props.push(J);for(let J of X)U(J.tag),V.get(J.tag).events.push(J);for(let J of K)U(J.tag),V.get(J.tag).methods.push(J);for(let J of Y)U(J.tag),V.get(J.tag).slots.push(J);for(let[J,B]of V){if(q+=`### \`<${J}>\`
436
-
437
- `,B.component){let G=B.component,M=G.change==="removed"?"\uD83D\uDD34":G.change==="added"?"\uD83D\uDFE2":"\uD83D\uDFE1";if(q+=`**Component:** ${M} ${G.change}`,G.change==="tag-changed")q+=` (${G.fromTag} → ${G.toTag})`;if(G.change==="shadow-changed")q+=` (shadow: ${G.fromShadow} → ${G.toShadow})`;q+=`
438
- `,q+=`**File:** \`${G.file}\`
439
-
440
- `}if(B.props.length>0){q+=`**Props:**
441
- `;for(let G of B.props){let M=G.change==="removed"?"\uD83D\uDD34":G.change==="added"?"\uD83D\uDFE2":"\uD83D\uDFE1",H="";if(G.details?.typeText)H=`: ${G.details.typeText}`;q+=`- ${M} \`${G.propName}\`${H} (${G.change})
442
- `}q+=`
443
- `}if(B.events.length>0){q+=`**Events:**
444
- `;for(let G of B.events){let M=G.change==="removed"?"\uD83D\uDD34":G.change==="added"?"\uD83D\uDFE2":"\uD83D\uDFE1";q+=`- ${M} \`${G.eventName}\` (${G.change})
445
- `}q+=`
446
- `}if(B.methods.length>0){q+=`**Methods:**
447
- `;for(let G of B.methods){let M=G.change==="removed"?"\uD83D\uDD34":G.change==="added"?"\uD83D\uDFE2":"\uD83D\uDFE1",H=G.signature?`: ${G.signature}`:"";q+=`- ${M} \`${G.methodName}\`${H} (${G.change})
448
- `}q+=`
449
- `}if(B.slots.length>0){q+=`**Slots:**
450
- `;for(let G of B.slots){let M=G.change==="removed"?"\uD83D\uDD34":"\uD83D\uDFE2",H=G.slotName==="default"?"(default)":`"${G.slotName}"`;q+=`- ${M} ${H} (${G.change})
451
- `}q+=`
452
- `}}return q}function N7($){if($.length===0)return"";let Z=`### CI Workflows
453
-
454
- `;for(let Q of $){let X=Q.riskType==="permissions_broadened"||Q.riskType==="pull_request_target"||Q.riskType==="remote_script_download"?"\uD83D\uDD34":"\uD83D\uDFE1",K=Q.riskType.replace(/_/g," ");Z+=`${X} **${K}**
479
+ `}}return Z}function EQ($){let Z=$.get("stencil-component-change")??[],Q=$.get("stencil-prop-change")??[],X=$.get("stencil-event-change")??[],Y=$.get("stencil-method-change")??[],K=$.get("stencil-slot-change")??[];if(!(Z.length>0||Q.length>0||X.length>0||Y.length>0||K.length>0))return"";let W=`### Component API (Stencil)
480
+
481
+ `,V=new Map,U=(J)=>{if(!V.has(J))V.set(J,{props:[],events:[],methods:[],slots:[]})};for(let J of Z)U(J.tag),V.get(J.tag).component=J;for(let J of Q)U(J.tag),V.get(J.tag).props.push(J);for(let J of X)U(J.tag),V.get(J.tag).events.push(J);for(let J of Y)U(J.tag),V.get(J.tag).methods.push(J);for(let J of K)U(J.tag),V.get(J.tag).slots.push(J);for(let[J,G]of V){if(W+=`**\`<${J}>\`**
482
+
483
+ `,G.component){let B=G.component;if(W+=`**Component:** ${B.change}`,B.change==="tag-changed")W+=` (${B.fromTag} → ${B.toTag})`;if(B.change==="shadow-changed")W+=` (shadow: ${B.fromShadow} → ${B.toShadow})`;W+=`
484
+ `,W+=`**File:** \`${B.file}\`
485
+
486
+ `}if(G.props.length>0){W+=`**Props:**
487
+ `;for(let B of G.props){let H="";if(B.details?.typeText)H=`: ${B.details.typeText}`;W+=`- \`${B.propName}\`${H} (${B.change})
488
+ `}W+=`
489
+ `}if(G.events.length>0){W+=`**Events:**
490
+ `;for(let B of G.events)W+=`- \`${B.eventName}\` (${B.change})
491
+ `;W+=`
492
+ `}if(G.methods.length>0){W+=`**Methods:**
493
+ `;for(let B of G.methods){let H=B.signature?`: ${B.signature}`:"";W+=`- \`${B.methodName}\`${H} (${B.change})
494
+ `}W+=`
495
+ `}if(G.slots.length>0){W+=`**Slots:**
496
+ `;for(let B of G.slots){let H=B.slotName==="default"?"(default)":`"${B.slotName}"`;W+=`- ${H} (${B.change})
497
+ `}W+=`
498
+ `}}return W}function IQ($){let Z=$.get("angular-component-change")??[];if(Z.length===0)return"";let Q=`### Angular Components
499
+
500
+ `,X=new Map;for(let Y of Z){let K=Y.componentType;if(!X.has(K))X.set(K,[]);X.get(K).push(Y)}for(let[Y,K]of X){let q=Y.charAt(0).toUpperCase()+Y.slice(1)+"s";Q+=`**${q}**
501
+
502
+ `,Q+=`| File | Change | Selector | Standalone |
503
+ `,Q+=`|------|--------|----------|------------|
504
+ `;for(let W of K){let V=W.selector||"-",U=W.standalone!==void 0?W.standalone?"Yes":"No":"-";Q+=`| \`${W.file}\` | ${W.change} | \`${V}\` | ${U} |
505
+ `}Q+=`
506
+ `}return Q}function bQ($){if($.length===0)return"";let Z=`### CI Workflows
507
+
508
+ `;for(let Q of $){let X=Q.riskType.replace(/_/g," ");Z+=`**${X}**
455
509
  `,Z+=`- File: \`${Q.file}\`
456
510
  `,Z+=`- ${Q.details}
457
511
 
458
- `}return Z}function R7($){if($.length===0)return"";let Z=`## SQL Risk
512
+ `}return Z}function PQ($){if($.length===0)return"";let Z=`### SQL Risk
459
513
 
460
- `;for(let Q of $){let X=Q.riskType==="destructive"?"\uD83D\uDD34":Q.riskType==="unscoped_modification"?"\uD83D\uDD34":"\uD83D\uDFE1",K=Q.riskType.replace(/_/g," ");Z+=`${X} **${K}**
514
+ `;for(let Q of $){let X=Q.riskType.replace(/_/g," ");Z+=`**${X}**
461
515
  `,Z+=`- File: \`${Q.file}\`
462
516
  `,Z+=`- ${Q.details}
463
517
 
464
- `}return Z}function T7($){if($.length===0)return"";let Z=`### Infrastructure
518
+ `}return Z}function kQ($){if($.length===0)return"";let Z=`### Infrastructure
465
519
 
466
- `,Q=new Map;for(let X of $){if(!Q.has(X.infraType))Q.set(X.infraType,[]);Q.get(X.infraType).push(X)}for(let[X,K]of Q){Z+=`**${X==="dockerfile"?"Docker":X==="terraform"?"Terraform":X==="k8s"?"Kubernetes":X}:**
467
- `;let W=K.flatMap((q)=>q.files);for(let q of W)Z+=`- \`${q}\`
520
+ `,Q=new Map;for(let X of $){if(!Q.has(X.infraType))Q.set(X.infraType,[]);Q.get(X.infraType).push(X)}for(let[X,Y]of Q){Z+=`**${X==="dockerfile"?"Docker":X==="terraform"?"Terraform":X==="k8s"?"Kubernetes":X}:**
521
+ `;let q=Y.flatMap((W)=>W.files);for(let W of q)Z+=`- \`${W}\`
468
522
  `;Z+=`
469
- `}return Z}function x7($,Z){if($.length===0&&Z.length===0)return"";let Q=`## CI / Infrastructure
470
-
471
- `;return Q+=N7($),Q+=T7(Z),Q}function w7($){if($.length===0)return"";let Z=`## Database (Python)
523
+ `}return Z}function vQ($,Z){if($.length===0&&Z.length===0)return"";let Q="";return Q+=bQ($),Q+=kQ(Z),Q}function SQ($){if($.length===0)return"";let Z=`### Database (Python)
472
524
 
473
- `;for(let Q of $){let X=Q.risk==="high"?"\uD83D\uDD34":Q.risk==="medium"?"\uD83D\uDFE1":"\uD83D\uDFE2",K=Q.tool==="alembic"?"Alembic":"Django";Z+=`**Tool:** ${K}
474
- `,Z+=`**Risk Level:** ${X} ${Q.risk.toUpperCase()}
525
+ `;for(let Q of $){let X=Q.tool==="alembic"?"Alembic":"Django";Z+=`**Tool:** ${X}
526
+ `,Z+=`**Risk Level:** ${Q.risk.toUpperCase()}
475
527
 
476
528
  `,Z+=`**Files:**
477
529
  `;for(let Y of Q.files)Z+=`- \`${Y}\`
@@ -479,89 +531,126 @@ ${$.interactive.context}
479
531
  `,Q.reasons.length>0){Z+=`**Detected patterns:**
480
532
  `;for(let Y of Q.reasons)Z+=`- ${Y}
481
533
  `;Z+=`
482
- `}}return Z}function E7($){if($.length===0)return"";let Z=`### Python Configuration
534
+ `}}return Z}function CQ($){if($.length===0)return"";let Z=`**Python Configuration**
483
535
 
484
- `;for(let Q of $){let X=Q.isBreaking?"\uD83D\uDD34":"\uD83D\uDFE2";if(Z+=`**File:** \`${Q.file}\` (${Q.configType}) ${X}
536
+ `;for(let Q of $){let X=Q.isBreaking?"(BREAKING)":"";if(Z+=`**File:** \`${Q.file}\` (${Q.configType}) ${X}
485
537
 
486
- `,Q.affectedSections.length>0){Z+=`**Affected Sections:**
487
- `;for(let K of Q.affectedSections.slice(0,5))Z+=`- ${K}
538
+ `,Q.affectedSections.length>0){Z+=`Affected Sections:
539
+ `;for(let Y of Q.affectedSections.slice(0,5))Z+=`- ${Y}
488
540
  `;if(Q.affectedSections.length>5)Z+=`- ...and ${Q.affectedSections.length-5} more
489
541
  `;Z+=`
490
- `}if(Q.isBreaking&&Q.breakingReasons.length>0){Z+=`**Breaking Changes:**
491
- `;for(let K of Q.breakingReasons)Z+=`- ${K}
542
+ `}if(Q.isBreaking&&Q.breakingReasons.length>0){Z+=`Breaking Changes:
543
+ `;for(let Y of Q.breakingReasons)Z+=`- ${Y}
492
544
  `;Z+=`
493
- `}}return Z}function I7($){let Z=$.get("large-diff")??[],Q=$.get("lockfile-mismatch")??[],X=$.get("test-gap")??[];if(!(Z.length>0||Q.length>0||X.length>0))return"";let Y=`## ⚠️ Warnings
545
+ `}}return Z}function FQ($){let Z=$.get("large-diff")??[],Q=$.get("lockfile-mismatch")??[],X=$.get("test-gap")??[];if(!(Z.length>0||Q.length>0||X.length>0))return"";let K=`### Warnings
494
546
 
495
- `;for(let W of Z)Y+=`- **Large diff detected:** ${W.filesChanged} files changed, ${W.linesChanged} lines modified
496
- `;for(let W of Q)if(W.manifestChanged&&!W.lockfileChanged)Y+=`- **Lockfile mismatch:** package.json changed but lockfile not updated
497
- `;else if(!W.manifestChanged&&W.lockfileChanged)Y+=`- **Lockfile mismatch:** lockfile changed but package.json not updated
498
- `;for(let W of X)Y+=`- **Test coverage gap:** ${W.prodFilesChanged} production files changed, only ${W.testFilesChanged} test files changed
499
- `;return Y+=`
500
- `,Y}function b7($,Z){let Q=[],X=Z.get("test-change");if(X&&X.length>0)Q.push("`bun test` - Run test suite");if($.profile==="sveltekit")Q.push("`bun run check` - Run SvelteKit type check");let K=Z.get("route-change");if(K){let W=K.filter((V)=>V.routeType==="endpoint");for(let V of W.slice(0,3)){let U=c1(V.routeId),J=V.methods?.join("/")||"GET";Q.push(`Test \`${J} ${U}\` endpoint`)}let q=K.filter((V)=>V.routeType==="page"&&V.change!=="deleted");for(let V of q.slice(0,3)){let U=c1(V.routeId);Q.push(`Verify \`${U}\` page renders correctly`)}}if($.interactive?.testNotes)Q.push($.interactive.testNotes);if(Q.length===0)Q.push("No specific test suggestions");let Y=`## Suggested Test Plan
547
+ `;for(let q of Z)K+=`- **Large diff detected:** ${q.filesChanged} files changed, ${q.linesChanged} lines modified
548
+ `;for(let q of Q)if(q.manifestChanged&&!q.lockfileChanged)K+=`- **Lockfile mismatch:** package.json changed but lockfile not updated
549
+ `;else if(!q.manifestChanged&&q.lockfileChanged)K+=`- **Lockfile mismatch:** lockfile changed but package.json not updated
550
+ `;for(let q of X)K+=`- **Test coverage gap:** ${q.prodFilesChanged} production files changed, only ${q.testFilesChanged} test files changed
551
+ `;return K+=`
552
+ `,K}function yQ($){if($.length===0)return"";let Z={high:0,medium:1,low:2},Q=[...$].sort((Y,K)=>Z[Y.blastRadius]-Z[K.blastRadius]),X=`### Impact Analysis
501
553
 
502
- `;return Y+=Q.map((W)=>`- [ ] ${W}`).join(`
503
- `)+`
504
-
505
- `,Y}function C7($){let{riskScore:Z}=$,Q=Z.level==="high"?"\uD83D\uDD34":Z.level==="medium"?"\uD83D\uDFE1":"\uD83D\uDFE2",X=`## Risks / Notes
554
+ `;for(let Y of Q){X+=`**\`${Y.sourceFile}\`** - Blast Radius: ${Y.blastRadius.toUpperCase()} (${Y.affectedFiles.length} files)
506
555
 
507
- `;X+=`**Overall Risk:** ${Q} ${Z.level.toUpperCase()} (score: ${Z.score}/100)
508
-
509
- `;let K=Z.evidenceBullets??[];if(K.length>0){for(let Y of K)X+=`- ${Y}
556
+ `,X+=`Affected files:
557
+ `;for(let K of Y.affectedFiles.slice(0,5))X+=`- \`${K}\`
558
+ `;if(Y.affectedFiles.length>5)X+=`- ...and ${Y.affectedFiles.length-5} more
510
559
  `;X+=`
511
- `}return X}function f8($){let Z=Y7($.findings),Q="";Q+=q7($),Q+=W7(Z);let X=Z.get("file-category")?.[0],K=Z.get("file-summary")?.[0];Q+=U7(X,K);let Y=Z.get("route-change")??[];Q+=V7(Y);let W=Z.get("api-contract-change")??[];Q+=J7(W);let q=Z.get("graphql-change")??[];Q+=H7(q);let V=Z.get("db-migration")??[];Q+=B7(V);let U=Z.get("python-migration")??[];Q+=w7(U);let J=Z.get("sql-risk")??[];Q+=R7(J);let B=Z.get("env-var")??[];Q+=G7(B);let G=Z.get("typescript-config")??[],M=Z.get("tailwind-config")??[],H=Z.get("monorepo-config")??[],O=Z.get("python-config")??[];Q+=j7(G,M,H),Q+=E7(O);let z=Z.get("cloudflare-change")??[];Q+=O7(z);let _=Z.get("dependency-change")??[];Q+=M7(_);let D=Z.get("package-exports")??[];Q+=D7(D),Q+=A7(Z);let L=Z.get("ci-workflow")??[],w=Z.get("infra-change")??[];Q+=x7(L,w);let T=Z.get("convention-violation")??[];if(T.length>0){Q+=`## ⚠️ Conventions
560
+ `}return X}function mQ($){if($.length===0)return"";let Z=`### Conventions
512
561
 
513
- `;for(let R of T){Q+=`- **${R.message}**
514
- `;for(let h of R.files.slice(0,5))Q+=` - \`${h}\`
515
- `;if(R.files.length>5)Q+=` - ...and ${R.files.length-5} more
516
- `}Q+=`
517
- `}let A=Z.get("test-parity-violation")??[];if(A.length>0){Q+=`## \uD83E\uDDEA Test Coverage Gaps
518
-
519
- `,Q+=`Found ${A.length} source file(s) without corresponding tests:
520
-
521
- `;for(let R of A.slice(0,10)){let h=R.confidence==="high"?"\uD83D\uDD34":R.confidence==="medium"?"\uD83D\uDFE1":"⚪";Q+=`- ${h} \`${R.sourceFile}\`
522
- `}if(A.length>10)Q+=`- ...and ${A.length-10} more
523
- `;Q+=`
524
- `}let b=Z.get("impact-analysis")??[];if(b.length>0){Q+=`## \uD83E\uDDE8 Impact Analysis
525
-
526
- `;for(let R of b){let h=R.blastRadius==="high"?"\uD83D\uDD34":R.blastRadius==="medium"?"\uD83D\uDFE1":"\uD83D\uDFE2";Q+=`### \`${R.sourceFile}\` ${h}
562
+ `;for(let Q of $){Z+=`- **${Q.message}**
563
+ `;for(let X of Q.files.slice(0,5))Z+=` - \`${X}\`
564
+ `;if(Q.files.length>5)Z+=` - ...and ${Q.files.length-5} more
565
+ `}return Z+=`
566
+ `,Z}function hQ($){if($.length===0)return"";let Z=`### Test Coverage Gaps
527
567
 
528
- `,Q+=`**Blast Radius:** ${R.blastRadius.toUpperCase()} (${R.affectedFiles.length} files)
568
+ `;Z+=`Found ${$.length} source file(s) without corresponding tests:
529
569
 
530
- `,Q+=`Affected files:
531
- `;for(let y of R.affectedFiles.slice(0,5))Q+=`- \`${y}\`
532
- `;if(R.affectedFiles.length>5)Q+=`- ...and ${R.affectedFiles.length-5} more
533
- `;Q+=`
534
- `}}return Q+=I7(Z),Q+=b7($,Z),Q+=C7($),Q.trim()+`
535
- `}function mW($){let Z={profile:$.profile,riskScore:$.riskScore,findings:$.findings};return JSON.stringify(Z,null,2)}t$();n$();import p from"chalk";import p8 from"boxen";import j2 from"cli-table3";var E={riskHigh:p.red.bold,riskMedium:p.yellow.bold,riskLow:p.green.bold,fileAdded:p.green,fileDeleted:p.red,fileModified:p.cyan,fileRenamed:p.blue,header:p.magenta.bold,subheader:p.cyan.bold,label:p.gray,value:p.white,muted:p.dim,accent:p.blue,warning:p.yellow,success:p.green,error:p.red,route:p.blue,packageName:p.cyan,version:p.yellow,envVar:p.magenta},Q1={file:"\uD83D\uDCC4",folder:"\uD83D\uDCC1",route:"\uD83D\uDEE4️",database:"\uD83D\uDDC4️",security:"\uD83D\uDD12",dependency:"\uD83D\uDCE6",test:"\uD83E\uDDEA",config:"⚙️",warning:"⚠️",check:"✓",cross:"✗",arrow:"→",bullet:"•",riskHigh:"\uD83D\uDD34",riskMedium:"\uD83D\uDFE1",riskLow:"\uD83D\uDFE2"};function y7($){let Z=new Map;for(let Q of $){if(!Z.has(Q.type))Z.set(Q.type,[]);Z.get(Q.type).push(Q)}return Z}function D2($){let Z=$==="high"?E.riskHigh:$==="medium"?E.riskMedium:E.riskLow;return`${$==="high"?Q1.riskHigh:$==="medium"?Q1.riskMedium:Q1.riskLow} ${Z($.toUpperCase())}`}function f1($,Z){let Q=Z?`${Z} `:"";return`
536
- ${E.header(Q+$)}
570
+ `;for(let Q of $.slice(0,10)){let X=Q.confidence==="high"?"[high]":Q.confidence==="medium"?"[medium]":"[low]";Z+=`- ${X} \`${Q.sourceFile}\`
571
+ `}if($.length>10)Z+=`- ...and ${$.length-10} more
572
+ `;return Z+=`
573
+ `,Z}function uQ($,Z){let Q="",X=Z.get("impact-analysis")??[];Q+=yQ(X);let Y=Z.get("route-change")??[];Q+=OQ(Y);let K=Z.get("api-contract-change")??[];Q+=HQ(K);let q=Z.get("graphql-change")??[];Q+=DQ(q);let W=Z.get("db-migration")??[];Q+=_Q(W);let V=Z.get("python-migration")??[];Q+=SQ(V);let U=Z.get("sql-risk")??[];Q+=PQ(U);let J=Z.get("env-var")??[];Q+=MQ(J);let G=Z.get("typescript-config")??[],B=Z.get("tailwind-config")??[],H=Z.get("monorepo-config")??[],_=Z.get("vite-config")??[],O=Z.get("python-config")??[];Q+=wQ(G,B,H,_),Q+=CQ(O);let M=Z.get("cloudflare-change")??[];Q+=zQ(M);let z=Z.get("dependency-change")??[];Q+=jQ(z);let A=Z.get("package-exports")??[];Q+=xQ(A),Q+=EQ(Z),Q+=IQ(Z);let N=Z.get("ci-workflow")??[],E=Z.get("infra-change")??[];Q+=vQ(N,E);let w=Z.get("security-file")??[];Q+=LQ(w);let T=Z.get("convention-violation")??[];Q+=mQ(T);let P=Z.get("test-parity-violation")??[];if(Q+=hQ(P),Q+=FQ(Z),Q.trim()==="")return"";return`<details>
574
+ <summary>Details</summary>
575
+
576
+ ${Q}</details>
577
+ `}function J9($){let Z=WQ($.findings),Q=V0($.findings),X="";X+=`<!-- branch-narrator: profile=${$.profile} -->
578
+ `,X+=qQ($),X+=UQ($,Q),X+=VQ(Q.topFindings);let Y=Z.get("file-category")?.[0],K=Z.get("file-summary")?.[0];return X+=JQ(Y,K,Q),X+=GQ($,Z),X+=BQ($),X+=uQ($,Z),X.trim()+`
579
+ `}function FV($){let Z={profile:$.profile,riskScore:$.riskScore,findings:$.findings};return JSON.stringify(Z,null,2)}S$();import J1 from"chalk";import G9 from"boxen";import S2 from"cli-table3";var L={riskHigh:J1.red.bold,riskMedium:J1.yellow.bold,riskLow:J1.green.bold,fileAdded:J1.green,fileDeleted:J1.red,fileModified:J1.cyan,fileRenamed:J1.blue,header:J1.magenta.bold,subheader:J1.cyan.bold,label:J1.gray,value:J1.white,muted:J1.dim,accent:J1.blue,warning:J1.yellow,success:J1.green,error:J1.red,route:J1.blue,packageName:J1.cyan,version:J1.yellow,envVar:J1.magenta},cQ={sveltekit:[{cmd:"bun run check",label:"Run SvelteKit type check",rationale:"SvelteKit profile"}],next:[{cmd:"bun run build",label:"Run Next.js build",rationale:"Next.js profile"}],react:[],vue:[{cmd:"bun run build",label:"Run Vue build",rationale:"Vue profile"}],astro:[{cmd:"bun run build",label:"Run Astro build",rationale:"Astro profile"}],stencil:[{cmd:"bun run build",label:"Run Stencil build",rationale:"Stencil profile"}],angular:[{cmd:"ng build",label:"Run Angular build",rationale:"Angular profile"}],library:[{cmd:"bun run build",label:"Build library",rationale:"library profile"}],python:[{cmd:"pytest",label:"Run pytest",rationale:"Python profile"}],vite:[{cmd:"bun run build",label:"Run Vite build",rationale:"Vite profile"}],auto:[]};function lQ($){let Z=new Map;for(let Q of $){if(!Z.has(Q.type))Z.set(Q.type,[]);Z.get(Q.type).push(Q)}return Z}function B9($){return($==="high"?L.riskHigh:$==="medium"?L.riskMedium:L.riskLow)($.toUpperCase())}function fQ($){return($==="HIGH"?L.riskHigh:$==="MEDIUM"?L.riskMedium:L.riskLow)($)}function z1($){return`
580
+ ${L.header($)}
537
581
  ${"─".repeat(50)}
538
- `}function k7($,Z){let Q=[],X=$.get("file-summary")?.[0];if(X){let J=X.added.length+X.modified.length+X.deleted.length+X.renamed.length;if(Q.push(`${E.value(String(J))} file(s) changed`),X.added.length>0)Q.push(`${E.fileAdded(`+${X.added.length}`)} file(s) added`);if(X.deleted.length>0)Q.push(`${E.fileDeleted(`-${X.deleted.length}`)} file(s) deleted`);if(X.modified.length>0)Q.push(`${E.fileModified(`~${X.modified.length}`)} file(s) modified`)}let K=$.get("route-change");if(K&&K.length>0){let J=K.filter((B)=>B.change==="added");if(J.length>0)Q.push(`${E.success(String(J.length))} new route(s)`)}let Y=$.get("db-migration");if(Y&&Y.length>0)Q.push(`${Q1.database} Database migrations detected`);let W=$.get("dependency-change");if(W&&W.length>0){let J=W.filter((B)=>B.impact==="major");if(J.length>0)Q.push(`${E.warning(String(J.length))} major dependency update(s)`)}let q=$.get("security-file");if(q&&q.length>0){let J=q.reduce((B,G)=>B+G.files.length,0);Q.push(`${Q1.security} ${J} security-sensitive file(s)`)}if(Q.length===0)Q.push("Minor changes detected");let V=`
539
- ${E.label("Risk:")} ${D2(Z.level)} ${E.muted(`(score: ${Z.score}/100)`)}`,U=Q.map((J)=>` ${Q1.bullet} ${J}`).join(`
540
- `)+V;return p8(U,{title:"SUMMARY",titleAlignment:"left",padding:{top:0,bottom:0,left:1,right:1},borderColor:"cyan",borderStyle:"round"})}function S7($,Z){if(!$||!Z)return"";let{categories:Q,summary:X}=$;if(X.length<=1)return"";let K=f1("WHAT CHANGED",Q1.file),Y=X.filter((W)=>W.count>0).sort((W,q)=>q.count-W.count);for(let{category:W,count:q}of Y){let V=o$(W);K+=`
541
- ${E.subheader(V)} ${E.muted(`(${q})`)}
542
- `;let U=Q[W],J=U.slice(0,8);for(let B of J){let G=" ",M=E.value;if(Z.added.includes(B))G=E.fileAdded("+ "),M=E.fileAdded;else if(Z.deleted.includes(B))G=E.fileDeleted("- "),M=E.fileDeleted;else if(Z.modified.includes(B))G=E.fileModified("~ "),M=E.fileModified;K+=` ${G}${M(B)}
543
- `}if(U.length>8)K+=` ${E.muted(`...and ${U.length-8} more`)}
544
- `}return K}function v7($){if($.length===0)return"";let Z=f1("ROUTES / API",Q1.route),Q=new j2({head:[E.label("Route"),E.label("Type"),E.label("Change"),E.label("Methods")],style:{head:[],border:["dim"]},chars:{top:"─","top-mid":"┬","top-left":"┌","top-right":"┐",bottom:"─","bottom-mid":"┴","bottom-left":"└","bottom-right":"┘",left:"│","left-mid":"├",mid:"─","mid-mid":"┼",right:"│","right-mid":"┤",middle:"│"}});for(let X of $){let K=c1(X.routeId),Y=X.methods?.join(", ")||"-",W=X.change==="added"?E.fileAdded:X.change==="deleted"?E.fileDeleted:E.fileModified;Q.push([E.route(K),X.routeType,W(X.change),Y])}return Z+=Q.toString()+`
545
- `,Z}function F7($){if($.length===0)return"";let Z=f1("DATABASE (SUPABASE)",Q1.database);for(let Q of $){Z+=`${E.label("Risk Level:")} ${D2(Q.risk)}
546
-
547
- `,Z+=`${E.label("Files:")}
548
- `;for(let X of Q.files)Z+=` ${Q1.bullet} ${E.value(X)}
582
+ `}function pQ($,Z){let{diffstat:Q,reviewAttention:X,findingsByCategory:Y}=Z,{riskScore:K,profile:q}=$,W=[];W.push(`${L.label("Files:")} ${J0(Q)}`),W.push(`${L.label("Profile:")} ${L.accent(q)}`),W.push(`${L.label("Risk:")} ${B9(K.level)} ${L.muted(`(${K.score}/100)`)}`),W.push(`${L.label("Review attention:")} ${fQ(X)} ${L.muted("(blast radius)")}`);let V=U9(Y);if(V!=="none")W.push(`${L.label("Findings:")} ${L.muted(V)}`);let U=W.map((J)=>` ${J}`).join(`
583
+ `);return G9(U,{title:"Summary",titleAlignment:"left",padding:{top:0,bottom:0,left:1,right:1},borderColor:"cyan",borderStyle:"round"})}function dQ($){if($.length===0)return"";let Z=z1("Top findings"),Q=1;for(let X of $){if(Z+=` ${Q}) ${L.value(X.description)}
584
+ `,X.examples.length>0){let Y=X.examples.map((q)=>L.muted(q)).join(", "),K=X.moreCount>0?L.muted(` (+${X.moreCount} more)`):"";Z+=` ${Y}${K}
585
+ `}Q++}return Z}function rQ($,Z,Q){if(!$||!Z)return"";let{categories:X,summary:Y}=$,{primaryFiles:K,changesetFiles:q}=Q;if(Y.reduce((J,G)=>J+G.count,0)===0)return"";let V=z1("What changed");if(K.length>0){V+=`${L.subheader("Primary files")}
586
+ `;for(let J of K){let G=" ",B=L.value;if(Z.added.includes(J))G=L.fileAdded("+ "),B=L.fileAdded;else if(Z.modified.includes(J))G=L.fileModified("~ "),B=L.fileModified;V+=` ${G}${B(J)}
587
+ `}V+=`
588
+ `}let U=Y.filter((J)=>J.count>0).sort((J,G)=>G.count-J.count);for(let{category:J}of U){let G=X[J],B=aQ(J);if(J==="docs"){let _=G.filter((O)=>!O.startsWith(".changeset/"));if(_.length===0&&q.length>0)continue;if(G=_,G.length===0)continue}V+=`${L.subheader(B)} ${L.muted(`(${G.length})`)}
589
+ `;let H=G.slice(0,8);for(let _ of H){let O=" ",M=L.value;if(Z.added.includes(_))O=L.fileAdded("+ "),M=L.fileAdded;else if(Z.deleted.includes(_))O=L.fileDeleted("- "),M=L.fileDeleted;else if(Z.modified.includes(_))O=L.fileModified("~ "),M=L.fileModified;V+=` ${O}${M(_)}
590
+ `}if(G.length>8)V+=` ${L.muted(`...and ${G.length-8} more`)}
591
+ `;V+=`
592
+ `}if(q.length>0){V+=`${L.subheader("Changesets")} ${L.muted(`(${q.length})`)}
593
+ `;for(let J of q){let G=Z.added.includes(J)?L.fileAdded("+ "):L.fileModified("~ "),B=Z.added.includes(J)?L.fileAdded:L.fileModified;V+=` ${G}${B(J)}
594
+ `}V+=`
595
+ `}return V}function aQ($){return{product:"Code",tests:"Tests",ci:"CI/CD",infra:"Infrastructure",database:"Database",docs:"Documentation",dependencies:"Dependencies",config:"Configuration",artifacts:"Build Artifacts",other:"Other"}[$]??$}function sQ($){if($.length===0)return"";let Z=z1("Routes / API"),Q=new S2({head:[L.label("Route"),L.label("Type"),L.label("Change"),L.label("Methods")],style:{head:[],border:["dim"]},chars:{top:"─","top-mid":"┬","top-left":"┌","top-right":"┐",bottom:"─","bottom-mid":"┴","bottom-left":"└","bottom-right":"┘",left:"│","left-mid":"├",mid:"─","mid-mid":"┼",right:"│","right-mid":"┤",middle:"│"}});for(let X of $){let Y=m1(X.routeId),K=X.methods?.join(", ")||"-",q=X.change==="added"?L.fileAdded:X.change==="deleted"?L.fileDeleted:L.fileModified;Q.push([L.route(Y),X.routeType,q(X.change),K])}return Z+=Q.toString()+`
596
+ `,Z}function oQ($){if($.length===0)return"";let Z=z1("Database (Supabase)");for(let Q of $){let X=B9(Q.risk);Z+=`${L.label("Risk Level:")} ${X}
597
+
598
+ `,Z+=`${L.label("Files:")}
599
+ `;for(let Y of Q.files)Z+=` - ${L.value(Y)}
549
600
  `;if(Q.reasons.length>0){Z+=`
550
- ${E.label("Detected patterns:")}
551
- `;for(let X of Q.reasons)Z+=` ${Q1.warning} ${E.warning(X)}
601
+ ${L.label("Detected patterns:")}
602
+ `;for(let Y of Q.reasons)Z+=` - ${L.warning(Y)}
552
603
  `}Z+=`
553
- `}return Z}function m7($){if($.length===0)return"";let Z=f1("CONFIG / ENV",Q1.config),Q=new j2({head:[E.label("Variable"),E.label("Status"),E.label("Evidence")],style:{head:[],border:["dim"]},chars:{top:"─","top-mid":"┬","top-left":"┌","top-right":"┐",bottom:"─","bottom-mid":"┴","bottom-left":"└","bottom-right":"┘",left:"│","left-mid":"├",mid:"─","mid-mid":"┼",right:"│","right-mid":"┤",middle:"│"}});for(let X of $){let K=X.evidenceFiles.slice(0,2).join(", "),Y=X.change==="added"?E.fileAdded:E.fileModified;Q.push([E.envVar(X.name),Y(X.change),E.muted(K)])}return Z+=Q.toString()+`
554
- `,Z}function u7($){if($.length===0)return"";let Z=f1("CLOUDFLARE","☁️");for(let Q of $){Z+=`${E.label("Area:")} ${E.value(Q.area)}
555
- `,Z+=`${E.label("Files:")}
556
- `;for(let X of Q.files)Z+=` ${Q1.bullet} ${E.value(X)}
604
+ `}return Z}function iQ($){if($.length===0)return"";let Z=z1("Config / Env"),Q=new S2({head:[L.label("Variable"),L.label("Status"),L.label("Evidence")],style:{head:[],border:["dim"]},chars:{top:"─","top-mid":"┬","top-left":"┌","top-right":"┐",bottom:"─","bottom-mid":"┴","bottom-left":"└","bottom-right":"┘",left:"│","left-mid":"├",mid:"─","mid-mid":"┼",right:"│","right-mid":"┤",middle:"│"}});for(let X of $){let Y=X.evidenceFiles.slice(0,2).join(", "),K=X.change==="added"?L.fileAdded:L.fileModified;Q.push([L.envVar(X.name),K(X.change),L.muted(Y)])}return Z+=Q.toString()+`
605
+ `,Z}function nQ($){if($.length===0)return"";let Z=z1("Cloudflare");for(let Q of $){Z+=`${L.label("Area:")} ${L.value(Q.area)}
606
+ `,Z+=`${L.label("Files:")}
607
+ `;for(let X of Q.files)Z+=` - ${L.value(X)}
608
+ `;Z+=`
609
+ `}return Z}function tQ($){if($.length===0)return"";let Z=$.filter((K)=>K.section==="dependencies"),Q=$.filter((K)=>K.section==="devDependencies"),X=z1("Dependencies"),Y=(K,q)=>{if(K.length===0)return"";let W=`${L.subheader(q)}
610
+ `,V=new S2({head:[L.label("Package"),L.label("From"),L.label("To"),L.label("Impact")],style:{head:[],border:["dim"]},chars:{top:"─","top-mid":"┬","top-left":"┌","top-right":"┐",bottom:"─","bottom-mid":"┴","bottom-left":"└","bottom-right":"┘",left:"│","left-mid":"├",mid:"─","mid-mid":"┼",right:"│","right-mid":"┤",middle:"│"}});for(let U of K){let J=U.impact==="major"?L.error:U.impact==="minor"?L.warning:L.muted;V.push([L.packageName(U.name),L.muted(U.from??"-"),L.version(U.to??"-"),J(U.impact??"-")])}return W+=V.toString()+`
611
+ `,W};if(Z.length>0)X+=Y(Z,"Production");if(Q.length>0)X+=Y(Q,"Dev Dependencies");return X}function eQ($,Z){let Q=[],X=Z.get("test-change");if(X&&X.length>0){let V=X.flatMap((U)=>U.files);if(V.length===1)Q.push({cmd:`bun test ${V[0]}`,rationale:"targeted"});else Q.push({cmd:"bun test",rationale:`${V.length} test files changed`})}let Y=cQ[$.profile]??[];for(let{cmd:V,rationale:U}of Y)Q.push({cmd:V,rationale:U});let K=Z.get("route-change");if(K){let V=K.filter((J)=>J.routeType==="endpoint");for(let J of V.slice(0,3)){let G=m1(J.routeId),B=J.methods?.join("/")||"GET";Q.push({cmd:`Test ${B} ${G} endpoint`,rationale:"route changed"})}let U=K.filter((J)=>J.routeType==="page"&&J.change!=="deleted");for(let J of U.slice(0,3)){let G=m1(J.routeId);Q.push({cmd:`Verify ${G} page renders correctly`,rationale:"page changed"})}}let q=Z.get("test-gap");if(q&&q.length>0){let V=q.reduce((U,J)=>U+J.prodFilesChanged,0);Q.push({cmd:`Add tests for ${V} modified file(s) lacking coverage`,rationale:"test gap"})}if($.interactive?.testNotes)Q.push({cmd:$.interactive.testNotes,rationale:"user note"});if(Q.length===0)return"";let W=z1("Suggested test plan");for(let{cmd:V,rationale:U}of Q)W+=` [ ] ${L.accent(V)} ${L.muted(`(${U})`)}
612
+ `;return W}function $X($){if($.length===0)return"";let Z=z1("Infrastructure"),Q=new Map;for(let X of $){if(!Q.has(X.infraType))Q.set(X.infraType,[]);Q.get(X.infraType).push(...X.files)}for(let[X,Y]of Q){let K=X==="docker"?"Docker":X==="terraform"?"Terraform":X==="kubernetes"?"Kubernetes":X==="compose"?"Docker Compose":X.charAt(0).toUpperCase()+X.slice(1);Z+=`${L.subheader(K)} ${L.muted(`(${Y.length})`)}
613
+ `;for(let q of Y.slice(0,5))Z+=` - ${L.value(q)}
614
+ `;if(Y.length>5)Z+=` ${L.muted(`...and ${Y.length-5} more`)}
557
615
  `;Z+=`
558
- `}return Z}function h7($){if($.length===0)return"";let Z=$.filter((Y)=>Y.section==="dependencies"),Q=$.filter((Y)=>Y.section==="devDependencies"),X=f1("DEPENDENCIES",Q1.dependency),K=(Y,W)=>{if(Y.length===0)return"";let q=`${E.subheader(W)}
559
- `,V=new j2({head:[E.label("Package"),E.label("From"),E.label("To"),E.label("Impact")],style:{head:[],border:["dim"]},chars:{top:"─","top-mid":"┬","top-left":"┌","top-right":"┐",bottom:"─","bottom-mid":"┴","bottom-left":"└","bottom-right":"┘",left:"│","left-mid":"├",mid:"─","mid-mid":"┼",right:"│","right-mid":"┤",middle:"│"}});for(let U of Y){let J=U.impact==="major"?E.error:U.impact==="minor"?E.warning:E.muted;V.push([E.packageName(U.name),E.muted(U.from??"-"),E.version(U.to??"-"),J(U.impact??"-")])}return q+=V.toString()+`
560
- `,q};if(Z.length>0)X+=K(Z,"Production");if(Q.length>0)X+=K(Q,"Dev Dependencies");return X}function g7($,Z){let Q=[],X=Z.get("test-change");if(X&&X.length>0)Q.push(`${E.accent("bun test")} - Run test suite`);if($.profile==="sveltekit")Q.push(`${E.accent("bun run check")} - Run SvelteKit type check`);let K=Z.get("route-change");if(K){let W=K.filter((V)=>V.routeType==="endpoint");for(let V of W.slice(0,3)){let U=c1(V.routeId),J=V.methods?.join("/")||"GET";Q.push(`Test ${E.route(`${J} ${U}`)} endpoint`)}let q=K.filter((V)=>V.routeType==="page"&&V.change!=="deleted");for(let V of q.slice(0,3)){let U=c1(V.routeId);Q.push(`Verify ${E.route(U)} page renders correctly`)}}if($.interactive?.testNotes)Q.push($.interactive.testNotes);if(Q.length===0)Q.push("No specific test suggestions");let Y=f1("SUGGESTED TEST PLAN",Q1.test);for(let W of Q)Y+=` ${E.muted("[ ]")} ${W}
561
- `;return Y}function l7($){let{riskScore:Z}=$,Q=f1("RISKS / NOTES",Q1.warning);Q+=`${E.label("Overall Risk:")} ${D2(Z.level)} ${E.muted(`(score: ${Z.score}/100)`)}
562
-
563
- `;let X=Z.evidenceBullets??[];if(X.length>0)for(let K of X)Q+=` ${Q1.bullet} ${K}
564
- `;return Q}function c7($){if(!$.interactive?.context)return"";return p8($.interactive.context,{title:"CONTEXT",titleAlignment:"left",padding:{top:0,bottom:0,left:1,right:1},borderColor:"blue",borderStyle:"round"})+`
565
- `}function A2($){let Z=y7($.findings),Q=`
566
- `;Q+=c7($),Q+=k7(Z,$.riskScore),Q+=`
567
- `;let X=Z.get("file-category")?.[0],K=Z.get("file-summary")?.[0];Q+=S7(X,K);let Y=Z.get("route-change")??[];Q+=v7(Y);let W=Z.get("db-migration")??[];Q+=F7(W);let q=Z.get("env-var")??[];Q+=m7(q);let V=Z.get("cloudflare-change")??[];Q+=u7(V);let U=Z.get("dependency-change")??[];return Q+=h7(U),Q+=g7($,Z),Q+=l7($),Q}var k1=new FX,gX=await g$();k1.name("branch-narrator").description("A local-first CLI that reads git diff and generates structured PR descriptions").version(gX).option("--quiet","Suppress all non-fatal diagnostic output (warnings, info)").option("--debug","Show debug diagnostics on stderr").hook("preAction",($)=>{let Z=$.opts();n2({quiet:Z.quiet,debug:Z.debug})});async function JZ($){let Z=mX({input:process.stdin,output:process.stderr});return new Promise((Q)=>{Z.question($,(X)=>{Z.close(),Q(X.trim())})})}async function N$($){if($.mode==="branch"){let{base:X,head:K}=$;if(!X)X=await p0();if(!K)K="HEAD";return{base:X,head:K}}let Z=$.base!==void 0,Q=$.head!==void 0;if(Z||Q)s1(`Warning: --base and --head are ignored when --mode is "${$.mode}"`);return{base:void 0,head:void 0}}async function BZ($){let Z=$.showSpinner?uX({text:"Collecting git changes...",color:"cyan"}).start():null,Q=await l1({mode:$.mode,base:$.base,head:$.head,includeUntracked:$.mode==="all"||$.mode==="unstaged"});if(Z)Z.text="Resolving profile...";let X=e1($.profile,Q,process.cwd()),K=y1(X);if(Z)Z.text=`Running analyzers (${K.analyzers.length})...`;let Y=await I1(K.analyzers,Q);if(Z)Z.succeed(hX.green(`Analysis complete (${Y.length} findings)`));return{findings:Y,resolvedProfile:X}}k1.command("pretty").description("Display a colorized summary of changes (for humans)").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base branch to compare against (branch mode; auto-detected if omitted)").option("--head <ref>","Head branch (branch mode; defaults to HEAD)").option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").action(async($)=>{try{let Z=$.mode;if(!["branch","unstaged","staged","all"].includes(Z))c(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:Q,head:X}=await N$({mode:Z,base:$.base,head:$.head}),{findings:K,resolvedProfile:Y}=await BZ({mode:Z,base:Q,head:X,profile:$.profile,showSpinner:!0}),W=O$(K);console.log(A2({findings:K,riskScore:W,profile:Y}));return}catch(Z){j1(Z)}});k1.command("pr-body").description("Generate a Markdown PR description").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base branch to compare against (branch mode; auto-detected if omitted)").option("--head <ref>","Head branch (branch mode; defaults to HEAD)").option("-u, --uncommitted","[DEPRECATED] Use --mode unstaged instead",!1).option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").option("--interactive","Prompt for additional context",!1).action(async($)=>{try{let Z=$.mode;if($.uncommitted)s1("Warning: --uncommitted is deprecated. Use --mode unstaged instead."),Z="unstaged";if(!["branch","unstaged","staged","all"].includes(Z))c(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:Q,head:X}=await N$({mode:Z,base:$.base,head:$.head}),{findings:K,resolvedProfile:Y}=await BZ({mode:Z,base:Q,head:X,profile:$.profile,showSpinner:!1}),W=O$(K),q;if($.interactive){let U=await JZ("Context/Why (1-3 sentences, press Enter to skip): "),J=await JZ("Special manual test notes (press Enter to skip): ");q={context:U||void 0,testNotes:J||void 0}}console.log(f8({findings:K,riskScore:W,profile:Y,interactive:q}));return}catch(Z){j1(Z)}});k1.command("facts").description("Output structured JSON facts (agent-grade output)").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").option("--format <type>","Output format: json|sarif","json").option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--redact","Redact obvious secret values in evidence excerpts",!1).option("--exclude <glob>","Additional exclusion glob (repeatable)",E0,[]).option("--include <glob>","Include only files matching glob (repeatable)",E0,[]).option("--max-file-bytes <n>","Maximum file size in bytes to analyze","1048576").option("--max-diff-bytes <n>","Maximum diff size in bytes to analyze","5242880").option("--max-findings <n>","Maximum number of findings to include").option("--out <path>","Write output to file instead of stdout").option("--no-timestamp","Omit generatedAt for deterministic output").option("--since <path>","Compare current output to a previous JSON file").option("--since-strict","Exit with code 1 on scope/tool/schema mismatch",!1).option("--test-parity","Enable test parity checking (opt-in, may be slow on large repos)",!1).action(async($)=>{try{let{executeFacts:Z}=await Promise.resolve().then(() => (K9(),X9)),{getRepoRoot:Q,isWorkingDirDirty:X}=await Promise.resolve().then(() => (B$(),G5)),{computeFactsDelta:K}=await Promise.resolve().then(() => (w2(),Q9)),Y=$.mode;if(!["branch","unstaged","staged","all"].includes(Y))c(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:W,head:q}=await N$({mode:Y,base:$.base,head:$.head});if($.format!=="json"&&$.format!=="sarif")c(`Invalid format: ${$.format}. Use json or sarif.`),process.exit(1);let V=parseInt($.maxFileBytes,10),U=parseInt($.maxDiffBytes,10),J=$.maxFindings?parseInt($.maxFindings,10):void 0,B=await l1({mode:Y,base:W,head:q,includeUntracked:Y==="all"||Y==="unstaged"}),[G,M]=await Promise.all([Q(),X()]),H=$.profile,O,z,_;if(H==="auto"){let R=b$(B,process.cwd());O=R.profile,z=R.confidence,_=R.reasons}else O=H,z="high",_=[`Profile explicitly set to ${H}`];let D=y1(O),L=await I1(D.analyzers,B);if($.testParity){let{testParityAnalyzer:R}=await Promise.resolve().then(() => (Q0(),e0)),h=await R.analyze(B);L.push(...h)}let w=O$(L),T=await Z({changeSet:B,findings:L,riskScore:w,requestedProfile:H,detectedProfile:O,profileConfidence:z,profileReasons:_,filters:{excludes:$.exclude,includes:$.include,redact:$.redact,maxFileBytes:V,maxDiffBytes:U,maxFindings:J},skippedFiles:[],warnings:[],noTimestamp:$.timestamp===!1,repoRoot:G,isDirty:M,mode:Y}),A;if($.since)A=await K({sincePath:$.since,currentFacts:T,mode:Y,base:W||null,head:q||null,profile:O,include:$.include,exclude:$.exclude,sinceStrict:$.sinceStrict});else A=T;if($.format==="sarif"&&$.since)throw new v("The --since option cannot be used with --format sarif. Remove --since or choose a different output format.",1);let b;if($.format==="sarif"){let{renderSarif:R}=await Promise.resolve().then(() => (W9(),q9)),h=R(A,B);b=$.pretty?JSON.stringify(h,null,2):JSON.stringify(h)}else b=$.pretty?JSON.stringify(A,null,2):JSON.stringify(A);if($.out){let{writeFile:R,mkdir:h}=await import("node:fs/promises"),{dirname:y}=await import("node:path");await h(y($.out),{recursive:!0}),await R($.out,b,"utf-8"),l(`Facts written to ${$.out}`)}else console.log(b);return}catch(Z){j1(Z)}});function E0($,Z){return Z.concat([$])}k1.command("dump-diff").description("Output prompt-ready git diff with smart exclusions (for AI agents)").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--no-untracked","Exclude untracked files (non-branch modes)").option("--out <path>","Write output to file (creates directories as needed)").option("--format <type>","Output format: text|md|json","text").option("--unified <n>","Lines of unified context (git diff -U)","0").option("--include <glob>","Include only files matching glob (repeatable)",E0,[]).option("--exclude <glob>","Additional exclusion glob (repeatable)",E0,[]).option("--max-chars <n>","Chunk output if it exceeds this size").option("--chunk-dir <path>","Directory for chunk files",".ai/diff-chunks").option("--name <prefix>","Chunk file name prefix","diff").option("--dry-run","Preview what would be included/excluded",!1).option("--name-only","Output only file list (no diffs)",!1).option("--stat","Output file statistics (additions/deletions)",!1).option("--patch-for <path>","Output diff for a specific file only").option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--no-timestamp","Omit generatedAt for deterministic output",!1).action(async($)=>{try{let Z=$.mode;if(!["branch","unstaged","staged","all"].includes(Z))c(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:Q,head:X}=await N$({mode:Z,base:$.base,head:$.head}),K=$.format;if(!["text","md","json"].includes(K))c(`Invalid format: ${$.format}. Use text, md, or json.`),process.exit(1);let Y=parseInt($.unified,10);if(isNaN(Y)||Y<0)c(`Invalid unified context: ${$.unified}. Must be a non-negative integer.`),process.exit(1);let W=$.maxChars?parseInt($.maxChars,10):void 0;if(W!==void 0&&(isNaN(W)||W<=0))c(`Invalid max-chars: ${$.maxChars}. Must be a positive integer.`),process.exit(1);let q=$.nameOnly===!0,V=$.stat===!0,U=$.patchFor!==void 0;if([q,V,U].filter(Boolean).length>1)c("Options --name-only, --stat, and --patch-for are mutually exclusive. Use only one at a time."),process.exit(1);await Y5({mode:Z,base:Q,head:X,out:$.out,format:K,unified:Y,include:$.include,exclude:$.exclude,maxChars:W,chunkDir:$.chunkDir,name:$.name,dryRun:$.dryRun,includeUntracked:$.untracked!==!1,nameOnly:q,stat:V,patchFor:$.patchFor,pretty:$.pretty,noTimestamp:$.timestamp===!1});return}catch(Z){j1(Z)}});k1.command("risk-report").description("Analyze git diff and emit risk score (0-100) with evidence-backed flags").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--format <type>","Output format: json|md|text","json").option("--out <path>","Write output to file instead of stdout").option("--fail-on-score <n>","Exit with code 2 if risk score >= threshold").option("--only <categories>","Only include these categories (comma-separated)").option("--exclude <categories>","Exclude these categories (comma-separated)").option("--max-evidence-lines <n>","Max evidence lines per flag","5").option("--redact","Redact secret values in evidence",!1).option("--explain-score","Include score breakdown in output",!1).option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--no-timestamp","Omit generatedAt for deterministic output",!1).option("--since <path>","Compare current output to a previous JSON file").option("--since-strict","Exit with code 1 on scope/tool/schema mismatch",!1).option("--test-parity","Enable test parity checking (opt-in, may be slow on large repos)",!1).action(async($)=>{try{let{executeRiskReport:Z,renderRiskReportJSON:Q,renderRiskReportMarkdown:X,renderRiskReportText:K}=await Promise.resolve().then(() => (G0(),J9)),{computeRiskReportDelta:Y}=await Promise.resolve().then(() => (m2(),V9)),W=$.mode;if(!["branch","unstaged","staged","all"].includes(W))c(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:q,head:V}=await N$({mode:W,base:$.base,head:$.head}),U=$.format;if(!["json","md","text"].includes(U))c(`Invalid format: ${$.format}. Use json, md, or text.`),process.exit(1);let J=parseInt($.maxEvidenceLines,10);if(isNaN(J)||J<1)c(`Invalid max-evidence-lines: ${$.maxEvidenceLines}. Must be a positive integer.`),process.exit(1);let B=$.failOnScore?parseInt($.failOnScore,10):void 0;if(B!==void 0&&(isNaN(B)||B<0||B>100))c(`Invalid fail-on-score: ${$.failOnScore}. Must be 0-100.`),process.exit(1);let G=$.only?$.only.split(",").map((_)=>_.trim()):void 0,M=$.exclude?$.exclude.split(",").map((_)=>_.trim()):void 0,H=await l1({mode:W,base:q,head:V,includeUntracked:W==="all"||W==="unstaged"}),O=await Z(H,{only:G,exclude:M,maxEvidenceLines:J,redact:$.redact,explainScore:$.explainScore,noTimestamp:$.timestamp===!1,mode:W,testParity:$.testParity}),z;if($.since){if(U!=="json")c("--since requires --format json (other formats not supported in v1)"),process.exit(1);let _=await Y({sincePath:$.since,currentReport:O,mode:W,base:q||null,head:V||null,only:G||null,exclude:M||null,sinceStrict:$.sinceStrict});z=$.pretty?JSON.stringify(_,null,2):JSON.stringify(_)}else switch(U){case"json":z=Q(O,$.pretty);break;case"md":z=X(O);break;case"text":z=K(O);break}if($.out){let{writeFile:_,mkdir:D}=await import("node:fs/promises"),{dirname:L}=await import("node:path");await D(L($.out),{recursive:!0}),await _($.out,z,"utf-8"),l(`Risk report written to ${$.out}`)}else console.log(z);if(B!==void 0&&O.riskScore>=B){c(`Risk score ${O.riskScore} >= threshold ${B}`),process.exitCode=2;return}return}catch(Z){j1(Z)}});k1.command("zoom").description("Zoom into a specific finding or flag for detailed context").option("--finding <id>","Finding ID to zoom into").option("--flag <id>","Flag ID to zoom into").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").option("--format <type>","Output format: json|md|text","json").option("--unified <n>","Lines of unified context for patch hunks","3").option("--no-patch","Do not include patch context, only evidence").option("--max-evidence-lines <n>","Max evidence excerpt lines to show","8").option("--redact","Redact obvious secret values in evidence excerpts",!1).option("--out <path>","Write output to file instead of stdout").option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--no-timestamp","Omit generatedAt for deterministic output").action(async($)=>{try{let{executeZoom:Z}=await Promise.resolve().then(() => (O9(),G9)),{renderZoomJSON:Q,renderZoomMarkdown:X,renderZoomText:K}=await Promise.resolve().then(() => M9),Y=$.mode;if(!["branch","unstaged","staged","all"].includes(Y))c(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:W,head:q}=await N$({mode:Y,base:$.base,head:$.head}),V=$.format;if(!["json","md","text"].includes(V))c(`Invalid format: ${$.format}. Use json, md, or text.`),process.exit(1);let U=parseInt($.unified,10);if(isNaN(U)||U<0)c(`Invalid unified context: ${$.unified}. Must be a non-negative integer.`),process.exit(1);let J=parseInt($.maxEvidenceLines,10);if(isNaN(J)||J<1)c(`Invalid max-evidence-lines: ${$.maxEvidenceLines}. Must be a positive integer.`),process.exit(1);let B=await l1({mode:Y,base:W,head:q,includeUntracked:Y==="all"||Y==="unstaged"}),G=await Z(B,{findingId:$.finding,flagId:$.flag,mode:Y,base:W,head:q,profile:$.profile,includePatch:$.patch!==!1,unified:U,maxEvidenceLines:J,redact:$.redact,noTimestamp:$.timestamp===!1}),M;switch(V){case"json":M=Q(G,$.pretty);break;case"md":M=X(G);break;case"text":M=K(G);break}if($.out){let{writeFile:H,mkdir:O}=await import("node:fs/promises"),{dirname:z}=await import("node:path");await O(z($.out),{recursive:!0}),await H($.out,M,"utf-8"),l(`Zoom output written to ${$.out}`)}else console.log(M);return}catch(Z){j1(Z)}});k1.command("integrate [target]").description("Generate provider-specific rules (auto-detects when omitted)").option("--dry-run","Preview what would be written without creating files",!1).option("--force","Overwrite existing files",!1).action(async($,Z)=>{try{let{executeIntegrate:Q}=await Promise.resolve().then(() => (k9(),y9));await Q({target:$,dryRun:Z.dryRun,force:Z.force});return}catch(Q){j1(Q)}});var u$=k1.command("snap").description("Manage local workspace snapshots for agent iteration");u$.command("save [label]").description("Create a new snapshot of current workspace state").option("--out <path>","Write snapshotId to file instead of stdout").action(async($,Z)=>{try{let{executeSnapSave:Q}=await Promise.resolve().then(() => (A$(),D$)),X=await Q({label:$,out:Z.out});if(!Z.out)console.log(X.snapshotId);else l(`Snapshot ${X.snapshotId} saved to ${Z.out}`);return}catch(Q){j1(Q)}});u$.command("list").description("List all snapshots").option("--pretty","Pretty-print JSON with 2-space indentation",!1).action(async($)=>{try{let{executeSnapList:Z,renderSnapListJSON:Q}=await Promise.resolve().then(() => (A$(),D$)),X=await Z();console.log(Q(X,$.pretty));return}catch(Z){j1(Z)}});u$.command("show <snapshotId>").description("Show snapshot details").option("--pretty","Pretty-print JSON with 2-space indentation",!1).action(async($,Z)=>{try{let{executeSnapShow:Q,renderSnapShowJSON:X}=await Promise.resolve().then(() => (A$(),D$)),K=await Q($);console.log(X(K,Z.pretty));return}catch(Q){j1(Q)}});u$.command("diff <idA> <idB>").description("Compare two snapshots").option("--pretty","Pretty-print JSON with 2-space indentation",!1).action(async($,Z,Q)=>{try{let{executeSnapDiff:X,renderSnapDiffJSON:K}=await Promise.resolve().then(() => (A$(),D$)),Y=await X($,Z);console.log(K(Y,Q.pretty));return}catch(X){j1(X)}});u$.command("restore <snapshotId>").description("Restore workspace to snapshot state (creates automatic backup first)").action(async($)=>{try{let{executeSnapRestore:Z}=await Promise.resolve().then(() => (A$(),D$)),Q=await Z($);if(l(`Restored to snapshot ${Q.snapshotId}`),l(`Pre-restore backup: ${Q.backupSnapshotId}`),Q.verified)l("Verification: passed");else s1("Verification: patch hashes differ (this may be expected for empty patches)");return}catch(Z){j1(Z)}});function j1($){if($ instanceof v)c(`Error: ${$.message}`),process.exit($.exitCode);if($ instanceof Error){if(c(`Unexpected error: ${$.message}`),process.env.DEBUG)c($.stack||"")}else c("An unexpected error occurred");process.exit(1)}await k1.parseAsync();
616
+ `}return Z}function ZX($){if($.length===0)return"";let Z=$.filter((Y)=>Y.riskType==="permissions_broadened"||Y.riskType==="pull_request_target"),Q=$.filter((Y)=>Y.riskType!=="permissions_broadened"&&Y.riskType!=="pull_request_target");if(Z.length===0&&Q.length===0)return"";let X=z1("CI/CD Workflows");if(Z.length>0){X+=`${L.riskHigh("SECURITY CONCERNS")}
617
+ `;for(let Y of Z){let K=Y.riskType==="permissions_broadened"?"Permissions broadened":"pull_request_target trigger";X+=` - ${L.warning(Y.file)}: ${L.error(K)}
618
+ `}X+=`
619
+ `}if(Q.length>0){X+=`${L.subheader("Modified Workflows")} ${L.muted(`(${Q.length})`)}
620
+ `;for(let Y of Q.slice(0,5)){if(X+=` - ${L.value(Y.file)}`,Y.riskType)X+=` ${L.muted(`(${Y.riskType})`)}`;X+=`
621
+ `}if(Q.length>5)X+=` ${L.muted(`...and ${Q.length-5} more`)}
622
+ `}return X}function QX($){if($.length===0)return"";let Z=z1("SQL Risks"),Q=$.filter((Y)=>Y.riskType==="destructive"),X=$.filter((Y)=>Y.riskType!=="destructive");if(Q.length>0){Z+=`${L.riskHigh("DESTRUCTIVE SQL DETECTED")}
623
+ `;for(let Y of Q){if(Z+=` - ${L.error(Y.file)}`,Y.details)Z+=`: ${L.warning(Y.details)}`;Z+=`
624
+ `}Z+=`
625
+ `}if(X.length>0){Z+=`${L.subheader("Other SQL Changes")} ${L.muted(`(${X.length})`)}
626
+ `;for(let Y of X.slice(0,5)){if(Z+=` - ${L.value(Y.file)}`,Y.riskType)Z+=` ${L.muted(`(${Y.riskType})`)}`;Z+=`
627
+ `}if(X.length>5)Z+=` ${L.muted(`...and ${X.length-5} more`)}
628
+ `}return Z}function XX($){if($.length===0)return"";let Z=$[0];if(!Z||Z.linesChanged<500)return"";let Q=z1("Large changes");return Q+=`${L.warning("Large change detected - review carefully")}
629
+
630
+ `,Q+=` - ${L.value(`${Z.filesChanged} file(s)`)} changed
631
+ `,Q+=` - ${L.value(`${Z.linesChanged} line(s)`)} modified
632
+ `,Q}function YX($){let Z=$.get("stencil-component-change")??[],Q=$.get("stencil-prop-change")??[],X=$.get("stencil-event-change")??[],Y=$.get("stencil-method-change")??[],K=$.get("stencil-slot-change")??[];if(Z.length+Q.length+X.length+Y.length+K.length===0)return"";let W=z1("Stencil Components"),V=new Map,U=(J)=>{if(!V.has(J))V.set(J,{props:[],events:[],methods:[],slots:[]});return V.get(J)};for(let J of Q)U(J.tag).props.push(`${J.propName} (${J.change})`);for(let J of X)U(J.tag).events.push(`${J.eventName} (${J.change})`);for(let J of Y)U(J.tag).methods.push(`${J.methodName} (${J.change})`);for(let J of K){let G=U(J.tag),B=J.slotName||"(default)";G.slots.push(`${B} (${J.change})`)}for(let[J,G]of V){W+=`${L.subheader(`<${J}>`)}`;let B=[];if(G.props.length>0)B.push(`${G.props.length} prop(s)`);if(G.events.length>0)B.push(`${G.events.length} event(s)`);if(G.methods.length>0)B.push(`${G.methods.length} method(s)`);if(G.slots.length>0)B.push(`${G.slots.length} slot(s)`);W+=` ${L.muted(`(${B.join(", ")})`)}
633
+ `;let H=[...G.props.map((_)=>`@Prop ${_}`),...G.events.map((_)=>`@Event ${_}`),...G.methods.map((_)=>`@Method ${_}`),...G.slots.map((_)=>`slot ${_}`)];for(let _ of H.slice(0,4))W+=` - ${L.value(_)}
634
+ `;if(H.length>4)W+=` ${L.muted(`...and ${H.length-4} more`)}
635
+ `;W+=`
636
+ `}return W}function KX($){let Z=$.get("typescript-config")??[],Q=$.get("tailwind-config")??[],X=$.get("graphql-change")??[],Y=$.get("package-exports")??[],K=$.get("monorepo-config")??[];if(Z.length+Q.length+X.length+Y.length+K.length===0)return"";let W=z1("Config Changes");if(Z.length>0){let V=Z.some((U)=>U.isBreaking);if(W+=`${L.subheader("TypeScript Config")}`,V)W+=` ${L.error("(BREAKING)")}`;W+=`
637
+ `;for(let U of Z){W+=` - ${L.value(U.file)}`;let J=[...U.changedOptions.added,...U.changedOptions.removed,...U.changedOptions.modified];if(J.length>0){if(W+=`: ${L.muted(J.slice(0,3).join(", "))}`,J.length>3)W+=L.muted(` +${J.length-3}`)}W+=`
638
+ `}W+=`
639
+ `}if(Q.length>0){let V=Q.some((U)=>U.isBreaking);if(W+=`${L.subheader("Tailwind Config")}`,V)W+=` ${L.error("(BREAKING)")}`;W+=`
640
+ `;for(let U of Q)W+=` - ${L.value(U.file)}
641
+ `;W+=`
642
+ `}if(X.length>0){let V=X.some((U)=>U.isBreaking);if(W+=`${L.subheader("GraphQL Schema")}`,V)W+=` ${L.error("(BREAKING)")}`;W+=`
643
+ `;for(let U of X){W+=` - ${L.value(U.file)}`;let J=[...U.breakingChanges.map((G)=>`${G} (breaking)`),...U.addedElements];if(J.length>0){if(W+=`: ${L.muted(J.slice(0,2).join(", "))}`,J.length>2)W+=L.muted(` +${J.length-2}`)}W+=`
644
+ `}W+=`
645
+ `}if(Y.length>0){let V=Y.some((U)=>U.isBreaking);if(W+=`${L.subheader("Package Exports")}`,V)W+=` ${L.error("(BREAKING)")}`;W+=`
646
+ `;for(let U of Y){let J=[];if(U.addedExports&&U.addedExports.length>0)J.push(`+${U.addedExports.length} added`);if(U.removedExports&&U.removedExports.length>0)J.push(`-${U.removedExports.length} removed`);if(U.binChanges){if(U.binChanges.added.length>0)J.push(`+${U.binChanges.added.length} bin`);if(U.binChanges.removed.length>0)J.push(`-${U.binChanges.removed.length} bin`)}if(W+=` - ${L.value("package.json exports")}`,J.length>0)W+=`: ${L.muted(J.join(", "))}`;W+=`
647
+ `}W+=`
648
+ `}if(K.length>0){W+=`${L.subheader("Monorepo Config")}
649
+ `;for(let V of K)W+=` - ${L.value(V.tool)}: ${L.muted(V.file)}
650
+ `;W+=`
651
+ `}return W}function WX($){let{riskScore:Z}=$,Q=Z.evidenceBullets??[];if(Q.length===0&&Z.level==="low"){let X=z1("Notes");return X+=` No elevated risks detected.
652
+ `,X}if(Q.length>0){let X=z1("Notes");for(let Y of Q){let K=Y.replace(/^[⚠️⚡ℹ️✅]\s*/,"").replace(/^[\u2600-\u27FF]\s*/,"");X+=` - ${K}
653
+ `}return X}return""}function qX($){if(!$.interactive?.context)return"";return G9($.interactive.context,{title:"Context",titleAlignment:"left",padding:{top:0,bottom:0,left:1,right:1},borderColor:"blue",borderStyle:"round"})+`
654
+ `}function C2($){let Z=lQ($.findings),Q=V0($.findings),X=`
655
+ `;X+=qX($),X+=pQ($,Q),X+=`
656
+ `,X+=dQ(Q.topFindings);let Y=Z.get("large-diff")??[];X+=XX(Y);let K=Z.get("file-category")?.[0],q=Z.get("file-summary")?.[0];X+=rQ(K,q,Q);let W=Z.get("route-change")??[];X+=sQ(W);let V=Z.get("db-migration")??[];X+=oQ(V);let U=Z.get("sql-risk")??[];X+=QX(U);let J=Z.get("env-var")??[];X+=iQ(J),X+=KX(Z),X+=YX(Z);let G=Z.get("infra-change")??[];X+=$X(G);let B=Z.get("ci-workflow")??[];X+=ZX(B);let H=Z.get("cloudflare-change")??[];X+=nQ(H);let _=Z.get("dependency-change")??[];return X+=tQ(_),X+=eQ($,Z),X+=WX($),X}var g1=new ZK,KK=await a$();g1.name("branch-narrator").description("A local-first CLI that reads git diff and generates structured PR descriptions").version(KK).option("--quiet","Suppress all non-fatal diagnostic output (warnings, info)").option("--debug","Show debug diagnostics on stderr").hook("preAction",($)=>{let Z=$.opts();V5({quiet:Z.quiet,debug:Z.debug})});async function vZ($){let Z=QK({input:process.stdin,output:process.stderr});return new Promise((Q)=>{Z.question($,(X)=>{Z.close(),Q(X.trim())})})}async function I$($){if($.mode==="branch"){let{base:X,head:Y}=$;if(!X)X=await i0();if(!Y)Y="HEAD";return{base:X,head:Y}}let Z=$.base!==void 0,Q=$.head!==void 0;if(Z||Q)J$(`Warning: --base and --head are ignored when --mode is "${$.mode}"`);return{base:void 0,head:void 0}}async function SZ($){let Z=$.showSpinner?XK({text:"Collecting git changes...",color:"cyan"}).start():null,Q=await n1({mode:$.mode,base:$.base,head:$.head,includeUntracked:$.mode==="all"||$.mode==="unstaged"});if(Z)Z.text="Resolving profile...";let X=Y$($.profile,Q,process.cwd()),Y=u1(X);if(Z)Z.text=`Running analyzers (${Y.analyzers.length})...`;let K=await F1(Y.analyzers,Q);if(Z)Z.succeed(YK.green(`Analysis complete (${K.length} findings)`));return{findings:K,resolvedProfile:X}}g1.command("pretty").description("Display a colorized summary of changes (for humans)").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base branch to compare against (branch mode; auto-detected if omitted)").option("--head <ref>","Head branch (branch mode; defaults to HEAD)").option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").action(async($)=>{try{let Z=$.mode;if(!["branch","unstaged","staged","all"].includes(Z))r(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:Q,head:X}=await I$({mode:Z,base:$.base,head:$.head}),{findings:Y,resolvedProfile:K}=await SZ({mode:Z,base:Q,head:X,profile:$.profile,showSpinner:!0}),q=L$(Y);console.log(C2({findings:Y,riskScore:q,profile:K}));return}catch(Z){I1(Z)}});g1.command("pr-body").description("Generate a Markdown PR description").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base branch to compare against (branch mode; auto-detected if omitted)").option("--head <ref>","Head branch (branch mode; defaults to HEAD)").option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").option("--interactive","Prompt for additional context",!1).action(async($)=>{try{let Z=$.mode;if(!["branch","unstaged","staged","all"].includes(Z))r(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:Q,head:X}=await I$({mode:Z,base:$.base,head:$.head}),{findings:Y,resolvedProfile:K}=await SZ({mode:Z,base:Q,head:X,profile:$.profile,showSpinner:!1}),q=L$(Y),W;if($.interactive){let U=await vZ("Context/Why (1-3 sentences, press Enter to skip): "),J=await vZ("Special manual test notes (press Enter to skip): ");W={context:U||void 0,testNotes:J||void 0}}console.log(J9({findings:Y,riskScore:q,profile:K,interactive:W}));return}catch(Z){I1(Z)}});g1.command("facts").description("Output structured JSON facts (agent-grade output)").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").option("--format <type>","Output format: json|sarif","json").option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--redact","Redact obvious secret values in evidence excerpts",!1).option("--exclude <glob>","Additional exclusion glob (repeatable)",C0,[]).option("--include <glob>","Include only files matching glob (repeatable)",C0,[]).option("--max-file-bytes <n>","Maximum file size in bytes to analyze","1048576").option("--max-diff-bytes <n>","Maximum diff size in bytes to analyze","5242880").option("--max-findings <n>","Maximum number of findings to include").option("--out <path>","Write output to file instead of stdout").option("--no-timestamp","Omit generatedAt for deterministic output").option("--since <path>","Compare current output to a previous JSON file").option("--since-strict","Exit with code 1 on scope/tool/schema mismatch",!1).option("--test-parity","Enable test parity checking (opt-in, may be slow on large repos)",!1).action(async($)=>{try{let{executeFacts:Z}=await Promise.resolve().then(() => (x9(),w9)),{getRepoRoot:Q,isWorkingDirDirty:X}=await Promise.resolve().then(() => (M$(),w5)),{computeFactsDelta:Y}=await Promise.resolve().then(() => (u2(),T9)),K=$.mode;if(!["branch","unstaged","staged","all"].includes(K))r(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:q,head:W}=await I$({mode:K,base:$.base,head:$.head});if($.format!=="json"&&$.format!=="sarif")r(`Invalid format: ${$.format}. Use json or sarif.`),process.exit(1);let V=parseInt($.maxFileBytes,10),U=parseInt($.maxDiffBytes,10),J=$.maxFindings?parseInt($.maxFindings,10):void 0,G=await n1({mode:K,base:q,head:W,includeUntracked:K==="all"||K==="unstaged"}),[B,H]=await Promise.all([Q(),X()]),_=$.profile,O,M,z;if(_==="auto"){let I=y$(G,process.cwd());O=I.profile,M=I.confidence,z=I.reasons}else O=_,M="high",z=[`Profile explicitly set to ${_}`];let A=u1(O),N=await F1(A.analyzers,G);if($.testParity){let{testParityAnalyzer:I}=await Promise.resolve().then(() => (q0(),W2)),f=await I.analyze(G);N.push(...f)}let E=L$(N),w=await Z({changeSet:G,findings:N,riskScore:E,requestedProfile:_,detectedProfile:O,profileConfidence:M,profileReasons:z,filters:{excludes:$.exclude,includes:$.include,redact:$.redact,maxFileBytes:V,maxDiffBytes:U,maxFindings:J},skippedFiles:[],warnings:[],noTimestamp:$.timestamp===!1,repoRoot:B,isDirty:H,mode:K}),T;if($.since)T=await Y({sincePath:$.since,currentFacts:w,mode:K,base:q||null,head:W||null,profile:O,include:$.include,exclude:$.exclude,sinceStrict:$.sinceStrict});else T=w;if($.format==="sarif"&&$.since)throw new F("The --since option cannot be used with --format sarif. Remove --since or choose a different output format.",1);let P;if($.format==="sarif"){let{renderSarif:I}=await Promise.resolve().then(() => (b9(),I9)),f=I(T,G);P=$.pretty?JSON.stringify(f,null,2):JSON.stringify(f)}else P=$.pretty?JSON.stringify(T,null,2):JSON.stringify(T);if($.out){let{writeFile:I,mkdir:f}=await import("node:fs/promises"),{dirname:j}=await import("node:path");await f(j($.out),{recursive:!0}),await I($.out,P,"utf-8"),d(`Facts written to ${$.out}`)}else console.log(P);return}catch(Z){I1(Z)}});function C0($,Z){return Z.concat([$])}g1.command("dump-diff").description("Output prompt-ready git diff with smart exclusions (for AI agents)").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--no-untracked","Exclude untracked files (non-branch modes)").option("--out <path>","Write output to file (creates directories as needed)").option("--format <type>","Output format: text|md|json","text").option("--unified <n>","Lines of unified context (git diff -U)","0").option("--include <glob>","Include only files matching glob (repeatable)",C0,[]).option("--exclude <glob>","Additional exclusion glob (repeatable)",C0,[]).option("--max-chars <n>","Chunk output if it exceeds this size").option("--chunk-dir <path>","Directory for chunk files",".ai/diff-chunks").option("--name <prefix>","Chunk file name prefix","diff").option("--dry-run","Preview what would be included/excluded",!1).option("--name-only","Output only file list (no diffs)",!1).option("--stat","Output file statistics (additions/deletions)",!1).option("--patch-for <path>","Output diff for a specific file only").option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--no-timestamp","Omit generatedAt for deterministic output",!1).action(async($)=>{try{let Z=$.mode;if(!["branch","unstaged","staged","all"].includes(Z))r(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:Q,head:X}=await I$({mode:Z,base:$.base,head:$.head}),Y=$.format;if(!["text","md","json"].includes(Y))r(`Invalid format: ${$.format}. Use text, md, or json.`),process.exit(1);let K=parseInt($.unified,10);if(isNaN(K)||K<0)r(`Invalid unified context: ${$.unified}. Must be a non-negative integer.`),process.exit(1);let q=$.maxChars?parseInt($.maxChars,10):void 0;if(q!==void 0&&(isNaN(q)||q<=0))r(`Invalid max-chars: ${$.maxChars}. Must be a positive integer.`),process.exit(1);let W=$.nameOnly===!0,V=$.stat===!0,U=$.patchFor!==void 0;if([W,V,U].filter(Boolean).length>1)r("Options --name-only, --stat, and --patch-for are mutually exclusive. Use only one at a time."),process.exit(1);await j5({mode:Z,base:Q,head:X,out:$.out,format:Y,unified:K,include:$.include,exclude:$.exclude,maxChars:q,chunkDir:$.chunkDir,name:$.name,dryRun:$.dryRun,includeUntracked:$.untracked!==!1,nameOnly:W,stat:V,patchFor:$.patchFor,pretty:$.pretty,noTimestamp:$.timestamp===!1});return}catch(Z){I1(Z)}});g1.command("risk-report").description("Analyze git diff and emit risk score (0-100) with evidence-backed flags").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--format <type>","Output format: json|md|text","json").option("--out <path>","Write output to file instead of stdout").option("--fail-on-score <n>","Exit with code 2 if risk score >= threshold").option("--only <categories>","Only include these categories (comma-separated)").option("--exclude <categories>","Exclude these categories (comma-separated)").option("--max-evidence-lines <n>","Max evidence lines per flag","5").option("--redact","Redact secret values in evidence",!1).option("--explain-score","Include score breakdown in output",!1).option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--no-timestamp","Omit generatedAt for deterministic output",!1).option("--since <path>","Compare current output to a previous JSON file").option("--since-strict","Exit with code 1 on scope/tool/schema mismatch",!1).option("--test-parity","Enable test parity checking (opt-in, may be slow on large repos)",!1).action(async($)=>{try{let{executeRiskReport:Z,renderRiskReportJSON:Q,renderRiskReportMarkdown:X,renderRiskReportText:Y}=await Promise.resolve().then(() => (L0(),v9)),{computeRiskReportDelta:K}=await Promise.resolve().then(() => (i2(),k9)),q=$.mode;if(!["branch","unstaged","staged","all"].includes(q))r(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:W,head:V}=await I$({mode:q,base:$.base,head:$.head}),U=$.format;if(!["json","md","text"].includes(U))r(`Invalid format: ${$.format}. Use json, md, or text.`),process.exit(1);let J=parseInt($.maxEvidenceLines,10);if(isNaN(J)||J<1)r(`Invalid max-evidence-lines: ${$.maxEvidenceLines}. Must be a positive integer.`),process.exit(1);let G=$.failOnScore?parseInt($.failOnScore,10):void 0;if(G!==void 0&&(isNaN(G)||G<0||G>100))r(`Invalid fail-on-score: ${$.failOnScore}. Must be 0-100.`),process.exit(1);let B=$.only?$.only.split(",").map((z)=>z.trim()):void 0,H=$.exclude?$.exclude.split(",").map((z)=>z.trim()):void 0,_=await n1({mode:q,base:W,head:V,includeUntracked:q==="all"||q==="unstaged"}),O=await Z(_,{only:B,exclude:H,maxEvidenceLines:J,redact:$.redact,explainScore:$.explainScore,noTimestamp:$.timestamp===!1,mode:q,testParity:$.testParity}),M;if($.since){if(U!=="json")r("--since requires --format json (other formats not supported in v1)"),process.exit(1);let z=await K({sincePath:$.since,currentReport:O,mode:q,base:W||null,head:V||null,only:B||null,exclude:H||null,sinceStrict:$.sinceStrict});M=$.pretty?JSON.stringify(z,null,2):JSON.stringify(z)}else switch(U){case"json":M=Q(O,$.pretty);break;case"md":M=X(O);break;case"text":M=Y(O);break}if($.out){let{writeFile:z,mkdir:A}=await import("node:fs/promises"),{dirname:N}=await import("node:path");await A(N($.out),{recursive:!0}),await z($.out,M,"utf-8"),d(`Risk report written to ${$.out}`)}else console.log(M);if(G!==void 0&&O.riskScore>=G){r(`Risk score ${O.riskScore} >= threshold ${G}`),process.exitCode=2;return}return}catch(Z){I1(Z)}});g1.command("zoom").description("Zoom into a specific finding or flag for detailed context").option("--finding <id>","Finding ID to zoom into").option("--flag <id>","Flag ID to zoom into").option("--mode <type>","Diff mode: branch|unstaged|staged|all","unstaged").option("--base <ref>","Base git reference (branch mode only; auto-detected if omitted)").option("--head <ref>","Head git reference (branch mode only; defaults to HEAD)").option("--profile <name>","Profile to use (auto|sveltekit|react|stencil|next)","auto").option("--format <type>","Output format: json|md|text","json").option("--unified <n>","Lines of unified context for patch hunks","3").option("--no-patch","Do not include patch context, only evidence").option("--max-evidence-lines <n>","Max evidence excerpt lines to show","8").option("--redact","Redact obvious secret values in evidence excerpts",!1).option("--out <path>","Write output to file instead of stdout").option("--pretty","Pretty-print JSON with 2-space indentation",!1).option("--no-timestamp","Omit generatedAt for deterministic output").action(async($)=>{try{let{executeZoom:Z}=await Promise.resolve().then(() => (F9(),C9)),{renderZoomJSON:Q,renderZoomMarkdown:X,renderZoomText:Y}=await Promise.resolve().then(() => y9),K=$.mode;if(!["branch","unstaged","staged","all"].includes(K))r(`Invalid mode: ${$.mode}. Use branch, unstaged, staged, or all.`),process.exit(1);let{base:q,head:W}=await I$({mode:K,base:$.base,head:$.head}),V=$.format;if(!["json","md","text"].includes(V))r(`Invalid format: ${$.format}. Use json, md, or text.`),process.exit(1);let U=parseInt($.unified,10);if(isNaN(U)||U<0)r(`Invalid unified context: ${$.unified}. Must be a non-negative integer.`),process.exit(1);let J=parseInt($.maxEvidenceLines,10);if(isNaN(J)||J<1)r(`Invalid max-evidence-lines: ${$.maxEvidenceLines}. Must be a positive integer.`),process.exit(1);let G=await n1({mode:K,base:q,head:W,includeUntracked:K==="all"||K==="unstaged"}),B=await Z(G,{findingId:$.finding,flagId:$.flag,mode:K,base:q,head:W,profile:$.profile,includePatch:$.patch!==!1,unified:U,maxEvidenceLines:J,redact:$.redact,noTimestamp:$.timestamp===!1}),H;switch(V){case"json":H=Q(B,$.pretty);break;case"md":H=X(B);break;case"text":H=Y(B);break}if($.out){let{writeFile:_,mkdir:O}=await import("node:fs/promises"),{dirname:M}=await import("node:path");await O(M($.out),{recursive:!0}),await _($.out,H,"utf-8"),d(`Zoom output written to ${$.out}`)}else console.log(H);return}catch(Z){I1(Z)}});g1.command("integrate [target]").description("Generate provider-specific rules (auto-detects when omitted)").option("--dry-run","Preview what would be written without creating files",!1).option("--force","Overwrite existing files",!1).action(async($,Z)=>{try{let{executeIntegrate:Q}=await Promise.resolve().then(() => (ZZ(),$Z));await Q({target:$,dryRun:Z.dryRun,force:Z.force});return}catch(Q){I1(Q)}});var d$=g1.command("snap").description("Manage local workspace snapshots for agent iteration");d$.command("save [label]").description("Create a new snapshot of current workspace state").option("--out <path>","Write snapshotId to file instead of stdout").action(async($,Z)=>{try{let{executeSnapSave:Q}=await Promise.resolve().then(() => (E$(),x$)),X=await Q({label:$,out:Z.out});if(!Z.out)console.log(X.snapshotId);else d(`Snapshot ${X.snapshotId} saved to ${Z.out}`);return}catch(Q){I1(Q)}});d$.command("list").description("List all snapshots").option("--pretty","Pretty-print JSON with 2-space indentation",!1).action(async($)=>{try{let{executeSnapList:Z,renderSnapListJSON:Q}=await Promise.resolve().then(() => (E$(),x$)),X=await Z();console.log(Q(X,$.pretty));return}catch(Z){I1(Z)}});d$.command("show <snapshotId>").description("Show snapshot details").option("--pretty","Pretty-print JSON with 2-space indentation",!1).action(async($,Z)=>{try{let{executeSnapShow:Q,renderSnapShowJSON:X}=await Promise.resolve().then(() => (E$(),x$)),Y=await Q($);console.log(X(Y,Z.pretty));return}catch(Q){I1(Q)}});d$.command("diff <idA> <idB>").description("Compare two snapshots").option("--pretty","Pretty-print JSON with 2-space indentation",!1).action(async($,Z,Q)=>{try{let{executeSnapDiff:X,renderSnapDiffJSON:Y}=await Promise.resolve().then(() => (E$(),x$)),K=await X($,Z);console.log(Y(K,Q.pretty));return}catch(X){I1(X)}});d$.command("restore <snapshotId>").description("Restore workspace to snapshot state (creates automatic backup first)").action(async($)=>{try{let{executeSnapRestore:Z}=await Promise.resolve().then(() => (E$(),x$)),Q=await Z($);if(d(`Restored to snapshot ${Q.snapshotId}`),d(`Pre-restore backup: ${Q.backupSnapshotId}`),Q.verified)d("Verification: passed");else J$("Verification: patch hashes differ (this may be expected for empty patches)");return}catch(Z){I1(Z)}});function I1($){if($ instanceof F)r(`Error: ${$.message}`),process.exit($.exitCode);if($ instanceof Error){if(r(`Unexpected error: ${$.message}`),process.env.DEBUG)r($.stack||"")}else r("An unexpected error occurred");process.exit(1)}await g1.parseAsync();