ripplo 0.11.2 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{chunk-22KCYZGP.js → chunk-37NZ5HM2.js} +1 -1
  2. package/dist/{chunk-UNYR7SAP.js → chunk-4GIORBIH.js} +1 -1
  3. package/dist/{chunk-7BLJ6357.js → chunk-5JD26R53.js} +1 -1
  4. package/dist/chunk-7E3AM2KY.js +83 -0
  5. package/dist/{chunk-GL66NIOQ.js → chunk-BOMK6ZXG.js} +1 -1
  6. package/dist/{chunk-XJRG46JA.js → chunk-C63HR3XQ.js} +1 -1
  7. package/dist/{chunk-ISLXOVJF.js → chunk-CAGQ4M2W.js} +1 -1
  8. package/dist/{chunk-2QZIICHO.js → chunk-D5F6DIXU.js} +1 -1
  9. package/dist/{chunk-CEUZS5YN.js → chunk-FAYHW72O.js} +1 -1
  10. package/dist/{chunk-6HGQIP4L.js → chunk-GMOMT4D5.js} +1 -1
  11. package/dist/{chunk-TROVQD5M.js → chunk-IUEJNPB6.js} +1 -1
  12. package/dist/{chunk-XA4ZWH7N.js → chunk-JTML352F.js} +2 -2
  13. package/dist/{chunk-XSO43S23.js → chunk-K4GNKQB5.js} +1 -1
  14. package/dist/{chunk-WZBHHW7X.js → chunk-KGCLJTPO.js} +21 -21
  15. package/dist/{chunk-XPPUVBTI.js → chunk-MBQEVGUG.js} +1 -1
  16. package/dist/{chunk-LFBAW3EA.js → chunk-NAXGHRI7.js} +1 -1
  17. package/dist/chunk-NRJUY625.js +360 -0
  18. package/dist/{chunk-LBSM7G4L.js → chunk-TLSVFIET.js} +1 -1
  19. package/dist/{chunk-TDIT65FZ.js → chunk-XUZZKRZB.js} +1 -1
  20. package/dist/{cli-error-VML3CZTB.js → cli-error-UKCCFGND.js} +1 -1
  21. package/dist/{compile-write-AWMMKBY4.js → compile-write-HYPPASGM.js} +1 -1
  22. package/dist/{daemon-2LB22RRW.js → daemon-FPJC6UTS.js} +1 -1
  23. package/dist/{daemon-RDOVYYAZ.js → daemon-JCI3PIF2.js} +1 -1
  24. package/dist/{dsl-loader-GZILSBK5.js → dsl-loader-3PR7GLST.js} +1 -1
  25. package/dist/hook.js +1 -1
  26. package/dist/index.js +181 -208
  27. package/dist/{plan-reminder-V7RZXP37.js → plan-reminder-5IW6CHBL.js} +1 -1
  28. package/dist/{post-edit-D6EBGSYK.js → post-edit-FXAZHTN6.js} +1 -1
  29. package/dist/post-edit-analyze-ZSZ6AO3U.js +4 -0
  30. package/dist/{post-edit-flag-stubs-CGV4LWX2.js → post-edit-flag-stubs-QMRDE3JW.js} +1 -1
  31. package/dist/pre-bash-run-gate-CDFNAIK3.js +4 -0
  32. package/dist/{pre-edit-MPV73OUC.js → pre-edit-PGV7XSGT.js} +1 -1
  33. package/dist/{pre-edit-watch-gate-BXICNZNF.js → pre-edit-watch-gate-DQD7CWGN.js} +1 -1
  34. package/dist/{prompt-submit-DO3YGL4V.js → prompt-submit-PC4QIGY3.js} +1 -1
  35. package/dist/status-VQ57DB6M.js +4 -0
  36. package/dist/{stop-enforce-CEUM4LIV.js → stop-enforce-U7PURAF5.js} +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-2V4XEAR4.js +0 -360
  39. package/dist/chunk-6PEFUZNO.js +0 -83
  40. package/dist/post-edit-analyze-NSUCATEN.js +0 -4
  41. package/dist/pre-bash-run-gate-MIEM2DBB.js +0 -4
  42. package/dist/status-4LFECRO4.js +0 -4
package/dist/index.js CHANGED
@@ -1,37 +1,37 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __ripploCreateRequire } from "node:module";
3
3
  const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
4
- import{a as ht}from"./chunk-UNYR7SAP.js";import{B as ct,C as Q,E as pt,F as mt,G as ft,L as gt,M as yt,N as kt,O as wt,R as bt,S as Xe,a as Gn,b as Jn,c as Qn,d as Zn,e as Je,f as Xn,g as et,h as rt,k as nt,l as tt,m as ot,n as it,o as st,p as at,q as lt,r as dt,t as ut,z as Ze}from"./chunk-2V4XEAR4.js";import{j as Qe,k as Yn}from"./chunk-22KCYZGP.js";import{a as xn,b as Cn,d as Rn,e as $n,f as En,g as Pn,h as In,i as An,j as Tn,k as jn,l as Mn,m as Ln,n as Nn}from"./chunk-47LLHHJH.js";import{a as Dn,c as Ge,d as Un,e as Bn,f as qn,g as Hn,h as be}from"./chunk-LBSM7G4L.js";import{b as On,c as Fn,d as Wn,f as _n}from"./chunk-6HGQIP4L.js";import{b as we,c as O}from"./chunk-XJRG46JA.js";import{a as zn,b as S}from"./chunk-XSO43S23.js";import{b as oe,c as kn,e as he,f as wn}from"./chunk-LFBAW3EA.js";import{a as ye,b as Sn,c as ke}from"./chunk-ISLXOVJF.js";import{a as j}from"./chunk-OQ6KNYPG.js";import{a as J,b as bn,c as Ke,d as vn}from"./chunk-TROVQD5M.js";import{a as R,b as hn,c as y}from"./chunk-JS3DLVVI.js";import{a as Ir,b as Vn,c as Kn}from"./chunk-XA4ZWH7N.js";import{a as b}from"./chunk-R4ZTRVDQ.js";import{b as Ar,c as ne,d as Tr,e as jr}from"./chunk-FEHVIHVA.js";import{a as C}from"./chunk-MHNGR6M7.js";import"./chunk-KOKEEAEF.js";import{b as fn,h as gn,j as G,m as yn}from"./chunk-GL66NIOQ.js";import{C as tn,D as on,G as ze,M as fe,Q as sn,R as an,T as ln,V as dn,W as un,Y as cn,Z as ge,_ as pn,ba as mn,d as z,e as c,f as Xr,g as Yr,l as Ve,n as K,o as en,p as rn,r as nn}from"./chunk-6PEFUZNO.js";import{f as te,i as Zr,j as V,l as pe,m as me}from"./chunk-2QZIICHO.js";import{Ba as Qr,S as zr,T as N,X as H,Y as Kr,Z as D,aa as Gr,oa as T,pa as Jr,s as Vr}from"./chunk-WZBHHW7X.js";import{a as Hr}from"./chunk-7WZ3VIUU.js";import{b as qr,e as He}from"./chunk-KH4QH23U.js";import"./chunk-RIASQHPG.js";import{a as Mr,b as Lr,c as Nr,d,f as q,g as Or,i as Fr,k as P,l as Wr,m as _r,n as qe,o as Dr,p as Ur,q as Br}from"./chunk-C7SV6AR2.js";import{b as ce}from"./chunk-HEOMRXZE.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import bp from"update-notifier";import vp from"yargs";import{hideBin as Sp}from"yargs/helpers";function ve({current:e,latest:r}){return r==null?`ripplo v${e} (latest: unknown)`:r===e?`ripplo v${e} (latest)`:`ripplo v${e} (latest: v${r} \u2014 run \`npx ripplo update\`)`}function vt(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as qs}from"gql.tada";import{exec as Ls}from"child_process";import{createAuthClient as js}from"better-auth/client";import{deviceAuthorizationClient as Ms}from"better-auth/client/plugins";function St({baseURL:e}){return js({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Ms()]})}import{err as xt,ok as Ns}from"neverthrow";var Os=5e3,Ct="ripplo-cli";async function Rt({onDeviceCode:e,url:r}){let n=r??hn().RIPPLO_SERVER_URL,t=St({baseURL:n}),o=await t.device.code({client_id:Ct});if(o.error!=null)return xt({description:o.error.error_description,kind:"oauth-device-code-failed"});let{device_code:i,user_code:s,verification_uri_complete:a}=o.data;return e({userCode:s,verificationUrl:a}),Bs(a),(await Fs({authClient:t,deviceCode:i})).map(u=>(Wr({serverUrl:n,token:u}),u))}async function Fs({authClient:e,deviceCode:r}){for(;;){await Ds(Os);let n=await e.device.token({client_id:Ct,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return Ns(n.data.access_token);if(n.error==null)continue;if(!_s(n.error.error))return xt({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var Ws=new Set(["authorization_pending","slow_down"]);function _s(e){return Ws.has(e)}function Ds(e){return new Promise(r=>{setTimeout(r,e)})}function Us(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function Bs(e){let r=Us();Ls(`${r} "${e}"`,()=>{})}function M({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var Hs=qs(`
4
+ import{a as bt}from"./chunk-4GIORBIH.js";import{B as ft,C as Q,E as gt,F as yt,G as ht,L as kt,M as wt,N as vt,O as St,R as xt,S as Ye,a as Zn,b as Xn,c as Yn,d as et,e as Qe,f as rt,g as tt,h as ot,k as it,l as st,m as at,n as lt,o as dt,p as ct,q as ut,r as pt,t as mt,z as Xe}from"./chunk-NRJUY625.js";import{j as Ze,k as nt}from"./chunk-37NZ5HM2.js";import{a as $n,b as En,d as Pn,e as In,f as An,g as Tn,h as jn,i as Mn,j as Ln,k as Nn,l as On,m as Fn,n as Wn}from"./chunk-47LLHHJH.js";import{a as Bn,c as Je,d as Hn,e as Vn,f as zn,g as Kn,h as be}from"./chunk-TLSVFIET.js";import{b as Dn,c as _n,d as Un,f as qn}from"./chunk-GMOMT4D5.js";import{b as we,c as O}from"./chunk-C63HR3XQ.js";import{a as Jn,b as S}from"./chunk-K4GNKQB5.js";import{b as oe,c as vn,e as he,f as Sn}from"./chunk-NAXGHRI7.js";import{a as ye,b as Cn,c as ke}from"./chunk-CAGQ4M2W.js";import{a as j}from"./chunk-OQ6KNYPG.js";import{a as J,b as xn,c as Ge,d as Rn}from"./chunk-IUEJNPB6.js";import{a as C,b as bn,c as y}from"./chunk-JS3DLVVI.js";import{a as Ar,b as Gn,c as Qn}from"./chunk-JTML352F.js";import{a as w}from"./chunk-R4ZTRVDQ.js";import{b as Tr,c as ne,d as jr,e as Mr}from"./chunk-FEHVIHVA.js";import{a as R}from"./chunk-MHNGR6M7.js";import"./chunk-KOKEEAEF.js";import{b as hn,h as kn,j as G,m as wn}from"./chunk-BOMK6ZXG.js";import{$ as gn,D as an,E as ln,H as Ke,N as fe,R as dn,S as cn,U as un,W as pn,X as mn,Z as fn,_ as ge,ca as yn,e as z,f as u,g as rn,h as nn,m as ze,o as K,p as tn,q as on,s as sn}from"./chunk-7E3AM2KY.js";import{f as te,i as en,j as V,l as pe,m as me}from"./chunk-D5F6DIXU.js";import{Ca as Xr,Ga as Yr,T as Kr,U as N,Y as H,Z as Gr,_,ba as Jr,da as Qr,ra as T,sa as Zr,t as zr}from"./chunk-KGCLJTPO.js";import{a as Vr}from"./chunk-7WZ3VIUU.js";import{b as Hr,e as Ve}from"./chunk-KH4QH23U.js";import"./chunk-RIASQHPG.js";import{a as Lr,b as Nr,c as Or,d,f as B,g as Fr,i as Wr,k as P,l as Dr,m as _r,n as He,o as Ur,p as qr,q as Br}from"./chunk-C7SV6AR2.js";import{b as ue}from"./chunk-HEOMRXZE.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import wp from"update-notifier";import bp from"yargs";import{hideBin as vp}from"yargs/helpers";function ve({current:e,latest:r}){return r==null?`ripplo v${e} (latest: unknown)`:r===e?`ripplo v${e} (latest)`:`ripplo v${e} (latest: v${r} \u2014 run \`npx ripplo update\`)`}function Rt(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as Hs}from"gql.tada";import{exec as Ns}from"child_process";import{createAuthClient as Ms}from"better-auth/client";import{deviceAuthorizationClient as Ls}from"better-auth/client/plugins";function Ct({baseURL:e}){return Ms({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Ls()]})}import{err as $t,ok as Os}from"neverthrow";var Fs=5e3,Et="ripplo-cli";async function Pt({onDeviceCode:e,url:r}){let n=r??bn().RIPPLO_SERVER_URL,t=Ct({baseURL:n}),o=await t.device.code({client_id:Et});if(o.error!=null)return $t({description:o.error.error_description,kind:"oauth-device-code-failed"});let{device_code:i,user_code:s,verification_uri_complete:a}=o.data;return e({userCode:s,verificationUrl:a}),Bs(a),(await Ws({authClient:t,deviceCode:i})).map(c=>(Dr({serverUrl:n,token:c}),c))}async function Ws({authClient:e,deviceCode:r}){for(;;){await Us(Fs);let n=await e.device.token({client_id:Et,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return Os(n.data.access_token);if(n.error==null)continue;if(!_s(n.error.error))return $t({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var Ds=new Set(["authorization_pending","slow_down"]);function _s(e){return Ds.has(e)}function Us(e){return new Promise(r=>{setTimeout(r,e)})}function qs(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function Bs(e){let r=qs();Ns(`${r} "${e}"`,()=>{})}function M({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var Vs=Hs(`
5
5
  query AuthViewer {
6
6
  currentUser {
7
7
  name
8
8
  email
9
9
  }
10
10
  }
11
- `);async function $t(){let e=R(),r=P(e);if(r!=null&&await Vs(e,r))return;let t=(await Rt({url:e,onDeviceCode:a=>{process.stdout.write(`Opening your browser to finish sign-in.
11
+ `);async function It(){let e=C(),r=P(e);if(r!=null&&await zs(e,r))return;let t=(await Pt({url:e,onDeviceCode:a=>{process.stdout.write(`Opening your browser to finish sign-in.
12
12
  `),process.stdout.write(`If it didn't open, visit: ${a.verificationUrl}
13
13
  `),process.stdout.write(`Verification code: ${a.userCode}
14
14
 
15
15
  `),process.stdout.write(`Waiting for approval...
16
16
  `)}})).match(a=>a,a=>{process.stderr.write(`${S(a)}
