ripplo 0.4.12 → 0.4.13
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/index.js +96 -100
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var cn=Object.defineProperty;var ps=Object.getOwnPropertyDescriptor;var ms=Object.getOwnPropertyNames;var fs=Object.prototype.hasOwnProperty;var gs=(e,t)=>{for(var r in t)cn(e,r,{get:t[r],enumerable:!0})},ln=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ms(t))!fs.call(e,o)&&o!==r&&cn(e,o,{get:()=>t[o],enumerable:!(n=ps(t,o))||n.enumerable});return e},Kt=(e,t,r)=>(ln(e,t,"default"),r&&ln(r,t,"default"));import{execFileSync as ys}from"child_process";import hs from"fs";import
|
|
3
|
-
`)}function Ss(e){return e.length!==Qt.length?!1:e.every((t,r)=>t===Qt[r])}function fn(e){let r=er(e)?.envFiles??[".env",".env.local"],n=mt.join(e,".ripplo");r.forEach(o=>{let i=mt.resolve(n,o);mn.existsSync(i)&&Rs({override:!0,path:i,quiet:!0})}),tr=void 0}var Ps=pt.object({RIPPLO_APP_URL:pt.url(),RIPPLO_ENGINE_URL:pt.url(),RIPPLO_WEBHOOK_SECRET:pt.string().min(1)}),tr;function
|
|
2
|
+
var cn=Object.defineProperty;var ps=Object.getOwnPropertyDescriptor;var ms=Object.getOwnPropertyNames;var fs=Object.prototype.hasOwnProperty;var gs=(e,t)=>{for(var r in t)cn(e,r,{get:t[r],enumerable:!0})},ln=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ms(t))!fs.call(e,o)&&o!==r&&cn(e,o,{get:()=>t[o],enumerable:!(n=ps(t,o))||n.enumerable});return e},Kt=(e,t,r)=>(ln(e,t,"default"),r&&ln(r,t,"default"));import{execFileSync as ys}from"child_process";import hs from"fs";import dt from"path";function Jt(e){let t=bs(e);return t??dn(e)}function dn(e){let t=dt.dirname(e);return ws(dt.join(e,".ripplo"))?e:t===e?null:dn(t)}function ws(e){try{return hs.statSync(e).isDirectory()}catch{return!1}}function bs(e){let t=vs(["rev-parse","--show-toplevel"],e);if(t==null)return null;let r=t.trim();return r.length===0?null:dt.isAbsolute(r)?r:dt.resolve(e,r)}function vs(e,t){try{return ys("git",e,{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]})}catch{return null}}import mn from"fs";import mt from"path";import{config as Rs}from"dotenv";import{z as pt}from"zod";import ze from"fs";import Yt from"path";import{z as ut}from"zod";var un=Yt.join(".ripplo","project.json"),Qt=[".env",".env.local"],ks=ut.object({envFiles:ut.array(ut.string().min(1)).optional(),projectId:ut.string().min(1)});function Xt(e){return Yt.join(e,un)}function Zt(e){let t=Xt(e);if(!ze.existsSync(t))throw new Error(`ripplo: missing ${un}. Run \`ripplo init\` to create it.`);let r=JSON.parse(ze.readFileSync(t,"utf8")),n=ks.parse(r);return{envFiles:n.envFiles??Qt,projectId:n.projectId}}function er(e){let t=Xt(e);if(ze.existsSync(t))try{return Zt(e)}catch{return}}function pn({cwd:e,envFiles:t,projectId:r}){let n=Xt(e);ze.mkdirSync(Yt.dirname(n),{recursive:!0});let o={projectId:r};t!=null&&!Ss(t)&&(o.envFiles=[...t]),ze.writeFileSync(n,JSON.stringify(o,null,2)+`
|
|
3
|
+
`)}function Ss(e){return e.length!==Qt.length?!1:e.every((t,r)=>t===Qt[r])}function fn(e){let r=er(e)?.envFiles??[".env",".env.local"],n=mt.join(e,".ripplo");r.forEach(o=>{let i=mt.resolve(n,o);mn.existsSync(i)&&Rs({override:!0,path:i,quiet:!0})}),tr=void 0}var Ps=pt.object({RIPPLO_APP_URL:pt.url(),RIPPLO_ENGINE_URL:pt.url(),RIPPLO_WEBHOOK_SECRET:pt.string().min(1)}),tr;function Ae(){return tr??=xs(),tr}function xs(){let e=Ps.safeParse(process.env);if(!e.success){let r=e.error.issues.map(s=>` ${s.path.join(".")}: ${s.message}`).join(`
|
|
4
4
|
`),n=rr(process.cwd()),o=n.map(s=>` ${s}`).join(`
|
|
5
5
|
`),i=n.length>0?`
|
|
6
6
|
|
|
@@ -9,23 +9,23 @@ ${o}
|
|
|
9
9
|
If you're in a git worktree, the env file may not have been copied from the main checkout \u2014 recreate it (or symlink to a shared file outside the working tree).`:"";throw new Error(`ripplo: env config invalid:
|
|
10
10
|
${r}
|
|
11
11
|
|
|
12
|
-
Add missing values to the env file(s) declared in .ripplo/project.json.${i}`)}let t=e.data;return{appUrl:t.RIPPLO_APP_URL,engineUrl:t.RIPPLO_ENGINE_URL,webhookSecret:t.RIPPLO_WEBHOOK_SECRET}}function rr(e){let r=er(e)?.envFiles??[],n=mt.join(e,".ripplo");return r.map(o=>mt.resolve(n,o)).filter(o=>!mn.existsSync(o))}import Xg from"yargs";import{hideBin as Zg}from"yargs/helpers";import{graphql as Vc}from"gql.tada";async function ft(e,t,r){let n;try{return n=await e.context().newCDPSession(e),await r(n)}catch{return t}finally{await n?.detach().catch(()=>{})}}async function z({awaitPromise:e,expression:t,page:r}){return ft(r,void 0,async n=>{let o=await n.send("Runtime.evaluate",{awaitPromise:e,expression:t,returnByValue:!0});if(o.exceptionDetails==null)return o.result.value})}var Cs=Object.prototype.toString,je=Array.isArray||function(t){return Cs.call(t)==="[object Array]"};function or(e){return typeof e=="function"}function Es(e){return je(e)?"array":typeof e}function nr(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function gn(e,t){return e!=null&&typeof e=="object"&&t in e}function
|
|
13
|
-
`&&(p(),l="",c=0,r=!1);if(!
|
|
12
|
+
Add missing values to the env file(s) declared in .ripplo/project.json.${i}`)}let t=e.data;return{appUrl:t.RIPPLO_APP_URL,engineUrl:t.RIPPLO_ENGINE_URL,webhookSecret:t.RIPPLO_WEBHOOK_SECRET}}function rr(e){let r=er(e)?.envFiles??[],n=mt.join(e,".ripplo");return r.map(o=>mt.resolve(n,o)).filter(o=>!mn.existsSync(o))}import Xg from"yargs";import{hideBin as Zg}from"yargs/helpers";import{graphql as Vc}from"gql.tada";async function ft(e,t,r){let n;try{return n=await e.context().newCDPSession(e),await r(n)}catch{return t}finally{await n?.detach().catch(()=>{})}}async function z({awaitPromise:e,expression:t,page:r}){return ft(r,void 0,async n=>{let o=await n.send("Runtime.evaluate",{awaitPromise:e,expression:t,returnByValue:!0});if(o.exceptionDetails==null)return o.result.value})}var Cs=Object.prototype.toString,je=Array.isArray||function(t){return Cs.call(t)==="[object Array]"};function or(e){return typeof e=="function"}function Es(e){return je(e)?"array":typeof e}function nr(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function gn(e,t){return e!=null&&typeof e=="object"&&t in e}function As(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var Is=RegExp.prototype.test;function js(e,t){return Is.call(e,t)}var Ts=/\S/;function $s(e){return!js(Ts,e)}var Ns={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Os(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return Ns[r]})}var Ds=/\s*/,Ls=/\s+/,yn=/\s*=/,_s=/\s*\}/,Us=/#|\^|\/|>|\{|&|=|!/;function Vs(e,t){if(!e)return[];var r=!1,n=[],o=[],i=[],s=!1,a=!1,l="",c=0;function p(){if(s&&!a)for(;i.length;)delete o[i.pop()];else i=[];s=!1,a=!1}var m,k,_;function j(re){if(typeof re=="string"&&(re=re.split(Ls,2)),!je(re)||re.length!==2)throw new Error("Invalid tags: "+re);m=new RegExp(nr(re[0])+"\\s*"),k=new RegExp("\\s*"+nr(re[1])),_=new RegExp("\\s*"+nr("}"+re[1]))}j(t||X.tags);for(var f=new Ke(e),V,$,F,te,Ee,oe;!f.eos();){if(V=f.pos,F=f.scanUntil(m),F)for(var qe=0,W=F.length;qe<W;++qe)te=F.charAt(qe),$s(te)?(i.push(o.length),l+=te):(a=!0,r=!0,l+=" "),o.push(["text",te,V,V+1]),V+=1,te===`
|
|
13
|
+
`&&(p(),l="",c=0,r=!1);if(!f.scan(m))break;if(s=!0,$=f.scan(Us)||"name",f.scan(Ds),$==="="?(F=f.scanUntil(yn),f.scan(yn),f.scanUntil(k)):$==="{"?(F=f.scanUntil(_),f.scan(_s),f.scanUntil(k),$="&"):F=f.scanUntil(k),!f.scan(k))throw new Error("Unclosed tag at "+f.pos);if($==">"?Ee=[$,F,V,f.pos,l,c,r]:Ee=[$,F,V,f.pos],c++,o.push(Ee),$==="#"||$==="^")n.push(Ee);else if($==="/"){if(oe=n.pop(),!oe)throw new Error('Unopened section "'+F+'" at '+V);if(oe[1]!==F)throw new Error('Unclosed section "'+oe[1]+'" at '+V)}else $==="name"||$==="{"||$==="&"?a=!0:$==="="&&j(F)}if(p(),oe=n.pop(),oe)throw new Error('Unclosed section "'+oe[1]+'" at '+f.pos);return Hs(Fs(o))}function Fs(e){for(var t=[],r,n,o=0,i=e.length;o<i;++o)r=e[o],r&&(r[0]==="text"&&n&&n[0]==="text"?(n[1]+=r[1],n[3]=r[3]):(t.push(r),n=r));return t}function Hs(e){for(var t=[],r=t,n=[],o,i,s=0,a=e.length;s<a;++s)switch(o=e[s],o[0]){case"#":case"^":r.push(o),n.push(o),r=o[4]=[];break;case"/":i=n.pop(),i[5]=o[2],r=n.length>0?n[n.length-1][4]:t;break;default:r.push(o)}return t}function Ke(e){this.string=e,this.tail=e,this.pos=0}Ke.prototype.eos=function(){return this.tail===""};Ke.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var n=r[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};Ke.prototype.scanUntil=function(t){var r=this.tail.search(t),n;switch(r){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=n.length,n};function Ie(e,t){this.view=e,this.cache={".":this.view},this.parent=t}Ie.prototype.push=function(t){return new Ie(t,this)};Ie.prototype.lookup=function(t){var r=this.cache,n;if(r.hasOwnProperty(t))n=r[t];else{for(var o=this,i,s,a,l=!1;o;){if(t.indexOf(".")>0)for(i=o.view,s=t.split("."),a=0;i!=null&&a<s.length;)a===s.length-1&&(l=gn(i,s[a])||As(i,s[a])),i=i[s[a++]];else i=o.view[t],l=gn(o.view,t);if(l){n=i;break}o=o.parent}r[t]=n}return or(n)&&(n=n.call(this.view)),n};function B(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}B.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};B.prototype.parse=function(t,r){var n=this.templateCache,o=t+":"+(r||X.tags).join(":"),i=typeof n<"u",s=i?n.get(o):void 0;return s==null&&(s=Vs(t,r),i&&n.set(o,s)),s};B.prototype.render=function(t,r,n,o){var i=this.getConfigTags(o),s=this.parse(t,i),a=r instanceof Ie?r:new Ie(r,void 0);return this.renderTokens(s,a,n,t,o)};B.prototype.renderTokens=function(t,r,n,o,i){for(var s="",a,l,c,p=0,m=t.length;p<m;++p)c=void 0,a=t[p],l=a[0],l==="#"?c=this.renderSection(a,r,n,o,i):l==="^"?c=this.renderInverted(a,r,n,o,i):l===">"?c=this.renderPartial(a,r,n,i):l==="&"?c=this.unescapedValue(a,r):l==="name"?c=this.escapedValue(a,r,i):l==="text"&&(c=this.rawValue(a)),c!==void 0&&(s+=c);return s};B.prototype.renderSection=function(t,r,n,o,i){var s=this,a="",l=r.lookup(t[1]);function c(k){return s.render(k,r,n,i)}if(l){if(je(l))for(var p=0,m=l.length;p<m;++p)a+=this.renderTokens(t[4],r.push(l[p]),n,o,i);else if(typeof l=="object"||typeof l=="string"||typeof l=="number")a+=this.renderTokens(t[4],r.push(l),n,o,i);else if(or(l)){if(typeof o!="string")throw new Error("Cannot use higher-order sections without the original template");l=l.call(r.view,o.slice(t[3],t[5]),c),l!=null&&(a+=l)}else a+=this.renderTokens(t[4],r,n,o,i);return a}};B.prototype.renderInverted=function(t,r,n,o,i){var s=r.lookup(t[1]);if(!s||je(s)&&s.length===0)return this.renderTokens(t[4],r,n,o,i)};B.prototype.indentPartial=function(t,r,n){for(var o=r.replace(/[^ \t]/g,""),i=t.split(`
|
|
14
14
|
`),s=0;s<i.length;s++)i[s].length&&(s>0||!n)&&(i[s]=o+i[s]);return i.join(`
|
|
15
|
-
`)};B.prototype.renderPartial=function(t,r,n,o){if(n){var i=this.getConfigTags(o),s=or(n)?n(t[1]):n[t[1]];if(s!=null){var a=t[6],l=t[5],c=t[4],p=s;l==0&&c&&(p=this.indentPartial(s,c,a));var m=this.parse(p,i);return this.renderTokens(m,r,n,p,o)}}};B.prototype.unescapedValue=function(t,r){var n=r.lookup(t[1]);if(n!=null)return n};B.prototype.escapedValue=function(t,r,n){var o=this.getConfigEscape(n)||X.escape,i=r.lookup(t[1]);if(i!=null)return typeof i=="number"&&o===X.escape?String(i):o(i)};B.prototype.rawValue=function(t){return t[1]};B.prototype.getConfigTags=function(t){return je(t)?t:t&&typeof t=="object"?t.tags:void 0};B.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!je(t))return t.escape};var X={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){Ge.templateCache=e},get templateCache(){return Ge.templateCache}},Ge=new B;X.clearCache=function(){return Ge.clearCache()};X.parse=function(t,r){return Ge.parse(t,r)};X.render=function(t,r,n,o){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Es(t)+'" was given as the first argument for mustache#render(template, view, partials)');return Ge.render(t,r,n,o)};X.escape=Os;X.Scanner=Ke;X.Context=Ae;X.Writer=B;var hn=X;function ir({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Ws({def:r,name:t})]))}var Bs={boolean:!1,number:0,string:""};function Ws({def:e,name:t}){if(e.type==="env"){let r=process.env[e.key];if(r==null)throw new Error(`Environment variable "${e.key}" not set for variable "${t}"`);return r}return e.default??Bs[e.type]??""}function gt({ref:e,variables:t}){if(e.type==="static")return e.value;let r=t[e.name];if(r==null||typeof r=="object")throw new Error(`Variable "${e.name}" is not defined`);return r}function M({ref:e,variables:t}){let r=String(gt({ref:e,variables:t}));return ht({raw:r,variables:t})}function yt({ref:e,variables:t}){let r=gt({ref:e,variables:t});return typeof r=="string"?ht({raw:r,variables:t}):r}function ht({raw:e,variables:t}){return hn.render(e,t,{},{escape:r=>r})}function sr({ref:e,variables:t}){let r=gt({ref:e,variables:t});if(typeof r=="number")return r;let n=Number(r);if(Number.isNaN(n))throw new TypeError(`Cannot convert "${String(r)}" to number`);return n}function Te({name:e,store:t,value:r}){return{...t,[e]:r}}function O({locator:e,page:t,variables:r}){switch(e.by){case"testId":return t.getByTestId(wn(e.value,r));case"role":return t.getByRole(e.role,{exact:!0,name:e.name==null?void 0:wn(e.name,r)})}}function wn(e,t){return t==null?e:ht({raw:e,variables:t})}async function bn({node:e,page:t,timeout:r}){await O({locator:e.source,page:t,variables:void 0}).dragTo(O({locator:e.target,page:t,variables:void 0}),{timeout:r})}async function vn({node:e,page:t,timeout:r}){await O({locator:e.locator,page:t,variables:void 0}).click({button:"right",timeout:r})}function kn({node:e,page:t,variables:r}){return t.once("dialog",async n=>{e.action==="accept"?await n.accept(e.promptText??void 0):await n.dismiss()}),{variables:r}}async function Sn({node:e,page:t,variables:r}){if(e.action==="write"){if(e.value==null)throw new Error("clipboard write requires a value");let o=M({ref:e.value,variables:r}),i=JSON.stringify(o);return await z({awaitPromise:!0,expression:`navigator.clipboard.writeText(${i})`,page:t}),{variables:r}}if(e.variable==null)throw new Error("clipboard read requires a variable name to store the result");let n=await z({awaitPromise:!0,expression:"navigator.clipboard.readText()",page:t})??"";return{variables:Te({name:e.variable,store:r,value:n})}}async function Rn({node:e,page:t}){let r=t.context();e.state==="granted"?await r.grantPermissions([e.permission]):await r.clearPermissions()}async function ar({node:e,page:t,timeout:r,variables:n}){switch(e.type){case"click":case"check":case"uncheck":case"clear":case"dblclick":case"focus":case"hover":case"scrollIntoView":return qs({node:e,page:t,timeout:r,variables:n});case"rightClick":return await vn({node:e,page:t,timeout:r}),{variables:n};case"goto":{let o=M({ref:e.url,variables:n});return await t.goto(o,{timeout:r,waitUntil:"domcontentloaded"}),await t.waitForLoadState("load",{timeout:r}),await t.waitForFunction("document.body != null && document.body.childElementCount > 0 && (document.body.textContent?.trim().length ?? 0) > 0",void 0,{timeout:r}),await z({awaitPromise:!0,expression:"new Promise((resolve) => { requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined))); })",page:t}),{variables:n}}case"fill":return Gs({node:e,page:t,timeout:r,variables:n});case"select":return Ks({node:e,page:t,timeout:r,variables:n});case"type":return Js({node:e,page:t,timeout:r,variables:n});case"press":return await zs({node:e,page:t,timeout:r}),{variables:n};case"drag":return await bn({node:e,page:t,timeout:r}),{variables:n};case"upload":return Qs({node:e,page:t,timeout:r,variables:n});case"extractText":return Ys({node:e,page:t,timeout:r,variables:n});case"setVariable":{let o=yt({ref:e.value,variables:n});return{variables:Te({name:e.variable,store:n,value:o})}}case"fail":throw new Error(e.message);case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:n};case"handleDialog":return kn({node:e,page:t,variables:n});case"clipboard":return Sn({node:e,page:t,variables:n});case"setPermission":return await Rn({node:e,page:t}),{variables:n}}}var Ms={check:"check",clear:"clear",click:"click",dblclick:"dblclick",focus:"focus",hover:"hover",scrollIntoView:"scrollIntoViewIfNeeded",uncheck:"uncheck"};async function qs({node:e,page:t,timeout:r,variables:n}){return await O({locator:e.locator,page:t,variables:n})[Ms[e.type]]({timeout:r}),{variables:n}}async function zs({node:e,page:t,timeout:r}){e.locator==null?await t.keyboard.press(e.key):await O({locator:e.locator,page:t,variables:void 0}).press(e.key,{timeout:r})}async function Gs({node:e,page:t,timeout:r,variables:n}){let o=M({ref:e.value,variables:n});return await O({locator:e.locator,page:t,variables:n}).fill(o,{timeout:r}),{variables:n}}async function Ks({node:e,page:t,timeout:r,variables:n}){let o=M({ref:e.value,variables:n});return await O({locator:e.locator,page:t,variables:n}).selectOption(o,{timeout:r}),{variables:n}}async function Js({node:e,page:t,timeout:r,variables:n}){let o=M({ref:e.value,variables:n});return await O({locator:e.locator,page:t,variables:n}).pressSequentially(o,{timeout:r}),{variables:n}}async function Qs({node:e,page:t,timeout:r,variables:n}){return await O({locator:e.locator,page:t,variables:n}).setInputFiles(e.files,{timeout:r}),{variables:n}}async function Ys({node:e,page:t,timeout:r,variables:n}){let o=await O({locator:e.locator,page:t,variables:n}).textContent({timeout:r});if(o==null)throw new Error("extractText: element had no text content");return{variables:Te({name:e.variable,store:n,value:o})}}var H={};gs(H,{default:()=>Xs});Kt(H,Uy);import*as Uy from"playwright/test";import{default as Xs}from"playwright/test";async function lr({expected:e,locator:t,operator:r,timeout:n}){await Je({expected:e,operator:r,timeout:n,read:async()=>await t.textContent()??""});let o=await Qe(async()=>await t.textContent()??"");return $e({actual:o,expected:e,label:"Text",operator:r})}async function cr({expected:e,operator:t,page:r,timeout:n}){return await Je({expected:e,operator:t,timeout:n,read:()=>Promise.resolve(r.url())}),$e({actual:r.url(),expected:e,label:"URL",operator:t})}async function Pn({expected:e,operator:t,page:r,timeout:n}){await Je({expected:e,operator:t,timeout:n,read:()=>r.title()});let o=await Qe(()=>r.title());return $e({actual:o,expected:e,label:"Title",operator:t})}async function ur({expected:e,locator:t,operator:r,timeout:n}){await H.expect.poll(async()=>On({actual:await t.count(),expected:e,operator:r}),{timeout:n}).toBe(!0).catch(()=>{});let o=await t.count();return Nn({actual:o,expected:e,label:"Count",operator:r})}async function dr({expected:e,locator:t,operator:r,timeout:n}){await Je({expected:e,operator:r,timeout:n,read:()=>t.inputValue()});let o=await Qe(()=>t.inputValue());return $e({actual:o,expected:e,label:"Value",operator:r})}async function pr({locator:e,timeout:t}){return ge({description:"Element is visible",failureDetail:"Element not visible",run:()=>(0,H.expect)(e).toBeVisible({timeout:t})})}async function mr({locator:e,timeout:t}){return ge({description:"Element is not visible",failureDetail:"Element still visible",run:()=>(0,H.expect)(e).toBeHidden({timeout:t})})}async function xn({attribute:e,expected:t,locator:r,operator:n,timeout:o}){await Je({expected:t,operator:n,timeout:o,read:async()=>await r.getAttribute(e)??""});let i=await Qe(async()=>await r.getAttribute(e)??"");return $e({actual:i,expected:t,label:`Attribute "${e}"`,operator:n})}async function Cn({locator:e,timeout:t}){return ge({description:"Element is enabled",failureDetail:"Element is disabled or not found",run:()=>(0,H.expect)(e).toBeEnabled({timeout:t})})}async function En({locator:e,timeout:t}){return ge({description:"Element is disabled",failureDetail:"Element is enabled or not found",run:()=>(0,H.expect)(e).toBeDisabled({timeout:t})})}async function In({locator:e,timeout:t}){return ge({description:"Element is checked",failureDetail:"Element is not checked",run:()=>(0,H.expect)(e).toBeChecked({timeout:t})})}async function An({locator:e,timeout:t}){return ge({description:"Element is not checked",failureDetail:"Element is checked",run:()=>(0,H.expect)(e).not.toBeChecked({timeout:t})})}async function jn({locator:e,timeout:t}){return ge({description:"Element is focused",failureDetail:"Element is not focused",run:()=>(0,H.expect)(e).toBeFocused({timeout:t})})}async function Tn({locator:e,timeout:t}){return ge({description:"Element is not focused",failureDetail:"Element is focused",run:()=>(0,H.expect)(e).not.toBeFocused({timeout:t})})}async function ge({description:e,failureDetail:t,run:r}){try{return await r(),{description:e,detail:void 0,status:"passed"}}catch{return{description:e,detail:t,status:"failed"}}}async function Je({expected:e,operator:t,read:r,timeout:n}){await H.expect.poll(async()=>{let o=await Qe(r);return $n({actual:o,expected:e,operator:t})},{timeout:n}).toBe(!0).catch(()=>{})}async function Qe(e){return e().catch(()=>"")}function $e(e){let t=`${e.label} ${e.operator} "${e.expected}"`,r=$n(e),n=r?void 0:`Got: "${e.actual}"`;return{description:t,detail:n,status:r?"passed":"failed"}}function $n({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="contains"?e.includes(t):r==="startsWith"?e.startsWith(t):r==="endsWith"?e.endsWith(t):new RegExp(t).test(e)}function Nn(e){let t=`${e.label} ${e.operator} ${String(e.expected)}`,r=On(e),n=r?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:n,status:r?"passed":"failed"}}function On({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="greaterThan"?e>t:r==="greaterThanOrEqual"?e>=t:r==="lessThan"?e<t:e<=t}import{execFile as ea}from"child_process";import{createRequire as ta}from"module";import Dn from"fs";import Ln from"path";import{chromium as _n}from"playwright";import Wy from"fs";import qy from"path";import Zs from"pino";var f=Zs({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});async function Ye({headed:e}){process.env.PW_TEST_SCREENSHOT_NO_FONTS_READY="1";try{return await _n.launch({headless:!e})}catch(t){throw ra(t)?new Error(`Playwright browsers are not installed. Run:
|
|
15
|
+
`)};B.prototype.renderPartial=function(t,r,n,o){if(n){var i=this.getConfigTags(o),s=or(n)?n(t[1]):n[t[1]];if(s!=null){var a=t[6],l=t[5],c=t[4],p=s;l==0&&c&&(p=this.indentPartial(s,c,a));var m=this.parse(p,i);return this.renderTokens(m,r,n,p,o)}}};B.prototype.unescapedValue=function(t,r){var n=r.lookup(t[1]);if(n!=null)return n};B.prototype.escapedValue=function(t,r,n){var o=this.getConfigEscape(n)||X.escape,i=r.lookup(t[1]);if(i!=null)return typeof i=="number"&&o===X.escape?String(i):o(i)};B.prototype.rawValue=function(t){return t[1]};B.prototype.getConfigTags=function(t){return je(t)?t:t&&typeof t=="object"?t.tags:void 0};B.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!je(t))return t.escape};var X={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){Ge.templateCache=e},get templateCache(){return Ge.templateCache}},Ge=new B;X.clearCache=function(){return Ge.clearCache()};X.parse=function(t,r){return Ge.parse(t,r)};X.render=function(t,r,n,o){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Es(t)+'" was given as the first argument for mustache#render(template, view, partials)');return Ge.render(t,r,n,o)};X.escape=Os;X.Scanner=Ke;X.Context=Ie;X.Writer=B;var hn=X;function ir({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Ws({def:r,name:t})]))}var Bs={boolean:!1,number:0,string:""};function Ws({def:e,name:t}){if(e.type==="env"){let r=process.env[e.key];if(r==null)throw new Error(`Environment variable "${e.key}" not set for variable "${t}"`);return r}return e.default??Bs[e.type]??""}function gt({ref:e,variables:t}){if(e.type==="static")return e.value;let r=t[e.name];if(r==null||typeof r=="object")throw new Error(`Variable "${e.name}" is not defined`);return r}function M({ref:e,variables:t}){let r=String(gt({ref:e,variables:t}));return ht({raw:r,variables:t})}function yt({ref:e,variables:t}){let r=gt({ref:e,variables:t});return typeof r=="string"?ht({raw:r,variables:t}):r}function ht({raw:e,variables:t}){return hn.render(e,t,{},{escape:r=>r})}function sr({ref:e,variables:t}){let r=gt({ref:e,variables:t});if(typeof r=="number")return r;let n=Number(r);if(Number.isNaN(n))throw new TypeError(`Cannot convert "${String(r)}" to number`);return n}function Te({name:e,store:t,value:r}){return{...t,[e]:r}}function N({locator:e,page:t,variables:r}){switch(e.by){case"testId":return t.getByTestId(wn(e.value,r));case"role":return t.getByRole(e.role,{exact:!0,name:e.name==null?void 0:wn(e.name,r)})}}function wn(e,t){return t==null?e:ht({raw:e,variables:t})}async function bn({node:e,page:t,timeout:r}){await N({locator:e.source,page:t,variables:void 0}).dragTo(N({locator:e.target,page:t,variables:void 0}),{timeout:r})}async function vn({node:e,page:t,timeout:r}){await N({locator:e.locator,page:t,variables:void 0}).click({button:"right",timeout:r})}function kn({node:e,page:t,variables:r}){return t.once("dialog",async n=>{e.action==="accept"?await n.accept(e.promptText??void 0):await n.dismiss()}),{variables:r}}async function Sn({node:e,page:t,variables:r}){if(e.action==="write"){if(e.value==null)throw new Error("clipboard write requires a value");let o=M({ref:e.value,variables:r}),i=JSON.stringify(o);return await z({awaitPromise:!0,expression:`navigator.clipboard.writeText(${i})`,page:t}),{variables:r}}if(e.variable==null)throw new Error("clipboard read requires a variable name to store the result");let n=await z({awaitPromise:!0,expression:"navigator.clipboard.readText()",page:t})??"";return{variables:Te({name:e.variable,store:r,value:n})}}async function Rn({node:e,page:t}){let r=t.context();e.state==="granted"?await r.grantPermissions([e.permission]):await r.clearPermissions()}async function ar({node:e,page:t,timeout:r,variables:n}){switch(e.type){case"click":case"check":case"uncheck":case"clear":case"dblclick":case"focus":case"hover":case"scrollIntoView":return qs({node:e,page:t,timeout:r,variables:n});case"rightClick":return await vn({node:e,page:t,timeout:r}),{variables:n};case"goto":{let o=M({ref:e.url,variables:n});return await t.goto(o,{timeout:r,waitUntil:"domcontentloaded"}),await t.waitForLoadState("load",{timeout:r}),await t.waitForFunction("document.body != null && document.body.childElementCount > 0 && (document.body.textContent?.trim().length ?? 0) > 0",void 0,{timeout:r}),await z({awaitPromise:!0,expression:"new Promise((resolve) => { requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined))); })",page:t}),{variables:n}}case"fill":return Gs({node:e,page:t,timeout:r,variables:n});case"select":return Ks({node:e,page:t,timeout:r,variables:n});case"type":return Js({node:e,page:t,timeout:r,variables:n});case"press":return await zs({node:e,page:t,timeout:r}),{variables:n};case"drag":return await bn({node:e,page:t,timeout:r}),{variables:n};case"upload":return Qs({node:e,page:t,timeout:r,variables:n});case"extractText":return Ys({node:e,page:t,timeout:r,variables:n});case"setVariable":{let o=yt({ref:e.value,variables:n});return{variables:Te({name:e.variable,store:n,value:o})}}case"fail":throw new Error(e.message);case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:n};case"handleDialog":return kn({node:e,page:t,variables:n});case"clipboard":return Sn({node:e,page:t,variables:n});case"setPermission":return await Rn({node:e,page:t}),{variables:n}}}var Ms={check:"check",clear:"clear",click:"click",dblclick:"dblclick",focus:"focus",hover:"hover",scrollIntoView:"scrollIntoViewIfNeeded",uncheck:"uncheck"};async function qs({node:e,page:t,timeout:r,variables:n}){return await N({locator:e.locator,page:t,variables:n})[Ms[e.type]]({timeout:r}),{variables:n}}async function zs({node:e,page:t,timeout:r}){e.locator==null?await t.keyboard.press(e.key):await N({locator:e.locator,page:t,variables:void 0}).press(e.key,{timeout:r})}async function Gs({node:e,page:t,timeout:r,variables:n}){let o=M({ref:e.value,variables:n});return await N({locator:e.locator,page:t,variables:n}).fill(o,{timeout:r}),{variables:n}}async function Ks({node:e,page:t,timeout:r,variables:n}){let o=M({ref:e.value,variables:n});return await N({locator:e.locator,page:t,variables:n}).selectOption(o,{timeout:r}),{variables:n}}async function Js({node:e,page:t,timeout:r,variables:n}){let o=M({ref:e.value,variables:n});return await N({locator:e.locator,page:t,variables:n}).pressSequentially(o,{timeout:r}),{variables:n}}async function Qs({node:e,page:t,timeout:r,variables:n}){return await N({locator:e.locator,page:t,variables:n}).setInputFiles(e.files,{timeout:r}),{variables:n}}async function Ys({node:e,page:t,timeout:r,variables:n}){let o=await N({locator:e.locator,page:t,variables:n}).textContent({timeout:r});if(o==null)throw new Error("extractText: element had no text content");return{variables:Te({name:e.variable,store:n,value:o})}}var H={};gs(H,{default:()=>Xs});Kt(H,Uy);import*as Uy from"playwright/test";import{default as Xs}from"playwright/test";async function lr({expected:e,locator:t,operator:r,timeout:n}){await Je({expected:e,operator:r,timeout:n,read:async()=>await t.textContent()??""});let o=await Qe(async()=>await t.textContent()??"");return $e({actual:o,expected:e,label:"Text",operator:r})}async function cr({expected:e,operator:t,page:r,timeout:n}){return await Je({expected:e,operator:t,timeout:n,read:()=>Promise.resolve(r.url())}),$e({actual:r.url(),expected:e,label:"URL",operator:t})}async function Pn({expected:e,operator:t,page:r,timeout:n}){await Je({expected:e,operator:t,timeout:n,read:()=>r.title()});let o=await Qe(()=>r.title());return $e({actual:o,expected:e,label:"Title",operator:t})}async function dr({expected:e,locator:t,operator:r,timeout:n}){await H.expect.poll(async()=>On({actual:await t.count(),expected:e,operator:r}),{timeout:n}).toBe(!0).catch(()=>{});let o=await t.count();return Nn({actual:o,expected:e,label:"Count",operator:r})}async function ur({expected:e,locator:t,operator:r,timeout:n}){await Je({expected:e,operator:r,timeout:n,read:()=>t.inputValue()});let o=await Qe(()=>t.inputValue());return $e({actual:o,expected:e,label:"Value",operator:r})}async function pr({locator:e,timeout:t}){return ge({description:"Element is visible",failureDetail:"Element not visible",run:()=>(0,H.expect)(e).toBeVisible({timeout:t})})}async function mr({locator:e,timeout:t}){return ge({description:"Element is not visible",failureDetail:"Element still visible",run:()=>(0,H.expect)(e).toBeHidden({timeout:t})})}async function xn({attribute:e,expected:t,locator:r,operator:n,timeout:o}){await Je({expected:t,operator:n,timeout:o,read:async()=>await r.getAttribute(e)??""});let i=await Qe(async()=>await r.getAttribute(e)??"");return $e({actual:i,expected:t,label:`Attribute "${e}"`,operator:n})}async function Cn({locator:e,timeout:t}){return ge({description:"Element is enabled",failureDetail:"Element is disabled or not found",run:()=>(0,H.expect)(e).toBeEnabled({timeout:t})})}async function En({locator:e,timeout:t}){return ge({description:"Element is disabled",failureDetail:"Element is enabled or not found",run:()=>(0,H.expect)(e).toBeDisabled({timeout:t})})}async function An({locator:e,timeout:t}){return ge({description:"Element is checked",failureDetail:"Element is not checked",run:()=>(0,H.expect)(e).toBeChecked({timeout:t})})}async function In({locator:e,timeout:t}){return ge({description:"Element is not checked",failureDetail:"Element is checked",run:()=>(0,H.expect)(e).not.toBeChecked({timeout:t})})}async function jn({locator:e,timeout:t}){return ge({description:"Element is focused",failureDetail:"Element is not focused",run:()=>(0,H.expect)(e).toBeFocused({timeout:t})})}async function Tn({locator:e,timeout:t}){return ge({description:"Element is not focused",failureDetail:"Element is focused",run:()=>(0,H.expect)(e).not.toBeFocused({timeout:t})})}async function ge({description:e,failureDetail:t,run:r}){try{return await r(),{description:e,detail:void 0,status:"passed"}}catch{return{description:e,detail:t,status:"failed"}}}async function Je({expected:e,operator:t,read:r,timeout:n}){await H.expect.poll(async()=>{let o=await Qe(r);return $n({actual:o,expected:e,operator:t})},{timeout:n}).toBe(!0).catch(()=>{})}async function Qe(e){return e().catch(()=>"")}function $e(e){let t=`${e.label} ${e.operator} "${e.expected}"`,r=$n(e),n=r?void 0:`Got: "${e.actual}"`;return{description:t,detail:n,status:r?"passed":"failed"}}function $n({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="contains"?e.includes(t):r==="startsWith"?e.startsWith(t):r==="endsWith"?e.endsWith(t):new RegExp(t).test(e)}function Nn(e){let t=`${e.label} ${e.operator} ${String(e.expected)}`,r=On(e),n=r?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:n,status:r?"passed":"failed"}}function On({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="greaterThan"?e>t:r==="greaterThanOrEqual"?e>=t:r==="lessThan"?e<t:e<=t}import{execFile as ea}from"child_process";import{createRequire as ta}from"module";import Dn from"fs";import Ln from"path";import{chromium as _n}from"playwright";import Wy from"fs";import qy from"path";import Zs from"pino";var g=Zs({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});async function Ye({headed:e}){process.env.PW_TEST_SCREENSHOT_NO_FONTS_READY="1";try{return await _n.launch({headless:!e})}catch(t){throw ra(t)?new Error(`Playwright browsers are not installed. Run:
|
|
16
16
|
|
|
17
17
|
npx playwright install chromium
|
|
18
|
-
`):t}}async function fr(){let e=_n.executablePath();if(Dn.existsSync(e))return;
|
|
18
|
+
`):t}}async function fr(){let e=_n.executablePath();if(Dn.existsSync(e))return;g.info("Chromium not found. Installing via Playwright...");let t=ta(import.meta.url),r=Ln.dirname(t.resolve("playwright/package.json")),n=Ln.join(r,"cli.js");if(await new Promise((o,i)=>{ea(process.execPath,[n,"install","chromium"],s=>{if(s!=null){i(new Error(`Playwright install failed: ${s.message}`));return}o()})}),!Dn.existsSync(e))throw new Error(`Playwright browser installation failed. Try running manually:
|
|
19
19
|
|
|
20
20
|
npx playwright install chromium
|
|
21
|
-
`);
|
|
21
|
+
`);g.info("\u2713 Chromium installed")}function ra(e){return e instanceof Error?e.message.includes("Executable doesn't exist"):!1}import{readdir as la,rm as ca,stat as da}from"fs/promises";import ih from"os";import Fn from"path";import{graphql as ua}from"gql.tada";import{print as na}from"graphql";var oa=15e3;async function y(e){let t=na(e.document),r=JSON.stringify({query:t,variables:e.variables}),n=`${e.config.ripploServerUrl}/graphql`,o;try{o=await fetch(n,{body:r,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(oa)})}catch(s){let a=s instanceof Error?s.message:String(s);throw new Error(`Failed to connect to Ripplo server at ${e.config.ripploServerUrl}. Make sure \`npx ripplo\` is running and your internet connection is active. Details: ${a}`)}let i=await ia({res:o,url:n});if(!sa(i))throw new Error("Invalid GraphQL response");if(aa(i))throw new Error(i.errors.map(s=>s.message).join(", "));if(i.data==null)throw new Error("No data returned from server");return i.data}async function ia({res:e,url:t}){let r=await e.text();if(r.length===0)throw new Error(`Empty response from Ripplo server at ${t} (status ${String(e.status)}). The server may have restarted or the request was rejected before a body was sent.`);try{return JSON.parse(r)}catch{throw new Error(`Non-JSON response from Ripplo server at ${t} (status ${String(e.status)}): ${r.slice(0,200)}`)}}function sa(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function aa(e){return Array.isArray(e.errors)&&e.errors.length>0}var Un=Fn.join(process.cwd(),".ripplo","debug"),Vn=360*60*1e3,dh=ua(`
|
|
22
22
|
mutation RevokeCurrentCliToken {
|
|
23
23
|
revokeCurrentCliToken
|
|
24
24
|
}
|
|
25
|
-
`);async function gr({maxRuns:e}){try{let r=(await la(Un,{withFileTypes:!0})).filter(c=>c.isDirectory()),n=Date.now(),o=await Promise.all(r.map(async c=>{let p=Fn.join(Un,c.name),m=await
|
|
25
|
+
`);async function gr({maxRuns:e}){try{let r=(await la(Un,{withFileTypes:!0})).filter(c=>c.isDirectory()),n=Date.now(),o=await Promise.all(r.map(async c=>{let p=Fn.join(Un,c.name),m=await da(p);return{dirPath:p,mtime:m.mtimeMs}})),i=o.filter(c=>n-c.mtime>Vn),a=o.filter(c=>n-c.mtime<=Vn).toSorted((c,p)=>p.mtime-c.mtime).slice(e),l=[...i,...a];if(l.length===0)return;await Promise.allSettled(l.map(c=>ca(c.dirPath,{force:!0,recursive:!0}))),g.info("Pruned %d old debug run(s)",l.length)}catch{g.warn("Debug run pruning failed, ignoring")}}var pa=5e3;async function yr({appUrl:e}){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(pa)})}catch(t){let r=t instanceof Error?t.message:String(t);throw g.debug("App URL reachability check failed: %s",r),new Error([`Could not reach your dev server at ${e}.`,"","Troubleshooting:",` 1. Make sure your app is running at ${e}`," 2. Check RIPPLO_APP_URL in the env file declared in .ripplo/project.json"," 3. If you're in a git worktree, RIPPLO_APP_URL and RIPPLO_ENGINE_URL must point at this worktree's dev server port (not main's)"].join(`
|
|
26
26
|
`))}}import tt from"fs";import xe from"fs";import ma from"os";import Xe from"path";var fa=".local",ga=".ripplo";function hr(e){return Xe.join(e,".ripplo",fa)}function Ze(e){let t=hr(e);xe.existsSync(t)||xe.mkdirSync(t,{recursive:!0});let r=Xe.join(t,".gitignore");return xe.existsSync(r)||xe.writeFileSync(r,`*
|
|
27
27
|
`),t}function et(e,t){return Xe.join(hr(e),t)}function wr(){return Xe.join(ma.homedir(),ga)}function br(){let e=wr();return xe.existsSync(e)?xe.chmodSync(e,448):xe.mkdirSync(e,{mode:448,recursive:!0}),e}function ye(e){return Xe.join(wr(),e)}function Z(){let e=process.env.RIPPLO_TOKEN;if(e!=null&&e.trim().length>0)return e.trim();let t=ye("token");if(!tt.existsSync(t))return null;let r=tt.readFileSync(t,"utf8").trim();return r.length===0?null:r}function vr(e){br(),tt.writeFileSync(ye("token"),e+`
|
|
28
|
-
`,{mode:384})}function kr(){let e=ye("token");return tt.existsSync(e)?(tt.unlinkSync(e),!0):!1}import{z as
|
|
28
|
+
`,{mode:384})}function kr(){let e=ye("token");return tt.existsSync(e)?(tt.unlinkSync(e),!0):!1}import{z as ue}from"zod";import{z as wt}from"zod";var ya=wt.object({__codec:wt.string().min(1),data:wt.unknown(),version:wt.number().int().positive()}),bt=class extends Error{codec;currentVersion;gotVersion;constructor(t){super(`Unsupported ${t.codec} version ${String(t.gotVersion)} (current ${String(t.currentVersion)}). Upgrade Ripplo or rebuild with a compatible CLI.`),this.name="CodecVersionError",this.codec=t.codec,this.currentVersion=t.currentVersion,this.gotVersion=t.gotVersion}},vt=class extends Error{constructor(t){super(`Codec mismatch: expected "${t.expected}", got "${t.got}"`),this.name="CodecMismatchError"}};function kt(e){return Hn({legacy:void 0,migrators:[],name:e,schemas:[]})}function Hn(e){return{initial:t=>Sr(t,{...e,schemas:[t]}),legacy:t=>Hn({...e,legacy:t})}}function Sr(e,t){return{build:()=>ha(e,t),legacy:r=>Sr(e,{...t,legacy:r}),upgrade:(r,n)=>{let o=n;return Sr(r,{...t,migrators:[...t.migrators,o],schemas:[...t.schemas,r]})}}}function ha(e,t){let r=t.schemas.length;return{currentVersion:r,name:t.name,decode:n=>wa(e,t,n),encode:n=>({__codec:t.name,data:n,version:r})}}function wa(e,t,r){let{data:n,version:o}=ba(t,r),i=Bn(t,n,o);return e.parse(i)}function ba(e,t){let r=ya.safeParse(t);if(r.success){if(r.data.__codec!==e.name)throw new vt({expected:e.name,got:r.data.__codec});return{data:r.data.data,version:r.data.version}}if(e.legacy!=null&&e.legacy.detect(t))return{data:t,version:e.legacy.assumedVersion};throw new Error(`Cannot decode "${e.name}": value is not a codec envelope and no legacy detector matched.`)}function Bn(e,t,r){let n=e.schemas.length;if(r>n)throw new bt({codec:e.name,currentVersion:n,gotVersion:r});if(r===n)return t;let o=e.schemas[r-1];if(o==null)throw new Error(`Codec "${e.name}" missing schema for v${String(r)}; cannot migrate.`);let i=o.parse(t),s=e.migrators[r-1];if(s==null)throw new Error(`Codec "${e.name}" missing migrator v${String(r)} \u2192 v${String(r+1)}.`);return Bn(e,s(i),r+1)}import{z as zn}from"zod";import{z as Ne}from"zod";var Rr=Ne.object({depends:Ne.array(Ne.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:Ne.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:Ne.array(Ne.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.");import{z as d}from"zod";import{z as he}from"zod";var va=he.object({by:he.literal("testId"),value:he.string().min(1)}),ka=he.object({by:he.literal("role"),name:he.string().optional(),role:he.string().min(1)}),S=he.discriminatedUnion("by",[va,ka]);import{z as Wn}from"zod";var we=Wn.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),St=Wn.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as A}from"zod";var Sa=A.object({type:A.literal("static"),value:A.union([A.string(),A.number(),A.boolean()])}),Rt=A.object({name:A.string().min(1),type:A.literal("variable")}),Pt=A.discriminatedUnion("type",[Sa,Rt]),G=A.discriminatedUnion("type",[A.object({type:A.literal("static"),value:A.string()}),Rt]),xt=A.discriminatedUnion("type",[A.object({type:A.literal("static"),value:A.number().int().nonnegative()}),Rt]),Pr=A.discriminatedUnion("type",[A.object({type:A.literal("static"),value:A.union([A.string(),A.number(),A.boolean()])}),Rt]);import{z as K}from"zod";var Ct=K.discriminatedUnion("type",[K.object({default:K.string().optional(),type:K.literal("string")}),K.object({default:K.number().optional(),type:K.literal("number")}),K.object({default:K.boolean().optional(),type:K.literal("boolean")}),K.object({key:K.string().min(1),type:K.literal("env")})]);var b={id:d.string().min(1).max(200),label:d.string().max(500).optional(),next:d.string().max(200).optional(),uiOnly:d.boolean().optional()},Mn=500,Ra=d.object({...b,type:d.literal("goto"),url:G}),Pa=d.object({...b,locator:S,type:d.literal("click")}),xa=d.object({...b,locator:S,type:d.literal("fill"),value:G}),Ca=d.object({...b,locator:S,type:d.literal("select"),value:G}),Ea=d.object({...b,locator:S,type:d.literal("hover")}),Aa=d.object({...b,key:d.string().min(1),locator:S.optional(),type:d.literal("press")}),Ia=d.object({...b,locator:S,type:d.literal("check")}),ja=d.object({...b,locator:S,type:d.literal("uncheck")}),Ta=d.object({...b,height:d.number().int().positive(),type:d.literal("setViewport"),width:d.number().int().positive()}),$a=d.object({...b,message:d.string().min(1),type:d.literal("fail")}),Na=d.object({...b,type:d.literal("setVariable"),value:Pt,variable:d.string().min(1)}),Oa=d.object({...b,locator:S,type:d.literal("extractText"),variable:d.string().min(1)}),Da=d.object({...b,files:d.array(d.string()).min(1),locator:S,type:d.literal("upload")}),La=d.object({...b,locator:S,type:d.literal("dblclick")}),_a=d.object({...b,source:S,target:S,type:d.literal("drag")}),Ua=d.object({...b,locator:S,type:d.literal("scrollIntoView")}),Va=d.object({...b,locator:S,type:d.literal("type"),value:G}),Fa=d.object({...b,locator:S,type:d.literal("focus")}),Ha=d.object({...b,locator:S,type:d.literal("clear")}),Ba=d.object({...b,locator:S,type:d.literal("rightClick")}),Wa=d.object({...b,action:d.enum(["accept","dismiss"]),promptText:d.string().optional(),type:d.literal("handleDialog")}),Ma=d.object({...b,action:d.enum(["read","write"]),type:d.literal("clipboard"),value:G.optional(),variable:d.string().min(1).optional()}),qa=d.object({...b,permission:d.string().min(1),state:d.enum(["granted","prompt"]),type:d.literal("setPermission")}),za=d.object({...b,locator:S,type:d.literal("assertVisible")}),Ga=d.object({...b,locator:S,type:d.literal("assertNotVisible")}),Ka=d.object({...b,expected:G,locator:S,operator:we,type:d.literal("assertText")}),Ja=d.object({...b,expected:G,operator:we,type:d.literal("assertUrl")}),Qa=d.object({...b,expected:xt,locator:S,operator:St,type:d.literal("assertCount")}),Ya=d.object({...b,expected:G,locator:S,operator:we,type:d.literal("assertValue")}),Xa=d.object({...b,attribute:d.string().min(1),expected:G,locator:S,operator:we,type:d.literal("assertAttribute")}),Za=d.object({...b,locator:S,type:d.literal("assertEnabled")}),el=d.object({...b,locator:S,type:d.literal("assertDisabled")}),tl=d.object({...b,expected:G,operator:we,type:d.literal("assertTitle")}),rl=d.object({...b,locator:S,type:d.literal("assertChecked")}),nl=d.object({...b,locator:S,type:d.literal("assertNotChecked")}),ol=d.object({...b,locator:S,type:d.literal("assertFocused")}),il=d.object({...b,locator:S,type:d.literal("assertNotFocused")}),sl=d.object({...b,budget:d.enum(["fast","slow","async"]),observer:d.string().min(1).max(200),params:d.record(d.string().max(200),Pr),type:d.literal("assertObserver")}),qn=d.discriminatedUnion("type",[Ra,Pa,xa,Ca,Ea,Aa,Ia,ja,za,Ga,Ka,Ja,Qa,Ya,Xa,Za,el,Ta,$a,Na,Oa,Da,La,_a,Ua,Va,Fa,Ha,Ba,Wa,Ma,qa,tl,rl,nl,ol,il,sl]),Et=d.object({entryNode:d.string().min(1).max(200),nodes:d.record(d.string().max(200),qn).refine(e=>Object.keys(e).length<=Mn,`Workflow has more than ${String(Mn)} nodes`),uiOnly:d.boolean().optional(),variableNamespaces:d.record(d.string().max(200),d.string().max(500)).optional(),variables:d.record(d.string().max(200),Ct).optional()});var al=zn.record(zn.string().max(200),Rr),ll={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&"entryNode"in e&&"nodes"in e},cl={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&!("__codec"in e)},xr=kt("workflow-spec").legacy(ll).initial(Et).build(),dl=kt("precondition-map").legacy(cl).initial(al).build();import{z as Cr}from"zod";var Gn=["fast","slow","async"],ul=Cr.object({budget:Cr.enum(Gn).describe("Polling budget tier: fast | slow | async"),description:Cr.string().min(1).describe("Human-readable description of what this observer checks")}).describe("A named backend state observer. Tests assert against it with assert.backend(observer, params). Implementation lives on the user's server.");import{graphql as Lr,readFragment as At}from"gql.tada";import{mkdir as Er,writeFile as be}from"fs/promises";import ne from"path";async function Kn({context:e,page:t,runId:r,stepIndex:n,stepResult:o}){try{let i=ne.join(process.cwd(),".ripplo","debug",r,"steps",String(n));await Er(i,{recursive:!0});let s={assertions:o.assertions,detail:o.detail,duration:o.duration,nodeId:o.nodeId,nodeType:o.nodeType,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url};await Promise.all([be(ne.join(i,"info.json"),JSON.stringify(s,null,2)),pl({context:e,page:t,stepDir:i})])}catch(i){let s=i instanceof Error?i.message:String(i);g.warn("Failed to write step debug data for step %d: %s",n,s)}}async function pl({context:e,page:t,stepDir:r}){let[n,o,i,s]=await Promise.all([ml(t),fl(t),hl({context:e,page:t}),gl(t)]);await Promise.all([be(ne.join(r,"dom.html"),n),be(ne.join(r,"accessibility-tree.txt"),o),be(ne.join(r,"storage.json"),JSON.stringify(i,null,2)),s==null?Promise.resolve():be(ne.join(r,"screenshot.png"),s)])}async function ml(e){return await z({awaitPromise:!1,expression:"document.documentElement.outerHTML",page:e})??"(unable to capture DOM)"}async function fl(e){return ft(e,"(unable to capture accessibility tree)",async t=>{let r=await t.send("Accessibility.getFullAXTree");return JSON.stringify(r,null,2)})}async function gl(e){return ft(e,void 0,async t=>{let r=await t.send("Page.captureScreenshot",{format:"png"});return Buffer.from(r.data,"base64")})}var yl=`(() => {
|
|
29
29
|
function dump(s) {
|
|
30
30
|
var out = {};
|
|
31
31
|
for (var i = 0; i < s.length; i++) {
|
|
@@ -35,39 +35,39 @@ Add missing values to the env file(s) declared in .ripplo/project.json.${i}`)}le
|
|
|
35
35
|
return out;
|
|
36
36
|
}
|
|
37
37
|
return { localStorage: dump(localStorage), sessionStorage: dump(sessionStorage) };
|
|
38
|
-
})()`;async function hl({context:e,page:t}){let[r,n]=await Promise.all([z({awaitPromise:!1,expression:yl,page:t}),e.cookies().catch(()=>[])]);return{cookies:n,localStorage:r?.localStorage??{},sessionStorage:r?.sessionStorage??{}}}async function Jn({runId:e,steps:t,summary:r}){try{let n=ne.join(process.cwd(),".ripplo","debug",e);await Er(n,{recursive:!0}),await be(ne.join(n,"summary.txt"),wl({steps:t,summary:r})),
|
|
38
|
+
})()`;async function hl({context:e,page:t}){let[r,n]=await Promise.all([z({awaitPromise:!1,expression:yl,page:t}),e.cookies().catch(()=>[])]);return{cookies:n,localStorage:r?.localStorage??{},sessionStorage:r?.sessionStorage??{}}}async function Jn({runId:e,steps:t,summary:r}){try{let n=ne.join(process.cwd(),".ripplo","debug",e);await Er(n,{recursive:!0}),await be(ne.join(n,"summary.txt"),wl({steps:t,summary:r})),g.info("Debug artifacts written to .ripplo/debug/%s/",e)}catch(n){let o=n instanceof Error?n.message:String(n);g.warn("Failed to write run debug summary: %s",o)}}function wl({steps:e,summary:t}){return[`Run ID: ${t.runId}`,`Workflow: ${t.workflowName}`,`Status: ${t.status}`,`Duration: ${String(t.duration)}ms`,`Passed: ${String(t.passCount)}`,`Failed: ${String(t.failCount)}`,"","Steps:",...e.map(n=>` [${String(n.stepIndex)}] ${n.status==="passed"?"\u2713":"\u2717"} ${n.title} (${String(n.duration)}ms) \u2014 ${n.detail??"ok"}`)].join(`
|
|
39
39
|
`)}async function Qn({error:e,runId:t,stack:r,workflowName:n}){try{let o=ne.join(process.cwd(),".ripplo","debug",t);await Er(o,{recursive:!0});let i=r==null?e:`${e}
|
|
40
40
|
|
|
41
41
|
${r}`,s=[`Run ID: ${t}`,`Workflow: ${n}`,"Status: failed","",`Error: ${e}`,"",r==null?"":`Stack trace:
|
|
42
42
|
${r}`].join(`
|
|
43
|
-
`);await Promise.all([be(ne.join(o,"error.txt"),i),be(ne.join(o,"summary.txt"),s)]),
|
|
43
|
+
`);await Promise.all([be(ne.join(o,"error.txt"),i),be(ne.join(o,"summary.txt"),s)]),g.info("Debug error artifacts written to .ripplo/debug/%s/",t)}catch(o){let i=o instanceof Error?o.message:String(o);g.warn("Failed to write error debug artifacts: %s",i)}}import{readFileSync as bl}from"fs";import{createRequire as vl}from"module";import Yn from"path";import{gzipSync as kl}from"zlib";var Sl=vl(import.meta.url),Rl=Sl.resolve("rrweb"),Pl=Yn.join(Yn.dirname(Rl),"rrweb.umd.min.cjs"),xl=bl(Pl,"utf8"),Cl=[";(function() {"," try {"," if (window.__ripploRrwebLoaded) return;"," window.__ripploRrwebLoaded = true;"," window.__ripploRrwebBuffer = [];"," window.__ripploRrwebDrain = function() {"," var out = window.__ripploRrwebBuffer;"," window.__ripploRrwebBuffer = [];"," return out;"," };"," var r = window.rrweb;"," if (r == null || r.record == null) {"," console.warn('[ripplo] rrweb global not found');"," return;"," }"," function startRecording() {"," if (window.__ripploRrwebStartedAt != null) return;"," window.__ripploRrwebStartedAt = Date.now();"," var stop = r.record({"," emit: function(event) { window.__ripploRrwebBuffer.push(event); },"," recordCanvas: false,"," recordCrossOriginIframes: false,"," });"," window.__ripploRrwebStop = stop;"," }"," window.__ripploRrwebStart = startRecording;"," // Auto-start on every bootstrap run so agent-driven tests (which don't"," // emit a 'first step' signal before navigating) capture from the start."," startRecording();"," } catch (err) {"," console.error('[ripplo] rrweb bootstrap failed', err && err.message ? err.message : err);"," }","})();"].join(`
|
|
44
44
|
`),El=xl+`
|
|
45
|
-
`+Cl;async function Xn(e){let t,r=0;async function n(){await e.addScriptTag({content:El}).catch(()=>{})}await n(),e.on("load",()=>{n()});async function o(){await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebStart && globalThis.__ripploRrwebStart()",page:e});let l=await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebStartedAt",page:e});typeof l=="number"&&(t??=l)}function i(){if(t!=null)return Date.now()-t}async function s(){let l=await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebDrain ? globalThis.__ripploRrwebDrain() : []",page:e})??[],c=l[0],p=l.at(-1);if(c==null||p==null)return;t??=c.timestamp;let m=t,k=l.map(
|
|
46
|
-
`),j={body:kl(Buffer.from(k,"utf8")),chunkIndex:r,endTimestamp:p.timestamp-m,eventCount:l.length,startTimestamp:c.timestamp-m};return r+=1,j}async function a(){await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebStop && globalThis.__ripploRrwebStop()",page:e})}return{currentOffsetMs:i,detach:a,start:o,takeChunk:s}}import{z as ee}from"zod";import Zn from"crypto";import{Webhook as
|
|
45
|
+
`+Cl;async function Xn(e){let t,r=0;async function n(){await e.addScriptTag({content:El}).catch(()=>{})}await n(),e.on("load",()=>{n()});async function o(){await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebStart && globalThis.__ripploRrwebStart()",page:e});let l=await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebStartedAt",page:e});typeof l=="number"&&(t??=l)}function i(){if(t!=null)return Date.now()-t}async function s(){let l=await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebDrain ? globalThis.__ripploRrwebDrain() : []",page:e})??[],c=l[0],p=l.at(-1);if(c==null||p==null)return;t??=c.timestamp;let m=t,k=l.map(f=>JSON.stringify(f)).join(`
|
|
46
|
+
`),j={body:kl(Buffer.from(k,"utf8")),chunkIndex:r,endTimestamp:p.timestamp-m,eventCount:l.length,startTimestamp:c.timestamp-m};return r+=1,j}async function a(){await z({awaitPromise:!1,expression:"globalThis.__ripploRrwebStop && globalThis.__ripploRrwebStop()",page:e})}return{currentOffsetMs:i,detach:a,start:o,takeChunk:s}}import{z as ee}from"zod";import Zn from"crypto";import{Webhook as Al}from"standardwebhooks";function ve({body:e,secret:t}){let r=new Al(t),n=`msg_${Zn.randomUUID()}`,o=new Date,i=r.sign(n,o,e),s=Math.floor(o.getTime()/1e3);return{"webhook-id":n,"webhook-signature":i,"webhook-timestamp":String(s)}}function Ar(){return`whsec_${Zn.randomBytes(24).toString("base64")}`}var Il=15e4,jl={async:{backoffMs:[500,1e3,2e3,5e3],timeoutMs:12e4},fast:{backoffMs:[100,250,500,1e3],timeoutMs:5e3},slow:{backoffMs:[250,500,1e3,2e3],timeoutMs:3e4}},Tl=ee.discriminatedUnion("kind",[ee.object({kind:ee.literal("pass")}),ee.object({kind:ee.literal("retry"),reason:ee.string()}),ee.object({kind:ee.literal("fail"),reason:ee.string()})]),$l=ee.object({error:ee.string().optional(),outcome:Tl.optional(),success:ee.boolean()});async function eo({apiUrl:e,budget:t,observer:r,params:n,webhookSecret:o}){let i=jl[t],s=performance.now(),a={lastReason:void 0,pollCount:0};for(;performance.now()-s<i.timeoutMs;){a.pollCount+=1;let l=await Ol({apiUrl:e,observer:r,params:n,webhookSecret:o}),c=Nl({observer:r,outcome:l,start:s,state:a});if(c!=null)return c;let p=i.timeoutMs-(performance.now()-s);if(p<=0)break;let m=Math.min(Dl({backoff:i.backoffMs,pollCount:a.pollCount}),p);await Ll(m)}return{description:`observer "${r}"`,detail:`budget "${t}" exhausted after ${String(a.pollCount)} poll(s) (${to(s)}); last: ${a.lastReason??"no retry reason"}
|
|
47
47
|
\u2192 /ripplo:debug \u2014 check .ripplo/debug/<runId>/ artifacts`,status:"failed"}}function Nl({observer:e,outcome:t,start:r,state:n}){return t.kind==="transport-error"?{description:`observer "${e}"`,detail:`transport error after ${String(n.pollCount)} poll(s): ${t.reason}
|
|
48
48
|
Load \`/ripplo:setup\` skill for instructions on engine endpoint + webhook secret wiring.`,status:"failed"}:t.kind==="pass"?{description:`observer "${e}"`,detail:n.pollCount>1?`passed after ${String(n.pollCount)} polls (${to(r)})`:void 0,status:"passed"}:t.kind==="fail"?{description:`observer "${e}"`,detail:`failed (invariant): ${t.reason} (after ${String(n.pollCount)} poll(s)) \u2014 ctx.fail stops polling immediately and is reserved for invariant violations (wrong shape, contradictory/forbidden state). For transient conditions like "not yet committed", "status not yet X", or "row not found", use ctx.retry(reason) so the runtime keeps polling until the budget expires.
|
|
49
|
-
Load \`/ripplo:create\` skill for instructions.`,status:"failed"}:(n.lastReason=t.reason,null)}async function Ol({apiUrl:e,observer:t,params:r,webhookSecret:n}){let o=JSON.stringify({observer:t,params:r});try{let i=await fetch(`${e}/execute-observer`,{body:o,headers:{"Content-Type":"application/json",...ve({body:o,secret:n})},method:"PUT",signal:AbortSignal.timeout(Al)});if(!i.ok){let l=await i.text().catch(()=>"");return{kind:"transport-error",reason:`status ${String(i.status)}: ${l.slice(0,200)}`}}let s=await i.json(),a=$l.safeParse(s);return a.success?!a.data.success||a.data.outcome==null?{kind:"transport-error",reason:a.data.error??"engine reported failure without outcome"}:a.data.outcome:{kind:"transport-error",reason:`invalid response shape: ${a.error.message}`}}catch(i){let s=i instanceof Error?i.message:String(i);return f.error("observer request failed: %s",s),{kind:"transport-error",reason:s}}}function Dl({backoff:e,pollCount:t}){let r=Math.min(t-1,e.length-1);return e[r]??1e3}function to(e){return`${String(Math.round(performance.now()-e))}ms`}async function Ll(e){return new Promise(t=>setTimeout(t,e))}var _l=1e4;async function Ar({failFast:e,getRecordingOffsetMs:t,observerTransport:r,onStep:n,page:o,spec:i,variables:s}){let a=performance.now();return Vl({currentId:i.entryNode,failFast:e,getRecordingOffsetMs:t,observerTransport:r,onStep:n,page:o,runStartTime:a,spec:i,variables:s})}function Ul({onStep:e,steps:t,target:r}){t.forEach(n=>{let o={...n,stepIndex:r.length};r.push(o),e?.(o)})}async function Vl({currentId:e,failFast:t,getRecordingOffsetMs:r,observerTransport:n,onStep:o,page:i,runStartTime:s,spec:a,variables:l}){let c=[],p=l,m=e;for(;m!=null;){let k=a.nodes[m];if(k==null)throw new Error(`Node "${m}" not found in spec`);let L=m,j=k.label??`${k.type} (${m})`;f.info("Executing node: %s [%s]",j,k.type);let y=await Fl({getRecordingOffsetMs:r,node:k,nodeId:L,observerTransport:n,page:i,runStartTime:s,variables:p});if(Ul({onStep:o,steps:[y],target:c}),p=y.variables,t&&y.status==="failed")break;m=k.next}return{steps:c,variables:p}}async function Fl({getRecordingOffsetMs:e,node:t,nodeId:r,observerTransport:n,page:o,runStartTime:i,variables:s}){let a=performance.now(),l=e?.(),c=t.label??`${t.type} (${t.id})`,p=_l;try{let m=await Hl({node:t,observerTransport:n,page:o,timeout:p,variables:s}),k=Math.round(performance.now()-a),L=m.assertions.some(y=>y.status==="failed"),j=e?.();return{assertions:m.assertions,detail:void 0,duration:k,nodeId:r,nodeType:t.type,recordingEndMs:j,recordingStartMs:l,snapshotTimestamp:Math.round(performance.now()-i),status:L?"failed":"passed",stepIndex:0,title:c,url:o.url(),variables:m.variables}}catch(m){let k=Math.round(performance.now()-a),L=m instanceof Error?m.message:String(m),j=e?.();return{assertions:[],detail:L,duration:k,nodeId:r,nodeType:t.type,recordingEndMs:j,recordingStartMs:l,snapshotTimestamp:Math.round(performance.now()-i),status:"failed",stepIndex:0,title:c,url:o.url(),variables:s}}}async function Hl({node:e,observerTransport:t,page:r,timeout:n,variables:o}){if(Bl(e)){let s=await ar({node:e,page:r,timeout:n,variables:o});return{assertions:[],variables:s.variables}}return{assertions:await Ml({node:e,observerTransport:t,page:r,timeout:n,variables:o}),variables:o}}function Bl(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","clipboard","setPermission","setViewport","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}function Wl(e){return e.type.startsWith("assert")}async function Ml({node:e,observerTransport:t,page:r,timeout:n,variables:o}){if(!Wl(e))throw new Error(`Unknown node type: ${e.type}`);let i=e;switch(i.type){case"assertVisible":case"assertNotVisible":case"assertEnabled":case"assertDisabled":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertNotFocused":return zl({assertNode:i,page:r,timeout:n,variables:o});case"assertText":{let s=M({ref:i.expected,variables:o});return[await lr({expected:s,locator:O({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertUrl":{let s=M({ref:i.expected,variables:o});return[await cr({expected:s,operator:i.operator,page:r,timeout:n})]}case"assertTitle":{let s=M({ref:i.expected,variables:o});return[await Pn({expected:s,operator:i.operator,page:r,timeout:n})]}case"assertCount":{let s=sr({ref:i.expected,variables:o});return[await ur({expected:s,locator:O({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertValue":{let s=M({ref:i.expected,variables:o});return[await dr({expected:s,locator:O({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertAttribute":{let s=M({ref:i.expected,variables:o});return[await xn({attribute:i.attribute,expected:s,locator:O({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertObserver":{if(t==null)return[{description:`observer "${i.observer}"`,detail:"observer transport not configured \u2014 set engineUrl + webhookSecret in ripplo.config",status:"failed"}];let s={};return Object.entries(i.params).forEach(([a,l])=>{s[a]=yt({ref:l,variables:o})}),[await eo({apiUrl:t.apiUrl,budget:i.budget,observer:i.observer,params:s,webhookSecret:t.webhookSecret})]}}}var ql={assertChecked:In,assertDisabled:En,assertEnabled:Cn,assertFocused:jn,assertNotChecked:An,assertNotFocused:Tn,assertNotVisible:mr,assertVisible:pr};async function zl({assertNode:e,page:t,timeout:r,variables:n}){let o=ql[e.type];return[await o({locator:O({locator:e.locator,page:t,variables:n}),timeout:r})]}var ro=1e4;async function jr({baseUrl:e,browser:t,cookies:r,extraVariables:n,observerTransport:o,onRecordingChunk:i,onStep:s,runId:a,spec:l}){let c=await t.newContext({baseURL:e});c.setDefaultTimeout(ro),c.setDefaultNavigationTimeout(ro),r.length>0&&await c.addCookies(r);let p=await c.newPage(),m=await Xn(p);async function k(){let W=await m.takeChunk();W!=null&&i?.(W)}let L=setInterval(()=>{k()},2e3),j=[],y=!1;function N(W){s?.(W),y||(y=!0,m.start()),j.push(Kn({context:c,page:p,runId:a,stepIndex:W.stepIndex,stepResult:W}))}let T=Gl(n,l.variableNamespaces),F={...ir({defs:l.variables}),...T},te=await Ar({failFast:!0,getRecordingOffsetMs:m.currentOffsetMs,observerTransport:o,onStep:N,page:p,spec:l,variables:F});clearInterval(L);let Ee=te.steps.filter(W=>W.status==="passed").length,oe=te.steps.filter(W=>W.status==="failed").length,qe={duration:te.steps.reduce((W,re)=>W+re.duration,0),failCount:oe,passCount:Ee,runId:a,status:oe>0?"failed":"passed",workflowName:""};return await Promise.all([Promise.allSettled(j).then(()=>Jn({runId:a,steps:te.steps,summary:qe})),m.detach().then(k)]),await c.close(),te.steps}function Gl(e,t){if(e==null||t==null)return{};let r=new Map;Object.entries(t).forEach(([o,i])=>{r.set(i,o)});let n={};return Object.entries(e).forEach(([o,i])=>{let s=r.get(o);s!=null&&(n[s]={...n[s],...i})}),n}async function ue({fn:e,label:t}){let r=performance.now(),n=await e();return f.info("%s: %dms",t,Math.round(performance.now()-r)),n}import{parseSetCookie as Kl}from"set-cookie-parser";import{z as J}from"zod";var no=3e4,Jl=J.object({data:J.record(J.string(),J.record(J.string(),J.string())),error:J.string().optional(),executed:J.array(J.string()),runId:J.string(),success:J.boolean()});async function Tr({project:e,webhookSecret:t,workflowSlug:r}){let n={apiUrl:void 0,cookies:[],data:{},executed:[]},o=e.workflows.find(a=>a.slug===r);if(o==null)return n;let i=e.engineBaseUrl.length===0?void 0:e.engineBaseUrl,s=o.preconditions;return s.length===0?{...n,apiUrl:i}:i==null?n:oo({apiUrl:i,preconditionNames:s,webhookSecret:t})}async function $r({apiUrl:e,cookies:t,data:r,executed:n,webhookSecret:o}){if(n.length!==0)try{let i=JSON.stringify({data:r,preconditions:n}),s=await fetch(`${e}/teardown-preconditions`,{body:i,headers:{"Content-Type":"application/json",...Zl({cookies:t}),...ve({body:i,secret:o})},method:"PUT",signal:AbortSignal.timeout(no)});s.ok||f.error("Teardown returned %s",String(s.status))}catch{f.error("Teardown request failed")}}async function oo({apiUrl:e,preconditionNames:t,webhookSecret:r}){let n=performance.now(),o=JSON.stringify({preconditions:t}),i=await fetch(`${e}/execute-preconditions`,{body:o,headers:{"Content-Type":"application/json",...ve({body:o,secret:r})},method:"PUT",signal:AbortSignal.timeout(no)});if(!i.ok){let c=await Yl(i);throw new Error(`execute-preconditions returned ${String(i.status)}: ${c}`)}let s=await i.json(),a=Jl.safeParse(s);if(!a.success)throw new Error(`execute-preconditions response has invalid shape: ${a.error.message}`);if(!a.data.success){let c=a.data.error??"no error detail";throw new Error(`Precondition batch failed: ${c}`)}let l=ec({domain:new URL(e).hostname,res:i});return f.info("Preconditions resolved: %s (%dms)",a.data.executed.join(", "),Math.round(performance.now()-n)),{apiUrl:e,cookies:l,data:a.data.data,executed:a.data.executed}}var Ql=J.object({error:J.string()});async function Yl(e){let t=await e.text().catch(()=>"");if(t.length===0)return"no body";let r=Xl(t),n=r==null?null:Ql.safeParse(r);return n!=null&&n.success?n.data.error:t.slice(0,500)}function Xl(e){try{return JSON.parse(e)}catch{return null}}function Zl({cookies:e}){return e.length===0?{}:{Cookie:e.map(r=>`${r.name}=${r.value}`).join("; ")}}function ec({domain:e,res:t}){let r=t.headers.getSetCookie();return Kl(r,{decodeValues:!1}).map(o=>tc({cookie:o,domain:e}))}function tc({cookie:e,domain:t}){let r={domain:e.domain??t,httpOnly:e.httpOnly??!1,name:e.name,path:e.path??"/",secure:e.secure??!1,value:e.value};return e.sameSite!=null&&(r.sameSite=nc({raw:e.sameSite})),e.expires!=null?r.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(r.expires=Math.floor(Date.now()/1e3)+e.maxAge),r}var rc={lax:"Lax",none:"None",strict:"Strict"};function nc({raw:e}){return rc[e.toLowerCase()]??"Lax"}async function Nr({engineBaseUrl:e,preconditionNames:t,webhookSecret:r}){let n=e.length===0?void 0:e;return n==null||t.length===0?{apiUrl:n,cookies:[],data:{},executed:[]}:oo({apiUrl:n,preconditionNames:t,webhookSecret:r})}import{graphql as rt}from"gql.tada";async function Or({config:e,runId:t}){let r=await g({config:e,document:ac,variables:{platform:"chromium",runId:t}});if(r.startRun==null)throw new Error("Failed to start run");let n=r.startRun.id,o=[];function i(c){let p=ic({config:e,runResultId:n,steps:[c]}).catch(m=>{f.error(m,"Failed to submit step %d",c.stepIndex)});o.push(p)}function s(c){let p=oc({chunk:c,config:e,runResultId:n}).catch(m=>{f.error(m,"Failed to submit recording chunk %d",c.chunkIndex)});o.push(p)}async function a(){await Promise.all(o)}async function l({statusOverride:c,steps:p,summary:m}){await ue({label:`flushSteps (${String(o.length)} steps)`,fn:()=>Promise.all(o)});let k=p.filter(N=>N.status==="passed").length,L=p.filter(N=>N.status==="failed").length,j=p.reduce((N,T)=>N+T.duration,0),y=c??(L>0?"failed":"passed");await ue({label:"completeRun",fn:()=>g({config:e,document:uc,variables:{duration:j,failCount:L,passCount:k,runResultId:n,status:y,summary:m??null,warnCount:0}})})}return{complete:l,enqueueRecordingChunk:s,enqueueStep:i,flushSteps:a,runResultId:n}}async function oc({chunk:e,config:t,runResultId:r}){await g({config:t,document:cc,variables:{input:{bodyBase64:e.body.toString("base64"),chunkIndex:e.chunkIndex,endTimestamp:e.endTimestamp,eventCount:e.eventCount,runResultId:r,startTimestamp:e.startTimestamp}}})}async function ic({config:e,runResultId:t,steps:r}){let n=r.map(o=>({assertions:o.assertions.map(i=>({description:i.description,detail:i.detail,status:i.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,recordingEndMs:o.recordingEndMs??null,recordingStartMs:o.recordingStartMs??null,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url}));await g({config:e,document:lc,variables:{runResultId:t,steps:n}})}async function Dr({config:e,reason:t,runId:r}){await g({config:e,document:sc,variables:{reason:t,runId:r}})}var sc=rt(`
|
|
49
|
+
Load \`/ripplo:create\` skill for instructions.`,status:"failed"}:(n.lastReason=t.reason,null)}async function Ol({apiUrl:e,observer:t,params:r,webhookSecret:n}){let o=JSON.stringify({observer:t,params:r});try{let i=await fetch(`${e}/execute-observer`,{body:o,headers:{"Content-Type":"application/json",...ve({body:o,secret:n})},method:"PUT",signal:AbortSignal.timeout(Il)});if(!i.ok){let l=await i.text().catch(()=>"");return{kind:"transport-error",reason:`status ${String(i.status)}: ${l.slice(0,200)}`}}let s=await i.json(),a=$l.safeParse(s);return a.success?!a.data.success||a.data.outcome==null?{kind:"transport-error",reason:a.data.error??"engine reported failure without outcome"}:a.data.outcome:{kind:"transport-error",reason:`invalid response shape: ${a.error.message}`}}catch(i){let s=i instanceof Error?i.message:String(i);return g.error("observer request failed: %s",s),{kind:"transport-error",reason:s}}}function Dl({backoff:e,pollCount:t}){let r=Math.min(t-1,e.length-1);return e[r]??1e3}function to(e){return`${String(Math.round(performance.now()-e))}ms`}async function Ll(e){return new Promise(t=>setTimeout(t,e))}var _l=1e4;async function Ir({failFast:e,getRecordingOffsetMs:t,observerTransport:r,onStep:n,page:o,spec:i,variables:s}){let a=performance.now();return Vl({currentId:i.entryNode,failFast:e,getRecordingOffsetMs:t,observerTransport:r,onStep:n,page:o,runStartTime:a,spec:i,variables:s})}function Ul({onStep:e,steps:t,target:r}){t.forEach(n=>{let o={...n,stepIndex:r.length};r.push(o),e?.(o)})}async function Vl({currentId:e,failFast:t,getRecordingOffsetMs:r,observerTransport:n,onStep:o,page:i,runStartTime:s,spec:a,variables:l}){let c=[],p=l,m=e;for(;m!=null;){let k=a.nodes[m];if(k==null)throw new Error(`Node "${m}" not found in spec`);let _=m,j=k.label??`${k.type} (${m})`;g.info("Executing node: %s [%s]",j,k.type);let f=await Fl({getRecordingOffsetMs:r,node:k,nodeId:_,observerTransport:n,page:i,runStartTime:s,variables:p});if(Ul({onStep:o,steps:[f],target:c}),p=f.variables,t&&f.status==="failed")break;m=k.next}return{steps:c,variables:p}}async function Fl({getRecordingOffsetMs:e,node:t,nodeId:r,observerTransport:n,page:o,runStartTime:i,variables:s}){let a=performance.now(),l=e?.(),c=t.label??`${t.type} (${t.id})`,p=_l;try{let m=await Hl({node:t,observerTransport:n,page:o,timeout:p,variables:s}),k=Math.round(performance.now()-a),_=m.assertions.some(f=>f.status==="failed"),j=e?.();return{assertions:m.assertions,detail:void 0,duration:k,nodeId:r,nodeType:t.type,recordingEndMs:j,recordingStartMs:l,snapshotTimestamp:Math.round(performance.now()-i),status:_?"failed":"passed",stepIndex:0,title:c,url:o.url(),variables:m.variables}}catch(m){let k=Math.round(performance.now()-a),_=m instanceof Error?m.message:String(m),j=e?.();return{assertions:[],detail:_,duration:k,nodeId:r,nodeType:t.type,recordingEndMs:j,recordingStartMs:l,snapshotTimestamp:Math.round(performance.now()-i),status:"failed",stepIndex:0,title:c,url:o.url(),variables:s}}}async function Hl({node:e,observerTransport:t,page:r,timeout:n,variables:o}){if(Bl(e)){let s=await ar({node:e,page:r,timeout:n,variables:o});return{assertions:[],variables:s.variables}}return{assertions:await Ml({node:e,observerTransport:t,page:r,timeout:n,variables:o}),variables:o}}function Bl(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","clipboard","setPermission","setViewport","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}function Wl(e){return e.type.startsWith("assert")}async function Ml({node:e,observerTransport:t,page:r,timeout:n,variables:o}){if(!Wl(e))throw new Error(`Unknown node type: ${e.type}`);let i=e;switch(i.type){case"assertVisible":case"assertNotVisible":case"assertEnabled":case"assertDisabled":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertNotFocused":return zl({assertNode:i,page:r,timeout:n,variables:o});case"assertText":{let s=M({ref:i.expected,variables:o});return[await lr({expected:s,locator:N({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertUrl":{let s=M({ref:i.expected,variables:o});return[await cr({expected:s,operator:i.operator,page:r,timeout:n})]}case"assertTitle":{let s=M({ref:i.expected,variables:o});return[await Pn({expected:s,operator:i.operator,page:r,timeout:n})]}case"assertCount":{let s=sr({ref:i.expected,variables:o});return[await dr({expected:s,locator:N({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertValue":{let s=M({ref:i.expected,variables:o});return[await ur({expected:s,locator:N({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertAttribute":{let s=M({ref:i.expected,variables:o});return[await xn({attribute:i.attribute,expected:s,locator:N({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertObserver":{if(t==null)return[{description:`observer "${i.observer}"`,detail:"observer transport not configured \u2014 set engineUrl + webhookSecret in ripplo.config",status:"failed"}];let s={};return Object.entries(i.params).forEach(([a,l])=>{s[a]=yt({ref:l,variables:o})}),[await eo({apiUrl:t.apiUrl,budget:i.budget,observer:i.observer,params:s,webhookSecret:t.webhookSecret})]}}}var ql={assertChecked:An,assertDisabled:En,assertEnabled:Cn,assertFocused:jn,assertNotChecked:In,assertNotFocused:Tn,assertNotVisible:mr,assertVisible:pr};async function zl({assertNode:e,page:t,timeout:r,variables:n}){let o=ql[e.type];return[await o({locator:N({locator:e.locator,page:t,variables:n}),timeout:r})]}var ro=1e4;async function jr({baseUrl:e,browser:t,cookies:r,extraVariables:n,observerTransport:o,onRecordingChunk:i,onStep:s,runId:a,spec:l}){let c=await t.newContext({baseURL:e});c.setDefaultTimeout(ro),c.setDefaultNavigationTimeout(ro),r.length>0&&await c.addCookies(r);let p=await c.newPage(),m=await Xn(p);async function k(){let W=await m.takeChunk();W!=null&&i?.(W)}let _=setInterval(()=>{k()},2e3),j=[],f=!1;function V(W){s?.(W),f||(f=!0,m.start()),j.push(Kn({context:c,page:p,runId:a,stepIndex:W.stepIndex,stepResult:W}))}let $=Gl(n,l.variableNamespaces),F={...ir({defs:l.variables}),...$},te=await Ir({failFast:!0,getRecordingOffsetMs:m.currentOffsetMs,observerTransport:o,onStep:V,page:p,spec:l,variables:F});clearInterval(_);let Ee=te.steps.filter(W=>W.status==="passed").length,oe=te.steps.filter(W=>W.status==="failed").length,qe={duration:te.steps.reduce((W,re)=>W+re.duration,0),failCount:oe,passCount:Ee,runId:a,status:oe>0?"failed":"passed",workflowName:""};return await Promise.all([Promise.allSettled(j).then(()=>Jn({runId:a,steps:te.steps,summary:qe})),m.detach().then(k)]),await c.close(),te.steps}function Gl(e,t){if(e==null||t==null)return{};let r=new Map;Object.entries(t).forEach(([o,i])=>{r.set(i,o)});let n={};return Object.entries(e).forEach(([o,i])=>{let s=r.get(o);s!=null&&(n[s]={...n[s],...i})}),n}async function de({fn:e,label:t}){let r=performance.now(),n=await e();return g.info("%s: %dms",t,Math.round(performance.now()-r)),n}import{parseSetCookie as Kl}from"set-cookie-parser";import{z as J}from"zod";var no=3e4,Jl=J.object({data:J.record(J.string(),J.record(J.string(),J.string())),error:J.string().optional(),executed:J.array(J.string()),runId:J.string(),success:J.boolean()});async function Tr({project:e,webhookSecret:t,workflowSlug:r}){let n={apiUrl:void 0,cookies:[],data:{},executed:[]},o=e.workflows.find(a=>a.slug===r);if(o==null)return n;let i=e.engineBaseUrl.length===0?void 0:e.engineBaseUrl,s=o.preconditions;return s.length===0?{...n,apiUrl:i}:i==null?n:oo({apiUrl:i,preconditionNames:s,webhookSecret:t})}async function $r({apiUrl:e,cookies:t,data:r,executed:n,webhookSecret:o}){if(n.length!==0)try{let i=JSON.stringify({data:r,preconditions:n}),s=await fetch(`${e}/teardown-preconditions`,{body:i,headers:{"Content-Type":"application/json",...Zl({cookies:t}),...ve({body:i,secret:o})},method:"PUT",signal:AbortSignal.timeout(no)});s.ok||g.error("Teardown returned %s",String(s.status))}catch{g.error("Teardown request failed")}}async function oo({apiUrl:e,preconditionNames:t,webhookSecret:r}){let n=performance.now(),o=JSON.stringify({preconditions:t}),i=await fetch(`${e}/execute-preconditions`,{body:o,headers:{"Content-Type":"application/json",...ve({body:o,secret:r})},method:"PUT",signal:AbortSignal.timeout(no)});if(!i.ok){let c=await Yl(i);throw new Error(`execute-preconditions returned ${String(i.status)}: ${c}`)}let s=await i.json(),a=Jl.safeParse(s);if(!a.success)throw new Error(`execute-preconditions response has invalid shape: ${a.error.message}`);if(!a.data.success){let c=a.data.error??"no error detail";throw new Error(`Precondition batch failed: ${c}`)}let l=ec({domain:new URL(e).hostname,res:i});return g.info("Preconditions resolved: %s (%dms)",a.data.executed.join(", "),Math.round(performance.now()-n)),{apiUrl:e,cookies:l,data:a.data.data,executed:a.data.executed}}var Ql=J.object({error:J.string()});async function Yl(e){let t=await e.text().catch(()=>"");if(t.length===0)return"no body";let r=Xl(t),n=r==null?null:Ql.safeParse(r);return n!=null&&n.success?n.data.error:t.slice(0,500)}function Xl(e){try{return JSON.parse(e)}catch{return null}}function Zl({cookies:e}){return e.length===0?{}:{Cookie:e.map(r=>`${r.name}=${r.value}`).join("; ")}}function ec({domain:e,res:t}){let r=t.headers.getSetCookie();return Kl(r,{decodeValues:!1}).map(o=>tc({cookie:o,domain:e}))}function tc({cookie:e,domain:t}){let r={domain:e.domain??t,httpOnly:e.httpOnly??!1,name:e.name,path:e.path??"/",secure:e.secure??!1,value:e.value};return e.sameSite!=null&&(r.sameSite=nc({raw:e.sameSite})),e.expires!=null?r.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(r.expires=Math.floor(Date.now()/1e3)+e.maxAge),r}var rc={lax:"Lax",none:"None",strict:"Strict"};function nc({raw:e}){return rc[e.toLowerCase()]??"Lax"}async function Nr({engineBaseUrl:e,preconditionNames:t,webhookSecret:r}){let n=e.length===0?void 0:e;return n==null||t.length===0?{apiUrl:n,cookies:[],data:{},executed:[]}:oo({apiUrl:n,preconditionNames:t,webhookSecret:r})}import{graphql as rt}from"gql.tada";async function Or({config:e,runId:t}){if((await y({config:e,document:ac,variables:{runId:t}})).startRun==null)throw new Error("Failed to start run");let n=[];function o(l){let c=ic({config:e,runId:t,steps:[l]}).catch(p=>{g.error(p,"Failed to submit step %d",l.stepIndex)});n.push(c)}function i(l){let c=oc({chunk:l,config:e,runId:t}).catch(p=>{g.error(p,"Failed to submit recording chunk %d",l.chunkIndex)});n.push(c)}async function s(){await Promise.all(n)}async function a({statusOverride:l,steps:c,summary:p}){await de({label:`flushSteps (${String(n.length)} steps)`,fn:()=>Promise.all(n)});let m=c.filter(f=>f.status==="passed").length,k=c.filter(f=>f.status==="failed").length,_=c.reduce((f,V)=>f+V.duration,0),j=l??(k>0?"failed":"passed");await de({label:"completeRun",fn:()=>y({config:e,document:dc,variables:{duration:_,failCount:k,passCount:m,runId:t,status:j,summary:p??null,warnCount:0}})})}return{complete:a,enqueueRecordingChunk:i,enqueueStep:o,flushSteps:s,runId:t}}async function oc({chunk:e,config:t,runId:r}){await y({config:t,document:cc,variables:{input:{bodyBase64:e.body.toString("base64"),chunkIndex:e.chunkIndex,endTimestamp:e.endTimestamp,eventCount:e.eventCount,runId:r,startTimestamp:e.startTimestamp}}})}async function ic({config:e,runId:t,steps:r}){let n=r.map(o=>({assertions:o.assertions.map(i=>({description:i.description,detail:i.detail,status:i.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,recordingEndMs:o.recordingEndMs??null,recordingStartMs:o.recordingStartMs??null,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url}));await y({config:e,document:lc,variables:{runId:t,steps:n}})}async function Dr({config:e,reason:t,runId:r}){await y({config:e,document:sc,variables:{reason:t,runId:r}})}var sc=rt(`
|
|
50
50
|
mutation FailRunCLI($runId: String!, $reason: String!) {
|
|
51
51
|
failRun(runId: $runId, reason: $reason)
|
|
52
52
|
}
|
|
53
53
|
`),ac=rt(`
|
|
54
|
-
mutation StartRunCLI($runId: String
|
|
55
|
-
startRun(runId: $runId
|
|
54
|
+
mutation StartRunCLI($runId: String!) {
|
|
55
|
+
startRun(runId: $runId) {
|
|
56
56
|
id
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
`),lc=rt(`
|
|
60
|
-
mutation SubmitRunStepsCLI($
|
|
61
|
-
submitRunSteps(
|
|
60
|
+
mutation SubmitRunStepsCLI($runId: String!, $steps: [StepInput!]!) {
|
|
61
|
+
submitRunSteps(runId: $runId, steps: $steps)
|
|
62
62
|
}
|
|
63
63
|
`),cc=rt(`
|
|
64
64
|
mutation SubmitRunRecordingChunkCLI($input: SubmitRunRecordingChunkInput!) {
|
|
65
65
|
submitRunRecordingChunk(input: $input)
|
|
66
66
|
}
|
|
67
|
-
`),
|
|
67
|
+
`),dc=rt(`
|
|
68
68
|
mutation CompleteRunCLI(
|
|
69
|
-
$
|
|
70
|
-
$status:
|
|
69
|
+
$runId: String!
|
|
70
|
+
$status: RunStatus!
|
|
71
71
|
$duration: Int!
|
|
72
72
|
$passCount: Int!
|
|
73
73
|
$failCount: Int!
|
|
@@ -75,7 +75,7 @@ Load \`/ripplo:create\` skill for instructions.`,status:"failed"}:(n.lastReason=
|
|
|
75
75
|
$summary: String
|
|
76
76
|
) {
|
|
77
77
|
completeRun(
|
|
78
|
-
|
|
78
|
+
runId: $runId
|
|
79
79
|
status: $status
|
|
80
80
|
duration: $duration
|
|
81
81
|
passCount: $passCount
|
|
@@ -87,7 +87,7 @@ Load \`/ripplo:create\` skill for instructions.`,status:"failed"}:(n.lastReason=
|
|
|
87
87
|
status
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
`);var
|
|
90
|
+
`);var uc=12e4,It=Lr(`
|
|
91
91
|
fragment WorkflowRun on Workflow {
|
|
92
92
|
id
|
|
93
93
|
slug
|
|
@@ -108,13 +108,13 @@ Load \`/ripplo:create\` skill for instructions.`,status:"failed"}:(n.lastReason=
|
|
|
108
108
|
...WorkflowRun
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
`,[
|
|
111
|
+
`,[It]),pc=Lr(`
|
|
112
112
|
query ProjectRun($projectId: String!) {
|
|
113
113
|
project(id: $projectId) {
|
|
114
114
|
...ProjectRun
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
`,[io]);async function _r({baseUrl:e,browser:t,config:r,headed:n,preconditionNames:o,runId:i,webhookSecret:s,workflowId:a}){let l="unknown",c,p,m=!1;try{m=t==null,p=mc({externalBrowser:t,headed:n});let k=o==null?void 0:Nr({engineBaseUrl:r.engineUrl,preconditionNames:o,webhookSecret:s}),[{project:
|
|
117
|
+
`,[io]);async function _r({baseUrl:e,browser:t,config:r,headed:n,preconditionNames:o,runId:i,webhookSecret:s,workflowId:a}){let l="unknown",c,p,m=!1;try{m=t==null,p=mc({externalBrowser:t,headed:n});let k=o==null?void 0:Nr({engineBaseUrl:r.engineUrl,preconditionNames:o,webhookSecret:s}),[{project:_,workflow:j},f]=await Promise.all([de({label:"Run context resolved",fn:()=>vc({config:r,workflowId:a})}),de({label:"Streaming run started",fn:()=>Or({config:r,runId:i})}),yr({appUrl:e})]);l=j.name,c=f;let V=kc(j.spec);g.info("Executing workflow: %s",j.name),await Pc(gc({baseUrl:e,browserPromise:p,preconditionPromise:k,project:_,runId:i,specData:V,streaming:c,webhookSecret:s,workflow:j}),Rc())}catch(k){throw await fc({browserPromise:p,config:r,error:k,ownsBrowser:m,runId:i,streaming:c,workflowName:l}),k}}function mc({externalBrowser:e,headed:t}){return e!=null?Promise.resolve(e):de({label:"Browser launched",fn:()=>Ye({headed:t})})}async function fc({browserPromise:e,config:t,error:r,ownsBrowser:n,runId:o,streaming:i,workflowName:s}){let a=r instanceof Error?r.message:String(r),l=r instanceof Error?r.stack:void 0;await Qn({error:a,runId:o,stack:l,workflowName:s}),i==null?await Dr({config:t,reason:a,runId:o}).catch(()=>{}):await i.complete({statusOverride:"failed",steps:[],summary:a}).catch(()=>{}),n&&e!=null&&await(await e.catch(()=>{}))?.close()}async function gc({baseUrl:e,browserPromise:t,preconditionPromise:r,project:n,runId:o,specData:i,streaming:s,webhookSecret:a,workflow:l}){let c=r??Tr({project:hc(n),webhookSecret:a,workflowSlug:l.slug}),[p,m]=await Promise.all([c,t]);await wc({baseUrl:e,browser:m,preconditionResult:p,runId:o,specData:i,streaming:s,webhookSecret:a})}var yc=ue.object({preconditions:ue.array(ue.string()),requiresKeys:ue.array(ue.object({namespace:ue.string(),preconditionName:ue.string()})),slug:ue.string()});function hc(e){let t=(e.workflows??[]).map(r=>{let n=At(It,r);return yc.parse(n)});return{engineBaseUrl:e.engineBaseUrl,workflows:t}}async function wc({baseUrl:e,browser:t,preconditionResult:r,runId:n,specData:o,streaming:i,webhookSecret:s}){let a=await de({label:"Spec executed",fn:()=>jr({baseUrl:e,browser:t,cookies:r.cookies,extraVariables:r.data,observerTransport:r.apiUrl==null?void 0:{apiUrl:r.apiUrl,webhookSecret:s},onRecordingChunk:i.enqueueRecordingChunk,onStep:i.enqueueStep,runId:n,spec:o})});await bc({preconditionResult:r,webhookSecret:s}),await i.complete({statusOverride:void 0,steps:a,summary:void 0});let l=a.filter(p=>p.status==="passed").length,c=a.filter(p=>p.status==="failed").length;g.info("Run complete: %d passed, %d failed",l,c)}async function bc({preconditionResult:e,webhookSecret:t}){e.apiUrl!=null&&await $r({apiUrl:e.apiUrl,cookies:e.cookies,data:e.data,executed:e.executed,webhookSecret:t})}async function vc({config:e,workflowId:t}){let r=await y({config:e,document:pc,variables:{projectId:e.projectId}});if(r.project==null)throw new Error("Project not found");let o={...At(io,r.project),...e.engineUrl.length>0?{engineBaseUrl:e.engineUrl}:{}},s=(o.workflows??[]).find(l=>At(It,l).id===t);if(s==null)throw new Error(`Workflow ${t} not found`);let a=At(It,s);return{project:o,workflow:a}}function kc(e){if(e==null)throw new Error("Workflow has no spec");return xr.decode(e)}var Sc=ue.coerce.number().int().positive().catch(uc);function Rc(){return Sc.parse(process.env.RIPPLO_RUN_TIMEOUT_MS)}async function Pc(e,t){let r,n=new Promise((o,i)=>{r=setTimeout(()=>{i(new Error(`Run timed out after ${String(t)}ms`))},t)});try{await Promise.race([e,n])}finally{r!=null&&clearTimeout(r)}}import{exec as Ic}from"child_process";import{createAuthClient as xc}from"better-auth/client";import{deviceAuthorizationClient as Cc}from"better-auth/client/plugins";function so({baseURL:e}){return xc({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Cc()]})}import{z as Ur}from"zod";var Ec="https://ripplo.ai";function Q(){return jt().RIPPLO_SERVER_URL}function lo(){return jt().RIPPLO_PROJECT_ID}var Ac=Ur.object({RIPPLO_PROJECT_ID:Ur.string().min(1).optional(),RIPPLO_SERVER_URL:Ur.string().min(1).default(Ec)}),ao;function jt(){return ao??=Ac.parse(process.env),ao}var jc=5e3,co="ripplo-cli";async function uo({onDeviceCode:e,url:t}){let r=t??jt().RIPPLO_SERVER_URL,n=so({baseURL:r}),o=await n.device.code({client_id:co});if(o.error!=null)throw new Error(`Failed to request device code: ${o.error.error_description}`);let{device_code:i,user_code:s,verification_uri_complete:a}=o.data;e({userCode:s,verificationUrl:a}),Lc(a);let l=await Tc({authClient:n,deviceCode:i});return vr(l),l}async function Tc({authClient:e,deviceCode:t}){for(;;){await Oc(jc);let r=await e.device.token({client_id:co,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(r.data?.access_token!=null)return r.data.access_token;if(r.error==null)continue;if(!Nc(r.error.error))throw new Error(`Authorization failed: ${r.error.error_description}`)}}var $c=new Set(["authorization_pending","slow_down"]);function Nc(e){return $c.has(e)}function Oc(e){return new Promise(t=>{setTimeout(t,e)})}function Dc(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function Lc(e){let t=Dc();Ic(`${t} "${e}"`,()=>{})}function ke({serverUrl:e,token:t}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:t,webhookSecret:""}}import _c from"fs";import Uc from"path";function x(e){return _c.existsSync(Uc.join(e,".ripplo"))}var Fc=Vc(`
|
|
118
118
|
query AuthViewer {
|
|
119
119
|
currentUser {
|
|
120
120
|
name
|
|
@@ -133,11 +133,11 @@ Load \`/ripplo:create\` skill for instructions.`,status:"failed"}:(n.lastReason=
|
|
|
133
133
|
`),process.stdout.write(n==null?`${i}.
|
|
134
134
|
`:`${i}, ${Hc(n)}.
|
|
135
135
|
`),process.stdout.write(`Session saved to ${ye("token")}.
|
|
136
|
-
`),o||(process.stdout.write("\nNext: run `/ripplo:setup` in Claude Code to wire Ripplo into this project,\n"),process.stdout.write("or `npx ripplo init` to set it up by hand.\n"))}function Hc(e){let t=e.name.trim().split(/\s+/)[0];return t!=null&&t.length>0?t:e.email}async function Vr({serverUrl:e,token:t}){try{let n=(await
|
|
136
|
+
`),o||(process.stdout.write("\nNext: run `/ripplo:setup` in Claude Code to wire Ripplo into this project,\n"),process.stdout.write("or `npx ripplo init` to set it up by hand.\n"))}function Hc(e){let t=e.name.trim().split(/\s+/)[0];return t!=null&&t.length>0?t:e.email}async function Vr({serverUrl:e,token:t}){try{let n=(await y({config:ke({serverUrl:e,token:t}),document:Fc,variables:void 0})).currentUser;return n==null?null:{email:n.email,name:n.name}}catch{return null}}async function mo(){let e=Z();e==null&&(process.stdout.write("Not authenticated. Run `ripplo auth login`.\n"),process.exit(1));let t=Q(),r=await Vr({serverUrl:t,token:e});r==null&&(process.stdout.write("Token rejected. Run `ripplo auth login` to re-authenticate.\n"),process.exit(1)),process.stdout.write(`Authenticated as ${r.name} <${r.email}> (${t})
|
|
137
137
|
`)}function fo(){if(!kr()){process.stdout.write(`No token to remove.
|
|
138
138
|
`);return}process.stdout.write(`Removed ${ye("token")}
|
|
139
|
-
`)}import Hr from"fs/promises";import Br from"path";import{z as Tt}from"zod";import{z as go}from"zod";import{z as Oe}from"zod";import{z as
|
|
140
|
-
`}async function Nt({cwd:e}){let t=Br.join(e,se),r=await Yu(t);return r==null?null:qc(So,r)}async function ae({cwd:e,result:t}){let r=Ro(t),n=Br.join(e,se);await Hr.mkdir(Br.dirname(n),{recursive:!0}),await Hr.writeFile(n,Mr(r),"utf8")}function Ot({compiled:e,existing:t}){if(t==null)return"missing";let r=Mr(Ro(e)),n=Mr(t);return r===n?"match":"stale"}async function Yu(e){try{return await Hr.readFile(e,"utf8")}catch(t){if(Xu(t)&&t.code==="ENOENT")return null;throw t}}function Xu(e){return e instanceof Error&&"code"in e}function Zu(e){return function(r,n){return n===e||!ed(n)?n:Object.fromEntries(Object.entries(n).toSorted(([o],[i])=>o.localeCompare(i)))}}function ed(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import ot from"fs";import _t from"path";var zr=["**/src/**","**/app/**","**/apps/**","**/pages/**","**/routes/**","**/components/**","**/server/**","**/api/**","**/backend/**","**/features/**","**/modules/**","**/views/**","**/ui/**","**/hooks/**","**/contexts/**","**/providers/**","**/controllers/**","**/handlers/**","**/resolvers/**","**/services/**","**/middleware/**","**/lib/**"],Re=["**/*.gen.*","**/generated/**","**/*.d.ts","**/*.test.*","**/*.spec.*","**/node_modules/**","**/dist/**","**/build/**",".ripplo/**","**/*.md","**/.next/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**","**/.nuxt/**","**/.astro/**","**/coverage/**","**/storybook-static/**","**/*.stories.*","**/*.story.*","**/cli/**","**/scripts/**","**/tools/**","**/__tests__/**","**/__mocks__/**","**/__fixtures__/**","**/*.config.*","**/*.setup.*","**/public/**","**/static/**","**/assets/**","**/migrations/**","**/prisma/migrations/**","**/scripts/**"];function Po(e){return e.data}function xo(e){return{as(t){return{data:{label:t,node:e}}}}}function Dt(e){let t=e.getPreconditions(),r=e.getObservers(),n=e.getTests();td(n);let o={};t.forEach(a=>{o[a.name]={depends:[...a.dependsOn],description:a.description,returns:[...a.returns]}});let i={};r.forEach(a=>{i[a.name]={budget:a.budget,description:a.description}});let s=n.map(a=>rd(a,t));return{observers:i,preconditions:o,tests:s}}function td(e){let t=new Map;e.forEach(r=>{let n=t.get(r.id);if(n!=null)throw new Error(`Duplicate test id "${r.id}" used by "${n}" and "${r.name}"`);t.set(r.id,r.name)})}function rd(e,t){let r=e.id,{accessedKeys:n,vars:o}=od(e.requiresKeys),i=e.startsAtFn==null?void 0:e.startsAtFn(o),s=e.stepsFn==null?[]:e.stepsFn(o),a=i==null?s:[nd(i),...s],l=id(a,n,e.requiresKeys,e.uiOnly),c=[];Object.keys(e.requiresKeys).length>0&&n.size===0&&e.implemented&&c.push("Test requires preconditions but never references their data \u2014 destructure and use precondition data in steps()");let m=ad(e.requires,t);return{additionalChecks:[],coverage:e.coverage,description:e.description,expectedOutcome:e.expectedOutcome,implemented:e.implemented,name:e.name,preconditions:m,requiresKeys:{...e.requiresKeys},slug:r,spec:l,warnings:c}}function nd(e){return xo({type:"goto",url:{type:"static",value:e}}).as(`navigate to ${e}`)}function od(e){let t=new Set,r={};return Object.keys(e).forEach(n=>{r[n]=new Proxy({},{get(o,i){if(typeof i=="string"){let s=`${n}.${i}`;return t.add(s),`{{${s}}}`}}})}),{accessedKeys:t,vars:r}}function id(e,t,r,n){let o={};e.forEach((a,l)=>{let c=`step-${String(l)}`,p=l<e.length-1?`step-${String(l+1)}`:void 0;o[c]=sd(a,c,p)});let i={};t.forEach(a=>{i[a]={default:`test-${a}`,type:"string"}});let s={...r};return{entryNode:"step-0",nodes:o,uiOnly:n,variableNamespaces:s,variables:i}}function sd(e,t,r){let{label:n,node:o}=Po(e);return{...o,id:t,label:n,next:r}}function ad(e,t){let r=new Map(t.map(s=>[s.name,s])),n=[],o=new Set;function i(s){o.has(s)||(o.add(s),r.get(s)?.dependsOn.forEach(a=>{i(a)}),n.push(s))}return e.forEach(s=>{i(s)}),n}import{Webhook as xv,WebhookVerificationError as Cv}from"standardwebhooks";import{z as R}from"zod";var Iv=R.object({preconditions:R.array(R.string().min(1))}),Av=R.object({data:R.record(R.string(),R.record(R.string(),R.string())),preconditions:R.array(R.string().min(1))}),jv=R.object({observer:R.string().min(1).max(200),params:R.record(R.string().max(200),R.union([R.string(),R.number(),R.boolean()]))}),ld=R.discriminatedUnion("kind",[R.object({kind:R.literal("pass")}),R.object({kind:R.literal("retry"),reason:R.string()}),R.object({kind:R.literal("fail"),reason:R.string()})]),Tv=R.object({error:R.string().optional(),outcome:ld.optional(),success:R.boolean()});function De(e){let t=[];return e.tests.forEach(r=>{let n=cd(r),o=i=>{t.push({...i,test:r.slug})};Td.forEach(i=>{i(n,r,o)})}),{diagnostics:t}}function cd(e){let t=[],r=e.spec.entryNode,n=new Set;for(;r!=null&&!n.has(r);){n.add(r);let o=e.spec.nodes[r];if(o==null)break;t.push(o),r=o.next}return t}function ud(e,t,r){e.forEach(n=>{n.type==="assertText"&&"operator"in n&&n.operator!=="equals"&&r({message:`${n.type} uses operator "${n.operator}" \u2014 only "equals" is allowed for determinism`,rule:"exact-text-match",step:n.label??n.id})})}function dd(e,t,r){Object.keys(t.spec.variables??{}).length>0&&e.forEach(o=>{if(o.type==="fill"&&Eo(o.value)){let i=o.value.value;!Io(i)&&wd(i)&&r({message:`fill() uses hardcoded value "${i}" \u2014 consider using precondition data via {{namespace.key}}`,rule:"no-hardcoded-data",step:o.label??o.id})}})}function pd(e,t,r){if(Object.keys(t.spec.variables??{}).length===0)return;e.some(i=>JSON.stringify(i).includes("{{"))||r({message:"Test requires preconditions but steps() never references precondition data \u2014 destructure and use it",rule:"prefer-precondition-data",step:void 0})}function md(e,t,r){e.forEach(n=>{(n.label==null||n.label.length===0)&&r({message:`Step "${n.id}" lacks .as("...") label \u2014 every step must be labeled`,rule:"missing-label",step:n.id})})}function fd(e,t,r){let n=new Map;e.forEach(o=>{if(o.label==null)return;let i=n.get(o.label);i==null?n.set(o.label,o.id):r({message:`Duplicate label "${o.label}" \u2014 also used by ${i}`,rule:"no-duplicate-labels",step:o.label})})}function gd(e,t,r){let n=0;e.forEach((o,i)=>{if(!(i===0&&o.type==="goto")){if(Le(o)){n=0;return}n++,n===3&&r({message:"3+ consecutive actions without an assertion \u2014 add verification between actions",rule:"assert-after-action",step:o.label??o.id})}})}function yd(e,t,r){if(e.length===0)return;let n=e.at(-1);n!=null&&!Le(n)&&r({message:"Last step is an action, not an assertion \u2014 expectedOutcome should be verified by assertions at the end",rule:"assert-matches-outcome",step:n.label??n.id})}function hd(e,t,r){t.implemented&&e.length===0&&r({message:"Test has zero steps",rule:"no-empty-steps",step:void 0})}function Eo(e){return!(typeof e!="object"||e==null||!("type"in e)||e.type!=="static"||!("value"in e)||typeof e.value!="string")}function Io(e){return e.includes("{{")}function wd(e){return e.includes("@")||/\b[a-f0-9]{8,}\b/.test(e)||/^(test|ripplo|example|sample|demo)/i.test(e)}function Le(e){return e.type.startsWith("assert")}var bd=new Set(["assertText","assertValue","assertCount","assertUrl","assertNotVisible","assertChecked","assertNotChecked","assertAttribute","assertDisabled","assertEnabled"]);function vd(e){return bd.has(e.type)}function kd(e,t,r){!t.implemented||e.length===0||e.some(n=>Le(n))||r({message:"Test has zero assertion steps \u2014 cannot verify expectedOutcome. Add assert.* steps.",rule:"no-assertions",step:void 0})}function Sd(e,t,r){if(!t.implemented||e.length<=3)return;let n=e.filter(i=>Le(i)).length;if(n===0)return;let o=n/e.length;if(o<.15){let i=Math.round(o*100);r({message:`Only ${String(n)}/${String(e.length)} steps are assertions (${String(i)}%) \u2014 add more verification between actions`,rule:"low-assertion-ratio",step:void 0})}}function Gr(e){if(!("locator"in e)||e.locator==null)return;let t=e.locator;return t.by==="role"?`role:${t.role}:${t.name??""}`:`testId:${t.value}`}function Rd(e,t,r){e.forEach((n,o)=>{if(n.type!=="click")return;let i=Gr(n);if(i==null)return;let s=e.slice(o+1,o+4);s.find(c=>c.type==="assertVisible"&&Gr(c)===i)==null||s.some(c=>vd(c)||Le(c)&&Gr(c)!==i)||r({message:`click "${n.label??n.id}" is followed only by assert.visible on the same locator \u2014 verifies nothing about the click's effect`,rule:"tautological-post-click-assert",step:n.label??n.id})})}var Pd=new Set(["the","is","a","an","and","or","of","to","in","on","at","for","that","this","with","be","are","was","were","it","its","as","by","from","after","before","should","will","can","still","but","not","no","so","if","then","than","user","users","page","view","shows","show","see","click","clicks","clicked","clickable","visible","appears","appear","displayed","stays","remains"]);function Kr(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=3&&!Pd.has(t))}function xd(e){let t=e.label==null?[]:Kr(e.label);if(!("locator"in e)||e.locator==null)return t;let r=e.locator,n=r.by==="role"?r.name??"":r.value;return[...t,...Kr(n)]}function Cd(e,t,r){if(!t.implemented||e.length===0)return;let n=new Set(Kr(t.expectedOutcome));if(n.size===0)return;let o=e.filter(s=>Le(s));if(o.length===0)return;o.some(s=>xd(s).some(a=>n.has(a)))||r({message:`No assertion references any keyword from expectedOutcome (${[...n].join(", ")}) \u2014 the outcome may not actually be verified`,rule:"expected-outcome-keyword-coverage",step:void 0})}var Ed=/save|submit|create|delete|remove|send|invite|update|confirm|publish|apply|pay|subscribe|upgrade|cancel|archive|rename/i;function Co(e){if(e.type==="upload")return!0;if(e.type!=="click")return!1;let t=e.locator,r=t.by==="role"?t.name??"":t.value;return Ed.test(r)}function Id(e,t,r){!t.implemented||t.spec.uiOnly===!0||e.forEach((n,o)=>{if(!Co(n)||"uiOnly"in n&&n.uiOnly===!0)return;let i=e.slice(o+1),s=i.findIndex(p=>Co(p)),a=s===-1?i.length:s;i.slice(0,a).some(p=>p.type==="assertObserver")||r({message:`"${n.label??n.id}" looks like it mutates backend state but no assert.backend(...) observer verifies it \u2014 the test can pass while the server is broken. You need to add an observer that checks the persisted result (see .ripplo/observers/ for examples). Only if this action truly does NOT change any server state (pure client-side interaction, presentation toggle, etc.) should you fall back to marking the step { uiOnly: true } to silence this rule.`,rule:"mutation-without-observer-coverage",step:n.label??n.id})})}function Ad(e,t,r){Object.keys(t.spec.variables??{}).length!==0&&e.forEach(o=>{if(o.type!=="assertObserver")return;let i=Object.entries(o.params);i.length===0||i.some(([,a])=>Eo(a)&&Io(a.value))||r({message:`assert.backend "${o.label??o.id}" passes only hardcoded params while the test defines precondition variables \u2014 observer assertions should reference {{namespace.key}} so they match the actual precondition data`,rule:"observer-params-reference-variables",step:o.label??o.id})})}function jd(e,t,r){let n=new Set(Object.keys(t.spec.variables??{})),o=/\{\{([^{}]+?)\}\}/g;e.forEach(i=>{let a=[...JSON.stringify(i).matchAll(o)],l=[...new Set(a.map(m=>m[1]).filter(m=>m!=null&&!n.has(m)))];if(l.length===0)return;let c=l.map(m=>`{{${m}}}`).join(", "),p=[...new Set(l.map(m=>m.split(".")[0]??m))].join(", ");r({message:`"${i.label??i.id}" contains literal template string(s) ${c} \u2014 destructure the proxy in .steps(({ ${p} }) => \u2026) and pass the proxy value (e.g. \`${l[0]??""}\`) directly. Writing the template as a string bypasses type-checking and silently accepts typos.`,rule:"no-literal-template-strings",step:i.label??i.id})})}var Td=[ud,dd,jd,pd,md,fd,gd,yd,hd,kd,Sd,Rd,Cd,Id,Ad];import rp from"picomatch";import{execFileSync as $d,spawnSync as Nd}from"child_process";function q(e,t){return $d("git",[...e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}function Ao(e,t){let r=Nd("git",["show",e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(r.status===0)return r.stdout;if(r.status===128)return null;throw new Error(`git show ${e} failed (${String(r.status)}): ${r.stderr}`)}import h from"typescript";import*as jo from"remeda";var To=[["onClick","click"],["onContextMenu","click"],["onKeyDown","click"],["onKeyPress","click"],["onKeyUp","click"],["onSelect","click"],["onOpenChange","click"],["onPress","click"],["onActivate","click"],["onToggle","click"],["onOpen","click"],["onClose","click"],["onDismiss","click"],["onConfirm","click"],["onCancel","click"],["onApply","click"],["onClear","click"],["onSubmit","submit"],["onReset","submit"],["onDrop","drag"],["onDragEnd","drag"],["onDragEnter","drag"],["onDragLeave","drag"],["onDragOver","drag"],["onDragStart","drag"],["onValueChange","select"],["onSelectionChange","select"],["onChange","input"],["onCheckedChange","input"],["onInput","input"]],Od=new Map([["button","click"],["link","navigate"],["textbox","input"],["searchbox","input"],["combobox","select"],["listbox","select"]]),Dd=[[/(?:^|[a-z])Button$/,"click"],[/(?:^|[a-z])(?:Link|NavLink|Anchor)$/,"navigate"],[/(?:^|[a-z])(?:Textarea|TextArea|Input|Field|SearchBox)$/,"input"],[/(?:^|[a-z])(?:Select|Combobox|ComboBox|Dropdown)$/,"select"],[/(?:^|[a-z])Form$/,"submit"]];function Lt({filePath:e,source:t}){let r=h.createSourceFile(e,t,h.ScriptTarget.Latest,!0,h.ScriptKind.TSX);return r.statements.flatMap(n=>Ld({filePath:e,sf:r,stmt:n}))}function Ld({filePath:e,sf:t,stmt:r}){let n=Ud(r);if(n==null||_d(n))return[];let o=$o(r,t).map(i=>({id:`${e}#${n}.${i.kind}[${i.label}]`,line:i.line}));return jo.uniqueBy(o,i=>i.id)}function _d(e){return e.endsWith("Fragment")||e.endsWith("Skeleton")||/^use[A-Z]/.test(e)||/^[A-Z][A-Z0-9_]*$/.test(e)}function Ud(e){if(h.isExportAssignment(e))return Vd(e.expression);if(!Fd(e))return null;if(h.isFunctionDeclaration(e)||h.isClassDeclaration(e))return e.name?.text??null;if(h.isVariableStatement(e)){let t=e.declarationList.declarations[0];return t!=null&&h.isIdentifier(t.name)?t.name.text:null}return null}function Vd(e){return h.isIdentifier(e)?e.text:(h.isFunctionExpression(e)||h.isClassExpression(e))&&e.name!=null?e.name.text:"default"}function Fd(e){if(!h.canHaveModifiers(e))return!1;let t=h.getModifiers(e);return t!=null&&t.some(r=>r.kind===h.SyntaxKind.ExportKeyword)}function $o(e,t){let r=Hd(e,t),n=e.getChildren(t).flatMap(o=>$o(o,t));return r==null?n:[r,...n]}function Hd(e,t){let r=Bd(e);if(r==null)return null;let n=Wd(r);if(n==null)return null;let o=Kd(r,n);return o==null?null:{kind:n,label:o,line:tp(t,e.getStart(t))}}function Bd(e){return h.isJsxSelfClosingElement(e)&&h.isIdentifier(e.tagName)?{attrs:e.attributes,children:[],tag:e.tagName.text}:h.isJsxElement(e)&&h.isIdentifier(e.openingElement.tagName)?{attrs:e.openingElement.attributes,children:e.children,tag:e.openingElement.tagName.text}:null}function Wd({attrs:e,tag:t}){let r=le(e,"role");return r!=null?Od.get(r)??null:qd(t,e)??zd(t)??Gd(e)}var Md=new Map([["button",()=>"click"],["a",e=>le(e,"href")==null?null:"navigate"],["input",e=>le(e,"type")==="file"?"upload":"input"],["textarea",()=>"input"],["select",()=>"select"],["form",()=>"submit"]]);function qd(e,t){return Md.get(e)?.(t)??null}function zd(e){return/^[A-Z]/.test(e)?Dd.find(([t])=>t.test(e))?.[1]??null:null}function Gd(e){return To.find(([t])=>Yd(e,t))?.[1]??null}function Kd({attrs:e,children:t,tag:r},n){return n==="navigate"?le(e,"href")??le(e,"to"):le(e,"aria-label")??le(e,"label")??le(e,"title")??le(e,"name")??le(e,"placeholder")??(Jd(r)?void 0:ep(t))??Qd(e,n)}function Jd(e){return e==="input"||e==="textarea"||e==="select"}function Qd(e,t){let r=To.find(([,o])=>o===t)?.[0];if(r==null)return;let n=Xd(e,r);if(n!=null){if(h.isIdentifier(n))return n.text;if(h.isArrowFunction(n)||h.isFunctionExpression(n))return No(n.body)}}function No(e){if(h.isCallExpression(e)){let t=e.expression;return h.isIdentifier(t)?t.text:h.isPropertyAccessExpression(t)?t.name.text:void 0}return h.forEachChild(e,No)}function Yd(e,t){return e.properties.some(r=>h.isJsxAttribute(r)&&h.isIdentifier(r.name)&&r.name.text===t)}function Oo(e,t){return e.properties.find(r=>h.isJsxAttribute(r)&&h.isIdentifier(r.name)&&r.name.text===t)}function le(e,t){let r=Oo(e,t);return r==null?void 0:Zd(r.initializer)}function Xd(e,t){let r=Oo(e,t);if(!(r?.initializer==null||!h.isJsxExpression(r.initializer)))return r.initializer.expression}function Zd(e){if(e==null)return"";if(h.isStringLiteral(e))return e.text;if(h.isJsxExpression(e))return Lo(e.expression)}function ep(e){let t=e.flatMap(r=>Do(r)).join(" ").trim();return t.length===0?void 0:t}function Do(e){if(h.isJsxText(e)){let t=e.text.trim();return t.length===0?[]:[t]}if(h.isJsxExpression(e)){let t=Lo(e.expression);return t==null?[]:[t]}return h.isJsxElement(e)?e.children.flatMap(t=>Do(t)):[]}function Lo(e){if(e!=null){if(h.isStringLiteral(e)||h.isNoSubstitutionTemplateLiteral(e))return e.text;if(h.isCallExpression(e)&&e.arguments.length===1){let t=e.arguments[0];if(t!=null&&(h.isStringLiteral(t)||h.isNoSubstitutionTemplateLiteral(t)))return t.text}}}function tp(e,t){return e.getLineAndCharacterOfPosition(t).line+1}var np=_t.join(".ripplo","coverage.d.ts");function _e({cwd:e}){op({cwd:e,ignorePaths:Re})}function op({cwd:e,ignorePaths:t}){let r=Ue({cwd:e,ignorePaths:t});ap({content:sp(r),cwd:e})}function Ue({cwd:e,ignorePaths:t}){let n=ip({cwd:e,ignorePaths:t}).flatMap(o=>Jr({cwd:e,file:o}));return[...new Set(n)].sort((o,i)=>o.localeCompare(i))}function ip({cwd:e,ignorePaths:t}){let r=q(["ls-files","--cached","--others","--exclude-standard","-z"],e),n=rp([...t]);return r.split("\0").filter(o=>o.length>0&&/\.(tsx|jsx)$/.test(o)).filter(o=>!n(o)).filter(o=>ot.existsSync(_t.join(e,o)))}function Jr({cwd:e,file:t}){let r=ot.readFileSync(_t.join(e,t),"utf8");return Lt({filePath:t,source:r}).map(n=>n.id)}function sp(e){let t=`// GENERATED \u2014 do not edit
|
|
139
|
+
`)}import Hr from"fs/promises";import Br from"path";import{z as Tt}from"zod";import{z as go}from"zod";import{z as Oe}from"zod";import{z as u}from"zod";import{z as Se}from"zod";import{z as vo}from"zod";import{z as I}from"zod";import{z as Y}from"zod";import{z as Fr}from"zod";import{z as U}from"zod";var Bc=Tt.object({__codec:Tt.string().min(1),data:Tt.unknown(),version:Tt.number().int().positive()}),Wc=class extends Error{codec;currentVersion;gotVersion;constructor(e){super(`Unsupported ${e.codec} version ${String(e.gotVersion)} (current ${String(e.currentVersion)}). Upgrade Ripplo or rebuild with a compatible CLI.`),this.name="CodecVersionError",this.codec=e.codec,this.currentVersion=e.currentVersion,this.gotVersion=e.gotVersion}},Mc=class extends Error{constructor(e){super(`Codec mismatch: expected "${e.expected}", got "${e.got}"`),this.name="CodecMismatchError"}};function qr(e){return ho({legacy:void 0,migrators:[],name:e,schemas:[]})}function qc(e,t){let r=JSON.parse(t);return e.decode(r)}function ho(e){return{initial:t=>Wr(t,{...e,schemas:[t]}),legacy:t=>ho({...e,legacy:t})}}function Wr(e,t){return{build:()=>zc(e,t),legacy:r=>Wr(e,{...t,legacy:r}),upgrade:(r,n)=>{let o=n;return Wr(r,{...t,migrators:[...t.migrators,o],schemas:[...t.schemas,r]})}}}function zc(e,t){let r=t.schemas.length;return{currentVersion:r,name:t.name,decode:n=>Gc(e,t,n),encode:n=>({__codec:t.name,data:n,version:r})}}function Gc(e,t,r){let{data:n,version:o}=Kc(t,r),i=wo(t,n,o);return e.parse(i)}function Kc(e,t){let r=Bc.safeParse(t);if(r.success){if(r.data.__codec!==e.name)throw new Mc({expected:e.name,got:r.data.__codec});return{data:r.data.data,version:r.data.version}}if(e.legacy!=null&&e.legacy.detect(t))return{data:t,version:e.legacy.assumedVersion};throw new Error(`Cannot decode "${e.name}": value is not a codec envelope and no legacy detector matched.`)}function wo(e,t,r){let n=e.schemas.length;if(r>n)throw new Wc({codec:e.name,currentVersion:n,gotVersion:r});if(r===n)return t;let o=e.schemas[r-1];if(o==null)throw new Error(`Codec "${e.name}" missing schema for v${String(r)}; cannot migrate.`);let i=o.parse(t),s=e.migrators[r-1];if(s==null)throw new Error(`Codec "${e.name}" missing migrator v${String(r)} \u2192 v${String(r+1)}.`);return wo(e,s(i),r+1)}var bo=Oe.object({depends:Oe.array(Oe.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:Oe.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:Oe.array(Oe.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name."),Jc=Se.object({by:Se.literal("testId"),value:Se.string().min(1)}),Qc=Se.object({by:Se.literal("role"),name:Se.string().optional(),role:Se.string().min(1)}),P=Se.discriminatedUnion("by",[Jc,Qc]),nt=vo.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),Yc=vo.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]),Xc=I.object({type:I.literal("static"),value:I.union([I.string(),I.number(),I.boolean()])}),$t=I.object({name:I.string().min(1),type:I.literal("variable")}),Zc=I.discriminatedUnion("type",[Xc,$t]),ie=I.discriminatedUnion("type",[I.object({type:I.literal("static"),value:I.string()}),$t]),ed=I.discriminatedUnion("type",[I.object({type:I.literal("static"),value:I.number().int().nonnegative()}),$t]),td=I.discriminatedUnion("type",[I.object({type:I.literal("static"),value:I.union([I.string(),I.number(),I.boolean()])}),$t]),rd=Y.discriminatedUnion("type",[Y.object({default:Y.string().optional(),type:Y.literal("string")}),Y.object({default:Y.number().optional(),type:Y.literal("number")}),Y.object({default:Y.boolean().optional(),type:Y.literal("boolean")}),Y.object({key:Y.string().min(1),type:Y.literal("env")})]),v={id:u.string().min(1).max(200),label:u.string().max(500).optional(),next:u.string().max(200).optional(),uiOnly:u.boolean().optional()},yo=500,nd=u.object({...v,type:u.literal("goto"),url:ie}),od=u.object({...v,locator:P,type:u.literal("click")}),id=u.object({...v,locator:P,type:u.literal("fill"),value:ie}),sd=u.object({...v,locator:P,type:u.literal("select"),value:ie}),ad=u.object({...v,locator:P,type:u.literal("hover")}),ld=u.object({...v,key:u.string().min(1),locator:P.optional(),type:u.literal("press")}),cd=u.object({...v,locator:P,type:u.literal("check")}),dd=u.object({...v,locator:P,type:u.literal("uncheck")}),ud=u.object({...v,height:u.number().int().positive(),type:u.literal("setViewport"),width:u.number().int().positive()}),pd=u.object({...v,message:u.string().min(1),type:u.literal("fail")}),md=u.object({...v,type:u.literal("setVariable"),value:Zc,variable:u.string().min(1)}),fd=u.object({...v,locator:P,type:u.literal("extractText"),variable:u.string().min(1)}),gd=u.object({...v,files:u.array(u.string()).min(1),locator:P,type:u.literal("upload")}),yd=u.object({...v,locator:P,type:u.literal("dblclick")}),hd=u.object({...v,source:P,target:P,type:u.literal("drag")}),wd=u.object({...v,locator:P,type:u.literal("scrollIntoView")}),bd=u.object({...v,locator:P,type:u.literal("type"),value:ie}),vd=u.object({...v,locator:P,type:u.literal("focus")}),kd=u.object({...v,locator:P,type:u.literal("clear")}),Sd=u.object({...v,locator:P,type:u.literal("rightClick")}),Rd=u.object({...v,action:u.enum(["accept","dismiss"]),promptText:u.string().optional(),type:u.literal("handleDialog")}),Pd=u.object({...v,action:u.enum(["read","write"]),type:u.literal("clipboard"),value:ie.optional(),variable:u.string().min(1).optional()}),xd=u.object({...v,permission:u.string().min(1),state:u.enum(["granted","prompt"]),type:u.literal("setPermission")}),Cd=u.object({...v,locator:P,type:u.literal("assertVisible")}),Ed=u.object({...v,locator:P,type:u.literal("assertNotVisible")}),Ad=u.object({...v,expected:ie,locator:P,operator:nt,type:u.literal("assertText")}),Id=u.object({...v,expected:ie,operator:nt,type:u.literal("assertUrl")}),jd=u.object({...v,expected:ed,locator:P,operator:Yc,type:u.literal("assertCount")}),Td=u.object({...v,expected:ie,locator:P,operator:nt,type:u.literal("assertValue")}),$d=u.object({...v,attribute:u.string().min(1),expected:ie,locator:P,operator:nt,type:u.literal("assertAttribute")}),Nd=u.object({...v,locator:P,type:u.literal("assertEnabled")}),Od=u.object({...v,locator:P,type:u.literal("assertDisabled")}),Dd=u.object({...v,expected:ie,operator:nt,type:u.literal("assertTitle")}),Ld=u.object({...v,locator:P,type:u.literal("assertChecked")}),_d=u.object({...v,locator:P,type:u.literal("assertNotChecked")}),Ud=u.object({...v,locator:P,type:u.literal("assertFocused")}),Vd=u.object({...v,locator:P,type:u.literal("assertNotFocused")}),Fd=u.object({...v,budget:u.enum(["fast","slow","async"]),observer:u.string().min(1).max(200),params:u.record(u.string().max(200),td),type:u.literal("assertObserver")}),Hd=u.discriminatedUnion("type",[nd,od,id,sd,ad,ld,cd,dd,Cd,Ed,Ad,Id,jd,Td,$d,Nd,Od,ud,pd,md,fd,gd,yd,hd,wd,bd,vd,kd,Sd,Rd,Pd,xd,Dd,Ld,_d,Ud,Vd,Fd]),ko=u.object({entryNode:u.string().min(1).max(200),nodes:u.record(u.string().max(200),Hd).refine(e=>Object.keys(e).length<=yo,`Workflow has more than ${String(yo)} nodes`),uiOnly:u.boolean().optional(),variableNamespaces:u.record(u.string().max(200),u.string().max(500)).optional(),variables:u.record(u.string().max(200),rd).optional()}),Bd=go.record(go.string().max(200),bo),Wd={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&"entryNode"in e&&"nodes"in e},Md={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&!("__codec"in e)},mv=qr("workflow-spec").legacy(Wd).initial(ko).build(),fv=qr("precondition-map").legacy(Md).initial(Bd).build(),qd=["fast","slow","async"],zd=Fr.object({budget:Fr.enum(qd).describe("Polling budget tier: fast | slow | async"),description:Fr.string().min(1).describe("Human-readable description of what this observer checks")}).describe("A named backend state observer. Tests assert against it with assert.backend(observer, params). Implementation lives on the user's server."),se=".ripplo/ripplo.lock",Gd=5e3,Kd=U.record(U.string().max(200),U.string().max(200)),Jd=U.object({coverage:U.array(U.string().max(500)).max(2e3).default([]),expectedOutcome:U.string().max(2e3),name:U.string().max(200),preconditions:U.array(U.string().max(200)).max(1e3),requiresKeys:Kd,slug:U.string().max(200),spec:ko}),Qd=U.object({observers:U.record(U.string().max(200),zd),preconditions:U.record(U.string().max(200),bo),tests:U.array(Jd).max(Gd)}),So=qr("ripplo-lockfile").initial(Qd).build();function Ro(e){return{observers:e.observers,preconditions:e.preconditions,tests:e.tests.filter(t=>t.implemented).map(t=>({coverage:[...t.coverage],expectedOutcome:t.expectedOutcome,name:t.name,preconditions:[...t.preconditions],requiresKeys:{...t.requiresKeys},slug:t.slug,spec:t.spec}))}}function Mr(e){let t=So.encode(e);return`${JSON.stringify(t,Zd(t),2)}
|
|
140
|
+
`}async function Nt({cwd:e}){let t=Br.join(e,se),r=await Yd(t);return r==null?null:qc(So,r)}async function ae({cwd:e,result:t}){let r=Ro(t),n=Br.join(e,se);await Hr.mkdir(Br.dirname(n),{recursive:!0}),await Hr.writeFile(n,Mr(r),"utf8")}function Ot({compiled:e,existing:t}){if(t==null)return"missing";let r=Mr(Ro(e)),n=Mr(t);return r===n?"match":"stale"}async function Yd(e){try{return await Hr.readFile(e,"utf8")}catch(t){if(Xd(t)&&t.code==="ENOENT")return null;throw t}}function Xd(e){return e instanceof Error&&"code"in e}function Zd(e){return function(r,n){return n===e||!eu(n)?n:Object.fromEntries(Object.entries(n).toSorted(([o],[i])=>o.localeCompare(i)))}}function eu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import ot from"fs";import _t from"path";var zr=["**/src/**","**/app/**","**/apps/**","**/pages/**","**/routes/**","**/components/**","**/server/**","**/api/**","**/backend/**","**/features/**","**/modules/**","**/views/**","**/ui/**","**/hooks/**","**/contexts/**","**/providers/**","**/controllers/**","**/handlers/**","**/resolvers/**","**/services/**","**/middleware/**","**/lib/**"],Re=["**/*.gen.*","**/generated/**","**/*.d.ts","**/*.test.*","**/*.spec.*","**/node_modules/**","**/dist/**","**/build/**",".ripplo/**","**/*.md","**/.next/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**","**/.nuxt/**","**/.astro/**","**/coverage/**","**/storybook-static/**","**/*.stories.*","**/*.story.*","**/cli/**","**/scripts/**","**/tools/**","**/__tests__/**","**/__mocks__/**","**/__fixtures__/**","**/*.config.*","**/*.setup.*","**/public/**","**/static/**","**/assets/**","**/migrations/**","**/prisma/migrations/**","**/scripts/**"];function Po(e){return e.data}function xo(e){return{as(t){return{data:{label:t,node:e}}}}}function Dt(e){let t=e.getPreconditions(),r=e.getObservers(),n=e.getTests();tu(n);let o={};t.forEach(a=>{o[a.name]={depends:[...a.dependsOn],description:a.description,returns:[...a.returns]}});let i={};r.forEach(a=>{i[a.name]={budget:a.budget,description:a.description}});let s=n.map(a=>ru(a,t));return{observers:i,preconditions:o,tests:s}}function tu(e){let t=new Map;e.forEach(r=>{let n=t.get(r.id);if(n!=null)throw new Error(`Duplicate test id "${r.id}" used by "${n}" and "${r.name}"`);t.set(r.id,r.name)})}function ru(e,t){let r=e.id,{accessedKeys:n,vars:o}=ou(e.requiresKeys),i=e.startsAtFn==null?void 0:e.startsAtFn(o),s=e.stepsFn==null?[]:e.stepsFn(o),a=i==null?s:[nu(i),...s],l=iu(a,n,e.requiresKeys,e.uiOnly),c=[];Object.keys(e.requiresKeys).length>0&&n.size===0&&e.implemented&&c.push("Test requires preconditions but never references their data \u2014 destructure and use precondition data in steps()");let m=au(e.requires,t);return{additionalChecks:[],coverage:e.coverage,description:e.description,expectedOutcome:e.expectedOutcome,implemented:e.implemented,name:e.name,preconditions:m,requiresKeys:{...e.requiresKeys},slug:r,spec:l,warnings:c}}function nu(e){return xo({type:"goto",url:{type:"static",value:e}}).as(`navigate to ${e}`)}function ou(e){let t=new Set,r={};return Object.keys(e).forEach(n=>{r[n]=new Proxy({},{get(o,i){if(typeof i=="string"){let s=`${n}.${i}`;return t.add(s),`{{${s}}}`}}})}),{accessedKeys:t,vars:r}}function iu(e,t,r,n){let o={};e.forEach((a,l)=>{let c=`step-${String(l)}`,p=l<e.length-1?`step-${String(l+1)}`:void 0;o[c]=su(a,c,p)});let i={};t.forEach(a=>{i[a]={default:`test-${a}`,type:"string"}});let s={...r};return{entryNode:"step-0",nodes:o,uiOnly:n,variableNamespaces:s,variables:i}}function su(e,t,r){let{label:n,node:o}=Po(e);return{...o,id:t,label:n,next:r}}function au(e,t){let r=new Map(t.map(s=>[s.name,s])),n=[],o=new Set;function i(s){o.has(s)||(o.add(s),r.get(s)?.dependsOn.forEach(a=>{i(a)}),n.push(s))}return e.forEach(s=>{i(s)}),n}import{Webhook as xv,WebhookVerificationError as Cv}from"standardwebhooks";import{z as R}from"zod";var Av=R.object({preconditions:R.array(R.string().min(1))}),Iv=R.object({data:R.record(R.string(),R.record(R.string(),R.string())),preconditions:R.array(R.string().min(1))}),jv=R.object({observer:R.string().min(1).max(200),params:R.record(R.string().max(200),R.union([R.string(),R.number(),R.boolean()]))}),lu=R.discriminatedUnion("kind",[R.object({kind:R.literal("pass")}),R.object({kind:R.literal("retry"),reason:R.string()}),R.object({kind:R.literal("fail"),reason:R.string()})]),Tv=R.object({error:R.string().optional(),outcome:lu.optional(),success:R.boolean()});function De(e){let t=[];return e.tests.forEach(r=>{let n=cu(r),o=i=>{t.push({...i,test:r.slug})};Tu.forEach(i=>{i(n,r,o)})}),{diagnostics:t}}function cu(e){let t=[],r=e.spec.entryNode,n=new Set;for(;r!=null&&!n.has(r);){n.add(r);let o=e.spec.nodes[r];if(o==null)break;t.push(o),r=o.next}return t}function du(e,t,r){e.forEach(n=>{n.type==="assertText"&&"operator"in n&&n.operator!=="equals"&&r({message:`${n.type} uses operator "${n.operator}" \u2014 only "equals" is allowed for determinism`,rule:"exact-text-match",step:n.label??n.id})})}function uu(e,t,r){Object.keys(t.spec.variables??{}).length>0&&e.forEach(o=>{if(o.type==="fill"&&Eo(o.value)){let i=o.value.value;!Ao(i)&&wu(i)&&r({message:`fill() uses hardcoded value "${i}" \u2014 consider using precondition data via {{namespace.key}}`,rule:"no-hardcoded-data",step:o.label??o.id})}})}function pu(e,t,r){if(Object.keys(t.spec.variables??{}).length===0)return;e.some(i=>JSON.stringify(i).includes("{{"))||r({message:"Test requires preconditions but steps() never references precondition data \u2014 destructure and use it",rule:"prefer-precondition-data",step:void 0})}function mu(e,t,r){e.forEach(n=>{(n.label==null||n.label.length===0)&&r({message:`Step "${n.id}" lacks .as("...") label \u2014 every step must be labeled`,rule:"missing-label",step:n.id})})}function fu(e,t,r){let n=new Map;e.forEach(o=>{if(o.label==null)return;let i=n.get(o.label);i==null?n.set(o.label,o.id):r({message:`Duplicate label "${o.label}" \u2014 also used by ${i}`,rule:"no-duplicate-labels",step:o.label})})}function gu(e,t,r){let n=0;e.forEach((o,i)=>{if(!(i===0&&o.type==="goto")){if(Le(o)){n=0;return}n++,n===3&&r({message:"3+ consecutive actions without an assertion \u2014 add verification between actions",rule:"assert-after-action",step:o.label??o.id})}})}function yu(e,t,r){if(e.length===0)return;let n=e.at(-1);n!=null&&!Le(n)&&r({message:"Last step is an action, not an assertion \u2014 expectedOutcome should be verified by assertions at the end",rule:"assert-matches-outcome",step:n.label??n.id})}function hu(e,t,r){t.implemented&&e.length===0&&r({message:"Test has zero steps",rule:"no-empty-steps",step:void 0})}function Eo(e){return!(typeof e!="object"||e==null||!("type"in e)||e.type!=="static"||!("value"in e)||typeof e.value!="string")}function Ao(e){return e.includes("{{")}function wu(e){return e.includes("@")||/\b[a-f0-9]{8,}\b/.test(e)||/^(test|ripplo|example|sample|demo)/i.test(e)}function Le(e){return e.type.startsWith("assert")}var bu=new Set(["assertText","assertValue","assertCount","assertUrl","assertNotVisible","assertChecked","assertNotChecked","assertAttribute","assertDisabled","assertEnabled"]);function vu(e){return bu.has(e.type)}function ku(e,t,r){!t.implemented||e.length===0||e.some(n=>Le(n))||r({message:"Test has zero assertion steps \u2014 cannot verify expectedOutcome. Add assert.* steps.",rule:"no-assertions",step:void 0})}function Su(e,t,r){if(!t.implemented||e.length<=3)return;let n=e.filter(i=>Le(i)).length;if(n===0)return;let o=n/e.length;if(o<.15){let i=Math.round(o*100);r({message:`Only ${String(n)}/${String(e.length)} steps are assertions (${String(i)}%) \u2014 add more verification between actions`,rule:"low-assertion-ratio",step:void 0})}}function Gr(e){if(!("locator"in e)||e.locator==null)return;let t=e.locator;return t.by==="role"?`role:${t.role}:${t.name??""}`:`testId:${t.value}`}function Ru(e,t,r){e.forEach((n,o)=>{if(n.type!=="click")return;let i=Gr(n);if(i==null)return;let s=e.slice(o+1,o+4);s.find(c=>c.type==="assertVisible"&&Gr(c)===i)==null||s.some(c=>vu(c)||Le(c)&&Gr(c)!==i)||r({message:`click "${n.label??n.id}" is followed only by assert.visible on the same locator \u2014 verifies nothing about the click's effect`,rule:"tautological-post-click-assert",step:n.label??n.id})})}var Pu=new Set(["the","is","a","an","and","or","of","to","in","on","at","for","that","this","with","be","are","was","were","it","its","as","by","from","after","before","should","will","can","still","but","not","no","so","if","then","than","user","users","page","view","shows","show","see","click","clicks","clicked","clickable","visible","appears","appear","displayed","stays","remains"]);function Kr(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=3&&!Pu.has(t))}function xu(e){let t=e.label==null?[]:Kr(e.label);if(!("locator"in e)||e.locator==null)return t;let r=e.locator,n=r.by==="role"?r.name??"":r.value;return[...t,...Kr(n)]}function Cu(e,t,r){if(!t.implemented||e.length===0)return;let n=new Set(Kr(t.expectedOutcome));if(n.size===0)return;let o=e.filter(s=>Le(s));if(o.length===0)return;o.some(s=>xu(s).some(a=>n.has(a)))||r({message:`No assertion references any keyword from expectedOutcome (${[...n].join(", ")}) \u2014 the outcome may not actually be verified`,rule:"expected-outcome-keyword-coverage",step:void 0})}var Eu=/save|submit|create|delete|remove|send|invite|update|confirm|publish|apply|pay|subscribe|upgrade|cancel|archive|rename/i;function Co(e){if(e.type==="upload")return!0;if(e.type!=="click")return!1;let t=e.locator,r=t.by==="role"?t.name??"":t.value;return Eu.test(r)}function Au(e,t,r){!t.implemented||t.spec.uiOnly===!0||e.forEach((n,o)=>{if(!Co(n)||"uiOnly"in n&&n.uiOnly===!0)return;let i=e.slice(o+1),s=i.findIndex(p=>Co(p)),a=s===-1?i.length:s;i.slice(0,a).some(p=>p.type==="assertObserver")||r({message:`"${n.label??n.id}" looks like it mutates backend state but no assert.backend(...) observer verifies it \u2014 the test can pass while the server is broken. You need to add an observer that checks the persisted result (see .ripplo/observers/ for examples). Only if this action truly does NOT change any server state (pure client-side interaction, presentation toggle, etc.) should you fall back to marking the step { uiOnly: true } to silence this rule.`,rule:"mutation-without-observer-coverage",step:n.label??n.id})})}function Iu(e,t,r){Object.keys(t.spec.variables??{}).length!==0&&e.forEach(o=>{if(o.type!=="assertObserver")return;let i=Object.entries(o.params);i.length===0||i.some(([,a])=>Eo(a)&&Ao(a.value))||r({message:`assert.backend "${o.label??o.id}" passes only hardcoded params while the test defines precondition variables \u2014 observer assertions should reference {{namespace.key}} so they match the actual precondition data`,rule:"observer-params-reference-variables",step:o.label??o.id})})}function ju(e,t,r){let n=new Set(Object.keys(t.spec.variables??{})),o=/\{\{([^{}]+?)\}\}/g;e.forEach(i=>{let a=[...JSON.stringify(i).matchAll(o)],l=[...new Set(a.map(m=>m[1]).filter(m=>m!=null&&!n.has(m)))];if(l.length===0)return;let c=l.map(m=>`{{${m}}}`).join(", "),p=[...new Set(l.map(m=>m.split(".")[0]??m))].join(", ");r({message:`"${i.label??i.id}" contains literal template string(s) ${c} \u2014 destructure the proxy in .steps(({ ${p} }) => \u2026) and pass the proxy value (e.g. \`${l[0]??""}\`) directly. Writing the template as a string bypasses type-checking and silently accepts typos.`,rule:"no-literal-template-strings",step:i.label??i.id})})}var Tu=[du,uu,ju,pu,mu,fu,gu,yu,hu,ku,Su,Ru,Cu,Au,Iu];import rp from"picomatch";import{execFileSync as $u,spawnSync as Nu}from"child_process";function q(e,t){return $u("git",[...e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}function Io(e,t){let r=Nu("git",["show",e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(r.status===0)return r.stdout;if(r.status===128)return null;throw new Error(`git show ${e} failed (${String(r.status)}): ${r.stderr}`)}import h from"typescript";import*as jo from"remeda";var To=[["onClick","click"],["onContextMenu","click"],["onKeyDown","click"],["onKeyPress","click"],["onKeyUp","click"],["onSelect","click"],["onOpenChange","click"],["onPress","click"],["onActivate","click"],["onToggle","click"],["onOpen","click"],["onClose","click"],["onDismiss","click"],["onConfirm","click"],["onCancel","click"],["onApply","click"],["onClear","click"],["onSubmit","submit"],["onReset","submit"],["onDrop","drag"],["onDragEnd","drag"],["onDragEnter","drag"],["onDragLeave","drag"],["onDragOver","drag"],["onDragStart","drag"],["onValueChange","select"],["onSelectionChange","select"],["onChange","input"],["onCheckedChange","input"],["onInput","input"]],Ou=new Map([["button","click"],["link","navigate"],["textbox","input"],["searchbox","input"],["combobox","select"],["listbox","select"]]),Du=[[/(?:^|[a-z])Button$/,"click"],[/(?:^|[a-z])(?:Link|NavLink|Anchor)$/,"navigate"],[/(?:^|[a-z])(?:Textarea|TextArea|Input|Field|SearchBox)$/,"input"],[/(?:^|[a-z])(?:Select|Combobox|ComboBox|Dropdown)$/,"select"],[/(?:^|[a-z])Form$/,"submit"]];function Lt({filePath:e,source:t}){let r=h.createSourceFile(e,t,h.ScriptTarget.Latest,!0,h.ScriptKind.TSX);return r.statements.flatMap(n=>Lu({filePath:e,sf:r,stmt:n}))}function Lu({filePath:e,sf:t,stmt:r}){let n=Uu(r);if(n==null||_u(n))return[];let o=$o(r,t).map(i=>({id:`${e}#${n}.${i.kind}[${i.label}]`,line:i.line}));return jo.uniqueBy(o,i=>i.id)}function _u(e){return e.endsWith("Fragment")||e.endsWith("Skeleton")||/^use[A-Z]/.test(e)||/^[A-Z][A-Z0-9_]*$/.test(e)}function Uu(e){if(h.isExportAssignment(e))return Vu(e.expression);if(!Fu(e))return null;if(h.isFunctionDeclaration(e)||h.isClassDeclaration(e))return e.name?.text??null;if(h.isVariableStatement(e)){let t=e.declarationList.declarations[0];return t!=null&&h.isIdentifier(t.name)?t.name.text:null}return null}function Vu(e){return h.isIdentifier(e)?e.text:(h.isFunctionExpression(e)||h.isClassExpression(e))&&e.name!=null?e.name.text:"default"}function Fu(e){if(!h.canHaveModifiers(e))return!1;let t=h.getModifiers(e);return t!=null&&t.some(r=>r.kind===h.SyntaxKind.ExportKeyword)}function $o(e,t){let r=Hu(e,t),n=e.getChildren(t).flatMap(o=>$o(o,t));return r==null?n:[r,...n]}function Hu(e,t){let r=Bu(e);if(r==null)return null;let n=Wu(r);if(n==null)return null;let o=Ku(r,n);return o==null?null:{kind:n,label:o,line:tp(t,e.getStart(t))}}function Bu(e){return h.isJsxSelfClosingElement(e)&&h.isIdentifier(e.tagName)?{attrs:e.attributes,children:[],tag:e.tagName.text}:h.isJsxElement(e)&&h.isIdentifier(e.openingElement.tagName)?{attrs:e.openingElement.attributes,children:e.children,tag:e.openingElement.tagName.text}:null}function Wu({attrs:e,tag:t}){let r=le(e,"role");return r!=null?Ou.get(r)??null:qu(t,e)??zu(t)??Gu(e)}var Mu=new Map([["button",()=>"click"],["a",e=>le(e,"href")==null?null:"navigate"],["input",e=>le(e,"type")==="file"?"upload":"input"],["textarea",()=>"input"],["select",()=>"select"],["form",()=>"submit"]]);function qu(e,t){return Mu.get(e)?.(t)??null}function zu(e){return/^[A-Z]/.test(e)?Du.find(([t])=>t.test(e))?.[1]??null:null}function Gu(e){return To.find(([t])=>Yu(e,t))?.[1]??null}function Ku({attrs:e,children:t,tag:r},n){return n==="navigate"?le(e,"href")??le(e,"to"):le(e,"aria-label")??le(e,"label")??le(e,"title")??le(e,"name")??le(e,"placeholder")??(Ju(r)?void 0:ep(t))??Qu(e,n)}function Ju(e){return e==="input"||e==="textarea"||e==="select"}function Qu(e,t){let r=To.find(([,o])=>o===t)?.[0];if(r==null)return;let n=Xu(e,r);if(n!=null){if(h.isIdentifier(n))return n.text;if(h.isArrowFunction(n)||h.isFunctionExpression(n))return No(n.body)}}function No(e){if(h.isCallExpression(e)){let t=e.expression;return h.isIdentifier(t)?t.text:h.isPropertyAccessExpression(t)?t.name.text:void 0}return h.forEachChild(e,No)}function Yu(e,t){return e.properties.some(r=>h.isJsxAttribute(r)&&h.isIdentifier(r.name)&&r.name.text===t)}function Oo(e,t){return e.properties.find(r=>h.isJsxAttribute(r)&&h.isIdentifier(r.name)&&r.name.text===t)}function le(e,t){let r=Oo(e,t);return r==null?void 0:Zu(r.initializer)}function Xu(e,t){let r=Oo(e,t);if(!(r?.initializer==null||!h.isJsxExpression(r.initializer)))return r.initializer.expression}function Zu(e){if(e==null)return"";if(h.isStringLiteral(e))return e.text;if(h.isJsxExpression(e))return Lo(e.expression)}function ep(e){let t=e.flatMap(r=>Do(r)).join(" ").trim();return t.length===0?void 0:t}function Do(e){if(h.isJsxText(e)){let t=e.text.trim();return t.length===0?[]:[t]}if(h.isJsxExpression(e)){let t=Lo(e.expression);return t==null?[]:[t]}return h.isJsxElement(e)?e.children.flatMap(t=>Do(t)):[]}function Lo(e){if(e!=null){if(h.isStringLiteral(e)||h.isNoSubstitutionTemplateLiteral(e))return e.text;if(h.isCallExpression(e)&&e.arguments.length===1){let t=e.arguments[0];if(t!=null&&(h.isStringLiteral(t)||h.isNoSubstitutionTemplateLiteral(t)))return t.text}}}function tp(e,t){return e.getLineAndCharacterOfPosition(t).line+1}var np=_t.join(".ripplo","coverage.d.ts");function _e({cwd:e}){op({cwd:e,ignorePaths:Re})}function op({cwd:e,ignorePaths:t}){let r=Ue({cwd:e,ignorePaths:t});ap({content:sp(r),cwd:e})}function Ue({cwd:e,ignorePaths:t}){let n=ip({cwd:e,ignorePaths:t}).flatMap(o=>Jr({cwd:e,file:o}));return[...new Set(n)].sort((o,i)=>o.localeCompare(i))}function ip({cwd:e,ignorePaths:t}){let r=q(["ls-files","--cached","--others","--exclude-standard","-z"],e),n=rp([...t]);return r.split("\0").filter(o=>o.length>0&&/\.(tsx|jsx)$/.test(o)).filter(o=>!n(o)).filter(o=>ot.existsSync(_t.join(e,o)))}function Jr({cwd:e,file:t}){let r=ot.readFileSync(_t.join(e,t),"utf8");return Lt({filePath:t,source:r}).map(n=>n.id)}function sp(e){let t=`// GENERATED \u2014 do not edit
|
|
141
141
|
import "@ripplo/testing";
|
|
142
142
|
|
|
143
143
|
declare module "@ripplo/testing" {
|
|
@@ -148,14 +148,14 @@ declare module "@ripplo/testing" {
|
|
|
148
148
|
`:`${t}${r}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
`}function ap({content:e,cwd:t}){let r=_t.join(t,np);ot.existsSync(r)&&ot.readFileSync(r,"utf8")===e||ot.writeFileSync(r,e)}import _o from"path";import{createJiti as lp}from"jiti";var cp=["getObservers","getPreconditions","getTests","getUnimplemented"];function
|
|
151
|
+
`}function ap({content:e,cwd:t}){let r=_t.join(t,np);ot.existsSync(r)&&ot.readFileSync(r,"utf8")===e||ot.writeFileSync(r,e)}import _o from"path";import{createJiti as lp}from"jiti";var cp=["getObservers","getPreconditions","getTests","getUnimplemented"];function dp(e){return e==null||typeof e!="object"?!1:cp.every(t=>typeof Reflect.get(e,t)=="function")}function up(e){return e===null?"null":Array.isArray(e)?"array":typeof e}async function C(e){let t=_o.join(e,".ripplo","index.ts"),r=_o.join(e,".ripplo");try{let o=await lp(import.meta.url,{moduleCache:!1,sourceMaps:!0}).import(t),i=o!=null&&typeof o=="object"&&"default"in o?Reflect.get(o,"default"):o;if(!dp(i))return{error:`${t} must default-export a RipploBuilder (got ${up(i)})`,ok:!1};let s=Dt(i);return{builder:i,ok:!0,result:s}}catch(n){return{error:mp(n,r),ok:!1}}}var pp=/\(?([^\s()]{1,500}\.ts):(\d{1,10}):(\d{1,10})\)?$/;function mp(e,t){if(!(e instanceof Error))return String(e);let r=fp(e.stack,t);return r==null?e.message:`${r} \u2014 ${e.message}`}function fp(e,t){if(e==null)return;let n=e.split(`
|
|
152
152
|
`).map(a=>pp.exec(a)).find(a=>a!=null&&a[1]!=null&&a[2]!=null&&a[3]!=null&&a[1].startsWith(t));if(n==null)return;let[,o,i,s]=n;return`${o??""}:${i??""}:${s??""}`}function w(e,t){return t==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${t}.`}function Uo(e){return e.length===1?w(e[0]):`REQUIRED before proceeding: load ${e.map(r=>`\`/ripplo:${r}\``).join(" AND ")} skills (load every one \u2014 each carries rules the others don't).`}async function Vo(e){let t=process.cwd(),r=await C(t);if(r.ok||(process.stderr.write(`Compilation failed: ${r.error}
|
|
153
153
|
`),process.stderr.write(`${w("create","DSL authoring + lint rules")}
|
|
154
154
|
`),process.exit(1)),e.check){let n=await Nt({cwd:t}),o=Ot({compiled:r.result,existing:n});if(o==="match"){process.stdout.write(`${se} is up to date
|
|
155
155
|
`);return}let i=o==="missing"?"missing":"out of date";process.stderr.write(`${se} is ${i} \u2014 run \`ripplo compile\` and commit the result
|
|
156
156
|
`),process.stderr.write(`${w("setup")}
|
|
157
157
|
`),process.exit(1)}await ae({cwd:t,result:r.result}),_e({cwd:t}),process.stdout.write(`wrote ${se}
|
|
158
|
-
`)}import pe from"process";import gp from"fs";import yp from"path";import hp from"picomatch";function Fo({compileResult:e,cwd:t,ignorePaths:r}){let n=new Set(Ue({cwd:t,ignorePaths:r})),o=Wo(e),i=wp({cwd:t,ignorePaths:r});return Bo({acknowledged:o,allStatements:n,unacked:i})}function Ho({compileResult:e,cwd:t,ignorePaths:r}){let n=new Set(Ue({cwd:t,ignorePaths:r})),o=Wo(e);return Bo({acknowledged:o,allStatements:n,unacked:n})}function Bo({acknowledged:e,allStatements:t,unacked:r}){let n=[...r].filter(i=>!e.has(i)).map(i=>({id:i,kind:"unacknowledged"})),o=[...e].filter(i=>!t.has(i)).map(i=>({id:i,kind:"stale"}));return[...n,...o]}function Wo(e){return new Set(e.tests.flatMap(t=>t.coverage))}function wp({cwd:e,ignorePaths:t}){let r=bp({cwd:e,ignorePaths:t}),n=new Set(r.flatMap(i=>vp({cwd:e,file:i}))),o=new Set(r.flatMap(i=>kp({cwd:e,file:i})?Jr({cwd:e,file:i}):[]));return new Set([...o].filter(i=>!n.has(i)))}function bp({cwd:e,ignorePaths:t}){let r=q(["diff","--name-only","HEAD","-z"],e),n=q(["ls-files","--others","--exclude-standard","-z"],e),o=hp([...t]);return[...new Set([...r.split("\0"),...n.split("\0")])].filter(i=>i.length>0&&/\.(tsx|jsx)$/.test(i)).filter(i=>!o(i))}function vp({cwd:e,file:t}){let r=
|
|
158
|
+
`)}import pe from"process";import gp from"fs";import yp from"path";import hp from"picomatch";function Fo({compileResult:e,cwd:t,ignorePaths:r}){let n=new Set(Ue({cwd:t,ignorePaths:r})),o=Wo(e),i=wp({cwd:t,ignorePaths:r});return Bo({acknowledged:o,allStatements:n,unacked:i})}function Ho({compileResult:e,cwd:t,ignorePaths:r}){let n=new Set(Ue({cwd:t,ignorePaths:r})),o=Wo(e);return Bo({acknowledged:o,allStatements:n,unacked:n})}function Bo({acknowledged:e,allStatements:t,unacked:r}){let n=[...r].filter(i=>!e.has(i)).map(i=>({id:i,kind:"unacknowledged"})),o=[...e].filter(i=>!t.has(i)).map(i=>({id:i,kind:"stale"}));return[...n,...o]}function Wo(e){return new Set(e.tests.flatMap(t=>t.coverage))}function wp({cwd:e,ignorePaths:t}){let r=bp({cwd:e,ignorePaths:t}),n=new Set(r.flatMap(i=>vp({cwd:e,file:i}))),o=new Set(r.flatMap(i=>kp({cwd:e,file:i})?Jr({cwd:e,file:i}):[]));return new Set([...o].filter(i=>!n.has(i)))}function bp({cwd:e,ignorePaths:t}){let r=q(["diff","--name-only","HEAD","-z"],e),n=q(["ls-files","--others","--exclude-standard","-z"],e),o=hp([...t]);return[...new Set([...r.split("\0"),...n.split("\0")])].filter(i=>i.length>0&&/\.(tsx|jsx)$/.test(i)).filter(i=>!o(i))}function vp({cwd:e,file:t}){let r=Io(`HEAD:${t}`,e);return r==null?[]:Lt({filePath:t,source:r}).map(n=>n.id)}function kp({cwd:e,file:t}){return gp.existsSync(yp.join(e,t))}async function Mo(){let e=pe.cwd(),t=await C(e);t.ok||(pe.stderr.write(`Compilation failed: ${t.error}
|
|
159
159
|
`),pe.exit(1));let r=Ue({cwd:e,ignorePaths:Re}),n=Ho({compileResult:t.result,cwd:e,ignorePaths:Re}),o=n.filter(a=>a.kind==="unacknowledged"),i=n.filter(a=>a.kind==="stale"),s=r.length-o.length;pe.stdout.write(`Coverage: ${String(s)}/${String(r.length)} statements acknowledged
|
|
160
160
|
`),o.length>0&&(pe.stdout.write(`
|
|
161
161
|
Unacknowledged (${String(o.length)}):
|
|
@@ -163,7 +163,7 @@ Unacknowledged (${String(o.length)}):
|
|
|
163
163
|
`))),i.length>0&&(pe.stdout.write(`
|
|
164
164
|
Stale claims (${String(i.length)}):
|
|
165
165
|
`),i.forEach(a=>pe.stdout.write(` ${a.id}
|
|
166
|
-
`))),n.length>0&&pe.exit(1)}import{graphql as Rp}from"gql.tada";import qo from"fs";import Qr from"path";function zo(e){let t=qo.realpathSync(e),r=t,n=Qr.dirname(r);for(;n!==r;){if(qo.existsSync(Qr.join(r,".git")))return r;r=n,n=Qr.dirname(r)}return t}function
|
|
166
|
+
`))),n.length>0&&pe.exit(1)}import{graphql as Rp}from"gql.tada";import qo from"fs";import Qr from"path";function zo(e){let t=qo.realpathSync(e),r=t,n=Qr.dirname(r);for(;n!==r;){if(qo.existsSync(Qr.join(r,".git")))return r;r=n,n=Qr.dirname(r)}return t}function D(e){let t=Zt(e),r=Ae(),n=Z();if(n==null)throw new Error("ripplo: not authenticated. Run `ripplo auth login`.");return{appUrl:r.appUrl,cwd:zo(e),engineUrl:r.engineUrl,projectId:lo()??t.projectId,ripploServerUrl:Q(),token:n,webhookSecret:r.webhookSecret}}import it from"fs";var Sp="dev.pid";function Go(e){return et(e,Sp)}function Ve(e){let t=Go(e);if(!it.existsSync(t))return!1;let r=it.readFileSync(t,"utf8").trim(),n=Number.parseInt(r,10);if(!Number.isFinite(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function Ko(e){Ze(e);let t=Go(e);it.writeFileSync(t,String(process.pid));let r=!1;return()=>{if(!r){r=!0;try{let n=it.readFileSync(t,"utf8").trim();Number.parseInt(n,10)===process.pid&&it.unlinkSync(t)}catch{}}}}var Pp=Rp(`
|
|
167
167
|
query DevSessionCheckHealth($projectId: String!, $cwd: String!) {
|
|
168
168
|
project(id: $projectId) {
|
|
169
169
|
id
|
|
@@ -172,7 +172,7 @@ Stale claims (${String(i.length)}):
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
`);function Jo(e){switch(e.status){case"active":return"\u2713 Dev session: ripplo watch is live for this directory";case"starting":return"! Dev session: `ripplo watch` is running locally but hasn't registered with the server yet. Wait a few seconds and re-run `npx ripplo doctor`. If it persists, check the watch process output for auth/network errors.";case"missing":return"\u2717 Dev session: no active ripplo watch. Start `npx ripplo watch` as a background process (separate from your app's dev server). Without it, `ripplo run` will refuse to dispatch and scope/coverage hooks won't arm."}}async function Qo(e){let t=Ve(e),r;try{r=
|
|
175
|
+
`);function Jo(e){switch(e.status){case"active":return"\u2713 Dev session: ripplo watch is live for this directory";case"starting":return"! Dev session: `ripplo watch` is running locally but hasn't registered with the server yet. Wait a few seconds and re-run `npx ripplo doctor`. If it persists, check the watch process output for auth/network errors.";case"missing":return"\u2717 Dev session: no active ripplo watch. Start `npx ripplo watch` as a background process (separate from your app's dev server). Without it, `ripplo run` will refuse to dispatch and scope/coverage hooks won't arm."}}async function Qo(e){let t=Ve(e),r;try{r=D(e)}catch{return{status:t?"starting":"missing",type:"dev-session"}}return(await y({config:r,document:Pp,variables:{cwd:r.cwd,projectId:r.projectId}}).catch(()=>null))?.project?.devSession!=null?{status:"active",type:"dev-session"}:{status:t?"starting":"missing",type:"dev-session"}}function Yo(e){switch(e.type){case"settings":return Ap(e);case"env-files":return Ip(e);case"token":return jp(e);case"dev-server":return Tp(e);case"dev-session":return Jo(e);case"preconditions":return Op(e);case"webhook-verification":return $p(e);case"preconditions-validation":return Dp(e);case"workflows":return Lp(e);case"browser":return Np(e);case"engine-endpoint":return e.reachable?`\u2713 Engine endpoint: ${e.url} is reachable`:`\u2717 Engine endpoint: ${e.url} is not reachable`;case"adapter-enabled":return xp(e);case"lockfile":return Cp(e);case"pre-commit-hook":return Ep(e)}}function xp(e){switch(e.status){case"enabled":return`\u2713 Adapter: enabled at ${e.url}`;case"disabled":return"\u2717 Adapter: disabled (handler returned 404). Set ENABLE_RIPPLO_TESTING=true in your app's env (e.g. apps/<app>/.env.local for Next.js) and restart the dev server.";case"bad-secret":return"\u2717 Adapter: webhook signature rejected. RIPPLO_WEBHOOK_SECRET seen by your dev server does not match the one in your env file.";case"unreachable":return`\u2717 Adapter: ${e.url} could not be reached for signed probe.`;case"no-secret":return"\u2717 Adapter: RIPPLO_WEBHOOK_SECRET is not set in your env file (declared in .ripplo/project.json)."}}function Cp(e){switch(e.status){case"match":return`\u2713 Lockfile: ${se} is up to date`;case"missing":return`\u2717 Lockfile: ${se} is missing \u2014 run \`ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${se} is out of date \u2014 run \`ripplo compile\` and commit it`}}function Ep(e){return e.installed?"\u2713 Pre-commit hook: .git/hooks/pre-commit runs `ripplo compile --check`":"! Pre-commit hook: .git/hooks/pre-commit does not run `ripplo compile --check` \u2014 see the setup skill for the snippet"}function Ap(e){return e.valid?"\u2713 Settings: Project configured":`\u2717 Settings: Missing fields: ${e.missingFields.join(", ")}`}function Ip(e){return e.missing.length===0?"\u2713 Env files: declared files present":`\u2717 Env files: declared in .ripplo/project.json but missing:
|
|
176
176
|
${e.missing.map(r=>` ${r}`).join(`
|
|
177
177
|
`)}
|
|
178
178
|
If you're in a git worktree, copy the env file from the main checkout (or symlink to a shared file outside the working tree).`}function jp(e){switch(e.status){case"valid":return`\u2713 Auth: Signed in as ${e.email??"unknown"}`;case"missing":return"\u2717 Auth: No token found. Run `ripplo` to authenticate.";case"invalid":return"\u2717 Auth: Saved token rejected by server. Run `ripplo auth login` to re-authenticate.";case"unreachable":return`! Auth: Could not reach ${Q()} to validate token.`}}function Tp(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Make sure your dev server is running.`}function $p(e){return e.rejectsUnsigned?"\u2713 Webhook verification: Unsigned requests are correctly rejected":"\u2717 Webhook verification: Endpoint accepted an unsigned request \u2014 webhook signature verification may be missing or misconfigured."}function Np(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run: npx playwright install chromium"}function Op(e){return e.count===0?"! Preconditions: None defined":e.configured?e.endpointReachable===void 0?`! Preconditions: ${String(e.count)} defined (could not verify endpoint)`:`\u2713 Preconditions: ${String(e.count)} defined, endpoint configured`:`\u2717 Preconditions: ${String(e.count)} defined but RIPPLO_ENGINE_URL is not set in your env file`}function Dp(e){if(!e.found)return"\u2717 State graph: DSL compilation failed";if(e.valid)return"\u2713 State graph: Valid";let t=e.errors.map(r=>` - ${r.path===""?"":r.path+": "}${r.message}`);return`\u2717 State graph: ${String(e.errorCount)} validation error${e.errorCount===1?"":"s"}
|
|
@@ -181,16 +181,16 @@ ${t.join(`
|
|
|
181
181
|
${t.join(`
|
|
182
182
|
`)}`}function _p(e){let t=e.errors.map(r=>" - "+(r.path===""?"":r.path+": ")+r.message);return" "+e.name+`:
|
|
183
183
|
`+t.join(`
|
|
184
|
-
`)}import Xr from"fs";import Wp from"path";import{chromium as Mp}from"playwright";import Up from"fs";import Vp from"path";async function Xo(e){let t=Vp.join(e,".ripplo","index.ts");if(!Up.existsSync(t))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let r=await C(e);if(!r.ok)return{appUrl:void 0,engineUrl:void 0,errors:[{message:r.error,path:".ripplo/"}],valid:!1,warnings:[]};try{let n=
|
|
184
|
+
`)}import Xr from"fs";import Wp from"path";import{chromium as Mp}from"playwright";import Up from"fs";import Vp from"path";async function Xo(e){let t=Vp.join(e,".ripplo","index.ts");if(!Up.existsSync(t))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let r=await C(e);if(!r.ok)return{appUrl:void 0,engineUrl:void 0,errors:[{message:r.error,path:".ripplo/"}],valid:!1,warnings:[]};try{let n=Ae();return{appUrl:n.appUrl,engineUrl:n.engineUrl,errors:[],valid:!0,warnings:[]}}catch(n){return{appUrl:void 0,engineUrl:void 0,errors:[{message:n instanceof Error?n.message:String(n),path:""}],valid:!1,warnings:[]}}}async function Yr(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`appUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}async function Zo({appUrl:e,engineUrl:t}){let r=t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`;try{return(await fetch(`${r}/execute-preconditions`,{body:JSON.stringify({preconditions:[]}),headers:{"Content-Type":"application/json"},method:"PUT",signal:AbortSignal.timeout(5e3)})).ok?"Engine endpoint accepted an unsigned request \u2014 webhook signature verification may be missing.":void 0}catch{return}}import{graphql as Fp}from"gql.tada";var Hp=Fp(`
|
|
185
185
|
query DoctorAuthViewer {
|
|
186
186
|
currentUser {
|
|
187
187
|
name
|
|
188
188
|
email
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
`),Bp="Failed to connect to Ripplo server";async function ei({serverUrl:e,token:t}){try{let r=await
|
|
191
|
+
`),Bp="Failed to connect to Ripplo server";async function ei({serverUrl:e,token:t}){try{let r=await y({config:ke({serverUrl:e,token:t}),document:Hp,variables:void 0});return r.currentUser==null?{kind:"invalid"}:{email:r.currentUser.email,kind:"valid"}}catch(r){return(r instanceof Error?r.message:String(r)).startsWith(Bp)?{kind:"unreachable"}:{kind:"invalid"}}}function ti(e){switch(e.type){case"settings":return!e.valid;case"env-files":return e.missing.length>0;case"token":return e.status==="missing"||e.status==="invalid";case"dev-server":return!e.reachable;case"dev-session":return e.status!=="active";case"preconditions":return e.count>0&&!e.configured;case"engine-endpoint":return!e.reachable;case"adapter-enabled":return e.status!=="enabled";case"webhook-verification":return!e.rejectsUnsigned;case"preconditions-validation":return!e.valid;case"workflows":return e.invalidNames.length>0;case"browser":return!e.installed;case"lockfile":return e.status!=="match";case"pre-commit-hook":return!e.installed}}async function ri(e){let t=await Gp(e),r={missing:rr(e),type:"env-files"},n=await Kp(),o=Jp(),i=await C(e),s=Qp(i),a=Zp(i),l=await qp(e,i),c=zp(e),p=await em(t,i);return[t,r,n,...p,s,a,l,c,o]}async function qp(e,t){if(!t.ok)return{status:"missing",type:"lockfile"};let r=await Nt({cwd:e});return{status:Ot({compiled:t.result,existing:r}),type:"lockfile"}}function zp(e){let t=Wp.join(e,".git","hooks","pre-commit");return Xr.existsSync(t)?{installed:Xr.readFileSync(t,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function Gp(e){let t=await Xo(e);return t.valid?{missingFields:[],type:"settings",valid:!0}:{missingFields:t.errors.map(n=>n.path).filter(n=>n.length>0),type:"settings",valid:!1}}async function Kp(){let e=Z();if(e==null||e.length===0)return{email:void 0,status:"missing",type:"token"};let t=await ei({serverUrl:Q(),token:e});return t.kind==="valid"?{email:t.email,status:"valid",type:"token"}:{email:void 0,status:t.kind,type:"token"}}function Jp(){let e=Mp.executablePath();return{installed:Xr.existsSync(e),type:"browser"}}function Qp(e){if(!e.ok)return{errorCount:1,errors:[{message:e.error,path:""}],found:!1,type:"preconditions-validation",valid:!1};let t=Yp(e.result.preconditions,e.result.tests);return{errorCount:t.length,errors:t,found:!0,type:"preconditions-validation",valid:t.length===0}}function Yp(e,t){let r=[],n=new Set(Object.keys(e));return Object.entries(e).forEach(([o,i])=>{(i.depends??[]).forEach(s=>{n.has(s)||r.push({message:`Depends on non-existent precondition "${s}"`,path:`preconditions.${o}.depends`})})}),t.forEach(o=>{Object.entries(o.requiresKeys).forEach(([i,s])=>{n.has(s)||r.push({message:`Test "${o.slug}" requires non-existent precondition "${s}" (as ${i})`,path:`tests.${o.slug}.requiresKeys.${i}`})})}),Xp(e).forEach(o=>{r.push({message:o,path:"preconditions"})}),r}function Xp(e){let t=new Set,r=new Set,n=[];function o(i){if(r.has(i)){n.push(`Precondition "${i}" has a circular dependency`);return}t.has(i)||(t.add(i),r.add(i),(e[i]?.depends??[]).forEach(s=>{o(s)}),r.delete(i))}return Object.keys(e).forEach(i=>{o(i)}),n}function Zp(e){if(!e.ok)return{invalidNames:[],invalidWorkflows:[],total:0,type:"workflows",valid:0};let t=e.result.tests.length;return{invalidNames:[],invalidWorkflows:[],total:t,type:"workflows",valid:t}}async function em(e,t){if(!e.valid||!t.ok)return[];let r;try{let a=Ae();r={appUrl:a.appUrl,engineUrl:a.engineUrl,webhookSecret:a.webhookSecret}}catch{return[]}let n=[],o=await Yr(r.appUrl)==null;n.push({appUrl:r.appUrl,reachable:o,type:"dev-server"});let i=await Qo(process.cwd());n.push(i);let s=await tm(r,t);return n.push(...s),n}async function tm(e,t){let r=t.ok?Object.keys(t.result.preconditions).length:0,n=e.engineUrl.length>0,o={configured:n,count:r,endpointReachable:void 0,type:"preconditions"};if(r===0||!n)return[o];let i=nm(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Yr(i)==null,a=[];if(a.push({configured:!0,count:r,endpointReachable:s,type:"preconditions"}),ni(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await Zo({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let c=await rm({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:c,type:"adapter-enabled",url:i}),a}async function rm({engineUrl:e,webhookSecret:t}){if(t.length===0)return"no-secret";let r=JSON.stringify({preconditions:[]});try{let n=await fetch(`${e}/execute-preconditions`,{body:r,headers:{"Content-Type":"application/json",...ve({body:r,secret:t})},method:"PUT",signal:AbortSignal.timeout(5e3)});return n.status===404?"disabled":n.status===401||n.status===403?"bad-secret":"enabled"}catch{return"unreachable"}}function ni(e){return e.startsWith("http://")||e.startsWith("https://")}function nm(e,t){return ni(t)?t:`${e}${t}`}async function oi(){let e=process.cwd(),t=await ri(e),r=t.map(o=>Yo(o));process.stdout.write(r.join(`
|
|
192
192
|
`)+`
|
|
193
|
-
`);let n=t.some(o=>ti(o));process.exit(n?1:0)}import{graphql as Vt,readFragment as
|
|
193
|
+
`);let n=t.some(o=>ti(o));process.exit(n?1:0)}import{graphql as Vt,readFragment as um}from"gql.tada";import im from"crypto";import{graphql as sm}from"gql.tada";import Zr from"fs";import en from"path";function Ut(e){try{let t=en.join(om(e),"HEAD"),r=Zr.readFileSync(t,"utf8").trim(),n="ref: refs/heads/";return r.startsWith(n)?r.slice(n.length):r.length===0?void 0:r.slice(0,7)}catch{return}}function om(e){let t=en.join(e,".git");if(Zr.statSync(t).isDirectory())return t;let n=Zr.readFileSync(t,"utf8").trim(),o="gitdir:";if(!n.startsWith(o))throw new Error(`unrecognized .git file at ${t}`);let i=n.slice(o.length).trim();if(i.length===0)throw new Error(`empty gitdir pointer at ${t}`);return en.resolve(e,i)}var am=sm(`
|
|
194
194
|
mutation SyncDevSession(
|
|
195
195
|
$projectId: String!
|
|
196
196
|
$cwd: String!
|
|
@@ -208,7 +208,7 @@ ${t.join(`
|
|
|
208
208
|
id
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
`);async function st(e){let t=lm(e.compiled);return
|
|
211
|
+
`);async function st(e){let t=lm(e.compiled);return dm({config:e.config,cwd:e.cwd,payload:t})}async function Ce(e,t){let r=await C(e);if(!r.ok)throw new Error(`DSL compilation failed: ${r.error}`);let n=await st({compiled:r.result,config:t,cwd:e});return{compiled:r.result,devSessionId:n.devSessionId}}function lm(e){return{preconditions:Object.entries(e.preconditions).map(([t,r])=>({depends:[...r.depends??[]],description:r.description,name:t,returns:[...r.returns??[]]})),workflows:e.tests.map(t=>({expectedOutcome:t.expectedOutcome,name:t.name,preconditions:[...t.preconditions],requiresKeys:Object.entries(t.requiresKeys).map(([r,n])=>({namespace:r,preconditionName:n})),slug:t.slug,spec:t.implemented?JSON.stringify(t.spec):null}))}}function cm(e){return im.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function dm({config:e,cwd:t,payload:r}){let n=cm(r),o=Ut(t),i=await y({config:e,document:am,variables:{branch:o??null,cwd:t,preconditions:r.preconditions.map(s=>({depends:[...s.depends],description:s.description,name:s.name,returns:[...s.returns]})),projectId:e.projectId,workflows:r.workflows.map(s=>({expectedOutcome:s.expectedOutcome,name:s.name,preconditions:[...s.preconditions],requiresKeys:s.requiresKeys.map(a=>({namespace:a.namespace,preconditionName:a.preconditionName})),slug:s.slug,spec:s.spec??null}))}});if(i.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:i.syncDevSession.id,hash:n}}import ii from"figures";var at={cross:ii.cross,tick:ii.tick};var ai=Vt(`
|
|
212
212
|
fragment WorkflowIdMCP on Workflow {
|
|
213
213
|
id
|
|
214
214
|
slug
|
|
@@ -226,8 +226,8 @@ ${t.join(`
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
`,[ai]),mm=Vt(`
|
|
229
|
-
mutation CreateRunMCP($workflowId: String
|
|
230
|
-
createRun(workflowId: $workflowId
|
|
229
|
+
mutation CreateRunMCP($workflowId: String!) {
|
|
230
|
+
createRun(workflowId: $workflowId) {
|
|
231
231
|
id
|
|
232
232
|
status
|
|
233
233
|
}
|
|
@@ -237,24 +237,20 @@ ${t.join(`
|
|
|
237
237
|
run(id: $id) {
|
|
238
238
|
id
|
|
239
239
|
status
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
duration
|
|
241
|
+
passCount
|
|
242
|
+
failCount
|
|
243
|
+
warnCount
|
|
244
|
+
summary
|
|
245
|
+
traceEntries {
|
|
246
|
+
title
|
|
242
247
|
status
|
|
248
|
+
detail
|
|
243
249
|
duration
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
warnCount
|
|
247
|
-
summary
|
|
248
|
-
traceEntries {
|
|
249
|
-
title
|
|
250
|
+
assertions {
|
|
251
|
+
description
|
|
250
252
|
status
|
|
251
253
|
detail
|
|
252
|
-
duration
|
|
253
|
-
assertions {
|
|
254
|
-
description
|
|
255
|
-
status
|
|
256
|
-
detail
|
|
257
|
-
}
|
|
258
254
|
}
|
|
259
255
|
}
|
|
260
256
|
}
|
|
@@ -270,9 +266,9 @@ ${s.summary}`).join(`
|
|
|
270
266
|
|
|
271
267
|
---
|
|
272
268
|
|
|
273
|
-
`);return{results:o,summary:i}}async function gm({config:e,ids:t}){let r=await Ce(e.cwd,e),n=await
|
|
269
|
+
`);return{results:o,summary:i}}async function gm({config:e,ids:t}){let r=await Ce(e.cwd,e),n=await y({config:e,document:pm,variables:{cwd:e.cwd,projectId:e.projectId}});if(n.project==null)throw new Error("Project not found");if(n.project.devSession==null)throw new Error("No active dev session. Start one by running `ripplo` (or `npx ripplo`) in your terminal, then try again.");let o=(n.project.workflows??[]).map(s=>um(ai,s));if(t.length===0)return o.map(s=>({id:s.slug,workflowId:s.id}));let i=r.compiled.tests.map(s=>s.slug);return t.map(s=>{let a=o.find(l=>l.slug===s);if(a==null)throw new Error(ym({compiledSlugs:i,slug:s}));return{id:s,workflowId:a.id}})}function ym({compiledSlugs:e,slug:t}){if(e.includes(t))return`Test "${t}" was synced from .ripplo/ but the server didn't return it. This is likely a server-state bug \u2014 check the server logs for the SyncDevSession mutation.`;let r=hm({compiledSlugs:e,limit:3,slug:t}),n=r.length>0?`
|
|
274
270
|
Did you mean: ${r.join(", ")}?`:"";return`Test "${t}" is not registered in this dev session.${n}
|
|
275
|
-
Tests must be exported from .ripplo/tests/index.ts. (ripplo run already syncs on demand \u2014 restarting the dev server will not help.)`}function hm({compiledSlugs:e,limit:t,slug:r}){let n=new Set(r.split("-"));return e.map(i=>({candidate:i,score:wm(n,i)})).filter(i=>i.score>0).toSorted((i,s)=>s.score-i.score).slice(0,t).map(i=>i.candidate)}function wm(e,t){return t.split("-").filter(r=>e.has(r)).length}function bm({config:e,id:t,runId:r}){let n=e.ripploServerUrl.replace(/:3000\b/,":3001"),o=new URL(n.endsWith("/")?n:`${n}/`);return new URL(`projects/${e.projectId}/workflows/${t}/runs/${r}`,o).toString()}async function vm({config:e,workflowId:t}){let r=await
|
|
271
|
+
Tests must be exported from .ripplo/tests/index.ts. (ripplo run already syncs on demand \u2014 restarting the dev server will not help.)`}function hm({compiledSlugs:e,limit:t,slug:r}){let n=new Set(r.split("-"));return e.map(i=>({candidate:i,score:wm(n,i)})).filter(i=>i.score>0).toSorted((i,s)=>s.score-i.score).slice(0,t).map(i=>i.candidate)}function wm(e,t){return t.split("-").filter(r=>e.has(r)).length}function bm({config:e,id:t,runId:r}){let n=e.ripploServerUrl.replace(/:3000\b/,":3001"),o=new URL(n.endsWith("/")?n:`${n}/`);return new URL(`projects/${e.projectId}/workflows/${t}/runs/${r}`,o).toString()}async function vm({config:e,workflowId:t}){let r=await y({config:e,document:mm,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(r.createRun==null)throw new Error("Failed to create run");return r.createRun.id}var km=2e3,si=150;async function Sm({config:e,runId:t}){let r=0;for(;r<si;){await Pm(km),r+=1;let o=(await y({config:e,document:fm,variables:{id:t}})).run;if(o==null)throw new Error(`Run ${t} not found`);if(!(o.status==="pending"||o.status==="running"))return Rm({run:o,runId:t})}return`Run ${t} timed out after polling ${String(si)} times.`}function Rm({run:e,runId:t}){let r=[`Run ${t}: ${e.status.toUpperCase()}`];return r.push(` ${e.status}: ${String(e.passCount)} passed, ${String(e.failCount)} failed (${String(e.duration??0)}ms)`),e.summary!=null&&r.push(` Summary: ${e.summary}`),e.traceEntries.forEach(n=>{let o=n.status==="passed"?at.tick:at.cross,i=n.detail==null?"":` \u2014 ${n.detail}`;r.push(` ${o} ${n.title} (${String(n.duration)}ms)${i}`),n.assertions.forEach(s=>{let a=s.status==="passed"?at.tick:at.cross,l=s.detail==null?"":` \u2014 ${s.detail}`;r.push(` ${a} ${s.description}${l}`)})}),r.join(`
|
|
276
272
|
`)}function Pm(e){return new Promise(t=>{setTimeout(t,e)})}import{graphql as xm}from"gql.tada";var Cm=xm(`
|
|
277
273
|
query DevSessionCheckPreflight($projectId: String!, $cwd: String!) {
|
|
278
274
|
project(id: $projectId) {
|
|
@@ -282,27 +278,27 @@ Tests must be exported from .ripplo/tests/index.ts. (ripplo run already syncs on
|
|
|
282
278
|
}
|
|
283
279
|
}
|
|
284
280
|
}
|
|
285
|
-
`);function me(){try{return
|
|
281
|
+
`);function me(){try{return D(process.cwd())}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`${t}
|
|
286
282
|
`),process.stderr.write(`${w("setup")}
|
|
287
|
-
`),process.exit(1)}}async function fe(e){(await
|
|
283
|
+
`),process.exit(1)}}async function fe(e){(await y({config:e,document:Cm,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession==null&&(process.stderr.write("No active dev session. Start `npx ripplo watch` as a background process (your app's dev server must also be running), then retry. Or run `/ripplo:start` in Claude Code.\n"),process.stderr.write(`${w("setup")}
|
|
288
284
|
`),process.exit(1))}async function li({id:e,runs:t}){let r=me();await fe(r),process.stdout.write(`flake-detect "${e}" x${String(t)}...
|
|
289
285
|
`);let n=await Promise.allSettled(Array.from({length:t},()=>Ft({config:r,ids:[e]}))),o=0,i=0,s=new Map;n.forEach(l=>{if(l.status==="rejected"){i++;let p=l.reason instanceof Error?l.reason.message:"unknown error";s.set(p,(s.get(p)??0)+1);return}let c=l.value.results[0];if(c==null){i++;return}if(c.summary.includes("FAILED")||c.summary.includes("ERROR")){i++;let p=c.summary.split(`
|
|
290
286
|
`).find(m=>m.includes("FAILED")||m.includes("ERROR"))??"unknown failure";s.set(p,(s.get(p)??0)+1)}else o++});let a=t>0?i/t*100:0;process.stdout.write(`${String(o)} passed / ${String(i)} failed (${a.toFixed(1)}% flake)
|
|
291
287
|
`),s.size>0&&s.forEach((l,c)=>{process.stdout.write(` ${String(l)}x: ${c}
|
|
292
288
|
`)}),i>0&&process.stderr.write(`${w("flake-detect","parallel safety + race conditions")}
|
|
293
|
-
`),process.exit(i>0?1:0)}import Ht from"fs";import{graphql as
|
|
289
|
+
`),process.exit(i>0?1:0)}import Ht from"fs";import{graphql as Am}from"gql.tada";import Em from"fs";function ce(e){return et(e,"hooks-paused")}function T(e){return Em.existsSync(ce(e))?!1:Ve(e)}var Im=Am(`
|
|
294
290
|
mutation CliSetHooksPaused($projectId: String!, $paused: Boolean!) {
|
|
295
291
|
setHooksPaused(projectId: $projectId, paused: $paused)
|
|
296
292
|
}
|
|
297
|
-
`);async function ci(){process.stdin.isTTY||(process.stderr.write("`ripplo hooks pause` must be invoked interactively from a terminal \u2014 refusing non-TTY invocation. Bypassing the gate is a human decision, not an agent decision.\n"),process.exit(1));let e=process.cwd();Ze(e);let t=ce(e);if(Ht.existsSync(t)){process.stdout.write("Hooks already paused. Run `ripplo hooks resume` to re-enable.\n");return}Ht.writeFileSync(t,""),await
|
|
298
|
-
`);return}Ht.unlinkSync(t),await
|
|
299
|
-
`)}async function
|
|
300
|
-
`)[0]??r.message:String(r);return
|
|
293
|
+
`);async function ci(){process.stdin.isTTY||(process.stderr.write("`ripplo hooks pause` must be invoked interactively from a terminal \u2014 refusing non-TTY invocation. Bypassing the gate is a human decision, not an agent decision.\n"),process.exit(1));let e=process.cwd();Ze(e);let t=ce(e);if(Ht.existsSync(t)){process.stdout.write("Hooks already paused. Run `ripplo hooks resume` to re-enable.\n");return}Ht.writeFileSync(t,""),await ui(e,!0),process.stdout.write("Hooks paused. Pre-edit gates and stop enforcement are off until you run `ripplo hooks resume`.\n")}async function di(){let e=process.cwd(),t=ce(e);if(!Ht.existsSync(t)){process.stdout.write(`Hooks already active.
|
|
294
|
+
`);return}Ht.unlinkSync(t),await ui(e,!1),process.stdout.write(`Hooks resumed.
|
|
295
|
+
`)}async function ui(e,t){let r;try{r=D(e)}catch{return}await y({config:r,document:Im,variables:{paused:t,projectId:r.projectId}}).catch(()=>null)}import Fe from"fs";import He from"path";import{input as fi,select as gi}from"@inquirer/prompts";import{graphql as Jm}from"gql.tada";import{exec as jm}from"child_process";import O from"fs";import L from"path";import{promisify as Tm}from"util";var $m=["@ripplo/testing"],pi=".ripplo/ripplo.lock linguist-generated=true",Nm=[".ripplo/debug/",".ripplo/.local/"],Om=Tm(jm);async function mi({cwd:e,onStep:t}){t("Scaffolding project files..."),Bm({cwd:e}),t("Updating .gitignore..."),Wm(e),t("Marking ripplo.lock as generated..."),_m(e),t("Installing dependencies...");let r=await Dm(e),n=[];if(r.ok||n.push({manualCommand:r.cmd,message:`Couldn't auto-install dev dependencies (${r.reason}). Run the command below, then run \`ripplo lint\` to compile the lockfile.`}),r.ok){t("Compiling initial lockfile...");let o=await Lm(e);o!=null&&n.push({manualCommand:void 0,message:o})}return t("Setting up browser..."),await fr(),n}async function Dm(e){let t=Um({cwd:e,pm:Hm(e)});g.info("Installing dependencies: %s",t);try{return await Om(t,{cwd:e}),{ok:!0}}catch(r){let n=r instanceof Error?r.message.split(`
|
|
296
|
+
`)[0]??r.message:String(r);return g.warn("Install failed (%s): %s",t,n),{cmd:t,ok:!1,reason:n}}}async function Lm(e){try{let t=await C(e);if(!t.ok)return;await ae({cwd:e,result:t.result});return}catch(t){return`Couldn't compile initial lockfile: ${t instanceof Error?t.message:String(t)}.`}}function _m(e){let t=L.join(e,".gitattributes"),r=O.existsSync(t)?O.readFileSync(t,"utf8"):"";if(r.includes(pi))return;let n=r.length===0||r.endsWith(`
|
|
301
297
|
`)?"":`
|
|
302
|
-
`;
|
|
303
|
-
`)}function Um({cwd:e,pm:t}){let r=$m.join(" ");return t==="pnpm"?Vm(e)?`pnpm add -wD ${r}`:`pnpm add -D ${r}`:t==="yarn"?Fm(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`:t==="bun"?`bun add -d ${r}`:`npm install -D ${r}`}function Vm(e){return
|
|
298
|
+
`;O.writeFileSync(t,`${r}${n}${pi}
|
|
299
|
+
`)}function Um({cwd:e,pm:t}){let r=$m.join(" ");return t==="pnpm"?Vm(e)?`pnpm add -wD ${r}`:`pnpm add -D ${r}`:t==="yarn"?Fm(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`:t==="bun"?`bun add -d ${r}`:`npm install -D ${r}`}function Vm(e){return O.existsSync(L.join(e,"pnpm-workspace.yaml"))||O.existsSync(L.join(e,"pnpm-workspace.yml"))}function Fm(e){let t=L.join(e,"package.json");if(!O.existsSync(t))return!1;try{let r=JSON.parse(O.readFileSync(t,"utf8"));if(r==null||typeof r!="object"||!("workspaces"in r))return!1;let n=r.workspaces;return Array.isArray(n)||n!=null&&typeof n=="object"}catch{return!1}}function Hm(e){return O.existsSync(L.join(e,"pnpm-lock.yaml"))?"pnpm":O.existsSync(L.join(e,"yarn.lock"))?"yarn":O.existsSync(L.join(e,"bun.lockb"))||O.existsSync(L.join(e,"bun.lock"))?"bun":"npm"}function Bm({cwd:e}){let t=L.join(e,".ripplo"),r=L.join(t,"tests"),n=L.join(t,"preconditions"),o=L.join(t,"observers");O.mkdirSync(r,{recursive:!0}),O.mkdirSync(n,{recursive:!0}),O.mkdirSync(o,{recursive:!0}),lt(L.join(t,"index.ts"),Mm),lt(L.join(n,"index.ts"),qm),lt(L.join(o,"index.ts"),zm),lt(L.join(r,"index.ts"),Gm),lt(L.join(t,"tsconfig.json"),Km)}function lt(e,t){O.existsSync(e)||O.writeFileSync(e,t)}function Wm(e){let t=L.join(e,".gitignore");if(!O.existsSync(t))return;let r=O.readFileSync(t,"utf8"),n=Nm.filter(i=>!r.includes(i));if(n.length===0)return;let o=r.endsWith(`
|
|
304
300
|
`)?"":`
|
|
305
|
-
`;
|
|
301
|
+
`;O.writeFileSync(t,r+o+n.join(`
|
|
306
302
|
`)+`
|
|
307
303
|
`)}var Mm=`import { createRipplo } from "@ripplo/testing";
|
|
308
304
|
import { preconditions } from "./preconditions/index";
|
|
@@ -374,39 +370,39 @@ export const tests = [] as const;
|
|
|
374
370
|
`)}});if(p.length>0){process.stdout.write(`Done with warnings:
|
|
375
371
|
`),p.forEach(m=>{process.stdout.write(` - ${m.message}
|
|
376
372
|
`),m.manualCommand!=null&&process.stdout.write(` run: ${m.manualCommand}
|
|
377
|
-
`)});return}process.stdout.write("Ready. Start `npx ripplo watch` as a background process (or run `/ripplo:start` in Claude Code), then write tests in `.ripplo/tests/`.\n")}function Ym(e){return Fe.existsSync(He.join(e,".ripplo","index.ts"))}async function Xm({serverUrl:e,token:t}){return((await
|
|
373
|
+
`)});return}process.stdout.write("Ready. Start `npx ripplo watch` as a background process (or run `/ripplo:start` in Claude Code), then write tests in `.ripplo/tests/`.\n")}function Ym(e){return Fe.existsSync(He.join(e,".ripplo","index.ts"))}async function Xm({serverUrl:e,token:t}){return((await y({config:ke({serverUrl:e,token:t}),document:Qm,variables:void 0})).projects??[]).map(n=>({id:n.id,name:n.name}))}function Zm(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function ef(e,t){if(t!=null){try{new URL(t)}catch{process.stdout.write(`--engine-url is not a valid URL: ${t}
|
|
378
374
|
`),process.exit(1)}return t}return`${e.replace(/\/$/,"")}/ripplo`}async function tf(e,t){if(t!=null){let r=e.find(n=>n.id===t);return r==null&&(process.stdout.write(`Unknown project id: ${t}
|
|
379
375
|
`),process.exit(1)),process.stdout.write(`Using project: ${r.name} (${r.id})
|
|
380
376
|
`),r.id}if(e.length===1){let r=e[0];if(r==null)throw new Error("unreachable");return process.stdout.write(`Using project: ${r.name} (${r.id})
|
|
381
377
|
`),r.id}return gi({choices:e.map(r=>({name:r.name,value:r.id})),message:"Select a project"})}async function rf(e,t){return t!=null?(t.trim().length===0&&(process.stdout.write(`--env must not be empty
|
|
382
378
|
`),process.exit(1)),t):of(e)}async function nf(e){if(e!=null){try{new URL(e)}catch{process.stdout.write(`--app-url is not a valid URL: ${e}
|
|
383
|
-
`),process.exit(1)}return e}return sf()}async function of(e){let t=He.join(e,".ripplo"),r=tn.find(o=>Fe.existsSync(He.resolve(t,o))),n=await gi({choices:[...tn.map(o=>({name:r===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:r??tn[0],message:"Which env file should ripplo write RIPPLO_APP_URL, RIPPLO_ENGINE_URL, RIPPLO_WEBHOOK_SECRET, and ENABLE_RIPPLO_TESTING to?"});return n!=="__custom__"?n:fi({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function sf(){return fi({default:"http://localhost:3000",message:"Where does your dev server run? (RIPPLO_APP_URL)",validate:e=>{try{return new URL(e),!0}catch{return"must be a valid URL"}}})}function af({appUrl:e,engineUrl:t,filePath:r}){Fe.mkdirSync(He.dirname(r),{recursive:!0});let n=Fe.existsSync(r)?Fe.readFileSync(r,"utf8"):"",o=[];if(/^RIPPLO_APP_URL=/m.test(n)||o.push(`RIPPLO_APP_URL=${e}`),/^RIPPLO_ENGINE_URL=/m.test(n)||o.push(`RIPPLO_ENGINE_URL=${t}`),/^RIPPLO_WEBHOOK_SECRET=/m.test(n)||o.push(`RIPPLO_WEBHOOK_SECRET=${
|
|
379
|
+
`),process.exit(1)}return e}return sf()}async function of(e){let t=He.join(e,".ripplo"),r=tn.find(o=>Fe.existsSync(He.resolve(t,o))),n=await gi({choices:[...tn.map(o=>({name:r===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:r??tn[0],message:"Which env file should ripplo write RIPPLO_APP_URL, RIPPLO_ENGINE_URL, RIPPLO_WEBHOOK_SECRET, and ENABLE_RIPPLO_TESTING to?"});return n!=="__custom__"?n:fi({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function sf(){return fi({default:"http://localhost:3000",message:"Where does your dev server run? (RIPPLO_APP_URL)",validate:e=>{try{return new URL(e),!0}catch{return"must be a valid URL"}}})}function af({appUrl:e,engineUrl:t,filePath:r}){Fe.mkdirSync(He.dirname(r),{recursive:!0});let n=Fe.existsSync(r)?Fe.readFileSync(r,"utf8"):"",o=[];if(/^RIPPLO_APP_URL=/m.test(n)||o.push(`RIPPLO_APP_URL=${e}`),/^RIPPLO_ENGINE_URL=/m.test(n)||o.push(`RIPPLO_ENGINE_URL=${t}`),/^RIPPLO_WEBHOOK_SECRET=/m.test(n)||o.push(`RIPPLO_WEBHOOK_SECRET=${Ar()}`),/^ENABLE_RIPPLO_TESTING=/m.test(n)||o.push("ENABLE_RIPPLO_TESTING=true"),o.length===0)return;let i=n.length===0||n.endsWith(`
|
|
384
380
|
`)?"":`
|
|
385
381
|
`;Fe.writeFileSync(r,`${n}${i}${o.join(`
|
|
386
382
|
`)}
|
|
387
|
-
`)}import rn from"fs";import hi from"path";import*as wi from"remeda";import lf from"path";import{graphql as cf}from"gql.tada";var
|
|
383
|
+
`)}import rn from"fs";import hi from"path";import*as wi from"remeda";import lf from"path";import{graphql as cf}from"gql.tada";var df=cf(`
|
|
388
384
|
mutation AutoScopeAddDirty($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
389
385
|
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
390
386
|
id
|
|
391
387
|
}
|
|
392
388
|
}
|
|
393
|
-
`);async function Bt({compileResult:e,cwd:t}){if(
|
|
389
|
+
`);async function Bt({compileResult:e,cwd:t}){if(!T(t))return{addedSlugs:[]};let r=uf(t);if(r.length===0)return{addedSlugs:[]};let n=new Set(e.result.tests.map(c=>c.slug)),o=r.filter(c=>n.has(c));if(o.length===0)return{addedSlugs:[]};let i;try{i=D(t)}catch{return{addedSlugs:[]}}if(await st({compiled:e.result,config:i,cwd:t}).catch(c=>(g.warn("auto-sync failed: %s",c instanceof Error?c.message:String(c)),null))==null)return{addedSlugs:[]};let a=await y({config:i,document:df,variables:{cwd:i.cwd,projectId:i.projectId,workflowSlugs:o}}).catch(c=>(g.warn("auto-scope failed: %s",c instanceof Error?c.message:String(c)),null));return a==null?{addedSlugs:[]}:(a.addDirtyTestsToScope??[]).length===0?{addedSlugs:[]}:{addedSlugs:o}}function uf(e){let t;try{t=q(["status","--porcelain","--",".ripplo/tests"],e)}catch{return[]}return t.split(`
|
|
394
390
|
`).map(r=>r.slice(3).trim()).filter(r=>/^\.ripplo\/tests\/[^/]+\.ts$/.test(r)).map(r=>lf.basename(r,".ts")).filter(r=>r!=="index")}async function bi(e){let{ids:t,requireImplemented:r}=e,n=process.cwd(),o=await C(n);o.ok||(process.stderr.write(`Compilation failed: ${o.error}
|
|
395
391
|
`),process.stderr.write(`${w("create","DSL authoring + lint rules")}
|
|
396
|
-
`),process.exit(1)),await ae({cwd:n,result:o.result});let i=De(o.result),s=t.length===0?i.diagnostics:i.diagnostics.filter(
|
|
397
|
-
${
|
|
398
|
-
`),
|
|
399
|
-
`),process.stderr.write(` ${
|
|
400
|
-
`)})});let l=new Set(o.builder.getUnimplemented().tests),c=r.filter(
|
|
392
|
+
`),process.exit(1)),await ae({cwd:n,result:o.result});let i=De(o.result),s=t.length===0?i.diagnostics:i.diagnostics.filter(f=>t.includes(f.test)),a=wi.groupBy(s,f=>f.test);Object.entries(a).forEach(([f,V])=>{process.stderr.write(`
|
|
393
|
+
${f}
|
|
394
|
+
`),V.forEach($=>{let F=$.step==null?"":` at "${$.step}"`;process.stderr.write(` [${$.rule}]${F}
|
|
395
|
+
`),process.stderr.write(` ${$.message}
|
|
396
|
+
`)})});let l=new Set(o.builder.getUnimplemented().tests),c=r.filter(f=>l.has(f));c.length>0&&(process.stderr.write(`
|
|
401
397
|
not-implemented
|
|
402
|
-
`),c.forEach(
|
|
398
|
+
`),c.forEach(f=>{process.stderr.write(` ${f} is still marked .notImplemented()
|
|
403
399
|
`)}));let p=gf(n);p.length>0&&(process.stderr.write(`
|
|
404
400
|
preconditions
|
|
405
|
-
`),p.forEach(
|
|
406
|
-
`),process.stderr.write(` ${
|
|
401
|
+
`),p.forEach(f=>{process.stderr.write(` [hardcoded-identifier] ${f.file}
|
|
402
|
+
`),process.stderr.write(` ${f.message}
|
|
407
403
|
`)}));let m=s.length+c.length+p.length;m>0&&(process.stderr.write(`
|
|
408
404
|
${String(m)} error(s)
|
|
409
|
-
`),pf({diagnostics:s,hardcodeWarnings:p,stillStubbed:c}),process.exit(1));let k=o.result.tests.length,
|
|
405
|
+
`),pf({diagnostics:s,hardcodeWarnings:p,stillStubbed:c}),process.exit(1));let k=o.result.tests.length,_=t.length===0?"all tests":`${String(t.length)} test(s)`;process.stdout.write(`\u2713 ripplo lint: ${_} passed (${String(k)} compiled, lockfile written)
|
|
410
406
|
`);let{addedSlugs:j}=await Bt({compileResult:o,cwd:n});j.length>0&&process.stdout.write(`\u2713 Auto-scoped ${j.join(", ")} (dirty tests).
|
|
411
407
|
`)}function pf({diagnostics:e,hardcodeWarnings:t,stillStubbed:r}){let n=new Set;(e.length>0||r.length>0)&&n.add("create"),t.length>0&&n.add("explore"),n.forEach(o=>process.stderr.write(`${w(o)}
|
|
412
408
|
`))}var mf=/['"`][\w.+-]+@[\w.-]+\.[a-z]{2,}['"`]/i,ff=/['"`][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"`]/i;function gf(e){let t=hi.join(e,".ripplo","preconditions");return rn.existsSync(t)?rn.readdirSync(t).filter(n=>n.endsWith(".ts")).flatMap(n=>yf(hi.join(t,n))):[]}function yf(e){let t=rn.readFileSync(e,"utf8"),r=t.includes("ctx.uniqueEmail")||t.includes("ctx.uniqueId"),n=[],o=mf.exec(t);o!=null&&!r&&n.push({file:e,message:`hardcoded email literal ${o[0]} \u2014 use ctx.uniqueEmail() so parallel runs don't collide`});let i=ff.exec(t);return i!=null&&!r&&n.push({file:e,message:`hardcoded UUID-like literal ${i[0]} \u2014 use ctx.uniqueId() so parallel runs don't collide`}),n}import{graphql as hf}from"gql.tada";var wf=hf(`
|
|
@@ -416,14 +412,14 @@ ${String(m)} error(s)
|
|
|
416
412
|
name
|
|
417
413
|
}
|
|
418
414
|
}
|
|
419
|
-
`);async function vi(){let e=Z();e==null&&(process.stderr.write("Not authenticated. Run `ripplo auth login` first.\n"),process.exit(1));let t=Q(),n=((await
|
|
415
|
+
`);async function vi(){let e=Z();e==null&&(process.stderr.write("Not authenticated. Run `ripplo auth login` first.\n"),process.exit(1));let t=Q(),n=((await y({config:ke({serverUrl:t,token:e}),document:wf,variables:void 0})).projects??[]).map(o=>({id:o.id,name:o.name}));process.stdout.write(`${JSON.stringify({projects:n},null,2)}
|
|
420
416
|
`)}async function ki(e){let t=me();await fe(t);let{results:r,summary:n}=await Ft({config:t,ids:e});process.stdout.write(`${n}
|
|
421
417
|
`);let o=r.some(i=>i.summary.includes("FAILED")||i.summary.includes("ERROR"));o&&(process.stderr.write(`Artifacts in .ripplo/debug/<runId>/ \u2014 read before re-running.
|
|
422
418
|
`),process.stderr.write(`${w("debug")}
|
|
423
|
-
`)),process.exit(o?1:0)}async function Si(){let e=process.cwd(),t=
|
|
419
|
+
`)),process.exit(o?1:0)}async function Si(){let e=process.cwd(),t=D(e);try{let r=await Ce(t.cwd,t),n=r.compiled.tests.length,o=Object.keys(r.compiled.preconditions).length;process.stdout.write(`synced ${String(n)} tests, ${String(o)} preconditions to dev session ${r.devSessionId}
|
|
424
420
|
`)}catch(r){let n=r instanceof Error?r.message:String(r);process.stderr.write(`ripplo sync failed: ${n}
|
|
425
421
|
`),process.stderr.write(`${w("setup","verify auth + server reachability")}
|
|
426
|
-
`),process.exit(1)}}import on from"fs";import{createClient as xf}from"graphql-sse";import{graphql as Wt}from"gql.tada";import{print as Pi}from"graphql";import{availableParallelism as bf}from"os";import vf from"p-limit";var kf=Math.max(1,Math.min(10,Math.floor(bf()/2))),Sf=vf(kf),nn=new Set;async function Ri(e){if(!nn.has(e.runId)){nn.add(e.runId);try{await Sf(()=>Rf(e))}finally{nn.delete(e.runId)}}}async function Rf({config:e,cwd:t,runId:r,workflowId:n,workflowSlug:o}){let i=await Ye({headed:!1});try{await gr({maxRuns:100});let s=t!=null&&o!=null?await Pf({cwd:t,workflowSlug:o}):void 0;await _r({baseUrl:e.appUrl,browser:i,config:e,headed:!1,preconditionNames:s,runId:r,webhookSecret:e.webhookSecret,workflowId:n})}catch(s){
|
|
422
|
+
`),process.exit(1)}}import on from"fs";import{createClient as xf}from"graphql-sse";import{graphql as Wt}from"gql.tada";import{print as Pi}from"graphql";import{availableParallelism as bf}from"os";import vf from"p-limit";var kf=Math.max(1,Math.min(10,Math.floor(bf()/2))),Sf=vf(kf),nn=new Set;async function Ri(e){if(!nn.has(e.runId)){nn.add(e.runId);try{await Sf(()=>Rf(e))}finally{nn.delete(e.runId)}}}async function Rf({config:e,cwd:t,runId:r,workflowId:n,workflowSlug:o}){let i=await Ye({headed:!1});try{await gr({maxRuns:100});let s=t!=null&&o!=null?await Pf({cwd:t,workflowSlug:o}):void 0;await _r({baseUrl:e.appUrl,browser:i,config:e,headed:!1,preconditionNames:s,runId:r,webhookSecret:e.webhookSecret,workflowId:n})}catch(s){g.error(s,"Runner error")}finally{await i.close()}}async function Pf({cwd:e,workflowSlug:t}){let r=await C(e);if(!r.ok)return;let n=r.result.tests.find(o=>o.slug===t);if(n!=null)return n.preconditions}var Cf=15e3,Ef=Wt(`
|
|
427
423
|
subscription RunRequestedWatch($devSessionId: String!) {
|
|
428
424
|
runRequested(devSessionId: $devSessionId) {
|
|
429
425
|
runId
|
|
@@ -431,14 +427,14 @@ ${String(m)} error(s)
|
|
|
431
427
|
workflowSlug
|
|
432
428
|
}
|
|
433
429
|
}
|
|
434
|
-
`),
|
|
430
|
+
`),Af=Wt(`
|
|
435
431
|
subscription HooksPausedWatch($projectId: String!) {
|
|
436
432
|
hooksPausedRequested(projectId: $projectId) {
|
|
437
433
|
paused
|
|
438
434
|
projectId
|
|
439
435
|
}
|
|
440
436
|
}
|
|
441
|
-
`),
|
|
437
|
+
`),If=Wt(`
|
|
442
438
|
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
443
439
|
heartbeatDevSession(id: $id) {
|
|
444
440
|
id
|
|
@@ -451,10 +447,10 @@ ${String(m)} error(s)
|
|
|
451
447
|
}
|
|
452
448
|
}
|
|
453
449
|
`);async function xi(){Hf();let e=Of(process.cwd()),t=e.cwd,r=await C(t);r.ok||(process.stderr.write(`ripplo: DSL compilation failed: ${r.error}
|
|
454
|
-
`),process.exit(1));let n=await _f(()=>st({compiled:r.result,config:e,cwd:t})),o=Ut(t);o!=null&&
|
|
455
|
-
`);let p=async()=>{c(),a(),l(),await Promise.race([
|
|
456
|
-
`),Ri({config:e,cwd:t,runId:i.runId,workflowId:i.workflowId,workflowSlug:i.workflowSlug}).catch(s=>{
|
|
457
|
-
`),process.exit(1)}}var Df=1e3,Lf=6e4;async function _f(e){let t=Date.now()+Lf,r;for(;Date.now()<t;){let n=await Uf(e);if(n.ok)return n.value;if(!Vf(n.message))throw n.error;r=n.error,await Ff(Df)}throw r instanceof Error?r:new Error("server never became ready")}async function Uf(e){try{return{ok:!0,value:await e()}}catch(t){let r=t instanceof Error?t.message:String(t);return{error:t,message:r,ok:!1}}}function Vf(e){return e.includes("status 502")||e.includes("ECONNREFUSED")||e.includes("Failed to connect")||e.includes("fetch failed")}function Ff(e){return new Promise(t=>setTimeout(t,e))}function Hf(){process.on("unhandledRejection",e=>{
|
|
450
|
+
`),process.exit(1));let n=await _f(()=>st({compiled:r.result,config:e,cwd:t})),o=Ut(t);o!=null&&g.info("watching branch %s in %s",o,t);let i=Ko(t),s=xf({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`}),a=Tf({config:e,cwd:t,devSessionId:n.devSessionId,sseClient:s}),l=$f({cwd:t,projectId:e.projectId,sseClient:s}),c=Nf({config:e,devSessionId:n.devSessionId});process.stdout.write(`ripplo watch: ready as local executor for session ${n.devSessionId} (sync happens on each \`ripplo run\`; Ctrl-C to stop)
|
|
451
|
+
`);let p=async()=>{c(),a(),l(),await Promise.race([y({config:e,document:jf,variables:{cwd:e.cwd,projectId:e.projectId}}).catch(()=>{}),new Promise(k=>setTimeout(k,3e3))]),i()},m=()=>{p().finally(()=>process.exit(0))};process.on("SIGINT",m),process.on("SIGTERM",m),process.on("SIGHUP",m),process.on("SIGBREAK",m),await new Promise(()=>{})}function Tf({config:e,cwd:t,devSessionId:r,sseClient:n}){return n.subscribe({query:Pi(Ef),variables:{devSessionId:r}},{complete:()=>{},error:o=>{g.error(o,"runRequested subscription error")},next:o=>{let i=o.data?.runRequested;i!=null&&(process.stdout.write(`ripplo: run ${i.runId} (${i.workflowSlug})
|
|
452
|
+
`),Ri({config:e,cwd:t,runId:i.runId,workflowId:i.workflowId,workflowSlug:i.workflowSlug}).catch(s=>{g.error({err:s,runId:i.runId,workflowSlug:i.workflowSlug},"run execution failed; watch continuing")}))}})}function $f({cwd:e,projectId:t,sseClient:r}){return r.subscribe({query:Pi(Af),variables:{projectId:t}},{complete:()=>{},error:n=>{g.error(n,"hooksPaused subscription error")},next:n=>{let o=n.data?.hooksPausedRequested?.paused;if(o===!0){on.writeFileSync(ce(e),"");return}o===!1&&on.existsSync(ce(e))&&on.unlinkSync(ce(e))}})}function Nf({config:e,devSessionId:t}){let r=setInterval(()=>{y({config:e,document:If,variables:{id:t}}).catch(n=>{g.warn("heartbeat failed: %s",n instanceof Error?n.message:String(n))})},Cf);return()=>{clearInterval(r)}}function Of(e){try{return D(e)}catch(t){let r=t instanceof Error?t.message:String(t);process.stderr.write(`${r}
|
|
453
|
+
`),process.exit(1)}}var Df=1e3,Lf=6e4;async function _f(e){let t=Date.now()+Lf,r;for(;Date.now()<t;){let n=await Uf(e);if(n.ok)return n.value;if(!Vf(n.message))throw n.error;r=n.error,await Ff(Df)}throw r instanceof Error?r:new Error("server never became ready")}async function Uf(e){try{return{ok:!0,value:await e()}}catch(t){let r=t instanceof Error?t.message:String(t);return{error:t,message:r,ok:!1}}}function Vf(e){return e.includes("status 502")||e.includes("ECONNREFUSED")||e.includes("Failed to connect")||e.includes("fetch failed")}function Ff(e){return new Promise(t=>setTimeout(t,e))}function Hf(){process.on("unhandledRejection",e=>{g.error({err:e},"unhandledRejection in watch; continuing")}),process.on("uncaughtException",e=>{g.error({err:e},"uncaughtException in watch; continuing")})}import{graphql as ct}from"gql.tada";var Bf=ct(`
|
|
458
454
|
query ScopeStatus($projectId: String!, $cwd: String!) {
|
|
459
455
|
project(id: $projectId) {
|
|
460
456
|
id
|
|
@@ -507,14 +503,14 @@ ${String(m)} error(s)
|
|
|
507
503
|
mutation ScopeRemoveMany($ids: [ID!]!) {
|
|
508
504
|
removeScopeItems(ids: $ids)
|
|
509
505
|
}
|
|
510
|
-
`);async function Ci(e){let t=me();await fe(t);let n=(await
|
|
506
|
+
`);async function Ci(e){let t=me();await fe(t);let n=(await y({config:t,document:Bf,variables:{cwd:t.cwd,projectId:t.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(n,null,2)}
|
|
511
507
|
`);return}if(n.length===0){process.stdout.write("No scope items. Add via `ripplo scope add <test-ids..>` (variadic) or from the dashboard.\n");return}n.forEach(o=>{let i=o.workflow;if(i==null){process.stdout.write(` [intent] (${o.id}) ${o.label??""}
|
|
512
508
|
`);return}let s=i.spec==null?"stub":"implemented";process.stdout.write(` [${s}] (${o.id}) ${i.slug} \u2014 ${i.name}
|
|
513
|
-
`)})}async function Ei({testIds:e}){let t=me();await fe(t),await Ce(t.cwd,t);let n=(await
|
|
509
|
+
`)})}async function Ei({testIds:e}){let t=me();await fe(t),await Ce(t.cwd,t);let n=(await y({config:t,document:Mf,variables:{cwd:t.cwd,projectId:t.projectId,workflowSlugs:[...e]}})).addDirtyTestsToScope??[];if(n.length===0){process.stdout.write(`No scope items added.
|
|
514
510
|
`);return}let o=n.map(i=>i.workflow?.slug??"?").join(", ");process.stdout.write(`Added ${String(n.length)} scope item(s): ${o}
|
|
515
|
-
`)}async function
|
|
516
|
-
`)}async function
|
|
517
|
-
`)}async function Gf({cfg:e,slug:t}){let n=(await
|
|
511
|
+
`)}async function Ai({id:e,testId:t}){let r=me();await fe(r),await Ce(r.cwd,r);let n=await Gf({cfg:r,slug:t});await y({config:r,document:qf,variables:{id:e,workflowId:n}}),process.stdout.write(`Linked scope item ${e} to ${t}
|
|
512
|
+
`)}async function Ii({ids:e}){let t=me();await fe(t);let n=(await y({config:t,document:zf,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${String(n)} scope item(s)
|
|
513
|
+
`)}async function Gf({cfg:e,slug:t}){let n=(await y({config:e,document:Wf,variables:{cwd:e.cwd,projectId:e.projectId,slug:t}})).project?.devSession?.workflows?.[0];return n==null&&(process.stderr.write(`No workflow found with id "${t}". Create a stub first via the testing DSL.
|
|
518
514
|
`),process.stderr.write(`${w("create")}
|
|
519
515
|
`),process.exit(1)),n.id}async function ji(e){let t=process.cwd(),r=await C(t);r.ok||(process.stderr.write(`Compilation failed: ${r.error}
|
|
520
516
|
`),process.exit(1));let{tests:n}=r.builder.getUnimplemented();if(e.format==="summary"){n.length>0&&process.stdout.write(`tests: ${n.join(", ")}
|
|
@@ -522,11 +518,11 @@ ${String(m)} error(s)
|
|
|
522
518
|
`)}import{z as Kf}from"zod";function E(e,t){let r=Kf.custom(n=>typeof n=="object"&&n!==null&&"hook_event_name"in n&&n.hook_event_name===e);return{event:e,run:async n=>await t(r.parse(n))??void 0}}import{createHash as TP}from"crypto";import Ti from"picomatch";function Jf(e){return q(["diff","--name-only","HEAD"],e).split(`
|
|
523
519
|
`).filter(t=>t.length>0)}function $i({cwd:e,ignoreGlobs:t,watchGlobs:r}){let n=Ti([...r]),o=Ti([...t]);return Jf(e).filter(i=>n(i)&&!o(i))}function Mt(e,...t){return q(["diff","--name-only","HEAD","--",...t],e).split(`
|
|
524
520
|
`).filter(r=>r.length>0)}import{createHash as Qf}from"crypto";import{mkdirSync as Yf,readFileSync as Ni,writeFileSync as Xf}from"fs";import sn from"path";var Zf=[".ts",".tsx",".js",".jsx"];function Be(e){let t=Qf("sha256");return t.update(q(["rev-parse","HEAD"],e)),t.update("\0"),t.update(q(["diff","HEAD"],e)),t.update("\0"),q(["ls-files","--others","--exclude-standard"],e).split(`
|
|
525
|
-
`).filter(n=>n.length>0).filter(n=>Zf.some(o=>n.endsWith(o))).toSorted((n,o)=>n.localeCompare(o)).forEach(n=>{t.update(n),t.update("\0"),t.update(eg(sn.join(e,n))),t.update("\0")}),t.digest("hex")}function We(e,t){try{return Ni(Oi(e,t),"utf8").trim()}catch{return null}}function Me(e,t,r){let n=Oi(e,t);Yf(sn.dirname(n),{recursive:!0}),Xf(n,r)}function Oi(e,t){return sn.join(e,".ripplo",".local",`${t}.hash`)}function eg(e){try{return Ni(e)}catch{return Buffer.alloc(0)}}function Pe(){return{ignorePaths:Re,watchPaths:zr}}var Di=E("UserPromptSubmit",e=>{let{cwd:t}=e;if(!x(t)
|
|
526
|
-
`),hookEventName:"UserPromptSubmit"}}});import ng from"path";import Vi from"picomatch";import{z as Fi}from"zod";var og=Fi.looseObject({file_path:Fi.string()}),Hi=E("PostToolUse",async e=>{let t=og.safeParse(e.tool_input);if(!t.success)return;let r=t.data.file_path,{cwd:n}=e;if(!x(n)
|
|
521
|
+
`).filter(n=>n.length>0).filter(n=>Zf.some(o=>n.endsWith(o))).toSorted((n,o)=>n.localeCompare(o)).forEach(n=>{t.update(n),t.update("\0"),t.update(eg(sn.join(e,n))),t.update("\0")}),t.digest("hex")}function We(e,t){try{return Ni(Oi(e,t),"utf8").trim()}catch{return null}}function Me(e,t,r){let n=Oi(e,t);Yf(sn.dirname(n),{recursive:!0}),Xf(n,r)}function Oi(e,t){return sn.join(e,".ripplo",".local",`${t}.hash`)}function eg(e){try{return Ni(e)}catch{return Buffer.alloc(0)}}function Pe(){return{ignorePaths:Re,watchPaths:zr}}var Di=E("UserPromptSubmit",e=>{let{cwd:t}=e;if(!x(t)||!T(t))return;let r=Be(t);if(We(t,"coverage-nudge")===r)return;let{ignorePaths:n,watchPaths:o}=Pe(),i=$i({cwd:t,ignoreGlobs:n,watchGlobs:o});if(Me(t,"coverage-nudge",r),!(i.length===0||Mt(t,".ripplo/tests",".ripplo/preconditions",".ripplo/observers").length>0))return{hookSpecificOutput:{additionalContext:`SCOPE DRIFT: ${String(i.length)} app file(s) changed without .ripplo/tests updates. ${w("scope")}`,hookEventName:"UserPromptSubmit"}}});import qt from"fs";import tg from"os";import Li from"path";var _i=E("PreToolUse",e=>{if(e.tool_name!=="ExitPlanMode"||!T(e.cwd))return;let t=rg();if(t==null)return;let r=qt.readFileSync(t,"utf8");if(!/\.ripplo\/tests|Tests to implement|No e2e coverage needed/.test(r))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Plan must cite ripplo test stubs. Add a "Tests to implement" section listing .ripplo/tests/<id>.ts per affected flow, OR add "No e2e coverage needed: <reason>" if this plan touches no user-facing behavior. ${w("explore")}`}}});function rg(){let e=Li.join(tg.homedir(),".claude","plans");return qt.existsSync(e)?qt.readdirSync(e).filter(r=>r.endsWith(".md")).map(r=>Li.join(e,r)).map(r=>({full:r,mtime:qt.statSync(r).mtimeMs})).sort((r,n)=>n.mtime-r.mtime)[0]?.full??null:null}var Ui=E("UserPromptSubmit",async e=>{if(e.permission_mode!=="plan"||!x(e.cwd)||!T(e.cwd))return;let t=await C(e.cwd);if(!t.ok)return;let{tests:r}=t.builder.getUnimplemented(),n=['Plan must include "Tests to implement" with .ripplo/tests/<id>.ts per affected flow (ExitPlanMode blocks otherwise).'];return r.length>0&&n.push(`Existing stubs: ${r.join(", ")}`),{hookSpecificOutput:{additionalContext:n.join(`
|
|
522
|
+
`),hookEventName:"UserPromptSubmit"}}});import ng from"path";import Vi from"picomatch";import{z as Fi}from"zod";var og=Fi.looseObject({file_path:Fi.string()}),Hi=E("PostToolUse",async e=>{let t=og.safeParse(e.tool_input);if(!t.success)return;let r=t.data.file_path,{cwd:n}=e;if(!x(n)||!T(n))return;let o=ng.relative(n,r);if(o.startsWith(".."))return;let{ignorePaths:i,watchPaths:s}=Pe(),a=Vi([...s]),l=Vi([...i]);if(!a(o)||l(o))return;let c=await C(n);if(!c.ok)return;let{tests:p}=c.builder.getUnimplemented();if(p.length!==0)return{hookSpecificOutput:{additionalContext:`Reminder: .notImplemented() stubs still present \u2014 tests: ${p.join(", ")}`,hookEventName:"PostToolUse"}}});import{z as Bi}from"zod";var ig=Bi.looseObject({file_path:Bi.string()}),Wi=E("PostToolUse",async e=>{let t=ig.safeParse(e.tool_input);if(!t.success)return;let r=t.data.file_path;if(!/\/\.ripplo\/.*\.ts$/.test(r))return;let{cwd:n}=e;if(!x(n)||!T(n))return;let o=await C(n);if(!o.ok)return{decision:"block",reason:`Compilation failed: ${o.error}
|
|
527
523
|
${w("create","DSL authoring + lint rules")}`};await ae({cwd:n,result:o.result}),_e({cwd:n});let{diagnostics:i}=De(o.result);if(i.length===0){let{addedSlugs:a}=await Bt({compileResult:o,cwd:n});return a.length===0?void 0:{hookSpecificOutput:{additionalContext:`Auto-scoped ${a.join(", ")} (dirty tests).`,hookEventName:"PostToolUse"}}}return{decision:"block",reason:`${i.map(a=>{let l=a.step==null?"":` at "${a.step}"`;return` [${a.rule}]${l} ${a.test}: ${a.message}`}).join(`
|
|
528
524
|
`)}
|
|
529
|
-
${w("create")}`}});import{z as Mi}from"zod";var sg=Mi.looseObject({command:Mi.string()}),ag=/\bripplo\s+hooks\s+pause\b/,qi=E("PreToolUse",e=>{if(e.tool_name!=="Bash")return;let t=sg.safeParse(e.tool_input);if(!t.success||!ag.test(t.data.command))return;let{cwd:r}=e;if(x(r))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:"`ripplo hooks pause` is a human-only escape hatch \u2014 agents can't bypass Ripplo guardrails on their own. If watch genuinely can't start (auth, server down, intentional offline work), surface the blocker to the user and ask them to run `npx ripplo hooks pause` themselves from their terminal."}}});import{parse as pg}from"shell-quote";import{z as Ki}from"zod";import{existsSync as lg,mkdirSync as cg,rmSync as Nx,writeFileSync as
|
|
525
|
+
${w("create")}`}});import{z as Mi}from"zod";var sg=Mi.looseObject({command:Mi.string()}),ag=/\bripplo\s+hooks\s+pause\b/,qi=E("PreToolUse",e=>{if(e.tool_name!=="Bash")return;let t=sg.safeParse(e.tool_input);if(!t.success||!ag.test(t.data.command))return;let{cwd:r}=e;if(x(r))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:"`ripplo hooks pause` is a human-only escape hatch \u2014 agents can't bypass Ripplo guardrails on their own. If watch genuinely can't start (auth, server down, intentional offline work), surface the blocker to the user and ask them to run `npx ripplo hooks pause` themselves from their terminal."}}});import{parse as pg}from"shell-quote";import{z as Ki}from"zod";import{existsSync as lg,mkdirSync as cg,rmSync as Nx,writeFileSync as dg}from"fs";import an from"path";function zi(e,t,r){let n=Gi(e,t,r);cg(an.dirname(n),{recursive:!0}),dg(n,"")}function zt(e,t,r){return lg(Gi(e,t,r))}function ug(e,t){return an.join(e,".ripplo",".local","skills-loaded",t)}function Gi(e,t,r){return an.join(ug(e,t),r)}var mg=Ki.looseObject({command:Ki.string()}),fg="debug",gg=new Set(["tail","head","less","more","wc","sort","uniq","awk","sed","grep"]),Qi=E("PreToolUse",e=>{if(e.tool_name!=="Bash")return;let t=mg.safeParse(e.tool_input);if(!t.success)return;let r=yg(t.data.command);if(!hg(r))return;let{cwd:n}=e;if(!x(n)||!T(n))return;let o=bg(r);if(o!=null)return Ji(`Don't pipe \`ripplo run\` through \`${o}\` \u2014 buffering filters hold all stdout until EOF, hiding live progress; if you kill the pipeline mid-run the run is orphaned on the server. Redirect to a file instead: \`ripplo run <id> > /tmp/run.log 2>&1\` and Read the file, or use \`run_in_background: true\`.`);if(!zt(n,e.session_id,fg))return Ji("Running `ripplo run` requires the `/ripplo:debug` skill loaded first. Load `/ripplo:debug` then retry \u2014 it carries the artifact-read order, the 3-strike rule, and the no-grep-piping guidance for run failures.")});function yg(e){try{return pg(e)}catch{return[]}}function hg(e){return e.some((t,r)=>t==="ripplo"&&e[r+1]==="run")}function wg(e){return typeof e=="object"&&"op"in e&&e.op==="|"}function bg(e){let t=e.find((r,n)=>{let o=e[n-1];return o!=null&&wg(o)&&typeof r=="string"&&gg.has(r)});return typeof t=="string"?t:null}function Ji(e){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:e}}}import vg from"path";import{z as Yi}from"zod";var kg=new Set(["Edit","Write","NotebookEdit"]),Sg=Yi.looseObject({file_path:Yi.string()}),Rg="create",Xi=E("PreToolUse",e=>{if(!kg.has(e.tool_name))return;let t=Sg.safeParse(e.tool_input);if(!t.success)return;let{cwd:r}=e;if(!x(r)||!T(r))return;let n=vg.relative(r,t.data.file_path);if(!(n.startsWith("..")||n!==".ripplo"&&!n.startsWith(".ripplo/"))&&!zt(r,e.session_id,Rg))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Editing \`.ripplo/\` files (${n}) requires the \`/ripplo:create\` skill loaded first. Load \`/ripplo:create\` then retry \u2014 it carries the DSL builder shape, lint rules, and the parallelization guidance you'll need.`}}});import Pg from"path";import Zi from"picomatch";import{graphql as xg}from"gql.tada";import{z as es}from"zod";var Cg=new Set(["Edit","Write","NotebookEdit"]),Eg=es.looseObject({file_path:es.string()}),Ag=xg(`
|
|
530
526
|
query PreEditScopeGate($projectId: String!, $cwd: String!) {
|
|
531
527
|
project(id: $projectId) {
|
|
532
528
|
id
|
|
@@ -538,7 +534,7 @@ ${w("create")}`}});import{z as Mi}from"zod";var sg=Mi.looseObject({command:Mi.st
|
|
|
538
534
|
}
|
|
539
535
|
}
|
|
540
536
|
}
|
|
541
|
-
`),ts=E("PreToolUse",async e=>{if(!Cg.has(e.tool_name))return;let t=Eg.safeParse(e.tool_input);if(!t.success)return;let{cwd:r}=e;if(!x(r)
|
|
537
|
+
`),ts=E("PreToolUse",async e=>{if(!Cg.has(e.tool_name))return;let t=Eg.safeParse(e.tool_input);if(!t.success)return;let{cwd:r}=e;if(!x(r)||!T(r))return;let n=Pg.relative(r,t.data.file_path);if(!(n.startsWith("..")||n===".ripplo"||n.startsWith(".ripplo/")||!Ig(n)||await jg(r)))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Scope empty; edit touches app code (${n}). Stub a test or \`scope add\` an existing one before proceeding \u2014 or acknowledge "no user-facing behavior" if pure refactor. Hook re-fires until scope is populated (or hooks paused via the web UI). ${Uo(["scope","create"])}`}}});function Ig(e){let{ignorePaths:t,watchPaths:r}=Pe(),n=Zi([...r]),o=Zi([...t]);return n(e)&&!o(e)}async function jg(e){let t;try{t=D(e)}catch{return!0}let r=await y({config:t,document:Ag,variables:{cwd:t.cwd,projectId:t.projectId}}).catch(()=>null);return r==null?!0:(r.project?.devSession?.scopeItems??[]).length>0}import Tg from"fs";import $g from"path";import{z as rs}from"zod";var Ng=new Set(["Edit","Write","NotebookEdit"]),Og=rs.looseObject({file_path:rs.string()}),ns=E("PreToolUse",e=>{if(!Ng.has(e.tool_name))return;let t=Og.safeParse(e.tool_input);if(!t.success)return;let{cwd:r}=e;if(!x(r))return;let n=$g.relative(r,t.data.file_path);if(!(n.startsWith("..")||n!==".ripplo"&&!n.startsWith(".ripplo/"))&&!Tg.existsSync(ce(r))&&!Ve(r))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`\`ripplo watch\` is not running, so this edit to \`${n}\` won't sync to the server and dev-mode guardrails won't fire. Run \`/ripplo:start\` (or spawn \`npx ripplo watch\` directly via Bash with run_in_background), then retry. The app's dev server also needs to be running \u2014 \`npx ripplo doctor\` reports both. If watch can't start (auth, server down, intentional offline work), the user can run \`npx ripplo hooks pause\` to bypass this gate; \`npx ripplo hooks resume\` re-enables it. ${w("start")}`}}});import{graphql as Dg}from"gql.tada";var Lg=Dg(`
|
|
542
538
|
query ScopeReminder($projectId: String!, $cwd: String!) {
|
|
543
539
|
project(id: $projectId) {
|
|
544
540
|
id
|
|
@@ -555,7 +551,7 @@ ${w("create")}`}});import{z as Mi}from"zod";var sg=Mi.looseObject({command:Mi.st
|
|
|
555
551
|
}
|
|
556
552
|
}
|
|
557
553
|
}
|
|
558
|
-
`),os=E("UserPromptSubmit",async e=>{let{cwd:t}=e;if(!x(t)
|
|
554
|
+
`),os=E("UserPromptSubmit",async e=>{let{cwd:t}=e;if(!x(t)||!T(t))return;let r=Be(t);if(We(t,"scope-reminder")===r)return;let n;try{n=D(t)}catch{return}let o=await y({config:n,document:Lg,variables:{cwd:n.cwd,projectId:n.projectId}}).catch(()=>null);if(o==null)return;Me(t,"scope-reminder",r);let i=o.project?.devSession?.scopeItems??[];return{hookSpecificOutput:{additionalContext:i.length===0?`RIPPLO SCOPE: empty. ${w("scope")}`:`RIPPLO SCOPE (${String(i.length)}):
|
|
559
555
|
${i.map(a=>{let l=a.workflow;return l==null?` [intent] (${a.id}) ${a.label??""}`:` [${l.spec==null?"stub":"implemented"}] (${a.id}) ${l.slug}`}).join(`
|
|
560
556
|
`)}`,hookEventName:"UserPromptSubmit"}}});var _g="# Ripplo \u2014 always-on session context\n\nEvery user-facing change in this repo ships with a deterministic, backend-aware test that proves it works end-to-end.\n\n## Load the right skill before acting \u2014 this is critical\n\nThe skills below carry the procedural detail you need to do Ripplo work correctly: precondition isolation, observer budget tiers, coverage IDs, scope discipline, artifact-read order on failures, parallelization patterns. **None of that is reproduced in this preamble** \u2014 only the always-on guardrails are. If you act on a Ripplo task without loading the matching skill, you will skip rules that exist to prevent specific past failure modes (cross-run data leakage, \"passing\" tests that never asserted backend state, cleared coverage gates without proof, etc.).\n\nMatch the task to a skill from the triage table; if unsure between two, load both. If completely unsure, load `/ripplo:explore` or `/ripplo:create`. Loading is cheap; acting under-informed is not.\n\n## Skill triage\n\n- Load `/ripplo:setup` skill for instructions on initializing Ripplo in a project; `ripplo doctor` reports the engine endpoint missing.\n- Load `/ripplo:explore` skill for instructions on planning/stubbing test coverage for a new project or new feature area.\n- Load `/ripplo:scope` skill for instructions on managing the working set of tests this session is responsible for.\n- Load `/ripplo:create` skill for instructions on authoring a single test spec for a user flow.\n- Load `/ripplo:run` skill for instructions on executing existing tests.\n- Load `/ripplo:debug` skill for instructions on a failed run; read artifacts in `.ripplo/debug/<runId>/` before re-running.\n- Load `/ripplo:flake-detect` skill for instructions on intermittent failures; parallelizes N runs (only use with evidence of flake).\n\n## Universal rules\n\n- **Two background processes must be running before feature work.** (1) The app's dev server, so the app is reachable; (2) `npx ripplo watch` (run `/ripplo:start` to spawn it, or invoke it directly via Bash with `run_in_background`), so the dev session is live. Without watch, scope/coverage hooks don't arm and `ripplo run` refuses to dispatch. Without the dev server, runs fail when they try to hit the app. `npx ripplo doctor` reports both.\n- **Two funnels.** Definitions \u2192 `createRipplo({ preconditions, observers, tests })` in `.ripplo/index.ts`. Implementations \u2192 `createEngine(ripplo, { preconditions, observers })` in your app server's `test/engine.ts`. Never call either elsewhere. TS enforces exhaustiveness across both.\n- **\"Done\" = app code delivers the behavior AND a passing test proves it.** Both halves. Shipping without a test isn't done; writing a test against broken UI/API isn't done.\n- **Scope is your job.** For any non-trivial change, enumerate every flow it could affect and either `scope add` existing tests or stub `.notImplemented()` tests. Don't wait to be told.\n- **`scope remove` is never for size/effort.** Valid only when an item is genuinely out of scope (wrong flow, duplicate, user said \"not this session,\" feature cut). \"Too many stubs\" \u2192 parallelize with subagents. Don't present \"implement vs. remove\" as a neutral A/B.\n- **Stub gates are not a question.** When `stop-enforce` blocks on `.notImplemented()` stubs, implement them \u2014 don't ask the user \"implement or defer?\", don't propose pausing hooks as option B. The fix isn't done until the test is. New scaffolding (precondition, observer, engine impl) is in-scope work, not follow-up.\n- **`uiOnly: true` is not a stub.** Observer wiring is in-scope for mutation flows; don't use it to silence observer lint.\n- **Never weaken a test to make it pass.** No `contains`/regex for exact text, no removed assertions, no fabricated locators. App lacks an accessible name \u2192 add one to the app, don't fall back to `testId()`. App bug \u2192 report with evidence.\n- **Artifacts first, re-run last.** Failed runs produce DOM, a11y tree, console, network, screenshots under `.ripplo/debug/<runId>/`. Read them. Never pipe `ripplo run` through `grep`/`tail`/`head`. Form a hypothesis citing an artifact line, make ONE change, re-run once.\n- **3-strike rule.** Same failure after 3 targeted fixes \u2192 stop and report. Repeated failure on the same step almost always means the diagnosis is wrong.\n- **`.ripplo/ripplo.lock` is committed, never hand-edited.** `ripplo lint` / `ripplo compile` regenerates it. Pre-commit runs `ripplo compile --check`.\n- **Scratch files live in `.ripplo/.local/`.** Never loose in `.ripplo/`.\n- **Worktrees are self-contained.** Each worktree has its own `.ripplo/` checkout, DevSession, scope, and debug artifacts. Auth and projectId are shared globally. Env files (typically gitignored) won't carry over to a fresh worktree \u2014 copy from main or point at a shared file. **If sibling worktrees run dev servers on different ports, the worktree's env file MUST update both `RIPPLO_APP_URL` and `RIPPLO_ENGINE_URL` to match the port that worktree's dev server is bound to** (e.g. main on `:3000`, this worktree on `:3001` \u2192 set `RIPPLO_APP_URL=http://localhost:3001` and `RIPPLO_ENGINE_URL=http://localhost:3001/ripplo` in the worktree's env file). Mismatched ports = `npx ripplo watch` (whether started via `/ripplo:start` or manually) talks to the wrong server, runs silently fail or hit the sibling worktree's app.\n- **DSL locators are semantic.** No `css` / `placeholder` / `waitFor` / `group`.\n- **New backend assertion?** Declare in `.ripplo/observers/index.ts`, implement in your app server's `engine.ts` (TS flags the missing impl).\n\n## Key files\n\n- `.ripplo/index.ts` \u2014 `createRipplo` call.\n- `.ripplo/{preconditions,observers,tests}/index.ts` \u2014 registry aggregators.\n- `.ripplo/project.json` \u2014 project id + env-file pointers.\n- `<app>/src/test/engine.ts` \u2014 single impl funnel via `createEngine`.\n- `packages/testing/README.md` (or the npm page for `@ripplo/testing`) \u2014 DSL reference.\n",is=E("SessionStart",e=>{if(x(e.cwd))return{hookSpecificOutput:{additionalContext:_g,hookEventName:"SessionStart"}}});import{execFileSync as Ug}from"child_process";import Vg from"path";import ss from"process";import{graphql as Fg}from"gql.tada";import{z as Gt}from"zod";var Hg=Fg(`
|
|
561
557
|
query ScopeEnforce($projectId: String!, $cwd: String!) {
|
|
@@ -576,7 +572,7 @@ ${i.map(a=>{let l=a.workflow;return l==null?` [intent] (${a.id}) ${a.label??""}
|
|
|
576
572
|
}
|
|
577
573
|
}
|
|
578
574
|
}
|
|
579
|
-
`),ls=E("Stop",async e=>{let{cwd:t}=e;if(!x(t)
|
|
575
|
+
`),ls=E("Stop",async e=>{let{cwd:t}=e;if(!x(t)||!T(t))return;let r=Be(t),n=We(t,"stop-enforce")===r;if(n&&!e.stop_hook_active)return;let o=Bg(t),i=await Wg(t,o);if(Me(t,"stop-enforce",r),i.length!==0)return n&&e.stop_hook_active?{continue:!1,stopReason:`Stop-enforce: same repo state across consecutive stop attempts; agent appears stuck. Errors:
|
|
580
576
|
${i.join(`
|
|
581
577
|
|
|
582
578
|
`)}`}:{decision:"block",reason:i.join(`
|
|
@@ -591,7 +587,7 @@ ${a}`)}return`--- Exhaustiveness ---
|
|
|
591
587
|
${s.join(`
|
|
592
588
|
|
|
593
589
|
`)}
|
|
594
|
-
${w("create")}`}async function qg(e){let t;try{t=
|
|
590
|
+
${w("create")}`}async function qg(e){let t;try{t=D(e)}catch{return{error:null,scopedSlugsToRun:[]}}let n=(await y({config:t,document:Hg,variables:{cwd:t.cwd,projectId:t.projectId}}).catch(()=>null))?.project?.devSession?.scopeItems??[],o=n.flatMap(a=>{let l=a.workflow;return l==null?[` [intent] ${a.label??"(no label)"} \u2014 stub a test for this flow`]:l.spec==null?[` [stub] ${l.slug} \u2014 implement \`${l.name}\``]:[]}),i=n.flatMap(a=>a.workflow?.spec==null?[]:[a.workflow.slug]);return{error:o.length===0?null:`--- Testing Scope ---
|
|
595
591
|
${o.join(`
|
|
596
592
|
`)}
|
|
597
593
|
${w("create")}`,scopedSlugsToRun:i}}function zg(e,t){let{diagnostics:r}=De(e.result),n=new Set(e.builder.getUnimplemented().tests),o=t.filter(a=>n.has(a));if(r.length===0&&o.length===0)return null;let i=r.map(a=>{let l=a.step==null?"":` at "${a.step}"`;return` [${a.rule}]${l} ${a.test}: ${a.message}`}),s=o.map(a=>` [not-implemented] ${a} is still marked .notImplemented()`);return`--- Ripplo Lint ---
|
|
@@ -604,9 +600,9 @@ ${w("create")}`}function Kg(e,t){if(t.length===0)return null;let r=Qg(["run",...
|
|
|
604
600
|
`).filter(o=>/FAILED/.test(o)).join(`
|
|
605
601
|
`);return n.length===0?null:`--- Ripplo Run Failures (${t.join(" ")}) ---
|
|
606
602
|
${n}
|
|
607
|
-
Artifacts: .ripplo/debug/<runId>/. ${w("debug")}`}var Jg=Gt.object({status:Gt.number().nullish(),stderr:Gt.unknown().optional(),stdout:Gt.unknown().optional()});function as(e){return e instanceof Buffer?e.toString("utf8"):typeof e=="string"?e:""}function Qg(e,t){let r=ss.argv[1];if(r==null)return{code:1,output:""};try{return{code:0,output:Ug(ss.execPath,[r,...e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}}catch(n){let o=Jg.safeParse(n);if(!o.success)return{code:1,output:""};let i=`${as(o.data.stdout)}${as(o.data.stderr)}`;return{code:o.data.status??1,output:i}}}import{z as cs}from"zod";var Yg=cs.looseObject({skill:cs.string()}),
|
|
603
|
+
Artifacts: .ripplo/debug/<runId>/. ${w("debug")}`}var Jg=Gt.object({status:Gt.number().nullish(),stderr:Gt.unknown().optional(),stdout:Gt.unknown().optional()});function as(e){return e instanceof Buffer?e.toString("utf8"):typeof e=="string"?e:""}function Qg(e,t){let r=ss.argv[1];if(r==null)return{code:1,output:""};try{return{code:0,output:Ug(ss.execPath,[r,...e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}}catch(n){let o=Jg.safeParse(n);if(!o.success)return{code:1,output:""};let i=`${as(o.data.stdout)}${as(o.data.stderr)}`;return{code:o.data.status??1,output:i}}}import{z as cs}from"zod";var Yg=cs.looseObject({skill:cs.string()}),ds=E("PostToolUse",e=>{if(e.tool_name!=="Skill")return;let t=Yg.safeParse(e.tool_input);if(!t.success)return;let r=/^ripplo:(.+)$/.exec(t.data.skill);if(r==null)return;let n=r[1];n!=null&&x(e.cwd)&&zi(e.cwd,e.session_id,n)});ay();fn(process.cwd());var us={"coverage-nudge":Di,"exit-plan-gate":_i,"plan-reminder":Ui,"post-edit-flag-stubs":Hi,"post-edit-lint":Wi,"pre-bash-hooks-pause-gate":qi,"pre-bash-run-gate":Qi,"pre-edit-ripplo-skill-gate":Xi,"pre-edit-scope-gate":ts,"pre-edit-watch-gate":ns,"scope-reminder":os,"session-preamble":is,"stop-enforce":ls,"track-skill-load":ds};async function ey(){await Xg(Zg(process.argv)).scriptName("ripplo").version("0.4.13").command("watch","Watch for run requests and execute locally",()=>{},()=>xi()).command("auth <subcommand>","Manage authentication",sy).command("projects <subcommand>","Inspect Ripplo projects",iy).command("hooks <subcommand>","Pause or resume Ripplo hooks",oy).command("init","Scaffold .ripplo/ in this project",e=>e.option("project",{type:"string"}).option("env",{type:"string"}).option("app-url",{type:"string"}).option("engine-url",{type:"string"}),e=>yi({appUrl:e["app-url"],engineUrl:e["engine-url"],envFile:e.env,projectId:e.project})).command("run [ids..]","Run tests in parallel",e=>{let t=[];return e.positional("ids",{array:!0,default:t,describe:"Test ids to run (all if omitted)",type:"string"})},e=>ki(e.ids)).command("lint [ids..]","Compile and lint tests (all or specific ids)",e=>{let t=[];return e.positional("ids",{array:!0,default:t,describe:"Test ids to lint (all if omitted)",type:"string"}).option("require-implemented",{array:!0,default:t,describe:"Test ids that must not be .notImplemented() \u2014 fails if any still are",type:"string"})},e=>bi({ids:e.ids,requireImplemented:e["require-implemented"]})).command("flake-detect <id>","Run N times to detect flakiness",e=>e.positional("id",{demandOption:!0,type:"string"}).option("runs",{default:10,type:"number"}),e=>li({id:e.id,runs:e.runs})).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>Si()).command("compile","Compile the DSL and write .ripplo/ripplo.lock",e=>e.option("check",{default:!1,describe:"Exit non-zero if the lockfile is missing or stale (does not write)",type:"boolean"}),e=>Vo({check:e.check})).command("cover","Audit all coverage statements",()=>{},()=>Mo()).command("doctor","Check project health",()=>{},()=>oi()).command("status","Report unimplemented tests and preconditions",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>ji({format:e.format})).command("scope <subcommand>","Manage testing scope",ny).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(us),demandOption:!0,type:"string"}),e=>ty(e.name)).strict().help().parse()}async function ty(e){let t=us[e];t==null&&(process.stderr.write(`Unknown hook: ${e}
|
|
608
604
|
`),process.exit(1));let r=await ry(),n=r.trim()===""?{}:JSON.parse(r),o=await t.run(n);o!=null&&process.stdout.write(JSON.stringify(o))}function ry(){return new Promise((e,t)=>{if(process.stdin.isTTY){e("");return}let r=[];process.stdin.on("data",n=>r.push(n)),process.stdin.on("end",()=>{e(Buffer.concat(r).toString("utf8"))}),process.stdin.on("error",t)})}ey().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
609
|
-
`),process.exit(1)});function ny(e){return e.command("status","Print the current scope",t=>t.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),t=>Ci({format:t.format})).command("add <test-ids..>","Bind one or more existing tests (stubs or implemented) to scope as agent intent",t=>{let r=[];return t.positional("test-ids",{array:!0,default:r,demandOption:!0,describe:"Slugs of existing workflows",type:"string"})},t=>Ei({testIds:t["test-ids"]})).command("link <id> <test-id>","Link an existing scope item to a test",t=>t.positional("id",{demandOption:!0,describe:"Scope item id",type:"string"}).positional("test-id",{demandOption:!0,describe:"Slug of the workflow to link",type:"string"}),t=>
|
|
605
|
+
`),process.exit(1)});function ny(e){return e.command("status","Print the current scope",t=>t.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),t=>Ci({format:t.format})).command("add <test-ids..>","Bind one or more existing tests (stubs or implemented) to scope as agent intent",t=>{let r=[];return t.positional("test-ids",{array:!0,default:r,demandOption:!0,describe:"Slugs of existing workflows",type:"string"})},t=>Ei({testIds:t["test-ids"]})).command("link <id> <test-id>","Link an existing scope item to a test",t=>t.positional("id",{demandOption:!0,describe:"Scope item id",type:"string"}).positional("test-id",{demandOption:!0,describe:"Slug of the workflow to link",type:"string"}),t=>Ai({id:t.id,testId:t["test-id"]})).command("remove <ids..>","Remove one or more scope items by id",t=>{let r=[];return t.positional("ids",{array:!0,default:r,demandOption:!0,describe:"Scope item ids",type:"string"})},t=>Ii({ids:t.ids})).demandCommand(1)}function oy(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>ci()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>di()).demandCommand(1)}function iy(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>vi()).demandCommand(1)}function sy(e){return e.command("login","Authenticate via device flow",()=>{},()=>po()).command("status","Show authentication status",()=>{},()=>mo()).command("logout","Remove the saved token",()=>{},()=>{fo()}).demandCommand(1)}function ay(){let e=process.cwd(),t=Jt(e);t!=null&&t!==e&&(process.chdir(t),process.stderr.write(`ripplo: resolved .ripplo/ at ${t}
|
|
610
606
|
`))}export{ey as main};
|
|
611
607
|
/*! Bundled license information:
|
|
612
608
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ripplo",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"description": "CLI for Ripplo — AI-powered end-to-end testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://ripplo.ai",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@ripplo/eslint-config": "0.0.0",
|
|
51
51
|
"@ripplo/runtime": "^0.0.0",
|
|
52
52
|
"@ripplo/graphql": "^0.0.0",
|
|
53
|
-
"@ripplo/
|
|
54
|
-
"@ripplo/
|
|
53
|
+
"@ripplo/spec": "^0.0.0",
|
|
54
|
+
"@ripplo/testing": "^0.4.4"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "tsx watch src/index.ts",
|