@skyramp/testbot-core 0.13.0-v3.140 → 0.13.0-v3.141

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.
package/dist/VERSION.json CHANGED
@@ -1 +1 @@
1
- {"version":"0.13.0-v3.140","commit":"b0529b787dadb62d44790066ae4756fd153f593e"}
1
+ {"version":"0.13.0-v3.141","commit":"2f5b89227aa3caf77214697182eeaf0696bc5f6b"}
package/dist/main.js CHANGED
@@ -428,7 +428,7 @@ ${E.message}`),b(127)}),c.on("exit",()=>l("SIGKILL")),c.on("close",(E,A)=>b(E??(
428
428
  `).filter(Boolean)}function lD(t){return Po(t,["rev-parse","--git-dir"])!==void 0}function uR(t,e){let r=[];if(e)r.push(e),!e.startsWith("origin/")&&!/[~^:@]/.test(e)&&r.push(`origin/${e}`);else{let n=Po(t,["symbolic-ref","--short","refs/remotes/origin/HEAD"]);n&&r.push(n),r.push("main","master")}for(let n of r)if(Po(t,["rev-parse","--verify",`${n}^{commit}`])!==void 0)return n}function fpr(t){let e=[],r=[],n="";for(let s of t.split(`
429
429
  `)){let i=s.match(/^diff --git a\/.+ b\/(.+)$/);if(i){n=i[1];continue}s==="--- /dev/null"&&n?e.push(n):s==="+++ /dev/null"&&n&&r.push(n)}return{newFiles:e,deletedFiles:r}}function uD(t,e){let r=uR(t,e);if(!r)return;let n=Po(t,["merge-base",r,"HEAD"])??r,s=Po(t,["diff",n]);if(s===void 0)return;let i=Po(t,["diff","--stat",n])??"";return{baseRef:r,diffContent:s,diffStat:i,...fpr(s)}}function dy(t,e){if(!lD(t))return;let r=uR(t,e);if(!r)return;let n=Po(t,["rev-parse","--abbrev-ref","HEAD"])??"HEAD",s=new Map,i=Po(t,["diff","--name-status",`${r}...HEAD`]);for(let c of(i??"").split(`
430
430
  `)){if(!c.trim())continue;let[l,...u]=c.split(" "),d=u[u.length-1];d&&s.set(d,l.charAt(0))}let o=Po(t,["status","--porcelain"]);for(let c of(o??"").split(`
431
- `)){if(!c.trim())continue;let l=c.slice(0,2).trim().charAt(0)||"M",u=c.slice(3).trim(),d=u.indexOf(" -> ");d!==-1&&(u=u.slice(d+4)),u&&s.set(u,l==="?"?"A":l)}let a=[...s.entries()].map(([c,l])=>({path:c,status:l})).sort((c,l)=>c.path.localeCompare(l.path));return{currentBranch:n,baseBranch:r,changedFiles:a}}var gpr=y.object({route:y.string().describe('the page this step happens on, e.g. "/products/:id"'),action:y.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:y.array(y.string()).optional().describe("the plan clause ids this step exercises"),check:y.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),cx=(r=>(r.InProcess="in-process",r.Browser="browser",r))(cx||{}),Zot=(n=>(n.Spec="spec",n.PrDescription="pr-description",n.Inferred="inferred",n))(Zot||{}),eat=y.object({id:y.string().describe('e.g. "J1"'),name:y.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:y.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:y.array(gpr).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:y.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:y.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:y.nativeEnum(cx).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:y.nativeEnum(Zot).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:y.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:y.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),vj=y.object({journey:y.string().describe("the plan's journey id"),file:y.string().describe("the browser test file that walks it"),brokeAt:y.object({step:y.number().int().describe("the 1-based step whose check failed first"),expected:y.string(),actual:y.string().describe("what the app did instead, from the runner's output"),notReached:y.array(y.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:y.string().describe("the title of the one test in that file that walks it end to end")}),tat=/\.(tsx|jsx|vue|svelte|astro)$/i,rat=/\.(html?|hbs|handlebars|ejs|erb|jinja2?|j2|njk|twig|pug|liquid|cshtml|razor|mustache)$/i,Apr=/\.(css|scss|sass|less)$/i,ypr=/\.(ts|js|mjs)$/i,bpr=/(^|\/)(components?|pages|views|screens|layouts|frontend|client|ui|templates|src\/app|composables|stores?|hooks|styles?|themes?)\//i,nat=/(^|\/)(__tests__|__mocks__|tests?|e2e|cypress|playwright|spec|stories)\/|\.(test|spec|cy|stories)\.[a-z]+$/i,Epr=/(^|\/)(\.skyramp|\.github|docs?|node_modules|dist|build|coverage)\//i,sat=/^(playwright|cypress)\.config\.[cm]?[jt]s$/;function Xfe(t){return t.filter(e=>{let r=e.replace(/\\/g,"/");return nat.test(r)||Epr.test(r)?!1:tat.test(r)||rat.test(r)||Apr.test(r)||ypr.test(r)&&!/\.d\.ts$/.test(r)&&bpr.test(r)})}var iat=new Set(["node_modules",".git","dist","build",".skyramp",".testbot","coverage","__pycache__",".venv","venv","vendor"]);function Zfe(t,e=4,r=2e4){let n=0,s=(i,o)=>{let a;try{a=Vc.readdirSync(i,{withFileTypes:!0})}catch{return!1}for(let c of a){if(++n>r)return!1;let l=ni.join(i,c.name);if(c.isDirectory()){if(!iat.has(c.name)&&!c.name.startsWith(".")&&o<e&&s(l,o+1))return!0;continue}if(sat.test(c.name))return!0;let u=ni.relative(t,l).split(ni.sep).join("/");if(!nat.test(u)&&(tat.test(c.name)||rat.test(c.name)&&/(^|\/)(templates|views|pages)\//i.test(u)))return!0}return!1};return s(t,0)}var wpr=/"(?:@playwright\/test|cypress|webdriverio|nightwatch|testcafe)"\s*:/,xpr=/^\s*["']?(?:pytest-playwright|pytest-selenium|pytest-splinter)\b/im,Spr=/^(requirements[\w.-]*\.txt|pyproject\.toml|Pipfile|setup\.cfg)$/,Cpr=/^\s*gem\s+["'](?:capybara|cuprite)["']/m,Ipr=["^[[:space:]]*import[[:space:]]+(static[[:space:]]+)?(org\\.openqa\\.selenium|com\\.codeborne\\.selenide)","^[[:space:]]*(from|import)[[:space:]]+(selenium|playwright|splinter)([.[:space:]]|$)",`^[[:space:]]*(import|const|let|var)[^;]*(from[[:space:]]*|require[[:space:]]*\\([[:space:]]*)["'](puppeteer|playwright|selenium-webdriver|webdriverio)["']`,`^[[:space:]]*require[[:space:]]+["']capybara`],vpr=["*.java","*.kt","*.groovy","*.py","*.rb","*.js","*.mjs","*.cjs","*.jsx","*.ts","*.mts","*.cts","*.tsx"],Rpr=/(^|\/)(__tests__|tests?|e2e|cypress|playwright|spec|features)\/|\.(test|spec|cy)\.[a-z]+$|(Test|Tests|IT|ST)\.(java|kt|groovy)$|(^|\/)test_[^/]+\.py$|_test\.py$|_spec\.rb$/;function ehe(t,e=5,r=2e4){let n=0,s=o=>{try{return Vc.statSync(o).size<1e6?Vc.readFileSync(o,"utf-8"):""}catch{return""}},i=(o,a)=>{let c;try{c=Vc.readdirSync(o,{withFileTypes:!0})}catch{return!1}for(let l of c){if(++n>r)return!1;let u=ni.join(o,l.name);if(l.isDirectory()){if(!iat.has(l.name)&&!l.name.startsWith(".")&&a<e&&i(u,a+1))return!0;continue}if(sat.test(l.name)||l.name==="application_system_test_case.rb"||l.name==="package.json"&&wpr.test(s(u))||Spr.test(l.name)&&xpr.test(s(u))||l.name==="Gemfile"&&Cpr.test(s(u)))return!0}return!1};return i(t,0)||Vot(t,Ipr,vpr).some(o=>Rpr.test(o))}var Tpr=/^(\/|#\/|https?:\/\/)/i;function oat(t){let e=`journey ${t.id||"(no id)"}`,r=[];return t.id.trim()||r.push(`${e} has no id`),t.name.trim()||r.push(`${e} has no name`),Tpr.test(t.entry.trim())||r.push(`${e}'s entry "${t.entry}" is not a route (e.g. "/" or "/products")`),t.steps.length<2&&r.push(`${e} has ${t.steps.length} step(s); a journey is at least two steps through the UI`),t.steps.forEach((n,s)=>{n.action.trim()||r.push(`${e} step ${s+1} has no user action`),n.check?.trim()||r.push(`${e} step ${s+1} does not say what the user then sees`)}),t.outcome.trim()||r.push(`${e} has no outcome`),t.testFile.trim()||r.push(`${e} has no testFile`),r}function py(t){let e=new Set;return(t??[]).filter(r=>oat(r).length===0).filter(r=>!e.has(r.id.trim())&&!!e.add(r.id.trim()))}function aat(t,e={}){let r=t??[],n=r.flatMap(oat),s=r.map(o=>o.id.trim()).filter(Boolean);for(let o of new Set(s.filter((a,c)=>s.indexOf(a)!==c)))n.push(`journey id ${o} is used twice`);for(let o of s.filter(a=>e.takenIds?.has(a)))n.push(`journey id ${o} is also a clause or case id; give journeys ids of their own (J1, J2, \u2026)`);for(let o of r)o.steps.forEach((a,c)=>{for(let l of a.clauses??[])e.clauses&&!e.clauses.has(l)&&n.push(`journey ${o.id} step ${c+1} names ${l}, which is not a clause of the plan`)}),o.finishes?.trim()?kpr(o)&&n.push(`journey ${o.id} stops at the step the change alters, and finishes names a later action ("${o.finishes.trim()}"): continue the steps past it to that action, and check after it, on the page, what it produces`):n.push(`journey ${o.id} does not say under finishes the user action that completes the task (save, submit, pick, open, run): name it, and walk the journey on to it`),o.source==="pr-description"&&e.quoted&&!(o.evidence?.trim()&&e.quoted(o.evidence))&&n.push(`journey ${o.id} says the PR description describes it, and its evidence is not quoted from one: quote the words, or mark it inferred`);let i=new Set(r.flatMap(o=>o.steps.flatMap(a=>a.clauses??[])));for(let o of e.uiClauses??[])!i.has(o)&&!e.notInJourney?.has(o)&&n.push(`clause ${o} (what a user sees or does) is in no journey's steps: add it to the step that reaches it, or list it under notInJourney with why no journey reaches it`);return n}var Npr=new Set(["the","a","an","user","they","then","and","to","it","its"]),Wot=t=>dR(t).split(" ").filter(e=>e&&!Npr.has(e)).map(e=>e.replace(/(ing|ed|es|s|e)$/,"").replace(/([^aeiou])\1$/,"$1"));function kpr(t){let e=t.steps.flatMap((n,s)=>n.clauses?.length?[s]:[]);if(e.length!==1||e[0]!==t.steps.length-1)return!1;let r=Wot(t.finishes??"")[0];return r!==void 0&&!Wot(t.steps[t.steps.length-1].action).includes(r)}function pR(t){return t.steps.map((e,r)=>{let n=e.clauses?.length?` [${e.clauses.join(", ")}]`:"",s=e.check?.trim()?`, then sees ${e.check.trim()}`:"";return`${r+1}. ${e.route.trim()?`${e.route.trim()} \u2014 `:""}${e.action.trim()}${n}${s}`}).join("; ")}function cat(t){return t.replace(/\/\*[\s\S]*?\*\//g,e=>e.replace(/[^\n]/g," ")).replace(/^[ \t]*(\/\/|#).*$/gm,e=>" ".repeat(e.length))}function Bpr(t,e){let r=0,n=[];for(let s=e;s<t.length;s++){let i=t[s];if(i==="'"||i==='"')for(s++;s<t.length&&t[s]!==i&&t[s]!==`
431
+ `)){if(!c.trim())continue;let l=c.slice(0,2).trim().charAt(0)||"M",u=c.slice(3).trim(),d=u.indexOf(" -> ");d!==-1&&(u=u.slice(d+4)),u&&s.set(u,l==="?"?"A":l)}let a=[...s.entries()].map(([c,l])=>({path:c,status:l})).sort((c,l)=>c.path.localeCompare(l.path));return{currentBranch:n,baseBranch:r,changedFiles:a}}var gpr=y.object({route:y.string().describe('the page this step happens on, e.g. "/products/:id"'),action:y.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:y.array(y.string()).optional().describe("the plan clause ids this step exercises"),check:y.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),cx=(r=>(r.InProcess="in-process",r.Browser="browser",r))(cx||{}),Zot=(n=>(n.Spec="spec",n.PrDescription="pr-description",n.Inferred="inferred",n))(Zot||{}),eat=y.object({id:y.string().describe('e.g. "J1"'),name:y.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:y.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:y.array(gpr).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:y.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:y.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:y.nativeEnum(cx).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:y.nativeEnum(Zot).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:y.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:y.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),vj=y.object({journey:y.string().describe("the plan's journey id"),file:y.string().describe("the browser test file that walks it"),brokeAt:y.object({step:y.number().int().describe("the 1-based step whose check failed first"),expected:y.string(),actual:y.string().describe("what the app did instead, from the runner's output"),notReached:y.array(y.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:y.string().describe("the title of the one test in that file that walks it end to end")}),tat=/\.(tsx|jsx|vue|svelte|astro)$/i,rat=/\.(html?|hbs|handlebars|ejs|erb|jinja2?|j2|njk|twig|pug|liquid|cshtml|razor|mustache)$/i,Apr=/\.(css|scss|sass|less)$/i,ypr=/\.(ts|js|mjs)$/i,bpr=/(^|\/)(components?|pages|views|screens|layouts|frontend|client|ui|templates|src\/app|composables|stores?|hooks|styles?|themes?)\//i,nat=/(^|\/)(__tests__|__mocks__|tests?|e2e|cypress|playwright|spec|stories)\/|\.(test|spec|cy|stories)\.[a-z]+$/i,Epr=/(^|\/)(\.skyramp|\.github|docs?|node_modules|dist|build|coverage)\//i,sat=/^(playwright|cypress)\.config\.[cm]?[jt]s$/;function Xfe(t){return t.filter(e=>{let r=e.replace(/\\/g,"/");return nat.test(r)||Epr.test(r)?!1:tat.test(r)||rat.test(r)||Apr.test(r)||ypr.test(r)&&!/\.d\.ts$/.test(r)&&bpr.test(r)})}var iat=new Set(["node_modules",".git","dist","build",".skyramp",".testbot","coverage","__pycache__",".venv","venv","vendor"]);function Zfe(t,e=4,r=2e4){let n=0,s=(i,o)=>{let a;try{a=Vc.readdirSync(i,{withFileTypes:!0})}catch{return!1}for(let c of a){if(++n>r)return!1;let l=ni.join(i,c.name);if(c.isDirectory()){if(!iat.has(c.name)&&!c.name.startsWith(".")&&o<e&&s(l,o+1))return!0;continue}if(sat.test(c.name))return!0;let u=ni.relative(t,l).split(ni.sep).join("/");if(!nat.test(u)&&(tat.test(c.name)||rat.test(c.name)&&/(^|\/)(templates|views|pages)\//i.test(u)))return!0}return!1};return s(t,0)}var wpr=/"(?:@playwright\/test|cypress|webdriverio|nightwatch|testcafe)"\s*:/,xpr=/^\s*["']?(?:pytest-playwright|pytest-selenium|pytest-splinter)\b/im,Spr=/^(requirements[\w.-]*\.txt|pyproject\.toml|Pipfile|setup\.cfg)$/,Cpr=/^\s*gem\s+["'](?:capybara|cuprite)["']/m,Ipr=["^[[:space:]]*import[[:space:]]+(static[[:space:]]+)?(org\\.openqa\\.selenium|com\\.codeborne\\.selenide)","^[[:space:]]*(from|import)[[:space:]]+(selenium|playwright|splinter)([.[:space:]]|$)",`^[[:space:]]*(import|const|let|var)[^;]*(from[[:space:]]*|require[[:space:]]*\\([[:space:]]*)["'](puppeteer|playwright|selenium-webdriver|webdriverio)["']`,`^[[:space:]]*require[[:space:]]+["']capybara`],vpr=["*.java","*.kt","*.groovy","*.py","*.rb","*.js","*.mjs","*.cjs","*.jsx","*.ts","*.mts","*.cts","*.tsx"],Rpr=/(^|\/)(__tests__|tests?|e2e|cypress|playwright|spec|features)\/|\.(test|spec|cy)\.[a-z]+$|(Test|Tests|IT|ST)\.(java|kt|groovy)$|(^|\/)test_[^/]+\.py$|_test\.py$|_spec\.rb$/;function ehe(t,e=5,r=2e4){let n=0,s=o=>{try{return Vc.statSync(o).size<1e6?Vc.readFileSync(o,"utf-8"):""}catch{return""}},i=(o,a)=>{let c;try{c=Vc.readdirSync(o,{withFileTypes:!0})}catch{return!1}for(let l of c){if(++n>r)return!1;let u=ni.join(o,l.name);if(l.isDirectory()){if(!iat.has(l.name)&&!l.name.startsWith(".")&&a<e&&i(u,a+1))return!0;continue}if(sat.test(l.name)||l.name==="application_system_test_case.rb"||l.name==="package.json"&&wpr.test(s(u))||Spr.test(l.name)&&xpr.test(s(u))||l.name==="Gemfile"&&Cpr.test(s(u)))return!0}return!1};return i(t,0)||Vot(t,Ipr,vpr).some(o=>Rpr.test(o))}var Tpr=/^(\/|#\/|https?:\/\/)/i;function oat(t){let e=`journey ${t.id||"(no id)"}`,r=[];return t.id.trim()||r.push(`${e} has no id`),t.name.trim()||r.push(`${e} has no name`),Tpr.test(t.entry.trim())||r.push(`${e}'s entry "${t.entry}" is not a route (e.g. "/" or "/products")`),t.steps.length<2&&r.push(`${e} has ${t.steps.length} step(s); a journey is at least two steps through the UI`),t.steps.forEach((n,s)=>{n.action.trim()||r.push(`${e} step ${s+1} has no user action`),n.check?.trim()||r.push(`${e} step ${s+1} does not say what the user then sees`)}),t.outcome.trim()||r.push(`${e} has no outcome`),t.testFile.trim()||r.push(`${e} has no testFile`),r}function py(t){let e=new Set;return(t??[]).filter(r=>oat(r).length===0).filter(r=>!e.has(r.id.trim())&&!!e.add(r.id.trim()))}function aat(t,e={}){let r=t??[],n=r.flatMap(oat),s=r.map(o=>o.id.trim()).filter(Boolean);for(let o of new Set(s.filter((a,c)=>s.indexOf(a)!==c)))n.push(`journey id ${o} is used twice`);for(let o of s.filter(a=>e.takenIds?.has(a)))n.push(`journey id ${o} is also a clause or case id; give journeys ids of their own (J1, J2, \u2026)`);for(let o of r)o.steps.forEach((a,c)=>{for(let l of a.clauses??[])e.clauses&&!e.clauses.has(l)&&n.push(`journey ${o.id} step ${c+1} names ${l}, which is not a clause of the plan`)}),o.finishes?.trim()?kpr(o)&&n.push(`journey ${o.id} stops at the step the change alters, and finishes names a later action ("${o.finishes.trim()}"): continue the steps past it to that action, and check after it, on the page, what it produces`):n.push(`journey ${o.id} does not say under finishes the user action that completes the task (save, submit, pick, open, run): name it, and walk the journey on to it`),o.source==="pr-description"&&e.quoted&&!(o.evidence?.trim()&&e.quoted(o.evidence))&&n.push(`journey ${o.id} says the PR description describes it, and its evidence is not quoted from one: quote the words, or mark it inferred`);let i=new Set(r.flatMap(o=>o.steps.flatMap(a=>a.clauses??[])));for(let o of e.uiClauses??[])!i.has(o)&&!e.notInJourney?.has(o)&&n.push(`clause ${o} (what a user sees or does) is in no journey's steps: add it to the step that reaches it, or list it under notInJourney with why no journey reaches it; a clause whose test calls code directly with no page (a function, hook or module) is type integration, not ui`);return n}var Npr=new Set(["the","a","an","user","they","then","and","to","it","its"]),Wot=t=>dR(t).split(" ").filter(e=>e&&!Npr.has(e)).map(e=>e.replace(/(ing|ed|es|s|e)$/,"").replace(/([^aeiou])\1$/,"$1"));function kpr(t){let e=t.steps.flatMap((n,s)=>n.clauses?.length?[s]:[]);if(e.length!==1||e[0]!==t.steps.length-1)return!1;let r=Wot(t.finishes??"")[0];return r!==void 0&&!Wot(t.steps[t.steps.length-1].action).includes(r)}function pR(t){return t.steps.map((e,r)=>{let n=e.clauses?.length?` [${e.clauses.join(", ")}]`:"",s=e.check?.trim()?`, then sees ${e.check.trim()}`:"";return`${r+1}. ${e.route.trim()?`${e.route.trim()} \u2014 `:""}${e.action.trim()}${n}${s}`}).join("; ")}function cat(t){return t.replace(/\/\*[\s\S]*?\*\//g,e=>e.replace(/[^\n]/g," ")).replace(/^[ \t]*(\/\/|#).*$/gm,e=>" ".repeat(e.length))}function Bpr(t,e){let r=0,n=[];for(let s=e;s<t.length;s++){let i=t[s];if(i==="'"||i==='"')for(s++;s<t.length&&t[s]!==i&&t[s]!==`
432
432
  `;s++)t[s]==="\\"&&s++;else if(i==="`"||i==="}"&&n.length&&n[n.length-1]===r)for(i==="}"&&n.pop(),s++;s<t.length;s++)if(t[s]==="\\")s++;else{if(t[s]==="`")break;if(t[s]==="$"&&t[s+1]==="{"){n.push(r),s++;break}}else if(i==="/"&&t[s+1]==="/")for(;s<t.length&&t[s]!==`
433
433
  `;)s++;else if(i==="/"&&t[s+1]==="*"){let o=t.indexOf("*/",s+2);s=o<0?t.length:o+1}else if(i==="{")r++;else if(i==="}"&&(r--,r===0))return s+1}return t.length}function Ppr(t,e){let r=t.slice(e,e+400),n=r.search(/=>/),s=r.search(/\bfunction\b/);if(n<0&&s<0)return;if(n>=0&&(s<0||n<s)){let a=/^=>\s*\{/.exec(r.slice(n));return a?e+n+a[0].length-1:void 0}let i=r.indexOf("(",s);if(i<0)return;for(let a=0;i<r.length;i++)if(r[i]==="(")a++;else if(r[i]===")"&&--a===0)break;let o=/^\)\s*\{/.exec(r.slice(i));return o?e+i+o[0].length-1:void 0}var _pr=/\b(?:test|it)(?:\.(only|skip|fixme|slow|fail))?\s*\(\s*(['"`])((?:\\.|(?!\2)[^\\])*)\2/g,Dpr=/^([ \t]*)(?:async[ \t]+)?def[ \t]+(test_\w+)[ \t]*\(/gm,Opr=/^[ \t]*(?:(?:test|it|scenario)[ \t]+(['"])((?:\\.|(?!\1)[^\\])*)\1[ \t]+do\b|def[ \t]+(test_\w+))/gm;function Mpr(t){let e=[...t.matchAll(Opr)];return e.map((r,n)=>({title:r[2]??r[3]??"",start:r.index,end:n+1<e.length?e[n+1].index:t.length,skipped:/\bskip\b/.test(t.slice(r.index,n+1<e.length?e[n+1].index:t.length).split(`
434
434
  `).slice(0,3).join(`
@@ -445,7 +445,7 @@ ${f}`);h.length&&d.push(`stubs the app's network (${h.join(", ")}); a journey te
445
445
  file: ${b.file} asserts: ${b.evidence}`}).join(`
446
446
  `)||" (none)",u=[`You are a SKEPTICAL reviewer of generated ${i?"UI (browser)":"backend"} tests. For each case below`,"the generator wrote a test with a cited assertion. Judge whether that","assertion would ACTUALLY discriminate the correct behaviour from the bug the","case targets \u2014 not merely that a request returns 2xx or that a field exists.","Read the test files (Read/Grep are available). Flag an assertion that:"," - is tautological (asserts what the app currently does, nothing sanctioning it),"," - checks only shape/status when the case targets a specific value or state,"," - would NOT fail on the buggy behaviour the case describes, or",` - references a value/response the test never actually exercises${i?",":"."}`,...i?[" - asserts only what the page REPAINTS (DOM text/visibility) after a mutation"," instead of the backend truth (an API read-back) \u2014 a UI that echoes a lying"," server passes such a test \u2014 or uses a locator that was never executed."]:[],"(Judge intent from reading the code \u2014 you have no interpreter, so do not guess at compilation.)","If the tests are genuinely sound, report nothing \u2014 do NOT invent problems.","","Cases + generated assertions:",l,"","Output ONLY this JSON (empty weak[] = the tests are sound):",'{ "weak": [ { "case": "<id>", "problem": "\u2264300 chars", "evidence": "the assertion line or file:line" } ] }'].join(`
447
447
  `),d;try{d=await r(u)}catch{return{name:s,passed:!0}}let{value:p}=Kr(d.stdout);if(!p||typeof p!="object")return{name:s,passed:!0};let m=p.weak,f=Array.isArray(m)?m.filter(b=>!!b&&typeof b.problem=="string"&&!!b.problem.trim()&&typeof b.case=="string"&&c.has(b.case)):[];if(f.length===0)return{name:s,passed:!0};let h=f.slice(0,5).map(b=>`[${b.case??"?"}] ${b.problem} (${b.evidence??""})`).join("; ");return{name:s,passed:!1,details:`skeptic found ${f.length} weak/ineffective assertion(s) \u2014 rewrite each to assert the exact observable that DIFFERS between correct and buggy behaviour: ${h}`}}var $at=(t,e,r)=>Uat(t,e,r,"backend"),qat=(t,e,r)=>Uat(t,e,r,"ui"),Lmr=/\.(spec|test)\.[cm]?[jt]sx?$/i;function Dj(t){let e;try{e=(0,uhe.execFileSync)("git",[...ji,"status","--porcelain","--untracked-files=all"],{env:xt(),cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let r=s=>/_scaffold/i.test(s)||ha.test(s),n=[];for(let s of e.split(`
448
- `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),o=i.indexOf(" -> ");if(o!==-1&&(i=i.slice(o+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let a=i.replace(/^\.\//,"");a.startsWith(".skyramp/")||!r(a)||n.push(a)}return n}function Hat(t){let e=t.inputs.repositoryPath;for(let r of Dj(e)??[])if(/_scaffold/i.test(r)){try{Ei.rmSync(_o.resolve(e,r),{force:!0})}catch{}try{(0,uhe.execFileSync)("git",[...ji,"rm","--cached","-q","--force","--",r],{cwd:e,stdio:"ignore",env:xt()})}catch{}}}function ghe(t){let e=_j[t],r=t==="ui";return{name:`${e.stage}-no-litter`,verify(n){let s=Dj(n.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(o=>Lmr.test(o)===r);return i.length===0?{name:this.name,passed:!0}:ve(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var vIn=ghe("backend");function zat(t,e){let{generate:r,errors:n}=Yc(e,t.secretValues);return tr(t,"generate",r,n)}var su=$(require("fs")),Fs=$(require("path"));function jat(t){return rs(iD,t).errors}function Ahe(t,e=[]){let{value:r,error:n}=Kr(t,e);if(n)return{errors:[n]};let s=jat(r);return s.length>0?{errors:s}:{adapt:r,errors:[]}}var ym="adapt-scratch",Oj=`${ym}/adapt-result.json`;function iu(t,e){let r=Fs.join(t.outputsDir,Oj),n;try{n=su.readFileSync(r,"utf-8")}catch{n=void 0}if(n!==void 0&&(t.secretValues??[]).some(o=>n.includes(o)))return{errors:[`${Oj} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=Ahe(e.stdout,t.secretValues);if(s.adapt)return s;let i=n!==void 0?mm(r):void 0;return i!==void 0&&jat(i).length===0?{adapt:i,errors:[]}:s}function Fmr(t,e){let r=oe(t,e);if(!(!r||!Array.isArray(r.tests)))return r}function Jc(t){let e=i=>t.state.stages[i]?.status==="passed",r=(i,o)=>(Fmr(t,i)?.tests??[]).map(a=>({...a,kind:o})),n=e("generate")?r("generate.json","backend"):[],s=e("generate-ui")?r("generate-ui.json","ui"):[];return[...n,...s]}function Umr(t,e){return t.prepared?.targetDirs?.[e.slug]}function $mr(t,e){return t.prepared?.destinations?.[e]?.repository}var Mj=(t,e)=>`${t}\0${zr(t,e)}`,Vat=Gi("adapt-schema",iu),Wat=/\b(e2e|ui|playwright|cypress)\b/i,Yat=t=>Wat.test(t),Jat=t=>Wat.test(t);function qmr(t){let e=t.match(/^\.+/)?.[0].length??1,r=t.slice(e).replace(/\./g,"/"),n=e===1?"./":"../".repeat(e-1);return r?`${n}${r}`:n}function Gat(t,e){let r=Fs.resolve(t,e),n="";try{n=su.readFileSync(r,"utf-8")}catch{return[]}let s=Fs.dirname(r),i=[],o=[...[...n.matchAll(/(?:from|require\()\s*["'](\.[^"']+)["']/g)].map(a=>a[1]),...[...n.matchAll(/^\s*from\s+(\.[\w.]*)\s+import\b/gm)].map(a=>qmr(a[1]))];for(let a of o){let c=Fs.resolve(s,a);for(let l of[c,...[".ts",".tsx",".js",".jsx",".mjs",".py"].flatMap(u=>[`${c}${u}`,Fs.join(c,`index${u}`)])])try{if(su.statSync(l).isFile()){i.push(l);break}}catch{}}return i}function fy(t,e,r=4){let n=new Set([Fs.resolve(t,e)]),s=Gat(t,e);for(let i=0;i<r&&s.length>0;i++){let o=[];for(let a of s)n.has(a)||(n.add(a),o.push(...Gat(t,Fs.relative(t,a))));s=o}return n.delete(Fs.resolve(t,e)),[...n]}var Kat={name:"adapt-intent",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=t.inputs.repositoryPath,i=new Map;for(let a of r.items)a.action==="place"&&a.from&&i.set(zr(s,a.from),{file:a.file,root:Ls(t.inputs,a.repository)});let o=[];for(let a of Jc(t)){let c=i.get(zr(s,a.file));if(!c)continue;let l=c.file,d=Bj((m=>{try{return su.readFileSync(Fs.resolve(s,m),"utf-8")}catch{return""}})(a.file),a.file),p=Th(c.root,l,fy);if(d===void 0||p===void 0){o.push(`${l}: cannot count assertions in a ${Fs.extname(l)||"extension-less"} file \u2014 no heads for that language (known: ${Object.keys(xR).join(", ")}). Add a row to ASSERTION_HEADS, with a test over a real file.`);continue}d>0&&p<d&&o.push(`${l} makes ${p} assertion(s), but the test generate staged made ${d} \u2014 placement dropped ${d-p}. Moving an assertion into a helper or page object is fine (those are counted too); deleting one is not.`)}return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}},Xat={name:"adapt-placement",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=Jc(t);if(s.length===0)return ve(this.name,["no staged tests from generate/generate-ui \u2014 nothing to place"]);let i=t.inputs.repositoryPath,o=new Map(r.items.filter(c=>c.action==="place"&&c.from).map(c=>[zr(i,c.from),c])),a=[];for(let c of s){let l=zr(i,c.file),u=o.get(l);if(!u){a.push(`staged test "${c.file}" was not placed by adapt`);continue}let d=fm(t.inputs,u.repository);if("error"in d){a.push(`placed test "${u.file}": ${d.error}`);continue}let p=$mr(t,c.file);p&&!nj(p,d.source.slug)&&a.push(`placed test "${u.file}" is in ${d.source.slug}, but it belongs in ${p}, the repository that owns ${c.covers.join(", ")}`);let m=d.source.path,f=zr(m,u.file);d.source.working&&f.startsWith(".skyramp/staged")&&a.push(`placed test "${u.file}" is still in the staging area`);let h=Hmr(m,u.file);if(h){a.push(`placed test "${u.file}" ${h}`);continue}let b=Umr(t,d.source),E=b&&Gmr(f,c.kind,b);E&&a.push(`placed test "${u.file}" ${E}`);let A=b&&zmr(f,b);A&&a.push(`placed test "${u.file}" ${A}`);let w=Fs.resolve(m,u.file);su.existsSync(w)?su.readFileSync(w,"utf-8").trim()||a.push(`placed test "${u.file}" is empty`):a.push(`placed test "${qt(t.inputs,d.source.slug)}${u.file}" does not exist on disk`)}return a.length===0?{name:this.name,passed:!0}:ve(this.name,a)}},yhe=/\.(py|ts|tsx|js|jsx|mjs|cjs|go|java|rb|kt|cs|snap)$/i;function Hmr(t,e){if(!e||!e.trim())return"is empty";if(Fs.isAbsolute(e))return"is an absolute path \u2014 placements are repo-relative";let r=jw(t,e);if(r===void 0)return"resolves outside the repository";if(!yhe.test(r))return"is not a test or support source file (by extension)"}function zmr(t,e){let r=[...e.backend,...e.ui].map(n=>n.replace(/\/+$/,"")).filter(Boolean);if(r.length!==0&&!r.some(n=>n==="."||t===n||t.startsWith(`${n}/`)))return`is outside every target test directory (${r.join(", ")}) \u2014 a test is placed under one of them, never elsewhere in the tree`}function Gmr(t,e,r){if(r.backend.length===0||r.ui.length===0)return;let n=o=>o.some(a=>t===a||t.startsWith(`${a}/`)),s=e==="ui"?r.ui:r.backend,i=e==="ui"?r.backend:r.ui;if(!n(s)&&n(i))return`is a ${e} test placed in the ${e==="ui"?"backend":"UI"} test directory (${i.find(o=>t.startsWith(`${o}/`))}) \u2014 it belongs under ${s.join(" or ")}`}var Zat={name:"adapt-no-extra-placements",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=t.inputs.repositoryPath,i=new Set(Jc(t).map(a=>zr(s,a.file))),o=[];for(let a of r.items)a.action==="place"&&a.from&&!i.has(zr(s,a.from))&&o.push(`placed test from "${a.from}" is not a generate/generate-ui staged output \u2014 refusing to ship an unverified draft (a failed generate stage may have left it behind)`);return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}},ect={name:"adapt-maintenance",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=Xr(t);if(!s)return ve(this.name,["recommend.json not found \u2014 cannot check maintenance"]);let i=new Map;for(let a of r.items)i.set(Mj(Ls(t.inputs,a.repository),a.file),a);let o=[];for(let a of s.maintenance){let c=Ls(t.inputs,a.repository),l=i.get(Mj(c,a.test));if(!l){let d=a.repository?` in ${a.repository}`:"";o.push(`recommend planned ${a.action} on "${a.test}"${d} but adapt did not act on it`);continue}let u=su.existsSync(Fs.resolve(c,a.test));a.action==="delete"&&u&&!l.keptReason?.trim()&&o.push(`"${a.test}" planned for delete still exists \u2014 delete it, or record a keptReason if you preserved it in place`),a.action!=="delete"&&l.action!=="delete"&&!u&&o.push(`"${a.test}" planned for ${a.action} no longer exists`)}return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}},jmr=/ModuleNotFoundError|ImportError|No module named|Cannot find module|cannot import|SyntaxError|is not defined|error collecting|collected 0 items|ENOENT|fixture '.*' not found/i;function Vmr(t,e=t.reran){let r=e!==t.reran,n=t.covers??[],s=e.exit;if(s==null||n.length===0)return[];let i=e.tests;if(i===void 0&&r)return[];if(i===void 0)return[`"${t.file}" covers ${n.length} case(s) but reran.tests is missing \u2014 record each case's own result ({ case, status }), so a red file says WHICH case is red. One exit code for five cases cannot.`];let o=[],a=new Set(i.map(d=>d.case)),c=n.filter(d=>!a.has(d));c.length>0&&!r&&o.push(`"${t.file}" reran.tests does not report case(s) it covers: ${c.join(", ")}`);let l=[...a].filter(d=>!n.includes(d));if(l.length>0&&o.push(`"${t.file}" reran.tests reports case(s) the file does not cover: ${l.join(", ")}`),t.placementBroken){let d=i.filter(p=>p.status!=="skip").map(p=>p.case);return d.length>0?[`"${t.file}" is placementBroken:true \u2014 it could not run \u2014 but reran.tests reports ${d.join(", ")} as ${i.find(p=>p.status!=="skip")?.status}. A case that never executed is "skip", not a result.`]:[]}let u=i.some(d=>d.status==="fail");return s===0&&u&&o.push(`"${t.file}" re-ran exit 0 but reran.tests marks ${i.filter(d=>d.status==="fail").map(d=>d.case).join(", ")} failed \u2014 the two cannot both be true`),s!==0&&!u&&!(r&&c.length)&&o.push(`"${t.file}" re-ran exit ${s} but reran.tests marks no case failed \u2014 record the case that failed, or the non-test reason in details`),o}var Wmr=/(?:^|[\s/])(?:pytest|jest|vitest|mocha|playwright\s+test|node\s+--test|(?:npm|pnpm|yarn)\s+(?:run\s+)?test)(?=\s|$)/;function Ymr(t,e,r){return t.split(/&&|\|\||[;|\n]/).some(n=>{let s=Wmr.exec(n);if(!s||/\b(?:install|add)\b|--version|--help/.test(n))return!1;let i=n.slice(s.index+s[0].length).split(/\s+/).map(o=>o.replace(/^["']|["']$/g,"")).filter(o=>!o.startsWith("-")&&/[./]/.test(o)).map(o=>zr(e,o.replace(/::.*$|:\d+$/,"")));return!i.length||i.some(o=>o===""||o===r||r.startsWith(`${o}/`)||r.endsWith(`/${o}`))})}var tct={name:"adapt-rerun",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=[],i=Gc(t),o=zc(t.inputs),a=Jc(t),c=Cj(Fs.join(t.outputsDir,"adapt-stream.ndjson"));for(let l of r.items){if(l.action==="delete")continue;let u=l.reran,d=u.exit,p=u.details?.trim()??"";if(l.from&&aD(Ej(t.inputs.repositoryPath,a,l.from),o)){d!=null&&s.push(`"${l.file}" runs alone with its declared setup, so the harness runs it: do not run it, and leave reran.exit null`),i&&!l.isolatedRun?.trim()&&s.push(`"${l.file}" runs alone with its declared setup: record isolatedRun, the command that runs only this file`);let m=Ls(t.inputs,l.repository),f=c.find(b=>Ymr(b,m,zr(m,l.file)));f&&s.push(`"${l.file}" runs alone, but the session ran it with other tests (\`${f.slice(0,200)}\`): leave every runs-alone file out of your runs, naming only the other test files`);let h=Pot(t,l);if(h?.exit===null||h?.exit===void 0)continue;u=h,d=h.exit,p=h.details??""}if(d==null){let m=l.action==="place"||l.action==="update"||l.action==="regenerate";i&&m&&(ha.test(l.file)?s.push(`"${l.file}" was not re-run (exit null) although a live SUT is available \u2014 run it and record the exit`):p||s.push(`"${l.file}" is not a runnable test and was not run (exit null) \u2014 say so in reran.details (what it is, and how it was checked)`));continue}d!==0&&!p&&s.push(`"${l.file}" re-ran exit ${d} with no reran.details \u2014 record what failed`);for(let m of Vmr(l,u))s.push(m);if(l.placementBroken&&d===0&&s.push(`"${l.file}" is marked placementBroken:true but re-ran exit 0 \u2014 a passing test is not broken. Clear the flag; if the test cannot observe a bug you believe is there, say so in reran.details (that is a test-quality note, not a placement failure)`),l.repro){d===0&&s.push(`repro "${l.file}" re-ran green (exit 0) \u2014 a repro must still fail after adaptation`);continue}if(d!==0&&!l.placementBroken){if(l.finding){jmr.test(p)&&s.push(`"${l.file}" is marked finding:true but its details read like a placement/harness error ("${p.slice(0,80)}") \u2014 that is placementBroken:true, not a product bug`);continue}ha.test(l.file)&&s.push(`"${l.file}" re-ran exit ${d} but is not classified \u2014 repro:true (meant to fail), finding:true (caught a real bug), or placementBroken:true (placement/harness problem one repair could not fix)`)}}return s.length===0?{name:this.name,passed:!0}:ve(this.name,s)}},rct={name:"adapt-no-litter",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=new Set(r.items.map(o=>Mj(Ls(t.inputs,o.repository),o.file))),i=kt(t.inputs).filter(o=>o.writable).flatMap(o=>(Dj(o.path)??[]).filter(a=>!s.has(Mj(o.path,a))&&!a.startsWith(".skyramp/")).map(a=>`${qt(t.inputs,o.slug)}${a}`));return i.length===0?{name:this.name,passed:!0}:ve(this.name,[`adapt left test-shaped files that are not in items[]: ${i.slice(0,6).join(", ")} \u2014 place them as items or delete them`])}};function nct(t,e){let{adapt:r,errors:n}=iu(t,e);if(r)for(let i of r.items){let o=Ls(t.inputs,i.repository);i.file&&i.action!=="delete"&&(i.assertionCount=Th(o,zr(o,i.file),fy))}let s=tr(t,"adapt",r,n);return su.rmSync(Fs.join(t.inputs.repositoryPath,ns),{recursive:!0,force:!0}),s}var sct=require("child_process"),SD=$(require("fs")),Kc=$(require("path"));var ict=(t,e)=>Yc(e).generate?.tests.map(r=>r.file)??[],oct=(t,e)=>iu(t,e).adapt?.items.filter(r=>r.action!=="delete").map(r=>Kc.resolve(Ls(t.inputs,r.repository),r.file))??[];function CD(t){return hy(t).map(e=>e.path)}function act(t){return hy(t).filter(e=>e.code==="??").map(e=>e.path)}function hy(t){let e;try{e=(0,sct.execFileSync)("git",[...ji,"status","--porcelain","-z","--untracked-files=all"],{env:xt(),cwd:t,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let r=e.split("\0"),n=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.length<4)continue;let o=i.slice(0,2);n.push({code:o,path:i.slice(3)}),(o[0]==="R"||o[0]==="C")&&s++}return n}function sd(t){return new Set((typeof t=="string"?[t]:t).flatMap(e=>CD(e).map(r=>Kc.resolve(e,r))))}function id(t){return kt(t).filter(e=>e.writable).map(e=>e.path)}function bhe(t){return kt(t).map(e=>e.path)}function Jmr(t){return[{prefix:"",root:t.inputs.repositoryPath},...(t.inputs.relatedRepos??[]).map(e=>({prefix:`${Kc.basename(Kc.resolve(e.path))}/`,root:e.path}))]}function Ehe(t,e){let r=Jmr(t).find(n=>n.prefix&&e.startsWith(n.prefix));return r?Kc.resolve(r.root,e.slice(r.prefix.length)):Kc.resolve(t.inputs.repositoryPath,e)}function Kmr(t,e,r){let n=e.replace(/^\.\//,""),s=Kc.resolve(t.inputs.repositoryPath,n),i=Ehe(t,n);return i===s?[s]:[i,...r.has(s)?[s]:[]]}function whe(t){return sd(bhe(t.inputs))}var Xmr=2*1024*1024;function gy(t,e,r=id){return{name:t,verify(n,s){let i=n.secretValues??[];if(i.length===0)return{name:this.name,passed:!0};let o=[];i.some(f=>s.stdout.includes(f))&&o.push("the stage output contains a secret value (token / credential) \u2014 never print it");let a=n.prepared?.secretGateBaseline,c=f=>{let h=rj(n.inputs,f),b=h?Kc.relative(h.path,f):f;return h?`${qt(n.inputs,h.slug)}${b}`:b},l=r(n.inputs).flatMap(f=>CD(f).filter(h=>yhe.test(h)||/\.(env|ya?ml|json|toml|ini|cfg|sh)$/i.test(h)).map(h=>Kc.resolve(f,h))),u=a?l.filter(f=>!a.has(f)):l,d=n.inputs.repositoryPath,p=new Set(CD(d).map(f=>Kc.resolve(d,f))),m=new Set([...e(n,s).flatMap(f=>Kmr(n,f,p)),...u]);for(let f of m){let h=c(f),b="";try{if(!SD.statSync(f).isFile()||SD.statSync(f).size>Xmr)continue;b=SD.readFileSync(f,"utf-8")}catch{continue}i.some(E=>b.includes(E))&&o.push(`${h} contains a secret value \u2014 tests read the token from the environment, never inline it`)}return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}}}var Ht=y.string().trim().min(1),Zmr=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},efr=y.preprocess(Zmr,y.object({id:Ht.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:Ht.describe("one testable part of the requirement"),expected:Ht.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:y.string().optional().describe("only when no test can check this clause here: why"),type:y.nativeEnum(ru).optional().describe("the test that checks this clause: contract / integration (API) or ui"),target:y.string().optional().describe('its "METHOD /path", or the page / flow'),steps:y.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:y.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:y.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:y.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:y.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),tfr=y.object({id:Ht.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:Ht,source:y.nativeEnum(Wc).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:y.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:Ht.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:y.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:y.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:y.array(y.object({spec:Ht.describe("file:line of the spec in the repository"),says:Ht.describe("what the spec says there, in its own words")})).optional().describe("requirement-reference only: each spec in the repository that says otherwise; the item wins, so test what it says"),clauses:y.array(efr)}),rfr=y.object({id:Ht.describe('e.g. "F1"'),file:Ht,line:y.number().optional(),claim:Ht.describe("the defect, in one sentence"),severity:y.nativeEnum(mR),evidence:Ht.describe("the code line, or the probe request and response, that shows it"),conflictsWith:y.array(Ht).optional().describe("requirement or clause ids it violates"),needsApp:y.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),nfr=y.object({id:Ht.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:y.nativeEnum(ru).describe("contract / integration: checks the API; ui: checks what a user sees or does"),target:Ht.describe('"METHOD /path", or the page / flow'),clause:y.string().optional().describe("the clause id this case checks"),finding:y.string().optional().describe("the finding id this case catches"),steps:Ht.describe("what the test does"),expected:Ht.describe("the expected outcome, from the clause"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),sfr=y.object({test:Ht.describe("existing test file"),action:y.nativeEnum(ex),reason:Ht,mutates:y.boolean().optional().describe("true when the maintained test changes state"),clauses:y.array(Ht).optional().describe("the clause ids this test checks")}),cct=y.object({outcome:y.nativeEnum(am).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:y.record(y.string()).optional().describe("service \u2192 base URL of the running app"),health:y.object({url:y.string().optional(),command:y.string().optional(),output:y.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:y.string().optional().describe("command that stops the app"),dependencies:y.record(y.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:y.array(y.string()).optional().describe("what you changed in the recipe"),error:y.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:y.array(y.string()).optional().describe("change-broke-bringup: the changed files to blame")}),Xc=y.object({schemaVersion:y.literal(1),requirements:y.array(tfr),findings:y.array(rfr),cases:y.array(nfr).describe("a second test for a clause, and one case per finding that fails on this branch"),maintenance:y.array(sfr),journeys:y.array(eat).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:y.array(y.object({clause:Ht,why:Ht})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:mx.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:cct.optional().describe("omit when no app was needed or none was started"),summary:Ht.describe("one paragraph: what the change does and where the risk is")}),Che=(r=>(r.Backend="backend",r.Ui="ui",r))(Che||{}),Nh=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Nh||{}),ifr=y.object({file:Ht.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:y.nativeEnum(Che),change:y.nativeEnum(Nh).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:y.array(y.string()).describe("the plan case ids this file tests"),defect:y.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:y.object({requirement:Ht.describe("the requirement or clause id the change deliberately alters"),line:Ht.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:y.object({exit:y.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:y.array(y.object({case:Ht,status:y.nativeEnum(jc),defect:y.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:y.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:y.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail")})).describe("one entry per covered case, from the runner's own output"),details:y.string().optional().describe("what failed and why, or why it was not run")}),assertions:y.array(y.object({case:Ht,evidence:Ht})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:y.array(y.object({name:Ht.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:y.array(Ht).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),run:gR.optional().describe(`for a file you added or updated in a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test): how the run executes only this file's tests, with the repository's own runner writing JUnit XML to ${px}; Testbot re-runs them with it`)}),ofr=y.object({description:Ht.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:y.nativeEnum(mR).optional(),sourceFile:y.string().optional().describe("the app file at fault"),sourceLine:y.number().optional(),test:y.string().optional().describe("the test file that shows it"),finding:y.string().optional().describe("the plan's finding id, when it is one"),requirements:y.array(Ht).optional().describe("the plan's requirement or clause ids it violates")}),Vi=y.object({schemaVersion:y.literal(1),tests:y.array(ifr),notWritten:y.array(y.object({case:Ht,reason:Ht})).describe("every plan case no test covers, and why"),journeys:y.array(vj).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:y.object({command:y.string(),clean:y.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one"),dependenciesAdded:y.array(y.object({package:Ht,manifest:Ht,repository:Ht.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:Ht.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),ciRunsTests:y.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),commit:y.object({message:Ht.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:Ht.describe("at most 72 characters"),prBody:Ht.describe("what the tests cover and what they found")}),report:y.object({summary:Ht.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:y.array(ofr).describe("every defect the tests found"),nextSteps:y.array(y.string())})});function xhe(t,e,r=[]){let{value:n,error:s}=Kr(e,r);return s?{errors:[s]}:rs(t,n)}function wi(t,e,r,n=[]){let s=xhe(t,e,n);if(s.value)return s;let i=ID(r);return i===void 0?s:xhe(t,i,n)}function lct(t,e){let r=new Set(t.cases.map(o=>o.id)),n=t.requirements.flatMap(o=>o.clauses.filter(a=>!a.steps?.trim()||a.skip?!1:r.has(a.id)?(e?.(a.id),!1):!0).map(a=>({id:a.id,type:a.type??"integration",target:a.target?.trim()||o.id,clause:a.id,...a.finding?{finding:a.finding}:{},steps:a.steps.trim(),expected:a.expected,...a.mutates?{mutates:!0}:{}}))),s=[...n,...t.cases],i=hx(s,o=>o.id);return e&&s.filter(o=>!i.includes(o)).forEach(o=>e(o.id)),i.length===t.cases.length&&n.length===0?t:{...t,cases:i}}function uct(t,e){if(!t.journeys)return t;let r=py(t.journeys),n=new Set(t.cases.map(i=>i.id)),s=e?r.filter(i=>!n.has(i.id)).map(i=>({id:i.id,type:"ui",target:i.entry.trim(),steps:`user journey "${i.name.trim()}", one ${i.kind==="in-process"?"in-process":"browser"} test from ${i.entry.trim()} to the outcome: ${pR(i)}`,expected:i.outcome.trim()})):[];return{...t,journeys:r,cases:[...t.cases,...s]}}function dct(t){let e=t.triage;if(e?.decision!=="runtime_required")return t;let r=new Set(e.plan.filter(i=>i.mechanism==="runtime").map(i=>i.behaviorId)),n=new Set([...e.plan,...e.outOfScope??[],...e.gaps].flatMap(i=>i.behaviorId?[i.behaviorId]:[]).filter(i=>!r.has(i))),s=t.cases.filter(i=>!i.clause||!n.has(i.clause));return s.length===t.cases.length?t:{...t,cases:s}}function Qj(t,e){for(let r of e){if(!r)continue;let{value:n}=xhe(t,r);if(n)return n}}function pct(t){if(t)try{let e=JSON.parse(t);if(!e||typeof e!="object"||!("app"in e)||cct.safeParse(e.app).success)return;let{app:r,...n}=e;return JSON.stringify(n)}catch{return}}function ID(t){try{return Ay.readFileSync(t,"utf-8")}catch{return}}function hx(t,e){let r=new Set;return t.filter(n=>{let s=e(n).trim();return r.has(s)?!1:(r.add(s),!0)})}function Ihe(t){return t?.outcome==="clean"||t?.outcome==="recipe-drift"}var mct=(t,e)=>{let r=t.requirement.source==="requirement-reference"?t.requirement.reference?.trim():void 0;return t.code?.trim()?t.code.trim():r?Zu(r,t.requirement.criterion,e):t.requirement.evidence};function vhe(t,e){return hx(t.requirements.flatMap(r=>r.clauses.map(n=>({id:n.id,evidence:mct({...n,requirement:r},e)}))),r=>r.id)}function fct(t,e,r=new Date){let n=hx(t.requirements,m=>m.id),s=hx(n.flatMap(m=>m.clauses.map(f=>({...f,requirement:m}))),m=>m.id),i=new Set(s.map(m=>m.id)),o=hx(t.findings,m=>m.id),a=new Set(o.map(m=>m.id)),c=hx(t.cases,m=>m.id),l=Ihe(t.app),u=s.map(m=>({id:m.id,statement:m.clause,surface:c.find(f=>f.clause===m.id)?.target??m.requirement.id,evidence:mct(m,e.itemNames),satisfies:[m.requirement.id]})),d={schemaVersion:1,repository:e.repository,project:{type:"other",primaryLanguage:"unknown",languages:[],frameworks:[]},services:[],infrastructure:{containerized:!1,hasDockerCompose:!1,composeFiles:[],hasCiCd:!1},diff:{changedFiles:e.changedFiles,nonApplicationOnly:e.nonApplicationOnly,summary:t.summary.slice(0,400)},endpoints:{new:[],modified:[],removed:[]},existingTests:{locations:[]},entityMap:{entities:[],references:[],stateFields:[]},requirements:n.map(m=>({id:m.id,statement:m.statement,source:m.source,evidence:m.evidence})),behaviors:u,findings:o.map(m=>({id:m.id,file:m.file,line:m.line,claim:m.claim,severity:m.severity,evidence:m.evidence,status:"suspected",conflictsWith:m.conflictsWith})),unexamined:[],summary:t.summary},p={schemaVersion:1,mode:l?"full":"static",maintenance:hx(t.maintenance,m=>m.test).map(m=>({test:m.test,action:m.action,evidence:m.reason,...m.mutates?{mutates:!0}:{}})),generate:c.map(m=>({id:m.id,type:m.type,target:m.target,from_behavior:m.clause&&i.has(m.clause)?m.clause:void 0,from_finding:m.finding&&a.has(m.finding)?m.finding:void 0,rationale:s.find(f=>f.id===m.clause)?.clause??o.find(f=>f.id===m.finding)?.claim??afr(t,m.id)??m.steps,expected_observable:m.expected,verifiable:l,...m.mutates?{mutates:!0}:{}})),surfaces:[],budget:{total:c.length,rationale:"planned in one session from the requirements' clauses"},summary:t.summary};return{analyze:d,recommend:p,deploy:t.app?cfr(t.app,e.defaultTeardown,r):void 0}}function afr(t,e){let r=t.journeys?.find(n=>n.id===e);return r?`user journey: ${r.name.trim()}`:void 0}function cfr(t,e,r){return{schemaVersion:1,baseUrls:t.baseUrls,health:t.health?{url:t.health.url,command:t.health.command,output:t.health.output??""}:void 0,teardown:t.teardown?.trim()||e||"true",dependencies:t.dependencies,outcome:t.outcome,recipeFixes:t.recipeFixes,bringupError:t.error?{command:"bring-up",output:t.error}:void 0,suspectFiles:t.suspectFiles,seeded:!1,startedAt:r.toISOString()}}var lfr={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};function ufr(t){return t.result.exit!==null&&t.result.exit!==0||t.result.cases.some(e=>e.status==="fail")}function She(t){let[e,...r]=t.split(`
448
+ `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),o=i.indexOf(" -> ");if(o!==-1&&(i=i.slice(o+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let a=i.replace(/^\.\//,"");a.startsWith(".skyramp/")||!r(a)||n.push(a)}return n}function Hat(t){let e=t.inputs.repositoryPath;for(let r of Dj(e)??[])if(/_scaffold/i.test(r)){try{Ei.rmSync(_o.resolve(e,r),{force:!0})}catch{}try{(0,uhe.execFileSync)("git",[...ji,"rm","--cached","-q","--force","--",r],{cwd:e,stdio:"ignore",env:xt()})}catch{}}}function ghe(t){let e=_j[t],r=t==="ui";return{name:`${e.stage}-no-litter`,verify(n){let s=Dj(n.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(o=>Lmr.test(o)===r);return i.length===0?{name:this.name,passed:!0}:ve(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var vIn=ghe("backend");function zat(t,e){let{generate:r,errors:n}=Yc(e,t.secretValues);return tr(t,"generate",r,n)}var su=$(require("fs")),Fs=$(require("path"));function jat(t){return rs(iD,t).errors}function Ahe(t,e=[]){let{value:r,error:n}=Kr(t,e);if(n)return{errors:[n]};let s=jat(r);return s.length>0?{errors:s}:{adapt:r,errors:[]}}var ym="adapt-scratch",Oj=`${ym}/adapt-result.json`;function iu(t,e){let r=Fs.join(t.outputsDir,Oj),n;try{n=su.readFileSync(r,"utf-8")}catch{n=void 0}if(n!==void 0&&(t.secretValues??[]).some(o=>n.includes(o)))return{errors:[`${Oj} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=Ahe(e.stdout,t.secretValues);if(s.adapt)return s;let i=n!==void 0?mm(r):void 0;return i!==void 0&&jat(i).length===0?{adapt:i,errors:[]}:s}function Fmr(t,e){let r=oe(t,e);if(!(!r||!Array.isArray(r.tests)))return r}function Jc(t){let e=i=>t.state.stages[i]?.status==="passed",r=(i,o)=>(Fmr(t,i)?.tests??[]).map(a=>({...a,kind:o})),n=e("generate")?r("generate.json","backend"):[],s=e("generate-ui")?r("generate-ui.json","ui"):[];return[...n,...s]}function Umr(t,e){return t.prepared?.targetDirs?.[e.slug]}function $mr(t,e){return t.prepared?.destinations?.[e]?.repository}var Mj=(t,e)=>`${t}\0${zr(t,e)}`,Vat=Gi("adapt-schema",iu),Wat=/\b(e2e|ui|playwright|cypress)\b/i,Yat=t=>Wat.test(t),Jat=t=>Wat.test(t);function qmr(t){let e=t.match(/^\.+/)?.[0].length??1,r=t.slice(e).replace(/\./g,"/"),n=e===1?"./":"../".repeat(e-1);return r?`${n}${r}`:n}function Gat(t,e){let r=Fs.resolve(t,e),n="";try{n=su.readFileSync(r,"utf-8")}catch{return[]}let s=Fs.dirname(r),i=[],o=[...[...n.matchAll(/(?:from|require\()\s*["'](\.[^"']+)["']/g)].map(a=>a[1]),...[...n.matchAll(/^\s*from\s+(\.[\w.]*)\s+import\b/gm)].map(a=>qmr(a[1]))];for(let a of o){let c=Fs.resolve(s,a);for(let l of[c,...[".ts",".tsx",".js",".jsx",".mjs",".py"].flatMap(u=>[`${c}${u}`,Fs.join(c,`index${u}`)])])try{if(su.statSync(l).isFile()){i.push(l);break}}catch{}}return i}function fy(t,e,r=4){let n=new Set([Fs.resolve(t,e)]),s=Gat(t,e);for(let i=0;i<r&&s.length>0;i++){let o=[];for(let a of s)n.has(a)||(n.add(a),o.push(...Gat(t,Fs.relative(t,a))));s=o}return n.delete(Fs.resolve(t,e)),[...n]}var Kat={name:"adapt-intent",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=t.inputs.repositoryPath,i=new Map;for(let a of r.items)a.action==="place"&&a.from&&i.set(zr(s,a.from),{file:a.file,root:Ls(t.inputs,a.repository)});let o=[];for(let a of Jc(t)){let c=i.get(zr(s,a.file));if(!c)continue;let l=c.file,d=Bj((m=>{try{return su.readFileSync(Fs.resolve(s,m),"utf-8")}catch{return""}})(a.file),a.file),p=Th(c.root,l,fy);if(d===void 0||p===void 0){o.push(`${l}: cannot count assertions in a ${Fs.extname(l)||"extension-less"} file \u2014 no heads for that language (known: ${Object.keys(xR).join(", ")}). Add a row to ASSERTION_HEADS, with a test over a real file.`);continue}d>0&&p<d&&o.push(`${l} makes ${p} assertion(s), but the test generate staged made ${d} \u2014 placement dropped ${d-p}. Moving an assertion into a helper or page object is fine (those are counted too); deleting one is not.`)}return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}},Xat={name:"adapt-placement",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=Jc(t);if(s.length===0)return ve(this.name,["no staged tests from generate/generate-ui \u2014 nothing to place"]);let i=t.inputs.repositoryPath,o=new Map(r.items.filter(c=>c.action==="place"&&c.from).map(c=>[zr(i,c.from),c])),a=[];for(let c of s){let l=zr(i,c.file),u=o.get(l);if(!u){a.push(`staged test "${c.file}" was not placed by adapt`);continue}let d=fm(t.inputs,u.repository);if("error"in d){a.push(`placed test "${u.file}": ${d.error}`);continue}let p=$mr(t,c.file);p&&!nj(p,d.source.slug)&&a.push(`placed test "${u.file}" is in ${d.source.slug}, but it belongs in ${p}, the repository that owns ${c.covers.join(", ")}`);let m=d.source.path,f=zr(m,u.file);d.source.working&&f.startsWith(".skyramp/staged")&&a.push(`placed test "${u.file}" is still in the staging area`);let h=Hmr(m,u.file);if(h){a.push(`placed test "${u.file}" ${h}`);continue}let b=Umr(t,d.source),E=b&&Gmr(f,c.kind,b);E&&a.push(`placed test "${u.file}" ${E}`);let A=b&&zmr(f,b);A&&a.push(`placed test "${u.file}" ${A}`);let w=Fs.resolve(m,u.file);su.existsSync(w)?su.readFileSync(w,"utf-8").trim()||a.push(`placed test "${u.file}" is empty`):a.push(`placed test "${qt(t.inputs,d.source.slug)}${u.file}" does not exist on disk`)}return a.length===0?{name:this.name,passed:!0}:ve(this.name,a)}},yhe=/\.(py|ts|tsx|js|jsx|mjs|cjs|go|java|rb|kt|cs|snap)$/i;function Hmr(t,e){if(!e||!e.trim())return"is empty";if(Fs.isAbsolute(e))return"is an absolute path \u2014 placements are repo-relative";let r=jw(t,e);if(r===void 0)return"resolves outside the repository";if(!yhe.test(r))return"is not a test or support source file (by extension)"}function zmr(t,e){let r=[...e.backend,...e.ui].map(n=>n.replace(/\/+$/,"")).filter(Boolean);if(r.length!==0&&!r.some(n=>n==="."||t===n||t.startsWith(`${n}/`)))return`is outside every target test directory (${r.join(", ")}) \u2014 a test is placed under one of them, never elsewhere in the tree`}function Gmr(t,e,r){if(r.backend.length===0||r.ui.length===0)return;let n=o=>o.some(a=>t===a||t.startsWith(`${a}/`)),s=e==="ui"?r.ui:r.backend,i=e==="ui"?r.backend:r.ui;if(!n(s)&&n(i))return`is a ${e} test placed in the ${e==="ui"?"backend":"UI"} test directory (${i.find(o=>t.startsWith(`${o}/`))}) \u2014 it belongs under ${s.join(" or ")}`}var Zat={name:"adapt-no-extra-placements",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=t.inputs.repositoryPath,i=new Set(Jc(t).map(a=>zr(s,a.file))),o=[];for(let a of r.items)a.action==="place"&&a.from&&!i.has(zr(s,a.from))&&o.push(`placed test from "${a.from}" is not a generate/generate-ui staged output \u2014 refusing to ship an unverified draft (a failed generate stage may have left it behind)`);return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}},ect={name:"adapt-maintenance",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=Xr(t);if(!s)return ve(this.name,["recommend.json not found \u2014 cannot check maintenance"]);let i=new Map;for(let a of r.items)i.set(Mj(Ls(t.inputs,a.repository),a.file),a);let o=[];for(let a of s.maintenance){let c=Ls(t.inputs,a.repository),l=i.get(Mj(c,a.test));if(!l){let d=a.repository?` in ${a.repository}`:"";o.push(`recommend planned ${a.action} on "${a.test}"${d} but adapt did not act on it`);continue}let u=su.existsSync(Fs.resolve(c,a.test));a.action==="delete"&&u&&!l.keptReason?.trim()&&o.push(`"${a.test}" planned for delete still exists \u2014 delete it, or record a keptReason if you preserved it in place`),a.action!=="delete"&&l.action!=="delete"&&!u&&o.push(`"${a.test}" planned for ${a.action} no longer exists`)}return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}},jmr=/ModuleNotFoundError|ImportError|No module named|Cannot find module|cannot import|SyntaxError|is not defined|error collecting|collected 0 items|ENOENT|fixture '.*' not found/i;function Vmr(t,e=t.reran){let r=e!==t.reran,n=t.covers??[],s=e.exit;if(s==null||n.length===0)return[];let i=e.tests;if(i===void 0&&r)return[];if(i===void 0)return[`"${t.file}" covers ${n.length} case(s) but reran.tests is missing \u2014 record each case's own result ({ case, status }), so a red file says WHICH case is red. One exit code for five cases cannot.`];let o=[],a=new Set(i.map(d=>d.case)),c=n.filter(d=>!a.has(d));c.length>0&&!r&&o.push(`"${t.file}" reran.tests does not report case(s) it covers: ${c.join(", ")}`);let l=[...a].filter(d=>!n.includes(d));if(l.length>0&&o.push(`"${t.file}" reran.tests reports case(s) the file does not cover: ${l.join(", ")}`),t.placementBroken){let d=i.filter(p=>p.status!=="skip").map(p=>p.case);return d.length>0?[`"${t.file}" is placementBroken:true \u2014 it could not run \u2014 but reran.tests reports ${d.join(", ")} as ${i.find(p=>p.status!=="skip")?.status}. A case that never executed is "skip", not a result.`]:[]}let u=i.some(d=>d.status==="fail");return s===0&&u&&o.push(`"${t.file}" re-ran exit 0 but reran.tests marks ${i.filter(d=>d.status==="fail").map(d=>d.case).join(", ")} failed \u2014 the two cannot both be true`),s!==0&&!u&&!(r&&c.length)&&o.push(`"${t.file}" re-ran exit ${s} but reran.tests marks no case failed \u2014 record the case that failed, or the non-test reason in details`),o}var Wmr=/(?:^|[\s/])(?:pytest|jest|vitest|mocha|playwright\s+test|node\s+--test|(?:npm|pnpm|yarn)\s+(?:run\s+)?test)(?=\s|$)/;function Ymr(t,e,r){return t.split(/&&|\|\||[;|\n]/).some(n=>{let s=Wmr.exec(n);if(!s||/\b(?:install|add)\b|--version|--help/.test(n))return!1;let i=n.slice(s.index+s[0].length).split(/\s+/).map(o=>o.replace(/^["']|["']$/g,"")).filter(o=>!o.startsWith("-")&&/[./]/.test(o)).map(o=>zr(e,o.replace(/::.*$|:\d+$/,"")));return!i.length||i.some(o=>o===""||o===r||r.startsWith(`${o}/`)||r.endsWith(`/${o}`))})}var tct={name:"adapt-rerun",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=[],i=Gc(t),o=zc(t.inputs),a=Jc(t),c=Cj(Fs.join(t.outputsDir,"adapt-stream.ndjson"));for(let l of r.items){if(l.action==="delete")continue;let u=l.reran,d=u.exit,p=u.details?.trim()??"";if(l.from&&aD(Ej(t.inputs.repositoryPath,a,l.from),o)){d!=null&&s.push(`"${l.file}" runs alone with its declared setup, so the harness runs it: do not run it, and leave reran.exit null`),i&&!l.isolatedRun?.trim()&&s.push(`"${l.file}" runs alone with its declared setup: record isolatedRun, the command that runs only this file`);let m=Ls(t.inputs,l.repository),f=c.find(b=>Ymr(b,m,zr(m,l.file)));f&&s.push(`"${l.file}" runs alone, but the session ran it with other tests (\`${f.slice(0,200)}\`): leave every runs-alone file out of your runs, naming only the other test files`);let h=Pot(t,l);if(h?.exit===null||h?.exit===void 0)continue;u=h,d=h.exit,p=h.details??""}if(d==null){let m=l.action==="place"||l.action==="update"||l.action==="regenerate";i&&m&&(ha.test(l.file)?s.push(`"${l.file}" was not re-run (exit null) although a live SUT is available \u2014 run it and record the exit`):p||s.push(`"${l.file}" is not a runnable test and was not run (exit null) \u2014 say so in reran.details (what it is, and how it was checked)`));continue}d!==0&&!p&&s.push(`"${l.file}" re-ran exit ${d} with no reran.details \u2014 record what failed`);for(let m of Vmr(l,u))s.push(m);if(l.placementBroken&&d===0&&s.push(`"${l.file}" is marked placementBroken:true but re-ran exit 0 \u2014 a passing test is not broken. Clear the flag; if the test cannot observe a bug you believe is there, say so in reran.details (that is a test-quality note, not a placement failure)`),l.repro){d===0&&s.push(`repro "${l.file}" re-ran green (exit 0) \u2014 a repro must still fail after adaptation`);continue}if(d!==0&&!l.placementBroken){if(l.finding){jmr.test(p)&&s.push(`"${l.file}" is marked finding:true but its details read like a placement/harness error ("${p.slice(0,80)}") \u2014 that is placementBroken:true, not a product bug`);continue}ha.test(l.file)&&s.push(`"${l.file}" re-ran exit ${d} but is not classified \u2014 repro:true (meant to fail), finding:true (caught a real bug), or placementBroken:true (placement/harness problem one repair could not fix)`)}}return s.length===0?{name:this.name,passed:!0}:ve(this.name,s)}},rct={name:"adapt-no-litter",verify(t,e){let{adapt:r,errors:n}=iu(t,e);if(!r)return ve(this.name,n);let s=new Set(r.items.map(o=>Mj(Ls(t.inputs,o.repository),o.file))),i=kt(t.inputs).filter(o=>o.writable).flatMap(o=>(Dj(o.path)??[]).filter(a=>!s.has(Mj(o.path,a))&&!a.startsWith(".skyramp/")).map(a=>`${qt(t.inputs,o.slug)}${a}`));return i.length===0?{name:this.name,passed:!0}:ve(this.name,[`adapt left test-shaped files that are not in items[]: ${i.slice(0,6).join(", ")} \u2014 place them as items or delete them`])}};function nct(t,e){let{adapt:r,errors:n}=iu(t,e);if(r)for(let i of r.items){let o=Ls(t.inputs,i.repository);i.file&&i.action!=="delete"&&(i.assertionCount=Th(o,zr(o,i.file),fy))}let s=tr(t,"adapt",r,n);return su.rmSync(Fs.join(t.inputs.repositoryPath,ns),{recursive:!0,force:!0}),s}var sct=require("child_process"),SD=$(require("fs")),Kc=$(require("path"));var ict=(t,e)=>Yc(e).generate?.tests.map(r=>r.file)??[],oct=(t,e)=>iu(t,e).adapt?.items.filter(r=>r.action!=="delete").map(r=>Kc.resolve(Ls(t.inputs,r.repository),r.file))??[];function CD(t){return hy(t).map(e=>e.path)}function act(t){return hy(t).filter(e=>e.code==="??").map(e=>e.path)}function hy(t){let e;try{e=(0,sct.execFileSync)("git",[...ji,"status","--porcelain","-z","--untracked-files=all"],{env:xt(),cwd:t,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let r=e.split("\0"),n=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.length<4)continue;let o=i.slice(0,2);n.push({code:o,path:i.slice(3)}),(o[0]==="R"||o[0]==="C")&&s++}return n}function sd(t){return new Set((typeof t=="string"?[t]:t).flatMap(e=>CD(e).map(r=>Kc.resolve(e,r))))}function id(t){return kt(t).filter(e=>e.writable).map(e=>e.path)}function bhe(t){return kt(t).map(e=>e.path)}function Jmr(t){return[{prefix:"",root:t.inputs.repositoryPath},...(t.inputs.relatedRepos??[]).map(e=>({prefix:`${Kc.basename(Kc.resolve(e.path))}/`,root:e.path}))]}function Ehe(t,e){let r=Jmr(t).find(n=>n.prefix&&e.startsWith(n.prefix));return r?Kc.resolve(r.root,e.slice(r.prefix.length)):Kc.resolve(t.inputs.repositoryPath,e)}function Kmr(t,e,r){let n=e.replace(/^\.\//,""),s=Kc.resolve(t.inputs.repositoryPath,n),i=Ehe(t,n);return i===s?[s]:[i,...r.has(s)?[s]:[]]}function whe(t){return sd(bhe(t.inputs))}var Xmr=2*1024*1024;function gy(t,e,r=id){return{name:t,verify(n,s){let i=n.secretValues??[];if(i.length===0)return{name:this.name,passed:!0};let o=[];i.some(f=>s.stdout.includes(f))&&o.push("the stage output contains a secret value (token / credential) \u2014 never print it");let a=n.prepared?.secretGateBaseline,c=f=>{let h=rj(n.inputs,f),b=h?Kc.relative(h.path,f):f;return h?`${qt(n.inputs,h.slug)}${b}`:b},l=r(n.inputs).flatMap(f=>CD(f).filter(h=>yhe.test(h)||/\.(env|ya?ml|json|toml|ini|cfg|sh)$/i.test(h)).map(h=>Kc.resolve(f,h))),u=a?l.filter(f=>!a.has(f)):l,d=n.inputs.repositoryPath,p=new Set(CD(d).map(f=>Kc.resolve(d,f))),m=new Set([...e(n,s).flatMap(f=>Kmr(n,f,p)),...u]);for(let f of m){let h=c(f),b="";try{if(!SD.statSync(f).isFile()||SD.statSync(f).size>Xmr)continue;b=SD.readFileSync(f,"utf-8")}catch{continue}i.some(E=>b.includes(E))&&o.push(`${h} contains a secret value \u2014 tests read the token from the environment, never inline it`)}return o.length===0?{name:this.name,passed:!0}:ve(this.name,o)}}}var Ht=y.string().trim().min(1),Zmr=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},efr=y.preprocess(Zmr,y.object({id:Ht.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:Ht.describe("one testable part of the requirement"),expected:Ht.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:y.string().optional().describe("only when no test can check this clause here: why"),type:y.nativeEnum(ru).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:y.string().optional().describe('its "METHOD /path", or the page / flow'),steps:y.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:y.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:y.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:y.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:y.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),tfr=y.object({id:Ht.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:Ht,source:y.nativeEnum(Wc).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:y.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:Ht.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:y.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:y.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:y.array(y.object({spec:Ht.describe("file:line of the spec in the repository"),says:Ht.describe("what the spec says there, in its own words")})).optional().describe("requirement-reference only: each spec in the repository that says otherwise; the item wins, so test what it says"),clauses:y.array(efr)}),rfr=y.object({id:Ht.describe('e.g. "F1"'),file:Ht,line:y.number().optional(),claim:Ht.describe("the defect, in one sentence"),severity:y.nativeEnum(mR),evidence:Ht.describe("the code line, or the probe request and response, that shows it"),conflictsWith:y.array(Ht).optional().describe("requirement or clause ids it violates"),needsApp:y.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),nfr=y.object({id:Ht.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:y.nativeEnum(ru).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:Ht.describe('"METHOD /path", or the page / flow'),clause:y.string().optional().describe("the clause id this case checks"),finding:y.string().optional().describe("the finding id this case catches"),steps:Ht.describe("what the test does"),expected:Ht.describe("the expected outcome, from the clause"),mutates:y.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),sfr=y.object({test:Ht.describe("existing test file"),action:y.nativeEnum(ex),reason:Ht,mutates:y.boolean().optional().describe("true when the maintained test changes state"),clauses:y.array(Ht).optional().describe("the clause ids this test checks")}),cct=y.object({outcome:y.nativeEnum(am).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:y.record(y.string()).optional().describe("service \u2192 base URL of the running app"),health:y.object({url:y.string().optional(),command:y.string().optional(),output:y.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:y.string().optional().describe("command that stops the app"),dependencies:y.record(y.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:y.array(y.string()).optional().describe("what you changed in the recipe"),error:y.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:y.array(y.string()).optional().describe("change-broke-bringup: the changed files to blame")}),Xc=y.object({schemaVersion:y.literal(1),requirements:y.array(tfr),findings:y.array(rfr),cases:y.array(nfr).describe("a second test for a clause, and one case per finding that fails on this branch"),maintenance:y.array(sfr),journeys:y.array(eat).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:y.array(y.object({clause:Ht,why:Ht})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:mx.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:cct.optional().describe("omit when no app was needed or none was started"),summary:Ht.describe("one paragraph: what the change does and where the risk is")}),Che=(r=>(r.Backend="backend",r.Ui="ui",r))(Che||{}),Nh=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(Nh||{}),ifr=y.object({file:Ht.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:y.nativeEnum(Che),change:y.nativeEnum(Nh).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:y.array(y.string()).describe("the plan case ids this file tests"),defect:y.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:y.object({requirement:Ht.describe("the requirement or clause id the change deliberately alters"),line:Ht.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:y.object({exit:y.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:y.array(y.object({case:Ht,status:y.nativeEnum(jc),defect:y.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:y.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:y.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail")})).describe("one entry per covered case, from the runner's own output"),details:y.string().optional().describe("what failed and why, or why it was not run")}),assertions:y.array(y.object({case:Ht,evidence:Ht})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:y.array(y.object({name:Ht.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:y.array(Ht).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),run:gR.optional().describe(`for a file you added or updated in a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test): how the run executes only this file's tests, with the repository's own runner writing JUnit XML to ${px}; Testbot re-runs them with it`)}),ofr=y.object({description:Ht.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:y.nativeEnum(mR).optional(),sourceFile:y.string().optional().describe("the app file at fault"),sourceLine:y.number().optional(),test:y.string().optional().describe("the test file that shows it"),finding:y.string().optional().describe("the plan's finding id, when it is one"),requirements:y.array(Ht).optional().describe("the plan's requirement or clause ids it violates")}),Vi=y.object({schemaVersion:y.literal(1),tests:y.array(ifr),notWritten:y.array(y.object({case:Ht,reason:Ht})).describe("every plan case no test covers, and why"),journeys:y.array(vj).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:y.object({command:y.string(),clean:y.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one"),dependenciesAdded:y.array(y.object({package:Ht,manifest:Ht,repository:Ht.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:Ht.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),ciRunsTests:y.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),commit:y.object({message:Ht.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:Ht.describe("at most 72 characters"),prBody:Ht.describe("what the tests cover and what they found")}),report:y.object({summary:Ht.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:y.array(ofr).describe("every defect the tests found"),nextSteps:y.array(y.string())})});function xhe(t,e,r=[]){let{value:n,error:s}=Kr(e,r);return s?{errors:[s]}:rs(t,n)}function wi(t,e,r,n=[]){let s=xhe(t,e,n);if(s.value)return s;let i=ID(r);return i===void 0?s:xhe(t,i,n)}function lct(t,e){let r=new Set(t.cases.map(o=>o.id)),n=t.requirements.flatMap(o=>o.clauses.filter(a=>!a.steps?.trim()||a.skip?!1:r.has(a.id)?(e?.(a.id),!1):!0).map(a=>({id:a.id,type:a.type??"integration",target:a.target?.trim()||o.id,clause:a.id,...a.finding?{finding:a.finding}:{},steps:a.steps.trim(),expected:a.expected,...a.mutates?{mutates:!0}:{}}))),s=[...n,...t.cases],i=hx(s,o=>o.id);return e&&s.filter(o=>!i.includes(o)).forEach(o=>e(o.id)),i.length===t.cases.length&&n.length===0?t:{...t,cases:i}}function uct(t,e){if(!t.journeys)return t;let r=py(t.journeys),n=new Set(t.cases.map(i=>i.id)),s=e?r.filter(i=>!n.has(i.id)).map(i=>({id:i.id,type:"ui",target:i.entry.trim(),steps:`user journey "${i.name.trim()}", one ${i.kind==="in-process"?"in-process":"browser"} test from ${i.entry.trim()} to the outcome: ${pR(i)}`,expected:i.outcome.trim()})):[];return{...t,journeys:r,cases:[...t.cases,...s]}}function dct(t){let e=t.triage;if(e?.decision!=="runtime_required")return t;let r=new Set(e.plan.filter(i=>i.mechanism==="runtime").map(i=>i.behaviorId)),n=new Set([...e.plan,...e.outOfScope??[],...e.gaps].flatMap(i=>i.behaviorId?[i.behaviorId]:[]).filter(i=>!r.has(i))),s=t.cases.filter(i=>!i.clause||!n.has(i.clause));return s.length===t.cases.length?t:{...t,cases:s}}function Qj(t,e){for(let r of e){if(!r)continue;let{value:n}=xhe(t,r);if(n)return n}}function pct(t){if(t)try{let e=JSON.parse(t);if(!e||typeof e!="object"||!("app"in e)||cct.safeParse(e.app).success)return;let{app:r,...n}=e;return JSON.stringify(n)}catch{return}}function ID(t){try{return Ay.readFileSync(t,"utf-8")}catch{return}}function hx(t,e){let r=new Set;return t.filter(n=>{let s=e(n).trim();return r.has(s)?!1:(r.add(s),!0)})}function Ihe(t){return t?.outcome==="clean"||t?.outcome==="recipe-drift"}var mct=(t,e)=>{let r=t.requirement.source==="requirement-reference"?t.requirement.reference?.trim():void 0;return t.code?.trim()?t.code.trim():r?Zu(r,t.requirement.criterion,e):t.requirement.evidence};function vhe(t,e){return hx(t.requirements.flatMap(r=>r.clauses.map(n=>({id:n.id,evidence:mct({...n,requirement:r},e)}))),r=>r.id)}function fct(t,e,r=new Date){let n=hx(t.requirements,m=>m.id),s=hx(n.flatMap(m=>m.clauses.map(f=>({...f,requirement:m}))),m=>m.id),i=new Set(s.map(m=>m.id)),o=hx(t.findings,m=>m.id),a=new Set(o.map(m=>m.id)),c=hx(t.cases,m=>m.id),l=Ihe(t.app),u=s.map(m=>({id:m.id,statement:m.clause,surface:c.find(f=>f.clause===m.id)?.target??m.requirement.id,evidence:mct(m,e.itemNames),satisfies:[m.requirement.id]})),d={schemaVersion:1,repository:e.repository,project:{type:"other",primaryLanguage:"unknown",languages:[],frameworks:[]},services:[],infrastructure:{containerized:!1,hasDockerCompose:!1,composeFiles:[],hasCiCd:!1},diff:{changedFiles:e.changedFiles,nonApplicationOnly:e.nonApplicationOnly,summary:t.summary.slice(0,400)},endpoints:{new:[],modified:[],removed:[]},existingTests:{locations:[]},entityMap:{entities:[],references:[],stateFields:[]},requirements:n.map(m=>({id:m.id,statement:m.statement,source:m.source,evidence:m.evidence})),behaviors:u,findings:o.map(m=>({id:m.id,file:m.file,line:m.line,claim:m.claim,severity:m.severity,evidence:m.evidence,status:"suspected",conflictsWith:m.conflictsWith})),unexamined:[],summary:t.summary},p={schemaVersion:1,mode:l?"full":"static",maintenance:hx(t.maintenance,m=>m.test).map(m=>({test:m.test,action:m.action,evidence:m.reason,...m.mutates?{mutates:!0}:{}})),generate:c.map(m=>({id:m.id,type:m.type,target:m.target,from_behavior:m.clause&&i.has(m.clause)?m.clause:void 0,from_finding:m.finding&&a.has(m.finding)?m.finding:void 0,rationale:s.find(f=>f.id===m.clause)?.clause??o.find(f=>f.id===m.finding)?.claim??afr(t,m.id)??m.steps,expected_observable:m.expected,verifiable:l,...m.mutates?{mutates:!0}:{}})),surfaces:[],budget:{total:c.length,rationale:"planned in one session from the requirements' clauses"},summary:t.summary};return{analyze:d,recommend:p,deploy:t.app?cfr(t.app,e.defaultTeardown,r):void 0}}function afr(t,e){let r=t.journeys?.find(n=>n.id===e);return r?`user journey: ${r.name.trim()}`:void 0}function cfr(t,e,r){return{schemaVersion:1,baseUrls:t.baseUrls,health:t.health?{url:t.health.url,command:t.health.command,output:t.health.output??""}:void 0,teardown:t.teardown?.trim()||e||"true",dependencies:t.dependencies,outcome:t.outcome,recipeFixes:t.recipeFixes,bringupError:t.error?{command:"bring-up",output:t.error}:void 0,suspectFiles:t.suspectFiles,seeded:!1,startedAt:r.toISOString()}}var lfr={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};function ufr(t){return t.result.exit!==null&&t.result.exit!==0||t.result.cases.some(e=>e.status==="fail")}function She(t){let[e,...r]=t.split(`
449
449
  `);return[e.length<=my?e:`${e.slice(0,my-1).trimEnd()}\u2026`,...r].join(`
450
450
  `)}function hct(t,e,r=[]){let n=[],s=[],i=[],o=new Set,a=new Map([...r].reverse().map(A=>{let w=Aa.basename(Aa.resolve(A.path));return[w,{name:w,root:Aa.resolve(A.path),slug:A.slug}]})),c=new Map,l=[],u=A=>`${A.repository??""}\0${A.file}`,d=new Map,p=A=>d.get(A)??d.set(A,new Set(CD(A))).get(A);for(let A of t.tests){let w=e,C=zr(e,A.file),R,N,T=A.file.replace(/^\.\//,"").split("/")[0],Q=Aa.resolve(e,A.file),k=[...a.values()].find(z=>Q.startsWith(z.root+Aa.sep)),M=A.file.replace(/^\.\//,"").slice(T.length+1),F=a.get(T),X=F!==void 0&&Ay.existsSync(Aa.join(F.root,M)),H=F!==void 0&&(!Ay.existsSync(Aa.join(e,T))||!Ay.existsSync(Q)&&X);if(F&&X&&Ay.existsSync(Q)&&Aa.join(F.root,M)!==Q){let z=p(F.root).has(zr(F.root,M)),B=p(e).has(zr(e,A.file));z&&!B?H=!0:z===B&&s.push(A.file)}if(H?({name:N,root:w,slug:R}=F,C=zr(w,M)):k&&({name:N,root:w,slug:R}=k,C=zr(w,Q)),!C||C.startsWith("..")||Aa.isAbsolute(C)){n.push(A.file);continue}if(A.change!=="deleted"&&!Ay.existsSync(Aa.join(w,C))){n.push(A.file);continue}let q={...A,file:C,shown:N?`${N}/${C}`:C,...R?{repository:R}:{}};o.has(u(q))||(o.add(u(q)),c.set(u(q),w),i.push(q),l.push({written:A.file,root:w,file:C,...R?{repository:R}:{}}))}let m=i.map(A=>{let w=lfr[A.change];return{...w==="place"?{from:A.shown}:{},file:A.file,...A.repository?{repository:A.repository}:{},action:w,covers:A.covers,...A.defect&&ufr(A)?{finding:!0}:{},reran:{exit:A.result.exit,details:A.result.details,tests:A.result.cases},...w==="delete"?{}:{assertionCount:Th(c.get(u(A)),A.file,fy)}}}),f=A=>({schemaVersion:1,tests:i.filter(w=>w.kind===A&&w.change==="added").map(w=>({file:w.shown,source:"llm",language:Zw(w.file)??"unknown",covers:w.covers,assertions:w.assertions??[]})),deferredUi:[],summary:t.report.summary}),h=t.lint?.command?.trim()??"",b=t.lint?.clean??!0,E={schemaVersion:1,lint:h?[{tool:h.split(/\s+/)[0],command:h,clean:b,uncovered:[]}]:[],fileConventions:{ok:!0},ciReadiness:{covered:t.ciRunsTests??!0},dependencies:{added:t.dependenciesAdded??[]},commit:{message:She(t.commit.message)},pr:{title:She(t.commit.prTitle).split(`
451
451
  `)[0],body:t.commit.prBody},ready:b,blockers:b?[]:[`the linter (${h||"the repo's linter"}) still reports problems in the test files`],summary:t.report.summary};return{adapt:{schemaVersion:1,items:m,ignored:[],summary:t.report.summary},generate:f("backend"),generateUi:f("ui"),finalize:E,dropped:n,ambiguous:s,placed:l}}function Rhe(t){let e=[...new Set([...t.tests,...t.maintained??[]].map(o=>o.file))],r=`${e.length} unit test file(s): ${e.join(", ")}`,n=She(t.commitMessage?.trim()||"Skyramp Testbot: add unit tests"),s=t.lint?.command?.trim()??"",i=t.lint?.clean??!0;return{schemaVersion:1,lint:s?[{tool:s.split(/\s+/)[0],command:s,clean:i,uncovered:[]}]:[],fileConventions:{ok:!0},ciReadiness:{covered:!0},dependencies:{added:[]},commit:{message:n},pr:{title:n.split(`
package/dist/post.js CHANGED
@@ -237,7 +237,7 @@ ${w.message}`),C(127)}),c.on("exit",()=>l("SIGKILL")),c.on("close",(w,b)=>C(w??(
237
237
  `).filter(Boolean)}function Cx(e){return xs(e,["rev-parse","--git-dir"])!==void 0}function Qb(e,t){let r=[];if(t)r.push(t),!t.startsWith("origin/")&&!/[~^:@]/.test(t)&&r.push(`origin/${t}`);else{let n=xs(e,["symbolic-ref","--short","refs/remotes/origin/HEAD"]);n&&r.push(n),r.push("main","master")}for(let n of r)if(xs(e,["rev-parse","--verify",`${n}^{commit}`])!==void 0)return n}function SCt(e){let t=[],r=[],n="";for(let s of e.split(`
238
238
  `)){let i=s.match(/^diff --git a\/.+ b\/(.+)$/);if(i){n=i[1];continue}s==="--- /dev/null"&&n?t.push(n):s==="+++ /dev/null"&&n&&r.push(n)}return{newFiles:t,deletedFiles:r}}function Sx(e,t){let r=Qb(e,t);if(!r)return;let n=xs(e,["merge-base",r,"HEAD"])??r,s=xs(e,["diff",n]);if(s===void 0)return;let i=xs(e,["diff","--stat",n])??"";return{baseRef:r,diffContent:s,diffStat:i,...SCt(s)}}function tf(e,t){if(!Cx(e))return;let r=Qb(e,t);if(!r)return;let n=xs(e,["rev-parse","--abbrev-ref","HEAD"])??"HEAD",s=new Map,i=xs(e,["diff","--name-status",`${r}...HEAD`]);for(let c of(i??"").split(`
239
239
  `)){if(!c.trim())continue;let[l,...u]=c.split(" "),d=u[u.length-1];d&&s.set(d,l.charAt(0))}let o=xs(e,["status","--porcelain"]);for(let c of(o??"").split(`
240
- `)){if(!c.trim())continue;let l=c.slice(0,2).trim().charAt(0)||"M",u=c.slice(3).trim(),d=u.indexOf(" -> ");d!==-1&&(u=u.slice(d+4)),u&&s.set(u,l==="?"?"A":l)}let a=[...s.entries()].map(([c,l])=>({path:c,status:l})).sort((c,l)=>c.path.localeCompare(l.path));return{currentBranch:n,baseBranch:r,changedFiles:a}}var xCt=g.object({route:g.string().describe('the page this step happens on, e.g. "/products/:id"'),action:g.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:g.array(g.string()).optional().describe("the plan clause ids this step exercises"),check:g.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),Um=(r=>(r.InProcess="in-process",r.Browser="browser",r))(Um||{}),qTe=(n=>(n.Spec="spec",n.PrDescription="pr-description",n.Inferred="inferred",n))(qTe||{}),GTe=g.object({id:g.string().describe('e.g. "J1"'),name:g.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:g.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:g.array(xCt).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:g.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:g.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:g.nativeEnum(Um).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:g.nativeEnum(qTe).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:g.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:g.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),FQ=g.object({journey:g.string().describe("the plan's journey id"),file:g.string().describe("the browser test file that walks it"),brokeAt:g.object({step:g.number().int().describe("the 1-based step whose check failed first"),expected:g.string(),actual:g.string().describe("what the app did instead, from the runner's output"),notReached:g.array(g.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:g.string().describe("the title of the one test in that file that walks it end to end")}),HTe=/\.(tsx|jsx|vue|svelte|astro)$/i,jTe=/\.(html?|hbs|handlebars|ejs|erb|jinja2?|j2|njk|twig|pug|liquid|cshtml|razor|mustache)$/i,vCt=/\.(css|scss|sass|less)$/i,RCt=/\.(ts|js|mjs)$/i,kCt=/(^|\/)(components?|pages|views|screens|layouts|frontend|client|ui|templates|src\/app|composables|stores?|hooks|styles?|themes?)\//i,zTe=/(^|\/)(__tests__|__mocks__|tests?|e2e|cypress|playwright|spec|stories)\/|\.(test|spec|cy|stories)\.[a-z]+$/i,BCt=/(^|\/)(\.skyramp|\.github|docs?|node_modules|dist|build|coverage)\//i,VTe=/^(playwright|cypress)\.config\.[cm]?[jt]s$/;function K4(e){return e.filter(t=>{let r=t.replace(/\\/g,"/");return zTe.test(r)||BCt.test(r)?!1:HTe.test(r)||jTe.test(r)||vCt.test(r)||RCt.test(r)&&!/\.d\.ts$/.test(r)&&kCt.test(r)})}var WTe=new Set(["node_modules",".git","dist","build",".skyramp",".testbot","coverage","__pycache__",".venv","venv","vendor"]);function X4(e,t=4,r=2e4){let n=0,s=(i,o)=>{let a;try{a=fo.readdirSync(i,{withFileTypes:!0})}catch{return!1}for(let c of a){if(++n>r)return!1;let l=mn.join(i,c.name);if(c.isDirectory()){if(!WTe.has(c.name)&&!c.name.startsWith(".")&&o<t&&s(l,o+1))return!0;continue}if(VTe.test(c.name))return!0;let u=mn.relative(e,l).split(mn.sep).join("/");if(!zTe.test(u)&&(HTe.test(c.name)||jTe.test(c.name)&&/(^|\/)(templates|views|pages)\//i.test(u)))return!0}return!1};return s(e,0)}var TCt=/"(?:@playwright\/test|cypress|webdriverio|nightwatch|testcafe)"\s*:/,NCt=/^\s*["']?(?:pytest-playwright|pytest-selenium|pytest-splinter)\b/im,_Ct=/^(requirements[\w.-]*\.txt|pyproject\.toml|Pipfile|setup\.cfg)$/,PCt=/^\s*gem\s+["'](?:capybara|cuprite)["']/m,QCt=["^[[:space:]]*import[[:space:]]+(static[[:space:]]+)?(org\\.openqa\\.selenium|com\\.codeborne\\.selenide)","^[[:space:]]*(from|import)[[:space:]]+(selenium|playwright|splinter)([.[:space:]]|$)",`^[[:space:]]*(import|const|let|var)[^;]*(from[[:space:]]*|require[[:space:]]*\\([[:space:]]*)["'](puppeteer|playwright|selenium-webdriver|webdriverio)["']`,`^[[:space:]]*require[[:space:]]+["']capybara`],DCt=["*.java","*.kt","*.groovy","*.py","*.rb","*.js","*.mjs","*.cjs","*.jsx","*.ts","*.mts","*.cts","*.tsx"],OCt=/(^|\/)(__tests__|tests?|e2e|cypress|playwright|spec|features)\/|\.(test|spec|cy)\.[a-z]+$|(Test|Tests|IT|ST)\.(java|kt|groovy)$|(^|\/)test_[^/]+\.py$|_test\.py$|_spec\.rb$/;function Z4(e,t=5,r=2e4){let n=0,s=o=>{try{return fo.statSync(o).size<1e6?fo.readFileSync(o,"utf-8"):""}catch{return""}},i=(o,a)=>{let c;try{c=fo.readdirSync(o,{withFileTypes:!0})}catch{return!1}for(let l of c){if(++n>r)return!1;let u=mn.join(o,l.name);if(l.isDirectory()){if(!WTe.has(l.name)&&!l.name.startsWith(".")&&a<t&&i(u,a+1))return!0;continue}if(VTe.test(l.name)||l.name==="application_system_test_case.rb"||l.name==="package.json"&&TCt.test(s(u))||_Ct.test(l.name)&&NCt.test(s(u))||l.name==="Gemfile"&&PCt.test(s(u)))return!0}return!1};return i(e,0)||OTe(e,QCt,DCt).some(o=>OCt.test(o))}var MCt=/^(\/|#\/|https?:\/\/)/i;function JTe(e){let t=`journey ${e.id||"(no id)"}`,r=[];return e.id.trim()||r.push(`${t} has no id`),e.name.trim()||r.push(`${t} has no name`),MCt.test(e.entry.trim())||r.push(`${t}'s entry "${e.entry}" is not a route (e.g. "/" or "/products")`),e.steps.length<2&&r.push(`${t} has ${e.steps.length} step(s); a journey is at least two steps through the UI`),e.steps.forEach((n,s)=>{n.action.trim()||r.push(`${t} step ${s+1} has no user action`),n.check?.trim()||r.push(`${t} step ${s+1} does not say what the user then sees`)}),e.outcome.trim()||r.push(`${t} has no outcome`),e.testFile.trim()||r.push(`${t} has no testFile`),r}function rf(e){let t=new Set;return(e??[]).filter(r=>JTe(r).length===0).filter(r=>!t.has(r.id.trim())&&!!t.add(r.id.trim()))}function YTe(e,t={}){let r=e??[],n=r.flatMap(JTe),s=r.map(o=>o.id.trim()).filter(Boolean);for(let o of new Set(s.filter((a,c)=>s.indexOf(a)!==c)))n.push(`journey id ${o} is used twice`);for(let o of s.filter(a=>t.takenIds?.has(a)))n.push(`journey id ${o} is also a clause or case id; give journeys ids of their own (J1, J2, \u2026)`);for(let o of r)o.steps.forEach((a,c)=>{for(let l of a.clauses??[])t.clauses&&!t.clauses.has(l)&&n.push(`journey ${o.id} step ${c+1} names ${l}, which is not a clause of the plan`)}),o.finishes?.trim()?LCt(o)&&n.push(`journey ${o.id} stops at the step the change alters, and finishes names a later action ("${o.finishes.trim()}"): continue the steps past it to that action, and check after it, on the page, what it produces`):n.push(`journey ${o.id} does not say under finishes the user action that completes the task (save, submit, pick, open, run): name it, and walk the journey on to it`),o.source==="pr-description"&&t.quoted&&!(o.evidence?.trim()&&t.quoted(o.evidence))&&n.push(`journey ${o.id} says the PR description describes it, and its evidence is not quoted from one: quote the words, or mark it inferred`);let i=new Set(r.flatMap(o=>o.steps.flatMap(a=>a.clauses??[])));for(let o of t.uiClauses??[])!i.has(o)&&!t.notInJourney?.has(o)&&n.push(`clause ${o} (what a user sees or does) is in no journey's steps: add it to the step that reaches it, or list it under notInJourney with why no journey reaches it`);return n}var FCt=new Set(["the","a","an","user","they","then","and","to","it","its"]),MTe=e=>Db(e).split(" ").filter(t=>t&&!FCt.has(t)).map(t=>t.replace(/(ing|ed|es|s|e)$/,"").replace(/([^aeiou])\1$/,"$1"));function LCt(e){let t=e.steps.flatMap((n,s)=>n.clauses?.length?[s]:[]);if(t.length!==1||t[0]!==e.steps.length-1)return!1;let r=MTe(e.finishes??"")[0];return r!==void 0&&!MTe(e.steps[e.steps.length-1].action).includes(r)}function Ob(e){return e.steps.map((t,r)=>{let n=t.clauses?.length?` [${t.clauses.join(", ")}]`:"",s=t.check?.trim()?`, then sees ${t.check.trim()}`:"";return`${r+1}. ${t.route.trim()?`${t.route.trim()} \u2014 `:""}${t.action.trim()}${n}${s}`}).join("; ")}function KTe(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/^[ \t]*(\/\/|#).*$/gm,t=>" ".repeat(t.length))}function UCt(e,t){let r=0,n=[];for(let s=t;s<e.length;s++){let i=e[s];if(i==="'"||i==='"')for(s++;s<e.length&&e[s]!==i&&e[s]!==`
240
+ `)){if(!c.trim())continue;let l=c.slice(0,2).trim().charAt(0)||"M",u=c.slice(3).trim(),d=u.indexOf(" -> ");d!==-1&&(u=u.slice(d+4)),u&&s.set(u,l==="?"?"A":l)}let a=[...s.entries()].map(([c,l])=>({path:c,status:l})).sort((c,l)=>c.path.localeCompare(l.path));return{currentBranch:n,baseBranch:r,changedFiles:a}}var xCt=g.object({route:g.string().describe('the page this step happens on, e.g. "/products/:id"'),action:g.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:g.array(g.string()).optional().describe("the plan clause ids this step exercises"),check:g.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),Um=(r=>(r.InProcess="in-process",r.Browser="browser",r))(Um||{}),qTe=(n=>(n.Spec="spec",n.PrDescription="pr-description",n.Inferred="inferred",n))(qTe||{}),GTe=g.object({id:g.string().describe('e.g. "J1"'),name:g.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:g.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:g.array(xCt).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:g.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:g.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:g.nativeEnum(Um).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:g.nativeEnum(qTe).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:g.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:g.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),FQ=g.object({journey:g.string().describe("the plan's journey id"),file:g.string().describe("the browser test file that walks it"),brokeAt:g.object({step:g.number().int().describe("the 1-based step whose check failed first"),expected:g.string(),actual:g.string().describe("what the app did instead, from the runner's output"),notReached:g.array(g.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:g.string().describe("the title of the one test in that file that walks it end to end")}),HTe=/\.(tsx|jsx|vue|svelte|astro)$/i,jTe=/\.(html?|hbs|handlebars|ejs|erb|jinja2?|j2|njk|twig|pug|liquid|cshtml|razor|mustache)$/i,vCt=/\.(css|scss|sass|less)$/i,RCt=/\.(ts|js|mjs)$/i,kCt=/(^|\/)(components?|pages|views|screens|layouts|frontend|client|ui|templates|src\/app|composables|stores?|hooks|styles?|themes?)\//i,zTe=/(^|\/)(__tests__|__mocks__|tests?|e2e|cypress|playwright|spec|stories)\/|\.(test|spec|cy|stories)\.[a-z]+$/i,BCt=/(^|\/)(\.skyramp|\.github|docs?|node_modules|dist|build|coverage)\//i,VTe=/^(playwright|cypress)\.config\.[cm]?[jt]s$/;function K4(e){return e.filter(t=>{let r=t.replace(/\\/g,"/");return zTe.test(r)||BCt.test(r)?!1:HTe.test(r)||jTe.test(r)||vCt.test(r)||RCt.test(r)&&!/\.d\.ts$/.test(r)&&kCt.test(r)})}var WTe=new Set(["node_modules",".git","dist","build",".skyramp",".testbot","coverage","__pycache__",".venv","venv","vendor"]);function X4(e,t=4,r=2e4){let n=0,s=(i,o)=>{let a;try{a=fo.readdirSync(i,{withFileTypes:!0})}catch{return!1}for(let c of a){if(++n>r)return!1;let l=mn.join(i,c.name);if(c.isDirectory()){if(!WTe.has(c.name)&&!c.name.startsWith(".")&&o<t&&s(l,o+1))return!0;continue}if(VTe.test(c.name))return!0;let u=mn.relative(e,l).split(mn.sep).join("/");if(!zTe.test(u)&&(HTe.test(c.name)||jTe.test(c.name)&&/(^|\/)(templates|views|pages)\//i.test(u)))return!0}return!1};return s(e,0)}var TCt=/"(?:@playwright\/test|cypress|webdriverio|nightwatch|testcafe)"\s*:/,NCt=/^\s*["']?(?:pytest-playwright|pytest-selenium|pytest-splinter)\b/im,_Ct=/^(requirements[\w.-]*\.txt|pyproject\.toml|Pipfile|setup\.cfg)$/,PCt=/^\s*gem\s+["'](?:capybara|cuprite)["']/m,QCt=["^[[:space:]]*import[[:space:]]+(static[[:space:]]+)?(org\\.openqa\\.selenium|com\\.codeborne\\.selenide)","^[[:space:]]*(from|import)[[:space:]]+(selenium|playwright|splinter)([.[:space:]]|$)",`^[[:space:]]*(import|const|let|var)[^;]*(from[[:space:]]*|require[[:space:]]*\\([[:space:]]*)["'](puppeteer|playwright|selenium-webdriver|webdriverio)["']`,`^[[:space:]]*require[[:space:]]+["']capybara`],DCt=["*.java","*.kt","*.groovy","*.py","*.rb","*.js","*.mjs","*.cjs","*.jsx","*.ts","*.mts","*.cts","*.tsx"],OCt=/(^|\/)(__tests__|tests?|e2e|cypress|playwright|spec|features)\/|\.(test|spec|cy)\.[a-z]+$|(Test|Tests|IT|ST)\.(java|kt|groovy)$|(^|\/)test_[^/]+\.py$|_test\.py$|_spec\.rb$/;function Z4(e,t=5,r=2e4){let n=0,s=o=>{try{return fo.statSync(o).size<1e6?fo.readFileSync(o,"utf-8"):""}catch{return""}},i=(o,a)=>{let c;try{c=fo.readdirSync(o,{withFileTypes:!0})}catch{return!1}for(let l of c){if(++n>r)return!1;let u=mn.join(o,l.name);if(l.isDirectory()){if(!WTe.has(l.name)&&!l.name.startsWith(".")&&a<t&&i(u,a+1))return!0;continue}if(VTe.test(l.name)||l.name==="application_system_test_case.rb"||l.name==="package.json"&&TCt.test(s(u))||_Ct.test(l.name)&&NCt.test(s(u))||l.name==="Gemfile"&&PCt.test(s(u)))return!0}return!1};return i(e,0)||OTe(e,QCt,DCt).some(o=>OCt.test(o))}var MCt=/^(\/|#\/|https?:\/\/)/i;function JTe(e){let t=`journey ${e.id||"(no id)"}`,r=[];return e.id.trim()||r.push(`${t} has no id`),e.name.trim()||r.push(`${t} has no name`),MCt.test(e.entry.trim())||r.push(`${t}'s entry "${e.entry}" is not a route (e.g. "/" or "/products")`),e.steps.length<2&&r.push(`${t} has ${e.steps.length} step(s); a journey is at least two steps through the UI`),e.steps.forEach((n,s)=>{n.action.trim()||r.push(`${t} step ${s+1} has no user action`),n.check?.trim()||r.push(`${t} step ${s+1} does not say what the user then sees`)}),e.outcome.trim()||r.push(`${t} has no outcome`),e.testFile.trim()||r.push(`${t} has no testFile`),r}function rf(e){let t=new Set;return(e??[]).filter(r=>JTe(r).length===0).filter(r=>!t.has(r.id.trim())&&!!t.add(r.id.trim()))}function YTe(e,t={}){let r=e??[],n=r.flatMap(JTe),s=r.map(o=>o.id.trim()).filter(Boolean);for(let o of new Set(s.filter((a,c)=>s.indexOf(a)!==c)))n.push(`journey id ${o} is used twice`);for(let o of s.filter(a=>t.takenIds?.has(a)))n.push(`journey id ${o} is also a clause or case id; give journeys ids of their own (J1, J2, \u2026)`);for(let o of r)o.steps.forEach((a,c)=>{for(let l of a.clauses??[])t.clauses&&!t.clauses.has(l)&&n.push(`journey ${o.id} step ${c+1} names ${l}, which is not a clause of the plan`)}),o.finishes?.trim()?LCt(o)&&n.push(`journey ${o.id} stops at the step the change alters, and finishes names a later action ("${o.finishes.trim()}"): continue the steps past it to that action, and check after it, on the page, what it produces`):n.push(`journey ${o.id} does not say under finishes the user action that completes the task (save, submit, pick, open, run): name it, and walk the journey on to it`),o.source==="pr-description"&&t.quoted&&!(o.evidence?.trim()&&t.quoted(o.evidence))&&n.push(`journey ${o.id} says the PR description describes it, and its evidence is not quoted from one: quote the words, or mark it inferred`);let i=new Set(r.flatMap(o=>o.steps.flatMap(a=>a.clauses??[])));for(let o of t.uiClauses??[])!i.has(o)&&!t.notInJourney?.has(o)&&n.push(`clause ${o} (what a user sees or does) is in no journey's steps: add it to the step that reaches it, or list it under notInJourney with why no journey reaches it; a clause whose test calls code directly with no page (a function, hook or module) is type integration, not ui`);return n}var FCt=new Set(["the","a","an","user","they","then","and","to","it","its"]),MTe=e=>Db(e).split(" ").filter(t=>t&&!FCt.has(t)).map(t=>t.replace(/(ing|ed|es|s|e)$/,"").replace(/([^aeiou])\1$/,"$1"));function LCt(e){let t=e.steps.flatMap((n,s)=>n.clauses?.length?[s]:[]);if(t.length!==1||t[0]!==e.steps.length-1)return!1;let r=MTe(e.finishes??"")[0];return r!==void 0&&!MTe(e.steps[e.steps.length-1].action).includes(r)}function Ob(e){return e.steps.map((t,r)=>{let n=t.clauses?.length?` [${t.clauses.join(", ")}]`:"",s=t.check?.trim()?`, then sees ${t.check.trim()}`:"";return`${r+1}. ${t.route.trim()?`${t.route.trim()} \u2014 `:""}${t.action.trim()}${n}${s}`}).join("; ")}function KTe(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/^[ \t]*(\/\/|#).*$/gm,t=>" ".repeat(t.length))}function UCt(e,t){let r=0,n=[];for(let s=t;s<e.length;s++){let i=e[s];if(i==="'"||i==='"')for(s++;s<e.length&&e[s]!==i&&e[s]!==`
241
241
  `;s++)e[s]==="\\"&&s++;else if(i==="`"||i==="}"&&n.length&&n[n.length-1]===r)for(i==="}"&&n.pop(),s++;s<e.length;s++)if(e[s]==="\\")s++;else{if(e[s]==="`")break;if(e[s]==="$"&&e[s+1]==="{"){n.push(r),s++;break}}else if(i==="/"&&e[s+1]==="/")for(;s<e.length&&e[s]!==`
242
242
  `;)s++;else if(i==="/"&&e[s+1]==="*"){let o=e.indexOf("*/",s+2);s=o<0?e.length:o+1}else if(i==="{")r++;else if(i==="}"&&(r--,r===0))return s+1}return e.length}function $Ct(e,t){let r=e.slice(t,t+400),n=r.search(/=>/),s=r.search(/\bfunction\b/);if(n<0&&s<0)return;if(n>=0&&(s<0||n<s)){let a=/^=>\s*\{/.exec(r.slice(n));return a?t+n+a[0].length-1:void 0}let i=r.indexOf("(",s);if(i<0)return;for(let a=0;i<r.length;i++)if(r[i]==="(")a++;else if(r[i]===")"&&--a===0)break;let o=/^\)\s*\{/.exec(r.slice(i));return o?t+i+o[0].length-1:void 0}var qCt=/\b(?:test|it)(?:\.(only|skip|fixme|slow|fail))?\s*\(\s*(['"`])((?:\\.|(?!\2)[^\\])*)\2/g,GCt=/^([ \t]*)(?:async[ \t]+)?def[ \t]+(test_\w+)[ \t]*\(/gm,HCt=/^[ \t]*(?:(?:test|it|scenario)[ \t]+(['"])((?:\\.|(?!\1)[^\\])*)\1[ \t]+do\b|def[ \t]+(test_\w+))/gm;function jCt(e){let t=[...e.matchAll(HCt)];return t.map((r,n)=>({title:r[2]??r[3]??"",start:r.index,end:n+1<t.length?t[n+1].index:e.length,skipped:/\bskip\b/.test(e.slice(r.index,n+1<t.length?t[n+1].index:e.length).split(`
243
243
  `).slice(0,3).join(`
@@ -254,7 +254,7 @@ ${h}`);A.length&&d.push(`stubs the app's network (${A.join(", ")}); a journey te
254
254
  file: ${C.file} asserts: ${C.evidence}`}).join(`
255
255
  `)||" (none)",u=[`You are a SKEPTICAL reviewer of generated ${i?"UI (browser)":"backend"} tests. For each case below`,"the generator wrote a test with a cited assertion. Judge whether that","assertion would ACTUALLY discriminate the correct behaviour from the bug the","case targets \u2014 not merely that a request returns 2xx or that a field exists.","Read the test files (Read/Grep are available). Flag an assertion that:"," - is tautological (asserts what the app currently does, nothing sanctioning it),"," - checks only shape/status when the case targets a specific value or state,"," - would NOT fail on the buggy behaviour the case describes, or",` - references a value/response the test never actually exercises${i?",":"."}`,...i?[" - asserts only what the page REPAINTS (DOM text/visibility) after a mutation"," instead of the backend truth (an API read-back) \u2014 a UI that echoes a lying"," server passes such a test \u2014 or uses a locator that was never executed."]:[],"(Judge intent from reading the code \u2014 you have no interpreter, so do not guess at compilation.)","If the tests are genuinely sound, report nothing \u2014 do NOT invent problems.","","Cases + generated assertions:",l,"","Output ONLY this JSON (empty weak[] = the tests are sound):",'{ "weak": [ { "case": "<id>", "problem": "\u2264300 chars", "evidence": "the assertion line or file:line" } ] }'].join(`
256
256
  `),d;try{d=await r(u)}catch{return{name:s,passed:!0}}let{value:p}=Xt(d.stdout);if(!p||typeof p!="object")return{name:s,passed:!0};let f=p.weak,h=Array.isArray(f)?f.filter(C=>!!C&&typeof C.problem=="string"&&!!C.problem.trim()&&typeof C.case=="string"&&c.has(C.case)):[];if(h.length===0)return{name:s,passed:!0};let A=h.slice(0,5).map(C=>`[${C.case??"?"}] ${C.problem} (${C.evidence??""})`).join("; ");return{name:s,passed:!1,details:`skeptic found ${h.length} weak/ineffective assertion(s) \u2014 rewrite each to assert the exact observable that DIFFERS between correct and buggy behaviour: ${A}`}}var NNe=(e,t,r)=>TNe(e,t,r,"backend"),_Ne=(e,t,r)=>TNe(e,t,r,"ui"),WSt=/\.(spec|test)\.[cm]?[jt]sx?$/i;function zQ(e){let t;try{t=(0,l8.execFileSync)("git",[...Is,"status","--porcelain","--untracked-files=all"],{env:Je(),cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let r=s=>/_scaffold/i.test(s)||Ws.test(s),n=[];for(let s of t.split(`
257
- `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),o=i.indexOf(" -> ");if(o!==-1&&(i=i.slice(o+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let a=i.replace(/^\.\//,"");a.startsWith(".skyramp/")||!r(a)||n.push(a)}return n}function PNe(e){let t=e.inputs.repositoryPath;for(let r of zQ(t)??[])if(/_scaffold/i.test(r)){try{vn.rmSync(vs.resolve(t,r),{force:!0})}catch{}try{(0,l8.execFileSync)("git",[...Is,"rm","--cached","-q","--force","--",r],{cwd:t,stdio:"ignore",env:Je()})}catch{}}}function m8(e){let t=jQ[e],r=e==="ui";return{name:`${t.stage}-no-litter`,verify(n){let s=zQ(n.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(o=>WSt.test(o)===r);return i.length===0?{name:this.name,passed:!0}:ce(this.name,[`${t.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var Kor=m8("backend");function QNe(e,t){let{generate:r,errors:n}=mo(t,e.secretValues);return ot(e,"generate",r,n)}var pa=z(require("fs")),on=z(require("path"));function ONe(e){return Pr(yx,e).errors}function g8(e,t=[]){let{value:r,error:n}=Xt(e,t);if(n)return{errors:[n]};let s=ONe(r);return s.length>0?{errors:s}:{adapt:r,errors:[]}}var kl="adapt-scratch",VQ=`${kl}/adapt-result.json`;function fa(e,t){let r=on.join(e.outputsDir,VQ),n;try{n=pa.readFileSync(r,"utf-8")}catch{n=void 0}if(n!==void 0&&(e.secretValues??[]).some(o=>n.includes(o)))return{errors:[`${VQ} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=g8(t.stdout,e.secretValues);if(s.adapt)return s;let i=n!==void 0?Cl(r):void 0;return i!==void 0&&ONe(i).length===0?{adapt:i,errors:[]}:s}function JSt(e,t){let r=ee(e,t);if(!(!r||!Array.isArray(r.tests)))return r}function go(e){let t=i=>e.state.stages[i]?.status==="passed",r=(i,o)=>(JSt(e,i)?.tests??[]).map(a=>({...a,kind:o})),n=t("generate")?r("generate.json","backend"):[],s=t("generate-ui")?r("generate-ui.json","ui"):[];return[...n,...s]}function YSt(e,t){return e.prepared?.targetDirs?.[t.slug]}function KSt(e,t){return e.prepared?.destinations?.[t]?.repository}var WQ=(e,t)=>`${e}\0${Mt(e,t)}`,MNe=zn("adapt-schema",fa),FNe=/\b(e2e|ui|playwright|cypress)\b/i,LNe=e=>FNe.test(e),UNe=e=>FNe.test(e);function XSt(e){let t=e.match(/^\.+/)?.[0].length??1,r=e.slice(t).replace(/\./g,"/"),n=t===1?"./":"../".repeat(t-1);return r?`${n}${r}`:n}function DNe(e,t){let r=on.resolve(e,t),n="";try{n=pa.readFileSync(r,"utf-8")}catch{return[]}let s=on.dirname(r),i=[],o=[...[...n.matchAll(/(?:from|require\()\s*["'](\.[^"']+)["']/g)].map(a=>a[1]),...[...n.matchAll(/^\s*from\s+(\.[\w.]*)\s+import\b/gm)].map(a=>XSt(a[1]))];for(let a of o){let c=on.resolve(s,a);for(let l of[c,...[".ts",".tsx",".js",".jsx",".mjs",".py"].flatMap(u=>[`${c}${u}`,on.join(c,`index${u}`)])])try{if(pa.statSync(l).isFile()){i.push(l);break}}catch{}}return i}function sf(e,t,r=4){let n=new Set([on.resolve(e,t)]),s=DNe(e,t);for(let i=0;i<r&&s.length>0;i++){let o=[];for(let a of s)n.has(a)||(n.add(a),o.push(...DNe(e,on.relative(e,a))));s=o}return n.delete(on.resolve(e,t)),[...n]}var $Ne={name:"adapt-intent",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=e.inputs.repositoryPath,i=new Map;for(let a of r.items)a.action==="place"&&a.from&&i.set(Mt(s,a.from),{file:a.file,root:sn(e.inputs,a.repository)});let o=[];for(let a of go(e)){let c=i.get(Mt(s,a.file));if(!c)continue;let l=c.file,d=GQ((f=>{try{return pa.readFileSync(on.resolve(s,f),"utf-8")}catch{return""}})(a.file),a.file),p=sd(c.root,l,sf);if(d===void 0||p===void 0){o.push(`${l}: cannot count assertions in a ${on.extname(l)||"extension-less"} file \u2014 no heads for that language (known: ${Object.keys(zb).join(", ")}). Add a row to ASSERTION_HEADS, with a test over a real file.`);continue}d>0&&p<d&&o.push(`${l} makes ${p} assertion(s), but the test generate staged made ${d} \u2014 placement dropped ${d-p}. Moving an assertion into a helper or page object is fine (those are counted too); deleting one is not.`)}return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}},qNe={name:"adapt-placement",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=go(e);if(s.length===0)return ce(this.name,["no staged tests from generate/generate-ui \u2014 nothing to place"]);let i=e.inputs.repositoryPath,o=new Map(r.items.filter(c=>c.action==="place"&&c.from).map(c=>[Mt(i,c.from),c])),a=[];for(let c of s){let l=Mt(i,c.file),u=o.get(l);if(!u){a.push(`staged test "${c.file}" was not placed by adapt`);continue}let d=Sl(e.inputs,u.repository);if("error"in d){a.push(`placed test "${u.file}": ${d.error}`);continue}let p=KSt(e,c.file);p&&!SQ(p,d.source.slug)&&a.push(`placed test "${u.file}" is in ${d.source.slug}, but it belongs in ${p}, the repository that owns ${c.covers.join(", ")}`);let f=d.source.path,h=Mt(f,u.file);d.source.working&&h.startsWith(".skyramp/staged")&&a.push(`placed test "${u.file}" is still in the staging area`);let A=ZSt(f,u.file);if(A){a.push(`placed test "${u.file}" ${A}`);continue}let C=YSt(e,d.source),w=C&&tIt(h,c.kind,C);w&&a.push(`placed test "${u.file}" ${w}`);let b=C&&eIt(h,C);b&&a.push(`placed test "${u.file}" ${b}`);let I=on.resolve(f,u.file);pa.existsSync(I)?pa.readFileSync(I,"utf-8").trim()||a.push(`placed test "${u.file}" is empty`):a.push(`placed test "${Xe(e.inputs,d.source.slug)}${u.file}" does not exist on disk`)}return a.length===0?{name:this.name,passed:!0}:ce(this.name,a)}},A8=/\.(py|ts|tsx|js|jsx|mjs|cjs|go|java|rb|kt|cs|snap)$/i;function ZSt(e,t){if(!t||!t.trim())return"is empty";if(on.isAbsolute(t))return"is an absolute path \u2014 placements are repo-relative";let r=Hm(e,t);if(r===void 0)return"resolves outside the repository";if(!A8.test(r))return"is not a test or support source file (by extension)"}function eIt(e,t){let r=[...t.backend,...t.ui].map(n=>n.replace(/\/+$/,"")).filter(Boolean);if(r.length!==0&&!r.some(n=>n==="."||e===n||e.startsWith(`${n}/`)))return`is outside every target test directory (${r.join(", ")}) \u2014 a test is placed under one of them, never elsewhere in the tree`}function tIt(e,t,r){if(r.backend.length===0||r.ui.length===0)return;let n=o=>o.some(a=>e===a||e.startsWith(`${a}/`)),s=t==="ui"?r.ui:r.backend,i=t==="ui"?r.backend:r.ui;if(!n(s)&&n(i))return`is a ${t} test placed in the ${t==="ui"?"backend":"UI"} test directory (${i.find(o=>e.startsWith(`${o}/`))}) \u2014 it belongs under ${s.join(" or ")}`}var GNe={name:"adapt-no-extra-placements",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=e.inputs.repositoryPath,i=new Set(go(e).map(a=>Mt(s,a.file))),o=[];for(let a of r.items)a.action==="place"&&a.from&&!i.has(Mt(s,a.from))&&o.push(`placed test from "${a.from}" is not a generate/generate-ui staged output \u2014 refusing to ship an unverified draft (a failed generate stage may have left it behind)`);return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}},HNe={name:"adapt-maintenance",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=Ht(e);if(!s)return ce(this.name,["recommend.json not found \u2014 cannot check maintenance"]);let i=new Map;for(let a of r.items)i.set(WQ(sn(e.inputs,a.repository),a.file),a);let o=[];for(let a of s.maintenance){let c=sn(e.inputs,a.repository),l=i.get(WQ(c,a.test));if(!l){let d=a.repository?` in ${a.repository}`:"";o.push(`recommend planned ${a.action} on "${a.test}"${d} but adapt did not act on it`);continue}let u=pa.existsSync(on.resolve(c,a.test));a.action==="delete"&&u&&!l.keptReason?.trim()&&o.push(`"${a.test}" planned for delete still exists \u2014 delete it, or record a keptReason if you preserved it in place`),a.action!=="delete"&&l.action!=="delete"&&!u&&o.push(`"${a.test}" planned for ${a.action} no longer exists`)}return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}},rIt=/ModuleNotFoundError|ImportError|No module named|Cannot find module|cannot import|SyntaxError|is not defined|error collecting|collected 0 items|ENOENT|fixture '.*' not found/i;function nIt(e,t=e.reran){let r=t!==e.reran,n=e.covers??[],s=t.exit;if(s==null||n.length===0)return[];let i=t.tests;if(i===void 0&&r)return[];if(i===void 0)return[`"${e.file}" covers ${n.length} case(s) but reran.tests is missing \u2014 record each case's own result ({ case, status }), so a red file says WHICH case is red. One exit code for five cases cannot.`];let o=[],a=new Set(i.map(d=>d.case)),c=n.filter(d=>!a.has(d));c.length>0&&!r&&o.push(`"${e.file}" reran.tests does not report case(s) it covers: ${c.join(", ")}`);let l=[...a].filter(d=>!n.includes(d));if(l.length>0&&o.push(`"${e.file}" reran.tests reports case(s) the file does not cover: ${l.join(", ")}`),e.placementBroken){let d=i.filter(p=>p.status!=="skip").map(p=>p.case);return d.length>0?[`"${e.file}" is placementBroken:true \u2014 it could not run \u2014 but reran.tests reports ${d.join(", ")} as ${i.find(p=>p.status!=="skip")?.status}. A case that never executed is "skip", not a result.`]:[]}let u=i.some(d=>d.status==="fail");return s===0&&u&&o.push(`"${e.file}" re-ran exit 0 but reran.tests marks ${i.filter(d=>d.status==="fail").map(d=>d.case).join(", ")} failed \u2014 the two cannot both be true`),s!==0&&!u&&!(r&&c.length)&&o.push(`"${e.file}" re-ran exit ${s} but reran.tests marks no case failed \u2014 record the case that failed, or the non-test reason in details`),o}var sIt=/(?:^|[\s/])(?:pytest|jest|vitest|mocha|playwright\s+test|node\s+--test|(?:npm|pnpm|yarn)\s+(?:run\s+)?test)(?=\s|$)/;function iIt(e,t,r){return e.split(/&&|\|\||[;|\n]/).some(n=>{let s=sIt.exec(n);if(!s||/\b(?:install|add)\b|--version|--help/.test(n))return!1;let i=n.slice(s.index+s[0].length).split(/\s+/).map(o=>o.replace(/^["']|["']$/g,"")).filter(o=>!o.startsWith("-")&&/[./]/.test(o)).map(o=>Mt(t,o.replace(/::.*$|:\d+$/,"")));return!i.length||i.some(o=>o===""||o===r||r.startsWith(`${o}/`)||r.endsWith(`/${o}`))})}var jNe={name:"adapt-rerun",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=[],i=uo(e),o=oo(e.inputs),a=go(e),c=OQ(on.join(e.outputsDir,"adapt-stream.ndjson"));for(let l of r.items){if(l.action==="delete")continue;let u=l.reran,d=u.exit,p=u.details?.trim()??"";if(l.from&&Ex(_Q(e.inputs.repositoryPath,a,l.from),o)){d!=null&&s.push(`"${l.file}" runs alone with its declared setup, so the harness runs it: do not run it, and leave reran.exit null`),i&&!l.isolatedRun?.trim()&&s.push(`"${l.file}" runs alone with its declared setup: record isolatedRun, the command that runs only this file`);let f=sn(e.inputs,l.repository),h=c.find(C=>iIt(C,f,Mt(f,l.file)));h&&s.push(`"${l.file}" runs alone, but the session ran it with other tests (\`${h.slice(0,200)}\`): leave every runs-alone file out of your runs, naming only the other test files`);let A=wTe(e,l);if(A?.exit===null||A?.exit===void 0)continue;u=A,d=A.exit,p=A.details??""}if(d==null){let f=l.action==="place"||l.action==="update"||l.action==="regenerate";i&&f&&(Ws.test(l.file)?s.push(`"${l.file}" was not re-run (exit null) although a live SUT is available \u2014 run it and record the exit`):p||s.push(`"${l.file}" is not a runnable test and was not run (exit null) \u2014 say so in reran.details (what it is, and how it was checked)`));continue}d!==0&&!p&&s.push(`"${l.file}" re-ran exit ${d} with no reran.details \u2014 record what failed`);for(let f of nIt(l,u))s.push(f);if(l.placementBroken&&d===0&&s.push(`"${l.file}" is marked placementBroken:true but re-ran exit 0 \u2014 a passing test is not broken. Clear the flag; if the test cannot observe a bug you believe is there, say so in reran.details (that is a test-quality note, not a placement failure)`),l.repro){d===0&&s.push(`repro "${l.file}" re-ran green (exit 0) \u2014 a repro must still fail after adaptation`);continue}if(d!==0&&!l.placementBroken){if(l.finding){rIt.test(p)&&s.push(`"${l.file}" is marked finding:true but its details read like a placement/harness error ("${p.slice(0,80)}") \u2014 that is placementBroken:true, not a product bug`);continue}Ws.test(l.file)&&s.push(`"${l.file}" re-ran exit ${d} but is not classified \u2014 repro:true (meant to fail), finding:true (caught a real bug), or placementBroken:true (placement/harness problem one repair could not fix)`)}}return s.length===0?{name:this.name,passed:!0}:ce(this.name,s)}},zNe={name:"adapt-no-litter",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=new Set(r.items.map(o=>WQ(sn(e.inputs,o.repository),o.file))),i=je(e.inputs).filter(o=>o.writable).flatMap(o=>(zQ(o.path)??[]).filter(a=>!s.has(WQ(o.path,a))&&!a.startsWith(".skyramp/")).map(a=>`${Xe(e.inputs,o.slug)}${a}`));return i.length===0?{name:this.name,passed:!0}:ce(this.name,[`adapt left test-shaped files that are not in items[]: ${i.slice(0,6).join(", ")} \u2014 place them as items or delete them`])}};function VNe(e,t){let{adapt:r,errors:n}=fa(e,t);if(r)for(let i of r.items){let o=sn(e.inputs,i.repository);i.file&&i.action!=="delete"&&(i.assertionCount=sd(o,Mt(o,i.file),sf))}let s=ot(e,"adapt",r,n);return pa.rmSync(on.join(e.inputs.repositoryPath,Qr),{recursive:!0,force:!0}),s}var WNe=require("child_process"),Ox=z(require("fs")),Ao=z(require("path"));var JNe=(e,t)=>mo(t).generate?.tests.map(r=>r.file)??[],YNe=(e,t)=>fa(e,t).adapt?.items.filter(r=>r.action!=="delete").map(r=>Ao.resolve(sn(e.inputs,r.repository),r.file))??[];function Mx(e){return of(e).map(t=>t.path)}function KNe(e){return of(e).filter(t=>t.code==="??").map(t=>t.path)}function of(e){let t;try{t=(0,WNe.execFileSync)("git",[...Is,"status","--porcelain","-z","--untracked-files=all"],{env:Je(),cwd:e,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let r=t.split("\0"),n=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.length<4)continue;let o=i.slice(0,2);n.push({code:o,path:i.slice(3)}),(o[0]==="R"||o[0]==="C")&&s++}return n}function tc(e){return new Set((typeof e=="string"?[e]:e).flatMap(t=>Mx(t).map(r=>Ao.resolve(t,r))))}function rc(e){return je(e).filter(t=>t.writable).map(t=>t.path)}function y8(e){return je(e).map(t=>t.path)}function oIt(e){return[{prefix:"",root:e.inputs.repositoryPath},...(e.inputs.relatedRepos??[]).map(t=>({prefix:`${Ao.basename(Ao.resolve(t.path))}/`,root:t.path}))]}function b8(e,t){let r=oIt(e).find(n=>n.prefix&&t.startsWith(n.prefix));return r?Ao.resolve(r.root,t.slice(r.prefix.length)):Ao.resolve(e.inputs.repositoryPath,t)}function aIt(e,t,r){let n=t.replace(/^\.\//,""),s=Ao.resolve(e.inputs.repositoryPath,n),i=b8(e,n);return i===s?[s]:[i,...r.has(s)?[s]:[]]}function E8(e){return tc(y8(e.inputs))}var cIt=2*1024*1024;function af(e,t,r=rc){return{name:e,verify(n,s){let i=n.secretValues??[];if(i.length===0)return{name:this.name,passed:!0};let o=[];i.some(h=>s.stdout.includes(h))&&o.push("the stage output contains a secret value (token / credential) \u2014 never print it");let a=n.prepared?.secretGateBaseline,c=h=>{let A=CQ(n.inputs,h),C=A?Ao.relative(A.path,h):h;return A?`${Xe(n.inputs,A.slug)}${C}`:C},l=r(n.inputs).flatMap(h=>Mx(h).filter(A=>A8.test(A)||/\.(env|ya?ml|json|toml|ini|cfg|sh)$/i.test(A)).map(A=>Ao.resolve(h,A))),u=a?l.filter(h=>!a.has(h)):l,d=n.inputs.repositoryPath,p=new Set(Mx(d).map(h=>Ao.resolve(d,h))),f=new Set([...t(n,s).flatMap(h=>aIt(n,h,p)),...u]);for(let h of f){let A=c(h),C="";try{if(!Ox.statSync(h).isFile()||Ox.statSync(h).size>cIt)continue;C=Ox.readFileSync(h,"utf-8")}catch{continue}i.some(w=>C.includes(w))&&o.push(`${A} contains a secret value \u2014 tests read the token from the environment, never inline it`)}return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}}}var Ze=g.string().trim().min(1),lIt=e=>{if(!e||typeof e!="object")return e;let t=e;return typeof t.skip=="string"&&t.skip.trim()&&(t.expected===void 0||t.expected===null)?{...t,expected:"(not tested)"}:e},uIt=g.preprocess(lIt,g.object({id:Ze.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:Ze.describe("one testable part of the requirement"),expected:Ze.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:g.string().optional().describe("only when no test can check this clause here: why"),type:g.nativeEnum(ca).optional().describe("the test that checks this clause: contract / integration (API) or ui"),target:g.string().optional().describe('its "METHOD /path", or the page / flow'),steps:g.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:g.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:g.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:g.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:g.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:g.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),dIt=g.object({id:Ze.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:Ze,source:g.nativeEnum(ho).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:g.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:Ze.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:g.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:g.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:g.array(g.object({spec:Ze.describe("file:line of the spec in the repository"),says:Ze.describe("what the spec says there, in its own words")})).optional().describe("requirement-reference only: each spec in the repository that says otherwise; the item wins, so test what it says"),clauses:g.array(uIt)}),pIt=g.object({id:Ze.describe('e.g. "F1"'),file:Ze,line:g.number().optional(),claim:Ze.describe("the defect, in one sentence"),severity:g.nativeEnum(Mb),evidence:Ze.describe("the code line, or the probe request and response, that shows it"),conflictsWith:g.array(Ze).optional().describe("requirement or clause ids it violates"),needsApp:g.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),fIt=g.object({id:Ze.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:g.nativeEnum(ca).describe("contract / integration: checks the API; ui: checks what a user sees or does"),target:Ze.describe('"METHOD /path", or the page / flow'),clause:g.string().optional().describe("the clause id this case checks"),finding:g.string().optional().describe("the finding id this case catches"),steps:Ze.describe("what the test does"),expected:Ze.describe("the expected outcome, from the clause"),mutates:g.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),hIt=g.object({test:Ze.describe("existing test file"),action:g.nativeEnum(Nm),reason:Ze,mutates:g.boolean().optional().describe("true when the maintained test changes state"),clauses:g.array(Ze).optional().describe("the clause ids this test checks")}),XNe=g.object({outcome:g.nativeEnum(bl).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:g.record(g.string()).optional().describe("service \u2192 base URL of the running app"),health:g.object({url:g.string().optional(),command:g.string().optional(),output:g.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:g.string().optional().describe("command that stops the app"),dependencies:g.record(g.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:g.array(g.string()).optional().describe("what you changed in the recipe"),error:g.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:g.array(g.string()).optional().describe("change-broke-bringup: the changed files to blame")}),yo=g.object({schemaVersion:g.literal(1),requirements:g.array(dIt),findings:g.array(pIt),cases:g.array(fIt).describe("a second test for a clause, and one case per finding that fails on this branch"),maintenance:g.array(hIt),journeys:g.array(GTe).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:g.array(g.object({clause:Ze,why:Ze})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Vm.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:XNe.optional().describe("omit when no app was needed or none was started"),summary:Ze.describe("one paragraph: what the change does and where the risk is")}),S8=(r=>(r.Backend="backend",r.Ui="ui",r))(S8||{}),id=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(id||{}),mIt=g.object({file:Ze.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:g.nativeEnum(S8),change:g.nativeEnum(id).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:g.array(g.string()).describe("the plan case ids this file tests"),defect:g.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:g.object({requirement:Ze.describe("the requirement or clause id the change deliberately alters"),line:Ze.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:g.object({exit:g.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:g.array(g.object({case:Ze,status:g.nativeEnum(po),defect:g.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:g.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:g.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail")})).describe("one entry per covered case, from the runner's own output"),details:g.string().optional().describe("what failed and why, or why it was not run")}),assertions:g.array(g.object({case:Ze,evidence:Ze})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:g.array(g.object({name:Ze.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:g.array(Ze).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),run:Ub.optional().describe(`for a file you added or updated in a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test): how the run executes only this file's tests, with the repository's own runner writing JUnit XML to ${zm}; Testbot re-runs them with it`)}),gIt=g.object({description:Ze.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:g.nativeEnum(Mb).optional(),sourceFile:g.string().optional().describe("the app file at fault"),sourceLine:g.number().optional(),test:g.string().optional().describe("the test file that shows it"),finding:g.string().optional().describe("the plan's finding id, when it is one"),requirements:g.array(Ze).optional().describe("the plan's requirement or clause ids it violates")}),Jn=g.object({schemaVersion:g.literal(1),tests:g.array(mIt),notWritten:g.array(g.object({case:Ze,reason:Ze})).describe("every plan case no test covers, and why"),journeys:g.array(FQ).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:g.object({command:g.string(),clean:g.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one"),dependenciesAdded:g.array(g.object({package:Ze,manifest:Ze,repository:Ze.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:Ze.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),ciRunsTests:g.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),commit:g.object({message:Ze.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:Ze.describe("at most 72 characters"),prBody:Ze.describe("what the tests cover and what they found")}),report:g.object({summary:Ze.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:g.array(gIt).describe("every defect the tests found"),nextSteps:g.array(g.string())})});function w8(e,t,r=[]){let{value:n,error:s}=Xt(t,r);return s?{errors:[s]}:Pr(e,n)}function Rn(e,t,r,n=[]){let s=w8(e,t,n);if(s.value)return s;let i=Fx(r);return i===void 0?s:w8(e,i,n)}function ZNe(e,t){let r=new Set(e.cases.map(o=>o.id)),n=e.requirements.flatMap(o=>o.clauses.filter(a=>!a.steps?.trim()||a.skip?!1:r.has(a.id)?(t?.(a.id),!1):!0).map(a=>({id:a.id,type:a.type??"integration",target:a.target?.trim()||o.id,clause:a.id,...a.finding?{finding:a.finding}:{},steps:a.steps.trim(),expected:a.expected,...a.mutates?{mutates:!0}:{}}))),s=[...n,...e.cases],i=Jm(s,o=>o.id);return t&&s.filter(o=>!i.includes(o)).forEach(o=>t(o.id)),i.length===e.cases.length&&n.length===0?e:{...e,cases:i}}function e_e(e,t){if(!e.journeys)return e;let r=rf(e.journeys),n=new Set(e.cases.map(i=>i.id)),s=t?r.filter(i=>!n.has(i.id)).map(i=>({id:i.id,type:"ui",target:i.entry.trim(),steps:`user journey "${i.name.trim()}", one ${i.kind==="in-process"?"in-process":"browser"} test from ${i.entry.trim()} to the outcome: ${Ob(i)}`,expected:i.outcome.trim()})):[];return{...e,journeys:r,cases:[...e.cases,...s]}}function t_e(e){let t=e.triage;if(t?.decision!=="runtime_required")return e;let r=new Set(t.plan.filter(i=>i.mechanism==="runtime").map(i=>i.behaviorId)),n=new Set([...t.plan,...t.outOfScope??[],...t.gaps].flatMap(i=>i.behaviorId?[i.behaviorId]:[]).filter(i=>!r.has(i))),s=e.cases.filter(i=>!i.clause||!n.has(i.clause));return s.length===e.cases.length?e:{...e,cases:s}}function JQ(e,t){for(let r of t){if(!r)continue;let{value:n}=w8(e,r);if(n)return n}}function r_e(e){if(e)try{let t=JSON.parse(e);if(!t||typeof t!="object"||!("app"in t)||XNe.safeParse(t.app).success)return;let{app:r,...n}=t;return JSON.stringify(n)}catch{return}}function Fx(e){try{return cf.readFileSync(e,"utf-8")}catch{return}}function Jm(e,t){let r=new Set;return e.filter(n=>{let s=t(n).trim();return r.has(s)?!1:(r.add(s),!0)})}function I8(e){return e?.outcome==="clean"||e?.outcome==="recipe-drift"}var n_e=(e,t)=>{let r=e.requirement.source==="requirement-reference"?e.requirement.reference?.trim():void 0;return e.code?.trim()?e.code.trim():r?Ka(r,e.requirement.criterion,t):e.requirement.evidence};function x8(e,t){return Jm(e.requirements.flatMap(r=>r.clauses.map(n=>({id:n.id,evidence:n_e({...n,requirement:r},t)}))),r=>r.id)}function s_e(e,t,r=new Date){let n=Jm(e.requirements,f=>f.id),s=Jm(n.flatMap(f=>f.clauses.map(h=>({...h,requirement:f}))),f=>f.id),i=new Set(s.map(f=>f.id)),o=Jm(e.findings,f=>f.id),a=new Set(o.map(f=>f.id)),c=Jm(e.cases,f=>f.id),l=I8(e.app),u=s.map(f=>({id:f.id,statement:f.clause,surface:c.find(h=>h.clause===f.id)?.target??f.requirement.id,evidence:n_e(f,t.itemNames),satisfies:[f.requirement.id]})),d={schemaVersion:1,repository:t.repository,project:{type:"other",primaryLanguage:"unknown",languages:[],frameworks:[]},services:[],infrastructure:{containerized:!1,hasDockerCompose:!1,composeFiles:[],hasCiCd:!1},diff:{changedFiles:t.changedFiles,nonApplicationOnly:t.nonApplicationOnly,summary:e.summary.slice(0,400)},endpoints:{new:[],modified:[],removed:[]},existingTests:{locations:[]},entityMap:{entities:[],references:[],stateFields:[]},requirements:n.map(f=>({id:f.id,statement:f.statement,source:f.source,evidence:f.evidence})),behaviors:u,findings:o.map(f=>({id:f.id,file:f.file,line:f.line,claim:f.claim,severity:f.severity,evidence:f.evidence,status:"suspected",conflictsWith:f.conflictsWith})),unexamined:[],summary:e.summary},p={schemaVersion:1,mode:l?"full":"static",maintenance:Jm(e.maintenance,f=>f.test).map(f=>({test:f.test,action:f.action,evidence:f.reason,...f.mutates?{mutates:!0}:{}})),generate:c.map(f=>({id:f.id,type:f.type,target:f.target,from_behavior:f.clause&&i.has(f.clause)?f.clause:void 0,from_finding:f.finding&&a.has(f.finding)?f.finding:void 0,rationale:s.find(h=>h.id===f.clause)?.clause??o.find(h=>h.id===f.finding)?.claim??AIt(e,f.id)??f.steps,expected_observable:f.expected,verifiable:l,...f.mutates?{mutates:!0}:{}})),surfaces:[],budget:{total:c.length,rationale:"planned in one session from the requirements' clauses"},summary:e.summary};return{analyze:d,recommend:p,deploy:e.app?yIt(e.app,t.defaultTeardown,r):void 0}}function AIt(e,t){let r=e.journeys?.find(n=>n.id===t);return r?`user journey: ${r.name.trim()}`:void 0}function yIt(e,t,r){return{schemaVersion:1,baseUrls:e.baseUrls,health:e.health?{url:e.health.url,command:e.health.command,output:e.health.output??""}:void 0,teardown:e.teardown?.trim()||t||"true",dependencies:e.dependencies,outcome:e.outcome,recipeFixes:e.recipeFixes,bringupError:e.error?{command:"bring-up",output:e.error}:void 0,suspectFiles:e.suspectFiles,seeded:!1,startedAt:r.toISOString()}}var bIt={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};function EIt(e){return e.result.exit!==null&&e.result.exit!==0||e.result.cases.some(t=>t.status==="fail")}function C8(e){let[t,...r]=e.split(`
257
+ `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),o=i.indexOf(" -> ");if(o!==-1&&(i=i.slice(o+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let a=i.replace(/^\.\//,"");a.startsWith(".skyramp/")||!r(a)||n.push(a)}return n}function PNe(e){let t=e.inputs.repositoryPath;for(let r of zQ(t)??[])if(/_scaffold/i.test(r)){try{vn.rmSync(vs.resolve(t,r),{force:!0})}catch{}try{(0,l8.execFileSync)("git",[...Is,"rm","--cached","-q","--force","--",r],{cwd:t,stdio:"ignore",env:Je()})}catch{}}}function m8(e){let t=jQ[e],r=e==="ui";return{name:`${t.stage}-no-litter`,verify(n){let s=zQ(n.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(o=>WSt.test(o)===r);return i.length===0?{name:this.name,passed:!0}:ce(this.name,[`${t.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var Kor=m8("backend");function QNe(e,t){let{generate:r,errors:n}=mo(t,e.secretValues);return ot(e,"generate",r,n)}var pa=z(require("fs")),on=z(require("path"));function ONe(e){return Pr(yx,e).errors}function g8(e,t=[]){let{value:r,error:n}=Xt(e,t);if(n)return{errors:[n]};let s=ONe(r);return s.length>0?{errors:s}:{adapt:r,errors:[]}}var kl="adapt-scratch",VQ=`${kl}/adapt-result.json`;function fa(e,t){let r=on.join(e.outputsDir,VQ),n;try{n=pa.readFileSync(r,"utf-8")}catch{n=void 0}if(n!==void 0&&(e.secretValues??[]).some(o=>n.includes(o)))return{errors:[`${VQ} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=g8(t.stdout,e.secretValues);if(s.adapt)return s;let i=n!==void 0?Cl(r):void 0;return i!==void 0&&ONe(i).length===0?{adapt:i,errors:[]}:s}function JSt(e,t){let r=ee(e,t);if(!(!r||!Array.isArray(r.tests)))return r}function go(e){let t=i=>e.state.stages[i]?.status==="passed",r=(i,o)=>(JSt(e,i)?.tests??[]).map(a=>({...a,kind:o})),n=t("generate")?r("generate.json","backend"):[],s=t("generate-ui")?r("generate-ui.json","ui"):[];return[...n,...s]}function YSt(e,t){return e.prepared?.targetDirs?.[t.slug]}function KSt(e,t){return e.prepared?.destinations?.[t]?.repository}var WQ=(e,t)=>`${e}\0${Mt(e,t)}`,MNe=zn("adapt-schema",fa),FNe=/\b(e2e|ui|playwright|cypress)\b/i,LNe=e=>FNe.test(e),UNe=e=>FNe.test(e);function XSt(e){let t=e.match(/^\.+/)?.[0].length??1,r=e.slice(t).replace(/\./g,"/"),n=t===1?"./":"../".repeat(t-1);return r?`${n}${r}`:n}function DNe(e,t){let r=on.resolve(e,t),n="";try{n=pa.readFileSync(r,"utf-8")}catch{return[]}let s=on.dirname(r),i=[],o=[...[...n.matchAll(/(?:from|require\()\s*["'](\.[^"']+)["']/g)].map(a=>a[1]),...[...n.matchAll(/^\s*from\s+(\.[\w.]*)\s+import\b/gm)].map(a=>XSt(a[1]))];for(let a of o){let c=on.resolve(s,a);for(let l of[c,...[".ts",".tsx",".js",".jsx",".mjs",".py"].flatMap(u=>[`${c}${u}`,on.join(c,`index${u}`)])])try{if(pa.statSync(l).isFile()){i.push(l);break}}catch{}}return i}function sf(e,t,r=4){let n=new Set([on.resolve(e,t)]),s=DNe(e,t);for(let i=0;i<r&&s.length>0;i++){let o=[];for(let a of s)n.has(a)||(n.add(a),o.push(...DNe(e,on.relative(e,a))));s=o}return n.delete(on.resolve(e,t)),[...n]}var $Ne={name:"adapt-intent",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=e.inputs.repositoryPath,i=new Map;for(let a of r.items)a.action==="place"&&a.from&&i.set(Mt(s,a.from),{file:a.file,root:sn(e.inputs,a.repository)});let o=[];for(let a of go(e)){let c=i.get(Mt(s,a.file));if(!c)continue;let l=c.file,d=GQ((f=>{try{return pa.readFileSync(on.resolve(s,f),"utf-8")}catch{return""}})(a.file),a.file),p=sd(c.root,l,sf);if(d===void 0||p===void 0){o.push(`${l}: cannot count assertions in a ${on.extname(l)||"extension-less"} file \u2014 no heads for that language (known: ${Object.keys(zb).join(", ")}). Add a row to ASSERTION_HEADS, with a test over a real file.`);continue}d>0&&p<d&&o.push(`${l} makes ${p} assertion(s), but the test generate staged made ${d} \u2014 placement dropped ${d-p}. Moving an assertion into a helper or page object is fine (those are counted too); deleting one is not.`)}return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}},qNe={name:"adapt-placement",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=go(e);if(s.length===0)return ce(this.name,["no staged tests from generate/generate-ui \u2014 nothing to place"]);let i=e.inputs.repositoryPath,o=new Map(r.items.filter(c=>c.action==="place"&&c.from).map(c=>[Mt(i,c.from),c])),a=[];for(let c of s){let l=Mt(i,c.file),u=o.get(l);if(!u){a.push(`staged test "${c.file}" was not placed by adapt`);continue}let d=Sl(e.inputs,u.repository);if("error"in d){a.push(`placed test "${u.file}": ${d.error}`);continue}let p=KSt(e,c.file);p&&!SQ(p,d.source.slug)&&a.push(`placed test "${u.file}" is in ${d.source.slug}, but it belongs in ${p}, the repository that owns ${c.covers.join(", ")}`);let f=d.source.path,h=Mt(f,u.file);d.source.working&&h.startsWith(".skyramp/staged")&&a.push(`placed test "${u.file}" is still in the staging area`);let A=ZSt(f,u.file);if(A){a.push(`placed test "${u.file}" ${A}`);continue}let C=YSt(e,d.source),w=C&&tIt(h,c.kind,C);w&&a.push(`placed test "${u.file}" ${w}`);let b=C&&eIt(h,C);b&&a.push(`placed test "${u.file}" ${b}`);let I=on.resolve(f,u.file);pa.existsSync(I)?pa.readFileSync(I,"utf-8").trim()||a.push(`placed test "${u.file}" is empty`):a.push(`placed test "${Xe(e.inputs,d.source.slug)}${u.file}" does not exist on disk`)}return a.length===0?{name:this.name,passed:!0}:ce(this.name,a)}},A8=/\.(py|ts|tsx|js|jsx|mjs|cjs|go|java|rb|kt|cs|snap)$/i;function ZSt(e,t){if(!t||!t.trim())return"is empty";if(on.isAbsolute(t))return"is an absolute path \u2014 placements are repo-relative";let r=Hm(e,t);if(r===void 0)return"resolves outside the repository";if(!A8.test(r))return"is not a test or support source file (by extension)"}function eIt(e,t){let r=[...t.backend,...t.ui].map(n=>n.replace(/\/+$/,"")).filter(Boolean);if(r.length!==0&&!r.some(n=>n==="."||e===n||e.startsWith(`${n}/`)))return`is outside every target test directory (${r.join(", ")}) \u2014 a test is placed under one of them, never elsewhere in the tree`}function tIt(e,t,r){if(r.backend.length===0||r.ui.length===0)return;let n=o=>o.some(a=>e===a||e.startsWith(`${a}/`)),s=t==="ui"?r.ui:r.backend,i=t==="ui"?r.backend:r.ui;if(!n(s)&&n(i))return`is a ${t} test placed in the ${t==="ui"?"backend":"UI"} test directory (${i.find(o=>e.startsWith(`${o}/`))}) \u2014 it belongs under ${s.join(" or ")}`}var GNe={name:"adapt-no-extra-placements",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=e.inputs.repositoryPath,i=new Set(go(e).map(a=>Mt(s,a.file))),o=[];for(let a of r.items)a.action==="place"&&a.from&&!i.has(Mt(s,a.from))&&o.push(`placed test from "${a.from}" is not a generate/generate-ui staged output \u2014 refusing to ship an unverified draft (a failed generate stage may have left it behind)`);return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}},HNe={name:"adapt-maintenance",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=Ht(e);if(!s)return ce(this.name,["recommend.json not found \u2014 cannot check maintenance"]);let i=new Map;for(let a of r.items)i.set(WQ(sn(e.inputs,a.repository),a.file),a);let o=[];for(let a of s.maintenance){let c=sn(e.inputs,a.repository),l=i.get(WQ(c,a.test));if(!l){let d=a.repository?` in ${a.repository}`:"";o.push(`recommend planned ${a.action} on "${a.test}"${d} but adapt did not act on it`);continue}let u=pa.existsSync(on.resolve(c,a.test));a.action==="delete"&&u&&!l.keptReason?.trim()&&o.push(`"${a.test}" planned for delete still exists \u2014 delete it, or record a keptReason if you preserved it in place`),a.action!=="delete"&&l.action!=="delete"&&!u&&o.push(`"${a.test}" planned for ${a.action} no longer exists`)}return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}},rIt=/ModuleNotFoundError|ImportError|No module named|Cannot find module|cannot import|SyntaxError|is not defined|error collecting|collected 0 items|ENOENT|fixture '.*' not found/i;function nIt(e,t=e.reran){let r=t!==e.reran,n=e.covers??[],s=t.exit;if(s==null||n.length===0)return[];let i=t.tests;if(i===void 0&&r)return[];if(i===void 0)return[`"${e.file}" covers ${n.length} case(s) but reran.tests is missing \u2014 record each case's own result ({ case, status }), so a red file says WHICH case is red. One exit code for five cases cannot.`];let o=[],a=new Set(i.map(d=>d.case)),c=n.filter(d=>!a.has(d));c.length>0&&!r&&o.push(`"${e.file}" reran.tests does not report case(s) it covers: ${c.join(", ")}`);let l=[...a].filter(d=>!n.includes(d));if(l.length>0&&o.push(`"${e.file}" reran.tests reports case(s) the file does not cover: ${l.join(", ")}`),e.placementBroken){let d=i.filter(p=>p.status!=="skip").map(p=>p.case);return d.length>0?[`"${e.file}" is placementBroken:true \u2014 it could not run \u2014 but reran.tests reports ${d.join(", ")} as ${i.find(p=>p.status!=="skip")?.status}. A case that never executed is "skip", not a result.`]:[]}let u=i.some(d=>d.status==="fail");return s===0&&u&&o.push(`"${e.file}" re-ran exit 0 but reran.tests marks ${i.filter(d=>d.status==="fail").map(d=>d.case).join(", ")} failed \u2014 the two cannot both be true`),s!==0&&!u&&!(r&&c.length)&&o.push(`"${e.file}" re-ran exit ${s} but reran.tests marks no case failed \u2014 record the case that failed, or the non-test reason in details`),o}var sIt=/(?:^|[\s/])(?:pytest|jest|vitest|mocha|playwright\s+test|node\s+--test|(?:npm|pnpm|yarn)\s+(?:run\s+)?test)(?=\s|$)/;function iIt(e,t,r){return e.split(/&&|\|\||[;|\n]/).some(n=>{let s=sIt.exec(n);if(!s||/\b(?:install|add)\b|--version|--help/.test(n))return!1;let i=n.slice(s.index+s[0].length).split(/\s+/).map(o=>o.replace(/^["']|["']$/g,"")).filter(o=>!o.startsWith("-")&&/[./]/.test(o)).map(o=>Mt(t,o.replace(/::.*$|:\d+$/,"")));return!i.length||i.some(o=>o===""||o===r||r.startsWith(`${o}/`)||r.endsWith(`/${o}`))})}var jNe={name:"adapt-rerun",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=[],i=uo(e),o=oo(e.inputs),a=go(e),c=OQ(on.join(e.outputsDir,"adapt-stream.ndjson"));for(let l of r.items){if(l.action==="delete")continue;let u=l.reran,d=u.exit,p=u.details?.trim()??"";if(l.from&&Ex(_Q(e.inputs.repositoryPath,a,l.from),o)){d!=null&&s.push(`"${l.file}" runs alone with its declared setup, so the harness runs it: do not run it, and leave reran.exit null`),i&&!l.isolatedRun?.trim()&&s.push(`"${l.file}" runs alone with its declared setup: record isolatedRun, the command that runs only this file`);let f=sn(e.inputs,l.repository),h=c.find(C=>iIt(C,f,Mt(f,l.file)));h&&s.push(`"${l.file}" runs alone, but the session ran it with other tests (\`${h.slice(0,200)}\`): leave every runs-alone file out of your runs, naming only the other test files`);let A=wTe(e,l);if(A?.exit===null||A?.exit===void 0)continue;u=A,d=A.exit,p=A.details??""}if(d==null){let f=l.action==="place"||l.action==="update"||l.action==="regenerate";i&&f&&(Ws.test(l.file)?s.push(`"${l.file}" was not re-run (exit null) although a live SUT is available \u2014 run it and record the exit`):p||s.push(`"${l.file}" is not a runnable test and was not run (exit null) \u2014 say so in reran.details (what it is, and how it was checked)`));continue}d!==0&&!p&&s.push(`"${l.file}" re-ran exit ${d} with no reran.details \u2014 record what failed`);for(let f of nIt(l,u))s.push(f);if(l.placementBroken&&d===0&&s.push(`"${l.file}" is marked placementBroken:true but re-ran exit 0 \u2014 a passing test is not broken. Clear the flag; if the test cannot observe a bug you believe is there, say so in reran.details (that is a test-quality note, not a placement failure)`),l.repro){d===0&&s.push(`repro "${l.file}" re-ran green (exit 0) \u2014 a repro must still fail after adaptation`);continue}if(d!==0&&!l.placementBroken){if(l.finding){rIt.test(p)&&s.push(`"${l.file}" is marked finding:true but its details read like a placement/harness error ("${p.slice(0,80)}") \u2014 that is placementBroken:true, not a product bug`);continue}Ws.test(l.file)&&s.push(`"${l.file}" re-ran exit ${d} but is not classified \u2014 repro:true (meant to fail), finding:true (caught a real bug), or placementBroken:true (placement/harness problem one repair could not fix)`)}}return s.length===0?{name:this.name,passed:!0}:ce(this.name,s)}},zNe={name:"adapt-no-litter",verify(e,t){let{adapt:r,errors:n}=fa(e,t);if(!r)return ce(this.name,n);let s=new Set(r.items.map(o=>WQ(sn(e.inputs,o.repository),o.file))),i=je(e.inputs).filter(o=>o.writable).flatMap(o=>(zQ(o.path)??[]).filter(a=>!s.has(WQ(o.path,a))&&!a.startsWith(".skyramp/")).map(a=>`${Xe(e.inputs,o.slug)}${a}`));return i.length===0?{name:this.name,passed:!0}:ce(this.name,[`adapt left test-shaped files that are not in items[]: ${i.slice(0,6).join(", ")} \u2014 place them as items or delete them`])}};function VNe(e,t){let{adapt:r,errors:n}=fa(e,t);if(r)for(let i of r.items){let o=sn(e.inputs,i.repository);i.file&&i.action!=="delete"&&(i.assertionCount=sd(o,Mt(o,i.file),sf))}let s=ot(e,"adapt",r,n);return pa.rmSync(on.join(e.inputs.repositoryPath,Qr),{recursive:!0,force:!0}),s}var WNe=require("child_process"),Ox=z(require("fs")),Ao=z(require("path"));var JNe=(e,t)=>mo(t).generate?.tests.map(r=>r.file)??[],YNe=(e,t)=>fa(e,t).adapt?.items.filter(r=>r.action!=="delete").map(r=>Ao.resolve(sn(e.inputs,r.repository),r.file))??[];function Mx(e){return of(e).map(t=>t.path)}function KNe(e){return of(e).filter(t=>t.code==="??").map(t=>t.path)}function of(e){let t;try{t=(0,WNe.execFileSync)("git",[...Is,"status","--porcelain","-z","--untracked-files=all"],{env:Je(),cwd:e,encoding:"utf-8",maxBuffer:16*1024*1024})}catch{return[]}let r=t.split("\0"),n=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.length<4)continue;let o=i.slice(0,2);n.push({code:o,path:i.slice(3)}),(o[0]==="R"||o[0]==="C")&&s++}return n}function tc(e){return new Set((typeof e=="string"?[e]:e).flatMap(t=>Mx(t).map(r=>Ao.resolve(t,r))))}function rc(e){return je(e).filter(t=>t.writable).map(t=>t.path)}function y8(e){return je(e).map(t=>t.path)}function oIt(e){return[{prefix:"",root:e.inputs.repositoryPath},...(e.inputs.relatedRepos??[]).map(t=>({prefix:`${Ao.basename(Ao.resolve(t.path))}/`,root:t.path}))]}function b8(e,t){let r=oIt(e).find(n=>n.prefix&&t.startsWith(n.prefix));return r?Ao.resolve(r.root,t.slice(r.prefix.length)):Ao.resolve(e.inputs.repositoryPath,t)}function aIt(e,t,r){let n=t.replace(/^\.\//,""),s=Ao.resolve(e.inputs.repositoryPath,n),i=b8(e,n);return i===s?[s]:[i,...r.has(s)?[s]:[]]}function E8(e){return tc(y8(e.inputs))}var cIt=2*1024*1024;function af(e,t,r=rc){return{name:e,verify(n,s){let i=n.secretValues??[];if(i.length===0)return{name:this.name,passed:!0};let o=[];i.some(h=>s.stdout.includes(h))&&o.push("the stage output contains a secret value (token / credential) \u2014 never print it");let a=n.prepared?.secretGateBaseline,c=h=>{let A=CQ(n.inputs,h),C=A?Ao.relative(A.path,h):h;return A?`${Xe(n.inputs,A.slug)}${C}`:C},l=r(n.inputs).flatMap(h=>Mx(h).filter(A=>A8.test(A)||/\.(env|ya?ml|json|toml|ini|cfg|sh)$/i.test(A)).map(A=>Ao.resolve(h,A))),u=a?l.filter(h=>!a.has(h)):l,d=n.inputs.repositoryPath,p=new Set(Mx(d).map(h=>Ao.resolve(d,h))),f=new Set([...t(n,s).flatMap(h=>aIt(n,h,p)),...u]);for(let h of f){let A=c(h),C="";try{if(!Ox.statSync(h).isFile()||Ox.statSync(h).size>cIt)continue;C=Ox.readFileSync(h,"utf-8")}catch{continue}i.some(w=>C.includes(w))&&o.push(`${A} contains a secret value \u2014 tests read the token from the environment, never inline it`)}return o.length===0?{name:this.name,passed:!0}:ce(this.name,o)}}}var Ze=g.string().trim().min(1),lIt=e=>{if(!e||typeof e!="object")return e;let t=e;return typeof t.skip=="string"&&t.skip.trim()&&(t.expected===void 0||t.expected===null)?{...t,expected:"(not tested)"}:e},uIt=g.preprocess(lIt,g.object({id:Ze.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:Ze.describe("one testable part of the requirement"),expected:Ze.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:g.string().optional().describe("only when no test can check this clause here: why"),type:g.nativeEnum(ca).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:g.string().optional().describe('its "METHOD /path", or the page / flow'),steps:g.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:g.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:g.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:g.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:g.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:g.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),dIt=g.object({id:Ze.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:Ze,source:g.nativeEnum(ho).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:g.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:Ze.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:g.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:g.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:g.array(g.object({spec:Ze.describe("file:line of the spec in the repository"),says:Ze.describe("what the spec says there, in its own words")})).optional().describe("requirement-reference only: each spec in the repository that says otherwise; the item wins, so test what it says"),clauses:g.array(uIt)}),pIt=g.object({id:Ze.describe('e.g. "F1"'),file:Ze,line:g.number().optional(),claim:Ze.describe("the defect, in one sentence"),severity:g.nativeEnum(Mb),evidence:Ze.describe("the code line, or the probe request and response, that shows it"),conflictsWith:g.array(Ze).optional().describe("requirement or clause ids it violates"),needsApp:g.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),fIt=g.object({id:Ze.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:g.nativeEnum(ca).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:Ze.describe('"METHOD /path", or the page / flow'),clause:g.string().optional().describe("the clause id this case checks"),finding:g.string().optional().describe("the finding id this case catches"),steps:Ze.describe("what the test does"),expected:Ze.describe("the expected outcome, from the clause"),mutates:g.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),hIt=g.object({test:Ze.describe("existing test file"),action:g.nativeEnum(Nm),reason:Ze,mutates:g.boolean().optional().describe("true when the maintained test changes state"),clauses:g.array(Ze).optional().describe("the clause ids this test checks")}),XNe=g.object({outcome:g.nativeEnum(bl).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:g.record(g.string()).optional().describe("service \u2192 base URL of the running app"),health:g.object({url:g.string().optional(),command:g.string().optional(),output:g.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:g.string().optional().describe("command that stops the app"),dependencies:g.record(g.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:g.array(g.string()).optional().describe("what you changed in the recipe"),error:g.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:g.array(g.string()).optional().describe("change-broke-bringup: the changed files to blame")}),yo=g.object({schemaVersion:g.literal(1),requirements:g.array(dIt),findings:g.array(pIt),cases:g.array(fIt).describe("a second test for a clause, and one case per finding that fails on this branch"),maintenance:g.array(hIt),journeys:g.array(GTe).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:g.array(g.object({clause:Ze,why:Ze})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Vm.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:XNe.optional().describe("omit when no app was needed or none was started"),summary:Ze.describe("one paragraph: what the change does and where the risk is")}),S8=(r=>(r.Backend="backend",r.Ui="ui",r))(S8||{}),id=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(id||{}),mIt=g.object({file:Ze.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:g.nativeEnum(S8),change:g.nativeEnum(id).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:g.array(g.string()).describe("the plan case ids this file tests"),defect:g.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:g.object({requirement:Ze.describe("the requirement or clause id the change deliberately alters"),line:Ze.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:g.object({exit:g.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:g.array(g.object({case:Ze,status:g.nativeEnum(po),defect:g.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:g.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:g.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail")})).describe("one entry per covered case, from the runner's own output"),details:g.string().optional().describe("what failed and why, or why it was not run")}),assertions:g.array(g.object({case:Ze,evidence:Ze})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:g.array(g.object({name:Ze.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:g.array(Ze).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),run:Ub.optional().describe(`for a file you added or updated in a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test): how the run executes only this file's tests, with the repository's own runner writing JUnit XML to ${zm}; Testbot re-runs them with it`)}),gIt=g.object({description:Ze.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:g.nativeEnum(Mb).optional(),sourceFile:g.string().optional().describe("the app file at fault"),sourceLine:g.number().optional(),test:g.string().optional().describe("the test file that shows it"),finding:g.string().optional().describe("the plan's finding id, when it is one"),requirements:g.array(Ze).optional().describe("the plan's requirement or clause ids it violates")}),Jn=g.object({schemaVersion:g.literal(1),tests:g.array(mIt),notWritten:g.array(g.object({case:Ze,reason:Ze})).describe("every plan case no test covers, and why"),journeys:g.array(FQ).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:g.object({command:g.string(),clean:g.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one"),dependenciesAdded:g.array(g.object({package:Ze,manifest:Ze,repository:Ze.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:Ze.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),ciRunsTests:g.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),commit:g.object({message:Ze.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:Ze.describe("at most 72 characters"),prBody:Ze.describe("what the tests cover and what they found")}),report:g.object({summary:Ze.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:g.array(gIt).describe("every defect the tests found"),nextSteps:g.array(g.string())})});function w8(e,t,r=[]){let{value:n,error:s}=Xt(t,r);return s?{errors:[s]}:Pr(e,n)}function Rn(e,t,r,n=[]){let s=w8(e,t,n);if(s.value)return s;let i=Fx(r);return i===void 0?s:w8(e,i,n)}function ZNe(e,t){let r=new Set(e.cases.map(o=>o.id)),n=e.requirements.flatMap(o=>o.clauses.filter(a=>!a.steps?.trim()||a.skip?!1:r.has(a.id)?(t?.(a.id),!1):!0).map(a=>({id:a.id,type:a.type??"integration",target:a.target?.trim()||o.id,clause:a.id,...a.finding?{finding:a.finding}:{},steps:a.steps.trim(),expected:a.expected,...a.mutates?{mutates:!0}:{}}))),s=[...n,...e.cases],i=Jm(s,o=>o.id);return t&&s.filter(o=>!i.includes(o)).forEach(o=>t(o.id)),i.length===e.cases.length&&n.length===0?e:{...e,cases:i}}function e_e(e,t){if(!e.journeys)return e;let r=rf(e.journeys),n=new Set(e.cases.map(i=>i.id)),s=t?r.filter(i=>!n.has(i.id)).map(i=>({id:i.id,type:"ui",target:i.entry.trim(),steps:`user journey "${i.name.trim()}", one ${i.kind==="in-process"?"in-process":"browser"} test from ${i.entry.trim()} to the outcome: ${Ob(i)}`,expected:i.outcome.trim()})):[];return{...e,journeys:r,cases:[...e.cases,...s]}}function t_e(e){let t=e.triage;if(t?.decision!=="runtime_required")return e;let r=new Set(t.plan.filter(i=>i.mechanism==="runtime").map(i=>i.behaviorId)),n=new Set([...t.plan,...t.outOfScope??[],...t.gaps].flatMap(i=>i.behaviorId?[i.behaviorId]:[]).filter(i=>!r.has(i))),s=e.cases.filter(i=>!i.clause||!n.has(i.clause));return s.length===e.cases.length?e:{...e,cases:s}}function JQ(e,t){for(let r of t){if(!r)continue;let{value:n}=w8(e,r);if(n)return n}}function r_e(e){if(e)try{let t=JSON.parse(e);if(!t||typeof t!="object"||!("app"in t)||XNe.safeParse(t.app).success)return;let{app:r,...n}=t;return JSON.stringify(n)}catch{return}}function Fx(e){try{return cf.readFileSync(e,"utf-8")}catch{return}}function Jm(e,t){let r=new Set;return e.filter(n=>{let s=t(n).trim();return r.has(s)?!1:(r.add(s),!0)})}function I8(e){return e?.outcome==="clean"||e?.outcome==="recipe-drift"}var n_e=(e,t)=>{let r=e.requirement.source==="requirement-reference"?e.requirement.reference?.trim():void 0;return e.code?.trim()?e.code.trim():r?Ka(r,e.requirement.criterion,t):e.requirement.evidence};function x8(e,t){return Jm(e.requirements.flatMap(r=>r.clauses.map(n=>({id:n.id,evidence:n_e({...n,requirement:r},t)}))),r=>r.id)}function s_e(e,t,r=new Date){let n=Jm(e.requirements,f=>f.id),s=Jm(n.flatMap(f=>f.clauses.map(h=>({...h,requirement:f}))),f=>f.id),i=new Set(s.map(f=>f.id)),o=Jm(e.findings,f=>f.id),a=new Set(o.map(f=>f.id)),c=Jm(e.cases,f=>f.id),l=I8(e.app),u=s.map(f=>({id:f.id,statement:f.clause,surface:c.find(h=>h.clause===f.id)?.target??f.requirement.id,evidence:n_e(f,t.itemNames),satisfies:[f.requirement.id]})),d={schemaVersion:1,repository:t.repository,project:{type:"other",primaryLanguage:"unknown",languages:[],frameworks:[]},services:[],infrastructure:{containerized:!1,hasDockerCompose:!1,composeFiles:[],hasCiCd:!1},diff:{changedFiles:t.changedFiles,nonApplicationOnly:t.nonApplicationOnly,summary:e.summary.slice(0,400)},endpoints:{new:[],modified:[],removed:[]},existingTests:{locations:[]},entityMap:{entities:[],references:[],stateFields:[]},requirements:n.map(f=>({id:f.id,statement:f.statement,source:f.source,evidence:f.evidence})),behaviors:u,findings:o.map(f=>({id:f.id,file:f.file,line:f.line,claim:f.claim,severity:f.severity,evidence:f.evidence,status:"suspected",conflictsWith:f.conflictsWith})),unexamined:[],summary:e.summary},p={schemaVersion:1,mode:l?"full":"static",maintenance:Jm(e.maintenance,f=>f.test).map(f=>({test:f.test,action:f.action,evidence:f.reason,...f.mutates?{mutates:!0}:{}})),generate:c.map(f=>({id:f.id,type:f.type,target:f.target,from_behavior:f.clause&&i.has(f.clause)?f.clause:void 0,from_finding:f.finding&&a.has(f.finding)?f.finding:void 0,rationale:s.find(h=>h.id===f.clause)?.clause??o.find(h=>h.id===f.finding)?.claim??AIt(e,f.id)??f.steps,expected_observable:f.expected,verifiable:l,...f.mutates?{mutates:!0}:{}})),surfaces:[],budget:{total:c.length,rationale:"planned in one session from the requirements' clauses"},summary:e.summary};return{analyze:d,recommend:p,deploy:e.app?yIt(e.app,t.defaultTeardown,r):void 0}}function AIt(e,t){let r=e.journeys?.find(n=>n.id===t);return r?`user journey: ${r.name.trim()}`:void 0}function yIt(e,t,r){return{schemaVersion:1,baseUrls:e.baseUrls,health:e.health?{url:e.health.url,command:e.health.command,output:e.health.output??""}:void 0,teardown:e.teardown?.trim()||t||"true",dependencies:e.dependencies,outcome:e.outcome,recipeFixes:e.recipeFixes,bringupError:e.error?{command:"bring-up",output:e.error}:void 0,suspectFiles:e.suspectFiles,seeded:!1,startedAt:r.toISOString()}}var bIt={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};function EIt(e){return e.result.exit!==null&&e.result.exit!==0||e.result.cases.some(t=>t.status==="fail")}function C8(e){let[t,...r]=e.split(`
258
258
  `);return[t.length<=nf?t:`${t.slice(0,nf-1).trimEnd()}\u2026`,...r].join(`
259
259
  `)}function i_e(e,t,r=[]){let n=[],s=[],i=[],o=new Set,a=new Map([...r].reverse().map(b=>{let I=Ys.basename(Ys.resolve(b.path));return[I,{name:I,root:Ys.resolve(b.path),slug:b.slug}]})),c=new Map,l=[],u=b=>`${b.repository??""}\0${b.file}`,d=new Map,p=b=>d.get(b)??d.set(b,new Set(Mx(b))).get(b);for(let b of e.tests){let I=t,x=Mt(t,b.file),B,k,R=b.file.replace(/^\.\//,"").split("/")[0],L=Ys.resolve(t,b.file),v=[...a.values()].find(V=>L.startsWith(V.root+Ys.sep)),F=b.file.replace(/^\.\//,"").slice(R.length+1),U=a.get(R),X=U!==void 0&&cf.existsSync(Ys.join(U.root,F)),W=U!==void 0&&(!cf.existsSync(Ys.join(t,R))||!cf.existsSync(L)&&X);if(U&&X&&cf.existsSync(L)&&Ys.join(U.root,F)!==L){let V=p(U.root).has(Mt(U.root,F)),N=p(t).has(Mt(t,b.file));V&&!N?W=!0:V===N&&s.push(b.file)}if(W?({name:k,root:I,slug:B}=U,x=Mt(I,F)):v&&({name:k,root:I,slug:B}=v,x=Mt(I,L)),!x||x.startsWith("..")||Ys.isAbsolute(x)){n.push(b.file);continue}if(b.change!=="deleted"&&!cf.existsSync(Ys.join(I,x))){n.push(b.file);continue}let J={...b,file:x,shown:k?`${k}/${x}`:x,...B?{repository:B}:{}};o.has(u(J))||(o.add(u(J)),c.set(u(J),I),i.push(J),l.push({written:b.file,root:I,file:x,...B?{repository:B}:{}}))}let f=i.map(b=>{let I=bIt[b.change];return{...I==="place"?{from:b.shown}:{},file:b.file,...b.repository?{repository:b.repository}:{},action:I,covers:b.covers,...b.defect&&EIt(b)?{finding:!0}:{},reran:{exit:b.result.exit,details:b.result.details,tests:b.result.cases},...I==="delete"?{}:{assertionCount:sd(c.get(u(b)),b.file,sf)}}}),h=b=>({schemaVersion:1,tests:i.filter(I=>I.kind===b&&I.change==="added").map(I=>({file:I.shown,source:"llm",language:Mm(I.file)??"unknown",covers:I.covers,assertions:I.assertions??[]})),deferredUi:[],summary:e.report.summary}),A=e.lint?.command?.trim()??"",C=e.lint?.clean??!0,w={schemaVersion:1,lint:A?[{tool:A.split(/\s+/)[0],command:A,clean:C,uncovered:[]}]:[],fileConventions:{ok:!0},ciReadiness:{covered:e.ciRunsTests??!0},dependencies:{added:e.dependenciesAdded??[]},commit:{message:C8(e.commit.message)},pr:{title:C8(e.commit.prTitle).split(`
260
260
  `)[0],body:e.commit.prBody},ready:C,blockers:C?[]:[`the linter (${A||"the repo's linter"}) still reports problems in the test files`],summary:e.report.summary};return{adapt:{schemaVersion:1,items:f,ignored:[],summary:e.report.summary},generate:h("backend"),generateUi:h("ui"),finalize:w,dropped:n,ambiguous:s,placed:l}}function v8(e){let t=[...new Set([...e.tests,...e.maintained??[]].map(o=>o.file))],r=`${t.length} unit test file(s): ${t.join(", ")}`,n=C8(e.commitMessage?.trim()||"Skyramp Testbot: add unit tests"),s=e.lint?.command?.trim()??"",i=e.lint?.clean??!0;return{schemaVersion:1,lint:s?[{tool:s.split(/\s+/)[0],command:s,clean:i,uncovered:[]}]:[],fileConventions:{ok:!0},ciReadiness:{covered:!0},dependencies:{added:[]},commit:{message:n},pr:{title:n.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/testbot-core",
3
- "version": "0.13.0-v3.140",
3
+ "version": "0.13.0-v3.141",
4
4
  "description": "Skyramp Testbot engine: AI-powered deterministic test generation, execution and maintenance",
5
5
  "main": "dist/main.js",
6
6
  "//files": "An explicit allowlist, never a glob. `dist/` is gitignored, so without this key npm's .gitignore fallback would publish a package with no engine in it; with a glob it would publish the sourcemaps, whose sourcesContent embeds every src/*.ts verbatim. eval-entry.js is a development entry and must not ship. dist/VERSION.json exists only in a release-engine.yml build. assets/gen-reference/ is the staged codegen reference corpus, which generate.ts finds at ../assets from dist/.",