17
- `),process.exit(1)}),o=await Ye({serverUrl:e,token:t}),i=Hr(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
- `),process.stdout.write(o.kind==="ok"?`${s}, ${zs(o.viewer)}.
17
+ `),process.exit(1)}),o=await er({serverUrl:e,token:t}),i=Vr(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
+ `),process.stdout.write(o.kind==="ok"?`${s}, ${Ks(o.viewer)}.
19
19
  `:`${s}.
20
- `),process.stdout.write(`Session saved to ${qe(e)}.
21
- `),i||(process.stdout.write("\nNext: run `npx ripplo setup` to wire Ripplo into this project,\n"),process.stdout.write("or `npx ripplo init` to set it up by hand.\n"))}async function Vs(e,r){let n=await Ye({serverUrl:e,token:r});return n.kind==="ok"?(process.stdout.write(`Already signed in as ${n.viewer.email}. Run \`npx ripplo auth logout\` to switch accounts.
20
+ `),process.stdout.write(`Session saved to ${He(e)}.
21
+ `),i||(process.stdout.write("\nNext: run `npx ripplo setup` to wire Ripplo into this project,\n"),process.stdout.write("or `npx ripplo init` to set it up by hand.\n"))}async function zs(e,r){let n=await er({serverUrl:e,token:r});return n.kind==="ok"?(process.stdout.write(`Already signed in as ${n.viewer.email}. Run \`npx ripplo auth logout\` to switch accounts.
22
22
  `),!0):(n.kind==="unreachable"&&(process.stdout.write(`Could not reach the Ripplo server at ${e} (${n.message}). Your saved session may still be valid \u2014 fix connectivity and retry.
23
23
  `),process.exit(1)),process.stdout.write(`Your session expired \u2014 signing you back in.
24
24
 
25
- `),!1)}async function Et(){let e=R(),r=P(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await Ye({serverUrl:e,token:r});n.kind==="unreachable"&&(process.stdout.write(`Could not reach the Ripplo server at ${e} (${n.message}). The token may still be valid \u2014 check the server / network and retry.
25
+ `),!1)}async function At(){let e=C(),r=P(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await er({serverUrl:e,token:r});n.kind==="unreachable"&&(process.stdout.write(`Could not reach the Ripplo server at ${e} (${n.message}). The token may still be valid \u2014 check the server / network and retry.
26
26
  `),process.exit(1)),n.kind==="rejected"&&(process.stdout.write("Token rejected by the server. Run `npx ripplo auth login` to sign in again.\n"),process.stdout.write(`(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)
27
27
  `),process.exit(1)),process.stdout.write(`Signed in as ${n.viewer.name} <${n.viewer.email}> (${e})
28
- `)}function Pt(){let e=R();if(!_r(e)){process.stdout.write(`Already signed out.
29
- `);return}process.stdout.write(`Signed out. Removed ${qe(e)}.
30
- `)}async function Ye({serverUrl:e,token:r}){try{let t=(await d({config:M({serverUrl:e,token:r}),document:Hs,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return Nr(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function zs(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as Ks,writeFile as Gs}from"fs/promises";import Js from"path";async function It(e){let r=process.cwd(),n=await me(r);n.isErr()&&Se(J(n.error));let t=n.value,o=ye({cwd:r,lockfile:t});o.length>0&&Se(ke(o));let i=await G(r,t),s=zr(T,i),a=Js.join(r,V);if(e.check){await Qs(a,i);return}await Gs(a,s),Zr(r,s),Xs(i)}function Se(e){process.stderr.write(`${e}
31
- `),process.exit(1)}async function Qs(e,r){let n=await Ks(e,"utf8").catch(()=>null);n==null&&Se(Ke("missing")),Zs(n,r)||Se(Ke("stale")),process.stdout.write(`${bn()}
32
- `)}function Zs(e,r){try{let n=N(T,e);return n.checks==null?!1:fn(n,r)}catch{return!1}}function Xs(e){let r=e.workflows.reduce((t,o)=>t+o.tests.length,0),n=[vn(),Sn(r)];process.stdout.write(`${n.join(`
28
+ `)}function Tt(){let e=C();if(!_r(e)){process.stdout.write(`Already signed out.
29
+ `);return}process.stdout.write(`Signed out. Removed ${He(e)}.
30
+ `)}async function er({serverUrl:e,token:r}){try{let t=(await d({config:M({serverUrl:e,token:r}),document:Vs,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return Or(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function Ks(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as Gs,writeFile as Js}from"fs/promises";import Qs from"path";async function jt(e){let r=process.cwd(),n=await me(r);n.isErr()&&Se(J(n.error));let t=n.value,o=ye({cwd:r,lockfile:t});o.length>0&&Se(ke(o));let i=await G(r,t),s=Kr(T,i),a=Qs.join(r,V);if(e.check){await Zs(a,i);return}await Js(a,s),en(r,s),Ys(i)}function Se(e){process.stderr.write(`${e}
31
+ `),process.exit(1)}async function Zs(e,r){let n=await Gs(e,"utf8").catch(()=>null);n==null&&Se(Ge("missing")),Xs(n,r)||Se(Ge("stale")),process.stdout.write(`${xn()}
32
+ `)}function Xs(e,r){try{let n=N(T,e);return n.checks==null?!1:hn(n,r)}catch{return!1}}function Ys(e){let r=e.workflows.reduce((t,o)=>t+o.tests.length,0),n=[Rn(),Cn(r)];process.stdout.write(`${n.join(`
33
33
  `)}
34
- `)}import{graphql as At}from"gql.tada";function er(e){return e==null?"Max local concurrent runs: unknown (not signed in?)":`Max local concurrent runs: ${String(e)} (the daemon applies changes live)`}import{graphql as Ys}from"gql.tada";var ea=Ys(`
34
+ `)}import{graphql as Mt}from"gql.tada";function rr(e){return e==null?"Max local concurrent runs: unknown (not signed in?)":`Max local concurrent runs: ${String(e)} (the daemon applies changes live)`}import{graphql as ea}from"gql.tada";var ra=ea(`
35
35
  query DevSessionCheckPreflight($projectId: String!, $cwd: String!) {
36
36
  project(id: $projectId) {
37
37
  id
@@ -40,69 +40,69 @@ import{a as ht}from"./chunk-UNYR7SAP.js";import{B as ct,C as Q,E as pt,F as mt,G
40
40
  }
41
41
  }
42
42
  }
43
- `);function w(){return y(process.cwd()).match(e=>e,e=>{process.stderr.write(`${S(e)}
44
- `),process.stderr.write(`${C("setup")}
45
- `),process.exit(1)})}async function x(e){(await d({config:e,document:ea,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession==null&&(process.stderr.write("No active dev session. Start `npx ripplo daemon` 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(`${C("setup")}
46
- `),process.exit(1))}var ra=At(`
43
+ `);function b(){return y(process.cwd()).match(e=>e,e=>{process.stderr.write(`${S(e)}
44
+ `),process.stderr.write(`${R("setup")}
45
+ `),process.exit(1)})}async function x(e){(await d({config:e,document:ra,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession==null&&(process.stderr.write("No active dev session. Start `npx ripplo daemon` 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(`${R("setup")}
46
+ `),process.exit(1))}var na=Mt(`
47
47
  mutation CliUpdateMaxLocalConcurrentRuns($value: Int!) {
48
48
  updateMaxLocalConcurrentRuns(value: $value) {
49
49
  id
50
50
  maxLocalConcurrentRuns
51
51
  }
52
52
  }
53
- `),na=At(`
53
+ `),ta=Mt(`
54
54
  query CliMaxLocalConcurrentRuns {
55
55
  currentUser {
56
56
  id
57
57
  maxLocalConcurrentRuns
58
58
  }
59
59
  }
60
- `);async function Tt({value:e}){let r=w();if(e==null){let t=await d({config:r,document:na,variables:{}});process.stdout.write(`${er(t.currentUser?.maxLocalConcurrentRuns)}
61
- `);return}let n=await d({config:r,document:ra,variables:{value:e}});process.stdout.write(`${er(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
- `)}function jt(e){return e.status==="match"?"\u2713 Webhook secret: your app and Ripplo agree":e.status==="missing-local"?"! Webhook secret: RIPPLO_WEBHOOK_SECRET is not set \u2014 the engine adapter needs it to verify Ripplo's calls":e.status==="unknown"?"! Webhook secret: could not read this project's secret from Ripplo, so a mismatch would not be caught here":`\u2717 Webhook secret: RIPPLO_WEBHOOK_SECRET does not match the secret Ripplo holds for this project (${ta(e)}). Local runs still pass because your app verifies against the same local value, but cloud runs will be rejected. Copy the secret from the project settings into your env file.`}function ta(e){let r=e.localFingerprint??"unset",n=e.serverFingerprint??"unknown";return`yours ${r}, Ripplo's ${n}`}function Mt(e){switch(e.type){case"settings":return oa(e);case"env-files":return ia(e);case"token":return sa(e);case"dev-server":return aa(e);case"dev-session":return Jn(e);case"state-sources":return la(e);case"webhook-verification":return da(e);case"model-validation":return ua(e);case"workflows":return ca(e);case"browser":return ma(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 fa(e);case"lockfile":return ga(e);case"pre-commit-hook":return ya(e);case"plugin-version":return ha(e);case"stale-build":return ka(e);case"webhook-secret":return jt(e)}}function oa(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function ia(e){return e.missing.length===0?"\u2713 Env files: declared files present":`\u2717 Env files: declared in .ripplo/project.json but missing:
60
+ `);async function Lt({value:e}){let r=b();if(e==null){let t=await d({config:r,document:ta,variables:{}});process.stdout.write(`${rr(t.currentUser?.maxLocalConcurrentRuns)}
61
+ `);return}let n=await d({config:r,document:na,variables:{value:e}});process.stdout.write(`${rr(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
+ `)}function Nt(e){return e.status==="match"?"\u2713 Webhook secret: your app and Ripplo agree":e.status==="missing-local"?"! Webhook secret: RIPPLO_WEBHOOK_SECRET is not set \u2014 the engine adapter needs it to verify Ripplo's calls":e.status==="unknown"?"! Webhook secret: could not read this project's secret from Ripplo, so a mismatch would not be caught here":`\u2717 Webhook secret: RIPPLO_WEBHOOK_SECRET does not match the secret Ripplo holds for this project (${oa(e)}). Local runs still pass because your app verifies against the same local value, but cloud runs will be rejected. Copy the secret from the project settings into your env file.`}function oa(e){let r=e.localFingerprint??"unset",n=e.serverFingerprint??"unknown";return`yours ${r}, Ripplo's ${n}`}function Ot(e){switch(e.type){case"settings":return ia(e);case"env-files":return sa(e);case"token":return aa(e);case"dev-server":return la(e);case"dev-session":return Xn(e);case"state-sources":return da(e);case"webhook-verification":return ca(e);case"model-validation":return ua(e);case"workflows":return pa(e);case"browser":return fa(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 ga(e);case"lockfile":return ya(e);case"pre-commit-hook":return ha(e);case"plugin-version":return ka(e);case"stale-build":return wa(e);case"webhook-secret":return Nt(e)}}function ia(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function sa(e){return e.missing.length===0?"\u2713 Env files: declared files present":`\u2717 Env files: declared in .ripplo/project.json but missing:
63
63
  ${e.missing.map(n=>` ${n}`).join(`
64
64
  `)}
65
- In a git worktree? Copy the env file from the main checkout, or symlink to a shared file outside the working tree.`}function sa(e){switch(e.status){case"valid":return`\u2713 Auth: signed in as ${e.email??"unknown"}`;case"missing":return"\u2717 Auth: not signed in. Run `npx ripplo auth login`.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"invalid":return"\u2717 Auth: saved token rejected by the server. Run `npx ripplo auth login` to sign in again.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"unreachable":return`! Auth: could not reach ${R()} to validate the token.`}}function aa(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function la(e){return e.count===0?"! State sources: none use HTTP":e.configured?e.endpointReachable===void 0?`! State sources: ${String(e.count)} use HTTP, but the engine endpoint was not verified`:`\u2713 State sources: ${String(e.count)} HTTP sources configured`:`\u2717 State sources: ${String(e.count)} use HTTP but RIPPLO_ENGINE_URL is not set`}function da(e){return e.rejectsUnsigned?"\u2713 Webhook verification: unsigned requests rejected":"\u2717 Webhook verification: endpoint accepted an unsigned request \u2014 signature verification may be missing or misconfigured."}function ua(e){if(!e.found)return"\u2717 Model: DSL failed to compile";if(e.valid)return"\u2713 Model: valid";let r=e.errors.map(n=>` - ${n.path===""?"":n.path+": "}${n.message}`);return`\u2717 Model: ${String(e.errorCount)} validation error${e.errorCount===1?"":"s"}
65
+ In a git worktree? Copy the env file from the main checkout, or symlink to a shared file outside the working tree.`}function aa(e){switch(e.status){case"valid":return`\u2713 Auth: signed in as ${e.email??"unknown"}`;case"missing":return"\u2717 Auth: not signed in. Run `npx ripplo auth login`.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"invalid":return"\u2717 Auth: saved token rejected by the server. Run `npx ripplo auth login` to sign in again.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"unreachable":return`! Auth: could not reach ${C()} to validate the token.`}}function la(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function da(e){return e.count===0?"! State sources: none use HTTP":e.configured?e.endpointReachable===void 0?`! State sources: ${String(e.count)} use HTTP, but the engine endpoint was not verified`:`\u2713 State sources: ${String(e.count)} HTTP sources configured`:`\u2717 State sources: ${String(e.count)} use HTTP but RIPPLO_ENGINE_URL is not set`}function ca(e){return e.rejectsUnsigned?"\u2713 Webhook verification: unsigned requests rejected":"\u2717 Webhook verification: endpoint accepted an unsigned request \u2014 signature verification may be missing or misconfigured."}function ua(e){if(!e.found)return"\u2717 Model: DSL failed to compile";if(e.valid)return"\u2713 Model: valid";let r=e.errors.map(n=>` - ${n.path===""?"":n.path+": "}${n.message}`);return`\u2717 Model: ${String(e.errorCount)} validation error${e.errorCount===1?"":"s"}
66
66
  ${r.join(`
67
- `)}`}function ca(e){if(e.total===0)return"! Tests: none defined";if(e.invalidNames.length===0)return`\u2713 Tests: ${String(e.total)} valid`;let r=e.invalidWorkflows.map(n=>pa(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
67
+ `)}`}function pa(e){if(e.total===0)return"! Tests: none defined";if(e.invalidNames.length===0)return`\u2713 Tests: ${String(e.total)} valid`;let r=e.invalidWorkflows.map(n=>ma(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
68
68
  ${r.join(`
69
- `)}`}function pa(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
69
+ `)}`}function ma(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
70
70
  `+r.join(`
71
- `)}function ma(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function fa(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 ga(e){switch(e.status){case"match":return`\u2713 Lockfile: ${V} is up to date`;case"missing":return`\u2717 Lockfile: ${V} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${V} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function ya(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 ha(e){return e.installed===e.cliVersion?`\u2713 Claude plugin: v${e.installed} matches CLI`:`! Claude plugin: installed v${e.installed}, CLI v${e.cliVersion} \u2014 run \`npx ripplo update\` (or /plugin in Claude Code)`}function ka(e){return e.freshness.kind==="foreign-binary"?"! Build: running a ripplo binary from outside this workspace \u2014 its bundle may not match your source. Run `npx ripplo` from this workspace after `pnpm build`.":e.freshness.kind==="stale"?`! Build: source is newer than the built bundles (${e.freshness.packages.join(", ")}) \u2014 the daemon and engine may be serving stale code. Run \`pnpm build\`, then \`npx ripplo daemon stop\` and start it again.`:"\u2713 Build: bundles up to date"}import Ce from"fs";import Pa from"os";import rr from"path";import{z as F}from"zod";import wa from"latest-version";import Lt from"semver";async function xe(e){try{return await Promise.race([wa("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function Nt(e){return e.filter(r=>Lt.valid(r)!=null).toSorted(Lt.rcompare)[0]}import{createHash as ba}from"crypto";import{graphql as va}from"gql.tada";var Sa=va(`
71
+ `)}function fa(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function ga(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 ya(e){switch(e.status){case"match":return`\u2713 Lockfile: ${V} is up to date`;case"missing":return`\u2717 Lockfile: ${V} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${V} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function ha(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 ka(e){return e.installed===e.cliVersion?`\u2713 Claude plugin: v${e.installed} matches CLI`:`! Claude plugin: installed v${e.installed}, CLI v${e.cliVersion} \u2014 run \`npx ripplo update\` (or /plugin in Claude Code)`}function wa(e){return e.freshness.kind==="foreign-binary"?"! Build: running a ripplo binary from outside this workspace \u2014 its bundle may not match your source. Run `npx ripplo` from this workspace after `pnpm build`.":e.freshness.kind==="stale"?`! Build: source is newer than the built bundles (${e.freshness.packages.join(", ")}) \u2014 the daemon and engine may be serving stale code. Run \`pnpm build\`, then \`npx ripplo daemon stop\` and start it again.`:"\u2713 Build: bundles up to date"}import Re from"fs";import Ia from"os";import nr from"path";import{z as F}from"zod";import ba from"latest-version";import Ft from"semver";async function xe(e){try{return await Promise.race([ba("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function Wt(e){return e.filter(r=>Ft.valid(r)!=null).toSorted(Ft.rcompare)[0]}import{createHash as va}from"crypto";import{graphql as Sa}from"gql.tada";var xa=Sa(`
72
72
  query ProjectWebhookSecret($projectId: String!) {
73
73
  project(id: $projectId) {
74
74
  id
75
75
  webhookSecret
76
76
  }
77
77
  }
78
- `);async function Ft(e){let r=y(e).unwrapOr(void 0),n=r==null?null:Ot(r.webhookSecret);if(r==null||n==null)return{localFingerprint:null,serverFingerprint:null,status:"missing-local",type:"webhook-secret"};let t=await Ca(r),o=t==null?null:Ot(t);return o==null?{localFingerprint:n,serverFingerprint:null,status:"unknown",type:"webhook-secret"}:{localFingerprint:n,serverFingerprint:o,status:n===o?"match":"drifted",type:"webhook-secret"}}function Ot(e){return e.length===0?null:ba("sha256").update(e).digest("hex").slice(0,xa)}var xa=8;async function Ca(e){return(await d({config:e,document:Sa,variables:{projectId:e.projectId}}).catch(()=>null))?.project?.webhookSecret??null}import{graphql as Ra}from"gql.tada";var $a=Ra(`
78
+ `);async function _t(e){let r=y(e).unwrapOr(void 0),n=r==null?null:Dt(r.webhookSecret);if(r==null||n==null)return{localFingerprint:null,serverFingerprint:null,status:"missing-local",type:"webhook-secret"};let t=await Ca(r),o=t==null?null:Dt(t);return o==null?{localFingerprint:n,serverFingerprint:null,status:"unknown",type:"webhook-secret"}:{localFingerprint:n,serverFingerprint:o,status:n===o?"match":"drifted",type:"webhook-secret"}}function Dt(e){return e.length===0?null:va("sha256").update(e).digest("hex").slice(0,Ra)}var Ra=8;async function Ca(e){return(await d({config:e,document:xa,variables:{projectId:e.projectId}}).catch(()=>null))?.project?.webhookSecret??null}import{graphql as $a}from"gql.tada";var Ea=$a(`
79
79
  query DoctorAuthViewer {
80
80
  currentUser {
81
81
  name
82
82
  email
83
83
  }
84
84
  }
85
- `),Ea="Failed to connect to Ripplo server";async function Wt({serverUrl:e,token:r}){try{let n=await d({config:M({serverUrl:e,token:r}),document:$a,variables:void 0});return n.currentUser==null?{kind:"invalid"}:{email:n.currentUser.email,kind:"valid"}}catch(n){return(n instanceof Error?n.message:String(n)).startsWith(Ea)?{kind:"unreachable"}:{kind:"invalid"}}}function _t(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"state-sources":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"webhook-secret":return e.status==="drifted";case"model-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;case"plugin-version":return!1;case"stale-build":return!1}}async function Dt(e){let r=await ja(e),n={missing:jr(e),type:"env-files"},t=await Ma(),o=await La(),i=await me(e),s=Na(e,i),a=Oa(i),l=await Fa(e,i),u=Wa(e),g=Ta(e),f=Ia(),p=await Ba(r,i);return[r,n,t,...p,s,a,l,u,o,...g==null?[]:[g],...f==null?[]:[f]]}function Ia(){let e=O();return e.kind==="fresh"?null:{freshness:e,type:"stale-build"}}var Aa=F.object({plugins:F.record(F.string(),F.array(F.object({projectPath:F.string().optional(),scope:F.string().optional(),version:F.string()})))});function Ta(e){let r=rr.join(Pa.homedir(),".claude","plugins","installed_plugins.json"),n=Ce.existsSync(r)?Ce.readFileSync(r,"utf8"):null;if(n==null)return null;let t=Aa.safeParse(JSON.parse(n));if(!t.success)return null;let o=Object.entries(t.data.plugins).filter(([s])=>s.startsWith("ripplo@")).flatMap(([,s])=>s).filter(s=>s.scope==="user"||s.projectPath===e).map(s=>s.version),i=Nt(o);return i==null?null:{cliVersion:b(),installed:i,type:"plugin-version"}}async function ja(e){let r=await Zn(e);return r.valid?{missingFields:[],type:"settings",valid:!0}:{missingFields:r.errors.map(t=>t.path).filter(t=>t.length>0),type:"settings",valid:!1}}async function Ma(){let e=R(),r=P(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await Wt({serverUrl:e,token:r});return n.kind==="valid"?{email:n.email,status:"valid",type:"token"}:{email:void 0,status:n.kind,type:"token"}}async function La(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:Ce.existsSync(r),type:"browser"}}function Na(e,r){if(r.isErr())return{errorCount:1,errors:[{message:J(r.error),path:".ripplo/"}],found:!1,type:"model-validation",valid:!1};let n=ye({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:ke(n),path:""}],found:!0,type:"model-validation",valid:n.length===0}}function Oa(e){if(e.isErr())return{invalidNames:[],invalidWorkflows:[],total:0,type:"workflows",valid:0};let r=e.value.workflows.length;return{invalidNames:[],invalidWorkflows:[],total:r,type:"workflows",valid:r}}async function Fa(e,r){return r.isErr()?{status:"missing",type:"lockfile"}:{status:await yn(e,r.value),type:"lockfile"}}function Wa(e){return{installed:_a(e).some(n=>Ua(n).includes("ripplo compile --check")),type:"pre-commit-hook"}}function _a(e){let r=[Da(e)??rr.join(".git","hooks"),".husky"];return[...new Set(r)].map(n=>rr.resolve(e,n,"pre-commit"))}function Da(e){let r=qr(["rev-parse","--git-path","hooks"],e).trim();return r.length===0?void 0:r}function Ua(e){try{return Ce.readFileSync(e,"utf8")}catch{return""}}async function Ba(e,r){let n=Tr().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Je(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await Qn(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await qa(n,r);t.push(...s)}return t}async function qa(e,r){let n=r.isOk()?r.value.state.sources.filter(g=>g.transport==="http").length:0,t=e.engineUrl.length>0,o={configured:t,count:n,endpointReachable:void 0,type:"state-sources"};if(n===0||!t)return[o];let i=Va(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Je(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"state-sources"}),Ut(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await Xn({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let u=await Ha({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:u,type:"adapter-enabled",url:i},await Ft(process.cwd())),a}async function Ha({engineUrl:e,webhookSecret:r}){if(r.length===0)return"no-secret";let n=JSON.stringify({});try{let t=await fetch(`${e}/setup`,{body:n,headers:{"Content-Type":"application/json",...Ur({body:n,secret:r})},method:"PUT",signal:AbortSignal.timeout(5e3)});return t.status===404?"disabled":t.status===401||t.status===403?"bad-secret":"enabled"}catch{return"unreachable"}}function Ut(e){return e.startsWith("http://")||e.startsWith("https://")}function Va(e,r){return Ut(r)?r:`${e}${r}`}var za=3e3;async function Bt(){let e=process.cwd(),[r,n]=await Promise.all([xe(za),Dt(e)]);process.stdout.write(`${ve({current:b(),latest:r})}
86
- `);let t=n.map(i=>Mt(i));process.stdout.write(t.join(`
85
+ `),Pa="Failed to connect to Ripplo server";async function Ut({serverUrl:e,token:r}){try{let n=await d({config:M({serverUrl:e,token:r}),document:Ea,variables:void 0});return n.currentUser==null?{kind:"invalid"}:{email:n.currentUser.email,kind:"valid"}}catch(n){return(n instanceof Error?n.message:String(n)).startsWith(Pa)?{kind:"unreachable"}:{kind:"invalid"}}}function qt(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"state-sources":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"webhook-secret":return e.status==="drifted";case"model-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;case"plugin-version":return!1;case"stale-build":return!1}}async function Bt(e){let r=await Ma(e),n={missing:Mr(e),type:"env-files"},t=await La(),o=await Na(),i=await me(e),s=Oa(e,i),a=Fa(i),l=await Wa(e,i),c=Da(e),g=ja(e),f=Aa(),p=await Ba(r,i);return[r,n,t,...p,s,a,l,c,o,...g==null?[]:[g],...f==null?[]:[f]]}function Aa(){let e=O();return e.kind==="fresh"?null:{freshness:e,type:"stale-build"}}var Ta=F.object({plugins:F.record(F.string(),F.array(F.object({projectPath:F.string().optional(),scope:F.string().optional(),version:F.string()})))});function ja(e){let r=nr.join(Ia.homedir(),".claude","plugins","installed_plugins.json"),n=Re.existsSync(r)?Re.readFileSync(r,"utf8"):null;if(n==null)return null;let t=Ta.safeParse(JSON.parse(n));if(!t.success)return null;let o=Object.entries(t.data.plugins).filter(([s])=>s.startsWith("ripplo@")).flatMap(([,s])=>s).filter(s=>s.scope==="user"||s.projectPath===e).map(s=>s.version),i=Wt(o);return i==null?null:{cliVersion:w(),installed:i,type:"plugin-version"}}async function Ma(e){let r=await et(e);return r.valid?{missingFields:[],type:"settings",valid:!0}:{missingFields:r.errors.map(t=>t.path).filter(t=>t.length>0),type:"settings",valid:!1}}async function La(){let e=C(),r=P(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await Ut({serverUrl:e,token:r});return n.kind==="valid"?{email:n.email,status:"valid",type:"token"}:{email:void 0,status:n.kind,type:"token"}}async function Na(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:Re.existsSync(r),type:"browser"}}function Oa(e,r){if(r.isErr())return{errorCount:1,errors:[{message:J(r.error),path:".ripplo/"}],found:!1,type:"model-validation",valid:!1};let n=ye({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:ke(n),path:""}],found:!0,type:"model-validation",valid:n.length===0}}function Fa(e){if(e.isErr())return{invalidNames:[],invalidWorkflows:[],total:0,type:"workflows",valid:0};let r=e.value.workflows.length;return{invalidNames:[],invalidWorkflows:[],total:r,type:"workflows",valid:r}}async function Wa(e,r){return r.isErr()?{status:"missing",type:"lockfile"}:{status:await wn(e,r.value),type:"lockfile"}}function Da(e){return{installed:_a(e).some(n=>qa(n).includes("ripplo compile --check")),type:"pre-commit-hook"}}function _a(e){let r=[Ua(e)??nr.join(".git","hooks"),".husky"];return[...new Set(r)].map(n=>nr.resolve(e,n,"pre-commit"))}function Ua(e){let r=Hr(["rev-parse","--git-path","hooks"],e).trim();return r.length===0?void 0:r}function qa(e){try{return Re.readFileSync(e,"utf8")}catch{return""}}async function Ba(e,r){let n=jr().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Qe(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await Yn(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await Ha(n,r);t.push(...s)}return t}async function Ha(e,r){let n=r.isOk()?r.value.state.sources.filter(g=>g.transport==="http").length:0,t=e.engineUrl.length>0,o={configured:t,count:n,endpointReachable:void 0,type:"state-sources"};if(n===0||!t)return[o];let i=za(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Qe(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"state-sources"}),Ht(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await rt({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let c=await Va({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:c,type:"adapter-enabled",url:i},await _t(process.cwd())),a}async function Va({engineUrl:e,webhookSecret:r}){if(r.length===0)return"no-secret";let n=JSON.stringify({});try{let t=await fetch(`${e}/setup`,{body:n,headers:{"Content-Type":"application/json",...qr({body:n,secret:r})},method:"PUT",signal:AbortSignal.timeout(5e3)});return t.status===404?"disabled":t.status===401||t.status===403?"bad-secret":"enabled"}catch{return"unreachable"}}function Ht(e){return e.startsWith("http://")||e.startsWith("https://")}function za(e,r){return Ht(r)?r:`${e}${r}`}var Ka=3e3;async function Vt(){let e=process.cwd(),[r,n]=await Promise.all([xe(Ka),Bt(e)]);process.stdout.write(`${ve({current:w(),latest:r})}
86
+ `);let t=n.map(i=>Ot(i));process.stdout.write(t.join(`
87
87
  `)+`
88
- `);let o=n.some(i=>_t(i));process.exit(o?1:0)}import Re from"fs";import{graphql as Ka}from"gql.tada";var Ga=Ka(`
88
+ `);let o=n.some(i=>qt(i));process.exit(o?1:0)}import Ce from"fs";import{graphql as Ga}from"gql.tada";var Ja=Ga(`
89
89
  mutation CliSetHooksPaused($projectId: String!, $paused: Boolean!) {
90
90
  setHooksPaused(projectId: $projectId, paused: $paused) {
91
91
  id
92
92
  }
93
93
  }
94
- `);async function qt(){let e=process.cwd();Fr(e);let r=He(e);if(Re.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}Re.writeFileSync(r,""),await Vt(e,!0),process.stdout.write("Hooks paused. Pre-edit gates and stop enforcement are off until you run `npx ripplo hooks resume`.\n")}async function Ht(){let e=process.cwd(),r=He(e);if(!Re.existsSync(r)){process.stdout.write(`Hooks already active.
95
- `);return}Re.unlinkSync(r),await Vt(e,!1),process.stdout.write(`Hooks resumed.
96
- `)}async function Vt(e,r){let n=y(e).unwrapOr(void 0);n!=null&&await d({config:n,document:Ga,variables:{paused:r,projectId:n.projectId}}).catch(t=>{process.stderr.write(`Warning: could not push hook-pause state to the server (${t instanceof Error?t.message:String(t)}) \u2014 the dashboard may show stale hook status.
97
- `)})}import Z from"fs";import X from"path";import{input as no,select as to}from"@inquirer/prompts";import{graphql as Al}from"gql.tada";import{exec as Ja,execFile as Qa}from"child_process";import{err as Za,ok as zt}from"neverthrow";import m from"fs";import{createRequire as Xa}from"module";import k from"path";import{promisify as Jt}from"util";import{minVersion as Ya}from"semver";import{z as h}from"zod";var el=["ripplo","@ripplo/testing","@ripplo/instrument"],Kt=[h.core.version.major,h.core.version.minor,h.core.version.patch].map(String).join("."),rl=4,Gt=".ripplo/ripplo.lock linguist-generated=true",nl=[".ripplo/debug/",".ripplo/.local/"],tl=h.object({dependencies:h.record(h.string(),h.string()).optional(),devDependencies:h.record(h.string(),h.string()).optional(),optionalDependencies:h.record(h.string(),h.string()).optional(),peerDependencies:h.record(h.string(),h.string()).optional()}),ol=Jt(Ja),il=Jt(Qa);async function Qt({cwd:e,onStep:r}){let n=Yt(e);r("Scaffolding project files..."),hl({cwd:e,zodImportPath:n.importPath}),r("Updating .gitignore..."),wl(e),r("Marking ripplo.lock as generated..."),pl(e),r("Installing dependencies...");let t=b(),o=await al({cwd:e,version:t}),i=[];o.ok||i.push({manualCommand:o.cmd,message:`Couldn't auto-install dev dependencies (${o.reason}). Run the command below, then run \`npx ripplo compile\` to build the lockfile.`});let s=o.ok?Zt(e):void 0;if(s!=null&&s!==t&&i.push({manualCommand:void 0,message:`Installed ripplo ${s}, but ${t} was requested. A registry policy such as pnpm's minimumReleaseAge can silently resolve an older version \u2014 allow the newer version and reinstall so the installed package matches the scaffolded files.`}),o.ok){r("Compiling initial lockfile...");let l=await cl(e);l!=null&&i.push({manualCommand:void 0,message:l})}return r("Setting up browser..."),(await sl()).map(()=>i)}async function sl(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return zt(void 0);q.info("Chromium not found. Installing via Playwright...");let n=Xa(import.meta.url),t=k.dirname(n.resolve("playwright/package.json")),o=k.join(t,"cli.js");return await il(process.execPath,[o,"install","chromium"]),m.existsSync(r)?zt(void 0):Za({kind:"playwright-install-failed"})}async function al({cwd:e,version:r}){let n=nr({cwd:e,pm:tr(e),version:r});q.info("Installing dependencies: %s",n);try{return await ol(n,{cwd:e}),{ok:!0}}catch(t){let o=ul(t);return q.warn("Install failed (%s): %s",n,o),{cmd:n,ok:!1,reason:o}}}var ll=h.object({version:h.string()});function Zt(e){let r=k.join(e,"node_modules","ripplo","package.json");if(!m.existsSync(r)){let n=k.dirname(e);return n===e?void 0:Zt(n)}try{let n=ll.safeParse(JSON.parse(m.readFileSync(r,"utf8")));return n.success?n.data.version:void 0}catch{return}}var dl=h.object({stderr:h.string().optional(),stdout:h.string().optional()});function ul(e){let r=dl.safeParse(e),t=(r.success?[r.data.stderr,r.data.stdout]:[]).flatMap(o=>o==null?[]:o.split(`
98
- `)).map(o=>o.trim()).filter(o=>o.length>0).slice(-rl);return t.length>0?t.join(" "):e instanceof Error?e.message:String(e)}async function cl(e){try{await gn(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function pl(e){let r=k.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes(Gt))return;let t=n.length===0||n.endsWith(`
94
+ `);async function zt(){let e=process.cwd();Wr(e);let r=Ve(e);if(Ce.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}Ce.writeFileSync(r,""),await Gt(e,!0),process.stdout.write("Hooks paused. Pre-edit gates and stop enforcement are off until you run `npx ripplo hooks resume`.\n")}async function Kt(){let e=process.cwd(),r=Ve(e);if(!Ce.existsSync(r)){process.stdout.write(`Hooks already active.
95
+ `);return}Ce.unlinkSync(r),await Gt(e,!1),process.stdout.write(`Hooks resumed.
96
+ `)}async function Gt(e,r){let n=y(e).unwrapOr(void 0);n!=null&&await d({config:n,document:Ja,variables:{paused:r,projectId:n.projectId}}).catch(t=>{process.stderr.write(`Warning: could not push hook-pause state to the server (${t instanceof Error?t.message:String(t)}) \u2014 the dashboard may show stale hook status.
97
+ `)})}import Z from"fs";import X from"path";import{input as io,select as so}from"@inquirer/prompts";import{graphql as Tl}from"gql.tada";import{exec as Qa,execFile as Za}from"child_process";import{err as Xa,ok as Jt}from"neverthrow";import m from"fs";import{createRequire as Ya}from"module";import k from"path";import{promisify as Xt}from"util";import{minVersion as el}from"semver";import{z as h}from"zod";var rl=["ripplo","@ripplo/testing","@ripplo/instrument"],Qt=[h.core.version.major,h.core.version.minor,h.core.version.patch].map(String).join("."),nl=4,Zt=".ripplo/ripplo.lock linguist-generated=true",tl=[".ripplo/debug/",".ripplo/.local/"],ol=h.object({dependencies:h.record(h.string(),h.string()).optional(),devDependencies:h.record(h.string(),h.string()).optional(),optionalDependencies:h.record(h.string(),h.string()).optional(),peerDependencies:h.record(h.string(),h.string()).optional()}),il=Xt(Qa),sl=Xt(Za);async function Yt({cwd:e,onStep:r}){let n=no(e);r("Scaffolding project files..."),kl({cwd:e,zodImportPath:n.importPath}),r("Updating .gitignore..."),bl(e),r("Marking ripplo.lock as generated..."),ml(e),r("Installing dependencies...");let t=w(),o=await ll({cwd:e,version:t}),i=[];o.ok||i.push({manualCommand:o.cmd,message:`Couldn't auto-install dev dependencies (${o.reason}). Run the command below, then run \`npx ripplo compile\` to build the lockfile.`});let s=o.ok?eo(e):void 0;if(s!=null&&s!==t&&i.push({manualCommand:void 0,message:`Installed ripplo ${s}, but ${t} was requested. A registry policy such as pnpm's minimumReleaseAge can silently resolve an older version \u2014 allow the newer version and reinstall so the installed package matches the scaffolded files.`}),o.ok){r("Compiling initial lockfile...");let l=await pl(e);l!=null&&i.push({manualCommand:void 0,message:l})}return r("Setting up browser..."),(await al()).map(()=>i)}async function al(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return Jt(void 0);B.info("Chromium not found. Installing via Playwright...");let n=Ya(import.meta.url),t=k.dirname(n.resolve("playwright/package.json")),o=k.join(t,"cli.js");return await sl(process.execPath,[o,"install","chromium"]),m.existsSync(r)?Jt(void 0):Xa({kind:"playwright-install-failed"})}async function ll({cwd:e,version:r}){let n=tr({cwd:e,pm:or(e),version:r});B.info("Installing dependencies: %s",n);try{return await il(n,{cwd:e}),{ok:!0}}catch(t){let o=ul(t);return B.warn("Install failed (%s): %s",n,o),{cmd:n,ok:!1,reason:o}}}var dl=h.object({version:h.string()});function eo(e){let r=k.join(e,"node_modules","ripplo","package.json");if(!m.existsSync(r)){let n=k.dirname(e);return n===e?void 0:eo(n)}try{let n=dl.safeParse(JSON.parse(m.readFileSync(r,"utf8")));return n.success?n.data.version:void 0}catch{return}}var cl=h.object({stderr:h.string().optional(),stdout:h.string().optional()});function ul(e){let r=cl.safeParse(e),t=(r.success?[r.data.stderr,r.data.stdout]:[]).flatMap(o=>o==null?[]:o.split(`
98
+ `)).map(o=>o.trim()).filter(o=>o.length>0).slice(-nl);return t.length>0?t.join(" "):e instanceof Error?e.message:String(e)}async function pl(e){try{await kn(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function ml(e){let r=k.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes(Zt))return;let t=n.length===0||n.endsWith(`
99
99
  `)?"":`
100
- `;m.writeFileSync(r,`${n}${t}${Gt}
101
- `)}function nr({cwd:e,pm:r,version:n}){let t=el.map(s=>`${s}@${n}`),o=Yt(e),i=[...t,o.installSpec].join(" ");return r==="pnpm"?ml(e)?`pnpm add -wD --save-exact ${i}`:`pnpm add -D --save-exact ${i}`:r==="yarn"?fl({cwd:e,deps:i}):r==="bun"?`bun add -d --exact ${i}`:`npm install -D --save-exact ${i}`}function tr(e){return m.existsSync(k.join(e,"pnpm-lock.yaml"))?"pnpm":m.existsSync(k.join(e,"yarn.lock"))?"yarn":m.existsSync(k.join(e,"bun.lockb"))||m.existsSync(k.join(e,"bun.lock"))?"bun":"npm"}function ml(e){return m.existsSync(k.join(e,"pnpm-workspace.yaml"))||m.existsSync(k.join(e,"pnpm-workspace.yml"))}function fl({cwd:e,deps:r}){return gl(e)?`yarn add -D --exact ${r}`:yl(e)?`yarn add -WD --exact ${r}`:`yarn add -D --exact ${r}`}function gl(e){if(m.existsSync(k.join(e,".yarnrc.yml"))||m.existsSync(k.join(e,".pnp.cjs"))||m.existsSync(k.join(e,".pnp.js")))return!0;let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("packageManager"in n))return!1;let t=n.packageManager;if(typeof t!="string")return!1;let o=/^yarn@(\d+)/.exec(t);return o!=null&&Number(o[1])>=2}catch{return!1}}function yl(e){let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("workspaces"in n))return!1;let t=n.workspaces;return Array.isArray(t)||t!=null&&typeof t=="object"}catch{return!1}}function hl({cwd:e,zodImportPath:r}){let n=k.join(e,".ripplo");Xt({zodImportPath:r}).forEach(({content:t,relPath:o})=>{let i=k.join(n,o);m.mkdirSync(k.dirname(i),{recursive:!0}),kl(i,t)})}function kl(e,r){m.existsSync(e)||m.writeFileSync(e,r)}function wl(e){let r=k.join(e,".gitignore");if(!m.existsSync(r))return;let n=m.readFileSync(r,"utf8"),t=nl.filter(i=>!n.includes(i));if(t.length===0)return;let o=n.endsWith(`
100
+ `;m.writeFileSync(r,`${n}${t}${Zt}
101
+ `)}function tr({cwd:e,pm:r,version:n}){let t=rl.map(s=>`${s}@${n}`),o=no(e),i=[...t,o.installSpec].join(" ");return r==="pnpm"?fl(e)?`pnpm add -wD --save-exact ${i}`:`pnpm add -D --save-exact ${i}`:r==="yarn"?gl({cwd:e,deps:i}):r==="bun"?`bun add -d --exact ${i}`:`npm install -D --save-exact ${i}`}function or(e){return m.existsSync(k.join(e,"pnpm-lock.yaml"))?"pnpm":m.existsSync(k.join(e,"yarn.lock"))?"yarn":m.existsSync(k.join(e,"bun.lockb"))||m.existsSync(k.join(e,"bun.lock"))?"bun":"npm"}function fl(e){return m.existsSync(k.join(e,"pnpm-workspace.yaml"))||m.existsSync(k.join(e,"pnpm-workspace.yml"))}function gl({cwd:e,deps:r}){return yl(e)?`yarn add -D --exact ${r}`:hl(e)?`yarn add -WD --exact ${r}`:`yarn add -D --exact ${r}`}function yl(e){if(m.existsSync(k.join(e,".yarnrc.yml"))||m.existsSync(k.join(e,".pnp.cjs"))||m.existsSync(k.join(e,".pnp.js")))return!0;let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("packageManager"in n))return!1;let t=n.packageManager;if(typeof t!="string")return!1;let o=/^yarn@(\d+)/.exec(t);return o!=null&&Number(o[1])>=2}catch{return!1}}function hl(e){let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("workspaces"in n))return!1;let t=n.workspaces;return Array.isArray(t)||t!=null&&typeof t=="object"}catch{return!1}}function kl({cwd:e,zodImportPath:r}){let n=k.join(e,".ripplo");ro({zodImportPath:r}).forEach(({content:t,relPath:o})=>{let i=k.join(n,o);m.mkdirSync(k.dirname(i),{recursive:!0}),wl(i,t)})}function wl(e,r){m.existsSync(e)||m.writeFileSync(e,r)}function bl(e){let r=k.join(e,".gitignore");if(!m.existsSync(r))return;let n=m.readFileSync(r,"utf8"),t=tl.filter(i=>!n.includes(i));if(t.length===0)return;let o=n.endsWith(`
102
102
  `)?"":`
103
103
  `;m.writeFileSync(r,n+o+t.join(`
104
104
  `)+`
105
- `)}var bl=`import { createRipplo } from "@ripplo/testing";
105
+ `)}var vl=`import { createRipplo } from "@ripplo/testing";
106
106
  import { facts } from "./facts";
107
107
  import { state } from "./state";
108
108
  import { workflows } from "./workflows/index";
@@ -113,7 +113,7 @@ export default createRipplo({
113
113
  viewports: ["desktop", "mobile"],
114
114
  workflows,
115
115
  });
116
- `;function vl(e){return`import { defineState, source } from "@ripplo/testing";
116
+ `;function Sl(e){return`import { defineState, source } from "@ripplo/testing";
117
117
  import { z } from "${e}";
118
118
 
119
119
  export const state = defineState(
@@ -121,8 +121,8 @@ export const state = defineState(
121
121
  app: source.http(z.object({})),
122
122
  }),
123
123
  );
124
- `}var Sl=`export const facts = [] as const;
125
- `,xl=`export const workflows = [] as const;
124
+ `}var xl=`export const facts = [] as const;
125
+ `,Rl=`export const workflows = [] as const;
126
126
  `,Cl=`{
127
127
  "compilerOptions": {
128
128
  "strict": true,
@@ -138,7 +138,7 @@ export const state = defineState(
138
138
  "include": ["*.ts", "workflows/**/*.ts"],
139
139
  "exclude": ["node_modules"]
140
140
  }
141
- `,Rl=`// Guards spec files against shadowing DSL imports \u2014 \`const url = ...\` next to the
141
+ `,$l=`// Guards spec files against shadowing DSL imports \u2014 \`const url = ...\` next to the
142
142
  // imported \`url\` locator silently breaks specs. Requires typescript-eslint (and
143
143
  // ESLint's per-directory config lookup). Delete this file if your lint setup differs.
144
144
  import tseslint from "typescript-eslint";
@@ -152,47 +152,47 @@ export default tseslint.config({
152
152
  },
153
153
  plugins: { "@typescript-eslint": tseslint.plugin },
154
154
  });
155
- `;function Xt({zodImportPath:e}){return[{content:bl,relPath:"index.ts"},{content:vl(e),relPath:"state.ts"},{content:Sl,relPath:"facts.ts"},{content:xl,relPath:"workflows/index.ts"},{content:Cl,relPath:"tsconfig.json"},{content:Rl,relPath:"eslint.config.js"}]}var Bf=Xt({zodImportPath:"zod/v4"});function Yt(e){return $l(e)?{importPath:"zod4",installSpec:`zod4@npm:zod@${Kt}`}:{importPath:"zod/v4",installSpec:`zod@${Kt}`}}function $l(e){let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;let n=JSON.parse(m.readFileSync(r,"utf8")),t=tl.parse(n);return[t.dependencies?.zod,t.devDependencies?.zod,t.optionalDependencies?.zod,t.peerDependencies?.zod].filter(i=>i!=null).some(i=>!El(i))}function El(e){let r=e.replace(/^workspace:/,"").replace(/^npm:zod@/,"");return Ya(r)?.major===4}import $e from"fs";import eo from"path";import{z as or}from"zod";var Pl={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},ro=or.record(or.string(),or.unknown());function Ee(e){let r=eo.join(e,".claude","settings.json"),n=Il(r);if(n==null)return"unparseable";let t=ro.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:Pl}};return $e.mkdirSync(eo.dirname(r),{recursive:!0}),$e.writeFileSync(r,`${JSON.stringify(o,null,2)}
156
- `),"written"}function Il(e){if(!$e.existsSync(e))return{};try{let r=ro.safeParse(JSON.parse($e.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function Pe(e){switch(e){case"written":return" registered ripplo plugin marketplace in .claude/settings.json (autoUpdate: true \u2014 Claude Code keeps the plugin current)";case"already-present":return" ripplo plugin marketplace already registered in .claude/settings.json";case"unparseable":return" ! .claude/settings.json could not be parsed \u2014 add the ripplo marketplace to extraKnownMarketplaces manually"}}var Tl=Al(`
155
+ `;function ro({zodImportPath:e}){return[{content:vl,relPath:"index.ts"},{content:Sl(e),relPath:"state.ts"},{content:xl,relPath:"facts.ts"},{content:Rl,relPath:"workflows/index.ts"},{content:Cl,relPath:"tsconfig.json"},{content:$l,relPath:"eslint.config.js"}]}var _f=ro({zodImportPath:"zod/v4"});function no(e){return El(e)?{importPath:"zod4",installSpec:`zod4@npm:zod@${Qt}`}:{importPath:"zod/v4",installSpec:`zod@${Qt}`}}function El(e){let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;let n=JSON.parse(m.readFileSync(r,"utf8")),t=ol.parse(n);return[t.dependencies?.zod,t.devDependencies?.zod,t.optionalDependencies?.zod,t.peerDependencies?.zod].filter(i=>i!=null).some(i=>!Pl(i))}function Pl(e){let r=e.replace(/^workspace:/,"").replace(/^npm:zod@/,"");return el(r)?.major===4}import $e from"fs";import to from"path";import{z as ir}from"zod";var Il={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},oo=ir.record(ir.string(),ir.unknown());function Ee(e){let r=to.join(e,".claude","settings.json"),n=Al(r);if(n==null)return"unparseable";let t=oo.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:Il}};return $e.mkdirSync(to.dirname(r),{recursive:!0}),$e.writeFileSync(r,`${JSON.stringify(o,null,2)}
156
+ `),"written"}function Al(e){if(!$e.existsSync(e))return{};try{let r=oo.safeParse(JSON.parse($e.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function Pe(e){switch(e){case"written":return" registered ripplo plugin marketplace in .claude/settings.json (autoUpdate: true \u2014 Claude Code keeps the plugin current)";case"already-present":return" ripplo plugin marketplace already registered in .claude/settings.json";case"unparseable":return" ! .claude/settings.json could not be parsed \u2014 add the ripplo marketplace to extraKnownMarketplaces manually"}}var jl=Tl(`
157
157
  query InitProjects {
158
158
  projects {
159
159
  id
160
160
  name
161
161
  }
162
162
  }
163
- `),ir=["../.env.local","../.env"];async function oo(e=Ll()){let r=process.cwd(),n=R(),t=P(n);t==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login` first.\n"),process.exit(1)),jl(r)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${r}. To re-init, delete it first.
164
- `),process.exit(1));let o=await Ml({serverUrl:n,token:t});o.length===0&&(process.stdout.write("No projects found. Run `npx ripplo projects create <name>` first, then re-run `npx ripplo init`.\n"),process.exit(1));let i=await Ol(o,e.projectId),s=await Fl(r,e.envFile),a=await _l(e.appUrl),l=Nl(a,e.engineUrl),u=X.resolve(X.join(r,".ripplo"),s);Ar({cwd:r,envFiles:[s],projectId:i}),Ul({appUrl:a,engineUrl:l,filePath:u}),process.stdout.write(`${Pe(Ee(r))}
165
- `);let f=(await Qt({cwd:r,onStep:p=>{process.stdout.write(` ${p}
163
+ `),sr=["../.env.local","../.env"];async function ao(e=Nl()){let r=process.cwd(),n=C(),t=P(n);t==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login` first.\n"),process.exit(1)),Ml(r)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${r}. To re-init, delete it first.
164
+ `),process.exit(1));let o=await Ll({serverUrl:n,token:t});o.length===0&&(process.stdout.write("No projects found. Run `npx ripplo projects create <name>` first, then re-run `npx ripplo init`.\n"),process.exit(1));let i=await Fl(o,e.projectId),s=await Wl(r,e.envFile),a=await _l(e.appUrl),l=Ol(a,e.engineUrl),c=X.resolve(X.join(r,".ripplo"),s);Tr({cwd:r,envFiles:[s],projectId:i}),ql({appUrl:a,engineUrl:l,filePath:c}),process.stdout.write(`${Pe(Ee(r))}
165
+ `);let f=(await Yt({cwd:r,onStep:p=>{process.stdout.write(` ${p}
166
166
  `)}})).match(p=>p,p=>{process.stderr.write(`${S(p)}
167
167
  `),process.exit(1)});if(f.length>0){process.stdout.write(`Done with warnings:
168
168
  `),f.forEach(p=>{process.stdout.write(` - ${p.message}
169
169
  `),p.manualCommand!=null&&process.stdout.write(` run: ${p.manualCommand}
170
- `)});return}process.stdout.write("Ready. Start `npx ripplo daemon` as a background process (or run `/ripplo:start` in Claude Code), then write workflows in `.ripplo/workflows/`.\n")}function jl(e){return Z.existsSync(X.join(e,".ripplo","index.ts"))}async function Ml({serverUrl:e,token:r}){return((await d({config:M({serverUrl:e,token:r}),document:Tl,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function Ll(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function Nl(e,r){if(r!=null){try{new URL(r)}catch{process.stdout.write(`--engine-url is not a valid URL: ${r}
171
- `),process.exit(1)}return r}return`${e.replace(/\/$/,"")}/ripplo`}async function Ol(e,r){if(r!=null){let n=e.find(t=>t.id===r);return n==null&&(process.stdout.write(`Unknown project id: ${r}
170
+ `)});return}process.stdout.write("Ready. Start `npx ripplo daemon` as a background process (or run `/ripplo:start` in Claude Code), then write workflows in `.ripplo/workflows/`.\n")}function Ml(e){return Z.existsSync(X.join(e,".ripplo","index.ts"))}async function Ll({serverUrl:e,token:r}){return((await d({config:M({serverUrl:e,token:r}),document:jl,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function Nl(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function Ol(e,r){if(r!=null){try{new URL(r)}catch{process.stdout.write(`--engine-url is not a valid URL: ${r}
171
+ `),process.exit(1)}return r}return`${e.replace(/\/$/,"")}/ripplo`}async function Fl(e,r){if(r!=null){let n=e.find(t=>t.id===r);return n==null&&(process.stdout.write(`Unknown project id: ${r}
172
172
  `),process.exit(1)),process.stdout.write(`Using project: ${n.name} (${n.id})
173
173
  `),n.id}if(e.length===1){let n=e[0];if(n==null)throw new Error("unreachable");return process.stdout.write(`Using project: ${n.name} (${n.id})
174
- `),n.id}return to({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function Fl(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
175
- `),process.exit(1)),r):Wl(e)}async function Wl(e){let r=X.join(e,".ripplo"),n=ir.find(o=>Z.existsSync(X.resolve(r,o))),t=await to({choices:[...ir.map(o=>({name:n===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:n??ir[0],message:"Which env file should ripplo write RIPPLO_APP_URL, RIPPLO_ENGINE_URL, RIPPLO_WEBHOOK_SECRET, and ENABLE_RIPPLO_TESTING to?"});return t!=="__custom__"?t:no({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function _l(e){if(e!=null){try{new URL(e)}catch{process.stdout.write(`--app-url is not a valid URL: ${e}
176
- `),process.exit(1)}return e}return Dl()}async function Dl(){return no({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 Ul({appUrl:e,engineUrl:r,filePath:n}){Z.mkdirSync(X.dirname(n),{recursive:!0});let t=Z.existsSync(n)?Z.readFileSync(n,"utf8"):"",o=[];if(/^RIPPLO_APP_URL=/m.test(t)||o.push(`RIPPLO_APP_URL=${e}`),/^RIPPLO_ENGINE_URL=/m.test(t)||o.push(`RIPPLO_ENGINE_URL=${r}`),/^RIPPLO_WEBHOOK_SECRET=/m.test(t)||o.push(`RIPPLO_WEBHOOK_SECRET=${Br()}`),/^ENABLE_RIPPLO_TESTING=/m.test(t)||o.push("ENABLE_RIPPLO_TESTING=true"),o.length===0)return;let i=t.length===0||t.endsWith(`
174
+ `),n.id}return so({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function Wl(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
175
+ `),process.exit(1)),r):Dl(e)}async function Dl(e){let r=X.join(e,".ripplo"),n=sr.find(o=>Z.existsSync(X.resolve(r,o))),t=await so({choices:[...sr.map(o=>({name:n===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:n??sr[0],message:"Which env file should ripplo write RIPPLO_APP_URL, RIPPLO_ENGINE_URL, RIPPLO_WEBHOOK_SECRET, and ENABLE_RIPPLO_TESTING to?"});return t!=="__custom__"?t:io({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function _l(e){if(e!=null){try{new URL(e)}catch{process.stdout.write(`--app-url is not a valid URL: ${e}
176
+ `),process.exit(1)}return e}return Ul()}async function Ul(){return io({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 ql({appUrl:e,engineUrl:r,filePath:n}){Z.mkdirSync(X.dirname(n),{recursive:!0});let t=Z.existsSync(n)?Z.readFileSync(n,"utf8"):"",o=[];if(/^RIPPLO_APP_URL=/m.test(t)||o.push(`RIPPLO_APP_URL=${e}`),/^RIPPLO_ENGINE_URL=/m.test(t)||o.push(`RIPPLO_ENGINE_URL=${r}`),/^RIPPLO_WEBHOOK_SECRET=/m.test(t)||o.push(`RIPPLO_WEBHOOK_SECRET=${Br()}`),/^ENABLE_RIPPLO_TESTING=/m.test(t)||o.push("ENABLE_RIPPLO_TESTING=true"),o.length===0)return;let i=t.length===0||t.endsWith(`
177
177
  `)?"":`
178
178
  `;Z.writeFileSync(n,`${t}${i}${o.join(`
179
179
  `)}
180
- `)}import{graphql as lr}from"gql.tada";function sr(){return"Not signed in. Run `npx ripplo auth login` first."}function io(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function so(e){return["You belong to multiple organizations \u2014 pass `--org <id>`:",...e.map(n=>` ${n.id} ${n.name}`)].join(`
181
- `)}function ar(e){return`Could not create the project \u2014 ${e}`}var Bl=lr(`
180
+ `)}import{graphql as dr}from"gql.tada";function ar(){return"Not signed in. Run `npx ripplo auth login` first."}function lo(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function co(e){return["You belong to multiple organizations \u2014 pass `--org <id>`:",...e.map(n=>` ${n.id} ${n.name}`)].join(`
181
+ `)}function lr(e){return`Could not create the project \u2014 ${e}`}var Bl=dr(`
182
182
  query ProjectsList {
183
183
  projects {
184
184
  id
185
185
  name
186
186
  }
187
187
  }
188
- `),ql=lr(`
188
+ `),Hl=dr(`
189
189
  query OrganizationsList {
190
190
  organizations {
191
191
  id
192
192
  name
193
193
  }
194
194
  }
195
- `),Hl=lr(`
195
+ `),Vl=dr(`
196
196
  mutation CliCreateProject($name: String!, $organizationId: String!) {
197
197
  createProject(cloudBaseUrl: "", name: $name, organizationId: $organizationId) {
198
198
  __typename
@@ -208,59 +208,29 @@ export default tseslint.config({
208
208
  }
209
209
  }
210
210
  }
211
- `);async function ao(){let e=R(),r=P(e);r==null&&(process.stderr.write(`${sr()}
211
+ `);async function uo(){let e=C(),r=P(e);r==null&&(process.stderr.write(`${ar()}
212
212
  `),process.exit(1));let t=((await d({config:M({serverUrl:e,token:r}),document:Bl,variables:void 0})).projects??[]).map(o=>({id:o.id,name:o.name}));process.stdout.write(`${JSON.stringify({projects:t},null,2)}
213
- `)}async function lo({name:e,orgId:r}){let n=R(),t=P(n);t==null&&(process.stderr.write(`${sr()}
214
- `),process.exit(1));let o=M({serverUrl:n,token:t}),i=r??await Vl(o),a=(await d({config:o,document:Hl,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof Lr&&(process.stderr.write(`${ar(l.message)}
215
- `),process.exit(1)),l})).createProject;if(a?.__typename!=="Project"){let l=a?.message??"unknown error";process.stderr.write(`${ar(l)}
213
+ `)}async function po({name:e,orgId:r}){let n=C(),t=P(n);t==null&&(process.stderr.write(`${ar()}
214
+ `),process.exit(1));let o=M({serverUrl:n,token:t}),i=r??await zl(o),a=(await d({config:o,document:Vl,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof Nr&&(process.stderr.write(`${lr(l.message)}
215
+ `),process.exit(1)),l})).createProject;if(a?.__typename!=="Project"){let l=a?.message??"unknown error";process.stderr.write(`${lr(l)}
216
216
  `),process.exit(1)}process.stdout.write(`${JSON.stringify({project:{id:a.id,name:a.name}},null,2)}
217
- `)}async function Vl(e){let n=((await d({config:e,document:ql,variables:void 0})).organizations??[]).map(o=>({id:o.id,name:o.name})),t=n.length===1?n[0]:void 0;if(t!=null)return t.id;process.stderr.write(`${n.length===0?io():so(n)}
218
- `),process.exit(1)}import{spawnSync as Ie}from"child_process";function uo(){if(Ie("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};Ie("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=Ie("claude",["plugin","install","ripplo@ripplo"],{encoding:"utf8",stdio:["ignore","pipe","pipe"]}),n=/already installed/i.test(`${r.stdout}${r.stderr}`);return r.status!==0&&!n?{detail:r.stderr.trim(),kind:"plugin-install-failed"}:{exitCode:Ie("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function co(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function po(e){return e.kind==="claude-missing"?"Claude Code not found on your PATH. Install it, then re-run `npx ripplo setup`.":`Could not install the Ripplo plugin for Claude Code.${e.detail.length>0?`
219
- ${e.detail}`:""}`}function mo(){process.stdout.write(`${co()}
220
- `);let e=uo();e.kind!=="launched"&&(process.stderr.write(`${po(e)}
221
- `),process.exit(1)),process.exit(e.exitCode)}import{graphql as zl}from"gql.tada";function fo({id:e,kind:r,title:n}){return`Caught bug reported (${r}): "${n}" [${e}]`}var Kl=zl(`
222
- mutation ReportCaughtBug(
223
- $projectId: String!
224
- $kind: CaughtBugKind!
225
- $title: String!
226
- $rootCause: String!
227
- $surfacedBy: String!
228
- $runId: String!
229
- ) {
230
- reportCaughtBug(
231
- projectId: $projectId
232
- kind: $kind
233
- title: $title
234
- rootCause: $rootCause
235
- surfacedBy: $surfacedBy
236
- runId: $runId
237
- ) {
238
- __typename
239
- ... on CaughtBug {
240
- id
241
- kind
242
- title
243
- }
244
- ... on RunNotFoundError {
245
- message
246
- }
247
- }
248
- }
249
- `);async function go(e){let r=w(),t=(await d({config:r,document:Kl,variables:{kind:e.kind,projectId:r.projectId,rootCause:e.rootCause,runId:e.runId,surfacedBy:e.surfacedBy,title:e.title}})).reportCaughtBug;if(t?.__typename!=="CaughtBug"){let o=t?.__typename==="RunNotFoundError"?t.message:null;process.stderr.write(`${o??"reportCaughtBug failed"}
250
- `),process.exit(1)}process.stdout.write(`${fo({id:t.id,kind:e.kind,title:e.title})}
251
- `)}import Gl from"path";import{CancellationTokenSource as Jl}from"vscode-jsonrpc/node";function Ae(e){return`ripplo: workspace build is stale (${e.join(", ")}) \u2014 rebuilding`}function Te(){return"ripplo: workspace build failed \u2014 fix the build, then rerun"}function Y(e){return e.kind==="stale"?`! workspace build is stale (${e.packages.join(", ")}) \u2014 run pnpm build, then npx ripplo daemon restart`:e.kind==="foreign-binary"?"! this is the ripplo workspace but you're running the published CLI \u2014 use node_modules/.bin/ripplo so local changes apply":null}async function yo({all:e,headed:r,ids:n}){let t=process.cwd(),o=process.argv[1];o==null&&W(be({kind:"spawn-failed",message:"process.argv[1] missing"})),Xl();let i=await Dn(t);i!=null&&W(qn(i));let a=(await On({cliEntry:o,cwd:t})).match(p=>p,p=>W(be(p)));a.versionNote?.kind==="stale-busy"&&W(Qe(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${Qe(a.versionNote)}
252
- `);let l=new Jl;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let u=Gl.join(t,".ripplo","debug"),f=(await Fn({connection:a,onEvent:Ql(u),request:{all:e,headed:r,tests:[...n]},token:l.token})).match(p=>p,p=>W(be(p)));await Zl({connection:a,result:f})}function Ql(e){let r=!1;return n=>{let t=Bn({debugDir:e,event:n});if(t!=null){if(process.stdout.isTTY&&n.kind==="run-progress"){process.stdout.write(`\r\x1B[2K${t}`),r=!0;return}r&&(process.stdout.write("\r\x1B[2K"),r=!1),process.stdout.write(`${t}
253
- `)}}}async function Zl({connection:e,result:r}){await new Promise(n=>{e.socket.end(n)}),r.kind==="daemon-error"&&W(Hn(r.error)),process.stdout.write(`${Un(r)}
217
+ `)}async function zl(e){let n=((await d({config:e,document:Hl,variables:void 0})).organizations??[]).map(o=>({id:o.id,name:o.name})),t=n.length===1?n[0]:void 0;if(t!=null)return t.id;process.stderr.write(`${n.length===0?lo():co(n)}
218
+ `),process.exit(1)}import{spawnSync as Ie}from"child_process";function mo(){if(Ie("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};Ie("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=Ie("claude",["plugin","install","ripplo@ripplo"],{encoding:"utf8",stdio:["ignore","pipe","pipe"]}),n=/already installed/i.test(`${r.stdout}${r.stderr}`);return r.status!==0&&!n?{detail:r.stderr.trim(),kind:"plugin-install-failed"}:{exitCode:Ie("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function fo(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function go(e){return e.kind==="claude-missing"?"Claude Code not found on your PATH. Install it, then re-run `npx ripplo setup`.":`Could not install the Ripplo plugin for Claude Code.${e.detail.length>0?`
219
+ ${e.detail}`:""}`}function yo(){process.stdout.write(`${fo()}
220
+ `);let e=mo();e.kind!=="launched"&&(process.stderr.write(`${go(e)}
221
+ `),process.exit(1)),process.exit(e.exitCode)}import Kl from"path";import{CancellationTokenSource as Gl}from"vscode-jsonrpc/node";function Ae(e){return`ripplo: workspace build is stale (${e.join(", ")}) \u2014 rebuilding`}function Te(){return"ripplo: workspace build failed \u2014 fix the build, then rerun"}function Y(e){return e.kind==="stale"?`! workspace build is stale (${e.packages.join(", ")}) \u2014 run pnpm build, then npx ripplo daemon restart`:e.kind==="foreign-binary"?"! this is the ripplo workspace but you're running the published CLI \u2014 use node_modules/.bin/ripplo so local changes apply":null}async function ho({all:e,headed:r,ids:n}){let t=process.cwd(),o=process.argv[1];o==null&&W(be({kind:"spawn-failed",message:"process.argv[1] missing"})),Zl();let i=await Bn(t);i!=null&&W(zn(i));let a=(await Dn({cliEntry:o,cwd:t})).match(p=>p,p=>W(be(p)));a.versionNote?.kind==="stale-busy"&&W(Ze(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${Ze(a.versionNote)}
222
+ `);let l=new Gl;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let c=Kl.join(t,".ripplo","debug"),f=(await _n({connection:a,onEvent:Jl(c),request:{all:e,headed:r,tests:[...n]},token:l.token})).match(p=>p,p=>W(be(p)));await Ql({connection:a,result:f})}function Jl(e){let r=!1;return n=>{let t=Vn({debugDir:e,event:n});if(t!=null){if(process.stdout.isTTY&&n.kind==="run-progress"){process.stdout.write(`\r\x1B[2K${t}`),r=!0;return}r&&(process.stdout.write("\r\x1B[2K"),r=!1),process.stdout.write(`${t}
223
+ `)}}}async function Ql({connection:e,result:r}){await new Promise(n=>{e.socket.end(n)}),r.kind==="daemon-error"&&W(Kn(r.error)),process.stdout.write(`${Hn(r)}
254
224
  `),r.failed>0&&process.exit(1),process.exit(r.notRun>0?2:0)}function W(e){process.stderr.write(`${e}
255
- `),process.exit(1)}function Xl(){let e=O();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=Y(e);W(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Ae(e.packages)}
256
- `),we(e.workspaceRoot)||W(Te())}import U from"path";import td from"os";import{mkdtempSync as od,rmSync as id}from"fs";import{err as Le,ok as cr}from"neverthrow";import{readdir as Yl,rm as ed,stat as rd}from"fs/promises";import{existsSync as nd}from"fs";import dr from"path";async function ur(e,r){let t=(await Yl(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||nd(dr.join(e,s,Or)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await rd(dr.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>ed(dr.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var ho=50,sd=15e3,ad=15e3;async function ko(){ce(b());let e=process.cwd(),r=q.child({worker:process.pid}),n=ut(),t=od(U.join(td.tmpdir(),"ripplo-browser-cache-")),o=ge({cacheDir:t,clientVersion:b(),debugDir:U.join(e,".ripplo","debug"),headed:!1,writeOtlpPortFile:!1}),i=new Set,s=l=>{i.add(l),l.finally(()=>i.delete(l))},a=l=>{setTimeout(()=>{process.exit(l)},sd).unref(),pd(i).then(()=>o.close().catch(()=>{})).then(()=>{id(t,{force:!0,recursive:!0}),process.exit(l)})};ld({exit:a,workerLogger:r}),n.onRequest(tt,async(l,u)=>{let g=et.safeParse(l);if(!g.success)return je("bad-run-assign");let f=g.data;ne(e);let p=y(e).match(v=>v,v=>v.kind);if(typeof p=="string")return je(`config:${p}`);let E=await wo(n);if(E.isErr())return je(`lockfile-unavailable:${E.error}`);let A=E.value,$=K(A).find(v=>v.ref===f.testRef);if($==null)return je(`no-test:${f.testRef}`);let ue=pt({config:p,intervalMs:ad,runId:f.runId});try{let{outcome:v,persisted:Be,progress:Ts}=await mt({config:p,cwd:e,errorSettle:"settle",fixturesDir:U.join(e,te),headed:f.headed,lockfile:A,onProgress:dd({connection:n,runId:f.runId}),runId:f.runId,session:o,signal:Ze(u),test:$.test}),Pr=U.join(e,".ripplo","debug");return s(Promise.allSettled([Be]).then(()=>ud({config:p,debugDir:Pr,progress:Ts,runId:f.runId})).then(()=>ur(Pr,ho)).catch(()=>{})),{outcome:Yn(v),serverNotified:!0}}catch(v){let Be=U.join(e,".ripplo","debug");if(s(Q({config:p,debugDir:Be,runId:f.runId}).catch(()=>{})),v instanceof Mr)return{outcome:{detail:v.message,kind:"infra-error"},serverNotified:!1};throw v}finally{ue()}}),n.onRequest(st,(l,u)=>md({connection:n,cwd:e,raw:l,session:o,token:u,track:s})),n.onNotification(at,l=>{let u=rt.safeParse(l);u.success&&o.injectSpan(u.data.runId,u.data.span)}),n.onNotification(dt,()=>{a(0)}),n.sendNotification(nt),await new Promise(()=>{})}function ld({exit:e,workerLogger:r}){process.on("disconnect",()=>{e(1)}),process.on("unhandledRejection",n=>{r.error({err:n},"worker unhandled rejection")}),process.on("uncaughtException",n=>{r.error({err:n},"worker uncaught exception"),e(1)})}function dd({connection:e,runId:r}){return n=>{e.sendNotification(lt,{runId:r,signal:n})}}async function ud({config:e,debugDir:r,progress:n,runId:t}){n?.report({activity:{kind:"uploadingReplay"},deadlineAt:null,retry:null}),await n?.flush(),n!=null&&ft({debugDir:r,history:n.history(),runId:t}),await Q({config:e,debugDir:r,runId:t})}function je(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var cd=5e3;async function pd(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,cd)})])}async function md({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=it.safeParse(n);if(!s.success)return{error:{reason:"format-unsupported",source:"assignment-rejected"},kind:"error"};let{assign:a,currentTargetGeneration:l,devSessionId:u}=s.data;ne(r);let g=y(r).match(v=>v,v=>v.kind);if(typeof g=="string")return{error:{detail:g,source:"config"},kind:"error"};let f=await wo(e);if(f.isErr())return{error:{source:"lockfile-stale"},kind:"error"};let p=f.value,E=await he(r);if(E==null)return{error:{source:"lockfile-stale"},kind:"error"};let A=U.join(g.cwd,".ripplo","debug"),$=await gt({assign:a,config:g,currentModelHash:E,currentTargetGeneration:l,debugDir:A,devSessionId:u??void 0,fixturesDir:U.join(g.cwd,te),headed:!1,lockfile:p,report:!0,session:t,signal:Ze(o)}),ue=($.kind==="finding"||$.kind==="coverage-gap")&&$.runId!=null?Q({config:g,debugDir:A,runId:$.runId}):Promise.resolve();return i(ue.then(()=>ur(A,ho)).catch(()=>{})),$}async function wo(e){return(await fd(e)).andThen(n=>n.unavailable!=null?Le(n.unavailable):n.lockfileJson==null?Le("empty-reply"):gd(n.lockfileJson))}async function fd(e){try{return cr(await e.sendRequest(ot))}catch(r){return Le(`transport:${r instanceof Error?r.message:"unknown"}`)}}var Me;function gd(e){if(Me!==void 0&&Me.json===e)return cr(Me.lockfile);try{let r=Jr(N(T,e));return Me={json:e,lockfile:r},cr(r)}catch(r){return Le(`worker-decode-failed:${r instanceof Error?r.message.slice(0,200):"unknown"}`)}}async function bo(){await ko()}import{existsSync as Rd}from"fs";import $d from"path";import{ok as Ed}from"neverthrow";import{gunzipSync as yd}from"zlib";import{mkdir as hd,writeFile as kd}from"fs/promises";import vo from"path";import{graphql as wd}from"gql.tada";import{err as ie,ok as bd}from"neverthrow";var vd=31,Sd=139;async function Ne(e,r){let n=y(e).match(s=>s,s=>s.kind);if(typeof n=="string")return ie({detail:n,kind:"config"});let t=await d({config:n,document:xd,variables:{id:r}}).catch(()=>null);if(t==null)return ie({kind:"request-failed"});if(t.run==null)return ie({kind:"not-found"});if(t.run.behaviorUrl==null)return ie({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return ie({kind:"download-failed",status:o.status});let i=vo.join(e,".ripplo","debug",r,"behavior.jsonl");return await hd(vo.dirname(i),{recursive:!0}),await kd(i,Cd(Buffer.from(await o.arrayBuffer()))),bd({path:i,runId:r})}var xd=wd(`
225
+ `),process.exit(1)}function Zl(){let e=O();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=Y(e);W(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Ae(e.packages)}
226
+ `),we(e.workspaceRoot)||W(Te())}import U from"path";import nd from"os";import{mkdtempSync as td,rmSync as od}from"fs";import{err as Le,ok as pr}from"neverthrow";import{readdir as Xl,rm as Yl,stat as ed}from"fs/promises";import{existsSync as rd}from"fs";import cr from"path";async function ur(e,r){let t=(await Xl(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||rd(cr.join(e,s,Fr)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await ed(cr.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>Yl(cr.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var ko=50,id=15e3,sd=15e3;async function wo(){ue(w());let e=process.cwd(),r=B.child({worker:process.pid}),n=mt(),t=td(U.join(nd.tmpdir(),"ripplo-browser-cache-")),o=ge({cacheDir:t,clientVersion:w(),debugDir:U.join(e,".ripplo","debug"),headed:!1,writeOtlpPortFile:!1}),i=new Set,s=l=>{i.add(l),l.finally(()=>i.delete(l))},a=l=>{setTimeout(()=>{process.exit(l)},id).unref(),ud(i).then(()=>o.close().catch(()=>{})).then(()=>{od(t,{force:!0,recursive:!0}),process.exit(l)})};ad({exit:a,workerLogger:r}),n.onRequest(st,async(l,c)=>{let g=tt.safeParse(l);if(!g.success)return je("bad-run-assign");let f=g.data;ne(e);let p=y(e).match(v=>v,v=>v.kind);if(typeof p=="string")return je(`config:${p}`);let E=await bo(n);if(E.isErr())return je(`lockfile-unavailable:${E.error}`);let A=E.value,$=K(A).find(v=>v.ref===f.testRef);if($==null)return je(`no-test:${f.testRef}`);let ce=gt({config:p,intervalMs:sd,runId:f.runId});try{let{outcome:v,persisted:Be,progress:js}=await yt({config:p,cwd:e,errorSettle:"settle",fixturesDir:U.join(e,te),headed:f.headed,lockfile:A,onProgress:ld({connection:n,runId:f.runId}),runId:f.runId,session:o,signal:Xe(c),test:$.test}),Ir=U.join(e,".ripplo","debug");return s(Promise.allSettled([Be]).then(()=>dd({config:p,debugDir:Ir,progress:js,runId:f.runId})).then(()=>ur(Ir,ko)).catch(()=>{})),{outcome:nt(v),serverNotified:!0}}catch(v){let Be=U.join(e,".ripplo","debug");if(s(Q({config:p,debugDir:Be,runId:f.runId}).catch(()=>{})),v instanceof Lr)return{outcome:{detail:v.message,kind:"infra-error"},serverNotified:!1};throw v}finally{ce()}}),n.onRequest(dt,(l,c)=>pd({connection:n,cwd:e,raw:l,session:o,token:c,track:s})),n.onNotification(ct,l=>{let c=ot.safeParse(l);c.success&&o.injectSpan(c.data.runId,c.data.span)}),n.onNotification(pt,()=>{a(0)}),n.sendNotification(it),await new Promise(()=>{})}function ad({exit:e,workerLogger:r}){process.on("disconnect",()=>{e(1)}),process.on("unhandledRejection",n=>{r.error({err:n},"worker unhandled rejection")}),process.on("uncaughtException",n=>{r.error({err:n},"worker uncaught exception"),e(1)})}function ld({connection:e,runId:r}){return n=>{e.sendNotification(ut,{runId:r,signal:n})}}async function dd({config:e,debugDir:r,progress:n,runId:t}){n?.report({activity:{kind:"uploadingReplay"},deadlineAt:null,retry:null}),await n?.flush(),n!=null&&ht({debugDir:r,history:n.history(),runId:t}),await Q({config:e,debugDir:r,runId:t})}function je(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var cd=5e3;async function ud(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,cd)})])}async function pd({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=lt.safeParse(n);if(!s.success)return{error:{reason:"format-unsupported",source:"assignment-rejected"},kind:"error"};let{assign:a,currentTargetGeneration:l,devSessionId:c}=s.data;ne(r);let g=y(r).match(v=>v,v=>v.kind);if(typeof g=="string")return{error:{detail:g,source:"config"},kind:"error"};let f=await bo(e);if(f.isErr())return{error:{source:"lockfile-stale"},kind:"error"};let p=f.value,E=await he(r);if(E==null)return{error:{source:"lockfile-stale"},kind:"error"};let A=U.join(g.cwd,".ripplo","debug"),$=await kt({assign:a,config:g,currentModelHash:E,currentTargetGeneration:l,debugDir:A,devSessionId:c??void 0,fixturesDir:U.join(g.cwd,te),headed:!1,lockfile:p,report:!0,session:t,signal:Xe(o)}),ce=($.kind==="finding"||$.kind==="coverage-gap")&&$.runId!=null?Q({config:g,debugDir:A,runId:$.runId}):Promise.resolve();return i(ce.then(()=>ur(A,ko)).catch(()=>{})),$}async function bo(e){return(await md(e)).andThen(n=>n.unavailable!=null?Le(n.unavailable):n.lockfileJson==null?Le("empty-reply"):fd(n.lockfileJson))}async function md(e){try{return pr(await e.sendRequest(at))}catch(r){return Le(`transport:${r instanceof Error?r.message:"unknown"}`)}}var Me;function fd(e){if(Me!==void 0&&Me.json===e)return pr(Me.lockfile);try{let r=Zr(N(T,e));return Me={json:e,lockfile:r},pr(r)}catch(r){return Le(`worker-decode-failed:${r instanceof Error?r.message.slice(0,200):"unknown"}`)}}async function vo(){await wo()}import{existsSync as Rd}from"fs";import Cd from"path";import{ok as $d}from"neverthrow";import{gunzipSync as gd}from"zlib";import{mkdir as yd,writeFile as hd}from"fs/promises";import So from"path";import{graphql as kd}from"gql.tada";import{err as ie,ok as wd}from"neverthrow";var bd=31,vd=139;async function Ne(e,r){let n=y(e).match(s=>s,s=>s.kind);if(typeof n=="string")return ie({detail:n,kind:"config"});let t=await d({config:n,document:Sd,variables:{id:r}}).catch(()=>null);if(t==null)return ie({kind:"request-failed"});if(t.run==null)return ie({kind:"not-found"});if(t.run.behaviorUrl==null)return ie({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return ie({kind:"download-failed",status:o.status});let i=So.join(e,".ripplo","debug",r,"behavior.jsonl");return await yd(So.dirname(i),{recursive:!0}),await hd(i,xd(Buffer.from(await o.arrayBuffer()))),wd({path:i,runId:r})}var Sd=kd(`
257
227
  query RunBehaviorUrl($id: String!) {
258
228
  run(id: $id) {
259
229
  id
260
230
  behaviorUrl
261
231
  }
262
232
  }
263
- `);function Cd(e){return e[0]===vd&&e[1]===Sd?yd(e):e}async function ee(e,r){let n=$d.join(e,".ripplo","debug",r,"behavior.jsonl");return Rd(n)?Ed(void 0):(await Ne(e,r)).map(()=>{})}import{existsSync as xo,readFileSync as Co}from"fs";import Ro from"path";import{err as Pd,ok as Id}from"neverthrow";import{z as pr}from"zod";var mr=" \u203A ",Ad=4e3,Td=5;function $o(e,r){let n=Ro.join(e,".ripplo","debug",r,"behavior.jsonl");if(!xo(n))return Pd({kind:"run-not-found",runId:r});let t=jd(Co(n,"utf8")),o=Xd(e),i=o==null?[]:rn(o),s=[...t.failedChecks.map(a=>Fd({check:a,facts:i,lockfile:o,run:t})),...t.stepErrors.map(a=>Bd({event:a,run:t})),...t.findings.map(a=>qd({event:a,run:t}))];return Id({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,progress:t.progress,runId:r,stepsRan:t.stepTitles.size,viewport:t.viewport})}function jd(e){let r=H(e),n=r.filter(l=>l.kind==="check"&&l.outcome.kind==="failed"),t=r.filter(l=>l.kind==="stepError"),o=r.filter(l=>l.kind==="finding"),i=r.flatMap(l=>Nd(l)),s=r.flatMap(l=>l.kind==="progress"?[{atMs:D(l.timeNanos),signal:l.signal}]:[]),a=r.map(l=>D(l.timeNanos));return{causes:i,failedChecks:n,findings:o,firstTs:a.length===0?0:Math.min(...a),lastTs:a.length===0?0:Math.max(...a),progress:s,stepErrors:t,stepTitles:new Map(r.flatMap(l=>l.kind==="step"?[[l.stepIndex,l.title]]:[])),viewport:Ld(r)}}var Md=pr.object({height:pr.number(),width:pr.number()});function Ld(e){return e.flatMap(r=>{if(r.kind!=="rrweb"||r.event.type!==4)return[];let n=Md.safeParse(r.event.data);return n.success?[n.data]:[]})[0]}function Nd(e){let r=Od(e);return r==null?[]:[{detail:r,timestamp:D(e.timeNanos)}]}function Od(e){return e.kind==="network"?{kind:"network",method:e.method,status:e.status,traceId:e.traceId,url:e.url}:e.kind==="console"?e.level==="error"||e.level==="warning"?{kind:"console",level:e.level,text:e.text}:null:e.kind==="error"?{kind:"error",message:e.message}:e.kind==="span"?{durationMs:e.durationMs,kind:"span",name:e.name,statusCode:e.status.code,traceId:e.traceId}:null}function Fd({check:e,facts:r,lockfile:n,run:t}){let o=D(e.timeNanos),i=Wd(e.origin),s=t.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:fr(t.causes,o),error:void 0,label:_d(e),outcome:"failed",pending:void 0,ruleKind:i,rules:Vd({check:Eo(e),facts:r,lockfile:n,ruleKind:i,subjectKey:Ud(e)}),runWorkflow:s.split(mr)[0]??s,snapshotAt:o,step:s,wait:void 0,waitMs:e.waitedMs}}function Wd(e){switch(e.kind){case"fact":return"fact";case"dataRule":return"data-rule";case"step":return"step"}}function _d(e){let r=Gr(e);return r??`${e.family} ${Eo(e)}: ${e.outcome.kind}`}function Eo(e){switch(e.family){case"element":case"content":case"scalar":case"state":case"action":return e.subject;case"frame":return Dd(e);case"dataRule":return e.rule}}function Dd(e){if(e.outcome.kind==="passed")return e.family;let r=e.outcome.reason;return r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent"?r.subject:r.kind==="wrongCount"?r.entity:`${r.entity} [${r.key}]`}function Ud(e){if(e.family==="scalar")return e.subjectKey;if(e.family!=="frame"||e.outcome.kind!=="failed")return;let r=e.outcome.reason;if(r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent")return r.subjectKey}function Bd({event:e,run:r}){let n=D(e.timeNanos),t=r.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:fr(r.causes,n),error:e.error,label:`driver ${e.error.kind}`,outcome:"error",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:t.split(mr)[0]??t,snapshotAt:n,step:t,wait:void 0,waitMs:void 0}}function qd({event:e,run:r}){let n=D(e.timeNanos);return{browserMismatch:void 0,causes:fr(r.causes,n),error:void 0,label:Hd(e.payload),outcome:"failed",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:e.step.split(mr)[0]??e.step,snapshotAt:n,step:e.step,wait:void 0,waitMs:void 0}}function Hd(e){switch(e.kind){case"unrunnable":return e.unmet==null?`${e.kind} ${e.reason}`:`${e.kind} ${e.reason}: ${e.unmet}`;case"impossibleAction":return`${e.kind} ${e.action}`;case"liftVisibility":return`${e.kind} ${e.subject}`}}function Vd({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>zd({check:e,rule:i,subjectKey:o})).map(i=>({consequence:Ve(i.consequence),origins:Kd(i.origin,n),url:Xr(i.when),when:Yr(i.when)}))}function zd({check:e,rule:r,subjectKey:n}){return n!=null?nn(r)===n:Ve(r.consequence)===e}function Kd(e,r){let n=K(r),t=Gd(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return Jd(t)}function Gd(e){return e==null?[]:e.kind==="declared"?[]:[e.test]}function Jd(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function fr(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Ad).toSorted((t,o)=>o.timestamp-t.timestamp);return Qd(n).toSorted((t,o)=>Number(So(o.detail))-Number(So(t.detail))).slice(0,Td).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function Qd(e){return e.reduce((r,n)=>{let t=Zd(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function Zd(e){return e.kind==="network"?`net ${e.method} ${String(e.status)} ${e.url.split("?")[0]??""}`:e.kind==="console"?`console ${e.text}`:e.kind==="error"?`err ${e.message}`:`span ${e.name} ${e.statusCode}`}function So(e){return e.kind==="network"?e.status>=400:e.kind==="span"?e.statusCode==="error":!0}function Xd(e){let r=Ro.join(e,".ripplo","ripplo.lock");if(!xo(r))return null;try{return N(T,Co(r,"utf8"))}catch{return null}}import{existsSync as Po,readFileSync as Io}from"fs";import Ao from"path";import{graphql as Yd}from"gql.tada";async function To(e,r,n){let t=ru(e);return{test:t==null?void 0:await nu(n,r,t),timeline:eu(lu(e,r))}}function eu(e){return e.filter(r=>r.kind==="step").toSorted((r,n)=>r.stepIndex-n.stepIndex).map(r=>iu(r,e))}function ru(e){let r=Ao.join(e,".ripplo","ripplo.lock");return Po(r)?N(T,Io(r,"utf8")):null}async function nu(e,r,n){let t=await d({config:e,document:du,variables:{id:r}}).catch(()=>null);if(t?.run==null)return;let o=tu(t.run);return o!=null?K(n).find(i=>i.ref===o)?.test:ou(n,t.run.reproJson)}function tu(e){let r=e.workflow?.slug,n=e.test?.slug;return r==null||n==null?void 0:`${r}/${n}`}function ou(e,r){if(r==null)return;let n=fe(r);return n.kind==="rejected"?void 0:sn(e,{sweep:!0}).find(t=>t.name===n.repro.envelopeRef)?.test}function iu(e,r){let n=r.filter(i=>i.kind==="check"&&i.stepIndex===e.stepIndex),t=r.filter(i=>i.kind==="stepError"&&i.stepIndex===e.stepIndex),o=r.filter(i=>i.kind==="finding"&&i.stepIndex===e.stepIndex);return{changes:[...e.stateRows.flatMap(i=>su(i)),...e.stateSingletons.flatMap(i=>au(i))],checksHeld:n.filter(i=>i.outcome.kind==="passed").length,failures:[...n.filter(i=>i.outcome.kind==="failed").map(i=>({event:i,kind:"check"})),...t.map(i=>({event:i,kind:"stepError"})),...o.map(i=>({kind:"finding",payload:i.payload}))],index:e.stepIndex,title:e.title,url:e.pageUrl,workflow:e.sourceTest}}function su(e){return e.status==="present"?[]:[`${e.status} ${e.entity} ${e.key}`]}function au(e){return e.changed?[`${e.name} = ${e.value??"\u2205"}`]:[]}function lu(e,r){let n=Ao.join(e,".ripplo","debug",r,"behavior.jsonl");return Po(n)?H(Io(n,"utf8")):[]}var du=Yd(`
233
+ `);function xd(e){return e[0]===bd&&e[1]===vd?gd(e):e}async function ee(e,r){let n=Cd.join(e,".ripplo","debug",r,"behavior.jsonl");return Rd(n)?$d(void 0):(await Ne(e,r)).map(()=>{})}import{existsSync as Ro,readFileSync as Co}from"fs";import $o from"path";import{err as Ed,ok as Pd}from"neverthrow";import{z as mr}from"zod";function Oe(e){return e.shape==="legacy"?e.title:e.action==null?e.nodeType:Xr(e.action).map(r=>r.text).join(" ")}var fr=" \u203A ",Id=4e3,Ad=5;function Eo(e,r){let n=$o.join(e,".ripplo","debug",r,"behavior.jsonl");if(!Ro(n))return Ed({kind:"run-not-found",runId:r});let t=Td(Co(n,"utf8")),o=Zd(e),i=o==null?[]:on(o),s=[...t.failedChecks.map(a=>Od({check:a,facts:i,lockfile:o,run:t})),...t.stepErrors.map(a=>Ud({event:a,run:t})),...t.findings.map(a=>qd({event:a,run:t}))];return Pd({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,progress:t.progress,runId:r,stepsRan:t.stepTitles.size,viewport:t.viewport})}function Td(e){let r=H(e),n=r.filter(l=>l.kind==="check"&&l.outcome.kind==="failed"),t=r.filter(l=>l.kind==="stepError"),o=r.filter(l=>l.kind==="finding"),i=r.flatMap(l=>Ld(l)),s=r.flatMap(l=>l.kind==="progress"?[{atMs:_(l.timeNanos),signal:l.signal}]:[]),a=r.map(l=>_(l.timeNanos));return{causes:i,failedChecks:n,findings:o,firstTs:a.length===0?0:Math.min(...a),lastTs:a.length===0?0:Math.max(...a),progress:s,stepErrors:t,stepTitles:new Map(r.flatMap(l=>l.kind==="step"?[[l.stepIndex,Oe(l)]]:[])),viewport:Md(r)}}var jd=mr.object({height:mr.number(),width:mr.number()});function Md(e){return e.flatMap(r=>{if(r.kind!=="rrweb"||r.event.type!==4)return[];let n=jd.safeParse(r.event.data);return n.success?[n.data]:[]})[0]}function Ld(e){let r=Nd(e);return r==null?[]:[{detail:r,timestamp:_(e.timeNanos)}]}function Nd(e){return e.kind==="network"?{kind:"network",method:e.method,status:e.status,traceId:e.traceId,url:e.url}:e.kind==="console"?e.level==="error"||e.level==="warning"?{kind:"console",level:e.level,text:e.text}:null:e.kind==="error"?{kind:"error",message:e.message}:e.kind==="span"?{durationMs:e.durationMs,kind:"span",name:e.name,statusCode:e.status.code,traceId:e.traceId}:null}function Od({check:e,facts:r,lockfile:n,run:t}){let o=_(e.timeNanos),i=Fd(e.origin),s=t.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:gr(t.causes,o),error:void 0,label:Wd(e),outcome:"failed",pending:void 0,ruleKind:i,rules:Hd({check:Po(e),facts:r,lockfile:n,ruleKind:i,subjectKey:_d(e)}),runWorkflow:s.split(fr)[0]??s,snapshotAt:o,step:s,wait:void 0,waitMs:e.waitedMs}}function Fd(e){switch(e.kind){case"fact":return"fact";case"dataRule":return"data-rule";case"step":return"step"}}function Wd(e){let r=Qr(e);return r??`${e.family} ${Po(e)}: ${e.outcome.kind}`}function Po(e){switch(e.family){case"element":case"content":case"scalar":case"action":return Jr(e);case"state":return e.subject;case"frame":return Dd(e);case"dataRule":return e.rule}}function Dd(e){if(e.outcome.kind==="passed")return e.family;let r=e.outcome.reason;return r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent"?r.subject:r.kind==="wrongCount"?r.entity:`${r.entity} [${r.key}]`}function _d(e){if(e.family==="scalar")return e.subjectKey;if(e.family!=="frame"||e.outcome.kind!=="failed")return;let r=e.outcome.reason;if(r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent")return r.subjectKey}function Ud({event:e,run:r}){let n=_(e.timeNanos),t=r.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:gr(r.causes,n),error:e.error,label:`driver ${e.error.kind}`,outcome:"error",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:t.split(fr)[0]??t,snapshotAt:n,step:t,wait:void 0,waitMs:void 0}}function qd({event:e,run:r}){let n=_(e.timeNanos);return{browserMismatch:void 0,causes:gr(r.causes,n),error:void 0,label:Bd(e.payload),outcome:"failed",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:e.step.split(fr)[0]??e.step,snapshotAt:n,step:e.step,wait:void 0,waitMs:void 0}}function Bd(e){switch(e.kind){case"unrunnable":return e.unmet==null?`${e.kind} ${e.reason}`:`${e.kind} ${e.reason}: ${e.unmet}`;case"impossibleAction":return`${e.kind} ${e.action}`;case"liftVisibility":return`${e.kind} ${e.subject}`}}function Hd({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>Vd({check:e,rule:i,subjectKey:o})).map(i=>({consequence:ze(i.consequence),origins:zd(i.origin,n),url:rn(i.when),when:nn(i.when)}))}function Vd({check:e,rule:r,subjectKey:n}){return n!=null?sn(r)===n:ze(r.consequence)===e}function zd(e,r){let n=K(r),t=Kd(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return Gd(t)}function Kd(e){return e==null?[]:e.kind==="declared"?[]:[e.test]}function Gd(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function gr(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Id).toSorted((t,o)=>o.timestamp-t.timestamp);return Jd(n).toSorted((t,o)=>Number(xo(o.detail))-Number(xo(t.detail))).slice(0,Ad).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function Jd(e){return e.reduce((r,n)=>{let t=Qd(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function Qd(e){return e.kind==="network"?`net ${e.method} ${String(e.status)} ${e.url.split("?")[0]??""}`:e.kind==="console"?`console ${e.text}`:e.kind==="error"?`err ${e.message}`:`span ${e.name} ${e.statusCode}`}function xo(e){return e.kind==="network"?e.status>=400:e.kind==="span"?e.statusCode==="error":!0}function Zd(e){let r=$o.join(e,".ripplo","ripplo.lock");if(!Ro(r))return null;try{return N(T,Co(r,"utf8"))}catch{return null}}import{existsSync as Io,readFileSync as Ao}from"fs";import To from"path";import{graphql as Xd}from"gql.tada";async function jo(e,r,n){let t=ec(e);return{test:t==null?void 0:await rc(n,r,t),timeline:Yd(ac(e,r))}}function Yd(e){return e.filter(r=>r.kind==="step").toSorted((r,n)=>r.stepIndex-n.stepIndex).map(r=>oc(r,e))}function ec(e){let r=To.join(e,".ripplo","ripplo.lock");return Io(r)?N(T,Ao(r,"utf8")):null}async function rc(e,r,n){let t=await d({config:e,document:lc,variables:{id:r}}).catch(()=>null);if(t?.run==null)return;let o=nc(t.run);return o!=null?K(n).find(i=>i.ref===o)?.test:tc(n,t.run.reproJson)}function nc(e){let r=e.workflow?.slug,n=e.test?.slug;return r==null||n==null?void 0:`${r}/${n}`}function tc(e,r){if(r==null)return;let n=fe(r);return n.kind==="rejected"?void 0:dn(e,{sweep:!0}).find(t=>t.name===n.repro.envelopeRef)?.test}function oc(e,r){let n=r.filter(i=>i.kind==="check"&&i.stepIndex===e.stepIndex),t=r.filter(i=>i.kind==="stepError"&&i.stepIndex===e.stepIndex),o=r.filter(i=>i.kind==="finding"&&i.stepIndex===e.stepIndex);return{changes:[...e.stateRows.flatMap(i=>ic(i)),...e.stateSingletons.flatMap(i=>sc(i))],checksHeld:n.filter(i=>i.outcome.kind==="passed").length,failures:[...n.filter(i=>i.outcome.kind==="failed").map(i=>({event:i,kind:"check"})),...t.map(i=>({event:i,kind:"stepError"})),...o.map(i=>({kind:"finding",payload:i.payload}))],index:e.stepIndex,title:Oe(e),url:e.pageUrl,workflow:e.sourceTest}}function ic(e){return e.status==="present"?[]:[`${e.status} ${e.entity} ${e.key}`]}function sc(e){return e.changed?[`${e.name} = ${e.value??"\u2205"}`]:[]}function ac(e,r){let n=To.join(e,".ripplo","debug",r,"behavior.jsonl");return Io(n)?H(Ao(n,"utf8")):[]}var lc=Xd(`
264
234
  query ExplainRunTest($id: String!) {
265
235
  run(id: $id) {
266
236
  id
@@ -275,30 +245,30 @@ ${e.detail}`:""}`}function mo(){process.stdout.write(`${co()}
275
245
  }
276
246
  }
277
247
  }
278
- `);var jo=" \u203A ",uu=["fact ","data rule ","step "];function No(e){if(e.failures.length===0)return cu(e);let r=e.viewport==null?"":` (viewport ${String(e.viewport.width)}\xD7${String(e.viewport.height)})`,n=`${e.runId} \u2014 ${j(e.failures.length,"failing check")}${r}`,t=e.lockfileLoaded?[]:[c.dim("(no lockfile \u2014 workflow source unavailable)")],o=e.progress.at(-1),i=o==null?[]:[c.dim(`last progress \u2014 ${Ge(o.signal)}`)],s=pu(e.failures).map(a=>mu(a,e.runId));return[n,...t,...i,"",...s,C("tasks")].join(`
279
- `)}function Oo(e){return`${c.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function cu(e){if(e.stepsRan>0)return`${c.good("ok")} \u2014 ${e.runId}: no failing checks.`;let r=e.progress.at(-1),n=r==null?"":` It stopped at: ${Ge(r.signal)}.`;return`${e.runId}: no steps ran, so there are no checks to explain.${n} A run that ends this early failed before its first step \u2014 setup, sign-in, or reaching your app. The reason is on the run itself, not in this artifact.`}function pu(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function mu(e,r){let n=e.failures[0];if(n==null)return"";let t=fu(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>s.error==null?Wo(s.label):z(s.error)))].join(", "),i=c.dim(`(${n.runWorkflow})`);return[`${c.bad("\u2717")} ${yu(e.step)} ${i}`,` ${c.dim("failed")} ${o}`,...hu(e),...vu(n),...Su(n.causes),` ${c.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
280
- `)}function fu(e,r){let n=e.failures[0],t=e.failures.flatMap(u=>u.browserMismatch==null?[]:[u.browserMismatch])[0],o=Fo(e.failures.flatMap(u=>u.rules));if(n==null||t==null||o.length===0)return null;let i=Wo(e.failures.find(u=>u.rules.length>0)?.label??n.label),s=[...new Set(o.map(u=>u.url))].join(", "),a=c.dim(`(${n.runWorkflow})`);return[`${c.bad("\u2717")} ${i} ${c.warn("(wrong page)")} ${a}`,` ${c.dim("rule declared for url")} ${s}`,` ${c.dim("browser was actually at")} ${t.actual}`,` ${c.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${c.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
281
- `)}function Fo(e){let r=e.map(n=>[gu(n),n]);return[...new Map(r).values()]}function gu(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function Wo(e){let r=uu.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function yu(e){let r=e.split(jo);return r.length<2?e:r.slice(1).join(jo)}function hu(e){let r=Fo(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>ku(n)),...bu(e,r)]}function ku(e){let r=e.origins.length===0?c.dim("origin not in lockfile"):e.origins.map(n=>wu(n)).join(", ");return[` ${c.dim("workflow declaration")}`,` ${c.dim("from")} ${r}`,` ${c.dim("at")} ${e.url} ${c.dim("\u2014 holds only when")} ${e.when}`]}function wu(e){if(e.sourcePath==null)return e.intent;let r=c.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function bu(e,r){let n=new Set(r.flatMap(o=>o.origins.map(i=>i.intent)));return e.failures.some(o=>n.has(o.runWorkflow))||n.size===0?[]:[` ${c.warn("\u21B3 declared by another workflow \u2014 this declaration may be missing distinguishing state")}`]}function vu(e){if(e.waitMs==null||e.wait==null)return[];let r=`${String(Math.round(e.waitMs/1e3))}s`,n=e.pending===!0?" \u2014 value never changed (write may be slow or dropped)":"";return[` ${c.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function Su(e){if(e.length===0)return[];let r=xu(e),n=e.flatMap(t=>Cu(t,r));return n.length===0?[]:[` ${c.dim("nearby")} ${n.join(" \xB7 ")}`]}function xu(e){let r=e.flatMap(n=>n.detail.kind==="span"&&n.detail.traceId!=null?[[n.detail.traceId,n.detail]]:[]);return new Map(r)}function Cu(e,r){let n=e.detail;if(n.kind==="span"&&n.traceId!=null&&r.has(n.traceId))return[];if(n.kind==="network"&&n.traceId!=null){let t=r.get(n.traceId),o=t==null?"":` \u21B9 ${gr(t)}`;return[Lo(n,`${gr(n)}${o}`)]}return[Lo(n,gr(n))]}function gr(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${Ru(e.url)}`:e.kind==="console"?`console.${e.level} ${Mo(e.text)}`:e.kind==="error"?`error ${Mo(e.message)}`:`span ${e.name} ${e.statusCode} ${String(Math.round(e.durationMs))}ms`}function Ru(e){let r=e.split("?")[0]??e;return r.length>60?`\u2026${r.slice(-57)}`:r}function Mo(e){let r=e.replaceAll(/\s+/g," ").trim();return r.length>100?`${r.slice(0,97)}\u2026`:r}function Lo(e,r){return $u(e)?c.bad(r):r}function $u(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function _o(e){return[Eu(e.test),"",Iu(e.factOrigins),Au(e.timeline,e.factOrigins)].filter(r=>r.length>0).join(`
282
- `)}function Eu(e){return e==null?c.dim("starting state (couldn't resolve the run's test \u2014 offline, or it left the model)"):["starting state",...[` - ${String(e.startingState.operations.length)} setup operations`,` - ${String(e.startingState.constraints.length)} state constraints`,` - actor: ${Pu(e)}`]].join(`
283
- `)}function Pu(e){return e.actor.kind==="user"?`signed in as ${e.actor.alias}`:"signed out"}function Iu(e){return e.length===0?"":["facts checked here were declared in",...e.map(n=>` - ${n}`),""].join(`
284
- `)}function Au(e,r){return e.length===0?c.dim("timeline (no steps captured)"):["what happened, step by step",...e.map(t=>Tu(t,r))].join(`
285
- `)}function Tu(e,r){let n=` ${String(e.index+1)}. ${e.title}${ju(e.workflow)}${Mu(e.url)}`,t=e.changes.length===0?[]:[` \u0394 ${e.changes.join(", ")}`],o=e.failures.map(s=>` ${c.bad("\u2717")} ${Lu(s,r)}`),i=e.checksHeld===0?[]:[c.dim(` ${String(e.checksHeld)} checks held`)];return[n,...t,...o,...i].join(`
286
- `)}function ju(e){if(e==null)return"";let r=`(${e})`;return` ${c.dim(r)}`}function Mu(e){if(e==null)return"";let r=`@ ${e}`;return` ${c.dim(r)}`}function Lu(e,r){switch(e.kind){case"check":{let n=e.event.origin.kind==="fact"?Nu(r):"";return`${on(e.event)}${n}`}case"stepError":return`run error \u2014 ${z(e.event.error)}`;case"finding":return Ou(e.payload)}}function Nu(e){if(e.length===0)return"";let r=`(fact from ${e.join(", ")})`;return` ${c.dim(r)}`}function Ou(e){switch(e.kind){case"unrunnable":{let r=e.unmet==null?"":`: needs ${e.unmet}`;return`couldn't run \u2014 ${e.reason}${r}`}case"impossibleAction":return`impossible action: ${e.action} on ${e.subject}`;case"liftVisibility":{let r=String(e.visibleIndex+1),n=String(e.declaredIndex+1);return`${e.subject} visible by step ${r} but declared at step ${n}`}}}function Do(e){return`Saved behavior.jsonl to ${e.path}`}function re(e){switch(e.kind){case"config":return`Can't read project config (${e.detail}). Run this from your project root.`;case"request-failed":return"Couldn't reach the server. Check you're signed in with `npx ripplo auth`.";case"not-found":return"No run with that id.";case"not-uploaded":return"This run has no uploaded artifacts yet \u2014 it may still be running, or predates artifact upload.";case"download-failed":return`Download failed (HTTP ${String(e.status)}). The link may have expired \u2014 try again.`}}async function Uo({full:e,json:r,runId:n}){let t=process.cwd(),o=await ee(t,n);o.isErr()&&(process.stderr.write(`${re(o.error)}
287
- `),process.exit(1));let i=$o(t,n).match(s=>s,s=>(process.stderr.write(`${Oo(s)}
288
- `),process.exit(1)));process.stdout.write(`${r?JSON.stringify(i,null,2):No(i)}
289
- `),e&&!r&&await Fu(t,n,Wu(i))}async function Fu(e,r,n){let t=y(e).unwrapOr(void 0);if(t==null)return;let o=await To(e,r,t);process.stdout.write(`
248
+ `);var Mo=" \u203A ",dc=["fact ","data rule ","step "];function Oo(e){if(e.failures.length===0)return cc(e);let r=e.viewport==null?"":` (viewport ${String(e.viewport.width)}\xD7${String(e.viewport.height)})`,n=`${e.runId} \u2014 ${j(e.failures.length,"failing check")}${r}`,t=e.lockfileLoaded?[]:[u.dim("(no lockfile \u2014 workflow source unavailable)")],o=e.progress.at(-1),i=o==null?[]:[u.dim(`last progress \u2014 ${Je(o.signal)}`)],s=uc(e.failures).map(a=>pc(a,e.runId));return[n,...t,...i,"",...s,R("tasks")].join(`
249
+ `)}function Fo(e){return`${u.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function cc(e){if(e.stepsRan>0)return`${u.good("ok")} \u2014 ${e.runId}: no failing checks.`;let r=e.progress.at(-1),n=r==null?"":` It stopped at: ${Je(r.signal)}.`;return`${e.runId}: no steps ran, so there are no checks to explain.${n} A run that ends this early failed before its first step \u2014 setup, sign-in, or reaching your app. The reason is on the run itself, not in this artifact.`}function uc(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function pc(e,r){let n=e.failures[0];if(n==null)return"";let t=mc(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>s.error==null?Do(s.label):z(s.error)))].join(", "),i=u.dim(`(${n.runWorkflow})`);return[`${u.bad("\u2717")} ${gc(e.step)} ${i}`,` ${u.dim("failed")} ${o}`,...yc(e),...bc(n),...vc(n.causes),` ${u.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
250
+ `)}function mc(e,r){let n=e.failures[0],t=e.failures.flatMap(c=>c.browserMismatch==null?[]:[c.browserMismatch])[0],o=Wo(e.failures.flatMap(c=>c.rules));if(n==null||t==null||o.length===0)return null;let i=Do(e.failures.find(c=>c.rules.length>0)?.label??n.label),s=[...new Set(o.map(c=>c.url))].join(", "),a=u.dim(`(${n.runWorkflow})`);return[`${u.bad("\u2717")} ${i} ${u.warn("(wrong page)")} ${a}`,` ${u.dim("rule declared for url")} ${s}`,` ${u.dim("browser was actually at")} ${t.actual}`,` ${u.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${u.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
251
+ `)}function Wo(e){let r=e.map(n=>[fc(n),n]);return[...new Map(r).values()]}function fc(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function Do(e){let r=dc.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function gc(e){let r=e.split(Mo);return r.length<2?e:r.slice(1).join(Mo)}function yc(e){let r=Wo(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>hc(n)),...wc(e,r)]}function hc(e){let r=e.origins.length===0?u.dim("origin not in lockfile"):e.origins.map(n=>kc(n)).join(", ");return[` ${u.dim("workflow declaration")}`,` ${u.dim("from")} ${r}`,` ${u.dim("at")} ${e.url} ${u.dim("\u2014 holds only when")} ${e.when}`]}function kc(e){if(e.sourcePath==null)return e.intent;let r=u.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function wc(e,r){let n=new Set(r.flatMap(o=>o.origins.map(i=>i.intent)));return e.failures.some(o=>n.has(o.runWorkflow))||n.size===0?[]:[` ${u.warn("\u21B3 declared by another workflow \u2014 this declaration may be missing distinguishing state")}`]}function bc(e){if(e.waitMs==null||e.wait==null)return[];let r=`${String(Math.round(e.waitMs/1e3))}s`,n=e.pending===!0?" \u2014 value never changed (write may be slow or dropped)":"";return[` ${u.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function vc(e){if(e.length===0)return[];let r=Sc(e),n=e.flatMap(t=>xc(t,r));return n.length===0?[]:[` ${u.dim("nearby")} ${n.join(" \xB7 ")}`]}function Sc(e){let r=e.flatMap(n=>n.detail.kind==="span"&&n.detail.traceId!=null?[[n.detail.traceId,n.detail]]:[]);return new Map(r)}function xc(e,r){let n=e.detail;if(n.kind==="span"&&n.traceId!=null&&r.has(n.traceId))return[];if(n.kind==="network"&&n.traceId!=null){let t=r.get(n.traceId),o=t==null?"":` \u21B9 ${yr(t)}`;return[No(n,`${yr(n)}${o}`)]}return[No(n,yr(n))]}function yr(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${Rc(e.url)}`:e.kind==="console"?`console.${e.level} ${Lo(e.text)}`:e.kind==="error"?`error ${Lo(e.message)}`:`span ${e.name} ${e.statusCode} ${String(Math.round(e.durationMs))}ms`}function Rc(e){let r=e.split("?")[0]??e;return r.length>60?`\u2026${r.slice(-57)}`:r}function Lo(e){let r=e.replaceAll(/\s+/g," ").trim();return r.length>100?`${r.slice(0,97)}\u2026`:r}function No(e,r){return Cc(e)?u.bad(r):r}function Cc(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function _o(e){return[$c(e.test),"",Pc(e.factOrigins),Ic(e.timeline,e.factOrigins)].filter(r=>r.length>0).join(`
252
+ `)}function $c(e){return e==null?u.dim("starting state (couldn't resolve the run's test \u2014 offline, or it left the model)"):["starting state",...[` - ${String(e.startingState.operations.length)} setup operations`,` - ${String(e.startingState.constraints.length)} state constraints`,` - actor: ${Ec(e)}`]].join(`
253
+ `)}function Ec(e){return e.actor.kind==="user"?`signed in as ${e.actor.alias}`:"signed out"}function Pc(e){return e.length===0?"":["facts checked here were declared in",...e.map(n=>` - ${n}`),""].join(`
254
+ `)}function Ic(e,r){return e.length===0?u.dim("timeline (no steps captured)"):["what happened, step by step",...e.map(t=>Ac(t,r))].join(`
255
+ `)}function Ac(e,r){let n=` ${String(e.index+1)}. ${e.title}${Tc(e.workflow)}${jc(e.url)}`,t=e.changes.length===0?[]:[` \u0394 ${e.changes.join(", ")}`],o=e.failures.map(s=>` ${u.bad("\u2717")} ${Mc(s,r)}`),i=e.checksHeld===0?[]:[u.dim(` ${String(e.checksHeld)} checks held`)];return[n,...t,...o,...i].join(`
256
+ `)}function Tc(e){if(e==null)return"";let r=`(${e})`;return` ${u.dim(r)}`}function jc(e){if(e==null)return"";let r=`@ ${e}`;return` ${u.dim(r)}`}function Mc(e,r){switch(e.kind){case"check":{let n=e.event.origin.kind==="fact"?Lc(r):"";return`${ln(e.event)}${n}`}case"stepError":return`run error \u2014 ${z(e.event.error)}`;case"finding":return Nc(e.payload)}}function Lc(e){if(e.length===0)return"";let r=`(fact from ${e.join(", ")})`;return` ${u.dim(r)}`}function Nc(e){switch(e.kind){case"unrunnable":{let r=e.unmet==null?"":`: needs ${e.unmet}`;return`couldn't run \u2014 ${e.reason}${r}`}case"impossibleAction":return`impossible action: ${e.action} on ${e.subject}`;case"liftVisibility":{let r=String(e.visibleIndex+1),n=String(e.declaredIndex+1);return`${e.subject} visible by step ${r} but declared at step ${n}`}}}function Uo(e){return`Saved behavior.jsonl to ${e.path}`}function re(e){switch(e.kind){case"config":return`Can't read project config (${e.detail}). Run this from your project root.`;case"request-failed":return"Couldn't reach the server. Check you're signed in with `npx ripplo auth`.";case"not-found":return"No run with that id.";case"not-uploaded":return"This run has no uploaded artifacts yet \u2014 it may still be running, or predates artifact upload.";case"download-failed":return`Download failed (HTTP ${String(e.status)}). The link may have expired \u2014 try again.`}}async function qo({full:e,json:r,runId:n}){let t=process.cwd(),o=await ee(t,n);o.isErr()&&(process.stderr.write(`${re(o.error)}
257
+ `),process.exit(1));let i=Eo(t,n).match(s=>s,s=>(process.stderr.write(`${Fo(s)}
258
+ `),process.exit(1)));process.stdout.write(`${r?JSON.stringify(i,null,2):Oo(i)}
259
+ `),e&&!r&&await Oc(t,n,Fc(i))}async function Oc(e,r,n){let t=y(e).unwrapOr(void 0);if(t==null)return;let o=await jo(e,r,t);process.stdout.write(`
290
260
  ${_o({...o,factOrigins:n})}
291
- `)}function Wu(e){let r=e.failures.filter(n=>n.ruleKind==="fact").flatMap(n=>n.rules).flatMap(n=>n.origins).map(n=>n.sourcePath==null?n.intent:`${n.intent} (${n.sourcePath})`);return[...new Set(r)]}async function Bo({runId:e}){(await Ne(process.cwd(),e)).match(n=>{process.stdout.write(`${Do(n)}
261
+ `)}function Fc(e){let r=e.failures.filter(n=>n.ruleKind==="fact").flatMap(n=>n.rules).flatMap(n=>n.origins).map(n=>n.sourcePath==null?n.intent:`${n.intent} (${n.sourcePath})`);return[...new Set(r)]}async function Bo({runId:e}){(await Ne(process.cwd(),e)).match(n=>{process.stdout.write(`${Uo(n)}
292
262
  `)},n=>{process.stderr.write(`${re(n)}
293
- `),process.exit(1)})}import{randomUUID as _u}from"crypto";import{existsSync as Du,readFileSync as Uu}from"fs";import yr from"path";import{graphql as Ho}from"gql.tada";import{err as Oe,ok as qo}from"neverthrow";async function Vo(e,r,n){let t=Bu(e);if(t.kind==="error")return Oe(t.error);let o=t.config,i=await pe(e);if(i.result.isErr())return Oe({kind:"compile-failed"});let s=await qu({config:o,runId:r});if(s.kind==="error")return Oe(s.error);let{repro:a,reproJson:l}=s,u=await G(e,i.result.value),g=wn(u);await kn({config:o,cwd:e,lockfile:u});let f=`replay-${_u()}`,p=yr.join(e,".ripplo","debug"),E=[],A=ge({cacheDir:void 0,clientVersion:b(),debugDir:p,headed:!1,writeOtlpPortFile:!1});try{let $=await mn({capture:!0,lockfile:u,options:{baseUrl:o.appUrl,engineUrl:o.engineUrl,fixturesDir:yr.join(e,te),generate:Vr,headed:!1,secret:o.webhookSecret},repro:a,runId:f,session:A,signal:n,onEvent:v=>{E.push(v)}});return(await Vu({config:o,debugDir:p,events:E,lockfileHash:g,outcome:$,replayRunId:f,reproJson:l,stepSources:Hu({lockfile:u,repro:a})})).map(()=>({outcome:$,recordingCaptured:zu(p,f),replayRunId:f}))}finally{await A.close()}}function Bu(e){return y(e).match(r=>({config:r,kind:"found"}),r=>({error:{detail:r.kind,kind:"config"},kind:"error"}))}async function qu({config:e,runId:r}){let n=await d({config:e,document:Ku,variables:{id:r}}).catch(()=>null);if(n==null)return{error:{kind:"request-failed"},kind:"error"};if(n.run==null)return{error:{kind:"not-found"},kind:"error"};let t=n.run.reproJson;if(t==null)return{error:{kind:"no-repro"},kind:"error"};let o=fe(t);return o.kind==="rejected"?{error:{kind:"stale-repro",reason:"format-unsupported"},kind:"error"}:{kind:"found",repro:o.repro,reproJson:t}}function Hu({lockfile:e,repro:r}){let n=en(e);return r.steps.map(t=>n.find(o=>o.id===t.transitionId)?.test??null)}async function Vu({config:e,debugDir:r,events:n,lockfileHash:t,outcome:o,replayRunId:i,reproJson:s,stepSources:a}){if(o.kind!=="resolved"&&o.kind!=="still-fails")return qo(void 0);try{return await d({config:e,document:Gu,variables:{lockfileHash:t,projectId:e.projectId,reproJson:s,runId:i}}),await ct({config:e,debugDir:r,events:n,recordingOptional:!0,runId:i,stepSources:a}),await Q({config:e,debugDir:r,runId:i}),qo(void 0)}catch{return Oe({kind:"report-failed"})}}function zu(e,r){let n=yr.join(e,r,"behavior.jsonl");return Du(n)?Uu(n,"utf8").split(`
294
- `).some(t=>t.includes('"kind":"rrweb"')):!1}var Ku=Ho(`
263
+ `),process.exit(1)})}import{randomUUID as Wc}from"crypto";import{existsSync as Dc,readFileSync as _c}from"fs";import hr from"path";import{graphql as Vo}from"gql.tada";import{err as Fe,ok as Ho}from"neverthrow";async function zo(e,r,n){let t=Uc(e);if(t.kind==="error")return Fe(t.error);let o=t.config,i=await pe(e);if(i.result.isErr())return Fe({kind:"compile-failed"});let s=await qc({config:o,runId:r});if(s.kind==="error")return Fe(s.error);let{repro:a,reproJson:l}=s,c=await G(e,i.result.value),g=Sn(c);await vn({config:o,cwd:e,lockfile:c});let f=`replay-${Wc()}`,p=hr.join(e,".ripplo","debug"),E=[],A=ge({cacheDir:void 0,clientVersion:w(),debugDir:p,headed:!1,writeOtlpPortFile:!1});try{let $=await yn({capture:!0,lockfile:c,options:{baseUrl:o.appUrl,engineUrl:o.engineUrl,fixturesDir:hr.join(e,te),generate:zr,headed:!1,secret:o.webhookSecret},repro:a,runId:f,session:A,signal:n,onEvent:v=>{E.push(v)}});return(await Hc({config:o,debugDir:p,events:E,lockfileHash:g,outcome:$,replayRunId:f,reproJson:l,stepSources:Bc({lockfile:c,repro:a})})).map(()=>({outcome:$,recordingCaptured:Vc(p,f),replayRunId:f}))}finally{await A.close()}}function Uc(e){return y(e).match(r=>({config:r,kind:"found"}),r=>({error:{detail:r.kind,kind:"config"},kind:"error"}))}async function qc({config:e,runId:r}){let n=await d({config:e,document:zc,variables:{id:r}}).catch(()=>null);if(n==null)return{error:{kind:"request-failed"},kind:"error"};if(n.run==null)return{error:{kind:"not-found"},kind:"error"};let t=n.run.reproJson;if(t==null)return{error:{kind:"no-repro"},kind:"error"};let o=fe(t);return o.kind==="rejected"?{error:{kind:"stale-repro",reason:"format-unsupported"},kind:"error"}:{kind:"found",repro:o.repro,reproJson:t}}function Bc({lockfile:e,repro:r}){let n=tn(e);return r.steps.map(t=>n.find(o=>o.id===t.transitionId)?.test??null)}async function Hc({config:e,debugDir:r,events:n,lockfileHash:t,outcome:o,replayRunId:i,reproJson:s,stepSources:a}){if(o.kind!=="resolved"&&o.kind!=="still-fails")return Ho(void 0);try{return await d({config:e,document:Kc,variables:{lockfileHash:t,projectId:e.projectId,reproJson:s,runId:i}}),await ft({config:e,debugDir:r,events:n,recordingOptional:!0,runId:i,stepSources:a}),await Q({config:e,debugDir:r,runId:i}),Ho(void 0)}catch{return Fe({kind:"report-failed"})}}function Vc(e,r){let n=hr.join(e,r,"behavior.jsonl");return Dc(n)?_c(n,"utf8").split(`
264
+ `).some(t=>t.includes('"kind":"rrweb"')):!1}var zc=Vo(`
295
265
  query RunRepro($id: String!) {
296
266
  run(id: $id) {
297
267
  id
298
268
  reproJson
299
269
  }
300
270
  }
301
- `),Gu=Ho(`
271
+ `),Kc=Vo(`
302
272
  mutation CreateReplayRun(
303
273
  $projectId: String!
304
274
  $runId: String!
@@ -314,11 +284,11 @@ ${_o({...o,factOrigins:n})}
314
284
  id
315
285
  }
316
286
  }
317
- `);function zo({outcome:e,recordingCaptured:r,replayRunId:n}){let t=Ju(e);if(e.kind!=="resolved"&&e.kind!=="still-fails")return t;let o=r?"":"\n! No page recording was captured \u2014 the page may never have loaded. Treat this verdict with suspicion and confirm with `npx ripplo run`.",i=e.kind==="resolved"?`
287
+ `);function Ko({outcome:e,recordingCaptured:r,replayRunId:n}){let t=Gc(e);if(e.kind!=="resolved"&&e.kind!=="still-fails")return t;let o=r?"":"\n! No page recording was captured \u2014 the page may never have loaded. Treat this verdict with suspicion and confirm with `npx ripplo run`.",i=e.kind==="resolved"?`
318
288
  ! A clean replay confirms the fix but doesn't explain the original failure. Classify the root cause \u2014 app bug or model gap \u2014 before you resolve. Don't file it as flake unless you know why it flaked.`:"";return`${t}${o}${i}
319
- Replay run ${n} \u2014 snapshot it, or cite it as resolve proof: \`npx ripplo tasks resolve <id> --run ${n}\`.`}function Ju(e){switch(e.kind){case"resolved":return"\u2713 Resolved \u2014 the finding's trail ran clean.";case"still-fails":return`\u2717 Still failing \u2014 ${j(e.contradictions.length,"check")} still mismatch.`;case"unplannable":return"! Model changed \u2014 this trail's base state or actions no longer exist. Use `npx ripplo compile` and `npx ripplo run`.";case"state-unavailable":return`! Couldn't run the trail (${e.reason}).`;case"aborted":return"Replay aborted."}}function Ko(e){switch(e.kind){case"config":return`Can't read project config (${e.detail}). Run from your project root.`;case"compile-failed":return"Couldn't compile the local `.ripplo/` model. Run `npx ripplo compile` first.";case"request-failed":return"Couldn't reach the server. Check you're signed in with `npx ripplo auth`.";case"not-found":return"No run with that id.";case"no-repro":return"This run has no replayable trail \u2014 predates repro capture, or isn't an explore finding.";case"report-failed":return"The replay finished but couldn't be registered with the server, so its id won't work as resolve proof. Check you're signed in, then rerun `npx ripplo replay`.";case"stale-repro":return"This finding uses an older explorer trail format and cannot be replayed. Let the explorer reconcile stale findings."}}function Go(e){return e.kind==="resolved"}async function Jo({runId:e}){(await Vo(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${zo(n)}
320
- `),process.exit(Go(n.outcome)?0:1)},n=>{process.stderr.write(`${Ko(n)}
321
- `),process.exit(1)})}import ii from"path";import{existsSync as nc}from"fs";import{writeFile as ni}from"fs/promises";import ti from"path";import{err as ae,ok as tc}from"neverthrow";import{readFile as Qu}from"fs/promises";import{z as se}from"zod";var Zu={height:800,width:1280};async function Qo(e){let r=await Qu(e,"utf8");return H(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}var Xu=se.object({data:se.looseObject({height:se.number(),width:se.number()}),type:se.literal(4)});function hr(e){let r=e.flatMap(n=>{let t=Xu.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?Zu:{height:r.data.height,width:r.data.width}}var Yu='<svg xmlns="http://www.w3.org/2000/svg" width="17" height="22" viewBox="0 0 17 22"><path d="M1 1 L1 17 L5.4 12.8 L8.5 20 L11 19 L8 11.8 L14 11.8 Z" fill="black" stroke="white" stroke-width="1.3"/></svg>',ec=`.replayer-mouse-tail { display: none; }
289
+ Replay run ${n} \u2014 snapshot it, or cite it as resolve proof: \`npx ripplo tasks resolve <id> --run ${n}\`.`}function Gc(e){switch(e.kind){case"resolved":return"\u2713 Resolved \u2014 the finding's trail ran clean.";case"still-fails":return`\u2717 Still failing \u2014 ${j(e.contradictions.length,"check")} still mismatch.`;case"unplannable":return"! Model changed \u2014 this trail's base state or actions no longer exist. Use `npx ripplo compile` and `npx ripplo run`.";case"state-unavailable":return`! Couldn't run the trail (${e.reason}).`;case"aborted":return"Replay aborted."}}function Go(e){switch(e.kind){case"config":return`Can't read project config (${e.detail}). Run from your project root.`;case"compile-failed":return"Couldn't compile the local `.ripplo/` model. Run `npx ripplo compile` first.";case"request-failed":return"Couldn't reach the server. Check you're signed in with `npx ripplo auth`.";case"not-found":return"No run with that id.";case"no-repro":return"This run has no replayable trail \u2014 predates repro capture, or isn't an explore finding.";case"report-failed":return"The replay finished but couldn't be registered with the server, so its id won't work as resolve proof. Check you're signed in, then rerun `npx ripplo replay`.";case"stale-repro":return"This finding uses an older explorer trail format and cannot be replayed. Let the explorer reconcile stale findings."}}function Jo(e){return e.kind==="resolved"}async function Qo({runId:e}){(await zo(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${Ko(n)}
290
+ `),process.exit(Jo(n.outcome)?0:1)},n=>{process.stderr.write(`${Go(n)}
291
+ `),process.exit(1)})}import si from"path";import{existsSync as ru}from"fs";import{writeFile as ti}from"fs/promises";import oi from"path";import{err as ae,ok as nu}from"neverthrow";import{readFile as Jc}from"fs/promises";import{z as se}from"zod";var Qc={height:800,width:1280};async function Zo(e){let r=await Jc(e,"utf8");return H(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}var Zc=se.object({data:se.looseObject({height:se.number(),width:se.number()}),type:se.literal(4)});function kr(e){let r=e.flatMap(n=>{let t=Zc.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?Qc:{height:r.data.height,width:r.data.width}}var Xc='<svg xmlns="http://www.w3.org/2000/svg" width="17" height="22" viewBox="0 0 17 22"><path d="M1 1 L1 17 L5.4 12.8 L8.5 20 L11 19 L8 11.8 L14 11.8 Z" fill="black" stroke="white" stroke-width="1.3"/></svg>',Yc=`.replayer-mouse-tail { display: none; }
322
292
  .replayer-mouse {
323
293
  position: absolute;
324
294
  width: 17px;
@@ -326,28 +296,28 @@ Replay run ${n} \u2014 snapshot it, or cite it as resolve proof: \`npx ripplo ta
326
296
  z-index: 9999;
327
297
  background-repeat: no-repeat;
328
298
  background-size: contain;
329
- background-image: url('data:image/svg+xml;utf8,${Yu}');
330
- }`,rc=".replayer-mouse, .replayer-mouse-tail { display: none; }";function Zo(e){return`<!doctype html><html><head><style>
299
+ background-image: url('data:image/svg+xml;utf8,${Xc}');
300
+ }`,eu=".replayer-mouse, .replayer-mouse-tail { display: none; }";function Xo(e){return`<!doctype html><html><head><style>
331
301
  html, body { margin: 0; padding: 0; }
332
302
  .replayer-wrapper { position: relative; }
333
- ${e?ec:rc}
303
+ ${e?Yc:eu}
334
304
  iframe { border: none; }
335
- </style></head><body></body></html>`}var Xo="*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }";function Yo(){return`(async () => {
305
+ </style></head><body></body></html>`}var Yo="*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }";function ei(){return`(async () => {
336
306
  const doc = document.querySelector(".replayer-wrapper iframe")?.contentDocument;
337
307
  if (doc?.fonts != null) {
338
308
  await doc.fonts.ready;
339
309
  }
340
310
  await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
341
- })()`}function ei(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var ri=un(dn("@ripplo/rrweb-bundle/replay","rrweb-replay.js"));async function oi({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!nc(e))return ae({kind:"run-not-found",runId:t});let o=await Qo(e),i=o[0],s=o.at(-1);if(i==null||s==null)return ae({kind:"no-rrweb-events",runId:t});let a=s.timestamp-i.timestamp,l=r.kind==="offset"?r.offsetMs:r.at-i.timestamp;if(l<0)return ae({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let u=Math.min(l,a),g=String(Math.round(u)),f=ti.join(n,`snapshot-${g}ms.png`),p=ti.join(n,`snapshot-${g}ms.html`);return(await oc({events:o,htmlPath:p,offsetMs:u,pngPath:f})).map(()=>({durationMs:a,htmlPath:p,offsetMs:u,pngPath:f,viewport:hr(o)}))}async function oc({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await ei();if(o==null)return ae({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await ic({browser:o,events:e,offsetMs:n});return await ni(t,s),await ni(r,i,"utf8"),tc(void 0)}catch(i){return ae({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function ic({browser:e,events:r,offsetMs:n}){let t=hr(r),o=await e.newPage({viewport:t});await o.setContent(Zo(!1)),await o.addScriptTag({content:await ri()}),await o.evaluate(sc({events:r,offsetMs:n})),await o.evaluate(Yo());let i=o.locator(".replayer-wrapper iframe").first(),a=await(await i.count()>0?i:o).screenshot({type:"png"});return{html:await o.evaluate(ac()),png:a}}function sc({events:e,offsetMs:r}){return`(() => {
311
+ })()`}function ri(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var ni=mn(pn("@ripplo/rrweb-bundle/replay","rrweb-replay.js"));async function ii({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!ru(e))return ae({kind:"run-not-found",runId:t});let o=await Zo(e),i=o[0],s=o.at(-1);if(i==null||s==null)return ae({kind:"no-rrweb-events",runId:t});let a=s.timestamp-i.timestamp,l=r.kind==="offset"?r.offsetMs:r.at-i.timestamp;if(l<0)return ae({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let c=Math.min(l,a),g=String(Math.round(c)),f=oi.join(n,`snapshot-${g}ms.png`),p=oi.join(n,`snapshot-${g}ms.html`);return(await tu({events:o,htmlPath:p,offsetMs:c,pngPath:f})).map(()=>({durationMs:a,htmlPath:p,offsetMs:c,pngPath:f,viewport:kr(o)}))}async function tu({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await ri();if(o==null)return ae({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await ou({browser:o,events:e,offsetMs:n});return await ti(t,s),await ti(r,i,"utf8"),nu(void 0)}catch(i){return ae({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function ou({browser:e,events:r,offsetMs:n}){let t=kr(r),o=await e.newPage({viewport:t});await o.setContent(Xo(!1)),await o.addScriptTag({content:await ni()}),await o.evaluate(iu({events:r,offsetMs:n})),await o.evaluate(ei());let i=o.locator(".replayer-wrapper iframe").first(),a=await(await i.count()>0?i:o).screenshot({type:"png"});return{html:await o.evaluate(su()),png:a}}function iu({events:e,offsetMs:r}){return`(() => {
342
312
  const replayer = new globalThis.__RipploReplayer(${JSON.stringify(e)}, {
343
- insertStyleRules: [${JSON.stringify(Xo)}],
313
+ insertStyleRules: [${JSON.stringify(Yo)}],
344
314
  mouseTail: false,
345
315
  root: document.body,
346
316
  showWarning: false,
347
317
  });
348
318
  replayer.pause(${String(r+.5)});
349
319
  globalThis.__ripploSnapshotReplayer = replayer;
350
- })()`}function ac(){return`(() => {
320
+ })()`}function su(){return`(() => {
351
321
  const replayer = globalThis.__ripploSnapshotReplayer;
352
322
  if (replayer == null) {
353
323
  return "";
@@ -365,44 +335,44 @@ iframe { border: none; }
365
335
  }
366
336
  });
367
337
  return "<!doctype html>\\n" + doc.documentElement.outerHTML;
368
- })()`}function si({cwd:e,moment:r,runId:n}){let t=ii.join(e,".ripplo","debug",n);return oi({jsonlPath:ii.join(t,"behavior.jsonl"),moment:r,outDir:t,runId:n})}function ai(e){return[`${c.good("ok")} \u2014 rendered the page at ${String(Math.round(e.offsetMs))}ms into the recording (duration ${String(Math.round(e.durationMs))}ms, viewport ${String(e.viewport.width)}\xD7${String(e.viewport.height)})`,e.pngPath,"Read the PNG above to see the page state. Layout and text are faithful \u2014 URL-referenced images may be blank if the dev server is down.",e.htmlPath,"The HTML is the same frame with every element tagged `data-rrweb-id`. Grep it for your element's class or text to get the id for `tasks comment --element`."].join(`
369
- `)}function li(e){return`${c.bad("fail")} \u2014 ${lc(e)}`}function di(){return`${c.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function lc(e){switch(e.kind){case"run-not-found":return`no debug artifacts for run ${e.runId} (.ripplo/debug/${e.runId}/behavior.jsonl missing). ${C("run")}`;case"no-rrweb-events":return`run ${e.runId} has a behavior.jsonl but no rrweb events \u2014 nothing to replay.`;case"moment-out-of-range":return`${e.moment.kind==="offset"?"--offset":"--at"} is outside the recording, which spans ${String(e.firstTimestamp)}\u2013${String(e.lastTimestamp)} (duration ${String(e.durationMs)}ms). Pass --at <epoch-ms from behavior.jsonl> or --offset <0\u2013${String(e.durationMs)}>.`;case"browser-failed":return`replay browser failed (${e.detail}). Is chromium installed? Try \`npx playwright install chromium\`.`}}async function ui({at:e,offset:r,runId:n}){let t=dc({at:e,offset:r});t==null&&(process.stderr.write(`${di()}
338
+ })()`}function ai({cwd:e,moment:r,runId:n}){let t=si.join(e,".ripplo","debug",n);return ii({jsonlPath:si.join(t,"behavior.jsonl"),moment:r,outDir:t,runId:n})}function li(e){return[`${u.good("ok")} \u2014 rendered the page at ${String(Math.round(e.offsetMs))}ms into the recording (duration ${String(Math.round(e.durationMs))}ms, viewport ${String(e.viewport.width)}\xD7${String(e.viewport.height)})`,e.pngPath,"Read the PNG above to see the page state. Layout and text are faithful \u2014 URL-referenced images may be blank if the dev server is down.",e.htmlPath,"The HTML is the same frame with every element tagged `data-rrweb-id`. Grep it for your element's class or text to get the id for `tasks comment --element`."].join(`
339
+ `)}function di(e){return`${u.bad("fail")} \u2014 ${au(e)}`}function ci(){return`${u.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function au(e){switch(e.kind){case"run-not-found":return`no debug artifacts for run ${e.runId} (.ripplo/debug/${e.runId}/behavior.jsonl missing). ${R("run")}`;case"no-rrweb-events":return`run ${e.runId} has a behavior.jsonl but no rrweb events \u2014 nothing to replay.`;case"moment-out-of-range":return`${e.moment.kind==="offset"?"--offset":"--at"} is outside the recording, which spans ${String(e.firstTimestamp)}\u2013${String(e.lastTimestamp)} (duration ${String(e.durationMs)}ms). Pass --at <epoch-ms from behavior.jsonl> or --offset <0\u2013${String(e.durationMs)}>.`;case"browser-failed":return`replay browser failed (${e.detail}). Is chromium installed? Try \`npx playwright install chromium\`.`}}async function ui({at:e,offset:r,runId:n}){let t=lu({at:e,offset:r});t==null&&(process.stderr.write(`${ci()}
370
340
  `),process.exit(1));let o=await ee(process.cwd(),n);o.isErr()&&(process.stderr.write(`${re(o.error)}
371
- `),process.exit(1)),(await si({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${ai(s)}
372
- `)},s=>{process.stderr.write(`${li(s)}
373
- `),process.exit(1)})}function dc({at:e,offset:r}){if(e!=null&&r==null)return{at:e,kind:"absolute"};if(r!=null&&e==null)return{kind:"offset",offsetMs:r}}function ci(e,r){switch(e.kind){case"config-failed":return S(e.failure);case"compile-failed":return J(e.error);case"no-test":return`test "${e.ref}" not found \u2014 run npx ripplo compile to see available tests`;case"unplannable":return"the recorded walk no longer matches the model \u2014 run npx ripplo compile, then re-run";case"run-failed":return`teleport failed before reaching the step: ${z(e.error)}`;case"done":return uc(e.result,r)}}function pi(e){return e.kind==="done"&&e.result.kind==="handed-over"}function mi(e,r){return`landed at step ${String(e)} of ${r} \u2014 close the window to tear down`}function uc(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
341
+ `),process.exit(1)),(await ai({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${li(s)}
342
+ `)},s=>{process.stderr.write(`${di(s)}
343
+ `),process.exit(1)})}function lu({at:e,offset:r}){if(e!=null&&r==null)return{at:e,kind:"absolute"};if(r!=null&&e==null)return{kind:"offset",offsetMs:r}}function pi(e,r){switch(e.kind){case"config-failed":return S(e.failure);case"compile-failed":return J(e.error);case"no-test":return`test "${e.ref}" not found \u2014 run npx ripplo compile to see available tests`;case"unplannable":return"the recorded walk no longer matches the model \u2014 run npx ripplo compile, then re-run";case"run-failed":return`teleport failed before reaching the step: ${z(e.error)}`;case"done":return du(e.result,r)}}function mi(e){return e.kind==="done"&&e.result.kind==="handed-over"}function fi(e,r){return`landed at step ${String(e)} of ${r} \u2014 close the window to tear down`}function du(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
374
344
 
375
- ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
345
+ ${e.contradictions.map(t=>an({contradiction:t,evidencePath:void 0})).join(`
376
346
 
377
- `)}`:`torn down \u2014 teleport session for ${r} ended`}async function fi({ref:e,step:r}){let n=new AbortController;process.once("SIGINT",()=>{n.abort()});let t=()=>{process.stdout.write(`${mi(r,e)}
378
- `)},o=await yt({cwd:process.cwd(),onReady:t,signal:n.signal,step:r,target:{kind:"test",ref:e}});process.stdout.write(`${ci(o,e)}
379
- `),process.exit(pi(o)?0:1)}import gi from"path";import{randomUUID as cc}from"crypto";async function yi({cwd:e,onReady:r,signal:n}){let t=y(e).match(s=>s,s=>s.kind);if(typeof t=="string")return{detail:t,kind:"config-failed"};let o=`capture-${cc()}`;return(await cn({clientVersion:b(),debugDir:gi.join(t.cwd,".ripplo","debug"),onReady:r,profileDir:gi.join(t.cwd,".ripplo",".local","capture-profile"),runId:o,startUrl:t.appUrl},n)).match(s=>({behaviorPath:s.behaviorPath,kind:"done",runId:o}),s=>({error:s,kind:"run-failed"}))}function hi(){return"Capturing. Sign in if needed, click through your flow, then press Ctrl-C here to finish. Your login is remembered for next time."}function ki(e){return e.kind==="config-failed"?`Could not read project config: ${e.detail}`:e.kind==="run-failed"?"Capture failed to start. Could not launch the browser.":pc(e.behaviorPath,e.runId)}function wi(e){return e.kind==="done"}function pc(e,r){return[`Capture saved to ${e}`,"","Paste this to Claude Code to model the journey:",""," Load /ripplo:create. Turn this session into one critical Ripplo user journey under .ripplo/workflows/.","",` 1. Run \`npx ripplo clickpath ${r}\`. Name the user's intent, natural entry point, and actions that belong to that intent. Omit capture detours that are not part of the journey.`,` 2. Read ${e} for state-source requests and spans. Add only relevant paths to .ripplo/state.ts. Write the widest starting-state constraints valid for the whole journey.`," 3. Keep state-rendered values connected through handles and arbitrary(field). Use exact(value) only when the literal drives behavior."," 4. Declare every visible outcome and complete state effect, including cascades. Make every effect provably change state."," 5. Run `npx ripplo compile`, complete the /ripplo:create generality audit, then run the workflow."].join(`
380
- `)}async function bi(){let e=new AbortController;process.once("SIGINT",()=>{e.abort()});let r=await yi({cwd:process.cwd(),onReady:mc,signal:e.signal});process.stdout.write(`${ki(r)}
381
- `),process.exit(wi(r)?0:1)}function mc(){process.stdout.write(`${hi()}
382
- `)}import{existsSync as fc,readFileSync as gc}from"fs";import yc from"path";function vi(e,r){let n=yc.join(e,".ripplo","debug",r,"behavior.jsonl");return fc(n)?{actions:pn(gc(n,{encoding:"utf8"})),kind:"ok"}:{kind:"not-found",runId:r}}function Si(e){return e.kind==="not-found"?`No capture found for run ${e.runId}. Run npx ripplo capture first.`:e.actions.length===0?"No user actions found in this capture.":e.actions.map((r,n)=>hc(r,n)).join(`
383
- `)}function xi(e){return e.kind==="ok"}function hc(e,r){let n=e.element,t=n?.role??n?.tag??"?",o=n?.ariaLabel??n?.text;return[`${String(r+1)}.`,e.kind.padEnd(6),t.padEnd(10),o==null?"":`name=${JSON.stringify(o)}`,n?.testId==null?"":`testId=${n.testId}`,e.value==null?"":`value=${JSON.stringify(e.value)}`].filter(s=>s.length>0).join(" ")}function Ci({runId:e}){let r=vi(process.cwd(),e);process.stdout.write(`${Si(r)}
384
- `),process.exit(xi(r)?0:1)}async function Ri(){let e=w();try{let n=(await oe(e.cwd,e)).match(t=>t,t=>{process.stderr.write(`${S(t)}
347
+ `)}`:`torn down \u2014 teleport session for ${r} ended`}async function gi({ref:e,step:r}){let n=new AbortController;process.once("SIGINT",()=>{n.abort()});let t=()=>{process.stdout.write(`${fi(r,e)}
348
+ `)},o=await wt({cwd:process.cwd(),onReady:t,signal:n.signal,step:r,target:{kind:"test",ref:e}});process.stdout.write(`${pi(o,e)}
349
+ `),process.exit(mi(o)?0:1)}import yi from"path";import{randomUUID as cu}from"crypto";async function hi({cwd:e,onReady:r,signal:n}){let t=y(e).match(s=>s,s=>s.kind);if(typeof t=="string")return{detail:t,kind:"config-failed"};let o=`capture-${cu()}`;return(await fn({clientVersion:w(),debugDir:yi.join(t.cwd,".ripplo","debug"),onReady:r,profileDir:yi.join(t.cwd,".ripplo",".local","capture-profile"),runId:o,startUrl:t.appUrl},n)).match(s=>({behaviorPath:s.behaviorPath,kind:"done",runId:o}),s=>({error:s,kind:"run-failed"}))}function ki(){return"Capturing. Sign in if needed, click through your flow, then press Ctrl-C here to finish. Your login is remembered for next time."}function wi(e){return e.kind==="config-failed"?`Could not read project config: ${e.detail}`:e.kind==="run-failed"?"Capture failed to start. Could not launch the browser.":uu(e.behaviorPath,e.runId)}function bi(e){return e.kind==="done"}function uu(e,r){return[`Capture saved to ${e}`,"","Paste this to Claude Code to model the journey:",""," Load /ripplo:create. Turn this session into one critical Ripplo user journey under .ripplo/workflows/.","",` 1. Run \`npx ripplo clickpath ${r}\`. Name the user's intent, natural entry point, and actions that belong to that intent. Omit capture detours that are not part of the journey.`,` 2. Read ${e} for state-source requests and spans. Add only relevant paths to .ripplo/state.ts. Write the widest starting-state constraints valid for the whole journey.`," 3. Keep state-rendered values connected through handles and arbitrary(field). Use exact(value) only when the literal drives behavior."," 4. Declare every visible outcome and complete state effect, including cascades. Make every effect provably change state."," 5. Run `npx ripplo compile`, complete the /ripplo:create generality audit, then run the workflow."].join(`
350
+ `)}async function vi(){let e=new AbortController;process.once("SIGINT",()=>{e.abort()});let r=await hi({cwd:process.cwd(),onReady:pu,signal:e.signal});process.stdout.write(`${wi(r)}
351
+ `),process.exit(bi(r)?0:1)}function pu(){process.stdout.write(`${ki()}
352
+ `)}import{existsSync as mu,readFileSync as fu}from"fs";import gu from"path";function Si(e,r){let n=gu.join(e,".ripplo","debug",r,"behavior.jsonl");return mu(n)?{actions:gn(fu(n,{encoding:"utf8"})),kind:"ok"}:{kind:"not-found",runId:r}}function xi(e){return e.kind==="not-found"?`No capture found for run ${e.runId}. Run npx ripplo capture first.`:e.actions.length===0?"No user actions found in this capture.":e.actions.map((r,n)=>yu(r,n)).join(`
353
+ `)}function Ri(e){return e.kind==="ok"}function yu(e,r){let n=e.element,t=n?.role??n?.tag??"?",o=n?.ariaLabel??n?.text;return[`${String(r+1)}.`,e.kind.padEnd(6),t.padEnd(10),o==null?"":`name=${JSON.stringify(o)}`,n?.testId==null?"":`testId=${n.testId}`,e.value==null?"":`value=${JSON.stringify(e.value)}`].filter(s=>s.length>0).join(" ")}function Ci({runId:e}){let r=Si(process.cwd(),e);process.stdout.write(`${xi(r)}
354
+ `),process.exit(Ri(r)?0:1)}async function $i(){let e=b();try{let n=(await oe(e.cwd,e)).match(t=>t,t=>{process.stderr.write(`${S(t)}
385
355
  `),process.exit(1)});process.stdout.write(`Synced ${String(n.lockfile.workflows.length)} workflows to dev session ${n.devSessionId}
386
356
  `)}catch(r){let n=r instanceof Error?r.message:String(r);process.stderr.write(`ripplo sync failed: ${n}
387
- `),process.stderr.write(`${C("setup","verify auth + server reachability")}
388
- `),process.exit(1)}}import{spawnSync as vc}from"child_process";import Sc from"fs";import xc from"path";import Cc from"semver";import le from"fs";import kc from"os";import B from"path";function $i(e){let r=e.split(B.sep);return r.includes("_npx")?"npx":e.includes(B.join("packages","cli"))?"workspace":wc(r)?"local":"global"}function Ei(){let e=B.join(kc.homedir(),".npm","_npx");return le.existsSync(e)?le.readdirSync(e).map(r=>B.join(e,r)).filter(r=>le.existsSync(B.join(r,"node_modules","ripplo"))).map(r=>(le.rmSync(r,{force:!0,recursive:!0}),r)):[]}function wc(e){let r=e.lastIndexOf("node_modules");if(r<1)return!1;let n=e.slice(0,r).join(B.sep);return le.existsSync(B.join(n,"package.json"))}import{spawnSync as Pi}from"child_process";var bc=["user","project","local"];function kr(){return Pi("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":bc.find(n=>Pi("claude",["plugin","update","ripplo","--scope",n],{stdio:"ignore"}).status===0)==null?"not-installed":"updated"}function Ii(e){return`ripplo v${e} is already the latest version.`}function Ai(e){return`ripplo v${e}: could not reach the npm registry to check for updates.`}function wr({evicted:e,latest:r,mode:n}){return n==="npx"?`ripplo: ${e===0?"npx cache had no stale copy":`cleared ${j(e,"stale npx cache entry","stale npx cache entries")}`} \u2014 the next \`npx ripplo\` command runs v${r}.`:`ripplo: updated global install to v${r}.`}function Ti(){return"ripplo: this is a workspace build (packages/cli/dist) \u2014 update via git pull + `pnpm --filter ripplo build`."}function ji(e){return`ripplo: installed as a project dependency \u2014 update it with your package manager: \`${e}\``}function Mi(e){return`ripplo: \`npm install -g ripplo@latest\` failed: ${e}`}function br(e){switch(e){case"updated":return"ripplo: Claude plugin updated \u2014 restart Claude Code (or /reload-plugins) to apply.";case"not-installed":return"ripplo: Claude plugin not installed in this project \u2014 skipped.";case"claude-missing":return"ripplo: claude binary not found \u2014 skipped plugin update."}}function Li(e){return e?"ripplo: idle daemon stopped \u2014 the next `npx ripplo run` restarts it on the new version.":"ripplo: daemon is busy \u2014 it picks up the new version once idle (the next `npx ripplo run` handles it)."}var Rc=1e4;async function Ni(){let e=b(),r=process.argv[1];$c(process.cwd());let n=await xe(Rc);process.stdout.write(`${ve({current:e,latest:n})}
389
- `),n==null&&(process.stderr.write(`${Ai(e)}
390
- `),process.exit(1)),Cc.gt(n,e)||(process.stdout.write(`${Ii(e)}
391
- `),process.stdout.write(`${br(kr())}
392
- `),process.exit(0));let t=r==null?"global":$i(r);Ec({latest:n,mode:t}),process.stdout.write(`${br(kr())}
393
- `),await Ic(process.cwd()),process.exit(0)}function $c(e){if(!Sc.existsSync(xc.join(e,".ripplo")))return;let r=Ee(e);r==="written"&&process.stdout.write(`${Pe(r).trim()}
394
- `)}function Ec({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${Ti()}
395
- `),process.exit(0)),r==="local"){let n=process.cwd(),t=nr({cwd:n,pm:tr(n),version:e});process.stdout.write(`${ji(t)}
396
- `),process.exit(0)}if(r==="npx"){let n=Ei();process.stdout.write(`${wr({evicted:n.length,latest:e,mode:r})}
397
- `);return}Pc(e)}function Pc(e){let r=`ripplo@${e}`,n=vc("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${Mi(t)}
398
- `),process.exit(1)}process.stdout.write(`${wr({evicted:0,latest:e,mode:"global"})}
399
- `)}async function Ic(e){if((await _n(e)).kind==="not-running")return;let n=await Wn(e);process.stdout.write(`${Li(n)}
400
- `)}async function Oi({action:e,exploreDebug:r}){if(e==="status"){let{statusCommand:t}=await import("./status-4LFECRO4.js");await t({format:"summary"});return}if(e==="stop"||e==="restart"){let t=await Ac();(e==="stop"||!t)&&process.exit(t?0:1)}Tc();let{runDaemon:n}=await import("./daemon-2LB22RRW.js");await n({exploreDebug:r})}async function Ac(){let{stopDevDaemon:e}=await import("./daemon-lock-RPKO5SNE.js"),{renderDaemonStopResult:r}=await import("./daemon-RDOVYYAZ.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
401
- `),n.kind!=="timeout"}function Tc(){let e=Y(O());e!=null&&process.stderr.write(`${e}
402
- `)}function Fi(e){return`executor: ${e}`}function Wi(e){return e==="cloud"?"executor set to cloud \u2014 the daemon is bringing the tunnel up, the next run dispatches to the cloud fleet":"executor set to local \u2014 the next run executes on this machine"}function _i(e){switch(e.kind){case"no-session":return"No active dev session for this directory. Start `npx ripplo daemon` first.";case"starting":return"Dev session is still syncing \u2014 the daemon just started. Retry in a moment.";case"session-ended":return"The dev session ended before the switch landed. Check `npx ripplo daemon status` and try again.";case"empty-response":return"The server returned no result for the switch. Try again."}}async function Di({mode:e}){let r=y(process.cwd()).match(t=>t,t=>{process.stderr.write(`${S(t)}
403
- `),process.exit(1)});(e==null?await kt(r):await wt(r,e)).match(t=>{process.stdout.write(`${e==null?Fi(t):Wi(t)}
357
+ `),process.stderr.write(`${R("setup","verify auth + server reachability")}
358
+ `),process.exit(1)}}import{spawnSync as bu}from"child_process";import vu from"fs";import Su from"path";import xu from"semver";import le from"fs";import hu from"os";import q from"path";function Ei(e){let r=e.split(q.sep);return r.includes("_npx")?"npx":e.includes(q.join("packages","cli"))?"workspace":ku(r)?"local":"global"}function Pi(){let e=q.join(hu.homedir(),".npm","_npx");return le.existsSync(e)?le.readdirSync(e).map(r=>q.join(e,r)).filter(r=>le.existsSync(q.join(r,"node_modules","ripplo"))).map(r=>(le.rmSync(r,{force:!0,recursive:!0}),r)):[]}function ku(e){let r=e.lastIndexOf("node_modules");if(r<1)return!1;let n=e.slice(0,r).join(q.sep);return le.existsSync(q.join(n,"package.json"))}import{spawnSync as Ii}from"child_process";var wu=["user","project","local"];function wr(){return Ii("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":wu.find(n=>Ii("claude",["plugin","update","ripplo","--scope",n],{stdio:"ignore"}).status===0)==null?"not-installed":"updated"}function Ai(e){return`ripplo v${e} is already the latest version.`}function Ti(e){return`ripplo v${e}: could not reach the npm registry to check for updates.`}function br({evicted:e,latest:r,mode:n}){return n==="npx"?`ripplo: ${e===0?"npx cache had no stale copy":`cleared ${j(e,"stale npx cache entry","stale npx cache entries")}`} \u2014 the next \`npx ripplo\` command runs v${r}.`:`ripplo: updated global install to v${r}.`}function ji(){return"ripplo: this is a workspace build (packages/cli/dist) \u2014 update via git pull + `pnpm --filter ripplo build`."}function Mi(e){return`ripplo: installed as a project dependency \u2014 update it with your package manager: \`${e}\``}function Li(e){return`ripplo: \`npm install -g ripplo@latest\` failed: ${e}`}function vr(e){switch(e){case"updated":return"ripplo: Claude plugin updated \u2014 restart Claude Code (or /reload-plugins) to apply.";case"not-installed":return"ripplo: Claude plugin not installed in this project \u2014 skipped.";case"claude-missing":return"ripplo: claude binary not found \u2014 skipped plugin update."}}function Ni(e){return e?"ripplo: idle daemon stopped \u2014 the next `npx ripplo run` restarts it on the new version.":"ripplo: daemon is busy \u2014 it picks up the new version once idle (the next `npx ripplo run` handles it)."}var Ru=1e4;async function Oi(){let e=w(),r=process.argv[1];Cu(process.cwd());let n=await xe(Ru);process.stdout.write(`${ve({current:e,latest:n})}
359
+ `),n==null&&(process.stderr.write(`${Ti(e)}
360
+ `),process.exit(1)),xu.gt(n,e)||(process.stdout.write(`${Ai(e)}
361
+ `),process.stdout.write(`${vr(wr())}
362
+ `),process.exit(0));let t=r==null?"global":Ei(r);$u({latest:n,mode:t}),process.stdout.write(`${vr(wr())}
363
+ `),await Pu(process.cwd()),process.exit(0)}function Cu(e){if(!vu.existsSync(Su.join(e,".ripplo")))return;let r=Ee(e);r==="written"&&process.stdout.write(`${Pe(r).trim()}
364
+ `)}function $u({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${ji()}
365
+ `),process.exit(0)),r==="local"){let n=process.cwd(),t=tr({cwd:n,pm:or(n),version:e});process.stdout.write(`${Mi(t)}
366
+ `),process.exit(0)}if(r==="npx"){let n=Pi();process.stdout.write(`${br({evicted:n.length,latest:e,mode:r})}
367
+ `);return}Eu(e)}function Eu(e){let r=`ripplo@${e}`,n=bu("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${Li(t)}
368
+ `),process.exit(1)}process.stdout.write(`${br({evicted:0,latest:e,mode:"global"})}
369
+ `)}async function Pu(e){if((await qn(e)).kind==="not-running")return;let n=await Un(e);process.stdout.write(`${Ni(n)}
370
+ `)}async function Fi({action:e,exploreDebug:r}){if(e==="status"){let{statusCommand:t}=await import("./status-VQ57DB6M.js");await t({format:"summary"});return}if(e==="stop"||e==="restart"){let t=await Iu();(e==="stop"||!t)&&process.exit(t?0:1)}Au();let{runDaemon:n}=await import("./daemon-FPJC6UTS.js");await n({exploreDebug:r})}async function Iu(){let{stopDevDaemon:e}=await import("./daemon-lock-RPKO5SNE.js"),{renderDaemonStopResult:r}=await import("./daemon-JCI3PIF2.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
371
+ `),n.kind!=="timeout"}function Au(){let e=Y(O());e!=null&&process.stderr.write(`${e}
372
+ `)}function Wi(e){return`executor: ${e}`}function Di(e){return e==="cloud"?"executor set to cloud \u2014 the daemon is bringing the tunnel up, the next run dispatches to the cloud fleet":"executor set to local \u2014 the next run executes on this machine"}function _i(e){switch(e.kind){case"no-session":return"No active dev session for this directory. Start `npx ripplo daemon` first.";case"starting":return"Dev session is still syncing \u2014 the daemon just started. Retry in a moment.";case"session-ended":return"The dev session ended before the switch landed. Check `npx ripplo daemon status` and try again.";case"empty-response":return"The server returned no result for the switch. Try again."}}async function Ui({mode:e}){let r=y(process.cwd()).match(t=>t,t=>{process.stderr.write(`${S(t)}
373
+ `),process.exit(1)});(e==null?await vt(r):await St(r,e)).match(t=>{process.stdout.write(`${e==null?Wi(t):Di(t)}
404
374
  `)},t=>{process.stderr.write(`${_i(t)}
405
- `),process.exit(1)})}import{spawnSync as Bc}from"child_process";import{graphql as Ui}from"gql.tada";import{err as vr,ok as Sr}from"neverthrow";var jc=Ui(`
375
+ `),process.exit(1)})}import{spawnSync as Uu}from"child_process";import{graphql as qi}from"gql.tada";import{err as Sr,ok as xr}from"neverthrow";var Tu=qi(`
406
376
  query ExploreState($devSessionId: String!) {
407
377
  exploration(devSessionId: $devSessionId) {
408
378
  active
@@ -410,9 +380,10 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
410
380
  cloudWorkers
411
381
  localWorkers
412
382
  maxTrailLength
383
+ unhealthySince
413
384
  }
414
385
  }
415
- `),Mc=Ui(`
386
+ `),ju=qi(`
416
387
  mutation SetExploration(
417
388
  $devSessionId: String!
418
389
  $active: Boolean!
@@ -434,18 +405,20 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
434
405
  cloudWorkers
435
406
  localWorkers
436
407
  maxTrailLength
408
+ unhealthySince
437
409
  }
438
410
  }
439
- `);async function Bi(e){let r=await Hi(e);if(r.isErr())return vr(r.error);let n=await Vi(e,r.value.id);return Sr(zi(r.value.executor,n))}async function qi(e,r){let n=await Hi(e);if(n.isErr())return vr(n.error);let t=await Vi(e,n.value.id),o=Lc(n.value.executor,t,r),i=await d({config:e,document:Mc,variables:{devSessionId:n.value.id,...o}});return Sr(zi(n.value.executor,i.setExploration))}async function Hi(e){let r=await Gn(e);return r.kind==="active"?Sr({executor:r.executor,id:r.id}):vr({kind:r.kind==="starting"?"starting":"no-session"})}async function Vi(e,r){return(await d({config:e,document:jc,variables:{devSessionId:r}})).exploration??null}function zi(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??Xe,workers:(n?r?.localWorkers:r?.cloudWorkers)??0}}function Lc(e,r,n){let t=e==="local",o=(t?r?.localWorkers:r?.cloudWorkers)??0,i=(t?r?.cloudWorkers:r?.localWorkers)??0,s=Nc(n,o);return{active:n.active,autoCreateTasks:r?.autoCreateTasks??!1,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??Xe}}function Nc(e,r){return e.active?e.workers!=null?e.workers:r>0?r:bt:r}function Ki(e){return e.active?`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`:"explorer: off"}function Gi(e){return e.active?`explorer on \u2014 walking ${String(e.workers)} background paths, trail ${String(e.maxTrailLength)}, on the ${e.executor} executor. Findings land as tasks \u2014 triage with /ripplo:tasks`:"explorer off \u2014 background exploration stopped"}function Ji(e){return e.kind==="starting"?"Dev session is still syncing \u2014 the daemon just started. Retry in a moment.":"No active dev session for this directory. Start `npx ripplo daemon` first."}var Oc=32;async function Qi({cwd:e,maxTrailLength:r}){let n=await pe(e);if(n.result.isErr())return{kind:"error",reason:"compile-failed"};let t=await he(e);if(t==null)return{kind:"error",reason:"no-lockfile"};let o=await G(e,n.result.value),i=an(o);return i.kind==="model-empty"?{kind:"error",reason:"model-empty"}:{analysis:await ln({attempts:Oc,modelHash:t,prepared:i.value,strategy:r==null?ze("even"):{...ze("even"),maxAttemptLength:r}}),kind:"ok"}}function Xi(e){return["Explorer model analysis",`${String(e.plannedPaths)} of ${String(e.attempts)} agendas produced complete paths.`,`${String(e.transitionsReached)} of ${String(e.transitionCount)} transitions were reached across ${String(e.composablePairs)} adjacent transition pairs.`,`${String(e.envelopesReached)} starting-state families and ${String(e.crossWorkflowPaths)} cross-workflow paths were used.`,Fc(e),Wc(e),_c(e),Dc(e),`Reached patterns: ${e.patternsReached.length===0?"none":e.patternsReached.join(", ")}.`,`${String(e.isolatedTransitions.length)} of ${String(e.targetsAnalyzed)} targeted transitions were unreachable. ${String(e.weaklyConnectedTransitions.length)} appeared in only one planned path.`,...Zi({heading:"Targets without a proved path:",transitions:e.isolatedTransitions}),...Zi({heading:"Targets reached in one planned path:",transitions:e.weaklyConnectedTransitions}),...Uc(e.recommendations)].join(`
440
- `)}function Yi(e){switch(e){case"compile-failed":return"Explorer analysis could not load the workflow model. Run npx ripplo compile and fix the reported errors.";case"model-empty":return"Explorer analysis found no runnable workflows. Add a workflow with a modeled navigation step.";case"no-lockfile":return"Explorer analysis could not find .ripplo/ripplo.lock. Run npx ripplo compile."}}function Fc(e){let r=e.planningDepth;return`Path length target: ${String(r.targetSteps)} steps. Planned ${de(r.averagePlannedSteps)} on average and ${String(r.maxPlannedSteps)} at most after searching ${de(r.averageSearchedSteps)} on average and ${String(r.maxSearchedSteps)} at most. Search stopped at the target ${String(r.searchStops.targetReached)} times, exhausted legal continuations ${String(r.searchStops.frontierExhausted)} times, and exhausted its budget ${String(r.searchStops.budgetExhausted)} times.`}function de(e){return String(Math.round(e))}function Wc(e){let r=e.planningPerformance;return`Planner average: ${_(r.total.averageMs)} total, ${_(r.envelopes.averageMs)} starting states, ${_(r.search.averageMs)} search, and ${_(r.selection.averageMs)} selection. Total p95: ${_(r.total.p95Ms)}.`}function _(e){return`${String(Math.round(e))} ms`}function _c(e){let r=e.planningPerformance;return`Search average: ${_(r.expansion.averageMs)} proving runnable steps, ${_(r.candidates.averageMs)} scoring candidates, and ${_(r.beam.averageMs)} retaining the beam.`}function Dc(e){let r=e.planningWork;return`Search average: ${de(r.averageExpandedNodes)} expanded nodes after considering ${de(r.averageRulesConsidered)} transitions and ${de(r.averageParameterAttempts)} parameter attempts.`}function Zi({heading:e,transitions:r}){return r.length===0?[]:[e,...r.map(n=>`- ${n.test}: ${n.action}`)]}function Uc(e){return e.length===0?["No workflow coverage improvements are required by this analysis."]:["Recommendations:",...e.map(r=>`- ${r}`)]}async function es({json:e,state:r,trail:n,workers:t}){if(r==="analyze"){qc();let s=await Qi({cwd:process.cwd(),maxTrailLength:n});s.kind==="error"&&(process.stderr.write(`${Yi(s.reason)}
441
- `),process.exit(1)),process.stdout.write(`${e?JSON.stringify(s.analysis,null,2):Xi(s.analysis)}
411
+ `);async function Bi(e){let r=await Vi(e);if(r.isErr())return Sr(r.error);let n=await zi(e,r.value.id);return xr(Ki(r.value.executor,n))}async function Hi(e,r){let n=await Vi(e);if(n.isErr())return Sr(n.error);let t=await zi(e,n.value.id),o=Mu(n.value.executor,t,r),i=await d({config:e,document:ju,variables:{devSessionId:n.value.id,...o}});return xr(Ki(n.value.executor,i.setExploration))}async function Vi(e){let r=await Zn(e);return r.kind==="active"?xr({executor:r.executor,id:r.id}):Sr({kind:r.kind==="starting"?"starting":"no-session"})}async function zi(e,r){return(await d({config:e,document:Tu,variables:{devSessionId:r}})).exploration??null}function Ki(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??Ye,unhealthy:r?.unhealthySince!=null,workers:(n?r?.localWorkers:r?.cloudWorkers)??0}}function Mu(e,r,n){let t=e==="local",o=(t?r?.localWorkers:r?.cloudWorkers)??0,i=(t?r?.cloudWorkers:r?.localWorkers)??0,s=Lu(n,o);return{active:n.active,autoCreateTasks:r?.autoCreateTasks??!1,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??Ye}}function Lu(e,r){return e.active?e.workers!=null?e.workers:r>0?r:xt:r}function Gi(e){if(!e.active)return e.unhealthy?"explorer: off \u2014 paused after repeated infra errors, turn it back on with npx ripplo explore on":"explorer: off";let r=`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`;return e.unhealthy?`${r}
412
+ explorer is hitting infra errors \u2014 it pauses if this persists`:r}function Ji(e){return e.active?`explorer on \u2014 walking ${String(e.workers)} background paths, trail ${String(e.maxTrailLength)}, on the ${e.executor} executor. Findings land as tasks \u2014 triage with /ripplo:tasks`:"explorer off \u2014 background exploration stopped"}function Qi(e){return e.kind==="starting"?"Dev session is still syncing \u2014 the daemon just started. Retry in a moment.":"No active dev session for this directory. Start `npx ripplo daemon` first."}var Nu=32;async function Zi({cwd:e,maxTrailLength:r}){let n=await pe(e);if(n.result.isErr())return{kind:"error",reason:"compile-failed"};let t=await he(e);if(t==null)return{kind:"error",reason:"no-lockfile"};let o=await G(e,n.result.value),i=cn(o);return i.kind==="model-empty"?{kind:"error",reason:"model-empty"}:{analysis:await un({attempts:Nu,modelHash:t,prepared:i.value,strategy:r==null?Ke("even"):{...Ke("even"),maxAttemptLength:r}}),kind:"ok"}}function Yi(e){return["Explorer model analysis",`${String(e.plannedPaths)} of ${String(e.attempts)} agendas produced complete paths.`,`${String(e.transitionsReached)} of ${String(e.transitionCount)} transitions were reached across ${String(e.composablePairs)} adjacent transition pairs.`,`${String(e.envelopesReached)} starting-state families and ${String(e.crossWorkflowPaths)} cross-workflow paths were used.`,Ou(e),Fu(e),Wu(e),Du(e),`Reached patterns: ${e.patternsReached.length===0?"none":e.patternsReached.join(", ")}.`,`${String(e.isolatedTransitions.length)} of ${String(e.targetsAnalyzed)} targeted transitions were unreachable. ${String(e.weaklyConnectedTransitions.length)} appeared in only one planned path.`,...Xi({heading:"Targets without a proved path:",transitions:e.isolatedTransitions}),...Xi({heading:"Targets reached in one planned path:",transitions:e.weaklyConnectedTransitions}),..._u(e.recommendations)].join(`
413
+ `)}function es(e){switch(e){case"compile-failed":return"Explorer analysis could not load the workflow model. Run npx ripplo compile and fix the reported errors.";case"model-empty":return"Explorer analysis found no runnable workflows. Add a workflow with a modeled navigation step.";case"no-lockfile":return"Explorer analysis could not find .ripplo/ripplo.lock. Run npx ripplo compile."}}function Ou(e){let r=e.planningDepth;return`Path length target: ${String(r.targetSteps)} steps. Planned ${de(r.averagePlannedSteps)} on average and ${String(r.maxPlannedSteps)} at most after searching ${de(r.averageSearchedSteps)} on average and ${String(r.maxSearchedSteps)} at most. Search stopped at the target ${String(r.searchStops.targetReached)} times, exhausted legal continuations ${String(r.searchStops.frontierExhausted)} times, and exhausted its budget ${String(r.searchStops.budgetExhausted)} times.`}function de(e){return String(Math.round(e))}function Fu(e){let r=e.planningPerformance;return`Planner average: ${D(r.total.averageMs)} total, ${D(r.envelopes.averageMs)} starting states, ${D(r.search.averageMs)} search, and ${D(r.selection.averageMs)} selection. Total p95: ${D(r.total.p95Ms)}.`}function D(e){return`${String(Math.round(e))} ms`}function Wu(e){let r=e.planningPerformance;return`Search average: ${D(r.expansion.averageMs)} proving runnable steps, ${D(r.candidates.averageMs)} scoring candidates, and ${D(r.beam.averageMs)} retaining the beam.`}function Du(e){let r=e.planningWork;return`Search average: ${de(r.averageExpandedNodes)} expanded nodes after considering ${de(r.averageRulesConsidered)} transitions and ${de(r.averageParameterAttempts)} parameter attempts.`}function Xi({heading:e,transitions:r}){return r.length===0?[]:[e,...r.map(n=>`- ${n.test}: ${n.action}`)]}function _u(e){return e.length===0?["No workflow coverage improvements are required by this analysis."]:["Recommendations:",...e.map(r=>`- ${r}`)]}async function rs({json:e,state:r,trail:n,workers:t}){if(r==="analyze"){qu();let s=await Zi({cwd:process.cwd(),maxTrailLength:n});s.kind==="error"&&(process.stderr.write(`${es(s.reason)}
414
+ `),process.exit(1)),process.stdout.write(`${e?JSON.stringify(s.analysis,null,2):Yi(s.analysis)}
442
415
  `);return}let o=y(process.cwd()).match(s=>s,s=>{process.stderr.write(`${S(s)}
443
- `),process.exit(1)});(r==null?await Bi(o):await qi(o,{active:r==="on",trail:n,workers:t})).match(s=>{process.stdout.write(`${r==null?Ki(s):Gi(s)}
444
- `)},s=>{process.stderr.write(`${Ji(s)}
445
- `),process.exit(1)})}function qc(){let e=O();e.kind!=="fresh"&&(e.kind==="foreign-binary"&&Fe(Y(e)??"This command is not using the workspace CLI."),process.stderr.write(`${Ae(e.packages)}
446
- `),we(e.workspaceRoot)||Fe(Te()),Hc())}function Fe(e){process.stderr.write(`${e}
447
- `),process.exit(1)}function Hc(){let e=process.argv[1];e==null&&Fe("Ripplo rebuilt the workspace but could not find the CLI entry point.");let r=Bc(process.execPath,[e,...process.argv.slice(2)],{cwd:process.cwd(),stdio:"inherit"});r.error!=null&&Fe(`Ripplo rebuilt the workspace but could not restart analysis: ${r.error.message}`),process.exit(r.status??1)}import{graphql as We}from"gql.tada";function rs(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function ns(e){return[`No test found for: ${e.join(", ")}`,"Pass a test id (kebab-case slug) or the exact intent string. List tests with `npx ripplo status`.",C("create")].join(`
448
- `)}import{graphql as Vc}from"gql.tada";var ts=Vc(`
416
+ `),process.exit(1)});(r==null?await Bi(o):await Hi(o,{active:r==="on",trail:n,workers:t})).match(s=>{process.stdout.write(`${r==null?Gi(s):Ji(s)}
417
+ `)},s=>{process.stderr.write(`${Qi(s)}
418
+ `),process.exit(1)})}function qu(){let e=O();e.kind!=="fresh"&&(e.kind==="foreign-binary"&&We(Y(e)??"This command is not using the workspace CLI."),process.stderr.write(`${Ae(e.packages)}
419
+ `),we(e.workspaceRoot)||We(Te()),Bu())}function We(e){process.stderr.write(`${e}
420
+ `),process.exit(1)}function Bu(){let e=process.argv[1];e==null&&We("Ripplo rebuilt the workspace but could not find the CLI entry point.");let r=Uu(process.execPath,[e,...process.argv.slice(2)],{cwd:process.cwd(),stdio:"inherit"});r.error!=null&&We(`Ripplo rebuilt the workspace but could not restart analysis: ${r.error.message}`),process.exit(r.status??1)}import{graphql as De}from"gql.tada";function ns(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function ts(e){return[`No test found for: ${e.join(", ")}`,"Pass a test id (kebab-case slug) or the exact intent string. List tests with `npx ripplo status`.",R("create")].join(`
421
+ `)}import{graphql as Hu}from"gql.tada";var os=Hu(`
449
422
  query ScopeStatus($projectId: String!, $cwd: String!) {
450
423
  project(id: $projectId) {
451
424
  id
@@ -465,7 +438,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
465
438
  }
466
439
  }
467
440
  }
468
- `);var zc=We(`
441
+ `);var Vu=De(`
469
442
  query ScopeWorkflowBySlug($projectId: String!, $cwd: String!, $slug: String!) {
470
443
  project(id: $projectId) {
471
444
  id
@@ -478,7 +451,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
478
451
  }
479
452
  }
480
453
  }
481
- `),Kc=We(`
454
+ `),zu=De(`
482
455
  mutation ScopeAddDirtyTests($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
483
456
  addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
484
457
  __typename
@@ -500,31 +473,31 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
500
473
  }
501
474
  }
502
475
  }
503
- `),Gc=We(`
476
+ `),Ku=De(`
504
477
  mutation ScopeLink($id: ID!, $workflowId: String!) {
505
478
  linkScopeItem(id: $id, workflowId: $workflowId) {
506
479
  id
507
480
  }
508
481
  }
509
- `),Jc=We(`
482
+ `),Gu=De(`
510
483
  mutation ScopeRemoveMany($ids: [ID!]!) {
511
484
  removeScopeItems(ids: $ids)
512
485
  }
513
- `);async function os(e){let r=w();await x(r);let t=(await d({config:r,document:ts,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
486
+ `);async function is(e){let r=b();await x(r);let t=(await d({config:r,document:os,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
514
487
  `);return}if(t.length===0){process.stdout.write("No scope items. Add some with `npx ripplo scope add <test-ids..>` or from the dashboard.\n");return}t.forEach(o=>{let i=o.workflow;if(i==null){process.stdout.write(` [intent] (${o.id}) ${o.label??""}
515
488
  `);return}let s=i.spec==null?"stub":"implemented";process.stdout.write(` [${s}] (${o.id}) ${i.slug} \u2014 ${i.name}
516
- `)})}async function is({testIds:e}){let r=w();await x(r),(await oe(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${S(a)}
517
- `),process.exit(1)});let o=(await d({config:r,document:Kc,variables:{cwd:r.cwd,projectId:r.projectId,workflowSlugs:e.map(a=>Qr(a))}})).addDirtyTestsToScope;o?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${o.message}
518
- `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${ns(o.slugs)}
519
- `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${rs()}
489
+ `)})}async function ss({testIds:e}){let r=b();await x(r),(await oe(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${S(a)}
490
+ `),process.exit(1)});let o=(await d({config:r,document:zu,variables:{cwd:r.cwd,projectId:r.projectId,workflowSlugs:e.map(a=>Yr(a))}})).addDirtyTestsToScope;o?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${o.message}
491
+ `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${ts(o.slugs)}
492
+ `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${ns()}
520
493
  `);return}let s=i.map(a=>a.workflow?.slug??"?").join(", ");process.stdout.write(`Added ${j(i.length,"scope item")}: ${s}
521
- `)}async function ss({id:e,testId:r}){let n=w();await x(n),(await oe(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${S(i)}
522
- `),process.exit(1)});let o=await Qc({cfg:n,slug:r});await d({config:n,document:Gc,variables:{id:e,workflowId:o}}),process.stdout.write(`Linked scope item ${e} to ${r}
523
- `)}async function as({ids:e}){let r=w();await x(r);let t=(await d({config:r,document:Jc,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${j(t,"scope item")}
524
- `)}async function Qc({cfg:e,slug:r}){let t=(await d({config:e,document:zc,variables:{cwd:e.cwd,projectId:e.projectId,slug:r}})).project?.devSession?.workflows?.[0];return t==null&&(process.stderr.write(`No workflow found with id "${r}". Create a stub first via the testing DSL.
525
- `),process.stderr.write(`${C("create")}
526
- `),process.exit(1)),t.id}import{graphql as L}from"gql.tada";import{print as ks}from"graphql";import{createClient as ws}from"graphql-sse";import xr from"fs";import Zc from"path";import{err as _e,ok as Xc}from"neverthrow";function ds({cwd:e,rrwebId:r,runId:n}){let t=cs(e,n);if(!xr.existsSync(t))return _e({kind:"no-behavior"});let o=gs(fs(t,r));if(o==null)return _e({kind:"not-found"});let i=Rr(o.node.type);return i===3?_e({kind:"text-node",parentId:Rr(o.parent?.id)}):i!==2?_e({kind:"non-element",nodeType:i??-1}):Xc({tagName:I(o.node.tagName)})}function us({cwd:e,rrwebId:r,runId:n}){let t=fs(cs(e,n),r);if(t==null)return null;let o=gs(t);return o==null||Rr(o.node.type)!==2?null:Yc(t)}function cs(e,r){return Zc.join(e,".ripplo","debug",r,"behavior.jsonl")}function Yc(e){let r=e.at(-1)??{},n=$r(r.attributes)??{},t=I(r.tagName);return{ariaName:I(n["aria-label"]),role:I(n.role),selector:rp(e),tagName:t==null?null:t.toLowerCase(),testId:I(n["data-testid"]),text:sp(ip(r))}}var ep=6;function rp(e){let r=ps(e,e.length-1,ep);return r.length===0?null:r.join(" > ")}function ps(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=np(t);if(o!=null)return[o];let i=tp(t,e[r-1]);return r===0||n===1?[i]:[...ps(e,r-1,n-1),i]}function np(e){let r=$r(e.attributes)??{},n=I(r["data-testid"]);if(n!=null)return`[data-testid="${n}"]`;let t=I(r.id);return t!=null&&t.length>0?`#${t}`:null}function tp(e,r){let n=(I(e.tagName)??"*").toLowerCase(),t=ms(r).filter(i=>(I(i.tagName)??"*").toLowerCase()===n);if(t.length<=1)return n;let o=t.findIndex(i=>i.id===e.id);return o===-1?n:`${n}:nth-of-type(${String(o+1)})`}function ms(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>De(n)):[]}function fs(e,r){return xr.existsSync(e)?xr.readFileSync(e,"utf8").split(`
527
- `).reduce((t,o)=>t!=null||o.length===0?t:op(o,r),null):null}function op(e,r){let n=Kr(e);if(n?.kind!=="rrweb")return null;let t=$r(n.event.data),o=Cr(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??(De(a)?Cr(a.node,r):null),null):null}function Cr(e,r){if(!De(e))return null;if(e.id===r)return[e];let n=e.childNodes;if(!Array.isArray(n))return null;let t=n.reduce((o,i)=>o??Cr(i,r),null);return t==null?null:[e,...t]}function gs(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var ls=80;function ip(e){let r=ms(e).filter(n=>n.type===3).map(n=>I(n.textContent)).filter(n=>n!=null);return r.length===0?null:r.join(" ")}function I(e){return typeof e=="string"?e:null}function sp(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>ls?`${r.slice(0,ls)}\u2026`:r}function $r(e){return De(e)?e:void 0}function De(e){return typeof e=="object"&&e!=null}function Rr(e){return typeof e=="number"?e:null}function Er(e,r){let n=r.flatMap(o=>ap(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function ap(e,r){let n=e.get(r.id);return n==null?r.kind==="finding"||r.lastMessageAuthor==="agent"?[]:[{task:r,type:r.latestMessageKind==="reopen"?"reopened":"new"}]:n!==r.fingerprint&&r.lastMessageAuthor==="user"?[{task:r,type:"reply"}]:[]}var lp=L(`
494
+ `)}async function as({id:e,testId:r}){let n=b();await x(n),(await oe(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${S(i)}
495
+ `),process.exit(1)});let o=await Ju({cfg:n,slug:r});await d({config:n,document:Ku,variables:{id:e,workflowId:o}}),process.stdout.write(`Linked scope item ${e} to ${r}
496
+ `)}async function ls({ids:e}){let r=b();await x(r);let t=(await d({config:r,document:Gu,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${j(t,"scope item")}
497
+ `)}async function Ju({cfg:e,slug:r}){let t=(await d({config:e,document:Vu,variables:{cwd:e.cwd,projectId:e.projectId,slug:r}})).project?.devSession?.workflows?.[0];return t==null&&(process.stderr.write(`No workflow found with id "${r}". Create a stub first via the testing DSL.
498
+ `),process.stderr.write(`${R("create")}
499
+ `),process.exit(1)),t.id}import{graphql as L}from"gql.tada";import{print as ws}from"graphql";import{createClient as bs}from"graphql-sse";import Rr from"fs";import Qu from"path";import{err as _e,ok as Zu}from"neverthrow";function cs({cwd:e,rrwebId:r,runId:n}){let t=ps(e,n);if(!Rr.existsSync(t))return _e({kind:"no-behavior"});let o=ys(gs(t,r));if(o==null)return _e({kind:"not-found"});let i=$r(o.node.type);return i===3?_e({kind:"text-node",parentId:$r(o.parent?.id)}):i!==2?_e({kind:"non-element",nodeType:i??-1}):Zu({tagName:I(o.node.tagName)})}function us({cwd:e,rrwebId:r,runId:n}){let t=gs(ps(e,n),r);if(t==null)return null;let o=ys(t);return o==null||$r(o.node.type)!==2?null:Xu(t)}function ps(e,r){return Qu.join(e,".ripplo","debug",r,"behavior.jsonl")}function Xu(e){let r=e.at(-1)??{},n=Er(r.attributes)??{},t=I(r.tagName);return{ariaName:I(n["aria-label"]),role:I(n.role),selector:ep(e),tagName:t==null?null:t.toLowerCase(),testId:I(n["data-testid"]),text:ip(op(r))}}var Yu=6;function ep(e){let r=ms(e,e.length-1,Yu);return r.length===0?null:r.join(" > ")}function ms(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=rp(t);if(o!=null)return[o];let i=np(t,e[r-1]);return r===0||n===1?[i]:[...ms(e,r-1,n-1),i]}function rp(e){let r=Er(e.attributes)??{},n=I(r["data-testid"]);if(n!=null)return`[data-testid="${n}"]`;let t=I(r.id);return t!=null&&t.length>0?`#${t}`:null}function np(e,r){let n=(I(e.tagName)??"*").toLowerCase(),t=fs(r).filter(i=>(I(i.tagName)??"*").toLowerCase()===n);if(t.length<=1)return n;let o=t.findIndex(i=>i.id===e.id);return o===-1?n:`${n}:nth-of-type(${String(o+1)})`}function fs(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>Ue(n)):[]}function gs(e,r){return Rr.existsSync(e)?Rr.readFileSync(e,"utf8").split(`
500
+ `).reduce((t,o)=>t!=null||o.length===0?t:tp(o,r),null):null}function tp(e,r){let n=Gr(e);if(n?.kind!=="rrweb")return null;let t=Er(n.event.data),o=Cr(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??(Ue(a)?Cr(a.node,r):null),null):null}function Cr(e,r){if(!Ue(e))return null;if(e.id===r)return[e];let n=e.childNodes;if(!Array.isArray(n))return null;let t=n.reduce((o,i)=>o??Cr(i,r),null);return t==null?null:[e,...t]}function ys(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var ds=80;function op(e){let r=fs(e).filter(n=>n.type===3).map(n=>I(n.textContent)).filter(n=>n!=null);return r.length===0?null:r.join(" ")}function I(e){return typeof e=="string"?e:null}function ip(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>ds?`${r.slice(0,ds)}\u2026`:r}function Er(e){return Ue(e)?e:void 0}function Ue(e){return typeof e=="object"&&e!=null}function $r(e){return typeof e=="number"?e:null}function Pr(e,r){let n=r.flatMap(o=>sp(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function sp(e,r){let n=e.get(r.id);return n==null?r.kind==="finding"||r.lastMessageAuthor==="agent"?[]:[{task:r,type:r.latestMessageKind==="reopen"?"reopened":"new"}]:n!==r.fingerprint&&r.lastMessageAuthor==="user"?[{task:r,type:"reply"}]:[]}var ap=L(`
528
501
  query WorkList($projectId: String!, $cwd: String!) {
529
502
  project(id: $projectId) {
530
503
  id
@@ -542,7 +515,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
542
515
  }
543
516
  }
544
517
  }
545
- `),dp=L(`
518
+ `),lp=L(`
546
519
  query WatchSeed($projectId: String!, $cwd: String!) {
547
520
  project(id: $projectId) {
548
521
  id
@@ -562,7 +535,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
562
535
  }
563
536
  }
564
537
  }
565
- `),bs=L(`
538
+ `),vs=L(`
566
539
  subscription WatchTasks($devSessionId: String!) {
567
540
  tasksChanged(devSessionId: $devSessionId) {
568
541
  devSession {
@@ -581,7 +554,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
581
554
  }
582
555
  }
583
556
  }
584
- `),up=L(`
557
+ `),dp=L(`
585
558
  query WorkShow($id: String!) {
586
559
  task(id: $id) {
587
560
  id
@@ -624,7 +597,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
624
597
  }
625
598
  }
626
599
  }
627
- `),pp=L(`
600
+ `),up=L(`
628
601
  mutation WorkResolve($taskId: String!, $runId: String!, $note: String, $authorName: String) {
629
602
  agentResolveTask(taskId: $taskId, runId: $runId, note: $note, authorName: $authorName) {
630
603
  __typename
@@ -636,7 +609,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
636
609
  }
637
610
  }
638
611
  }
639
- `),mp=L(`
612
+ `),pp=L(`
640
613
  mutation WorkStart($taskId: String!) {
641
614
  agentStartTask(taskId: $taskId) {
642
615
  __typename
@@ -649,7 +622,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
649
622
  }
650
623
  }
651
624
  }
652
- `),fp=L(`
625
+ `),mp=L(`
653
626
  mutation WorkClarify($taskId: String!, $body: String!, $authorName: String) {
654
627
  agentSetNeedsClarification(taskId: $taskId, body: $body, authorName: $authorName) {
655
628
  __typename
@@ -661,7 +634,7 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
661
634
  }
662
635
  }
663
636
  }
664
- `),gp=L(`
637
+ `),fp=L(`
665
638
  mutation WorkDismiss($taskId: String!, $note: String, $authorName: String) {
666
639
  agentDismissTask(taskId: $taskId, note: $note, authorName: $authorName) {
667
640
  __typename
@@ -676,21 +649,21 @@ ${e.contradictions.map(t=>tn({contradiction:t,evidencePath:void 0})).join(`
676
649
  }
677
650
  }
678
651
  }
679
- `),yp=18e4;async function vs(e){let r=w();await x(r);let n=await ys(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await hp({cfg:r,devSessionId:n.devSessionId});let o=await ys(r);hs(o.items,e.format);return}hs(n.items,e.format)}async function ys(e){let n=(await d({config:e,document:lp,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return{devSessionId:n?.id??null,items:n?.tasks??[]}}function hs(e,r){if(r==="json"){process.stdout.write(`${JSON.stringify(e,null,2)}
680
- `);return}let n=e.map(t=>({id:t.id,kind:t.kind,lastMessage:(t.messages??[]).at(-1)?.body??null,status:t.status,title:t.title}));process.stdout.write(`${xn(n)}
681
- `)}function hp({cfg:e,devSessionId:r}){let n=ws({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});return new Promise(t=>{let o={settled:!1,timer:null,dispose:()=>{}},i=()=>{o.settled||(o.settled=!0,o.timer!=null&&clearTimeout(o.timer),o.dispose(),t())};o.timer=setTimeout(i,yp),o.dispose=n.subscribe({query:ks(bs),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function Ss(){let e=w();await x(e);let n=(await d({config:e,document:dp,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=Er(new Map,Cs(n.tasks??[])),o=ws({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});kp({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function kp({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:ks(bs),variables:{devSessionId:e}},{complete:()=>{},error:o=>{process.stderr.write(`task watch error: ${String(o)}
682
- `)},next:o=>{let i=o.data?.tasksChanged?.devSession?.tasks??[],s=Er(t,Cs(i));s.changes.forEach(a=>{process.stdout.write(`${Rn(a)}
683
- `)}),t=s.seen}})}async function xs(e){let r=w();await x(r);let t=(await d({config:r,document:up,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${$n(e.id)}
652
+ `),gp=18e4;async function Ss(e){let r=b();await x(r);let n=await hs(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await yp({cfg:r,devSessionId:n.devSessionId});let o=await hs(r);ks(o.items,e.format);return}ks(n.items,e.format)}async function hs(e){let n=(await d({config:e,document:ap,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return{devSessionId:n?.id??null,items:n?.tasks??[]}}function ks(e,r){if(r==="json"){process.stdout.write(`${JSON.stringify(e,null,2)}
653
+ `);return}let n=e.map(t=>({id:t.id,kind:t.kind,lastMessage:(t.messages??[]).at(-1)?.body??null,status:t.status,title:t.title}));process.stdout.write(`${$n(n)}
654
+ `)}function yp({cfg:e,devSessionId:r}){let n=bs({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});return new Promise(t=>{let o={settled:!1,timer:null,dispose:()=>{}},i=()=>{o.settled||(o.settled=!0,o.timer!=null&&clearTimeout(o.timer),o.dispose(),t())};o.timer=setTimeout(i,gp),o.dispose=n.subscribe({query:ws(vs),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function xs(){let e=b();await x(e);let n=(await d({config:e,document:lp,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=Pr(new Map,Cs(n.tasks??[])),o=bs({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});hp({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function hp({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:ws(vs),variables:{devSessionId:e}},{complete:()=>{},error:o=>{process.stderr.write(`task watch error: ${String(o)}
655
+ `)},next:o=>{let i=o.data?.tasksChanged?.devSession?.tasks??[],s=Pr(t,Cs(i));s.changes.forEach(a=>{process.stdout.write(`${Pn(a)}
656
+ `)}),t=s.seen}})}async function Rs(e){let r=b();await x(r);let t=(await d({config:r,document:dp,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${In(e.id)}
684
657
  `),process.exit(1)),e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
685
- `);return}let o=[...new Set((t.messages??[]).flatMap(s=>s.runId==null?[]:[s.runId]))];await Promise.all(o.map(s=>ee(r.cwd,s).then(a=>a.isErr())));let i={id:t.id,kind:t.kind,lastMessage:(t.messages??[]).at(-1)?.body??null,messages:(t.messages??[]).map(s=>({author:s.author,authorName:s.authorName,body:s.body,element:s.runId==null||s.rrwebId==null?null:us({cwd:r.cwd,rrwebId:s.rrwebId,runId:s.runId}),frameMs:s.frameMs,rrwebId:s.rrwebId,runId:s.runId})),status:t.status,title:t.title};process.stdout.write(`${Cn(i)}
686
- `)}function Cs(e){return e.map(r=>({fingerprint:`${r.id}:${String(r.updatedAt)}`,id:r.id,kind:r.kind,lastMessageAuthor:r.lastMessageAuthor,latestMessage:(r.messages??[]).at(-1)?.body??null,latestMessageKind:(r.messages??[]).at(-1)?.kind??null,title:r.title}))}async function Rs(e){let r=w();if(await x(r),e.elementId!=null&&e.runId!=null){let t=ds({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${wp(t,e.elementId,e.runId)}
687
- `),process.exit(1))}let n=await d({config:r,document:cp,variables:{authorName:e.authorName??null,body:e.body,frameMs:e.offsetMs??null,rrwebId:e.elementId??null,runId:e.runId??null,taskId:e.id}});Ue(n.agentCommentOnTask),process.stdout.write(`${En(e.id)}
688
- `)}async function $s(e){let r=w();await x(r);let n=await d({config:r,document:pp,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});Ue(n.agentResolveTask),process.stdout.write(`${jn(e.id)}
689
- `)}async function Es(e){let r=w();await x(r);let n=await d({config:r,document:mp,variables:{taskId:e.id}});Ue(n.agentStartTask),process.stdout.write(`${Mn(e.id)}
690
- `)}async function Ps(e){e.body.trim().length===0&&(process.stderr.write(`${Pn()}
691
- `),process.exit(1));let r=w();await x(r);let n=await d({config:r,document:fp,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});Ue(n.agentSetNeedsClarification),process.stdout.write(`${Ln(e.id)}
692
- `)}async function Is(e){let r=w();await x(r);let t=(await d({config:r,document:gp,variables:{authorName:e.authorName??null,note:e.note??null,taskId:e.id}})).agentDismissTask;(t?.__typename==="FindingNotDismissableError"||t?.__typename==="NoActiveDevSessionError")&&(process.stderr.write(`${t.message}
693
- `),process.exit(1)),process.stdout.write(`${Nn(e.id)}
694
- `)}function Ue(e){e?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${e.message}
695
- `),process.exit(1))}function wp(e,r,n){return e.kind==="text-node"?In(r,e.parentId):e.kind==="not-found"?An(r,n):Tn(r)}function As(e){return e.command("list","List open tasks for this dev session",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}).option("wait",{default:!1,describe:"Block until the first explorer finding lands (or a timeout)",type:"boolean"}),r=>vs({format:r.format,wait:r.wait})).command("watch","Stream new tasks and user replies as they arrive (arm via Monitor from /ripplo:start)",r=>r,()=>Ss()).command("show <id>","Show a task with its full message thread",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>xs({format:r.format,id:r.id})).command("comment <id> <body>","Comment on a task, optionally anchored to a run frame and element. For visual fixes, anchor to the proof run's frame and element, both read from .ripplo/debug/<runId>/behavior.jsonl: --element takes the rrweb id of an ELEMENT node (a text node has no box and cannot be highlighted \u2014 use its parentId), and --offset takes the frame offset in ms (from recording start, same as `snapshot --offset`) where that element is present. Call once per comment.",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).positional("body",{demandOption:!0,describe:"Comment body",type:"string"}).option("run",{describe:"Run id to anchor the comment to",type:"string"}).option("offset",{describe:"Frame offset in ms from recording start",type:"number"}).option("element",{describe:"rrweb id of an element node to highlight (not a text node)",type:"number"}).option("as",{describe:"Agent display name shown on the comment",type:"string"}),r=>Rs({authorName:r.as,body:r.body,elementId:r.element,id:r.id,offsetMs:r.offset,runId:r.run})).command("start <id>","Mark a task as picked up \u2014 flags it in progress until resolved, dismissed, or clarified",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}),r=>Es({id:r.id})).command("resolve <id>","Resolve a task with a proof run",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).option("run",{demandOption:!0,describe:"Proof run id",type:"string"}).option("note",{describe:"Optional resolution note",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>$s({authorName:r.as,id:r.id,note:r.note,runId:r.run})).command("clarify <id> <body>","Mark a task as needing clarification from the user",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).positional("body",{demandOption:!0,describe:"What you need clarified",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>Ps({authorName:r.as,body:r.body,id:r.id})).command("dismiss <id>","Dismiss a task as not actionable",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).option("note",{describe:"Optional reason",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>Is({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}Ir();ne(process.cwd());Dr();async function xp(){ce(b()),bp({pkg:{name:"ripplo",version:b()}}).notify({message:vt()}),await vp(Sp(process.argv)).scriptName("ripplo").version(b()).command(Ep()).command(Pp()).command(Ap()).command(Wp()).command("auth <subcommand>","Manage authentication",Hp).command("projects <subcommand>","List or create Ripplo projects",qp).command("hooks <subcommand>","Pause or resume Ripplo hooks",Bp).command(Mp()).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=>oo({appUrl:e["app-url"],engineUrl:e["engine-url"],envFile:e.env,projectId:e.project})).command("run [ids..]","Run tests locally via the daemon (start it first with `npx ripplo daemon`)",Dp,e=>yo({all:e.all,headed:e.headed,ids:e.ids})).command(Np()).command(_p()).command(Op()).command(Fp()).command(Cp()).command(Lp()).command(Tp()).command(jp()).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>Ri()).command("compile","Compile the DSL, run static model analysis, 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=>It({check:e.check})).command("update","Update ripplo to the latest published version (and hand the daemon off to it)",()=>{},()=>Ni()).command("doctor","Check project health",()=>{},()=>Bt()).command("status","Report stub tests and daemon status",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>ht({format:e.format})).command("scope <subcommand>","Manage testing scope",Up).command("tasks <subcommand>","Manage tasks for this dev session",As).command("run-worker",!1,()=>{},()=>bo()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(Vn),demandOption:!0,type:"string"}),e=>Kn(e.name)).strict().help().parse()}xp().catch(e=>{process.stderr.write(`${zn(e)}
696
- `),process.exit(1)});function Cp(){return{command:"report-bug",describe:"Report a critical application bug caught while building or testing",builder:e=>e.option("kind",{choices:["new_feature_bug","regression","latent_bug"],demandOption:!0,describe:"new_feature_bug: broke the new thing being built; regression: broke previously working behavior; latent_bug: pre-existing bug exposed by new test coverage"}).option("title",{demandOption:!0,describe:"Short bug name",type:"string"}).option("root-cause",{demandOption:!0,describe:"What was actually wrong",type:"string"}).option("surfaced-by",{demandOption:!0,describe:"How the test/run exposed it (cite evidence)",type:"string"}).option("run",{demandOption:!0,describe:"Run id where it surfaced \u2014 links the bug to its replay. For an exploration finding, pass the explore-\u2026 run id from the finding",type:"string"}),handler:e=>go({kind:e.kind,rootCause:e["root-cause"],runId:e.run,surfacedBy:e["surfaced-by"],title:e.title})}}var Rp=["start","stop","restart","status"],$p="start";function Ep(){return{command:"daemon [action]",describe:"Run the long-lived local executor (IPC socket + run subscription)",builder:e=>e.positional("action",{choices:Rp,default:$p,describe:"Lifecycle action for this project's daemon"}).option("explore-debug",{default:!1,describe:"Print local explorer planner decisions",type:"boolean"}),handler:e=>Oi({action:e.action,exploreDebug:e["explore-debug"]})}}function Pp(){return{command:"executor [mode]",describe:"Show or switch the run executor for the active dev session",builder:e=>e.positional("mode",{choices:["local","cloud"],describe:"Executor to switch to (omit to show the current one)"}),handler:e=>Di({mode:e.mode})}}var Ip=["analyze","on","off"];function Ap(){return{command:"explore [state]",describe:"Show or toggle the background explorer for the active dev session",builder:e=>e.positional("state",{choices:Ip,describe:"Turn the explorer on or off, or analyze workflow coverage (omit to show current state)"}).option("json",{default:!1,describe:"Print machine-readable analysis",type:"boolean"}).option("trail",{describe:"Target steps per explored path",type:"number"}).option("workers",{describe:"Concurrent explorer workers",type:"number"}),handler:e=>es({json:e.json,state:e.state,trail:e.trail,workers:e.workers})}}function Tp(){return{command:"explain <runId>",describe:"Explain a run's failing checks \u2014 what failed, where it came from, and what happened around it",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("json",{default:!1,describe:"Machine-readable output",type:"boolean"}).option("full",{default:!1,describe:"Also show the synthesized starting state and step-by-step run timeline",type:"boolean"}),handler:e=>Uo({full:e.full,json:e.json,runId:e.runId})}}function jp(){return{command:"replay <runId>",describe:"Re-run an explore finding's trail to confirm it's resolved",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}),handler:e=>Jo({runId:e.runId})}}function Mp(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{mo()}}}function Lp(){return{command:"pull <runId>",describe:"Download a run's behavior.jsonl from the server",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}),handler:e=>Bo({runId:e.runId})}}function Np(){return{command:"snapshot <runId>",describe:"Render a PNG of the page at a point in a run's rrweb recording",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("at",{describe:"Moment to render: epoch-ms timestamp exactly as found in behavior.jsonl",type:"number"}).option("offset",{describe:"Moment to render: ms from the start of the recording (alternative to --at)",type:"number"}).conflicts("at","offset"),handler:e=>ui({at:e.at,offset:e.offset,runId:e.runId})}}function Op(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>bi()}}function Fp(){return{command:"clickpath <runId>",describe:"Print the resolved, ordered user actions from a capture",builder:e=>e.positional("runId",{demandOption:!0,describe:"Capture run id (the capture-... folder under .ripplo/debug)",type:"string"}),handler:e=>{Ci({runId:e.runId})}}}function Wp(){return{command:"concurrency [value]",describe:"Show or set max local concurrent runs (daemon applies live)",builder:e=>e.positional("value",{type:"number"}),handler:e=>Tt({value:e.value})}}function _p(){return{command:"teleport <ref>",describe:"Open a live browser with starting state and earlier test steps applied",builder:e=>e.positional("ref",{demandOption:!0,describe:"Test ref: <workflow-slug>/<test-slug>",type:"string"}).option("step",{demandOption:!0,describe:"Step to land on \u2014 runs the test up to and including this step, then hands over",type:"number"}),handler:e=>fi({ref:e.ref,step:e.step})}}function Dp(e){let r=[];return e.positional("ids",{array:!0,default:r,describe:"Test ids to run",type:"string"}).option("all",{default:!1,describe:"Run every test in the suite (expensive)",type:"boolean"}).option("headed",{default:!1,describe:"Run with a visible browser window",type:"boolean"})}function Up(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>os({format:r.format})).command("add <test-ids..>","Bind one or more existing tests (stubs or implemented) to scope as agent intent",r=>{let n=[];return r.positional("test-ids",{array:!0,default:n,demandOption:!0,describe:"Slugs of existing workflows",type:"string"})},r=>is({testIds:r["test-ids"]})).command("link <id> <test-id>","Link an existing scope item to a test",r=>r.positional("id",{demandOption:!0,describe:"Scope item id",type:"string"}).positional("test-id",{demandOption:!0,describe:"Slug of the workflow to link",type:"string"}),r=>ss({id:r.id,testId:r["test-id"]})).command("remove <ids..>","Remove one or more scope items by id",r=>{let n=[];return r.positional("ids",{array:!0,default:n,demandOption:!0,describe:"Scope item ids",type:"string"})},r=>as({ids:r.ids})).demandCommand(1)}function Bp(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>qt()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>Ht()).demandCommand(1)}function qp(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>ao()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>lo({name:r.name,orgId:r.org})).demandCommand(1)}function Hp(e){return e.command("login","Authenticate via device flow",()=>{},()=>$t()).command("status","Show authentication status",()=>{},()=>Et()).command("logout","Remove the saved token",()=>{},()=>{Pt()}).demandCommand(1)}export{xp as main};
658
+ `);return}let o=[...new Set((t.messages??[]).flatMap(s=>s.runId==null?[]:[s.runId]))];await Promise.all(o.map(s=>ee(r.cwd,s).then(a=>a.isErr())));let i={id:t.id,kind:t.kind,lastMessage:(t.messages??[]).at(-1)?.body??null,messages:(t.messages??[]).map(s=>({author:s.author,authorName:s.authorName,body:s.body,element:s.runId==null||s.rrwebId==null?null:us({cwd:r.cwd,rrwebId:s.rrwebId,runId:s.runId}),frameMs:s.frameMs,rrwebId:s.rrwebId,runId:s.runId})),status:t.status,title:t.title};process.stdout.write(`${En(i)}
659
+ `)}function Cs(e){return e.map(r=>({fingerprint:`${r.id}:${String(r.updatedAt)}`,id:r.id,kind:r.kind,lastMessageAuthor:r.lastMessageAuthor,latestMessage:(r.messages??[]).at(-1)?.body??null,latestMessageKind:(r.messages??[]).at(-1)?.kind??null,title:r.title}))}async function $s(e){let r=b();if(await x(r),e.elementId!=null&&e.runId!=null){let t=cs({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${kp(t,e.elementId,e.runId)}
660
+ `),process.exit(1))}let n=await d({config:r,document:cp,variables:{authorName:e.authorName??null,body:e.body,frameMs:e.offsetMs??null,rrwebId:e.elementId??null,runId:e.runId??null,taskId:e.id}});qe(n.agentCommentOnTask),process.stdout.write(`${An(e.id)}
661
+ `)}async function Es(e){let r=b();await x(r);let n=await d({config:r,document:up,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});qe(n.agentResolveTask),process.stdout.write(`${Nn(e.id)}
662
+ `)}async function Ps(e){let r=b();await x(r);let n=await d({config:r,document:pp,variables:{taskId:e.id}});qe(n.agentStartTask),process.stdout.write(`${On(e.id)}
663
+ `)}async function Is(e){e.body.trim().length===0&&(process.stderr.write(`${Tn()}
664
+ `),process.exit(1));let r=b();await x(r);let n=await d({config:r,document:mp,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});qe(n.agentSetNeedsClarification),process.stdout.write(`${Fn(e.id)}
665
+ `)}async function As(e){let r=b();await x(r);let t=(await d({config:r,document:fp,variables:{authorName:e.authorName??null,note:e.note??null,taskId:e.id}})).agentDismissTask;(t?.__typename==="FindingNotDismissableError"||t?.__typename==="NoActiveDevSessionError")&&(process.stderr.write(`${t.message}
666
+ `),process.exit(1)),process.stdout.write(`${Wn(e.id)}
667
+ `)}function qe(e){e?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${e.message}
668
+ `),process.exit(1))}function kp(e,r,n){return e.kind==="text-node"?jn(r,e.parentId):e.kind==="not-found"?Mn(r,n):Ln(r)}function Ts(e){return e.command("list","List open tasks for this dev session",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}).option("wait",{default:!1,describe:"Block until the first explorer finding lands (or a timeout)",type:"boolean"}),r=>Ss({format:r.format,wait:r.wait})).command("watch","Stream new tasks and user replies as they arrive (arm via Monitor from /ripplo:start)",r=>r,()=>xs()).command("show <id>","Show a task with its full message thread",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>Rs({format:r.format,id:r.id})).command("comment <id> <body>","Comment on a task, optionally anchored to a run frame and element. For visual fixes, anchor to the proof run's frame and element, both read from .ripplo/debug/<runId>/behavior.jsonl: --element takes the rrweb id of an ELEMENT node (a text node has no box and cannot be highlighted \u2014 use its parentId), and --offset takes the frame offset in ms (from recording start, same as `snapshot --offset`) where that element is present. Call once per comment.",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).positional("body",{demandOption:!0,describe:"Comment body",type:"string"}).option("run",{describe:"Run id to anchor the comment to",type:"string"}).option("offset",{describe:"Frame offset in ms from recording start",type:"number"}).option("element",{describe:"rrweb id of an element node to highlight (not a text node)",type:"number"}).option("as",{describe:"Agent display name shown on the comment",type:"string"}),r=>$s({authorName:r.as,body:r.body,elementId:r.element,id:r.id,offsetMs:r.offset,runId:r.run})).command("start <id>","Mark a task as picked up \u2014 flags it in progress until resolved, dismissed, or clarified",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}),r=>Ps({id:r.id})).command("resolve <id>","Resolve a task with a proof run",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).option("run",{demandOption:!0,describe:"Proof run id",type:"string"}).option("note",{describe:"Optional resolution note",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>Es({authorName:r.as,id:r.id,note:r.note,runId:r.run})).command("clarify <id> <body>","Mark a task as needing clarification from the user",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).positional("body",{demandOption:!0,describe:"What you need clarified",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>Is({authorName:r.as,body:r.body,id:r.id})).command("dismiss <id>","Dismiss a task as not actionable",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).option("note",{describe:"Optional reason",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>As({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}Ar();ne(process.cwd());Ur();async function Sp(){ue(w()),wp({pkg:{name:"ripplo",version:w()}}).notify({message:Rt()}),await bp(vp(process.argv)).scriptName("ripplo").version(w()).command(Cp()).command($p()).command(Pp()).command(Op()).command("auth <subcommand>","Manage authentication",qp).command("projects <subcommand>","List or create Ripplo projects",Up).command("hooks <subcommand>","Pause or resume Ripplo hooks",_p).command(Tp()).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=>ao({appUrl:e["app-url"],engineUrl:e["engine-url"],envFile:e.env,projectId:e.project})).command("run [ids..]","Run tests locally via the daemon (start it first with `npx ripplo daemon`)",Wp,e=>ho({all:e.all,headed:e.headed,ids:e.ids})).command(Mp()).command(Fp()).command(Lp()).command(Np()).command(jp()).command(Ip()).command(Ap()).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>$i()).command("compile","Compile the DSL, run static model analysis, 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=>jt({check:e.check})).command("update","Update ripplo to the latest published version (and hand the daemon off to it)",()=>{},()=>Oi()).command("doctor","Check project health",()=>{},()=>Vt()).command("status","Report stub tests and daemon status",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>bt({format:e.format})).command("scope <subcommand>","Manage testing scope",Dp).command("tasks <subcommand>","Manage tasks for this dev session",Ts).command("run-worker",!1,()=>{},()=>vo()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(Gn),demandOption:!0,type:"string"}),e=>Qn(e.name)).strict().help().parse()}Sp().catch(e=>{process.stderr.write(`${Jn(e)}
669
+ `),process.exit(1)});var xp=["start","stop","restart","status"],Rp="start";function Cp(){return{command:"daemon [action]",describe:"Run the long-lived local executor (IPC socket + run subscription)",builder:e=>e.positional("action",{choices:xp,default:Rp,describe:"Lifecycle action for this project's daemon"}).option("explore-debug",{default:!1,describe:"Print local explorer planner decisions",type:"boolean"}),handler:e=>Fi({action:e.action,exploreDebug:e["explore-debug"]})}}function $p(){return{command:"executor [mode]",describe:"Show or switch the run executor for the active dev session",builder:e=>e.positional("mode",{choices:["local","cloud"],describe:"Executor to switch to (omit to show the current one)"}),handler:e=>Ui({mode:e.mode})}}var Ep=["analyze","on","off"];function Pp(){return{command:"explore [state]",describe:"Show or toggle the background explorer for the active dev session",builder:e=>e.positional("state",{choices:Ep,describe:"Turn the explorer on or off, or analyze workflow coverage (omit to show current state)"}).option("json",{default:!1,describe:"Print machine-readable analysis",type:"boolean"}).option("trail",{describe:"Target steps per explored path",type:"number"}).option("workers",{describe:"Concurrent explorer workers",type:"number"}),handler:e=>rs({json:e.json,state:e.state,trail:e.trail,workers:e.workers})}}function Ip(){return{command:"explain <runId>",describe:"Explain a run's failing checks \u2014 what failed, where it came from, and what happened around it",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("json",{default:!1,describe:"Machine-readable output",type:"boolean"}).option("full",{default:!1,describe:"Also show the synthesized starting state and step-by-step run timeline",type:"boolean"}),handler:e=>qo({full:e.full,json:e.json,runId:e.runId})}}function Ap(){return{command:"replay <runId>",describe:"Re-run an explore finding's trail to confirm it's resolved",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}),handler:e=>Qo({runId:e.runId})}}function Tp(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{yo()}}}function jp(){return{command:"pull <runId>",describe:"Download a run's behavior.jsonl from the server",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}),handler:e=>Bo({runId:e.runId})}}function Mp(){return{command:"snapshot <runId>",describe:"Render a PNG of the page at a point in a run's rrweb recording",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("at",{describe:"Moment to render: epoch-ms timestamp exactly as found in behavior.jsonl",type:"number"}).option("offset",{describe:"Moment to render: ms from the start of the recording (alternative to --at)",type:"number"}).conflicts("at","offset"),handler:e=>ui({at:e.at,offset:e.offset,runId:e.runId})}}function Lp(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>vi()}}function Np(){return{command:"clickpath <runId>",describe:"Print the resolved, ordered user actions from a capture",builder:e=>e.positional("runId",{demandOption:!0,describe:"Capture run id (the capture-... folder under .ripplo/debug)",type:"string"}),handler:e=>{Ci({runId:e.runId})}}}function Op(){return{command:"concurrency [value]",describe:"Show or set max local concurrent runs (daemon applies live)",builder:e=>e.positional("value",{type:"number"}),handler:e=>Lt({value:e.value})}}function Fp(){return{command:"teleport <ref>",describe:"Open a live browser with starting state and earlier test steps applied",builder:e=>e.positional("ref",{demandOption:!0,describe:"Test ref: <workflow-slug>/<test-slug>",type:"string"}).option("step",{demandOption:!0,describe:"Step to land on \u2014 runs the test up to and including this step, then hands over",type:"number"}),handler:e=>gi({ref:e.ref,step:e.step})}}function Wp(e){let r=[];return e.positional("ids",{array:!0,default:r,describe:"Test ids to run",type:"string"}).option("all",{default:!1,describe:"Run every test in the suite (expensive)",type:"boolean"}).option("headed",{default:!1,describe:"Run with a visible browser window",type:"boolean"})}function Dp(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>is({format:r.format})).command("add <test-ids..>","Bind one or more existing tests (stubs or implemented) to scope as agent intent",r=>{let n=[];return r.positional("test-ids",{array:!0,default:n,demandOption:!0,describe:"Slugs of existing workflows",type:"string"})},r=>ss({testIds:r["test-ids"]})).command("link <id> <test-id>","Link an existing scope item to a test",r=>r.positional("id",{demandOption:!0,describe:"Scope item id",type:"string"}).positional("test-id",{demandOption:!0,describe:"Slug of the workflow to link",type:"string"}),r=>as({id:r.id,testId:r["test-id"]})).command("remove <ids..>","Remove one or more scope items by id",r=>{let n=[];return r.positional("ids",{array:!0,default:n,demandOption:!0,describe:"Scope item ids",type:"string"})},r=>ls({ids:r.ids})).demandCommand(1)}function _p(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>zt()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>Kt()).demandCommand(1)}function Up(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>uo()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>po({name:r.name,orgId:r.org})).demandCommand(1)}function qp(e){return e.command("login","Authenticate via device flow",()=>{},()=>It()).command("status","Show authentication status",()=>{},()=>At()).command("logout","Remove the saved token",()=>{},()=>{Tt()}).demandCommand(1)}export{Sp as main};