ripplo 0.8.3 → 0.9.1

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 (49) hide show
  1. package/dist/{chunk-5SM4TCSW.js → chunk-4F67XQYS.js} +19 -19
  2. package/dist/{chunk-EGETJKAQ.js → chunk-4H7EIC6W.js} +1 -1
  3. package/dist/{chunk-XBD3OTIW.js → chunk-4XC5TAOG.js} +1 -1
  4. package/dist/chunk-6BQADUAX.js +229 -0
  5. package/dist/chunk-EVVF662P.js +6 -0
  6. package/dist/chunk-INO3L4WS.js +4 -0
  7. package/dist/{chunk-N2B5GZPU.js → chunk-IRTBARRY.js} +1 -1
  8. package/dist/chunk-MG43RZXH.js +83 -0
  9. package/dist/{chunk-4FKGHWCC.js → chunk-MMCOPC4L.js} +1 -1
  10. package/dist/{chunk-7TYUZIUO.js → chunk-NEPJCCQS.js} +1 -1
  11. package/dist/{chunk-2MT2MZJW.js → chunk-Q6IYTHMP.js} +1 -1
  12. package/dist/chunk-RWFS5SCW.js +6 -0
  13. package/dist/{chunk-SWOTFHBR.js → chunk-SFWAAS5H.js} +1 -1
  14. package/dist/{chunk-PXZV5X3C.js → chunk-TY5K3P4F.js} +1 -1
  15. package/dist/{chunk-7Z7RVHEL.js → chunk-UMSBDSRS.js} +2 -2
  16. package/dist/chunk-WZBLSDNV.js +4 -0
  17. package/dist/{chunk-AVBP7Q2M.js → chunk-XZ2TPZLD.js} +1 -1
  18. package/dist/{chunk-LKYTQXPR.js → chunk-YODZBLYM.js} +1 -1
  19. package/dist/{chunk-UVYCSHOJ.js → chunk-ZUPS6XVH.js} +1 -1
  20. package/dist/{cli-error-SLG6JHK2.js → cli-error-J33JDZET.js} +1 -1
  21. package/dist/{compile-write-7AV66JUA.js → compile-write-4ZAIPQMG.js} +1 -1
  22. package/dist/{daemon-LFFCR3TB.js → daemon-MZWLJO75.js} +1 -1
  23. package/dist/daemon-YPXZGJAB.js +152 -0
  24. package/dist/{dsl-loader-H25XGSHJ.js → dsl-loader-5Z2JRKY3.js} +1 -1
  25. package/dist/hook.js +1 -1
  26. package/dist/index.js +189 -182
  27. package/dist/{plan-reminder-VMBDQTAP.js → plan-reminder-45PSVOVW.js} +1 -1
  28. package/dist/post-edit-JHJT2QTK.js +4 -0
  29. package/dist/post-edit-analyze-PPFHKIYQ.js +4 -0
  30. package/dist/post-edit-flag-stubs-Q3UKDZ2W.js +4 -0
  31. package/dist/{pre-edit-Q4U5LSWG.js → pre-edit-EJO3TUNQ.js} +1 -1
  32. package/dist/{pre-edit-watch-gate-EUZGEH2J.js → pre-edit-watch-gate-DZHQCMEI.js} +1 -1
  33. package/dist/{prompt-submit-MPRVCWOI.js → prompt-submit-ZCDG6T4Y.js} +1 -1
  34. package/dist/{session-preamble-IHBGHKCW.js → session-preamble-ZYVRDSGA.js} +1 -1
  35. package/dist/solve-worker.js +1 -1
  36. package/dist/status-66XIDYSP.js +4 -0
  37. package/dist/{stop-enforce-UXBQRTFP.js → stop-enforce-Q4JNBYQU.js} +1 -1
  38. package/package.json +6 -5
  39. package/dist/chunk-AQ3DMGAY.js +0 -6
  40. package/dist/chunk-EK6TENV6.js +0 -4
  41. package/dist/chunk-ESOXRGIY.js +0 -83
  42. package/dist/chunk-GD63CZVP.js +0 -242
  43. package/dist/chunk-M7VQD4VO.js +0 -6
  44. package/dist/chunk-OY6HNCAZ.js +0 -4
  45. package/dist/daemon-EGU25OUV.js +0 -139
  46. package/dist/post-edit-2VFE6QND.js +0 -4
  47. package/dist/post-edit-analyze-VETPP5Z4.js +0 -4
  48. package/dist/post-edit-flag-stubs-J3MCGLXI.js +0 -4
  49. package/dist/status-UBUNHH5O.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 sn,c as an,d as ln,e as dn,f as un,g as ue}from"./chunk-LKYTQXPR.js";import{a as En,b as In,d as An,e as jn,f as Tn,g as Mn,h as Ln,i as Nn,j as On,k as _n,l as Fn,m as Wn,n as Dn}from"./chunk-CDPYJKK7.js";import{a as Rn}from"./chunk-XBD3OTIW.js";import{b as rn,c as nn,d as tn,f as on}from"./chunk-EGETJKAQ.js";import{A as ce,C as Cn,G as xn,H as Sn,J as Pn,K as $n,a as Jr,b as Qr,c as Xr,d as Yr,e as Te,f as Zr,g as pn,h as mn,j as fn,k as gn,l as yn,m as hn,n as kn,o as wn,q as bn,x as Ne,z as vn}from"./chunk-GD63CZVP.js";import{b as en,c as de}from"./chunk-OY6HNCAZ.js";import{a as Kr}from"./chunk-MOI4L3EX.js";import{a as se,b as Gr,c as le,d as zr}from"./chunk-PXZV5X3C.js";import{a as R}from"./chunk-OQ6KNYPG.js";import{b as z}from"./chunk-UVYCSHOJ.js";import{a as x,b as Ar,c as b}from"./chunk-LEFXRK53.js";import{a as jr}from"./chunk-7WZ3VIUU.js";import{e as Me}from"./chunk-4W6WIT7T.js";import{a as gr,b as Un,c as qn}from"./chunk-7Z7RVHEL.js";import{a as k}from"./chunk-R4ZTRVDQ.js";import{b as yr,c as K,d as hr,e as kr}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as Ir,b as w}from"./chunk-2MT2MZJW.js";import{a as D,b as Pr,c as $r,d as Er}from"./chunk-AVBP7Q2M.js";import{a as C}from"./chunk-MHNGR6M7.js";import{e as Vr,g as ae,h as Hr}from"./chunk-EK6TENV6.js";import{b as G,e as j,g as Rr,h as te}from"./chunk-AQ3DMGAY.js";import"./chunk-DBIXYJRB.js";import{a as sr,b as ar,c as lr,d as u,f as O,h as dr,j as $,k as ur,l as cr,m as Ae,n as pr,o as mr,p as fr}from"./chunk-PE5WVWI5.js";import{a as re}from"./chunk-CJUKILIO.js";import{k as Le,l as cn}from"./chunk-M7VQD4VO.js";import{F as Fr,K as je,N as Wr,O as Dr,T as Ur,W as ie,X as qr,_ as Br,e as oe,i as Tr,j as Mr,l as Lr,m as Nr,w as p,x as Or,y as _r}from"./chunk-ESOXRGIY.js";import{A as br,B as ne,H as W,I as vr,N as Cr,S as xr,T as Sr,i as wr,n as _,o as F}from"./chunk-5SM4TCSW.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{availableParallelism as Ou}from"os";import{existsSync as Bn}from"fs";function Vn(){let e=new URL("solve-worker.js",import.meta.url);if(Bn(e))return e;let r=new URL("../dist/solve-worker.js",import.meta.url);if(Bn(r))return r;throw new Error("solve worker missing \u2014 run `pnpm --filter ripplo build` first (Z3 solves run in the built worker, even when the CLI runs from source)")}import _u from"update-notifier";import Fu from"yargs";import{hideBin as Wu}from"yargs/helpers";function pe({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 Hn(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as as}from"gql.tada";import{exec as Yi}from"child_process";import{createAuthClient as Qi}from"better-auth/client";import{deviceAuthorizationClient as Xi}from"better-auth/client/plugins";function Kn({baseURL:e}){return Qi({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Xi()]})}import{err as Gn,ok as Zi}from"neverthrow";var es=5e3,zn="ripplo-cli";async function Jn({onDeviceCode:e,url:r}){let n=r??Ar().RIPPLO_SERVER_URL,t=Kn({baseURL:n}),o=await t.device.code({client_id:zn});if(o.error!=null)return Gn({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}),ss(a),(await rs({authClient:t,deviceCode:i})).map(d=>(ur({serverUrl:n,token:d}),d))}async function rs({authClient:e,deviceCode:r}){for(;;){await os(es);let n=await e.device.token({client_id:zn,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return Zi(n.data.access_token);if(n.error==null)continue;if(!ts(n.error.error))return Gn({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var ns=new Set(["authorization_pending","slow_down"]);function ts(e){return ns.has(e)}function os(e){return new Promise(r=>{setTimeout(r,e)})}function is(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function ss(e){let r=is();Yi(`${r} "${e}"`,()=>{})}function I({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var ls=as(`
4
+ import{a as cn,c as pn,d as mn,e as fn,f as gn,g as ce}from"./chunk-YODZBLYM.js";import{a as Nn,b as On,d as _n,e as Fn,f as Wn,g as Dn,h as Un,i as qn,j as Bn,k as Vn,l as Hn,m as Kn,n as Gn}from"./chunk-CDPYJKK7.js";import{a as jn}from"./chunk-4XC5TAOG.js";import{b as an,c as ln,d as dn,f as un}from"./chunk-4H7EIC6W.js";import{A as q,C as En,G as In,H as An,K as Tn,L as Fe,N as Mn,O as Ln,a as en,b as rn,c as nn,d as tn,e as Le,f as on,g as hn,h as kn,j as wn,k as bn,l as vn,m as Cn,n as xn,o as Sn,q as Rn,w as _e,y as Pn,z as $n}from"./chunk-6BQADUAX.js";import{b as sn,c as ue}from"./chunk-WZBLSDNV.js";import{a as Xr}from"./chunk-MOI4L3EX.js";import{a as ae,b as Yr,c as de,d as Zr}from"./chunk-TY5K3P4F.js";import{a as R}from"./chunk-OQ6KNYPG.js";import{b as Y}from"./chunk-ZUPS6XVH.js";import{a as S,b as Nr,c as v}from"./chunk-LEFXRK53.js";import{a as Or}from"./chunk-7WZ3VIUU.js";import{e as Ne}from"./chunk-4W6WIT7T.js";import{a as br,b as zn,c as Jn}from"./chunk-UMSBDSRS.js";import{a as w}from"./chunk-R4ZTRVDQ.js";import{b as vr,c as Q,d as Cr,e as xr}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as Lr,b}from"./chunk-Q6IYTHMP.js";import{a as U,b as Tr,c as Te,d as Mr}from"./chunk-XZ2TPZLD.js";import{a as x}from"./chunk-MHNGR6M7.js";import{e as Jr,g as le,h as Qr}from"./chunk-INO3L4WS.js";import{b as Ar,e as X,h as T,j as jr,k as oe}from"./chunk-EVVF662P.js";import"./chunk-DBIXYJRB.js";import{a as cr,b as pr,c as mr,d as u,f as _,h as fr,j as E,k as gr,l as yr,m as je,n as hr,o as kr,p as wr}from"./chunk-PE5WVWI5.js";import{a as te}from"./chunk-CJUKILIO.js";import{k as Oe,l as yn}from"./chunk-RWFS5SCW.js";import{F as Br,K as Me,O as Vr,P as Hr,V as Kr,Y as se,Z as Gr,aa as zr,e as ie,i as _r,j as Fr,l as Wr,m as Dr,w as p,x as Ur,y as qr}from"./chunk-MG43RZXH.js";import{E as Rr,F as D,L as N,M as Pr,R as $r,W as Er,X as Ir,i as Sr,n as F,o as W}from"./chunk-4F67XQYS.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{availableParallelism as Gu}from"os";import{existsSync as Qn}from"fs";function Xn(){let e=new URL("solve-worker.js",import.meta.url);if(Qn(e))return e;let r=new URL("../dist/solve-worker.js",import.meta.url);if(Qn(r))return r;throw new Error("solve worker missing \u2014 run `pnpm --filter ripplo build` first (Z3 solves run in the built worker, even when the CLI runs from source)")}import zu from"update-notifier";import Ju from"yargs";import{hideBin as Qu}from"yargs/helpers";function pe({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 Yn(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as ms}from"gql.tada";import{exec as os}from"child_process";import{createAuthClient as ns}from"better-auth/client";import{deviceAuthorizationClient as ts}from"better-auth/client/plugins";function Zn({baseURL:e}){return ns({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[ts()]})}import{err as et,ok as is}from"neverthrow";var ss=5e3,rt="ripplo-cli";async function nt({onDeviceCode:e,url:r}){let n=r??Nr().RIPPLO_SERVER_URL,t=Zn({baseURL:n}),o=await t.device.code({client_id:rt});if(o.error!=null)return et({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}),ps(a),(await as({authClient:t,deviceCode:i})).map(d=>(gr({serverUrl:n,token:d}),d))}async function as({authClient:e,deviceCode:r}){for(;;){await us(ss);let n=await e.device.token({client_id:rt,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return is(n.data.access_token);if(n.error==null)continue;if(!ds(n.error.error))return et({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var ls=new Set(["authorization_pending","slow_down"]);function ds(e){return ls.has(e)}function us(e){return new Promise(r=>{setTimeout(r,e)})}function cs(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function ps(e){let r=cs();os(`${r} "${e}"`,()=>{})}function A({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var fs=ms(`
5
5
  query AuthViewer {
6
6
  currentUser {
7
7
  name
8
8
  email
9
9
  }
10
10
  }
11
- `);async function Qn(){let e=x(),r=$(e);if(r!=null&&await ds(e,r))return;let t=(await Jn({url:e,onDeviceCode:a=>{process.stdout.write(`Opening your browser to finish sign-in.
11
+ `);async function tt(){let e=S(),r=E(e);if(r!=null&&await gs(e,r))return;let t=(await nt({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
- `)}})).match(a=>a,a=>{process.stderr.write(`${w(a)}
17
- `),process.exit(1)}),o=await Oe({serverUrl:e,token:t}),i=jr(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
- `),process.stdout.write(o.kind==="ok"?`${s}, ${us(o.viewer)}.
16
+ `)}})).match(a=>a,a=>{process.stderr.write(`${b(a)}
17
+ `),process.exit(1)}),o=await We({serverUrl:e,token:t}),i=Or(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
+ `),process.stdout.write(o.kind==="ok"?`${s}, ${ys(o.viewer)}.
19
19
  `:`${s}.
20
- `),process.stdout.write(`Session saved to ${Ae(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 ds(e,r){let n=await Oe({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 ${je(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 gs(e,r){let n=await We({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 Xn(){let e=x(),r=$(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await Oe({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 ot(){let e=S(),r=E(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await We({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 Yn(){let e=x();if(!cr(e)){process.stdout.write(`Already signed out.
29
- `);return}process.stdout.write(`Signed out. Removed ${Ae(e)}.
30
- `)}async function Oe({serverUrl:e,token:r}){try{let t=(await u({config:I({serverUrl:e,token:r}),document:ls,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return lr(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function us(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as cs,writeFile as ps}from"fs/promises";import ms from"path";async function Zn(e){let r=process.cwd(),n=await te(r);n.isErr()&&_e(D(n.error));let t=n.value,[o,i]=await Promise.all([se({cwd:r,lockfile:t}),ae(r,t)]);o.length>0&&_e(le(o));let s=br(W,i),a=ms.join(r,j);if(e.check){await fs(a,s);return}await ps(a,s),gs(i)}function _e(e){process.stderr.write(`${e}
31
- `),process.exit(1)}async function fs(e,r){let n=await cs(e,"utf8").catch(()=>null);n!==r&&_e($r(n==null?"missing":"stale")),process.stdout.write(`${Pr()}
32
- `)}function gs(e){let r=Kr(e),n=e.workflows.reduce((o,i)=>o+i.tests.length,0),t=[Er(),...r.length>0?[zr(r)]:[],Gr(n)];process.stdout.write(`${t.join(`
28
+ `)}function it(){let e=S();if(!yr(e)){process.stdout.write(`Already signed out.
29
+ `);return}process.stdout.write(`Signed out. Removed ${je(e)}.
30
+ `)}async function We({serverUrl:e,token:r}){try{let t=(await u({config:A({serverUrl:e,token:r}),document:fs,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return mr(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function ys(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as hs,writeFile as ks}from"fs/promises";import ws from"path";async function st(e){let r=process.cwd(),n=await oe(r);n.isErr()&&me(U(n.error));let t=n.value,[o,i]=await Promise.all([ae({cwd:r,lockfile:t}),le(r,t)]);o.length>0&&me(de(o));let s=Rr(N,i),a=ws.join(r,T);if(e.check){await bs(a,i);return}await ks(a,s),Cs(i)}function me(e){process.stderr.write(`${e}
31
+ `),process.exit(1)}async function bs(e,r){let n=await hs(e,"utf8").catch(()=>null);n==null&&me(Te("missing")),vs(n,r)||me(Te("stale")),process.stdout.write(`${Tr()}
32
+ `)}function vs(e,r){try{let n=D(N,e);return n.checks==null?!1:Ar(n,r)}catch{return!1}}function Cs(e){let r=Xr(e),n=e.workflows.reduce((o,i)=>o+i.tests.length,0),t=[Mr(),...r.length>0?[Zr(r)]:[],Yr(n)];process.stdout.write(`${t.join(`
33
33
  `)}
34
- `)}import{graphql as et}from"gql.tada";function Fe(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 hs=ys(`
34
+ `)}import{graphql as at}from"gql.tada";function De(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 xs}from"gql.tada";var Ss=xs(`
35
35
  query DevSessionCheckPreflight($projectId: String!, $cwd: String!) {
36
36
  project(id: $projectId) {
37
37
  id
@@ -40,62 +40,62 @@ import{a as sn,c as an,d as ln,e as dn,f as un,g as ue}from"./chunk-LKYTQXPR.js"
40
40
  }
41
41
  }
42
42
  }
43
- `);function g(){return b(process.cwd()).match(e=>e,e=>{process.stderr.write(`${w(e)}
44
- `),process.stderr.write(`${C("setup")}
45
- `),process.exit(1)})}async function v(e){(await u({config:e,document:hs,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 ks=et(`
43
+ `);function g(){return v(process.cwd()).match(e=>e,e=>{process.stderr.write(`${b(e)}
44
+ `),process.stderr.write(`${x("setup")}
45
+ `),process.exit(1)})}async function C(e){(await u({config:e,document:Ss,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(`${x("setup")}
46
+ `),process.exit(1))}var Rs=at(`
47
47
  mutation CliUpdateMaxLocalConcurrentRuns($value: Int!) {
48
48
  updateMaxLocalConcurrentRuns(value: $value) {
49
49
  id
50
50
  maxLocalConcurrentRuns
51
51
  }
52
52
  }
53
- `),ws=et(`
53
+ `),Ps=at(`
54
54
  query CliMaxLocalConcurrentRuns {
55
55
  currentUser {
56
56
  id
57
57
  maxLocalConcurrentRuns
58
58
  }
59
59
  }
60
- `);async function rt({value:e}){let r=g();if(e==null){let t=await u({config:r,document:ws,variables:{}});process.stdout.write(`${Fe(t.currentUser?.maxLocalConcurrentRuns)}
61
- `);return}let n=await u({config:r,document:ks,variables:{value:e}});process.stdout.write(`${Fe(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
- `)}function nt(e){switch(e.type){case"settings":return bs(e);case"env-files":return vs(e);case"token":return Cs(e);case"dev-server":return xs(e);case"dev-session":return Qr(e);case"entities":return Ss(e);case"webhook-verification":return Rs(e);case"entities-validation":return Ps(e);case"workflows":return $s(e);case"browser":return Is(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 As(e);case"lockfile":return js(e);case"pre-commit-hook":return Ts(e);case"plugin-version":return Ms(e)}}function bs(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function vs(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=g();if(e==null){let t=await u({config:r,document:Ps,variables:{}});process.stdout.write(`${De(t.currentUser?.maxLocalConcurrentRuns)}
61
+ `);return}let n=await u({config:r,document:Rs,variables:{value:e}});process.stdout.write(`${De(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
+ `)}function dt(e){switch(e.type){case"settings":return $s(e);case"env-files":return Es(e);case"token":return Is(e);case"dev-server":return As(e);case"dev-session":return rn(e);case"entities":return js(e);case"webhook-verification":return Ts(e);case"entities-validation":return Ms(e);case"workflows":return Ls(e);case"browser":return Os(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 _s(e);case"lockfile":return Fs(e);case"pre-commit-hook":return Ws(e);case"plugin-version":return Ds(e)}}function $s(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function Es(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 Cs(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 ${x()} to validate the token.`}}function xs(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function Ss(e){return e.count===0?"! Entities: none defined":e.configured?e.endpointReachable===void 0?`! Entities: ${String(e.count)} defined (could not verify engine endpoint)`:`\u2713 Entities: ${String(e.count)} defined, engine configured`:`\u2717 Entities: ${String(e.count)} defined but RIPPLO_ENGINE_URL is not set in your env file`}function Rs(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 Ps(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 Is(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 ${S()} to validate the token.`}}function As(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function js(e){return e.count===0?"! Entities: none defined":e.configured?e.endpointReachable===void 0?`! Entities: ${String(e.count)} defined (could not verify engine endpoint)`:`\u2713 Entities: ${String(e.count)} defined, engine configured`:`\u2717 Entities: ${String(e.count)} defined but RIPPLO_ENGINE_URL is not set in your env file`}function Ts(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 Ms(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 $s(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=>Es(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
67
+ `)}`}function Ls(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=>Ns(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
68
68
  ${r.join(`
69
- `)}`}function Es(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
69
+ `)}`}function Ns(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
70
70
  `+r.join(`
71
- `)}function Is(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function As(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 js(e){switch(e.status){case"match":return`\u2713 Lockfile: ${j} is up to date`;case"missing":return`\u2717 Lockfile: ${j} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${j} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function Ts(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 Ms(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)`}import U from"fs";import Fs from"os";import We from"path";import{z as T}from"zod";import Ls from"latest-version";import tt from"semver";async function me(e){try{return await Promise.race([Ls("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function ot(e){return e.filter(r=>tt.valid(r)!=null).toSorted(tt.rcompare)[0]}import{graphql as Ns}from"gql.tada";var Os=Ns(`
71
+ `)}function Os(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function _s(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 Fs(e){switch(e.status){case"match":return`\u2713 Lockfile: ${T} is up to date`;case"missing":return`\u2717 Lockfile: ${T} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${T} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function Ws(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 Ds(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)`}import B from"fs";import Hs from"os";import Ue from"path";import{z as M}from"zod";import Us from"latest-version";import ut from"semver";async function fe(e){try{return await Promise.race([Us("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function ct(e){return e.filter(r=>ut.valid(r)!=null).toSorted(ut.rcompare)[0]}import{graphql as qs}from"gql.tada";var Bs=qs(`
72
72
  query DoctorAuthViewer {
73
73
  currentUser {
74
74
  name
75
75
  email
76
76
  }
77
77
  }
78
- `),_s="Failed to connect to Ripplo server";async function it({serverUrl:e,token:r}){try{let n=await u({config:I({serverUrl:e,token:r}),document:Os,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(_s)?{kind:"unreachable"}:{kind:"invalid"}}}function st(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"entities":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"entities-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}}async function at(e){let r=await Us(e),n={missing:kr(e),type:"env-files"},t=await qs(),o=await Bs(),i=await te(e),s=await Vs(e,i),a=Hs(i),l=await Ks(e,i),d=Gs(e),f=Ds(e),y=await zs(r,i);return[r,n,t,...y,s,a,l,d,o,...f==null?[]:[f]]}var Ws=T.object({plugins:T.record(T.string(),T.array(T.object({projectPath:T.string().optional(),scope:T.string().optional(),version:T.string()})))});function Ds(e){let r=We.join(Fs.homedir(),".claude","plugins","installed_plugins.json"),n=U.existsSync(r)?U.readFileSync(r,"utf8"):null;if(n==null)return null;let t=Ws.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=ot(o);return i==null?null:{cliVersion:k(),installed:i,type:"plugin-version"}}async function Us(e){let r=await Yr(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 qs(){let e=x(),r=$(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await it({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 Bs(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:U.existsSync(r),type:"browser"}}async function Vs(e,r){if(r.isErr())return{errorCount:1,errors:[{message:D(r.error),path:".ripplo/"}],found:!1,type:"entities-validation",valid:!1};let n=await se({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:le(n),path:""}],found:!0,type:"entities-validation",valid:n.length===0}}function Hs(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 Ks(e,r){return r.isErr()?{status:"missing",type:"lockfile"}:await Hr(e,r.value)!=null?{status:"match",type:"lockfile"}:{status:await U.promises.readFile(We.join(e,j),"utf8").catch(()=>null)==null?"missing":"stale",type:"lockfile"}}function Gs(e){let r=We.join(e,".git","hooks","pre-commit");return U.existsSync(r)?{installed:U.readFileSync(r,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function zs(e,r){let n=hr().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Te(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await Xr(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await Js(n,r);t.push(...s)}return t}async function Js(e,r){let n=r.isOk()?r.value.entities.length:0,t=e.engineUrl.length>0,o={configured:t,count:n,endpointReachable:void 0,type:"entities"};if(n===0||!t)return[o];let i=Xs(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Te(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"entities"}),lt(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await Zr({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let d=await Qs({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:d,type:"adapter-enabled",url:i}),a}async function Qs({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",...mr({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 lt(e){return e.startsWith("http://")||e.startsWith("https://")}function Xs(e,r){return lt(r)?r:`${e}${r}`}var Ys=3e3;async function dt(){let e=process.cwd(),[r,n]=await Promise.all([me(Ys),at(e)]);process.stdout.write(`${pe({current:k(),latest:r})}
79
- `);let t=n.map(i=>nt(i));process.stdout.write(t.join(`
78
+ `),Vs="Failed to connect to Ripplo server";async function pt({serverUrl:e,token:r}){try{let n=await u({config:A({serverUrl:e,token:r}),document:Bs,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(Vs)?{kind:"unreachable"}:{kind:"invalid"}}}function mt(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"entities":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"entities-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}}async function ft(e){let r=await zs(e),n={missing:xr(e),type:"env-files"},t=await Js(),o=await Qs(),i=await oe(e),s=await Xs(e,i),a=Ys(i),l=await Zs(e,i),d=ea(e),k=Gs(e),f=await ra(r,i);return[r,n,t,...f,s,a,l,d,o,...k==null?[]:[k]]}var Ks=M.object({plugins:M.record(M.string(),M.array(M.object({projectPath:M.string().optional(),scope:M.string().optional(),version:M.string()})))});function Gs(e){let r=Ue.join(Hs.homedir(),".claude","plugins","installed_plugins.json"),n=B.existsSync(r)?B.readFileSync(r,"utf8"):null;if(n==null)return null;let t=Ks.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=ct(o);return i==null?null:{cliVersion:w(),installed:i,type:"plugin-version"}}async function zs(e){let r=await tn(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 Js(){let e=S(),r=E(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await pt({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 Qs(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:B.existsSync(r),type:"browser"}}async function Xs(e,r){if(r.isErr())return{errorCount:1,errors:[{message:U(r.error),path:".ripplo/"}],found:!1,type:"entities-validation",valid:!1};let n=await ae({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:de(n),path:""}],found:!0,type:"entities-validation",valid:n.length===0}}function Ys(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 Zs(e,r){return r.isErr()?{status:"missing",type:"lockfile"}:(await Qr(e,r.value)).isOk()?{status:"match",type:"lockfile"}:{status:await B.promises.readFile(Ue.join(e,T),"utf8").catch(()=>null)==null?"missing":"stale",type:"lockfile"}}function ea(e){let r=Ue.join(e,".git","hooks","pre-commit");return B.existsSync(r)?{installed:B.readFileSync(r,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function ra(e,r){let n=Cr().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Le(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await nn(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await na(n,r);t.push(...s)}return t}async function na(e,r){let n=r.isOk()?r.value.entities.length:0,t=e.engineUrl.length>0,o={configured:t,count:n,endpointReachable:void 0,type:"entities"};if(n===0||!t)return[o];let i=oa(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Le(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"entities"}),gt(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await on({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let d=await ta({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:d,type:"adapter-enabled",url:i}),a}async function ta({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",...kr({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 gt(e){return e.startsWith("http://")||e.startsWith("https://")}function oa(e,r){return gt(r)?r:`${e}${r}`}var ia=3e3;async function yt(){let e=process.cwd(),[r,n]=await Promise.all([fe(ia),ft(e)]);process.stdout.write(`${pe({current:w(),latest:r})}
79
+ `);let t=n.map(i=>dt(i));process.stdout.write(t.join(`
80
80
  `)+`
81
- `);let o=n.some(i=>st(i));process.exit(o?1:0)}import fe from"fs";import{graphql as Zs}from"gql.tada";var ea=Zs(`
81
+ `);let o=n.some(i=>mt(i));process.exit(o?1:0)}import ge from"fs";import{graphql as sa}from"gql.tada";var aa=sa(`
82
82
  mutation CliSetHooksPaused($projectId: String!, $paused: Boolean!) {
83
83
  setHooksPaused(projectId: $projectId, paused: $paused) {
84
84
  id
85
85
  }
86
86
  }
87
- `);async function ut(){let e=process.cwd();dr(e);let r=Me(e);if(fe.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}fe.writeFileSync(r,""),await pt(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 ct(){let e=process.cwd(),r=Me(e);if(!fe.existsSync(r)){process.stdout.write(`Hooks already active.
88
- `);return}fe.unlinkSync(r),await pt(e,!1),process.stdout.write(`Hooks resumed.
89
- `)}async function pt(e,r){let n=b(e).unwrapOr(void 0);n!=null&&await u({config:n,document:ea,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.
90
- `)})}import q from"fs";import B from"path";import{input as wt,select as bt}from"@inquirer/prompts";import{graphql as Ma}from"gql.tada";import{exec as ra,execFile as na}from"child_process";import{err as ta,ok as mt}from"neverthrow";import m from"fs";import{createRequire as oa}from"module";import h from"path";import{promisify as gt}from"util";var ia=["ripplo","@ripplo/testing","@ripplo/instrument"],ft=".ripplo/ripplo.lock linguist-generated=true",sa=[".ripplo/debug/",".ripplo/.local/"],aa=gt(ra),la=gt(na);async function yt({cwd:e,onStep:r}){r("Scaffolding project files..."),wa({cwd:e}),r("Updating .gitignore..."),va(e),r("Marking ripplo.lock as generated..."),pa(e),r("Installing dependencies...");let n=await ua(e),t=[];if(n.ok||t.push({manualCommand:n.cmd,message:`Couldn't auto-install dev dependencies (${n.reason}). Run the command below, then run \`npx ripplo compile\` to build the lockfile.`}),n.ok){r("Compiling initial lockfile...");let i=await ca(e);i!=null&&t.push({manualCommand:void 0,message:i})}return r("Setting up browser..."),(await da()).map(()=>t)}async function da(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return mt(void 0);O.info("Chromium not found. Installing via Playwright...");let n=oa(import.meta.url),t=h.dirname(n.resolve("playwright/package.json")),o=h.join(t,"cli.js");return await la(process.execPath,[o,"install","chromium"]),m.existsSync(r)?mt(void 0):ta({kind:"playwright-install-failed"})}async function ua(e){let r=ma({cwd:e,pm:ka(e)});O.info("Installing dependencies: %s",r);try{return await aa(r,{cwd:e}),{ok:!0}}catch(n){let t=n instanceof Error?n.message.split(`
91
- `)[0]??n.message:String(n);return O.warn("Install failed (%s): %s",r,t),{cmd:r,ok:!1,reason:t}}}async function ca(e){try{await Vr(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function pa(e){let r=h.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes(ft))return;let t=n.length===0||n.endsWith(`
87
+ `);async function ht(){let e=process.cwd();fr(e);let r=Ne(e);if(ge.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}ge.writeFileSync(r,""),await wt(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=Ne(e);if(!ge.existsSync(r)){process.stdout.write(`Hooks already active.
88
+ `);return}ge.unlinkSync(r),await wt(e,!1),process.stdout.write(`Hooks resumed.
89
+ `)}async function wt(e,r){let n=v(e).unwrapOr(void 0);n!=null&&await u({config:n,document:aa,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.
90
+ `)})}import V from"fs";import H from"path";import{input as Pt,select as $t}from"@inquirer/prompts";import{graphql as Da}from"gql.tada";import{exec as la,execFile as da}from"child_process";import{err as ua,ok as bt}from"neverthrow";import m from"fs";import{createRequire as ca}from"module";import h from"path";import{promisify as Ct}from"util";var pa=["ripplo","@ripplo/testing","@ripplo/instrument"],vt=".ripplo/ripplo.lock linguist-generated=true",ma=[".ripplo/debug/",".ripplo/.local/"],fa=Ct(la),ga=Ct(da);async function xt({cwd:e,onStep:r}){r("Scaffolding project files..."),Pa({cwd:e}),r("Updating .gitignore..."),Ea(e),r("Marking ripplo.lock as generated..."),wa(e),r("Installing dependencies...");let n=await ha(e),t=[];if(n.ok||t.push({manualCommand:n.cmd,message:`Couldn't auto-install dev dependencies (${n.reason}). Run the command below, then run \`npx ripplo compile\` to build the lockfile.`}),n.ok){r("Compiling initial lockfile...");let i=await ka(e);i!=null&&t.push({manualCommand:void 0,message:i})}return r("Setting up browser..."),(await ya()).map(()=>t)}async function ya(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return bt(void 0);_.info("Chromium not found. Installing via Playwright...");let n=ca(import.meta.url),t=h.dirname(n.resolve("playwright/package.json")),o=h.join(t,"cli.js");return await ga(process.execPath,[o,"install","chromium"]),m.existsSync(r)?bt(void 0):ua({kind:"playwright-install-failed"})}async function ha(e){let r=ba({cwd:e,pm:Ra(e)});_.info("Installing dependencies: %s",r);try{return await fa(r,{cwd:e}),{ok:!0}}catch(n){let t=n instanceof Error?n.message.split(`
91
+ `)[0]??n.message:String(n);return _.warn("Install failed (%s): %s",r,t),{cmd:r,ok:!1,reason:t}}}async function ka(e){try{await Jr(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function wa(e){let r=h.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes(vt))return;let t=n.length===0||n.endsWith(`
92
92
  `)?"":`
93
- `;m.writeFileSync(r,`${n}${t}${ft}
94
- `)}function ma({cwd:e,pm:r}){let n=ia.join(" ");return r==="pnpm"?fa(e)?`pnpm add -wD ${n}`:`pnpm add -D ${n}`:r==="yarn"?ga({cwd:e,deps:n}):r==="bun"?`bun add -d ${n}`:`npm install -D ${n}`}function fa(e){return m.existsSync(h.join(e,"pnpm-workspace.yaml"))||m.existsSync(h.join(e,"pnpm-workspace.yml"))}function ga({cwd:e,deps:r}){return ya(e)?`yarn add -D ${r}`:ha(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`}function ya(e){if(m.existsSync(h.join(e,".yarnrc.yml"))||m.existsSync(h.join(e,".pnp.cjs"))||m.existsSync(h.join(e,".pnp.js")))return!0;let r=h.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 ha(e){let r=h.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 ka(e){return m.existsSync(h.join(e,"pnpm-lock.yaml"))?"pnpm":m.existsSync(h.join(e,"yarn.lock"))?"yarn":m.existsSync(h.join(e,"bun.lockb"))||m.existsSync(h.join(e,"bun.lock"))?"bun":"npm"}function wa({cwd:e}){let r=h.join(e,".ripplo");Aa.forEach(({content:n,relPath:t})=>{let o=h.join(r,t);m.mkdirSync(h.dirname(o),{recursive:!0}),ba(o,n)})}function ba(e,r){m.existsSync(e)||m.writeFileSync(e,r)}function va(e){let r=h.join(e,".gitignore");if(!m.existsSync(r))return;let n=m.readFileSync(r,"utf8"),t=sa.filter(i=>!n.includes(i));if(t.length===0)return;let o=n.endsWith(`
93
+ `;m.writeFileSync(r,`${n}${t}${vt}
94
+ `)}function ba({cwd:e,pm:r}){let n=pa.join(" ");return r==="pnpm"?va(e)?`pnpm add -wD ${n}`:`pnpm add -D ${n}`:r==="yarn"?Ca({cwd:e,deps:n}):r==="bun"?`bun add -d ${n}`:`npm install -D ${n}`}function va(e){return m.existsSync(h.join(e,"pnpm-workspace.yaml"))||m.existsSync(h.join(e,"pnpm-workspace.yml"))}function Ca({cwd:e,deps:r}){return xa(e)?`yarn add -D ${r}`:Sa(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`}function xa(e){if(m.existsSync(h.join(e,".yarnrc.yml"))||m.existsSync(h.join(e,".pnp.cjs"))||m.existsSync(h.join(e,".pnp.js")))return!0;let r=h.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 Sa(e){let r=h.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 Ra(e){return m.existsSync(h.join(e,"pnpm-lock.yaml"))?"pnpm":m.existsSync(h.join(e,"yarn.lock"))?"yarn":m.existsSync(h.join(e,"bun.lockb"))||m.existsSync(h.join(e,"bun.lock"))?"bun":"npm"}function Pa({cwd:e}){let r=h.join(e,".ripplo");_a.forEach(({content:n,relPath:t})=>{let o=h.join(r,t);m.mkdirSync(h.dirname(o),{recursive:!0}),$a(o,n)})}function $a(e,r){m.existsSync(e)||m.writeFileSync(e,r)}function Ea(e){let r=h.join(e,".gitignore");if(!m.existsSync(r))return;let n=m.readFileSync(r,"utf8"),t=ma.filter(i=>!n.includes(i));if(t.length===0)return;let o=n.endsWith(`
95
95
  `)?"":`
96
96
  `;m.writeFileSync(r,n+o+t.join(`
97
97
  `)+`
98
- `)}var Ca=`import { createRipplo } from "@ripplo/testing";
98
+ `)}var Ia=`import { createRipplo } from "@ripplo/testing";
99
99
  import { entities } from "./entities/index";
100
100
  import { singletons } from "./singletons/index";
101
101
  import { workflows } from "./workflows/index";
@@ -108,7 +108,7 @@ export default createRipplo({
108
108
  facts,
109
109
  viewports: ["desktop", "mobile"],
110
110
  });
111
- `,xa=`// Model the app's state as entities. Each entity gets a \`seed\`/\`read\` impl in your
111
+ `,Aa=`// Model the app's state as entities. Each entity gets a \`seed\`/\`read\` impl in your
112
112
  // app's engine funnel (createEngine). See /ripplo:create "Adding an entity".
113
113
  //
114
114
  // Example:
@@ -123,7 +123,7 @@ export default createRipplo({
123
123
  // export const entities = [Project] as const;
124
124
 
125
125
  export const entities = [] as const;
126
- `,Sa=`// Client/global state (e.g. localStorage flags) modeled as singletons.
126
+ `,ja=`// Client/global state (e.g. localStorage flags) modeled as singletons.
127
127
  //
128
128
  // Example:
129
129
  // //
@@ -137,7 +137,7 @@ export const entities = [] as const;
137
137
  // export const singletons = [onboardingDismissed];
138
138
 
139
139
  export const singletons = [];
140
- `,Ra=`// App-wide rules enforced everywhere, independent of any workflow \u2014 invariants and
140
+ `,Ta=`// App-wide rules enforced everywhere, independent of any workflow \u2014 invariants and
141
141
  // permission boundaries. See /ripplo:create "Declared facts".
142
142
  //
143
143
  // Example:
@@ -150,7 +150,7 @@ export const singletons = [];
150
150
  // export const facts = [noCrashScreen] as const;
151
151
 
152
152
  export const facts = [] as const;
153
- `,Pa=`// Pure builder functions, each returning one entity handle (or a tight cluster) \u2014 the
153
+ `,Ma=`// Pure builder functions, each returning one entity handle (or a tight cluster) \u2014 the
154
154
  // starting state workflows compose. Parents come in as arguments, foreign keys wire from
155
155
  // their handles. See /ripplo:create "Givens".
156
156
  //
@@ -161,7 +161,7 @@ export const facts = [] as const;
161
161
  // export const user = () => User.of({ email: arbitrary(User.field.email) });
162
162
  // export const ownedProject = (me: ReturnType<typeof user>) =>
163
163
  // Project.of({ name: arbitrary(Project.field.name), ownerId: me.id });
164
- `,$a=`// Each file under ./workflows exports a workflow. Import them here and add to the
164
+ `,La=`// Each file under ./workflows exports a workflow. Import them here and add to the
165
165
  // \`workflows\` array \u2014 that's what createRipplo({ ..., workflows }) receives. Stub with
166
166
  // \`workflow("Intent")\` (no body); implement later with \`workflow("Intent", () => ({ given, steps }))\`.
167
167
  //
@@ -170,7 +170,7 @@ export const facts = [] as const;
170
170
  // export const workflows = [createProject] as const;
171
171
 
172
172
  export const workflows = [] as const;
173
- `,Ea=`{
173
+ `,Na=`{
174
174
  "compilerOptions": {
175
175
  "strict": true,
176
176
  "noUncheckedIndexedAccess": true,
@@ -186,7 +186,7 @@ export const workflows = [] as const;
186
186
  "include": ["*.ts", "entities/**/*.ts", "singletons/**/*.ts", "workflows/**/*.ts"],
187
187
  "exclude": ["node_modules"]
188
188
  }
189
- `,Ia=`// Guards spec files against shadowing DSL imports \u2014 \`const url = ...\` next to the
189
+ `,Oa=`// Guards spec files against shadowing DSL imports \u2014 \`const url = ...\` next to the
190
190
  // imported \`url\` locator silently breaks specs. Requires typescript-eslint (and
191
191
  // ESLint's per-directory config lookup). Delete this file if your lint setup differs.
192
192
  import tseslint from "typescript-eslint";
@@ -200,47 +200,47 @@ export default tseslint.config({
200
200
  },
201
201
  plugins: { "@typescript-eslint": tseslint.plugin },
202
202
  });
203
- `,Aa=[{content:Ca,relPath:"index.ts"},{content:xa,relPath:"entities/index.ts"},{content:Sa,relPath:"singletons/index.ts"},{content:Ra,relPath:"facts.ts"},{content:Pa,relPath:"givens.ts"},{content:$a,relPath:"workflows/index.ts"},{content:Ea,relPath:"tsconfig.json"},{content:Ia,relPath:"eslint.config.js"}];import ge from"fs";import ht from"path";import{z as De}from"zod";var ja={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},kt=De.record(De.string(),De.unknown());function ye(e){let r=ht.join(e,".claude","settings.json"),n=Ta(r);if(n==null)return"unparseable";let t=kt.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:ja}};return ge.mkdirSync(ht.dirname(r),{recursive:!0}),ge.writeFileSync(r,`${JSON.stringify(o,null,2)}
204
- `),"written"}function Ta(e){if(!ge.existsSync(e))return{};try{let r=kt.safeParse(JSON.parse(ge.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function he(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 La=Ma(`
203
+ `,_a=[{content:Ia,relPath:"index.ts"},{content:Aa,relPath:"entities/index.ts"},{content:ja,relPath:"singletons/index.ts"},{content:Ta,relPath:"facts.ts"},{content:Ma,relPath:"givens.ts"},{content:La,relPath:"workflows/index.ts"},{content:Na,relPath:"tsconfig.json"},{content:Oa,relPath:"eslint.config.js"}];import ye from"fs";import St from"path";import{z as qe}from"zod";var Fa={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},Rt=qe.record(qe.string(),qe.unknown());function he(e){let r=St.join(e,".claude","settings.json"),n=Wa(r);if(n==null)return"unparseable";let t=Rt.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:Fa}};return ye.mkdirSync(St.dirname(r),{recursive:!0}),ye.writeFileSync(r,`${JSON.stringify(o,null,2)}
204
+ `),"written"}function Wa(e){if(!ye.existsSync(e))return{};try{let r=Rt.safeParse(JSON.parse(ye.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function ke(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 Ua=Da(`
205
205
  query InitProjects {
206
206
  projects {
207
207
  id
208
208
  name
209
209
  }
210
210
  }
211
- `),Ue=["../.env.local","../.env"];async function vt(e=_a()){let r=process.cwd(),n=x(),t=$(n);t==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login` first.\n"),process.exit(1)),Na(r)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${r}. To re-init, delete it first.
212
- `),process.exit(1));let o=await Oa({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 Wa(o,e.projectId),s=await Da(r,e.envFile),a=await qa(e.appUrl),l=Fa(a,e.engineUrl),d=B.resolve(B.join(r,".ripplo"),s);yr({cwd:r,envFiles:[s],projectId:i}),Va({appUrl:a,engineUrl:l,filePath:d}),process.stdout.write(`${he(ye(r))}
213
- `);let y=(await yt({cwd:r,onStep:c=>{process.stdout.write(` ${c}
214
- `)}})).match(c=>c,c=>{process.stderr.write(`${w(c)}
215
- `),process.exit(1)});if(y.length>0){process.stdout.write(`Done with warnings:
216
- `),y.forEach(c=>{process.stdout.write(` - ${c.message}
211
+ `),Be=["../.env.local","../.env"];async function Et(e=Va()){let r=process.cwd(),n=S(),t=E(n);t==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login` first.\n"),process.exit(1)),qa(r)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${r}. To re-init, delete it first.
212
+ `),process.exit(1));let o=await Ba({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 Ka(o,e.projectId),s=await Ga(r,e.envFile),a=await Ja(e.appUrl),l=Ha(a,e.engineUrl),d=H.resolve(H.join(r,".ripplo"),s);vr({cwd:r,envFiles:[s],projectId:i}),Xa({appUrl:a,engineUrl:l,filePath:d}),process.stdout.write(`${ke(he(r))}
213
+ `);let f=(await xt({cwd:r,onStep:c=>{process.stdout.write(` ${c}
214
+ `)}})).match(c=>c,c=>{process.stderr.write(`${b(c)}
215
+ `),process.exit(1)});if(f.length>0){process.stdout.write(`Done with warnings:
216
+ `),f.forEach(c=>{process.stdout.write(` - ${c.message}
217
217
  `),c.manualCommand!=null&&process.stdout.write(` run: ${c.manualCommand}
218
- `)});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 Na(e){return q.existsSync(B.join(e,".ripplo","index.ts"))}async function Oa({serverUrl:e,token:r}){return((await u({config:I({serverUrl:e,token:r}),document:La,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function _a(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function Fa(e,r){if(r!=null){try{new URL(r)}catch{process.stdout.write(`--engine-url is not a valid URL: ${r}
219
- `),process.exit(1)}return r}return`${e.replace(/\/$/,"")}/ripplo`}async function Wa(e,r){if(r!=null){let n=e.find(t=>t.id===r);return n==null&&(process.stdout.write(`Unknown project id: ${r}
218
+ `)});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 qa(e){return V.existsSync(H.join(e,".ripplo","index.ts"))}async function Ba({serverUrl:e,token:r}){return((await u({config:A({serverUrl:e,token:r}),document:Ua,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function Va(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function Ha(e,r){if(r!=null){try{new URL(r)}catch{process.stdout.write(`--engine-url is not a valid URL: ${r}
219
+ `),process.exit(1)}return r}return`${e.replace(/\/$/,"")}/ripplo`}async function Ka(e,r){if(r!=null){let n=e.find(t=>t.id===r);return n==null&&(process.stdout.write(`Unknown project id: ${r}
220
220
  `),process.exit(1)),process.stdout.write(`Using project: ${n.name} (${n.id})
221
221
  `),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})
222
- `),n.id}return bt({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function Da(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
223
- `),process.exit(1)),r):Ua(e)}async function Ua(e){let r=B.join(e,".ripplo"),n=Ue.find(o=>q.existsSync(B.resolve(r,o))),t=await bt({choices:[...Ue.map(o=>({name:n===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:n??Ue[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:wt({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function qa(e){if(e!=null){try{new URL(e)}catch{process.stdout.write(`--app-url is not a valid URL: ${e}
224
- `),process.exit(1)}return e}return Ba()}async function Ba(){return wt({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 Va({appUrl:e,engineUrl:r,filePath:n}){q.mkdirSync(B.dirname(n),{recursive:!0});let t=q.existsSync(n)?q.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=${fr()}`),/^ENABLE_RIPPLO_TESTING=/m.test(t)||o.push("ENABLE_RIPPLO_TESTING=true"),o.length===0)return;let i=t.length===0||t.endsWith(`
222
+ `),n.id}return $t({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function Ga(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
223
+ `),process.exit(1)),r):za(e)}async function za(e){let r=H.join(e,".ripplo"),n=Be.find(o=>V.existsSync(H.resolve(r,o))),t=await $t({choices:[...Be.map(o=>({name:n===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:n??Be[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:Pt({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function Ja(e){if(e!=null){try{new URL(e)}catch{process.stdout.write(`--app-url is not a valid URL: ${e}
224
+ `),process.exit(1)}return e}return Qa()}async function Qa(){return Pt({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 Xa({appUrl:e,engineUrl:r,filePath:n}){V.mkdirSync(H.dirname(n),{recursive:!0});let t=V.existsSync(n)?V.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=${wr()}`),/^ENABLE_RIPPLO_TESTING=/m.test(t)||o.push("ENABLE_RIPPLO_TESTING=true"),o.length===0)return;let i=t.length===0||t.endsWith(`
225
225
  `)?"":`
226
- `;q.writeFileSync(n,`${t}${i}${o.join(`
226
+ `;V.writeFileSync(n,`${t}${i}${o.join(`
227
227
  `)}
228
- `)}import{graphql as Ve}from"gql.tada";function qe(){return"Not signed in. Run `npx ripplo auth login` first."}function Ct(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function xt(e){return["You belong to multiple organizations \u2014 pass `--org <id>`:",...e.map(n=>` ${n.id} ${n.name}`)].join(`
229
- `)}function Be(e){return`Could not create the project \u2014 ${e}`}var Ha=Ve(`
228
+ `)}import{graphql as Ke}from"gql.tada";function Ve(){return"Not signed in. Run `npx ripplo auth login` first."}function It(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function At(e){return["You belong to multiple organizations \u2014 pass `--org <id>`:",...e.map(n=>` ${n.id} ${n.name}`)].join(`
229
+ `)}function He(e){return`Could not create the project \u2014 ${e}`}var Ya=Ke(`
230
230
  query ProjectsList {
231
231
  projects {
232
232
  id
233
233
  name
234
234
  }
235
235
  }
236
- `),Ka=Ve(`
236
+ `),Za=Ke(`
237
237
  query OrganizationsList {
238
238
  organizations {
239
239
  id
240
240
  name
241
241
  }
242
242
  }
243
- `),Ga=Ve(`
243
+ `),el=Ke(`
244
244
  mutation CliCreateProject($name: String!, $organizationId: String!) {
245
245
  createProject(cloudBaseUrl: "", name: $name, organizationId: $organizationId) {
246
246
  __typename
@@ -256,17 +256,17 @@ export default tseslint.config({
256
256
  }
257
257
  }
258
258
  }
259
- `);async function St(){let e=x(),r=$(e);r==null&&(process.stderr.write(`${qe()}
260
- `),process.exit(1));let t=((await u({config:I({serverUrl:e,token:r}),document:Ha,variables:void 0})).projects??[]).map(o=>({id:o.id,name:o.name}));process.stdout.write(`${JSON.stringify({projects:t},null,2)}
261
- `)}async function Rt({name:e,orgId:r}){let n=x(),t=$(n);t==null&&(process.stderr.write(`${qe()}
262
- `),process.exit(1));let o=I({serverUrl:n,token:t}),i=r??await za(o),a=(await u({config:o,document:Ga,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof ar&&(process.stderr.write(`${Be(l.message)}
263
- `),process.exit(1)),l})).createProject;if(a?.__typename!=="Project"){let l=a?.message??"unknown error";process.stderr.write(`${Be(l)}
259
+ `);async function jt(){let e=S(),r=E(e);r==null&&(process.stderr.write(`${Ve()}
260
+ `),process.exit(1));let t=((await u({config:A({serverUrl:e,token:r}),document:Ya,variables:void 0})).projects??[]).map(o=>({id:o.id,name:o.name}));process.stdout.write(`${JSON.stringify({projects:t},null,2)}
261
+ `)}async function Tt({name:e,orgId:r}){let n=S(),t=E(n);t==null&&(process.stderr.write(`${Ve()}
262
+ `),process.exit(1));let o=A({serverUrl:n,token:t}),i=r??await rl(o),a=(await u({config:o,document:el,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof pr&&(process.stderr.write(`${He(l.message)}
263
+ `),process.exit(1)),l})).createProject;if(a?.__typename!=="Project"){let l=a?.message??"unknown error";process.stderr.write(`${He(l)}
264
264
  `),process.exit(1)}process.stdout.write(`${JSON.stringify({project:{id:a.id,name:a.name}},null,2)}
265
- `)}async function za(e){let n=((await u({config:e,document:Ka,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?Ct():xt(n)}
266
- `),process.exit(1)}import{spawnSync as ke}from"child_process";function Pt(){if(ke("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};ke("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=ke("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:ke("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function $t(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function Et(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?`
267
- ${e.detail}`:""}`}function It(){process.stdout.write(`${$t()}
268
- `);let e=Pt();e.kind!=="launched"&&(process.stderr.write(`${Et(e)}
269
- `),process.exit(1)),process.exit(e.exitCode)}import{graphql as Ja}from"gql.tada";function At({id:e,kind:r,title:n}){return`Caught bug reported (${r}): "${n}" [${e}]`}var Qa=Ja(`
265
+ `)}async function rl(e){let n=((await u({config:e,document:Za,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?It():At(n)}
266
+ `),process.exit(1)}import{spawnSync as we}from"child_process";function Mt(){if(we("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};we("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=we("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:we("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function Lt(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function Nt(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?`
267
+ ${e.detail}`:""}`}function Ot(){process.stdout.write(`${Lt()}
268
+ `);let e=Mt();e.kind!=="launched"&&(process.stderr.write(`${Nt(e)}
269
+ `),process.exit(1)),process.exit(e.exitCode)}import{graphql as nl}from"gql.tada";function _t({id:e,kind:r,title:n}){return`Caught bug reported (${r}): "${n}" [${e}]`}var tl=nl(`
270
270
  mutation ReportCaughtBug(
271
271
  $projectId: String!
272
272
  $kind: CaughtBugKind!
@@ -294,41 +294,48 @@ ${e.detail}`:""}`}function It(){process.stdout.write(`${$t()}
294
294
  }
295
295
  }
296
296
  }
297
- `);async function jt(e){let r=g(),t=(await u({config:r,document:Qa,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"}
298
- `),process.exit(1)}process.stdout.write(`${At({id:t.id,kind:e.kind,title:e.title})}
299
- `)}import Xa from"path";import{CancellationTokenSource as Ya}from"vscode-jsonrpc/node";function Tt(e){return`ripplo: workspace build is stale (${e.join(", ")}) \u2014 rebuilding`}function Mt(){return"ripplo: workspace build failed \u2014 fix the build, then rerun"}function we(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 Lt({all:e,headed:r,ids:n}){let t=process.cwd(),o=process.argv[1];o==null&&M(ue({kind:"spawn-failed",message:"process.argv[1] missing"})),el();let i=await sn(t);i!=null&&M(dn(i));let a=(await rn({cliEntry:o,cwd:t})).match(c=>c,c=>M(ue(c)));a.versionNote?.kind==="stale-busy"&&M(Le(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${Le(a.versionNote)}
300
- `);let l=new Ya;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let d=Xa.join(t,".ripplo","debug"),y=(await nn({connection:a,request:{all:e,headed:r,tests:[...n]},token:l.token,onEvent:c=>{let S=ln({debugDir:d,event:c});S!=null&&process.stdout.write(`${S}
301
- `)}})).match(c=>c,c=>M(ue(c)));await Za({connection:a,result:y})}async function Za({connection:e,result:r}){await new Promise(n=>{e.socket.end(n)}),r.kind==="daemon-error"&&M(un(r.error)),process.stdout.write(`${an(r)}
302
- `),r.failed>0&&process.exit(1),process.exit(r.notRun>0?2:0)}function M(e){process.stderr.write(`${e}
303
- `),process.exit(1)}function el(){let e=de();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=we(e);M(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Tt(e.packages)}
304
- `),en(e.workspaceRoot)||M(Mt())}import L from"path";import il from"os";import{mkdtempSync as sl,rmSync as al}from"fs";import{err as Ce,ok as Ge}from"neverthrow";import{z as Nt}from"zod";import{readdir as rl,rm as nl,stat as tl}from"fs/promises";import{existsSync as ol}from"fs";import He from"path";async function Ke(e,r){let t=(await rl(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||ol(He.join(e,s,vn)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await tl(He.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>nl(He.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var Ot=50,ll=15e3;async function _t(){re(k());let e=process.cwd(),r=O.child({worker:process.pid}),n=bn(),t=sl(L.join(il.tmpdir(),"ripplo-browser-cache-")),o=ie({cacheDir:t,clientVersion:k(),debugDir:L.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)},ll).unref(),ul(i).then(()=>o.close().catch(()=>{})).then(()=>{al(t,{force:!0,recursive:!0}),process.exit(l)})};process.on("disconnect",()=>{a(1)}),process.on("unhandledRejection",l=>{r.error({err:l},"worker unhandled rejection")}),process.on("uncaughtException",l=>{r.error({err:l},"worker uncaught exception"),a(1)}),n.onRequest(gn,async(l,d)=>{let f=pn.safeParse(l);if(!f.success)return be("bad-run-assign");let y=f.data;K(e);let c=b(e).match(P=>P,P=>P.kind);if(typeof c=="string")return be(`config:${c}`);let S=await Ft(n);if(S.isErr())return be(`lockfile-unavailable:${S.error}`);let ee=S.value,N=oe(ee).find(P=>P.ref===y.testRef);if(N==null)return be(`no-test:${y.testRef}`);try{let{outcome:P,persisted:Ie}=await Cn({config:c,cwd:e,errorSettle:"settle",fixturesDir:L.join(e,G),headed:y.headed,lockfile:ee,onPhase:void 0,runId:y.runId,session:o,signal:Ne(d),test:N.test}),ir=L.join(e,".ripplo","debug");return s(Promise.allSettled([Ie]).then(()=>ce({config:c,debugDir:ir,runId:y.runId})).then(()=>Ke(ir,Ot)).catch(()=>{})),{outcome:cn(P),serverNotified:!0}}catch(P){let Ie=L.join(e,".ripplo","debug");if(s(ce({config:c,debugDir:Ie,runId:y.runId}).catch(()=>{})),P instanceof sr)return{outcome:{detail:P.message,kind:"infra-error"},serverNotified:!1};throw P}}),n.onRequest(hn,(l,d)=>pl({connection:n,cwd:e,raw:l,session:o,token:d,track:s})),n.onNotification(kn,l=>{let d=mn.safeParse(l);d.success&&o.injectSpan(d.data.runId,d.data.span)}),n.onNotification(wn,()=>{a(0)}),n.sendNotification(fn),await new Promise(()=>{})}function be(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var dl=5e3;async function ul(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,dl)})])}var cl=Nt.object({assign:Wr,devSessionId:Nt.string().nullable()});async function pl({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=cl.safeParse(n);if(!s.success)return{kind:"error",reason:"bad-assign"};let{assign:a,devSessionId:l}=s.data;K(r);let d=b(r).match(N=>N,N=>N.kind);if(typeof d=="string")return{kind:"error",reason:`config:${d}`};let f=await Ft(e);if(f.isErr())return{kind:"error",reason:`lockfile:${f.error}`};let y=f.value,c=L.join(d.cwd,".ripplo","debug"),S=await xn({assign:a,config:d,debugDir:c,devSessionId:l??void 0,fixturesDir:L.join(d.cwd,G),headed:!1,lockfile:y,report:!0,session:t,signal:Ne(o)}),ee=S.kind==="finding"&&S.runId!=null?ce({config:d,debugDir:c,runId:S.runId}):Promise.resolve();return i(ee.then(()=>Ke(c,Ot)).catch(()=>{})),S}async function Ft(e){return(await ml(e)).andThen(n=>n.unavailable!=null?Ce(n.unavailable):n.lockfileJson==null?Ce("empty-reply"):fl(n.lockfileJson))}async function ml(e){try{return Ge(await e.sendRequest(yn))}catch(r){return Ce(`transport:${r instanceof Error?r.message:"unknown"}`)}}var ve;function fl(e){if(ve!==void 0&&ve.json===e)return Ge(ve.lockfile);try{let r=vr(ne(W,e));return ve={json:e,lockfile:r},Ge(r)}catch(r){return Ce(`worker-decode-failed:${r instanceof Error?r.message.slice(0,200):"unknown"}`)}}async function Wt(){await _t()}import{existsSync as Sl}from"fs";import Rl from"path";import{ok as Pl}from"neverthrow";import{gunzipSync as gl}from"zlib";import{mkdir as yl,writeFile as hl}from"fs/promises";import Dt from"path";import{graphql as kl}from"gql.tada";import{err as J,ok as wl}from"neverthrow";var bl=31,vl=139;async function xe(e,r){let n=b(e).match(s=>s,s=>s.kind);if(typeof n=="string")return J({detail:n,kind:"config"});let t=await u({config:n,document:Cl,variables:{id:r}}).catch(()=>null);if(t==null)return J({kind:"request-failed"});if(t.run==null)return J({kind:"not-found"});if(t.run.behaviorUrl==null)return J({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return J({kind:"download-failed",status:o.status});let i=Dt.join(e,".ripplo","debug",r,"behavior.jsonl");return await yl(Dt.dirname(i),{recursive:!0}),await hl(i,xl(Buffer.from(await o.arrayBuffer()))),wl({path:i,runId:r})}var Cl=kl(`
297
+ `);async function Ft(e){let r=g(),t=(await u({config:r,document:tl,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"}
298
+ `),process.exit(1)}process.stdout.write(`${_t({id:t.id,kind:e.kind,title:e.title})}
299
+ `)}import ol from"path";import{CancellationTokenSource as il}from"vscode-jsonrpc/node";function Wt(e){return`ripplo: workspace build is stale (${e.join(", ")}) \u2014 rebuilding`}function Dt(){return"ripplo: workspace build failed \u2014 fix the build, then rerun"}function be(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 Ut({all:e,headed:r,ids:n}){let t=process.cwd(),o=process.argv[1];o==null&&L(ce({kind:"spawn-failed",message:"process.argv[1] missing"})),al();let i=await cn(t);i!=null&&L(fn(i));let a=(await an({cliEntry:o,cwd:t})).match(c=>c,c=>L(ce(c)));a.versionNote?.kind==="stale-busy"&&L(Oe(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${Oe(a.versionNote)}
300
+ `);let l=new il;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let d=ol.join(t,".ripplo","debug"),f=(await ln({connection:a,request:{all:e,headed:r,tests:[...n]},token:l.token,onEvent:c=>{let y=mn({debugDir:d,event:c});y!=null&&process.stdout.write(`${y}
301
+ `)}})).match(c=>c,c=>L(ce(c)));await sl({connection:a,result:f})}async function sl({connection:e,result:r}){await new Promise(n=>{e.socket.end(n)}),r.kind==="daemon-error"&&L(gn(r.error)),process.stdout.write(`${pn(r)}
302
+ `),r.failed>0&&process.exit(1),process.exit(r.notRun>0?2:0)}function L(e){process.stderr.write(`${e}
303
+ `),process.exit(1)}function al(){let e=ue();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=be(e);L(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Wt(e.packages)}
304
+ `),sn(e.workspaceRoot)||L(Dt())}import O from"path";import pl from"os";import{mkdtempSync as ml,rmSync as fl}from"fs";import{err as xe,ok as Je}from"neverthrow";import{z as qt}from"zod";import{readdir as ll,rm as dl,stat as ul}from"fs/promises";import{existsSync as cl}from"fs";import Ge from"path";async function ze(e,r){let t=(await ll(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||cl(Ge.join(e,s,$n)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await ul(Ge.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>dl(Ge.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var Bt=50,gl=15e3;async function Vt(){te(w());let e=process.cwd(),r=_.child({worker:process.pid}),n=Rn(),t=ml(O.join(pl.tmpdir(),"ripplo-browser-cache-")),o=se({cacheDir:t,clientVersion:w(),debugDir:O.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)},gl).unref(),hl(i).then(()=>o.close().catch(()=>{})).then(()=>{fl(t,{force:!0,recursive:!0}),process.exit(l)})};process.on("disconnect",()=>{a(1)}),process.on("unhandledRejection",l=>{r.error({err:l},"worker unhandled rejection")}),process.on("uncaughtException",l=>{r.error({err:l},"worker uncaught exception"),a(1)}),n.onRequest(bn,async(l,d)=>{let k=hn.safeParse(l);if(!k.success)return ve("bad-run-assign");let f=k.data;Q(e);let c=v(e).match(P=>P,P=>P.kind);if(typeof c=="string")return ve(`config:${c}`);let y=await Ht(n);if(y.isErr())return ve(`lockfile-unavailable:${y.error}`);let J=y.value,$=ie(J).find(P=>P.ref===f.testRef);if($==null)return ve(`no-test:${f.testRef}`);try{let{outcome:P,persisted:Ae}=await En({config:c,cwd:e,errorSettle:"settle",fixturesDir:O.join(e,X),headed:f.headed,lockfile:J,onPhase:void 0,runId:f.runId,session:o,signal:_e(d),test:$.test}),ur=O.join(e,".ripplo","debug");return s(Promise.allSettled([Ae]).then(()=>q({config:c,debugDir:ur,runId:f.runId})).then(()=>ze(ur,Bt)).catch(()=>{})),{outcome:yn(P),serverNotified:!0}}catch(P){let Ae=O.join(e,".ripplo","debug");if(s(q({config:c,debugDir:Ae,runId:f.runId}).catch(()=>{})),P instanceof cr)return{outcome:{detail:P.message,kind:"infra-error"},serverNotified:!1};throw P}}),n.onRequest(Cn,(l,d)=>wl({connection:n,cwd:e,raw:l,session:o,token:d,track:s})),n.onNotification(xn,l=>{let d=kn.safeParse(l);d.success&&o.injectSpan(d.data.runId,d.data.span)}),n.onNotification(Sn,()=>{a(0)}),n.sendNotification(wn),await new Promise(()=>{})}function ve(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var yl=5e3;async function hl(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,yl)})])}var kl=qt.object({assign:Vr,devSessionId:qt.string().nullable()});async function wl({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=kl.safeParse(n);if(!s.success)return{error:{source:"bad-assign"},kind:"error"};let{assign:a,devSessionId:l}=s.data;Q(r);let d=v(r).match($=>$,$=>$.kind);if(typeof d=="string")return{error:{detail:d,source:"config"},kind:"error"};let k=await Ht(e);if(k.isErr())return{error:{source:"lockfile-stale"},kind:"error"};let f=k.value,c=O.join(d.cwd,".ripplo","debug"),y=await In({assign:a,config:d,debugDir:c,devSessionId:l??void 0,fixturesDir:O.join(d.cwd,X),headed:!1,lockfile:f,report:!0,session:t,signal:_e(o)}),J=y.kind==="finding"&&y.runId!=null?q({config:d,debugDir:c,runId:y.runId}):Promise.resolve();return i(J.then(()=>ze(c,Bt)).catch(()=>{})),y}async function Ht(e){return(await bl(e)).andThen(n=>n.unavailable!=null?xe(n.unavailable):n.lockfileJson==null?xe("empty-reply"):vl(n.lockfileJson))}async function bl(e){try{return Je(await e.sendRequest(vn))}catch(r){return xe(`transport:${r instanceof Error?r.message:"unknown"}`)}}var Ce;function vl(e){if(Ce!==void 0&&Ce.json===e)return Je(Ce.lockfile);try{let r=Pr(D(N,e));return Ce={json:e,lockfile:r},Je(r)}catch(r){return xe(`worker-decode-failed:${r instanceof Error?r.message.slice(0,200):"unknown"}`)}}async function Kt(){await Vt()}import{existsSync as jl}from"fs";import Tl from"path";import{ok as Ml}from"neverthrow";import{gunzipSync as Cl}from"zlib";import{mkdir as xl,writeFile as Sl}from"fs/promises";import Gt from"path";import{graphql as Rl}from"gql.tada";import{err as Z,ok as Pl}from"neverthrow";var $l=31,El=139;async function Se(e,r){let n=v(e).match(s=>s,s=>s.kind);if(typeof n=="string")return Z({detail:n,kind:"config"});let t=await u({config:n,document:Il,variables:{id:r}}).catch(()=>null);if(t==null)return Z({kind:"request-failed"});if(t.run==null)return Z({kind:"not-found"});if(t.run.behaviorUrl==null)return Z({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return Z({kind:"download-failed",status:o.status});let i=Gt.join(e,".ripplo","debug",r,"behavior.jsonl");return await xl(Gt.dirname(i),{recursive:!0}),await Sl(i,Al(Buffer.from(await o.arrayBuffer()))),Pl({path:i,runId:r})}var Il=Rl(`
305
305
  query RunBehaviorUrl($id: String!) {
306
306
  run(id: $id) {
307
307
  id
308
308
  behaviorUrl
309
309
  }
310
310
  }
311
- `);function xl(e){return e[0]===bl&&e[1]===vl?gl(e):e}async function V(e,r){let n=Rl.join(e,".ripplo","debug",r,"behavior.jsonl");return Sl(n)?Pl(void 0):(await xe(e,r)).map(()=>{})}import{existsSync as qt,readFileSync as Bt}from"fs";import Vt from"path";import{err as $l,ok as El}from"neverthrow";var Ht=" \u203A ",Il=4e3,Al=5,Kt="fact ",Gt="step ",jl="data rule ";async function zt(e,r){let n=Vt.join(e,".ripplo","debug",r,"behavior.jsonl");if(!qt(n))return $l({kind:"run-not-found",runId:r});let t=Tl(Bt(n,"utf8")),o=Jl(e),i=o==null?[]:await Mr(o),s=[...t.assertions.filter(a=>a.outcome!=="passed").map(a=>Wl({assertion:a,facts:i,lockfile:o,run:t})),...t.findings.map(a=>Nl({event:a,facts:i,lockfile:o,run:t}))];return El({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,runId:r})}function Tl(e){let r=e.split(`
312
- `).filter(s=>s.trim().length>0).flatMap(s=>{let a=_(s);return a==null?[]:[a]}),n=r.filter(s=>s.kind==="assertion"),t=r.filter(s=>s.kind==="finding"),o=r.flatMap(s=>Ml(s)),i=r.map(s=>F(s.timeNanos));return{assertions:n,causes:o,findings:t,firstTs:i.length===0?0:Math.min(...i),lastTs:i.length===0?0:Math.max(...i)}}function Ml(e){let r=Ll(e);return r==null?[]:[{detail:r,timestamp:F(e.timeNanos)}]}function Ll(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 Nl({event:e,facts:r,lockfile:n,run:t}){let o=F(e.timeNanos),i=e.payload,s=i.kind==="mismatch"?"fact":"unknown",a=i.kind==="mismatch"||i.kind==="pendingCheck";return{browserMismatch:void 0,causes:Yt(t.causes,o),label:_l(i),outcome:"failed",pending:i.kind==="mismatch"?i.pending:void 0,ruleKind:s,rules:Xt({check:Jt(i),facts:r,lockfile:n,ruleKind:s,subjectKey:Ol(i)}),runWorkflow:e.step.split(Ht)[0]??e.step,snapshotAt:o,step:e.step,wait:a?i.wait:void 0,waitMs:a?i.waitMs:void 0}}function Ol(e){return e.kind==="mismatch"&&e.mismatch.kind==="scalarMismatch"?e.mismatch.subjectKey:void 0}function Jt(e){return e.kind==="mismatch"?Qt(e.mismatch):e.kind==="unrunnable"?e.reason:e.kind==="impossibleAction"?e.action:e.kind==="driverError"?e.errorKind:e.subject}function Qt(e){return e.kind==="scalarMismatch"?e.subject:e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.entity} [${e.key}]`:`${e.entity}.${e.field} [${e.key}]`}function _l(e){return e.kind==="mismatch"?Fl(e.mismatch):e.kind==="pendingCheck"&&e.expected!=null?`${e.kind} ${e.subject}: expected ${e.expected}`:e.kind==="unrunnable"&&e.unmet!=null?`${e.kind} ${e.reason}: ${e.unmet}`:`${e.kind} ${Jt(e)}`}function Fl(e){let r=Qt(e);return e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.kind} ${r}`:`${e.kind} ${r}: expected ${e.expected}, got ${e.actual}`}function Wl({assertion:e,facts:r,lockfile:n,run:t}){let o=Dl(e.label),i=F(e.timeNanos);return{browserMismatch:void 0,causes:Yt(t.causes,i),label:e.label,outcome:e.outcome==="error"?"error":"failed",pending:void 0,ruleKind:o,rules:Xt({check:Ul(e.label,o),facts:r,lockfile:n,ruleKind:o,subjectKey:void 0}),runWorkflow:e.step.split(Ht)[0]??e.step,snapshotAt:i,step:e.step,wait:e.wait,waitMs:e.waitMs}}function Dl(e){return e.startsWith(Kt)?"fact":e.startsWith(jl)?"data-rule":e.startsWith(Gt)?"step":"unknown"}function Ul(e,r){return r==="fact"?e.slice(Kt.length):r==="step"?e.slice(Gt.length):e}function Xt({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>ql({check:e,rule:i,subjectKey:o})).map(i=>({consequence:je(i.consequence),origins:Bl(i.origin,n),provenance:Kl(i.origin),url:Or(i.when),when:_r(i.when)}))}function ql({check:e,rule:r,subjectKey:n}){return n!=null?Lr(r)===n:je(r.consequence)===e}function Bl(e,r){let n=oe(r),t=Vl(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return Hl(t)}function Vl(e){return e==null?[]:e.kind==="declared"?[]:e.kind==="generalized"?Nr(e):[e.test]}function Hl(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function Kl(e){return e!=null&&e.kind==="generalized"?"learned":"inferred"}function Yt(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Il).toSorted((t,o)=>o.timestamp-t.timestamp);return Gl(n).toSorted((t,o)=>Number(Ut(o.detail))-Number(Ut(t.detail))).slice(0,Al).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function Gl(e){return e.reduce((r,n)=>{let t=zl(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function zl(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 Ut(e){return e.kind==="network"?e.status>=400:e.kind==="span"?e.statusCode==="error":!0}function Jl(e){let r=Vt.join(e,".ripplo","ripplo.lock");if(!qt(r))return null;try{return ne(W,Bt(r,"utf8"))}catch{return null}}var Zt=" \u203A ",Ql=["fact ","data rule ","step "];function no(e){if(e.failures.length===0)return`${p.good("ok")} \u2014 ${e.runId}: no failing checks.`;let r=`${e.runId} \u2014 ${R(e.failures.length,"failing check")}`,n=e.lockfileLoaded?[]:[p.dim("(no lockfile \u2014 provenance unavailable)")],t=Xl(e.failures).map(o=>Yl(o,e.runId));return[r,...n,"",...t,C("tasks")].join(`
313
- `)}function to(e){return`${p.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function Xl(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function Yl(e,r){let n=e.failures[0];if(n==null)return"";let t=Zl(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>io(s.label)))].join(", "),i=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${rd(e.step)} ${i}`,` ${p.dim("failed")} ${o}`,...nd(e),...ad(n),...ld(n.causes),` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
314
- `)}function Zl(e,r){let n=e.failures[0],t=e.failures.flatMap(d=>d.browserMismatch==null?[]:[d.browserMismatch])[0],o=oo(e.failures.flatMap(d=>d.rules));if(n==null||t==null||o.length===0)return null;let i=io(e.failures.find(d=>d.rules.length>0)?.label??n.label),s=[...new Set(o.map(d=>d.url))].join(", "),a=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${i} ${p.warn("(wrong page)")} ${a}`,` ${p.dim("rule learned for url")} ${s}`,` ${p.dim("browser was actually at")} ${t.actual}`,` ${p.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
315
- `)}function oo(e){let r=e.map(n=>[ed(n),n]);return[...new Map(r).values()]}function ed(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function io(e){let r=Ql.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function rd(e){let r=e.split(Zt);return r.length<2?e:r.slice(1).join(Zt)}function nd(e){let r=oo(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>td(n)),...sd(e,r)]}function td(e){let r=e.origins.length===0?p.dim("origin not in lockfile"):e.origins.map(n=>od(n)).join(", ");return[` ${p.dim(id(e.provenance))}`,` ${p.dim("from")} ${r}`,` ${p.dim("at")} ${e.url} ${p.dim("\u2014 holds only when")} ${e.when}`]}function od(e){if(e.sourcePath==null)return e.intent;let r=p.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function id(e){return e==="learned"?"learned \u2014 kept only the conditions these flows share":"inferred \u2014 from a flow that reaches this state"}function sd(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?[]:[` ${p.warn("\u21B3 learned from another flow \u2014 likely a fact scoped too broadly")}`]}function ad(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[` ${p.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function ld(e){if(e.length===0)return[];let r=dd(e),n=e.flatMap(t=>ud(t,r));return n.length===0?[]:[` ${p.dim("nearby")} ${n.join(" \xB7 ")}`]}function dd(e){let r=e.flatMap(n=>n.detail.kind==="span"&&n.detail.traceId!=null?[[n.detail.traceId,n.detail]]:[]);return new Map(r)}function ud(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 ${ze(t)}`;return[ro(n,`${ze(n)}${o}`)]}return[ro(n,ze(n))]}function ze(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${cd(e.url)}`:e.kind==="console"?`console.${e.level} ${eo(e.text)}`:e.kind==="error"?`error ${eo(e.message)}`:`span ${e.name} ${e.statusCode} ${String(Math.round(e.durationMs))}ms`}function cd(e){let r=e.split("?")[0]??e;return r.length>60?`\u2026${r.slice(-57)}`:r}function eo(e){let r=e.replaceAll(/\s+/g," ").trim();return r.length>100?`${r.slice(0,97)}\u2026`:r}function ro(e,r){return pd(e)?p.bad(r):r}function pd(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function so(e){return`Saved behavior.jsonl to ${e.path}`}function H(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 ao({json:e,runId:r}){let n=await V(process.cwd(),r);n.isErr()&&(process.stderr.write(`${H(n.error)}
316
- `),process.exit(1)),(await zt(process.cwd(),r)).match(o=>{let i=e?JSON.stringify(o,null,2):no(o);process.stdout.write(`${i}
317
- `)},o=>{process.stderr.write(`${to(o)}
318
- `),process.exit(1)})}async function lo({runId:e}){(await xe(process.cwd(),e)).match(n=>{process.stdout.write(`${so(n)}
319
- `)},n=>{process.stderr.write(`${H(n)}
320
- `),process.exit(1)})}import{randomUUID as md}from"crypto";import uo from"path";import{graphql as fd}from"gql.tada";import{err as Q,ok as gd}from"neverthrow";async function co(e,r,n){let t=b(e).match(f=>f,f=>f.kind);if(typeof t=="string")return Q({detail:t,kind:"config"});let o=await Rr(e);if(o.result.isErr())return Q({kind:"compile-failed"});let i=await u({config:t,document:yd,variables:{id:r}}).catch(()=>null);if(i==null)return Q({kind:"request-failed"});if(i.run==null)return Q({kind:"not-found"});if(i.run.reproJson==null)return Q({kind:"no-repro"});let s=Dr.parse(JSON.parse(i.run.reproJson)),a=await ae(e,o.result.value),l=`replay-${md()}`,d=ie({cacheDir:void 0,clientVersion:k(),debugDir:uo.join(e,".ripplo","debug"),headed:!1,writeOtlpPortFile:!1});try{let f=await Br({capture:!0,lockfile:a,options:{baseUrl:t.appUrl,engineUrl:t.engineUrl,fixturesDir:uo.join(e,G),generate:wr,headed:!1,secret:t.webhookSecret},repro:s,runId:l,session:d,signal:n});return gd({outcome:f,replayRunId:l})}finally{await d.close()}}var yd=fd(`
311
+ `);function Al(e){return e[0]===$l&&e[1]===El?Cl(e):e}async function K(e,r){let n=Tl.join(e,".ripplo","debug",r,"behavior.jsonl");return jl(n)?Ml(void 0):(await Se(e,r)).map(()=>{})}import{existsSync as Jt,readFileSync as Qt}from"fs";import Xt from"path";import{err as Ll,ok as Nl}from"neverthrow";import{z as Qe}from"zod";var Yt=" \u203A ",Ol=4e3,_l=5,Zt="fact ",eo="step ",Fl="data rule ";async function ro(e,r){let n=Xt.join(e,".ripplo","debug",r,"behavior.jsonl");if(!Jt(n))return Ll({kind:"run-not-found",runId:r});let t=Wl(Qt(n,"utf8")),o=od(e),i=o==null?[]:await Fr(o),s=[...t.assertions.filter(a=>a.outcome!=="passed").map(a=>zl({assertion:a,facts:i,lockfile:o,run:t})),...t.findings.map(a=>Vl({event:a,facts:i,lockfile:o,run:t}))];return Nl({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,runId:r,viewport:t.viewport})}function Wl(e){let r=e.split(`
312
+ `).filter(s=>s.trim().length>0).flatMap(s=>{let a=F(s);return a==null?[]:[a]}),n=r.filter(s=>s.kind==="assertion"),t=r.filter(s=>s.kind==="finding"),o=r.flatMap(s=>ql(s)),i=r.map(s=>W(s.timeNanos));return{assertions:n,causes:o,findings:t,firstTs:i.length===0?0:Math.min(...i),lastTs:i.length===0?0:Math.max(...i),viewport:Ul(r)}}var Dl=Qe.object({height:Qe.number(),width:Qe.number()});function Ul(e){return e.flatMap(r=>{if(r.kind!=="rrweb"||r.event.type!==4)return[];let n=Dl.safeParse(r.event.data);return n.success?[n.data]:[]})[0]}function ql(e){let r=Bl(e);return r==null?[]:[{detail:r,timestamp:W(e.timeNanos)}]}function Bl(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 Vl({event:e,facts:r,lockfile:n,run:t}){let o=W(e.timeNanos),i=e.payload,s=i.kind==="mismatch"?"fact":"unknown",a=i.kind==="mismatch"||i.kind==="pendingCheck";return{browserMismatch:void 0,causes:io(t.causes,o),label:Kl(i),outcome:"failed",pending:i.kind==="mismatch"?i.pending:void 0,ruleKind:s,rules:oo({check:no(i),facts:r,lockfile:n,ruleKind:s,subjectKey:Hl(i)}),runWorkflow:e.step.split(Yt)[0]??e.step,snapshotAt:o,step:e.step,wait:a?i.wait:void 0,waitMs:a?i.waitMs:void 0}}function Hl(e){return e.kind==="mismatch"&&e.mismatch.kind==="scalarMismatch"?e.mismatch.subjectKey:void 0}function no(e){return e.kind==="mismatch"?to(e.mismatch):e.kind==="unrunnable"?e.reason:e.kind==="impossibleAction"?e.action:e.kind==="driverError"?e.errorKind:e.subject}function to(e){return e.kind==="scalarMismatch"?e.subject:e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.entity} [${e.key}]`:`${e.entity}.${e.field} [${e.key}]`}function Kl(e){return e.kind==="mismatch"?Gl(e.mismatch):e.kind==="pendingCheck"&&e.expected!=null?`${e.kind} ${e.subject}: expected ${e.expected}`:e.kind==="unrunnable"&&e.unmet!=null?`${e.kind} ${e.reason}: ${e.unmet}`:`${e.kind} ${no(e)}`}function Gl(e){let r=to(e);return e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.kind} ${r}`:`${e.kind} ${r}: expected ${e.expected}, got ${e.actual}`}function zl({assertion:e,facts:r,lockfile:n,run:t}){let o=Jl(e.label),i=W(e.timeNanos);return{browserMismatch:void 0,causes:io(t.causes,i),label:e.label,outcome:e.outcome==="error"?"error":"failed",pending:void 0,ruleKind:o,rules:oo({check:Ql(e.label,o),facts:r,lockfile:n,ruleKind:o,subjectKey:void 0}),runWorkflow:e.step.split(Yt)[0]??e.step,snapshotAt:i,step:e.step,wait:e.wait,waitMs:e.waitMs}}function Jl(e){return e.startsWith(Zt)?"fact":e.startsWith(Fl)?"data-rule":e.startsWith(eo)?"step":"unknown"}function Ql(e,r){return r==="fact"?e.slice(Zt.length):r==="step"?e.slice(eo.length):e}function oo({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>Xl({check:e,rule:i,subjectKey:o})).map(i=>({consequence:Me(i.consequence),origins:Yl(i.origin,n),provenance:rd(i.origin),url:Ur(i.when),when:qr(i.when)}))}function Xl({check:e,rule:r,subjectKey:n}){return n!=null?Wr(r)===n:Me(r.consequence)===e}function Yl(e,r){let n=ie(r),t=Zl(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return ed(t)}function Zl(e){return e==null?[]:e.kind==="declared"?[]:e.kind==="generalized"?Dr(e):[e.test]}function ed(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function rd(e){return e!=null&&e.kind==="generalized"?"learned":"inferred"}function io(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Ol).toSorted((t,o)=>o.timestamp-t.timestamp);return nd(n).toSorted((t,o)=>Number(zt(o.detail))-Number(zt(t.detail))).slice(0,_l).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function nd(e){return e.reduce((r,n)=>{let t=td(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function td(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 zt(e){return e.kind==="network"?e.status>=400:e.kind==="span"?e.statusCode==="error":!0}function od(e){let r=Xt.join(e,".ripplo","ripplo.lock");if(!Jt(r))return null;try{return D(N,Qt(r,"utf8"))}catch{return null}}var so=" \u203A ",id=["fact ","data rule ","step "];function uo(e){if(e.failures.length===0)return`${p.good("ok")} \u2014 ${e.runId}: no failing checks.`;let r=e.viewport==null?"":` (viewport ${String(e.viewport.width)}\xD7${String(e.viewport.height)})`,n=`${e.runId} \u2014 ${R(e.failures.length,"failing check")}${r}`,t=e.lockfileLoaded?[]:[p.dim("(no lockfile \u2014 provenance unavailable)")],o=sd(e.failures).map(i=>ad(i,e.runId));return[n,...t,"",...o,x("tasks")].join(`
313
+ `)}function co(e){return`${p.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function sd(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function ad(e,r){let n=e.failures[0];if(n==null)return"";let t=ld(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>mo(s.label)))].join(", "),i=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${ud(e.step)} ${i}`,` ${p.dim("failed")} ${o}`,...cd(e),...yd(n),...hd(n.causes),` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
314
+ `)}function ld(e,r){let n=e.failures[0],t=e.failures.flatMap(d=>d.browserMismatch==null?[]:[d.browserMismatch])[0],o=po(e.failures.flatMap(d=>d.rules));if(n==null||t==null||o.length===0)return null;let i=mo(e.failures.find(d=>d.rules.length>0)?.label??n.label),s=[...new Set(o.map(d=>d.url))].join(", "),a=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${i} ${p.warn("(wrong page)")} ${a}`,` ${p.dim("rule learned for url")} ${s}`,` ${p.dim("browser was actually at")} ${t.actual}`,` ${p.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
315
+ `)}function po(e){let r=e.map(n=>[dd(n),n]);return[...new Map(r).values()]}function dd(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function mo(e){let r=id.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function ud(e){let r=e.split(so);return r.length<2?e:r.slice(1).join(so)}function cd(e){let r=po(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>pd(n)),...gd(e,r)]}function pd(e){let r=e.origins.length===0?p.dim("origin not in lockfile"):e.origins.map(n=>md(n)).join(", ");return[` ${p.dim(fd(e.provenance))}`,` ${p.dim("from")} ${r}`,` ${p.dim("at")} ${e.url} ${p.dim("\u2014 holds only when")} ${e.when}`]}function md(e){if(e.sourcePath==null)return e.intent;let r=p.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function fd(e){return e==="learned"?"learned \u2014 kept only the conditions these flows share":"inferred \u2014 from a flow that reaches this state"}function gd(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?[]:[` ${p.warn("\u21B3 learned from another flow \u2014 likely a fact scoped too broadly")}`]}function yd(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[` ${p.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function hd(e){if(e.length===0)return[];let r=kd(e),n=e.flatMap(t=>wd(t,r));return n.length===0?[]:[` ${p.dim("nearby")} ${n.join(" \xB7 ")}`]}function kd(e){let r=e.flatMap(n=>n.detail.kind==="span"&&n.detail.traceId!=null?[[n.detail.traceId,n.detail]]:[]);return new Map(r)}function wd(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 ${Xe(t)}`;return[lo(n,`${Xe(n)}${o}`)]}return[lo(n,Xe(n))]}function Xe(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${bd(e.url)}`:e.kind==="console"?`console.${e.level} ${ao(e.text)}`:e.kind==="error"?`error ${ao(e.message)}`:`span ${e.name} ${e.statusCode} ${String(Math.round(e.durationMs))}ms`}function bd(e){let r=e.split("?")[0]??e;return r.length>60?`\u2026${r.slice(-57)}`:r}function ao(e){let r=e.replaceAll(/\s+/g," ").trim();return r.length>100?`${r.slice(0,97)}\u2026`:r}function lo(e,r){return vd(e)?p.bad(r):r}function vd(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function fo(e){return`Saved behavior.jsonl to ${e.path}`}function G(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 go({json:e,runId:r}){let n=await K(process.cwd(),r);n.isErr()&&(process.stderr.write(`${G(n.error)}
316
+ `),process.exit(1)),(await ro(process.cwd(),r)).match(o=>{let i=e?JSON.stringify(o,null,2):uo(o);process.stdout.write(`${i}
317
+ `)},o=>{process.stderr.write(`${co(o)}
318
+ `),process.exit(1)})}async function yo({runId:e}){(await Se(process.cwd(),e)).match(n=>{process.stdout.write(`${fo(n)}
319
+ `)},n=>{process.stderr.write(`${G(n)}
320
+ `),process.exit(1)})}import{randomUUID as Cd}from"crypto";import{existsSync as xd,readFileSync as Sd}from"fs";import Ye from"path";import{graphql as ko}from"gql.tada";import{err as z,ok as ho}from"neverthrow";async function wo(e,r,n){let t=v(e).match(y=>y,y=>y.kind);if(typeof t=="string")return z({detail:t,kind:"config"});let o=await jr(e);if(o.result.isErr())return z({kind:"compile-failed"});let i=await u({config:t,document:$d,variables:{id:r}}).catch(()=>null);if(i==null)return z({kind:"request-failed"});if(i.run==null)return z({kind:"not-found"});let s=i.run.reproJson;if(s==null)return z({kind:"no-repro"});let a=Hr.parse(JSON.parse(s)),l=await le(e,o.result.value),d=`replay-${Cd()}`,k=Ye.join(e,".ripplo","debug"),f=[],c=se({cacheDir:void 0,clientVersion:w(),debugDir:k,headed:!1,writeOtlpPortFile:!1});try{let y=await zr({capture:!0,lockfile:l,options:{baseUrl:t.appUrl,engineUrl:t.engineUrl,fixturesDir:Ye.join(e,X),generate:Sr,headed:!1,secret:t.webhookSecret},repro:a,runId:d,session:c,signal:n,onEvent:$=>{f.push($)}});return(await Rd({config:t,debugDir:k,events:f,outcome:y,replayRunId:d,reproJson:s,stepSources:a.steps.map($=>$.test)})).map(()=>({outcome:y,recordingCaptured:Pd(k,d),replayRunId:d}))}finally{await c.close()}}async function Rd({config:e,debugDir:r,events:n,outcome:t,replayRunId:o,reproJson:i,stepSources:s}){if(t.kind!=="resolved"&&t.kind!=="still-fails")return ho(void 0);try{return await u({config:e,document:Ed,variables:{projectId:e.projectId,reproJson:i,runId:o}}),await Pn({config:e,debugDir:r,events:n,recordingOptional:!0,runId:o,stepSources:s}),await q({config:e,debugDir:r,runId:o}),ho(void 0)}catch{return z({kind:"report-failed"})}}function Pd(e,r){let n=Ye.join(e,r,"behavior.jsonl");return xd(n)?Sd(n,"utf8").split(`
321
+ `).some(t=>t.includes('"kind":"rrweb"')):!1}var $d=ko(`
321
322
  query RunRepro($id: String!) {
322
323
  run(id: $id) {
323
324
  id
324
325
  reproJson
325
326
  }
326
327
  }
327
- `);function po({outcome:e,replayRunId:r}){let n=hd(e);return e.kind!=="resolved"&&e.kind!=="still-fails"?n:`${n}
328
- Replay run ${r} \u2014 snapshot it, e.g. \`npx ripplo snapshot ${r} --offset <ms>\`.`}function hd(e){switch(e.kind){case"resolved":return"\u2713 Resolved \u2014 the finding's trail ran clean.";case"still-fails":return`\u2717 Still failing \u2014 ${R(e.findings.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 mo(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."}}function fo(e){return e.kind==="resolved"}async function go({runId:e}){(await co(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${po(n)}
329
- `),process.exit(fo(n.outcome)?0:1)},n=>{process.stderr.write(`${mo(n)}
330
- `),process.exit(1)})}import Eo from"path";import{existsSync as $d}from"fs";import{writeFile as Ro}from"fs/promises";import Po from"path";import{err as Y,ok as Ed}from"neverthrow";import{createRequire as kd}from"module";import{readFile as ho}from"fs/promises";import{fileURLToPath as wd}from"url";import{z as X}from"zod";var bd={height:800,width:1280};async function ko(e){let r=await ho(e,"utf8");return vd(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}function vd(e){return e.split(`
331
- `).filter(r=>r.length>0).flatMap(r=>{let n=_(r);return n==null?[]:[n]})}var Cd=X.object({data:X.looseObject({height:X.number(),width:X.number()}),type:X.literal(4)});function wo(e){let r=e.flatMap(n=>{let t=Cd.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?bd:{height:r.data.height,width:r.data.width}}var xd='<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>',Sd=`.replayer-mouse-tail { display: none; }
328
+ `),Ed=ko(`
329
+ mutation CreateReplayRun($projectId: String!, $runId: String!, $reproJson: String) {
330
+ createExploreRun(projectId: $projectId, runId: $runId, reproJson: $reproJson) {
331
+ id
332
+ }
333
+ }
334
+ `);function bo({outcome:e,recordingCaptured:r,replayRunId:n}){let t=Id(e);return e.kind!=="resolved"&&e.kind!=="still-fails"?t:`${t}${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`."}
335
+ Replay run ${n} \u2014 snapshot it, or cite it as resolve proof: \`npx ripplo tasks resolve <id> --run ${n}\`.`}function Id(e){switch(e.kind){case"resolved":return"\u2713 Resolved \u2014 the finding's trail ran clean.";case"still-fails":return`\u2717 Still failing \u2014 ${R(e.findings.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 vo(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`."}}function Co(e){return e.kind==="resolved"}async function xo({runId:e}){(await wo(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${bo(n)}
336
+ `),process.exit(Co(n.outcome)?0:1)},n=>{process.stderr.write(`${vo(n)}
337
+ `),process.exit(1)})}import No from"path";import{existsSync as Wd}from"fs";import{writeFile as To}from"fs/promises";import Mo from"path";import{err as re,ok as Dd}from"neverthrow";import{createRequire as Ad}from"module";import{readFile as Ro}from"fs/promises";import{fileURLToPath as jd}from"url";import{z as ee}from"zod";var Td={height:800,width:1280};async function Po(e){let r=await Ro(e,"utf8");return Md(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}function Md(e){return e.split(`
338
+ `).filter(r=>r.length>0).flatMap(r=>{let n=F(r);return n==null?[]:[n]})}var Ld=ee.object({data:ee.looseObject({height:ee.number(),width:ee.number()}),type:ee.literal(4)});function Ze(e){let r=e.flatMap(n=>{let t=Ld.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?Td:{height:r.data.height,width:r.data.width}}var Nd='<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>',Od=`.replayer-mouse-tail { display: none; }
332
339
  .replayer-mouse {
333
340
  position: absolute;
334
341
  width: 17px;
@@ -336,28 +343,28 @@ Replay run ${r} \u2014 snapshot it, e.g. \`npx ripplo snapshot ${r} --offset <ms
336
343
  z-index: 9999;
337
344
  background-repeat: no-repeat;
338
345
  background-size: contain;
339
- background-image: url('data:image/svg+xml;utf8,${xd}');
340
- }`,Rd=".replayer-mouse, .replayer-mouse-tail { display: none; }";function bo(e){return`<!doctype html><html><head><style>
346
+ background-image: url('data:image/svg+xml;utf8,${Nd}');
347
+ }`,_d=".replayer-mouse, .replayer-mouse-tail { display: none; }";function $o(e){return`<!doctype html><html><head><style>
341
348
  html, body { margin: 0; padding: 0; }
342
349
  .replayer-wrapper { position: relative; }
343
- ${e?Sd:Rd}
350
+ ${e?Od:_d}
344
351
  iframe { border: none; }
345
- </style></head><body></body></html>`}var vo="*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }";function Co(){return`(async () => {
352
+ </style></head><body></body></html>`}var Eo="*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }";function Io(){return`(async () => {
346
353
  const doc = document.querySelector(".replayer-wrapper iframe")?.contentDocument;
347
354
  if (doc?.fonts != null) {
348
355
  await doc.fonts.ready;
349
356
  }
350
357
  await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
351
- })()`}function xo(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var yo;function So(){return yo??=ho(Pd(),"utf8"),yo}function Pd(){let e=kd(import.meta.url);try{return e.resolve("@ripplo/rrweb-bundle/replay")}catch{return wd(new URL("assets/rrweb-replay.js",import.meta.url))}}async function $o({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!$d(e))return Y({kind:"run-not-found",runId:t});let o=await ko(e),i=o[0],s=o.at(-1);if(i==null||s==null)return Y({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 Y({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let d=Math.min(l,a),f=String(Math.round(d)),y=Po.join(n,`snapshot-${f}ms.png`),c=Po.join(n,`snapshot-${f}ms.html`);return(await Id({events:o,htmlPath:c,offsetMs:d,pngPath:y})).map(()=>({durationMs:a,htmlPath:c,offsetMs:d,pngPath:y}))}async function Id({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await xo();if(o==null)return Y({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await Ad({browser:o,events:e,offsetMs:n});return await Ro(t,s),await Ro(r,i,"utf8"),Ed(void 0)}catch(i){return Y({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function Ad({browser:e,events:r,offsetMs:n}){let t=wo(r),o=await e.newPage({viewport:t});await o.setContent(bo(!1)),await o.addScriptTag({content:await So()}),await o.evaluate(jd({events:r,offsetMs:n})),await o.evaluate(Co());let i=o.locator(".replayer-wrapper iframe").first(),a=await(await i.count()>0?i:o).screenshot({type:"png"});return{html:await o.evaluate(Td()),png:a}}function jd({events:e,offsetMs:r}){return`(() => {
358
+ })()`}function Ao(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var So;function jo(){return So??=Ro(Fd(),"utf8"),So}function Fd(){let e=Ad(import.meta.url);try{return e.resolve("@ripplo/rrweb-bundle/replay")}catch{return jd(new URL("assets/rrweb-replay.js",import.meta.url))}}async function Lo({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!Wd(e))return re({kind:"run-not-found",runId:t});let o=await Po(e),i=o[0],s=o.at(-1);if(i==null||s==null)return re({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 re({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let d=Math.min(l,a),k=String(Math.round(d)),f=Mo.join(n,`snapshot-${k}ms.png`),c=Mo.join(n,`snapshot-${k}ms.html`);return(await Ud({events:o,htmlPath:c,offsetMs:d,pngPath:f})).map(()=>({durationMs:a,htmlPath:c,offsetMs:d,pngPath:f,viewport:Ze(o)}))}async function Ud({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await Ao();if(o==null)return re({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await qd({browser:o,events:e,offsetMs:n});return await To(t,s),await To(r,i,"utf8"),Dd(void 0)}catch(i){return re({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function qd({browser:e,events:r,offsetMs:n}){let t=Ze(r),o=await e.newPage({viewport:t});await o.setContent($o(!1)),await o.addScriptTag({content:await jo()}),await o.evaluate(Bd({events:r,offsetMs:n})),await o.evaluate(Io());let i=o.locator(".replayer-wrapper iframe").first(),a=await(await i.count()>0?i:o).screenshot({type:"png"});return{html:await o.evaluate(Vd()),png:a}}function Bd({events:e,offsetMs:r}){return`(() => {
352
359
  const replayer = new globalThis.__RipploReplayer(${JSON.stringify(e)}, {
353
- insertStyleRules: [${JSON.stringify(vo)}],
360
+ insertStyleRules: [${JSON.stringify(Eo)}],
354
361
  mouseTail: false,
355
362
  root: document.body,
356
363
  showWarning: false,
357
364
  });
358
365
  replayer.pause(${String(r+.5)});
359
366
  globalThis.__ripploSnapshotReplayer = replayer;
360
- })()`}function Td(){return`(() => {
367
+ })()`}function Vd(){return`(() => {
361
368
  const replayer = globalThis.__ripploSnapshotReplayer;
362
369
  if (replayer == null) {
363
370
  return "";
@@ -375,43 +382,43 @@ iframe { border: none; }
375
382
  }
376
383
  });
377
384
  return "<!doctype html>\\n" + doc.documentElement.outerHTML;
378
- })()`}function Io({cwd:e,moment:r,runId:n}){let t=Eo.join(e,".ripplo","debug",n);return $o({jsonlPath:Eo.join(t,"behavior.jsonl"),moment:r,outDir:t,runId:n})}function Ao(e){return[`${p.good("ok")} \u2014 rendered the page at ${String(Math.round(e.offsetMs))}ms into the recording (duration ${String(Math.round(e.durationMs))}ms)`,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(`
379
- `)}function jo(e){return`${p.bad("fail")} \u2014 ${Md(e)}`}function To(){return`${p.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function Md(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 Mo({at:e,offset:r,runId:n}){let t=Ld({at:e,offset:r});t==null&&(process.stderr.write(`${To()}
380
- `),process.exit(1));let o=await V(process.cwd(),n);o.isErr()&&(process.stderr.write(`${H(o.error)}
381
- `),process.exit(1)),(await Io({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${Ao(s)}
382
- `)},s=>{process.stderr.write(`${jo(s)}
383
- `),process.exit(1)})}function Ld({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 Lo(e,r){switch(e.kind){case"config-failed":return w(e.failure);case"compile-failed":return D(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: ${Tr(e.error)}`;case"done":return Nd(e.result,r)}}function No(e){return e.kind==="done"&&e.result.kind==="handed-over"}function Oo(e,r){return`landed at step ${String(e)} of ${r} \u2014 close the window to tear down`}function Nd(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
385
+ })()`}function Oo({cwd:e,moment:r,runId:n}){let t=No.join(e,".ripplo","debug",n);return Lo({jsonlPath:No.join(t,"behavior.jsonl"),moment:r,outDir:t,runId:n})}function _o(e){return[`${p.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(`
386
+ `)}function Fo(e){return`${p.bad("fail")} \u2014 ${Hd(e)}`}function Wo(){return`${p.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function Hd(e){switch(e.kind){case"run-not-found":return`no debug artifacts for run ${e.runId} (.ripplo/debug/${e.runId}/behavior.jsonl missing). ${x("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 Do({at:e,offset:r,runId:n}){let t=Kd({at:e,offset:r});t==null&&(process.stderr.write(`${Wo()}
387
+ `),process.exit(1));let o=await K(process.cwd(),n);o.isErr()&&(process.stderr.write(`${G(o.error)}
388
+ `),process.exit(1)),(await Oo({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${_o(s)}
389
+ `)},s=>{process.stderr.write(`${Fo(s)}
390
+ `),process.exit(1)})}function Kd({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 Uo(e,r){switch(e.kind){case"config-failed":return b(e.failure);case"compile-failed":return U(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: ${_r(e.error)}`;case"done":return Gd(e.result,r)}}function qo(e){return e.kind==="done"&&e.result.kind==="handed-over"}function Bo(e,r){return`landed at step ${String(e)} of ${r} \u2014 close the window to tear down`}function Gd(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
384
391
 
385
- ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
392
+ ${e.findings.map(t=>Br({evidencePath:void 0,finding:t})).join(`
386
393
 
387
- `)}`:`torn down \u2014 teleport session for ${r} ended`}async function _o({ref:e,step:r}){let n=new AbortController;process.once("SIGINT",()=>{n.abort()});let t=()=>{process.stdout.write(`${Oo(r,e)}
388
- `)},o=await Sn({cwd:process.cwd(),onReady:t,signal:n.signal,step:r,target:{kind:"test",ref:e}});process.stdout.write(`${Lo(o,e)}
389
- `),process.exit(No(o)?0:1)}import Fo from"path";import{randomUUID as Od}from"crypto";async function Wo({cwd:e,onReady:r,signal:n}){let t=b(e).match(s=>s,s=>s.kind);if(typeof t=="string")return{detail:t,kind:"config-failed"};let o=`capture-${Od()}`;return(await Ur({clientVersion:k(),debugDir:Fo.join(t.cwd,".ripplo","debug"),onReady:r,profileDir:Fo.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 Do(){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 Uo(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.":_d(e.behaviorPath,e.runId)}function qo(e){return e.kind==="done"}function _d(e,r){return[`Capture saved to ${e}`,"","Paste this to Claude Code to turn it into a workflow:",""," Reconstruct a real user session into a Ripplo workflow under .ripplo/workflows/.","",` 1. Run \`npx ripplo clickpath ${r}\` \u2014 the resolved, ordered list of user actions (clicks and inputs, each already mapped to its element with role, name, and testId). This is the exact action sequence. Encode every action as a workflow step in order, using a role+name or testId locator.`,` 2. Read ${e} for the network requests (with bodies) and backend spans. Model every entity and state the session reads or writes: declare entities in .ripplo/entities, build the starting state in given, and assert the resulting state in expect. The spans and request/response bodies are the source of truth for what state existed and what changed.`," 3. Run npx ripplo compile. Flag any action, entity, or state you cannot express in the DSL \u2014 those are gaps in the model worth reporting."].join(`
390
- `)}async function Bo(){let e=new AbortController;process.once("SIGINT",()=>{e.abort()});let r=await Wo({cwd:process.cwd(),onReady:Fd,signal:e.signal});process.stdout.write(`${Uo(r)}
391
- `),process.exit(qo(r)?0:1)}function Fd(){process.stdout.write(`${Do()}
392
- `)}import{existsSync as Wd,readFileSync as Dd}from"fs";import Ud from"path";function Vo(e,r){let n=Ud.join(e,".ripplo","debug",r,"behavior.jsonl");return Wd(n)?{actions:qr(Dd(n,{encoding:"utf8"})),kind:"ok"}:{kind:"not-found",runId:r}}function Ho(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)=>qd(r,n)).join(`
393
- `)}function Ko(e){return e.kind==="ok"}function qd(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 Go({runId:e}){let r=Vo(process.cwd(),e);process.stdout.write(`${Ho(r)}
394
- `),process.exit(Ko(r)?0:1)}async function zo(){let e=g();try{let n=(await z(e.cwd,e)).match(i=>i,i=>{process.stderr.write(`${w(i)}
394
+ `)}`:`torn down \u2014 teleport session for ${r} ended`}async function Vo({ref:e,step:r}){let n=new AbortController;process.once("SIGINT",()=>{n.abort()});let t=()=>{process.stdout.write(`${Bo(r,e)}
395
+ `)},o=await An({cwd:process.cwd(),onReady:t,signal:n.signal,step:r,target:{kind:"test",ref:e}});process.stdout.write(`${Uo(o,e)}
396
+ `),process.exit(qo(o)?0:1)}import Ho from"path";import{randomUUID as zd}from"crypto";async function Ko({cwd:e,onReady:r,signal:n}){let t=v(e).match(s=>s,s=>s.kind);if(typeof t=="string")return{detail:t,kind:"config-failed"};let o=`capture-${zd()}`;return(await Kr({clientVersion:w(),debugDir:Ho.join(t.cwd,".ripplo","debug"),onReady:r,profileDir:Ho.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 Go(){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 zo(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.":Jd(e.behaviorPath,e.runId)}function Jo(e){return e.kind==="done"}function Jd(e,r){return[`Capture saved to ${e}`,"","Paste this to Claude Code to turn it into a workflow:",""," Reconstruct a real user session into a Ripplo workflow under .ripplo/workflows/.","",` 1. Run \`npx ripplo clickpath ${r}\` \u2014 the resolved, ordered list of user actions (clicks and inputs, each already mapped to its element with role, name, and testId). This is the exact action sequence. Encode every action as a workflow step in order, using a role+name or testId locator.`,` 2. Read ${e} for the network requests (with bodies) and backend spans. Model every entity and state the session reads or writes: declare entities in .ripplo/entities, build the starting state in given, and assert the resulting state in expect. The spans and request/response bodies are the source of truth for what state existed and what changed.`," 3. Run npx ripplo compile. Flag any action, entity, or state you cannot express in the DSL \u2014 those are gaps in the model worth reporting."].join(`
397
+ `)}async function Qo(){let e=new AbortController;process.once("SIGINT",()=>{e.abort()});let r=await Ko({cwd:process.cwd(),onReady:Qd,signal:e.signal});process.stdout.write(`${zo(r)}
398
+ `),process.exit(Jo(r)?0:1)}function Qd(){process.stdout.write(`${Go()}
399
+ `)}import{existsSync as Xd,readFileSync as Yd}from"fs";import Zd from"path";function Xo(e,r){let n=Zd.join(e,".ripplo","debug",r,"behavior.jsonl");return Xd(n)?{actions:Gr(Yd(n,{encoding:"utf8"})),kind:"ok"}:{kind:"not-found",runId:r}}function Yo(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)=>eu(r,n)).join(`
400
+ `)}function Zo(e){return e.kind==="ok"}function eu(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 ei({runId:e}){let r=Xo(process.cwd(),e);process.stdout.write(`${Yo(r)}
401
+ `),process.exit(Zo(r)?0:1)}async function ri(){let e=g();try{let n=(await Y(e.cwd,e)).match(i=>i,i=>{process.stderr.write(`${b(i)}
395
402
  `),process.exit(1)}),t=n.lockfile.workflows.length,o=n.lockfile.entities.length;process.stdout.write(`Synced ${R(t,"workflow")} and ${R(o,"entity","entities")} to dev session ${n.devSessionId}
396
403
  `)}catch(r){let n=r instanceof Error?r.message:String(r);process.stderr.write(`ripplo sync failed: ${n}
397
- `),process.stderr.write(`${C("setup","verify auth + server reachability")}
398
- `),process.exit(1)}}import{spawnSync as Hd}from"child_process";import Kd from"fs";import Gd from"path";import zd from"semver";import Se from"fs";import Bd from"os";import Z from"path";function Jo(e){return e.split(Z.sep).includes("_npx")?"npx":e.includes(Z.join("packages","cli"))?"workspace":"global"}function Qo(){let e=Z.join(Bd.homedir(),".npm","_npx");return Se.existsSync(e)?Se.readdirSync(e).map(r=>Z.join(e,r)).filter(r=>Se.existsSync(Z.join(r,"node_modules","ripplo"))).map(r=>(Se.rmSync(r,{force:!0,recursive:!0}),r)):[]}import{spawnSync as Xo}from"child_process";var Vd=["user","project","local"];function Je(){return Xo("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":Vd.find(n=>Xo("claude",["plugin","update","ripplo","--scope",n],{stdio:"ignore"}).status===0)==null?"not-installed":"updated"}function Yo(e){return`ripplo v${e} is already the latest version.`}function Zo(e){return`ripplo v${e}: could not reach the npm registry to check for updates.`}function Qe({evicted:e,latest:r,mode:n}){return n==="npx"?`ripplo: ${e===0?"npx cache had no stale copy":`cleared ${R(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 ei(){return"ripplo: this is a workspace build (packages/cli/dist) \u2014 update via git pull + `pnpm --filter ripplo build`."}function ri(e){return`ripplo: \`npm install -g ripplo@latest\` failed: ${e}`}function Xe(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 Jd=1e4;async function ti(){let e=k(),r=process.argv[1];Qd(process.cwd());let n=await me(Jd);process.stdout.write(`${pe({current:e,latest:n})}
399
- `),n==null&&(process.stderr.write(`${Zo(e)}
400
- `),process.exit(1)),zd.gt(n,e)||(process.stdout.write(`${Yo(e)}
401
- `),process.stdout.write(`${Xe(Je())}
402
- `),process.exit(0));let t=r==null?"global":Jo(r);Xd({latest:n,mode:t}),process.stdout.write(`${Xe(Je())}
403
- `),await Zd(process.cwd()),process.exit(0)}function Qd(e){if(!Kd.existsSync(Gd.join(e,".ripplo")))return;let r=ye(e);r==="written"&&process.stdout.write(`${he(r).trim()}
404
- `)}function Xd({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${ei()}
405
- `),process.exit(0)),r==="npx"){let n=Qo();process.stdout.write(`${Qe({evicted:n.length,latest:e,mode:r})}
406
- `);return}Yd(e)}function Yd(e){let r=`ripplo@${e}`,n=Hd("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${ri(t)}
407
- `),process.exit(1)}process.stdout.write(`${Qe({evicted:0,latest:e,mode:"global"})}
408
- `)}async function Zd(e){if((await on(e)).kind==="not-running")return;let n=await tn(e);process.stdout.write(`${ni(n)}
409
- `)}async function oi({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-UBUNHH5O.js");await n({format:"summary"});return}if(e==="stop"||e==="restart"){let n=await eu();(e==="stop"||!n)&&process.exit(n?0:1)}ru();let{runDaemon:r}=await import("./daemon-EGU25OUV.js");await r()}async function eu(){let{stopDevDaemon:e}=await import("./daemon-lock-LTQMLU4Q.js"),{renderDaemonStopResult:r}=await import("./daemon-LFFCR3TB.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
410
- `),n.kind!=="timeout"}function ru(){let e=we(de());e!=null&&process.stderr.write(`${e}
411
- `)}function ii(e){return`executor: ${e}`}function si(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 ai(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 li({mode:e}){let r=b(process.cwd()).match(t=>t,t=>{process.stderr.write(`${w(t)}
412
- `),process.exit(1)});(e==null?await Pn(r):await $n(r,e)).match(t=>{process.stdout.write(`${e==null?ii(t):si(t)}
413
- `)},t=>{process.stderr.write(`${ai(t)}
414
- `),process.exit(1)})}import{graphql as ui}from"gql.tada";import{err as Ye,ok as Ze}from"neverthrow";var tu=ui(`
404
+ `),process.stderr.write(`${x("setup","verify auth + server reachability")}
405
+ `),process.exit(1)}}import{spawnSync as tu}from"child_process";import ou from"fs";import iu from"path";import su from"semver";import Re from"fs";import ru from"os";import ne from"path";function ni(e){return e.split(ne.sep).includes("_npx")?"npx":e.includes(ne.join("packages","cli"))?"workspace":"global"}function ti(){let e=ne.join(ru.homedir(),".npm","_npx");return Re.existsSync(e)?Re.readdirSync(e).map(r=>ne.join(e,r)).filter(r=>Re.existsSync(ne.join(r,"node_modules","ripplo"))).map(r=>(Re.rmSync(r,{force:!0,recursive:!0}),r)):[]}import{spawnSync as oi}from"child_process";var nu=["user","project","local"];function er(){return oi("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":nu.find(n=>oi("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 si(e){return`ripplo v${e}: could not reach the npm registry to check for updates.`}function rr({evicted:e,latest:r,mode:n}){return n==="npx"?`ripplo: ${e===0?"npx cache had no stale copy":`cleared ${R(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 ai(){return"ripplo: this is a workspace build (packages/cli/dist) \u2014 update via git pull + `pnpm --filter ripplo build`."}function li(e){return`ripplo: \`npm install -g ripplo@latest\` failed: ${e}`}function nr(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 di(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 au=1e4;async function ui(){let e=w(),r=process.argv[1];lu(process.cwd());let n=await fe(au);process.stdout.write(`${pe({current:e,latest:n})}
406
+ `),n==null&&(process.stderr.write(`${si(e)}
407
+ `),process.exit(1)),su.gt(n,e)||(process.stdout.write(`${ii(e)}
408
+ `),process.stdout.write(`${nr(er())}
409
+ `),process.exit(0));let t=r==null?"global":ni(r);du({latest:n,mode:t}),process.stdout.write(`${nr(er())}
410
+ `),await cu(process.cwd()),process.exit(0)}function lu(e){if(!ou.existsSync(iu.join(e,".ripplo")))return;let r=he(e);r==="written"&&process.stdout.write(`${ke(r).trim()}
411
+ `)}function du({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${ai()}
412
+ `),process.exit(0)),r==="npx"){let n=ti();process.stdout.write(`${rr({evicted:n.length,latest:e,mode:r})}
413
+ `);return}uu(e)}function uu(e){let r=`ripplo@${e}`,n=tu("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${li(t)}
414
+ `),process.exit(1)}process.stdout.write(`${rr({evicted:0,latest:e,mode:"global"})}
415
+ `)}async function cu(e){if((await un(e)).kind==="not-running")return;let n=await dn(e);process.stdout.write(`${di(n)}
416
+ `)}async function ci({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-66XIDYSP.js");await n({format:"summary"});return}if(e==="stop"||e==="restart"){let n=await pu();(e==="stop"||!n)&&process.exit(n?0:1)}mu();let{runDaemon:r}=await import("./daemon-YPXZGJAB.js");await r()}async function pu(){let{stopDevDaemon:e}=await import("./daemon-lock-LTQMLU4Q.js"),{renderDaemonStopResult:r}=await import("./daemon-MZWLJO75.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
417
+ `),n.kind!=="timeout"}function mu(){let e=be(ue());e!=null&&process.stderr.write(`${e}
418
+ `)}function pi(e){return`executor: ${e}`}function mi(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 fi(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 gi({mode:e}){let r=v(process.cwd()).match(t=>t,t=>{process.stderr.write(`${b(t)}
419
+ `),process.exit(1)});(e==null?await Mn(r):await Ln(r,e)).match(t=>{process.stdout.write(`${e==null?pi(t):mi(t)}
420
+ `)},t=>{process.stderr.write(`${fi(t)}
421
+ `),process.exit(1)})}import{graphql as yi}from"gql.tada";import{err as tr,ok as or}from"neverthrow";var fu=yi(`
415
422
  query ExploreState($devSessionId: String!) {
416
423
  exploration(devSessionId: $devSessionId) {
417
424
  active
@@ -420,7 +427,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
420
427
  maxTrailLength
421
428
  }
422
429
  }
423
- `),ou=ui(`
430
+ `),gu=yi(`
424
431
  mutation SetExploration(
425
432
  $devSessionId: String!
426
433
  $active: Boolean!
@@ -441,11 +448,11 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
441
448
  maxTrailLength
442
449
  }
443
450
  }
444
- `);async function ci(e){let r=await mi(e);if(r.isErr())return Ye(r.error);let n=await fi(e,r.value.id);return Ze(gi(r.value.executor,n))}async function pi(e,r){let n=await mi(e);if(n.isErr())return Ye(n.error);let t=await fi(e,n.value.id),o=iu(n.value.executor,t,r),i=await u({config:e,document:ou,variables:{devSessionId:n.value.id,...o}});return Ze(gi(n.value.executor,i.setExploration))}async function mi(e){let r=await Jr(e);return r.kind==="active"?Ze({executor:r.executor,id:r.id}):Ye({kind:r.kind==="starting"?"starting":"no-session"})}async function fi(e,r){return(await u({config:e,document:tu,variables:{devSessionId:r}})).exploration??null}function gi(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??12,workers:(n?r?.localWorkers:r?.cloudWorkers)??0}}function iu(e,r,n){let t=e==="local",o=(t?r?.localWorkers:r?.cloudWorkers)??0,i=(t?r?.cloudWorkers:r?.localWorkers)??0,s=su(n,o);return{active:n.active,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??12}}function su(e,r){return e.active?e.workers!=null?e.workers:r>0?r:2:r}function yi(e){return e.active?`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`:"explorer: off"}function hi(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 ki(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."}async function wi({state:e,trail:r,workers:n}){let t=b(process.cwd()).match(i=>i,i=>{process.stderr.write(`${w(i)}
445
- `),process.exit(1)});(e==null?await ci(t):await pi(t,{active:e==="on",trail:r,workers:n})).match(i=>{process.stdout.write(`${e==null?yi(i):hi(i)}
446
- `)},i=>{process.stderr.write(`${ki(i)}
447
- `),process.exit(1)})}import{graphql as Re}from"gql.tada";function bi(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function vi(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 au}from"gql.tada";var Ci=au(`
451
+ `);async function hi(e){let r=await wi(e);if(r.isErr())return tr(r.error);let n=await bi(e,r.value.id);return or(vi(r.value.executor,n))}async function ki(e,r){let n=await wi(e);if(n.isErr())return tr(n.error);let t=await bi(e,n.value.id),o=yu(n.value.executor,t,r),i=await u({config:e,document:gu,variables:{devSessionId:n.value.id,...o}});return or(vi(n.value.executor,i.setExploration))}async function wi(e){let r=await en(e);return r.kind==="active"?or({executor:r.executor,id:r.id}):tr({kind:r.kind==="starting"?"starting":"no-session"})}async function bi(e,r){return(await u({config:e,document:fu,variables:{devSessionId:r}})).exploration??null}function vi(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??Fe,workers:(n?r?.localWorkers:r?.cloudWorkers)??0}}function yu(e,r,n){let t=e==="local",o=(t?r?.localWorkers:r?.cloudWorkers)??0,i=(t?r?.cloudWorkers:r?.localWorkers)??0,s=hu(n,o);return{active:n.active,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??Fe}}function hu(e,r){return e.active?e.workers!=null?e.workers:r>0?r:Tn:r}function Ci(e){return e.active?`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`:"explorer: off"}function xi(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 Si(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."}async function Ri({state:e,trail:r,workers:n}){let t=v(process.cwd()).match(i=>i,i=>{process.stderr.write(`${b(i)}
452
+ `),process.exit(1)});(e==null?await hi(t):await ki(t,{active:e==="on",trail:r,workers:n})).match(i=>{process.stdout.write(`${e==null?Ci(i):xi(i)}
453
+ `)},i=>{process.stderr.write(`${Si(i)}
454
+ `),process.exit(1)})}import{graphql as Pe}from"gql.tada";function Pi(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function $i(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`.",x("create")].join(`
455
+ `)}import{graphql as ku}from"gql.tada";var Ei=ku(`
449
456
  query ScopeStatus($projectId: String!, $cwd: String!) {
450
457
  project(id: $projectId) {
451
458
  id
@@ -465,7 +472,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
465
472
  }
466
473
  }
467
474
  }
468
- `);var lu=Re(`
475
+ `);var wu=Pe(`
469
476
  query ScopeWorkflowBySlug($projectId: String!, $cwd: String!, $slug: String!) {
470
477
  project(id: $projectId) {
471
478
  id
@@ -478,7 +485,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
478
485
  }
479
486
  }
480
487
  }
481
- `),du=Re(`
488
+ `),bu=Pe(`
482
489
  mutation ScopeAddDirtyTests($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
483
490
  addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
484
491
  __typename
@@ -500,31 +507,31 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
500
507
  }
501
508
  }
502
509
  }
503
- `),uu=Re(`
510
+ `),vu=Pe(`
504
511
  mutation ScopeLink($id: ID!, $workflowId: String!) {
505
512
  linkScopeItem(id: $id, workflowId: $workflowId) {
506
513
  id
507
514
  }
508
515
  }
509
- `),cu=Re(`
516
+ `),Cu=Pe(`
510
517
  mutation ScopeRemoveMany($ids: [ID!]!) {
511
518
  removeScopeItems(ids: $ids)
512
519
  }
513
- `);async function xi(e){let r=g();await v(r);let t=(await u({config:r,document:Ci,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
520
+ `);async function Ii(e){let r=g();await C(r);let t=(await u({config:r,document:Ei,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
514
521
  `);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
522
  `);return}let s=i.spec==null?"stub":"implemented";process.stdout.write(` [${s}] (${o.id}) ${i.slug} \u2014 ${i.name}
516
- `)})}async function Si({testIds:e}){let r=g();await v(r),(await z(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${w(a)}
517
- `),process.exit(1)});let o=(await u({config:r,document:du,variables:{cwd:r.cwd,projectId:r.projectId,workflowSlugs:e.map(a=>Cr(a))}})).addDirtyTestsToScope;o?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${o.message}
518
- `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${vi(o.slugs)}
519
- `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${bi()}
523
+ `)})}async function Ai({testIds:e}){let r=g();await C(r),(await Y(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${b(a)}
524
+ `),process.exit(1)});let o=(await u({config:r,document:bu,variables:{cwd:r.cwd,projectId:r.projectId,workflowSlugs:e.map(a=>$r(a))}})).addDirtyTestsToScope;o?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${o.message}
525
+ `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${$i(o.slugs)}
526
+ `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${Pi()}
520
527
  `);return}let s=i.map(a=>a.workflow?.slug??"?").join(", ");process.stdout.write(`Added ${R(i.length,"scope item")}: ${s}
521
- `)}async function Ri({id:e,testId:r}){let n=g();await v(n),(await z(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${w(i)}
522
- `),process.exit(1)});let o=await pu({cfg:n,slug:r});await u({config:n,document:uu,variables:{id:e,workflowId:o}}),process.stdout.write(`Linked scope item ${e} to ${r}
523
- `)}async function Pi({ids:e}){let r=g();await v(r);let t=(await u({config:r,document:cu,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${R(t,"scope item")}
524
- `)}async function pu({cfg:e,slug:r}){let t=(await u({config:e,document:lu,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 A}from"gql.tada";import{print as _i}from"graphql";import{createClient as Fi}from"graphql-sse";import er from"fs";import mu from"path";import{err as Pe,ok as fu}from"neverthrow";function Ei({cwd:e,rrwebId:r,runId:n}){let t=Ai(e,n);if(!er.existsSync(t))return Pe({kind:"no-behavior"});let o=Li(Mi(t,r));if(o==null)return Pe({kind:"not-found"});let i=nr(o.node.type);return i===3?Pe({kind:"text-node",parentId:nr(o.parent?.id)}):i!==2?Pe({kind:"non-element",nodeType:i??-1}):fu({tagName:E(o.node.tagName)})}function Ii({cwd:e,rrwebId:r,runId:n}){let t=Mi(Ai(e,n),r);if(t==null)return null;let o=Li(t);return o==null||nr(o.node.type)!==2?null:gu(t)}function Ai(e,r){return mu.join(e,".ripplo","debug",r,"behavior.jsonl")}function gu(e){let r=e.at(-1)??{},n=tr(r.attributes)??{},t=E(r.tagName);return{ariaName:E(n["aria-label"]),role:E(n.role),selector:hu(e),tagName:t==null?null:t.toLowerCase(),testId:E(n["data-testid"]),text:Cu(vu(r))}}var yu=6;function hu(e){let r=ji(e,e.length-1,yu);return r.length===0?null:r.join(" > ")}function ji(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=ku(t);if(o!=null)return[o];let i=wu(t,e[r-1]);return r===0||n===1?[i]:[...ji(e,r-1,n-1),i]}function ku(e){let r=tr(e.attributes)??{},n=E(r["data-testid"]);if(n!=null)return`[data-testid="${n}"]`;let t=E(r.id);return t!=null&&t.length>0?`#${t}`:null}function wu(e,r){let n=(E(e.tagName)??"*").toLowerCase(),t=Ti(r).filter(i=>(E(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 Ti(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>$e(n)):[]}function Mi(e,r){return er.existsSync(e)?er.readFileSync(e,"utf8").split(`
527
- `).reduce((t,o)=>t!=null||o.length===0?t:bu(o,r),null):null}function bu(e,r){let n=_(e);if(n?.kind!=="rrweb")return null;let t=tr(n.event.data),o=rr(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??($e(a)?rr(a.node,r):null),null):null}function rr(e,r){if(!$e(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??rr(i,r),null);return t==null?null:[e,...t]}function Li(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var $i=80;function vu(e){let r=Ti(e).filter(n=>n.type===3).map(n=>E(n.textContent)).filter(n=>n!=null);return r.length===0?null:r.join(" ")}function E(e){return typeof e=="string"?e:null}function Cu(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>$i?`${r.slice(0,$i)}\u2026`:r}function tr(e){return $e(e)?e:void 0}function $e(e){return typeof e=="object"&&e!=null}function nr(e){return typeof e=="number"?e:null}function or(e,r){let n=r.flatMap(o=>xu(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function xu(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 Su=A(`
528
+ `)}async function ji({id:e,testId:r}){let n=g();await C(n),(await Y(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${b(i)}
529
+ `),process.exit(1)});let o=await xu({cfg:n,slug:r});await u({config:n,document:vu,variables:{id:e,workflowId:o}}),process.stdout.write(`Linked scope item ${e} to ${r}
530
+ `)}async function Ti({ids:e}){let r=g();await C(r);let t=(await u({config:r,document:Cu,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${R(t,"scope item")}
531
+ `)}async function xu({cfg:e,slug:r}){let t=(await u({config:e,document:wu,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.
532
+ `),process.stderr.write(`${x("create")}
533
+ `),process.exit(1)),t.id}import{graphql as j}from"gql.tada";import{print as Bi}from"graphql";import{createClient as Vi}from"graphql-sse";import ir from"fs";import Su from"path";import{err as $e,ok as Ru}from"neverthrow";function Li({cwd:e,rrwebId:r,runId:n}){let t=Oi(e,n);if(!ir.existsSync(t))return $e({kind:"no-behavior"});let o=Di(Wi(t,r));if(o==null)return $e({kind:"not-found"});let i=ar(o.node.type);return i===3?$e({kind:"text-node",parentId:ar(o.parent?.id)}):i!==2?$e({kind:"non-element",nodeType:i??-1}):Ru({tagName:I(o.node.tagName)})}function Ni({cwd:e,rrwebId:r,runId:n}){let t=Wi(Oi(e,n),r);if(t==null)return null;let o=Di(t);return o==null||ar(o.node.type)!==2?null:Pu(t)}function Oi(e,r){return Su.join(e,".ripplo","debug",r,"behavior.jsonl")}function Pu(e){let r=e.at(-1)??{},n=lr(r.attributes)??{},t=I(r.tagName);return{ariaName:I(n["aria-label"]),role:I(n.role),selector:Eu(e),tagName:t==null?null:t.toLowerCase(),testId:I(n["data-testid"]),text:Mu(Tu(r))}}var $u=6;function Eu(e){let r=_i(e,e.length-1,$u);return r.length===0?null:r.join(" > ")}function _i(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=Iu(t);if(o!=null)return[o];let i=Au(t,e[r-1]);return r===0||n===1?[i]:[..._i(e,r-1,n-1),i]}function Iu(e){let r=lr(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 Au(e,r){let n=(I(e.tagName)??"*").toLowerCase(),t=Fi(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 Fi(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>Ee(n)):[]}function Wi(e,r){return ir.existsSync(e)?ir.readFileSync(e,"utf8").split(`
534
+ `).reduce((t,o)=>t!=null||o.length===0?t:ju(o,r),null):null}function ju(e,r){let n=F(e);if(n?.kind!=="rrweb")return null;let t=lr(n.event.data),o=sr(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??(Ee(a)?sr(a.node,r):null),null):null}function sr(e,r){if(!Ee(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??sr(i,r),null);return t==null?null:[e,...t]}function Di(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var Mi=80;function Tu(e){let r=Fi(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 Mu(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>Mi?`${r.slice(0,Mi)}\u2026`:r}function lr(e){return Ee(e)?e:void 0}function Ee(e){return typeof e=="object"&&e!=null}function ar(e){return typeof e=="number"?e:null}function dr(e,r){let n=r.flatMap(o=>Lu(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function Lu(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 Nu=j(`
528
535
  query WorkList($projectId: String!, $cwd: String!) {
529
536
  project(id: $projectId) {
530
537
  id
@@ -542,7 +549,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
542
549
  }
543
550
  }
544
551
  }
545
- `),Ru=A(`
552
+ `),Ou=j(`
546
553
  query WatchSeed($projectId: String!, $cwd: String!) {
547
554
  project(id: $projectId) {
548
555
  id
@@ -562,7 +569,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
562
569
  }
563
570
  }
564
571
  }
565
- `),Wi=A(`
572
+ `),Hi=j(`
566
573
  subscription WatchTasks($devSessionId: String!) {
567
574
  tasksChanged(devSessionId: $devSessionId) {
568
575
  devSession {
@@ -581,7 +588,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
581
588
  }
582
589
  }
583
590
  }
584
- `),Pu=A(`
591
+ `),_u=j(`
585
592
  query WorkShow($id: String!) {
586
593
  task(id: $id) {
587
594
  id
@@ -598,7 +605,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
598
605
  }
599
606
  }
600
607
  }
601
- `),$u=A(`
608
+ `),Fu=j(`
602
609
  mutation WorkComment(
603
610
  $taskId: String!
604
611
  $body: String!
@@ -624,7 +631,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
624
631
  }
625
632
  }
626
633
  }
627
- `),Eu=A(`
634
+ `),Wu=j(`
628
635
  mutation WorkResolve($taskId: String!, $runId: String!, $note: String, $authorName: String) {
629
636
  agentResolveTask(taskId: $taskId, runId: $runId, note: $note, authorName: $authorName) {
630
637
  __typename
@@ -636,7 +643,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
636
643
  }
637
644
  }
638
645
  }
639
- `),Iu=A(`
646
+ `),Du=j(`
640
647
  mutation WorkStart($taskId: String!) {
641
648
  agentStartTask(taskId: $taskId) {
642
649
  __typename
@@ -649,7 +656,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
649
656
  }
650
657
  }
651
658
  }
652
- `),Au=A(`
659
+ `),Uu=j(`
653
660
  mutation WorkClarify($taskId: String!, $body: String!, $authorName: String) {
654
661
  agentSetNeedsClarification(taskId: $taskId, body: $body, authorName: $authorName) {
655
662
  __typename
@@ -661,7 +668,7 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
661
668
  }
662
669
  }
663
670
  }
664
- `),ju=A(`
671
+ `),qu=j(`
665
672
  mutation WorkDismiss($taskId: String!, $note: String, $authorName: String) {
666
673
  agentDismissTask(taskId: $taskId, note: $note, authorName: $authorName) {
667
674
  __typename
@@ -676,21 +683,21 @@ ${e.findings.map(t=>Fr({evidencePath:void 0,finding:t})).join(`
676
683
  }
677
684
  }
678
685
  }
679
- `),Tu=18e4;async function Di(e){let r=g();await v(r);let n=await Ni(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await Mu({cfg:r,devSessionId:n.devSessionId});let o=await Ni(r);Oi(o.items,e.format);return}Oi(n.items,e.format)}async function Ni(e){let n=(await u({config:e,document:Su,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return{devSessionId:n?.id??null,items:n?.tasks??[]}}function Oi(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(`${En(n)}
681
- `)}function Mu({cfg:e,devSessionId:r}){let n=Fi({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,Tu),o.dispose=n.subscribe({query:_i(Wi),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function Ui(){let e=g();await v(e);let n=(await u({config:e,document:Ru,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=or(new Map,Bi(n.tasks??[])),o=Fi({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});Lu({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function Lu({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:_i(Wi),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=or(t,Bi(i));s.changes.forEach(a=>{process.stdout.write(`${An(a)}
683
- `)}),t=s.seen}})}async function qi(e){let r=g();await v(r);let t=(await u({config:r,document:Pu,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${jn(e.id)}
686
+ `),Bu=18e4;async function Ki(e){let r=g();await C(r);let n=await Ui(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await Vu({cfg:r,devSessionId:n.devSessionId});let o=await Ui(r);qi(o.items,e.format);return}qi(n.items,e.format)}async function Ui(e){let n=(await u({config:e,document:Nu,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return{devSessionId:n?.id??null,items:n?.tasks??[]}}function qi(e,r){if(r==="json"){process.stdout.write(`${JSON.stringify(e,null,2)}
687
+ `);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(`${Nn(n)}
688
+ `)}function Vu({cfg:e,devSessionId:r}){let n=Vi({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,Bu),o.dispose=n.subscribe({query:Bi(Hi),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function Gi(){let e=g();await C(e);let n=(await u({config:e,document:Ou,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=dr(new Map,Ji(n.tasks??[])),o=Vi({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});Hu({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function Hu({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:Bi(Hi),variables:{devSessionId:e}},{complete:()=>{},error:o=>{process.stderr.write(`task watch error: ${String(o)}
689
+ `)},next:o=>{let i=o.data?.tasksChanged?.devSession?.tasks??[],s=dr(t,Ji(i));s.changes.forEach(a=>{process.stdout.write(`${_n(a)}
690
+ `)}),t=s.seen}})}async function zi(e){let r=g();await C(r);let t=(await u({config:r,document:_u,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${Fn(e.id)}
684
691
  `),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=>V(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:Ii({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(`${In(i)}
686
- `)}function Bi(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 Vi(e){let r=g();if(await v(r),e.elementId!=null&&e.runId!=null){let t=Ei({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${Nu(t,e.elementId,e.runId)}
687
- `),process.exit(1))}let n=await u({config:r,document:$u,variables:{authorName:e.authorName??null,body:e.body,frameMs:e.offsetMs??null,rrwebId:e.elementId??null,runId:e.runId??null,taskId:e.id}});Ee(n.agentCommentOnTask),process.stdout.write(`${Tn(e.id)}
688
- `)}async function Hi(e){let r=g();await v(r);let n=await u({config:r,document:Eu,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});Ee(n.agentResolveTask),process.stdout.write(`${_n(e.id)}
689
- `)}async function Ki(e){let r=g();await v(r);let n=await u({config:r,document:Iu,variables:{taskId:e.id}});Ee(n.agentStartTask),process.stdout.write(`${Fn(e.id)}
690
- `)}async function Gi(e){e.body.trim().length===0&&(process.stderr.write(`${Mn()}
691
- `),process.exit(1));let r=g();await v(r);let n=await u({config:r,document:Au,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});Ee(n.agentSetNeedsClarification),process.stdout.write(`${Wn(e.id)}
692
- `)}async function zi(e){let r=g();await v(r);let t=(await u({config:r,document:ju,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(`${Dn(e.id)}
694
- `)}function Ee(e){e?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${e.message}
695
- `),process.exit(1))}function Nu(e,r,n){return e.kind==="text-node"?Ln(r,e.parentId):e.kind==="not-found"?Nn(r,n):On(r)}function Ji(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=>Di({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,()=>Ui()).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=>qi({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=>Vi({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=>Ki({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=>Hi({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=>Gi({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=>zi({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}gr();K(process.cwd());pr();async function Du(){re(k()),xr({size:Math.max(1,Math.min(10,Ou()-2)),workerUrl:Vn()}),_u({pkg:{name:"ripplo",version:k()}}).notify({message:Hn()}),await Fu(Wu(process.argv)).scriptName("ripplo").version(k()).command(qu()).command(Bu()).command(Vu()).command(Yu()).command("auth <subcommand>","Manage authentication",oc).command("projects <subcommand>","List or create Ripplo projects",tc).command("hooks <subcommand>","Pause or resume Ripplo hooks",nc).command(Gu()).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=>vt({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`)",ec,e=>Lt({all:e.all,headed:e.headed,ids:e.ids})).command(Ju()).command(Zu()).command(Qu()).command(Xu()).command(Uu()).command(zu()).command(Hu()).command(Ku()).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>zo()).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=>Zn({check:e.check})).command("update","Update ripplo to the latest published version (and hand the daemon off to it)",()=>{},()=>ti()).command("doctor","Check project health",()=>{},()=>dt()).command("status","Report stub tests and daemon status",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>Rn({format:e.format})).command("scope <subcommand>","Manage testing scope",rc).command("tasks <subcommand>","Manage tasks for this dev session",Ji).command("run-worker",!1,()=>{},()=>Wt()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(Un),demandOption:!0,type:"string"}),e=>qn(e.name)).strict().help().parse(),Sr()}Du().catch(e=>{process.stderr.write(`${Ir(e)}
696
- `),process.exit(1)});function Uu(){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=>jt({kind:e.kind,rootCause:e["root-cause"],runId:e.run,surfacedBy:e["surfaced-by"],title:e.title})}}function qu(){return{command:"daemon [action]",describe:"Run the long-lived local executor (IPC socket + run subscription)",builder:e=>e.positional("action",{choices:["start","stop","restart","status"],default:"start",describe:"Lifecycle action for this project's daemon"}),handler:e=>oi({action:e.action})}}function Bu(){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=>li({mode:e.mode})}}function Vu(){return{command:"explore [state]",describe:"Show or toggle the background explorer for the active dev session",builder:e=>e.positional("state",{choices:["on","off"],describe:"Turn the explorer on or off (omit to show current state)"}).option("trail",{describe:"Max steps per explored path",type:"number"}).option("workers",{describe:"Concurrent explorer workers",type:"number"}),handler:e=>wi({state:e.state,trail:e.trail,workers:e.workers})}}function Hu(){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"}),handler:e=>ao({json:e.json,runId:e.runId})}}function Ku(){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=>go({runId:e.runId})}}function Gu(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{It()}}}function zu(){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=>lo({runId:e.runId})}}function Ju(){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=>Mo({at:e.at,offset:e.offset,runId:e.runId})}}function Qu(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>Bo()}}function Xu(){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=>{Go({runId:e.runId})}}}function Yu(){return{command:"concurrency [value]",describe:"Show or set max local concurrent runs (daemon applies live)",builder:e=>e.positional("value",{type:"number"}),handler:e=>rt({value:e.value})}}function Zu(){return{command:"teleport <ref>",describe:"Open a live browser at a step in a test, seeded with the run up to that point",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=>_o({ref:e.ref,step:e.step})}}function ec(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 rc(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>xi({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=>Si({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=>Ri({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=>Pi({ids:r.ids})).demandCommand(1)}function nc(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>ut()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>ct()).demandCommand(1)}function tc(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>St()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>Rt({name:r.name,orgId:r.org})).demandCommand(1)}function oc(e){return e.command("login","Authenticate via device flow",()=>{},()=>Qn()).command("status","Show authentication status",()=>{},()=>Xn()).command("logout","Remove the saved token",()=>{},()=>{Yn()}).demandCommand(1)}export{Du as main};
692
+ `);return}let o=[...new Set((t.messages??[]).flatMap(s=>s.runId==null?[]:[s.runId]))];await Promise.all(o.map(s=>K(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:Ni({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(`${On(i)}
693
+ `)}function Ji(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 Qi(e){let r=g();if(await C(r),e.elementId!=null&&e.runId!=null){let t=Li({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${Ku(t,e.elementId,e.runId)}
694
+ `),process.exit(1))}let n=await u({config:r,document:Fu,variables:{authorName:e.authorName??null,body:e.body,frameMs:e.offsetMs??null,rrwebId:e.elementId??null,runId:e.runId??null,taskId:e.id}});Ie(n.agentCommentOnTask),process.stdout.write(`${Wn(e.id)}
695
+ `)}async function Xi(e){let r=g();await C(r);let n=await u({config:r,document:Wu,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});Ie(n.agentResolveTask),process.stdout.write(`${Vn(e.id)}
696
+ `)}async function Yi(e){let r=g();await C(r);let n=await u({config:r,document:Du,variables:{taskId:e.id}});Ie(n.agentStartTask),process.stdout.write(`${Hn(e.id)}
697
+ `)}async function Zi(e){e.body.trim().length===0&&(process.stderr.write(`${Dn()}
698
+ `),process.exit(1));let r=g();await C(r);let n=await u({config:r,document:Uu,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});Ie(n.agentSetNeedsClarification),process.stdout.write(`${Kn(e.id)}
699
+ `)}async function es(e){let r=g();await C(r);let t=(await u({config:r,document:qu,variables:{authorName:e.authorName??null,note:e.note??null,taskId:e.id}})).agentDismissTask;(t?.__typename==="FindingNotDismissableError"||t?.__typename==="NoActiveDevSessionError")&&(process.stderr.write(`${t.message}
700
+ `),process.exit(1)),process.stdout.write(`${Gn(e.id)}
701
+ `)}function Ie(e){e?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${e.message}
702
+ `),process.exit(1))}function Ku(e,r,n){return e.kind==="text-node"?Un(r,e.parentId):e.kind==="not-found"?qn(r,n):Bn(r)}function rs(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=>Ki({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,()=>Gi()).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=>zi({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=>Qi({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=>Yi({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=>Xi({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=>Zi({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=>es({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}br();Q(process.cwd());hr();async function Xu(){te(w()),Er({size:Math.max(1,Math.min(10,Gu()-2)),workerUrl:Xn()}),zu({pkg:{name:"ripplo",version:w()}}).notify({message:Yn()}),await Ju(Qu(process.argv)).scriptName("ripplo").version(w()).command(Zu()).command(ec()).command(rc()).command(dc()).command("auth <subcommand>","Manage authentication",gc).command("projects <subcommand>","List or create Ripplo projects",fc).command("hooks <subcommand>","Pause or resume Ripplo hooks",mc).command(oc()).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=>Et({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`)",cc,e=>Ut({all:e.all,headed:e.headed,ids:e.ids})).command(sc()).command(uc()).command(ac()).command(lc()).command(Yu()).command(ic()).command(nc()).command(tc()).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=>st({check:e.check})).command("update","Update ripplo to the latest published version (and hand the daemon off to it)",()=>{},()=>ui()).command("doctor","Check project health",()=>{},()=>yt()).command("status","Report stub tests and daemon status",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>jn({format:e.format})).command("scope <subcommand>","Manage testing scope",pc).command("tasks <subcommand>","Manage tasks for this dev session",rs).command("run-worker",!1,()=>{},()=>Kt()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(zn),demandOption:!0,type:"string"}),e=>Jn(e.name)).strict().help().parse(),Ir()}Xu().catch(e=>{process.stderr.write(`${Lr(e)}
703
+ `),process.exit(1)});function Yu(){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=>Ft({kind:e.kind,rootCause:e["root-cause"],runId:e.run,surfacedBy:e["surfaced-by"],title:e.title})}}function Zu(){return{command:"daemon [action]",describe:"Run the long-lived local executor (IPC socket + run subscription)",builder:e=>e.positional("action",{choices:["start","stop","restart","status"],default:"start",describe:"Lifecycle action for this project's daemon"}),handler:e=>ci({action:e.action})}}function ec(){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=>gi({mode:e.mode})}}function rc(){return{command:"explore [state]",describe:"Show or toggle the background explorer for the active dev session",builder:e=>e.positional("state",{choices:["on","off"],describe:"Turn the explorer on or off (omit to show current state)"}).option("trail",{describe:"Max steps per explored path",type:"number"}).option("workers",{describe:"Concurrent explorer workers",type:"number"}),handler:e=>Ri({state:e.state,trail:e.trail,workers:e.workers})}}function nc(){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"}),handler:e=>go({json:e.json,runId:e.runId})}}function tc(){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=>xo({runId:e.runId})}}function oc(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{Ot()}}}function ic(){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=>yo({runId:e.runId})}}function sc(){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=>Do({at:e.at,offset:e.offset,runId:e.runId})}}function ac(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>Qo()}}function lc(){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=>{ei({runId:e.runId})}}}function dc(){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 uc(){return{command:"teleport <ref>",describe:"Open a live browser at a step in a test, seeded with the run up to that point",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=>Vo({ref:e.ref,step:e.step})}}function cc(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 pc(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>Ii({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=>Ai({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=>ji({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=>Ti({ids:r.ids})).demandCommand(1)}function mc(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>ht()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>kt()).demandCommand(1)}function fc(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>jt()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>Tt({name:r.name,orgId:r.org})).demandCommand(1)}function gc(e){return e.command("login","Authenticate via device flow",()=>{},()=>tt()).command("status","Show authentication status",()=>{},()=>ot()).command("logout","Remove the saved token",()=>{},()=>{it()}).demandCommand(1)}export{Xu as main};