ripplo 0.9.3 → 0.9.5

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 (61) hide show
  1. package/dist/{chunk-T4GHICK4.js → chunk-2A6KSSUD.js} +1 -1
  2. package/dist/{chunk-4W6WIT7T.js → chunk-3M2E253R.js} +1 -1
  3. package/dist/{chunk-XWUIRXMS.js → chunk-3OI2UH3H.js} +1 -1
  4. package/dist/{chunk-I2M24U3N.js → chunk-3PF5QK56.js} +1 -1
  5. package/dist/chunk-52IE2PAQ.js +48 -0
  6. package/dist/{chunk-L7GWKDGD.js → chunk-6FU7HD6D.js} +1 -1
  7. package/dist/{chunk-2TO6W5BR.js → chunk-74ZADYZC.js} +2 -2
  8. package/dist/{chunk-PPMW4GUY.js → chunk-77DJHICC.js} +1 -1
  9. package/dist/{chunk-WZBLSDNV.js → chunk-B6OQ2JE2.js} +1 -1
  10. package/dist/{chunk-4H7EIC6W.js → chunk-CUXFU3MF.js} +1 -1
  11. package/dist/{chunk-TBCRT6EC.js → chunk-ESTPIODD.js} +1 -1
  12. package/dist/{chunk-I5BHCICM.js → chunk-GAOLASGV.js} +1 -1
  13. package/dist/{chunk-ZQHKESUR.js → chunk-GYH4P7SC.js} +1 -1
  14. package/dist/{chunk-ELECJABM.js → chunk-IA7TU3WW.js} +1 -1
  15. package/dist/{chunk-RAN55ZC6.js → chunk-IDPYM454.js} +1 -1
  16. package/dist/{chunk-DBIXYJRB.js → chunk-INURHJF4.js} +1 -1
  17. package/dist/{chunk-727NNPVM.js → chunk-JIMLVUPS.js} +14 -14
  18. package/dist/{chunk-SBDRIIVW.js → chunk-JNLHZVZJ.js} +2 -2
  19. package/dist/{chunk-LEFXRK53.js → chunk-KQWFJRIP.js} +1 -1
  20. package/dist/{chunk-T5VLZ43M.js → chunk-N45RSC6N.js} +1 -1
  21. package/dist/{chunk-PLQGRHHV.js → chunk-NBSDY7QG.js} +1 -1
  22. package/dist/{chunk-ONNK7JT4.js → chunk-NJFCO7FT.js} +1 -1
  23. package/dist/{chunk-OIJBIBIN.js → chunk-PPB7QGV2.js} +1 -1
  24. package/dist/{chunk-G3UFH3WS.js → chunk-QIXJ7Z2L.js} +1 -1
  25. package/dist/{chunk-ZNUC2RLT.js → chunk-T46B2OPT.js} +1 -1
  26. package/dist/{chunk-BLH6XVEC.js → chunk-TRQDCBKV.js} +1 -1
  27. package/dist/{chunk-66LUQG5T.js → chunk-VXJACUXK.js} +1 -1
  28. package/dist/{chunk-ML7WCYPY.js → chunk-XBN6AJVQ.js} +1 -1
  29. package/dist/{chunk-2ZOIED3H.js → chunk-ZYDCN5K2.js} +1 -1
  30. package/dist/{cli-error-TM2YODR3.js → cli-error-MEC67EVT.js} +1 -1
  31. package/dist/{compile-write-TTEHFTNY.js → compile-write-F7D273JN.js} +1 -1
  32. package/dist/{daemon-M52H2YF7.js → daemon-3CCSJNDP.js} +14 -14
  33. package/dist/{daemon-6B4OSRBS.js → daemon-QRMX6RPX.js} +1 -1
  34. package/dist/{daemon-lock-LTQMLU4Q.js → daemon-lock-67AFXXED.js} +1 -1
  35. package/dist/{dsl-loader-Z54ZM7C6.js → dsl-loader-A2EMKCRL.js} +1 -1
  36. package/dist/{exit-plan-gate-BNAUL4FC.js → exit-plan-gate-WPHQII5J.js} +1 -1
  37. package/dist/hook.js +1 -1
  38. package/dist/index.js +198 -188
  39. package/dist/{plan-reminder-2ABA3SFH.js → plan-reminder-6E4CHEAZ.js} +1 -1
  40. package/dist/post-edit-VHZDDVV5.js +4 -0
  41. package/dist/post-edit-analyze-YAVEMK4O.js +4 -0
  42. package/dist/post-edit-flag-stubs-PMMITC7F.js +4 -0
  43. package/dist/{pre-bash-run-gate-PWLARIYK.js → pre-bash-run-gate-WOGQZARU.js} +1 -1
  44. package/dist/pre-edit-R77BLLLQ.js +4 -0
  45. package/dist/{pre-edit-ripplo-skill-gate-JD4BDCA3.js → pre-edit-ripplo-skill-gate-FXNQWVME.js} +1 -1
  46. package/dist/{pre-edit-scope-gate-NZO4HVGT.js → pre-edit-scope-gate-ADO3NRVS.js} +1 -1
  47. package/dist/{pre-edit-watch-gate-MR7YQGEV.js → pre-edit-watch-gate-6MMET2NZ.js} +1 -1
  48. package/dist/{prompt-submit-AMSKMHWO.js → prompt-submit-WMYBXZQN.js} +1 -1
  49. package/dist/scope-reminder-XTXZHPLU.js +4 -0
  50. package/dist/solve-worker.js +1 -1
  51. package/dist/status-PUV7KG33.js +4 -0
  52. package/dist/{stop-enforce-P6YWEHWE.js → stop-enforce-56SKN4RO.js} +1 -1
  53. package/dist/{tasks-reminder-VKRJRDNC.js → tasks-reminder-PICFLMC2.js} +1 -1
  54. package/package.json +3 -3
  55. package/dist/chunk-PE5WVWI5.js +0 -48
  56. package/dist/post-edit-XBVQBSKV.js +0 -4
  57. package/dist/post-edit-analyze-KDA7T37Z.js +0 -4
  58. package/dist/post-edit-flag-stubs-SX2Y7OHG.js +0 -4
  59. package/dist/pre-edit-FTNMDZZO.js +0 -4
  60. package/dist/scope-reminder-CBY4I5SG.js +0 -4
  61. package/dist/status-2IFILDIA.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 gn,c as yn,d as hn,e as kn,f as wn,g as me}from"./chunk-RAN55ZC6.js";import{a as Wn,b as Dn,d as Un,e as Bn,f as qn,g as Vn,h as Hn,i as Kn,j as Gn,k as zn,l as Jn,m as Qn,n as Xn}from"./chunk-5E62BCS7.js";import{a as Nn}from"./chunk-BLH6XVEC.js";import{b as cn,c as pn,d as mn,f as fn}from"./chunk-4H7EIC6W.js";import{A as V,C as Tn,G as Mn,H as Ln,K as On,L as De,N as Fn,O as _n,a as on,b as sn,c as an,d as ln,e as Oe,f as dn,g as vn,h as Sn,j as Cn,k as xn,l as Rn,m as $n,n as En,o as Pn,q as In,w as We,y as An,z as jn}from"./chunk-727NNPVM.js";import{b as un,c as q}from"./chunk-WZBLSDNV.js";import{a as rn}from"./chunk-MOI4L3EX.js";import{a as ue,b as nn,c as pe,d as tn}from"./chunk-TBCRT6EC.js";import{a as R}from"./chunk-OQ6KNYPG.js";import{b as Z}from"./chunk-OIJBIBIN.js";import{a as x,b as Wr,c as h}from"./chunk-LEFXRK53.js";import{a as Dr}from"./chunk-7WZ3VIUU.js";import{e as Fe}from"./chunk-4W6WIT7T.js";import{a as Cr,b as Yn,c as Zn}from"./chunk-2TO6W5BR.js";import{a as b}from"./chunk-R4ZTRVDQ.js";import{b as xr,c as X,d as Rr,e as $r}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as _r,b as v}from"./chunk-G3UFH3WS.js";import{a as U,b as Or,c as Le,d as Fr}from"./chunk-PLQGRHHV.js";import{a as C}from"./chunk-MHNGR6M7.js";import{e as Zr,g as ce,j as en}from"./chunk-ZQHKESUR.js";import{b as Lr,e as Y,h as D,j as Nr,k as se}from"./chunk-ML7WCYPY.js";import"./chunk-DBIXYJRB.js";import{a as fr,b as gr,c as yr,d,f as W,h as hr,j as P,k as kr,l as wr,m as Me,n as br,o as vr,p as Sr}from"./chunk-PE5WVWI5.js";import{a as ie}from"./chunk-CJUKILIO.js";import{k as _e,l as bn}from"./chunk-T4GHICK4.js";import{C as Kr,D as Gr,I as zr,J as le,M as Jr,Q as Qr,T as de,U as Xr,X as Yr,b as B,f as ae,g as c,h as Ur,i as Br,n as Ne,o as qr,r as Vr,s as Hr}from"./chunk-PPMW4GUY.js";import{K as Ir,L,R as A,S as Ar,X as jr,aa as Tr,ba as Mr,i as Er,r as M,s as F,v as Pr}from"./chunk-SBDRIIVW.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{availableParallelism as Ec}from"os";import{existsSync as et}from"fs";function rt(){let e=new URL("solve-worker.js",import.meta.url);if(et(e))return e;let r=new URL("../dist/solve-worker.js",import.meta.url);if(et(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 Pc from"update-notifier";import Ic from"yargs";import{hideBin as Ac}from"yargs/helpers";function fe({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 nt(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as ws}from"gql.tada";import{exec as us}from"child_process";import{createAuthClient as ls}from"better-auth/client";import{deviceAuthorizationClient as ds}from"better-auth/client/plugins";function tt({baseURL:e}){return ls({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[ds()]})}import{err as ot,ok as cs}from"neverthrow";var ps=5e3,it="ripplo-cli";async function st({onDeviceCode:e,url:r}){let n=r??Wr().RIPPLO_SERVER_URL,t=tt({baseURL:n}),o=await t.device.code({client_id:it});if(o.error!=null)return ot({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}),ks(a),(await ms({authClient:t,deviceCode:i})).map(u=>(kr({serverUrl:n,token:u}),u))}async function ms({authClient:e,deviceCode:r}){for(;;){await ys(ps);let n=await e.device.token({client_id:it,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return cs(n.data.access_token);if(n.error==null)continue;if(!gs(n.error.error))return ot({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var fs=new Set(["authorization_pending","slow_down"]);function gs(e){return fs.has(e)}function ys(e){return new Promise(r=>{setTimeout(r,e)})}function hs(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function ks(e){let r=hs();us(`${r} "${e}"`,()=>{})}function j({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var bs=ws(`
4
+ import{a as yn,c as hn,d as kn,e as wn,f as bn,g as me}from"./chunk-IDPYM454.js";import{a as Un,b as Bn,d as qn,e as Vn,f as Hn,g as Kn,h as Gn,i as zn,j as Jn,k as Qn,l as Xn,m as Yn,n as Zn}from"./chunk-5E62BCS7.js";import{a as Fn}from"./chunk-TRQDCBKV.js";import{b as pn,c as mn,d as fn,f as gn}from"./chunk-CUXFU3MF.js";import{B as Ln,F as Nn,G as On,J as _n,K as De,M as Wn,N as Dn,a as sn,b as an,c as ln,d as dn,e as Oe,f as un,g as Sn,h as Cn,j as xn,k as Rn,l as $n,m as En,n as Pn,o as In,q as An,w as We,y as Mn,z as K}from"./chunk-JIMLVUPS.js";import{b as cn,c as H}from"./chunk-B6OQ2JE2.js";import{a as nn}from"./chunk-MOI4L3EX.js";import{a as ue,b as tn,c as pe,d as on}from"./chunk-ESTPIODD.js";import{a as $}from"./chunk-OQ6KNYPG.js";import{b as Z,c as jn,e as Tn}from"./chunk-PPB7QGV2.js";import{a as R,b as Dr,c as y}from"./chunk-KQWFJRIP.js";import{a as Ur}from"./chunk-7WZ3VIUU.js";import{e as Fe}from"./chunk-3M2E253R.js";import{a as xr,b as et,c as rt}from"./chunk-74ZADYZC.js";import{a as w}from"./chunk-R4ZTRVDQ.js";import{b as Rr,c as X,d as $r,e as Er}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as Wr,b}from"./chunk-QIXJ7Z2L.js";import{a as q,b as Fr,c as Le,d as _r}from"./chunk-NBSDY7QG.js";import{a as x}from"./chunk-MHNGR6M7.js";import{e as en,g as ce,j as rn}from"./chunk-GYH4P7SC.js";import{b as Nr,e as Y,h as B,j as Or,k as se}from"./chunk-XBN6AJVQ.js";import"./chunk-INURHJF4.js";import{a as fr,b as gr,c as yr,d,f as U,g as hr,i as kr,k as P,l as wr,m as br,n as Me,o as vr,p as Sr,q as Cr}from"./chunk-52IE2PAQ.js";import{a as ie}from"./chunk-CJUKILIO.js";import{k as _e,l as vn}from"./chunk-2A6KSSUD.js";import{C as Gr,D as zr,I as Jr,J as le,M as Qr,Q as Xr,T as de,U as Yr,X as Zr,b as V,f as ae,g as c,h as Br,i as qr,n as Ne,o as Vr,r as Hr,s as Kr}from"./chunk-77DJHICC.js";import{K as Ar,L,R as A,S as jr,X as Tr,aa as Mr,ba as Lr,i as Pr,r as M,s as _,v as Ir}from"./chunk-JNLHZVZJ.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{availableParallelism as Ic}from"os";import{existsSync as nt}from"fs";function tt(){let e=new URL("solve-worker.js",import.meta.url);if(nt(e))return e;let r=new URL("../dist/solve-worker.js",import.meta.url);if(nt(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 Ac from"update-notifier";import jc from"yargs";import{hideBin as Tc}from"yargs/helpers";function fe({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 ot(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as vs}from"gql.tada";import{exec as ps}from"child_process";import{createAuthClient as us}from"better-auth/client";import{deviceAuthorizationClient as cs}from"better-auth/client/plugins";function it({baseURL:e}){return us({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[cs()]})}import{err as st,ok as ms}from"neverthrow";var fs=5e3,at="ripplo-cli";async function lt({onDeviceCode:e,url:r}){let n=r??Dr().RIPPLO_SERVER_URL,t=it({baseURL:n}),o=await t.device.code({client_id:at});if(o.error!=null)return st({description:o.error.error_description,kind:"oauth-device-code-failed"});let{device_code:i,user_code:s,verification_uri_complete:a}=o.data;return e({userCode:s,verificationUrl:a}),bs(a),(await gs({authClient:t,deviceCode:i})).map(u=>(wr({serverUrl:n,token:u}),u))}async function gs({authClient:e,deviceCode:r}){for(;;){await ks(fs);let n=await e.device.token({client_id:at,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return ms(n.data.access_token);if(n.error==null)continue;if(!hs(n.error.error))return st({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var ys=new Set(["authorization_pending","slow_down"]);function hs(e){return ys.has(e)}function ks(e){return new Promise(r=>{setTimeout(r,e)})}function ws(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function bs(e){let r=ws();ps(`${r} "${e}"`,()=>{})}function j({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var Ss=vs(`
5
5
  query AuthViewer {
6
6
  currentUser {
7
7
  name
8
8
  email
9
9
  }
10
10
  }
11
- `);async function at(){let e=x(),r=P(e);if(r!=null&&await vs(e,r))return;let t=(await st({url:e,onDeviceCode:a=>{process.stdout.write(`Opening your browser to finish sign-in.
11
+ `);async function dt(){let e=R(),r=P(e);if(r!=null&&await Cs(e,r))return;let t=(await lt({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(`${v(a)}
17
- `),process.exit(1)}),o=await Ue({serverUrl:e,token:t}),i=Dr(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
- `),process.stdout.write(o.kind==="ok"?`${s}, ${Ss(o.viewer)}.
16
+ `)}})).match(a=>a,a=>{process.stderr.write(`${b(a)}
17
+ `),process.exit(1)}),o=await Ue({serverUrl:e,token:t}),i=Ur(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
+ `),process.stdout.write(o.kind==="ok"?`${s}, ${xs(o.viewer)}.
19
19
  `:`${s}.
20
20
  `),process.stdout.write(`Session saved to ${Me(e)}.
21
- `),i||(process.stdout.write("\nNext: run `npx ripplo setup` to wire Ripplo into this project,\n"),process.stdout.write("or `npx ripplo init` to set it up by hand.\n"))}async function vs(e,r){let n=await Ue({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.
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 Cs(e,r){let n=await Ue({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 lt(){let e=x(),r=P(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await Ue({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 ut(){let e=R(),r=P(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await Ue({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 dt(){let e=x();if(!wr(e)){process.stdout.write(`Already signed out.
28
+ `)}function ct(){let e=R();if(!br(e)){process.stdout.write(`Already signed out.
29
29
  `);return}process.stdout.write(`Signed out. Removed ${Me(e)}.
30
- `)}async function Ue({serverUrl:e,token:r}){try{let t=(await d({config:j({serverUrl:e,token:r}),document:bs,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return yr(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function Ss(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as Cs,writeFile as xs}from"fs/promises";import Rs from"path";async function ut(e){let r=process.cwd(),n=await se(r);n.isErr()&&ge(U(n.error));let t=n.value,[o,i]=await Promise.all([ue({cwd:r,lockfile:t}),ce(r,t)]);o.length>0&&ge(pe(o));let s=Ir(A,i),a=Rs.join(r,D);if(e.check){await $s(a,i);return}await xs(a,s),Ps(i)}function ge(e){process.stderr.write(`${e}
31
- `),process.exit(1)}async function $s(e,r){let n=await Cs(e,"utf8").catch(()=>null);n==null&&ge(Le("missing")),Es(n,r)||ge(Le("stale")),process.stdout.write(`${Or()}
32
- `)}function Es(e,r){try{let n=L(A,e);return n.checks==null?!1:Lr(n,r)}catch{return!1}}function Ps(e){let r=rn(e),n=e.workflows.reduce((o,i)=>o+i.tests.length,0),t=[Fr(),...r.length>0?[tn(r)]:[],nn(n)];process.stdout.write(`${t.join(`
30
+ `)}async function Ue({serverUrl:e,token:r}){try{let t=(await d({config:j({serverUrl:e,token:r}),document:Ss,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return yr(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function xs(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as Rs,writeFile as $s}from"fs/promises";import Es from"path";async function pt(e){let r=process.cwd(),n=await se(r);n.isErr()&&ge(q(n.error));let t=n.value,[o,i]=await Promise.all([ue({cwd:r,lockfile:t}),ce(r,t)]);o.length>0&&ge(pe(o));let s=Ar(A,i),a=Es.join(r,B);if(e.check){await Ps(a,i);return}await $s(a,s),As(i)}function ge(e){process.stderr.write(`${e}
31
+ `),process.exit(1)}async function Ps(e,r){let n=await Rs(e,"utf8").catch(()=>null);n==null&&ge(Le("missing")),Is(n,r)||ge(Le("stale")),process.stdout.write(`${Fr()}
32
+ `)}function Is(e,r){try{let n=L(A,e);return n.checks==null?!1:Nr(n,r)}catch{return!1}}function As(e){let r=nn(e),n=e.workflows.reduce((o,i)=>o+i.tests.length,0),t=[_r(),...r.length>0?[on(r)]:[],tn(n)];process.stdout.write(`${t.join(`
33
33
  `)}
34
- `)}import{graphql as ct}from"gql.tada";function Be(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 Is}from"gql.tada";var As=Is(`
34
+ `)}import{graphql as mt}from"gql.tada";function Be(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 js}from"gql.tada";var Ts=js(`
35
35
  query DevSessionCheckPreflight($projectId: String!, $cwd: String!) {
36
36
  project(id: $projectId) {
37
37
  id
@@ -40,62 +40,62 @@ import{a as gn,c as yn,d as hn,e as kn,f as wn,g as me}from"./chunk-RAN55ZC6.js"
40
40
  }
41
41
  }
42
42
  }
43
- `);function g(){return h(process.cwd()).match(e=>e,e=>{process.stderr.write(`${v(e)}
44
- `),process.stderr.write(`${C("setup")}
45
- `),process.exit(1)})}async function S(e){(await d({config:e,document:As,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 js=ct(`
43
+ `);function g(){return y(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 d({config:e,document:Ts,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 Ms=mt(`
47
47
  mutation CliUpdateMaxLocalConcurrentRuns($value: Int!) {
48
48
  updateMaxLocalConcurrentRuns(value: $value) {
49
49
  id
50
50
  maxLocalConcurrentRuns
51
51
  }
52
52
  }
53
- `),Ts=ct(`
53
+ `),Ls=mt(`
54
54
  query CliMaxLocalConcurrentRuns {
55
55
  currentUser {
56
56
  id
57
57
  maxLocalConcurrentRuns
58
58
  }
59
59
  }
60
- `);async function pt({value:e}){let r=g();if(e==null){let t=await d({config:r,document:Ts,variables:{}});process.stdout.write(`${Be(t.currentUser?.maxLocalConcurrentRuns)}
61
- `);return}let n=await d({config:r,document:js,variables:{value:e}});process.stdout.write(`${Be(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
- `)}function mt(e){switch(e.type){case"settings":return Ms(e);case"env-files":return Ls(e);case"token":return Ns(e);case"dev-server":return Os(e);case"dev-session":return sn(e);case"entities":return Fs(e);case"webhook-verification":return _s(e);case"entities-validation":return Ws(e);case"workflows":return Ds(e);case"browser":return Bs(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 qs(e);case"lockfile":return Vs(e);case"pre-commit-hook":return Hs(e);case"plugin-version":return Ks(e);case"stale-build":return Gs(e)}}function Ms(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function Ls(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 ft({value:e}){let r=g();if(e==null){let t=await d({config:r,document:Ls,variables:{}});process.stdout.write(`${Be(t.currentUser?.maxLocalConcurrentRuns)}
61
+ `);return}let n=await d({config:r,document:Ms,variables:{value:e}});process.stdout.write(`${Be(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
+ `)}function gt(e){switch(e.type){case"settings":return Ns(e);case"env-files":return Os(e);case"token":return Fs(e);case"dev-server":return _s(e);case"dev-session":return an(e);case"entities":return Ws(e);case"webhook-verification":return Ds(e);case"entities-validation":return Us(e);case"workflows":return Bs(e);case"browser":return Vs(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 Hs(e);case"lockfile":return Ks(e);case"pre-commit-hook":return Gs(e);case"plugin-version":return zs(e);case"stale-build":return Js(e)}}function Ns(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function Os(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 Ns(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 Os(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function Fs(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 _s(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 Ws(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 Fs(e){switch(e.status){case"valid":return`\u2713 Auth: signed in as ${e.email??"unknown"}`;case"missing":return"\u2717 Auth: not signed in. Run `npx ripplo auth login`.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"invalid":return"\u2717 Auth: saved token rejected by the server. Run `npx ripplo auth login` to sign in again.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"unreachable":return`! Auth: could not reach ${R()} to validate the token.`}}function _s(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function Ws(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 Ds(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 Us(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 Ds(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=>Us(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
67
+ `)}`}function Bs(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=>qs(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
68
68
  ${r.join(`
69
- `)}`}function Us(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
69
+ `)}`}function qs(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
70
70
  `+r.join(`
71
- `)}function Bs(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function qs(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 Vs(e){switch(e.status){case"match":return`\u2713 Lockfile: ${D} is up to date`;case"missing":return`\u2717 Lockfile: ${D} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${D} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function Hs(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 Ks(e){return e.installed===e.cliVersion?`\u2713 Claude plugin: v${e.installed} matches CLI`:`! Claude plugin: installed v${e.installed}, CLI v${e.cliVersion} \u2014 run \`npx ripplo update\` (or /plugin in Claude Code)`}function Gs(e){return e.freshness.kind==="foreign-binary"?"! Build: running a ripplo binary from outside this workspace \u2014 its bundle may not match your source. Run `npx ripplo` from this workspace after `pnpm build`.":e.freshness.kind==="stale"?`! Build: source is newer than the built bundles (${e.freshness.packages.join(", ")}) \u2014 the daemon and engine may be serving stale code. Run \`pnpm build\`, then \`npx ripplo daemon stop\` and start it again.`:"\u2713 Build: bundles up to date"}import ee from"fs";import Ys from"os";import ht from"path";import{z as N}from"zod";import zs from"latest-version";import ft from"semver";async function ye(e){try{return await Promise.race([zs("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function gt(e){return e.filter(r=>ft.valid(r)!=null).toSorted(ft.rcompare)[0]}import{graphql as Js}from"gql.tada";var Qs=Js(`
71
+ `)}function Vs(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function Hs(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 Ks(e){switch(e.status){case"match":return`\u2713 Lockfile: ${B} is up to date`;case"missing":return`\u2717 Lockfile: ${B} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${B} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function Gs(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 zs(e){return e.installed===e.cliVersion?`\u2713 Claude plugin: v${e.installed} matches CLI`:`! Claude plugin: installed v${e.installed}, CLI v${e.cliVersion} \u2014 run \`npx ripplo update\` (or /plugin in Claude Code)`}function Js(e){return e.freshness.kind==="foreign-binary"?"! Build: running a ripplo binary from outside this workspace \u2014 its bundle may not match your source. Run `npx ripplo` from this workspace after `pnpm build`.":e.freshness.kind==="stale"?`! Build: source is newer than the built bundles (${e.freshness.packages.join(", ")}) \u2014 the daemon and engine may be serving stale code. Run \`pnpm build\`, then \`npx ripplo daemon stop\` and start it again.`:"\u2713 Build: bundles up to date"}import ee from"fs";import ea from"os";import wt from"path";import{z as N}from"zod";import Qs from"latest-version";import yt from"semver";async function ye(e){try{return await Promise.race([Qs("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function ht(e){return e.filter(r=>yt.valid(r)!=null).toSorted(yt.rcompare)[0]}import{graphql as Xs}from"gql.tada";var Ys=Xs(`
72
72
  query DoctorAuthViewer {
73
73
  currentUser {
74
74
  name
75
75
  email
76
76
  }
77
77
  }
78
- `),Xs="Failed to connect to Ripplo server";async function yt({serverUrl:e,token:r}){try{let n=await d({config:j({serverUrl:e,token:r}),document:Qs,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(Xs)?{kind:"unreachable"}:{kind:"invalid"}}}function kt(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;case"stale-build":return!1}}async function wt(e){let r=await na(e),n={missing:$r(e),type:"env-files"},t=await ta(),o=await oa(),i=await se(e),s=await ia(e,i),a=sa(i),l=await aa(e,i),u=la(e),w=ra(e),f=Zs(),p=await da(r,i);return[r,n,t,...p,s,a,l,u,o,...w==null?[]:[w],...f==null?[]:[f]]}function Zs(){let e=q();return e.kind==="fresh"?null:{freshness:e,type:"stale-build"}}var ea=N.object({plugins:N.record(N.string(),N.array(N.object({projectPath:N.string().optional(),scope:N.string().optional(),version:N.string()})))});function ra(e){let r=ht.join(Ys.homedir(),".claude","plugins","installed_plugins.json"),n=ee.existsSync(r)?ee.readFileSync(r,"utf8"):null;if(n==null)return null;let t=ea.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=gt(o);return i==null?null:{cliVersion:b(),installed:i,type:"plugin-version"}}async function na(e){let r=await ln(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 ta(){let e=x(),r=P(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await yt({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 oa(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:ee.existsSync(r),type:"browser"}}async function ia(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 ue({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:pe(n),path:""}],found:!0,type:"entities-validation",valid:n.length===0}}function sa(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 aa(e,r){return r.isErr()?{status:"missing",type:"lockfile"}:{status:await en(e,r.value),type:"lockfile"}}function la(e){let r=ht.join(e,".git","hooks","pre-commit");return ee.existsSync(r)?{installed:ee.readFileSync(r,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function da(e,r){let n=Rr().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Oe(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await an(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await ua(n,r);t.push(...s)}return t}async function ua(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=pa(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Oe(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"entities"}),bt(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await dn({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let u=await ca({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:u,type:"adapter-enabled",url:i}),a}async function ca({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",...vr({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 bt(e){return e.startsWith("http://")||e.startsWith("https://")}function pa(e,r){return bt(r)?r:`${e}${r}`}var ma=3e3;async function vt(){let e=process.cwd(),[r,n]=await Promise.all([ye(ma),wt(e)]);process.stdout.write(`${fe({current:b(),latest:r})}
79
- `);let t=n.map(i=>mt(i));process.stdout.write(t.join(`
78
+ `),Zs="Failed to connect to Ripplo server";async function kt({serverUrl:e,token:r}){try{let n=await d({config:j({serverUrl:e,token:r}),document:Ys,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(Zs)?{kind:"unreachable"}:{kind:"invalid"}}}function bt(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;case"stale-build":return!1}}async function vt(e){let r=await oa(e),n={missing:Er(e),type:"env-files"},t=await ia(),o=await sa(),i=await se(e),s=await aa(e,i),a=la(i),l=await da(e,i),u=ua(e),h=ta(e),f=ra(),p=await ca(r,i);return[r,n,t,...p,s,a,l,u,o,...h==null?[]:[h],...f==null?[]:[f]]}function ra(){let e=H();return e.kind==="fresh"?null:{freshness:e,type:"stale-build"}}var na=N.object({plugins:N.record(N.string(),N.array(N.object({projectPath:N.string().optional(),scope:N.string().optional(),version:N.string()})))});function ta(e){let r=wt.join(ea.homedir(),".claude","plugins","installed_plugins.json"),n=ee.existsSync(r)?ee.readFileSync(r,"utf8"):null;if(n==null)return null;let t=na.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=ht(o);return i==null?null:{cliVersion:w(),installed:i,type:"plugin-version"}}async function oa(e){let r=await dn(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 ia(){let e=R(),r=P(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await kt({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 sa(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:ee.existsSync(r),type:"browser"}}async function aa(e,r){if(r.isErr())return{errorCount:1,errors:[{message:q(r.error),path:".ripplo/"}],found:!1,type:"entities-validation",valid:!1};let n=await ue({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:pe(n),path:""}],found:!0,type:"entities-validation",valid:n.length===0}}function la(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 da(e,r){return r.isErr()?{status:"missing",type:"lockfile"}:{status:await rn(e,r.value),type:"lockfile"}}function ua(e){let r=wt.join(e,".git","hooks","pre-commit");return ee.existsSync(r)?{installed:ee.readFileSync(r,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function ca(e,r){let n=$r().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Oe(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await ln(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await pa(n,r);t.push(...s)}return t}async function pa(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=fa(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Oe(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"entities"}),St(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await un({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let u=await ma({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:u,type:"adapter-enabled",url:i}),a}async function ma({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",...Sr({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 St(e){return e.startsWith("http://")||e.startsWith("https://")}function fa(e,r){return St(r)?r:`${e}${r}`}var ga=3e3;async function Ct(){let e=process.cwd(),[r,n]=await Promise.all([ye(ga),vt(e)]);process.stdout.write(`${fe({current:w(),latest:r})}
79
+ `);let t=n.map(i=>gt(i));process.stdout.write(t.join(`
80
80
  `)+`
81
- `);let o=n.some(i=>kt(i));process.exit(o?1:0)}import he from"fs";import{graphql as fa}from"gql.tada";var ga=fa(`
81
+ `);let o=n.some(i=>bt(i));process.exit(o?1:0)}import he from"fs";import{graphql as ya}from"gql.tada";var ha=ya(`
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 St(){let e=process.cwd();hr(e);let r=Fe(e);if(he.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}he.writeFileSync(r,""),await xt(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=Fe(e);if(!he.existsSync(r)){process.stdout.write(`Hooks already active.
88
- `);return}he.unlinkSync(r),await xt(e,!1),process.stdout.write(`Hooks resumed.
89
- `)}async function xt(e,r){let n=h(e).unwrapOr(void 0);n!=null&&await d({config:n,document:ga,variables:{paused:r,projectId:n.projectId}}).catch(t=>{process.stderr.write(`Warning: could not push hook-pause state to the server (${t instanceof Error?t.message:String(t)}) \u2014 the dashboard may show stale hook status.
90
- `)})}import H from"fs";import K from"path";import{input as jt,select as Tt}from"@inquirer/prompts";import{graphql as za}from"gql.tada";import{exec as ya,execFile as ha}from"child_process";import{err as ka,ok as Rt}from"neverthrow";import m from"fs";import{createRequire as wa}from"module";import k from"path";import{promisify as Et}from"util";var ba=["ripplo","@ripplo/testing","@ripplo/instrument"],$t=".ripplo/ripplo.lock linguist-generated=true",va=[".ripplo/debug/",".ripplo/.local/"],Sa=Et(ya),Ca=Et(ha);async function Pt({cwd:e,onStep:r}){r("Scaffolding project files..."),La({cwd:e}),r("Updating .gitignore..."),Oa(e),r("Marking ripplo.lock as generated..."),Ea(e),r("Installing dependencies...");let n=await Ra(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 $a(e);i!=null&&t.push({manualCommand:void 0,message:i})}return r("Setting up browser..."),(await xa()).map(()=>t)}async function xa(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return Rt(void 0);W.info("Chromium not found. Installing via Playwright...");let n=wa(import.meta.url),t=k.dirname(n.resolve("playwright/package.json")),o=k.join(t,"cli.js");return await Ca(process.execPath,[o,"install","chromium"]),m.existsSync(r)?Rt(void 0):ka({kind:"playwright-install-failed"})}async function Ra(e){let r=Pa({cwd:e,pm:Ma(e)});W.info("Installing dependencies: %s",r);try{return await Sa(r,{cwd:e}),{ok:!0}}catch(n){let t=n instanceof Error?n.message.split(`
91
- `)[0]??n.message:String(n);return W.warn("Install failed (%s): %s",r,t),{cmd:r,ok:!1,reason:t}}}async function $a(e){try{await Zr(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function Ea(e){let r=k.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes($t))return;let t=n.length===0||n.endsWith(`
87
+ `);async function xt(){let e=process.cwd();kr(e);let r=Fe(e);if(he.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}he.writeFileSync(r,""),await $t(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 Rt(){let e=process.cwd(),r=Fe(e);if(!he.existsSync(r)){process.stdout.write(`Hooks already active.
88
+ `);return}he.unlinkSync(r),await $t(e,!1),process.stdout.write(`Hooks resumed.
89
+ `)}async function $t(e,r){let n=y(e).unwrapOr(void 0);n!=null&&await d({config:n,document:ha,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 G from"fs";import z from"path";import{input as Mt,select as Lt}from"@inquirer/prompts";import{graphql as Qa}from"gql.tada";import{exec as ka,execFile as wa}from"child_process";import{err as ba,ok as Et}from"neverthrow";import m from"fs";import{createRequire as va}from"module";import k from"path";import{promisify as It}from"util";var Sa=["ripplo","@ripplo/testing","@ripplo/instrument"],Pt=".ripplo/ripplo.lock linguist-generated=true",Ca=[".ripplo/debug/",".ripplo/.local/"],xa=It(ka),Ra=It(wa);async function At({cwd:e,onStep:r}){r("Scaffolding project files..."),Oa({cwd:e}),r("Updating .gitignore..."),_a(e),r("Marking ripplo.lock as generated..."),Ia(e),r("Installing dependencies...");let n=await Ea(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 Pa(e);i!=null&&t.push({manualCommand:void 0,message:i})}return r("Setting up browser..."),(await $a()).map(()=>t)}async function $a(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return Et(void 0);U.info("Chromium not found. Installing via Playwright...");let n=va(import.meta.url),t=k.dirname(n.resolve("playwright/package.json")),o=k.join(t,"cli.js");return await Ra(process.execPath,[o,"install","chromium"]),m.existsSync(r)?Et(void 0):ba({kind:"playwright-install-failed"})}async function Ea(e){let r=Aa({cwd:e,pm:Na(e)});U.info("Installing dependencies: %s",r);try{return await xa(r,{cwd:e}),{ok:!0}}catch(n){let t=n instanceof Error?n.message.split(`
91
+ `)[0]??n.message:String(n);return U.warn("Install failed (%s): %s",r,t),{cmd:r,ok:!1,reason:t}}}async function Pa(e){try{await en(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function Ia(e){let r=k.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes(Pt))return;let t=n.length===0||n.endsWith(`
92
92
  `)?"":`
93
- `;m.writeFileSync(r,`${n}${t}${$t}
94
- `)}function Pa({cwd:e,pm:r}){let n=ba.join(" ");return r==="pnpm"?Ia(e)?`pnpm add -wD ${n}`:`pnpm add -D ${n}`:r==="yarn"?Aa({cwd:e,deps:n}):r==="bun"?`bun add -d ${n}`:`npm install -D ${n}`}function Ia(e){return m.existsSync(k.join(e,"pnpm-workspace.yaml"))||m.existsSync(k.join(e,"pnpm-workspace.yml"))}function Aa({cwd:e,deps:r}){return ja(e)?`yarn add -D ${r}`:Ta(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`}function ja(e){if(m.existsSync(k.join(e,".yarnrc.yml"))||m.existsSync(k.join(e,".pnp.cjs"))||m.existsSync(k.join(e,".pnp.js")))return!0;let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("packageManager"in n))return!1;let t=n.packageManager;if(typeof t!="string")return!1;let o=/^yarn@(\d+)/.exec(t);return o!=null&&Number(o[1])>=2}catch{return!1}}function Ta(e){let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("workspaces"in n))return!1;let t=n.workspaces;return Array.isArray(t)||t!=null&&typeof t=="object"}catch{return!1}}function Ma(e){return m.existsSync(k.join(e,"pnpm-lock.yaml"))?"pnpm":m.existsSync(k.join(e,"yarn.lock"))?"yarn":m.existsSync(k.join(e,"bun.lockb"))||m.existsSync(k.join(e,"bun.lock"))?"bun":"npm"}function La({cwd:e}){let r=k.join(e,".ripplo");Ha.forEach(({content:n,relPath:t})=>{let o=k.join(r,t);m.mkdirSync(k.dirname(o),{recursive:!0}),Na(o,n)})}function Na(e,r){m.existsSync(e)||m.writeFileSync(e,r)}function Oa(e){let r=k.join(e,".gitignore");if(!m.existsSync(r))return;let n=m.readFileSync(r,"utf8"),t=va.filter(i=>!n.includes(i));if(t.length===0)return;let o=n.endsWith(`
93
+ `;m.writeFileSync(r,`${n}${t}${Pt}
94
+ `)}function Aa({cwd:e,pm:r}){let n=Sa.join(" ");return r==="pnpm"?ja(e)?`pnpm add -wD ${n}`:`pnpm add -D ${n}`:r==="yarn"?Ta({cwd:e,deps:n}):r==="bun"?`bun add -d ${n}`:`npm install -D ${n}`}function ja(e){return m.existsSync(k.join(e,"pnpm-workspace.yaml"))||m.existsSync(k.join(e,"pnpm-workspace.yml"))}function Ta({cwd:e,deps:r}){return Ma(e)?`yarn add -D ${r}`:La(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`}function Ma(e){if(m.existsSync(k.join(e,".yarnrc.yml"))||m.existsSync(k.join(e,".pnp.cjs"))||m.existsSync(k.join(e,".pnp.js")))return!0;let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("packageManager"in n))return!1;let t=n.packageManager;if(typeof t!="string")return!1;let o=/^yarn@(\d+)/.exec(t);return o!=null&&Number(o[1])>=2}catch{return!1}}function La(e){let r=k.join(e,"package.json");if(!m.existsSync(r))return!1;try{let n=JSON.parse(m.readFileSync(r,"utf8"));if(n==null||typeof n!="object"||!("workspaces"in n))return!1;let t=n.workspaces;return Array.isArray(t)||t!=null&&typeof t=="object"}catch{return!1}}function Na(e){return m.existsSync(k.join(e,"pnpm-lock.yaml"))?"pnpm":m.existsSync(k.join(e,"yarn.lock"))?"yarn":m.existsSync(k.join(e,"bun.lockb"))||m.existsSync(k.join(e,"bun.lock"))?"bun":"npm"}function Oa({cwd:e}){let r=k.join(e,".ripplo");Ga.forEach(({content:n,relPath:t})=>{let o=k.join(r,t);m.mkdirSync(k.dirname(o),{recursive:!0}),Fa(o,n)})}function Fa(e,r){m.existsSync(e)||m.writeFileSync(e,r)}function _a(e){let r=k.join(e,".gitignore");if(!m.existsSync(r))return;let n=m.readFileSync(r,"utf8"),t=Ca.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 Fa=`import { createRipplo } from "@ripplo/testing";
98
+ `)}var Wa=`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
- `,_a=`// Model the app's state as entities. Each entity gets a \`seed\`/\`read\` impl in your
111
+ `,Da=`// 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
- `,Wa=`// Client/global state (e.g. localStorage flags) modeled as singletons.
126
+ `,Ua=`// 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
- `,Da=`// App-wide rules enforced everywhere, independent of any workflow \u2014 invariants and
140
+ `,Ba=`// 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
- `,Ua=`// Pure builder functions, each returning one entity handle (or a tight cluster) \u2014 the
153
+ `,qa=`// 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
- `,Ba=`// Each file under ./workflows exports a workflow. Import them here and add to the
164
+ `,Va=`// 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
- `,qa=`{
173
+ `,Ha=`{
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
- `,Va=`// Guards spec files against shadowing DSL imports \u2014 \`const url = ...\` next to the
189
+ `,Ka=`// 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
- `,Ha=[{content:Fa,relPath:"index.ts"},{content:_a,relPath:"entities/index.ts"},{content:Wa,relPath:"singletons/index.ts"},{content:Da,relPath:"facts.ts"},{content:Ua,relPath:"givens.ts"},{content:Ba,relPath:"workflows/index.ts"},{content:qa,relPath:"tsconfig.json"},{content:Va,relPath:"eslint.config.js"}];import ke from"fs";import It from"path";import{z as qe}from"zod";var Ka={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},At=qe.record(qe.string(),qe.unknown());function we(e){let r=It.join(e,".claude","settings.json"),n=Ga(r);if(n==null)return"unparseable";let t=At.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:Ka}};return ke.mkdirSync(It.dirname(r),{recursive:!0}),ke.writeFileSync(r,`${JSON.stringify(o,null,2)}
204
- `),"written"}function Ga(e){if(!ke.existsSync(e))return{};try{let r=At.safeParse(JSON.parse(ke.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function be(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 Ja=za(`
203
+ `,Ga=[{content:Wa,relPath:"index.ts"},{content:Da,relPath:"entities/index.ts"},{content:Ua,relPath:"singletons/index.ts"},{content:Ba,relPath:"facts.ts"},{content:qa,relPath:"givens.ts"},{content:Va,relPath:"workflows/index.ts"},{content:Ha,relPath:"tsconfig.json"},{content:Ka,relPath:"eslint.config.js"}];import ke from"fs";import jt from"path";import{z as qe}from"zod";var za={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},Tt=qe.record(qe.string(),qe.unknown());function we(e){let r=jt.join(e,".claude","settings.json"),n=Ja(r);if(n==null)return"unparseable";let t=Tt.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:za}};return ke.mkdirSync(jt.dirname(r),{recursive:!0}),ke.writeFileSync(r,`${JSON.stringify(o,null,2)}
204
+ `),"written"}function Ja(e){if(!ke.existsSync(e))return{};try{let r=Tt.safeParse(JSON.parse(ke.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function be(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 Xa=Qa(`
205
205
  query InitProjects {
206
206
  projects {
207
207
  id
208
208
  name
209
209
  }
210
210
  }
211
- `),Ve=["../.env.local","../.env"];async function Mt(e=Ya()){let r=process.cwd(),n=x(),t=P(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 Xa({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 el(o,e.projectId),s=await rl(r,e.envFile),a=await tl(e.appUrl),l=Za(a,e.engineUrl),u=K.resolve(K.join(r,".ripplo"),s);xr({cwd:r,envFiles:[s],projectId:i}),il({appUrl:a,engineUrl:l,filePath:u}),process.stdout.write(`${be(we(r))}
213
- `);let f=(await Pt({cwd:r,onStep:p=>{process.stdout.write(` ${p}
214
- `)}})).match(p=>p,p=>{process.stderr.write(`${v(p)}
211
+ `),Ve=["../.env.local","../.env"];async function Nt(e=el()){let r=process.cwd(),n=R(),t=P(n);t==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login` first.\n"),process.exit(1)),Ya(r)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${r}. To re-init, delete it first.
212
+ `),process.exit(1));let o=await Za({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 nl(o,e.projectId),s=await tl(r,e.envFile),a=await il(e.appUrl),l=rl(a,e.engineUrl),u=z.resolve(z.join(r,".ripplo"),s);Rr({cwd:r,envFiles:[s],projectId:i}),al({appUrl:a,engineUrl:l,filePath:u}),process.stdout.write(`${be(we(r))}
213
+ `);let f=(await At({cwd:r,onStep:p=>{process.stdout.write(` ${p}
214
+ `)}})).match(p=>p,p=>{process.stderr.write(`${b(p)}
215
215
  `),process.exit(1)});if(f.length>0){process.stdout.write(`Done with warnings:
216
216
  `),f.forEach(p=>{process.stdout.write(` - ${p.message}
217
217
  `),p.manualCommand!=null&&process.stdout.write(` run: ${p.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 Qa(e){return H.existsSync(K.join(e,".ripplo","index.ts"))}async function Xa({serverUrl:e,token:r}){return((await d({config:j({serverUrl:e,token:r}),document:Ja,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function Ya(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function Za(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 el(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 Ya(e){return G.existsSync(z.join(e,".ripplo","index.ts"))}async function Za({serverUrl:e,token:r}){return((await d({config:j({serverUrl:e,token:r}),document:Xa,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function el(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function rl(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 nl(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 Tt({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function rl(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
223
- `),process.exit(1)),r):nl(e)}async function nl(e){let r=K.join(e,".ripplo"),n=Ve.find(o=>H.existsSync(K.resolve(r,o))),t=await Tt({choices:[...Ve.map(o=>({name:n===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:n??Ve[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:jt({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function tl(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 ol()}async function ol(){return jt({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 il({appUrl:e,engineUrl:r,filePath:n}){H.mkdirSync(K.dirname(n),{recursive:!0});let t=H.existsSync(n)?H.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=${Sr()}`),/^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 Lt({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function tl(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
223
+ `),process.exit(1)),r):ol(e)}async function ol(e){let r=z.join(e,".ripplo"),n=Ve.find(o=>G.existsSync(z.resolve(r,o))),t=await Lt({choices:[...Ve.map(o=>({name:n===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:n??Ve[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:Mt({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function il(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 sl()}async function sl(){return Mt({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 al({appUrl:e,engineUrl:r,filePath:n}){G.mkdirSync(z.dirname(n),{recursive:!0});let t=G.existsSync(n)?G.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=${Cr()}`),/^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
- `;H.writeFileSync(n,`${t}${i}${o.join(`
226
+ `;G.writeFileSync(n,`${t}${i}${o.join(`
227
227
  `)}
228
- `)}import{graphql as Ge}from"gql.tada";function He(){return"Not signed in. Run `npx ripplo auth login` first."}function Lt(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function Nt(e){return["You belong to multiple organizations \u2014 pass `--org <id>`:",...e.map(n=>` ${n.id} ${n.name}`)].join(`
229
- `)}function Ke(e){return`Could not create the project \u2014 ${e}`}var sl=Ge(`
228
+ `)}import{graphql as Ge}from"gql.tada";function He(){return"Not signed in. Run `npx ripplo auth login` first."}function Ot(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function Ft(e){return["You belong to multiple organizations \u2014 pass `--org <id>`:",...e.map(n=>` ${n.id} ${n.name}`)].join(`
229
+ `)}function Ke(e){return`Could not create the project \u2014 ${e}`}var ll=Ge(`
230
230
  query ProjectsList {
231
231
  projects {
232
232
  id
233
233
  name
234
234
  }
235
235
  }
236
- `),al=Ge(`
236
+ `),dl=Ge(`
237
237
  query OrganizationsList {
238
238
  organizations {
239
239
  id
240
240
  name
241
241
  }
242
242
  }
243
- `),ll=Ge(`
243
+ `),ul=Ge(`
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 Ot(){let e=x(),r=P(e);r==null&&(process.stderr.write(`${He()}
260
- `),process.exit(1));let t=((await d({config:j({serverUrl:e,token:r}),document:sl,variables:void 0})).projects??[]).map(o=>({id:o.id,name:o.name}));process.stdout.write(`${JSON.stringify({projects:t},null,2)}
261
- `)}async function Ft({name:e,orgId:r}){let n=x(),t=P(n);t==null&&(process.stderr.write(`${He()}
262
- `),process.exit(1));let o=j({serverUrl:n,token:t}),i=r??await dl(o),a=(await d({config:o,document:ll,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof gr&&(process.stderr.write(`${Ke(l.message)}
259
+ `);async function _t(){let e=R(),r=P(e);r==null&&(process.stderr.write(`${He()}
260
+ `),process.exit(1));let t=((await d({config:j({serverUrl:e,token:r}),document:ll,variables:void 0})).projects??[]).map(o=>({id:o.id,name:o.name}));process.stdout.write(`${JSON.stringify({projects:t},null,2)}
261
+ `)}async function Wt({name:e,orgId:r}){let n=R(),t=P(n);t==null&&(process.stderr.write(`${He()}
262
+ `),process.exit(1));let o=j({serverUrl:n,token:t}),i=r??await cl(o),a=(await d({config:o,document:ul,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof gr&&(process.stderr.write(`${Ke(l.message)}
263
263
  `),process.exit(1)),l})).createProject;if(a?.__typename!=="Project"){let l=a?.message??"unknown error";process.stderr.write(`${Ke(l)}
264
264
  `),process.exit(1)}process.stdout.write(`${JSON.stringify({project:{id:a.id,name:a.name}},null,2)}
265
- `)}async function dl(e){let n=((await d({config:e,document:al,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?Lt():Nt(n)}
266
- `),process.exit(1)}import{spawnSync as ve}from"child_process";function _t(){if(ve("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};ve("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=ve("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:ve("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function Wt(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function Dt(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 Ut(){process.stdout.write(`${Wt()}
268
- `);let e=_t();e.kind!=="launched"&&(process.stderr.write(`${Dt(e)}
269
- `),process.exit(1)),process.exit(e.exitCode)}import{graphql as ul}from"gql.tada";function Bt({id:e,kind:r,title:n}){return`Caught bug reported (${r}): "${n}" [${e}]`}var cl=ul(`
265
+ `)}async function cl(e){let n=((await d({config:e,document:dl,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?Ot():Ft(n)}
266
+ `),process.exit(1)}import{spawnSync as ve}from"child_process";function Dt(){if(ve("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};ve("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=ve("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:ve("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function Ut(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function Bt(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 qt(){process.stdout.write(`${Ut()}
268
+ `);let e=Dt();e.kind!=="launched"&&(process.stderr.write(`${Bt(e)}
269
+ `),process.exit(1)),process.exit(e.exitCode)}import{graphql as pl}from"gql.tada";function Vt({id:e,kind:r,title:n}){return`Caught bug reported (${r}): "${n}" [${e}]`}var ml=pl(`
270
270
  mutation ReportCaughtBug(
271
271
  $projectId: String!
272
272
  $kind: CaughtBugKind!
@@ -294,23 +294,23 @@ ${e.detail}`:""}`}function Ut(){process.stdout.write(`${Wt()}
294
294
  }
295
295
  }
296
296
  }
297
- `);async function qt(e){let r=g(),t=(await d({config:r,document:cl,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(`${Bt({id:t.id,kind:e.kind,title:e.title})}
299
- `)}import pl from"path";import{CancellationTokenSource as ml}from"vscode-jsonrpc/node";function Vt(e){return`ripplo: workspace build is stale (${e.join(", ")}) \u2014 rebuilding`}function Ht(){return"ripplo: workspace build failed \u2014 fix the build, then rerun"}function Se(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 Kt({all:e,headed:r,ids:n}){let t=process.cwd(),o=process.argv[1];o==null&&O(me({kind:"spawn-failed",message:"process.argv[1] missing"})),gl();let i=await gn(t);i!=null&&O(kn(i));let a=(await cn({cliEntry:o,cwd:t})).match(p=>p,p=>O(me(p)));a.versionNote?.kind==="stale-busy"&&O(_e(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${_e(a.versionNote)}
300
- `);let l=new ml;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let u=pl.join(t,".ripplo","debug"),f=(await pn({connection:a,request:{all:e,headed:r,tests:[...n]},token:l.token,onEvent:p=>{let y=hn({debugDir:u,event:p});y!=null&&process.stdout.write(`${y}
301
- `)}})).match(p=>p,p=>O(me(p)));await fl({connection:a,result:f})}async function fl({connection:e,result:r}){await new Promise(n=>{e.socket.end(n)}),r.kind==="daemon-error"&&O(wn(r.error)),process.stdout.write(`${yn(r)}
297
+ `);async function Ht(e){let r=g(),t=(await d({config:r,document:ml,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(`${Vt({id:t.id,kind:e.kind,title:e.title})}
299
+ `)}import fl from"path";import{CancellationTokenSource as gl}from"vscode-jsonrpc/node";function Kt(e){return`ripplo: workspace build is stale (${e.join(", ")}) \u2014 rebuilding`}function Gt(){return"ripplo: workspace build failed \u2014 fix the build, then rerun"}function Se(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 zt({all:e,headed:r,ids:n}){let t=process.cwd(),o=process.argv[1];o==null&&O(me({kind:"spawn-failed",message:"process.argv[1] missing"})),hl();let i=await yn(t);i!=null&&O(wn(i));let a=(await pn({cliEntry:o,cwd:t})).match(p=>p,p=>O(me(p)));a.versionNote?.kind==="stale-busy"&&O(_e(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${_e(a.versionNote)}
300
+ `);let l=new gl;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let u=fl.join(t,".ripplo","debug"),f=(await mn({connection:a,request:{all:e,headed:r,tests:[...n]},token:l.token,onEvent:p=>{let v=kn({debugDir:u,event:p});v!=null&&process.stdout.write(`${v}
301
+ `)}})).match(p=>p,p=>O(me(p)));await yl({connection:a,result:f})}async function yl({connection:e,result:r}){await new Promise(n=>{e.socket.end(n)}),r.kind==="daemon-error"&&O(bn(r.error)),process.stdout.write(`${hn(r)}
302
302
  `),r.failed>0&&process.exit(1),process.exit(r.notRun>0?2:0)}function O(e){process.stderr.write(`${e}
303
- `),process.exit(1)}function gl(){let e=q();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=Se(e);O(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Vt(e.packages)}
304
- `),un(e.workspaceRoot)||O(Ht())}import _ from"path";import bl from"os";import{mkdtempSync as vl,rmSync as Sl}from"fs";import{err as Re,ok as Qe}from"neverthrow";import{z as Gt}from"zod";import{readdir as yl,rm as hl,stat as kl}from"fs/promises";import{existsSync as wl}from"fs";import ze from"path";async function Je(e,r){let t=(await yl(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||wl(ze.join(e,s,jn)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await kl(ze.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>hl(ze.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var zt=50,Cl=15e3;async function Jt(){ie(b());let e=process.cwd(),r=W.child({worker:process.pid}),n=In(),t=vl(_.join(bl.tmpdir(),"ripplo-browser-cache-")),o=de({cacheDir:t,clientVersion:b(),debugDir:_.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)},Cl).unref(),Rl(i).then(()=>o.close().catch(()=>{})).then(()=>{Sl(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(xn,async(l,u)=>{let w=vn.safeParse(l);if(!w.success)return Ce("bad-run-assign");let f=w.data;X(e);let p=h(e).match($=>$,$=>$.kind);if(typeof p=="string")return Ce(`config:${p}`);let y=await Qt(n);if(y.isErr())return Ce(`lockfile-unavailable:${y.error}`);let Q=y.value,E=B(Q).find($=>$.ref===f.testRef);if(E==null)return Ce(`no-test:${f.testRef}`);try{let{outcome:$,persisted:Te}=await Tn({config:p,cwd:e,errorSettle:"settle",fixturesDir:_.join(e,Y),headed:f.headed,lockfile:Q,onPhase:void 0,runId:f.runId,session:o,signal:We(u),test:E.test}),mr=_.join(e,".ripplo","debug");return s(Promise.allSettled([Te]).then(()=>V({config:p,debugDir:mr,runId:f.runId})).then(()=>Je(mr,zt)).catch(()=>{})),{outcome:bn($),serverNotified:!0}}catch($){let Te=_.join(e,".ripplo","debug");if(s(V({config:p,debugDir:Te,runId:f.runId}).catch(()=>{})),$ instanceof fr)return{outcome:{detail:$.message,kind:"infra-error"},serverNotified:!1};throw $}}),n.onRequest($n,(l,u)=>El({connection:n,cwd:e,raw:l,session:o,token:u,track:s})),n.onNotification(En,l=>{let u=Sn.safeParse(l);u.success&&o.injectSpan(u.data.runId,u.data.span)}),n.onNotification(Pn,()=>{a(0)}),n.sendNotification(Cn),await new Promise(()=>{})}function Ce(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var xl=5e3;async function Rl(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,xl)})])}var $l=Gt.object({assign:zr,devSessionId:Gt.string().nullable()});async function El({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=$l.safeParse(n);if(!s.success)return{error:{source:"bad-assign"},kind:"error"};let{assign:a,devSessionId:l}=s.data;X(r);let u=h(r).match(E=>E,E=>E.kind);if(typeof u=="string")return{error:{detail:u,source:"config"},kind:"error"};let w=await Qt(e);if(w.isErr())return{error:{source:"lockfile-stale"},kind:"error"};let f=w.value,p=_.join(u.cwd,".ripplo","debug"),y=await Mn({assign:a,config:u,debugDir:p,devSessionId:l??void 0,fixturesDir:_.join(u.cwd,Y),headed:!1,lockfile:f,report:!0,session:t,signal:We(o)}),Q=y.kind==="finding"&&y.runId!=null?V({config:u,debugDir:p,runId:y.runId}):Promise.resolve();return i(Q.then(()=>Je(p,zt)).catch(()=>{})),y}async function Qt(e){return(await Pl(e)).andThen(n=>n.unavailable!=null?Re(n.unavailable):n.lockfileJson==null?Re("empty-reply"):Il(n.lockfileJson))}async function Pl(e){try{return Qe(await e.sendRequest(Rn))}catch(r){return Re(`transport:${r instanceof Error?r.message:"unknown"}`)}}var xe;function Il(e){if(xe!==void 0&&xe.json===e)return Qe(xe.lockfile);try{let r=Ar(L(A,e));return xe={json:e,lockfile:r},Qe(r)}catch(r){return Re(`worker-decode-failed:${r instanceof Error?r.message.slice(0,200):"unknown"}`)}}async function Xt(){await Jt()}import{existsSync as Wl}from"fs";import Dl from"path";import{ok as Ul}from"neverthrow";import{gunzipSync as Al}from"zlib";import{mkdir as jl,writeFile as Tl}from"fs/promises";import Yt from"path";import{graphql as Ml}from"gql.tada";import{err as re,ok as Ll}from"neverthrow";var Nl=31,Ol=139;async function $e(e,r){let n=h(e).match(s=>s,s=>s.kind);if(typeof n=="string")return re({detail:n,kind:"config"});let t=await d({config:n,document:Fl,variables:{id:r}}).catch(()=>null);if(t==null)return re({kind:"request-failed"});if(t.run==null)return re({kind:"not-found"});if(t.run.behaviorUrl==null)return re({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return re({kind:"download-failed",status:o.status});let i=Yt.join(e,".ripplo","debug",r,"behavior.jsonl");return await jl(Yt.dirname(i),{recursive:!0}),await Tl(i,_l(Buffer.from(await o.arrayBuffer()))),Ll({path:i,runId:r})}var Fl=Ml(`
303
+ `),process.exit(1)}function hl(){let e=H();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=Se(e);O(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Kt(e.packages)}
304
+ `),cn(e.workspaceRoot)||O(Gt())}import W from"path";import Sl from"os";import{mkdtempSync as Cl,rmSync as xl}from"fs";import{err as Re,ok as Qe}from"neverthrow";import{z as Jt}from"zod";import{readdir as kl,rm as wl,stat as bl}from"fs/promises";import{existsSync as vl}from"fs";import ze from"path";async function Je(e,r){let t=(await kl(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||vl(ze.join(e,s,hr)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await bl(ze.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>wl(ze.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var Qt=50,Rl=15e3;async function Xt(){ie(w());let e=process.cwd(),r=U.child({worker:process.pid}),n=An(),t=Cl(W.join(Sl.tmpdir(),"ripplo-browser-cache-")),o=de({cacheDir:t,clientVersion:w(),debugDir:W.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)},Rl).unref(),El(i).then(()=>o.close().catch(()=>{})).then(()=>{xl(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(Rn,async(l,u)=>{let h=Sn.safeParse(l);if(!h.success)return Ce("bad-run-assign");let f=h.data;X(e);let p=y(e).match(S=>S,S=>S.kind);if(typeof p=="string")return Ce(`config:${p}`);let v=await Yt(n);if(v.isErr())return Ce(`lockfile-unavailable:${v.error}`);let E=v.value,F=V(E).find(S=>S.ref===f.testRef);if(F==null)return Ce(`no-test:${f.testRef}`);try{let{outcome:S,persisted:Te}=await Ln({config:p,cwd:e,errorSettle:"settle",fixturesDir:W.join(e,Y),headed:f.headed,lockfile:E,onPhase:void 0,runId:f.runId,session:o,signal:We(u),test:F.test}),mr=W.join(e,".ripplo","debug");return s(Promise.allSettled([Te]).then(()=>K({config:p,debugDir:mr,runId:f.runId})).then(()=>Je(mr,Qt)).catch(()=>{})),{outcome:vn(S),serverNotified:!0}}catch(S){let Te=W.join(e,".ripplo","debug");if(s(K({config:p,debugDir:Te,runId:f.runId}).catch(()=>{})),S instanceof fr)return{outcome:{detail:S.message,kind:"infra-error"},serverNotified:!1};throw S}}),n.onRequest(En,(l,u)=>Il({connection:n,cwd:e,raw:l,session:o,token:u,track:s})),n.onNotification(Pn,l=>{let u=Cn.safeParse(l);u.success&&o.injectSpan(u.data.runId,u.data.span)}),n.onNotification(In,()=>{a(0)}),n.sendNotification(xn),await new Promise(()=>{})}function Ce(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var $l=5e3;async function El(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,$l)})])}var Pl=Jt.object({assign:Jr,devSessionId:Jt.string().nullable()});async function Il({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=Pl.safeParse(n);if(!s.success)return{error:{source:"bad-assign"},kind:"error"};let{assign:a,devSessionId:l}=s.data;X(r);let u=y(r).match(F=>F,F=>F.kind);if(typeof u=="string")return{error:{detail:u,source:"config"},kind:"error"};let h=await Yt(e);if(h.isErr())return{error:{source:"lockfile-stale"},kind:"error"};let f=h.value,p=W.join(u.cwd,".ripplo","debug"),v=await Nn({assign:a,config:u,debugDir:p,devSessionId:l??void 0,fixturesDir:W.join(u.cwd,Y),headed:!1,lockfile:f,report:!0,session:t,signal:We(o)}),E=v.kind==="finding"&&v.runId!=null?K({config:u,debugDir:p,runId:v.runId}):Promise.resolve();return i(E.then(()=>Je(p,Qt)).catch(()=>{})),v}async function Yt(e){return(await Al(e)).andThen(n=>n.unavailable!=null?Re(n.unavailable):n.lockfileJson==null?Re("empty-reply"):jl(n.lockfileJson))}async function Al(e){try{return Qe(await e.sendRequest($n))}catch(r){return Re(`transport:${r instanceof Error?r.message:"unknown"}`)}}var xe;function jl(e){if(xe!==void 0&&xe.json===e)return Qe(xe.lockfile);try{let r=jr(L(A,e));return xe={json:e,lockfile:r},Qe(r)}catch(r){return Re(`worker-decode-failed:${r instanceof Error?r.message.slice(0,200):"unknown"}`)}}async function Zt(){await Xt()}import{existsSync as Ul}from"fs";import Bl from"path";import{ok as ql}from"neverthrow";import{gunzipSync as Tl}from"zlib";import{mkdir as Ml,writeFile as Ll}from"fs/promises";import eo from"path";import{graphql as Nl}from"gql.tada";import{err as re,ok as Ol}from"neverthrow";var Fl=31,_l=139;async function $e(e,r){let n=y(e).match(s=>s,s=>s.kind);if(typeof n=="string")return re({detail:n,kind:"config"});let t=await d({config:n,document:Wl,variables:{id:r}}).catch(()=>null);if(t==null)return re({kind:"request-failed"});if(t.run==null)return re({kind:"not-found"});if(t.run.behaviorUrl==null)return re({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return re({kind:"download-failed",status:o.status});let i=eo.join(e,".ripplo","debug",r,"behavior.jsonl");return await Ml(eo.dirname(i),{recursive:!0}),await Ll(i,Dl(Buffer.from(await o.arrayBuffer()))),Ol({path:i,runId:r})}var Wl=Nl(`
305
305
  query RunBehaviorUrl($id: String!) {
306
306
  run(id: $id) {
307
307
  id
308
308
  behaviorUrl
309
309
  }
310
310
  }
311
- `);function _l(e){return e[0]===Nl&&e[1]===Ol?Al(e):e}async function G(e,r){let n=Dl.join(e,".ripplo","debug",r,"behavior.jsonl");return Wl(n)?Ul(void 0):(await $e(e,r)).map(()=>{})}import{existsSync as eo,readFileSync as ro}from"fs";import no from"path";import{err as Bl,ok as ql}from"neverthrow";import{z as Xe}from"zod";var Ye=" \u203A ",Vl=4e3,Hl=5;async function to(e,r){let n=no.join(e,".ripplo","debug",r,"behavior.jsonl");if(!eo(n))return Bl({kind:"run-not-found",runId:r});let t=Kl(ro(n,"utf8")),o=md(e),i=o==null?[]:await qr(o),s=[...t.failedChecks.map(a=>Xl({check:a,facts:i,lockfile:o,run:t})),...t.stepErrors.map(a=>nd({event:a,run:t})),...t.findings.map(a=>td({event:a,run:t}))];return ql({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,runId:r,viewport:t.viewport})}function Kl(e){let r=e.split(`
312
- `).filter(a=>a.trim().length>0).flatMap(a=>{let l=M(a);return l==null?[]:[l]}),n=r.filter(a=>a.kind==="check"&&a.outcome.kind==="failed"),t=r.filter(a=>a.kind==="stepError"),o=r.filter(a=>a.kind==="finding"),i=r.flatMap(a=>Jl(a)),s=r.map(a=>F(a.timeNanos));return{causes:i,failedChecks:n,findings:o,firstTs:s.length===0?0:Math.min(...s),lastTs:s.length===0?0:Math.max(...s),stepErrors:t,stepTitles:new Map(r.flatMap(a=>a.kind==="step"?[[a.stepIndex,a.title]]:[])),viewport:zl(r)}}var Gl=Xe.object({height:Xe.number(),width:Xe.number()});function zl(e){return e.flatMap(r=>{if(r.kind!=="rrweb"||r.event.type!==4)return[];let n=Gl.safeParse(r.event.data);return n.success?[n.data]:[]})[0]}function Jl(e){let r=Ql(e);return r==null?[]:[{detail:r,timestamp:F(e.timeNanos)}]}function Ql(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 Xl({check:e,facts:r,lockfile:n,run:t}){let o=F(e.timeNanos),i=Yl(e.origin),s=t.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:Ze(t.causes,o),label:Zl(e),outcome:"failed",pending:void 0,ruleKind:i,rules:id({check:oo(e),facts:r,lockfile:n,ruleKind:i,subjectKey:rd(e)}),runWorkflow:s.split(Ye)[0]??s,snapshotAt:o,step:s,wait:void 0,waitMs:e.waitedMs}}function Yl(e){switch(e.kind){case"fact":return"fact";case"dataRule":return"data-rule";case"step":return"step"}}function Zl(e){let r=Pr(e);return r??`${e.family} ${oo(e)}: ${e.outcome.kind}`}function oo(e){switch(e.family){case"element":case"content":case"scalar":case"state":case"action":return e.subject;case"frame":return ed(e);case"dataRule":return e.rule}}function ed(e){if(e.outcome.kind==="passed")return e.family;let r=e.outcome.reason;return r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent"?r.subject:r.kind==="wrongCount"?r.entity:`${r.entity} [${r.key}]`}function rd(e){if(e.family==="scalar")return e.subjectKey;if(e.family!=="frame"||e.outcome.kind!=="failed")return;let r=e.outcome.reason;if(r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent")return r.subjectKey}function nd({event:e,run:r}){let n=F(e.timeNanos),t=r.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:Ze(r.causes,n),label:`driver ${e.error.kind}`,outcome:"error",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:t.split(Ye)[0]??t,snapshotAt:n,step:t,wait:void 0,waitMs:void 0}}function td({event:e,run:r}){let n=F(e.timeNanos);return{browserMismatch:void 0,causes:Ze(r.causes,n),label:od(e.payload),outcome:"failed",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:e.step.split(Ye)[0]??e.step,snapshotAt:n,step:e.step,wait:void 0,waitMs:void 0}}function od(e){switch(e.kind){case"unrunnable":return e.unmet==null?`${e.kind} ${e.reason}`:`${e.kind} ${e.reason}: ${e.unmet}`;case"impossibleAction":return`${e.kind} ${e.action}`;case"liftVisibility":return`${e.kind} ${e.subject}`}}function id({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>sd({check:e,rule:i,subjectKey:o})).map(i=>({consequence:Ne(i.consequence),origins:ad(i.origin,n),provenance:ud(i.origin),url:Ur(i.when),when:Br(i.when)}))}function sd({check:e,rule:r,subjectKey:n}){return n!=null?Vr(r)===n:Ne(r.consequence)===e}function ad(e,r){let n=B(r),t=ld(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return dd(t)}function ld(e){return e==null?[]:e.kind==="declared"?[]:e.kind==="generalized"?Hr(e):[e.test]}function dd(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function ud(e){return e!=null&&e.kind==="generalized"?"learned":"inferred"}function Ze(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Vl).toSorted((t,o)=>o.timestamp-t.timestamp);return cd(n).toSorted((t,o)=>Number(Zt(o.detail))-Number(Zt(t.detail))).slice(0,Hl).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function cd(e){return e.reduce((r,n)=>{let t=pd(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function pd(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 md(e){let r=no.join(e,".ripplo","ripplo.lock");if(!eo(r))return null;try{return L(A,ro(r,"utf8"))}catch{return null}}import{existsSync as io,readFileSync as so}from"fs";import ao from"path";import{graphql as fd}from"gql.tada";async function lo(e,r,n){let t=yd(e),o=t==null?void 0:await hd(n,r,t);return{timeline:gd(Cd(e,r)),world:o}}function gd(e){return e.filter(r=>r.kind==="step").toSorted((r,n)=>r.stepIndex-n.stepIndex).map(r=>bd(r,e))}function yd(e){let r=ao.join(e,".ripplo","ripplo.lock");return io(r)?L(A,so(r,"utf8")):null}async function hd(e,r,n){let t=await d({config:e,document:xd,variables:{id:r}}).catch(()=>null);if(t?.run==null)return;let o=kd(t.run);return o!=null?B(n).find(i=>i.ref===o)?.test:wd(n,t.run.reproJson)}function kd(e){let r=e.workflow?.slug,n=e.test?.slug;return r==null||n==null?void 0:`${r}/${n}`}function wd(e,r){if(r==null)return;let n=le.parse(JSON.parse(r));return Jr(e,{sweep:!0}).find(t=>t.name===n.baseStateRef)?.test}function bd(e,r){let n=r.filter(i=>i.kind==="check"&&i.stepIndex===e.stepIndex),t=r.filter(i=>i.kind==="stepError"&&i.stepIndex===e.stepIndex),o=r.filter(i=>i.kind==="finding"&&i.stepIndex===e.stepIndex);return{changes:[...e.stateRows.flatMap(i=>vd(i)),...e.stateSingletons.flatMap(i=>Sd(i))],checksHeld:n.filter(i=>i.outcome.kind==="passed").length,failures:[...n.filter(i=>i.outcome.kind==="failed").map(i=>({event:i,kind:"check"})),...t.map(i=>({event:i,kind:"stepError"})),...o.map(i=>({kind:"finding",payload:i.payload}))],index:e.stepIndex,title:e.title,url:e.pageUrl,workflow:e.sourceTest}}function vd(e){return e.status==="present"?[]:[`${e.status} ${e.entity} ${e.key}`]}function Sd(e){return e.changed?[`${e.name} = ${e.value??"\u2205"}`]:[]}function Cd(e,r){let n=ao.join(e,".ripplo","debug",r,"behavior.jsonl");return io(n)?so(n,"utf8").split(`
313
- `).filter(t=>t.trim().length>0).flatMap(t=>{let o=M(t);return o==null?[]:[o]}):[]}var xd=fd(`
311
+ `);function Dl(e){return e[0]===Fl&&e[1]===_l?Tl(e):e}async function J(e,r){let n=Bl.join(e,".ripplo","debug",r,"behavior.jsonl");return Ul(n)?ql(void 0):(await $e(e,r)).map(()=>{})}import{existsSync as no,readFileSync as to}from"fs";import oo from"path";import{err as Vl,ok as Hl}from"neverthrow";import{z as Xe}from"zod";var Ye=" \u203A ",Kl=4e3,Gl=5;async function io(e,r){let n=oo.join(e,".ripplo","debug",r,"behavior.jsonl");if(!no(n))return Vl({kind:"run-not-found",runId:r});let t=zl(to(n,"utf8")),o=gd(e),i=o==null?[]:await Vr(o),s=[...t.failedChecks.map(a=>Zl({check:a,facts:i,lockfile:o,run:t})),...t.stepErrors.map(a=>od({event:a,run:t})),...t.findings.map(a=>id({event:a,run:t}))];return Hl({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,runId:r,viewport:t.viewport})}function zl(e){let r=e.split(`
312
+ `).filter(a=>a.trim().length>0).flatMap(a=>{let l=M(a);return l==null?[]:[l]}),n=r.filter(a=>a.kind==="check"&&a.outcome.kind==="failed"),t=r.filter(a=>a.kind==="stepError"),o=r.filter(a=>a.kind==="finding"),i=r.flatMap(a=>Xl(a)),s=r.map(a=>_(a.timeNanos));return{causes:i,failedChecks:n,findings:o,firstTs:s.length===0?0:Math.min(...s),lastTs:s.length===0?0:Math.max(...s),stepErrors:t,stepTitles:new Map(r.flatMap(a=>a.kind==="step"?[[a.stepIndex,a.title]]:[])),viewport:Ql(r)}}var Jl=Xe.object({height:Xe.number(),width:Xe.number()});function Ql(e){return e.flatMap(r=>{if(r.kind!=="rrweb"||r.event.type!==4)return[];let n=Jl.safeParse(r.event.data);return n.success?[n.data]:[]})[0]}function Xl(e){let r=Yl(e);return r==null?[]:[{detail:r,timestamp:_(e.timeNanos)}]}function Yl(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 Zl({check:e,facts:r,lockfile:n,run:t}){let o=_(e.timeNanos),i=ed(e.origin),s=t.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:Ze(t.causes,o),label:rd(e),outcome:"failed",pending:void 0,ruleKind:i,rules:ad({check:so(e),facts:r,lockfile:n,ruleKind:i,subjectKey:td(e)}),runWorkflow:s.split(Ye)[0]??s,snapshotAt:o,step:s,wait:void 0,waitMs:e.waitedMs}}function ed(e){switch(e.kind){case"fact":return"fact";case"dataRule":return"data-rule";case"step":return"step"}}function rd(e){let r=Ir(e);return r??`${e.family} ${so(e)}: ${e.outcome.kind}`}function so(e){switch(e.family){case"element":case"content":case"scalar":case"state":case"action":return e.subject;case"frame":return nd(e);case"dataRule":return e.rule}}function nd(e){if(e.outcome.kind==="passed")return e.family;let r=e.outcome.reason;return r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent"?r.subject:r.kind==="wrongCount"?r.entity:`${r.entity} [${r.key}]`}function td(e){if(e.family==="scalar")return e.subjectKey;if(e.family!=="frame"||e.outcome.kind!=="failed")return;let r=e.outcome.reason;if(r.kind==="wrongScalar"||r.kind==="wrongElementState"||r.kind==="wrongElementContent")return r.subjectKey}function od({event:e,run:r}){let n=_(e.timeNanos),t=r.stepTitles.get(e.stepIndex)??String(e.stepIndex);return{browserMismatch:void 0,causes:Ze(r.causes,n),label:`driver ${e.error.kind}`,outcome:"error",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:t.split(Ye)[0]??t,snapshotAt:n,step:t,wait:void 0,waitMs:void 0}}function id({event:e,run:r}){let n=_(e.timeNanos);return{browserMismatch:void 0,causes:Ze(r.causes,n),label:sd(e.payload),outcome:"failed",pending:void 0,ruleKind:"unknown",rules:[],runWorkflow:e.step.split(Ye)[0]??e.step,snapshotAt:n,step:e.step,wait:void 0,waitMs:void 0}}function sd(e){switch(e.kind){case"unrunnable":return e.unmet==null?`${e.kind} ${e.reason}`:`${e.kind} ${e.reason}: ${e.unmet}`;case"impossibleAction":return`${e.kind} ${e.action}`;case"liftVisibility":return`${e.kind} ${e.subject}`}}function ad({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>ld({check:e,rule:i,subjectKey:o})).map(i=>({consequence:Ne(i.consequence),origins:dd(i.origin,n),provenance:pd(i.origin),url:Br(i.when),when:qr(i.when)}))}function ld({check:e,rule:r,subjectKey:n}){return n!=null?Hr(r)===n:Ne(r.consequence)===e}function dd(e,r){let n=V(r),t=ud(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return cd(t)}function ud(e){return e==null?[]:e.kind==="declared"?[]:e.kind==="generalized"?Kr(e):[e.test]}function cd(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function pd(e){return e!=null&&e.kind==="generalized"?"learned":"inferred"}function Ze(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Kl).toSorted((t,o)=>o.timestamp-t.timestamp);return md(n).toSorted((t,o)=>Number(ro(o.detail))-Number(ro(t.detail))).slice(0,Gl).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function md(e){return e.reduce((r,n)=>{let t=fd(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function fd(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 ro(e){return e.kind==="network"?e.status>=400:e.kind==="span"?e.statusCode==="error":!0}function gd(e){let r=oo.join(e,".ripplo","ripplo.lock");if(!no(r))return null;try{return L(A,to(r,"utf8"))}catch{return null}}import{existsSync as ao,readFileSync as lo}from"fs";import uo from"path";import{graphql as yd}from"gql.tada";async function co(e,r,n){let t=kd(e),o=t==null?void 0:await wd(n,r,t);return{timeline:hd(Rd(e,r)),world:o}}function hd(e){return e.filter(r=>r.kind==="step").toSorted((r,n)=>r.stepIndex-n.stepIndex).map(r=>Sd(r,e))}function kd(e){let r=uo.join(e,".ripplo","ripplo.lock");return ao(r)?L(A,lo(r,"utf8")):null}async function wd(e,r,n){let t=await d({config:e,document:$d,variables:{id:r}}).catch(()=>null);if(t?.run==null)return;let o=bd(t.run);return o!=null?V(n).find(i=>i.ref===o)?.test:vd(n,t.run.reproJson)}function bd(e){let r=e.workflow?.slug,n=e.test?.slug;return r==null||n==null?void 0:`${r}/${n}`}function vd(e,r){if(r==null)return;let n=le.parse(JSON.parse(r));return Qr(e,{sweep:!0}).find(t=>t.name===n.baseStateRef)?.test}function Sd(e,r){let n=r.filter(i=>i.kind==="check"&&i.stepIndex===e.stepIndex),t=r.filter(i=>i.kind==="stepError"&&i.stepIndex===e.stepIndex),o=r.filter(i=>i.kind==="finding"&&i.stepIndex===e.stepIndex);return{changes:[...e.stateRows.flatMap(i=>Cd(i)),...e.stateSingletons.flatMap(i=>xd(i))],checksHeld:n.filter(i=>i.outcome.kind==="passed").length,failures:[...n.filter(i=>i.outcome.kind==="failed").map(i=>({event:i,kind:"check"})),...t.map(i=>({event:i,kind:"stepError"})),...o.map(i=>({kind:"finding",payload:i.payload}))],index:e.stepIndex,title:e.title,url:e.pageUrl,workflow:e.sourceTest}}function Cd(e){return e.status==="present"?[]:[`${e.status} ${e.entity} ${e.key}`]}function xd(e){return e.changed?[`${e.name} = ${e.value??"\u2205"}`]:[]}function Rd(e,r){let n=uo.join(e,".ripplo","debug",r,"behavior.jsonl");return ao(n)?lo(n,"utf8").split(`
313
+ `).filter(t=>t.trim().length>0).flatMap(t=>{let o=M(t);return o==null?[]:[o]}):[]}var $d=yd(`
314
314
  query ExplainRunTest($id: String!) {
315
315
  run(id: $id) {
316
316
  id
@@ -325,41 +325,51 @@ ${e.detail}`:""}`}function Ut(){process.stdout.write(`${Wt()}
325
325
  }
326
326
  }
327
327
  }
328
- `);var uo=" \u203A ",Rd=["fact ","data rule ","step "];function mo(e){if(e.failures.length===0)return`${c.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?[]:[c.dim("(no lockfile \u2014 provenance unavailable)")],o=$d(e.failures).map(i=>Ed(i,e.runId));return[n,...t,"",...o,C("tasks")].join(`
329
- `)}function fo(e){return`${c.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function $d(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function Ed(e,r){let n=e.failures[0];if(n==null)return"";let t=Pd(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>yo(s.label)))].join(", "),i=c.dim(`(${n.runWorkflow})`);return[`${c.bad("\u2717")} ${Ad(e.step)} ${i}`,` ${c.dim("failed")} ${o}`,...jd(e),...Od(n),...Fd(n.causes),` ${c.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
330
- `)}function Pd(e,r){let n=e.failures[0],t=e.failures.flatMap(u=>u.browserMismatch==null?[]:[u.browserMismatch])[0],o=go(e.failures.flatMap(u=>u.rules));if(n==null||t==null||o.length===0)return null;let i=yo(e.failures.find(u=>u.rules.length>0)?.label??n.label),s=[...new Set(o.map(u=>u.url))].join(", "),a=c.dim(`(${n.runWorkflow})`);return[`${c.bad("\u2717")} ${i} ${c.warn("(wrong page)")} ${a}`,` ${c.dim("rule learned for url")} ${s}`,` ${c.dim("browser was actually at")} ${t.actual}`,` ${c.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${c.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
331
- `)}function go(e){let r=e.map(n=>[Id(n),n]);return[...new Map(r).values()]}function Id(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function yo(e){let r=Rd.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function Ad(e){let r=e.split(uo);return r.length<2?e:r.slice(1).join(uo)}function jd(e){let r=go(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>Td(n)),...Nd(e,r)]}function Td(e){let r=e.origins.length===0?c.dim("origin not in lockfile"):e.origins.map(n=>Md(n)).join(", ");return[` ${c.dim(Ld(e.provenance))}`,` ${c.dim("from")} ${r}`,` ${c.dim("at")} ${e.url} ${c.dim("\u2014 holds only when")} ${e.when}`]}function Md(e){if(e.sourcePath==null)return e.intent;let r=c.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function Ld(e){return e==="learned"?"learned \u2014 kept only the conditions these flows share":"inferred \u2014 from a flow that reaches this state"}function Nd(e,r){let n=new Set(r.flatMap(o=>o.origins.map(i=>i.intent)));return e.failures.some(o=>n.has(o.runWorkflow))||n.size===0?[]:[` ${c.warn("\u21B3 learned from another flow \u2014 likely a fact scoped too broadly")}`]}function Od(e){if(e.waitMs==null||e.wait==null)return[];let r=`${String(Math.round(e.waitMs/1e3))}s`,n=e.pending===!0?" \u2014 value never changed (write may be slow or dropped)":"";return[` ${c.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function Fd(e){if(e.length===0)return[];let r=_d(e),n=e.flatMap(t=>Wd(t,r));return n.length===0?[]:[` ${c.dim("nearby")} ${n.join(" \xB7 ")}`]}function _d(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 ${er(t)}`;return[po(n,`${er(n)}${o}`)]}return[po(n,er(n))]}function er(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${Dd(e.url)}`:e.kind==="console"?`console.${e.level} ${co(e.text)}`:e.kind==="error"?`error ${co(e.message)}`:`span ${e.name} ${e.statusCode} ${String(Math.round(e.durationMs))}ms`}function Dd(e){let r=e.split("?")[0]??e;return r.length>60?`\u2026${r.slice(-57)}`:r}function co(e){let r=e.replaceAll(/\s+/g," ").trim();return r.length>100?`${r.slice(0,97)}\u2026`:r}function po(e,r){return Ud(e)?c.bad(r):r}function Ud(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function ho(e){return[Bd(e.world),"",Kd(e.factOrigins),Gd(e.timeline,e.factOrigins)].filter(r=>r.length>0).join(`
332
- `)}function Bd(e){return e==null?c.dim("world (couldn't resolve the run's test \u2014 offline, or it left the model)"):["world the model set up",...[...e.world.map(n=>` - ${qd(n)}`),...e.absent.map(n=>` - ${Vd(n)}`),...Object.entries(e.singletons).map(([n,t])=>` - ${n} = ${wo(t)}`),` - actor: ${Hd(e)}`]].join(`
333
- `)}function qd(e){return`${e.entity} as ${e.as} ${c.dim(ko(e.set))}`}function ko(e){return`{ ${Object.entries(e).map(([n,t])=>`${n}: ${wo(t)}`).join(", ")} }`}function wo(e){return e==null?"\u2205":typeof e=="object"?"ref"in e?`\u2192${e.ref}`:JSON.stringify(e):String(e)}function Vd(e){return`no ${e.entity} where ${c.dim(ko(e.where))}`}function Hd(e){return e.actor.kind==="user"?`signed in as ${e.actor.alias}`:"signed out"}function Kd(e){return e.length===0?"":["facts checked here were declared in",...e.map(n=>` - ${n}`),""].join(`
334
- `)}function Gd(e,r){return e.length===0?c.dim("timeline (no steps captured)"):["what happened, step by step",...e.map(t=>zd(t,r))].join(`
335
- `)}function zd(e,r){let n=` ${String(e.index+1)}. ${e.title}${Jd(e.workflow)}${Qd(e.url)}`,t=e.changes.length===0?[]:[` \u0394 ${e.changes.join(", ")}`],o=e.failures.map(s=>` ${c.bad("\u2717")} ${Xd(s,r)}`),i=e.checksHeld===0?[]:[c.dim(` ${String(e.checksHeld)} checks held`)];return[n,...t,...o,...i].join(`
336
- `)}function Jd(e){if(e==null)return"";let r=`(${e})`;return` ${c.dim(r)}`}function Qd(e){if(e==null)return"";let r=`@ ${e}`;return` ${c.dim(r)}`}function Xd(e,r){switch(e.kind){case"check":{let n=e.event.origin.kind==="fact"?Yd(r):"";return`${Gr(e.event)}${n}`}case"stepError":return`driver error \u2014 ${ae(e.event.error)}`;case"finding":return Zd(e.payload)}}function Yd(e){if(e.length===0)return"";let r=`(fact from ${e.join(", ")})`;return` ${c.dim(r)}`}function Zd(e){switch(e.kind){case"unrunnable":{let r=e.unmet==null?"":`: needs ${e.unmet}`;return`couldn't run \u2014 ${e.reason}${r}`}case"impossibleAction":return`impossible action: ${e.action} on ${e.subject}`;case"liftVisibility":{let r=String(e.visibleIndex+1),n=String(e.declaredIndex+1);return`${e.subject} visible by step ${r} but declared at step ${n}`}}}function bo(e){return`Saved behavior.jsonl to ${e.path}`}function z(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 vo({full:e,json:r,runId:n}){let t=process.cwd(),o=await G(t,n);o.isErr()&&(process.stderr.write(`${z(o.error)}
337
- `),process.exit(1));let i=await to(t,n);i.isErr()&&(process.stderr.write(`${fo(i.error)}
338
- `),process.exit(1));let s=i.value;process.stdout.write(`${r?JSON.stringify(s,null,2):mo(s)}
339
- `),e&&!r&&await eu(t,n,ru(s))}async function eu(e,r,n){let t=h(e).unwrapOr(void 0);if(t==null)return;let o=await lo(e,r,t);process.stdout.write(`
340
- ${ho({...o,factOrigins:n})}
341
- `)}function ru(e){let r=e.failures.filter(n=>n.ruleKind==="fact").flatMap(n=>n.rules).flatMap(n=>n.origins).map(n=>n.sourcePath==null?n.intent:`${n.intent} (${n.sourcePath})`);return[...new Set(r)]}async function So({runId:e}){(await $e(process.cwd(),e)).match(n=>{process.stdout.write(`${bo(n)}
342
- `)},n=>{process.stderr.write(`${z(n)}
343
- `),process.exit(1)})}import{randomUUID as nu}from"crypto";import{existsSync as tu,readFileSync as ou}from"fs";import rr from"path";import{graphql as xo}from"gql.tada";import{err as J,ok as Co}from"neverthrow";async function Ro(e,r,n){let t=h(e).match(y=>y,y=>y.kind);if(typeof t=="string")return J({detail:t,kind:"config"});let o=await Nr(e);if(o.result.isErr())return J({kind:"compile-failed"});let i=await d({config:t,document:au,variables:{id:r}}).catch(()=>null);if(i==null)return J({kind:"request-failed"});if(i.run==null)return J({kind:"not-found"});let s=i.run.reproJson;if(s==null)return J({kind:"no-repro"});let a=le.parse(JSON.parse(s)),l=await ce(e,o.result.value),u=`replay-${nu()}`,w=rr.join(e,".ripplo","debug"),f=[],p=de({cacheDir:void 0,clientVersion:b(),debugDir:w,headed:!1,writeOtlpPortFile:!1});try{let y=await Yr({capture:!0,lockfile:l,options:{baseUrl:t.appUrl,engineUrl:t.engineUrl,fixturesDir:rr.join(e,Y),generate:Er,headed:!1,secret:t.webhookSecret},repro:a,runId:u,session:p,signal:n,onEvent:E=>{f.push(E)}});return(await iu({config:t,debugDir:w,events:f,outcome:y,replayRunId:u,reproJson:s,stepSources:a.steps.map(E=>E.test)})).map(()=>({outcome:y,recordingCaptured:su(w,u),replayRunId:u}))}finally{await p.close()}}async function iu({config:e,debugDir:r,events:n,outcome:t,replayRunId:o,reproJson:i,stepSources:s}){if(t.kind!=="resolved"&&t.kind!=="still-fails")return Co(void 0);try{return await d({config:e,document:lu,variables:{projectId:e.projectId,reproJson:i,runId:o}}),await An({config:e,debugDir:r,events:n,recordingOptional:!0,runId:o,stepSources:s}),await V({config:e,debugDir:r,runId:o}),Co(void 0)}catch{return J({kind:"report-failed"})}}function su(e,r){let n=rr.join(e,r,"behavior.jsonl");return tu(n)?ou(n,"utf8").split(`
344
- `).some(t=>t.includes('"kind":"rrweb"')):!1}var au=xo(`
328
+ `);var po=" \u203A ",Ed=["fact ","data rule ","step "];function go(e){if(e.failures.length===0)return`${c.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 ${$(e.failures.length,"failing check")}${r}`,t=e.lockfileLoaded?[]:[c.dim("(no lockfile \u2014 provenance unavailable)")],o=Pd(e.failures).map(i=>Id(i,e.runId));return[n,...t,"",...o,x("tasks")].join(`
329
+ `)}function yo(e){return`${c.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function Pd(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function Id(e,r){let n=e.failures[0];if(n==null)return"";let t=Ad(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>ko(s.label)))].join(", "),i=c.dim(`(${n.runWorkflow})`);return[`${c.bad("\u2717")} ${Td(e.step)} ${i}`,` ${c.dim("failed")} ${o}`,...Md(e),..._d(n),...Wd(n.causes),` ${c.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
330
+ `)}function Ad(e,r){let n=e.failures[0],t=e.failures.flatMap(u=>u.browserMismatch==null?[]:[u.browserMismatch])[0],o=ho(e.failures.flatMap(u=>u.rules));if(n==null||t==null||o.length===0)return null;let i=ko(e.failures.find(u=>u.rules.length>0)?.label??n.label),s=[...new Set(o.map(u=>u.url))].join(", "),a=c.dim(`(${n.runWorkflow})`);return[`${c.bad("\u2717")} ${i} ${c.warn("(wrong page)")} ${a}`,` ${c.dim("rule learned for url")} ${s}`,` ${c.dim("browser was actually at")} ${t.actual}`,` ${c.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${c.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
331
+ `)}function ho(e){let r=e.map(n=>[jd(n),n]);return[...new Map(r).values()]}function jd(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function ko(e){let r=Ed.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function Td(e){let r=e.split(po);return r.length<2?e:r.slice(1).join(po)}function Md(e){let r=ho(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>Ld(n)),...Fd(e,r)]}function Ld(e){let r=e.origins.length===0?c.dim("origin not in lockfile"):e.origins.map(n=>Nd(n)).join(", ");return[` ${c.dim(Od(e.provenance))}`,` ${c.dim("from")} ${r}`,` ${c.dim("at")} ${e.url} ${c.dim("\u2014 holds only when")} ${e.when}`]}function Nd(e){if(e.sourcePath==null)return e.intent;let r=c.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function Od(e){return e==="learned"?"learned \u2014 kept only the conditions these flows share":"inferred \u2014 from a flow that reaches this state"}function Fd(e,r){let n=new Set(r.flatMap(o=>o.origins.map(i=>i.intent)));return e.failures.some(o=>n.has(o.runWorkflow))||n.size===0?[]:[` ${c.warn("\u21B3 learned from another flow \u2014 likely a fact scoped too broadly")}`]}function _d(e){if(e.waitMs==null||e.wait==null)return[];let r=`${String(Math.round(e.waitMs/1e3))}s`,n=e.pending===!0?" \u2014 value never changed (write may be slow or dropped)":"";return[` ${c.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function Wd(e){if(e.length===0)return[];let r=Dd(e),n=e.flatMap(t=>Ud(t,r));return n.length===0?[]:[` ${c.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 ${er(t)}`;return[fo(n,`${er(n)}${o}`)]}return[fo(n,er(n))]}function er(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${Bd(e.url)}`:e.kind==="console"?`console.${e.level} ${mo(e.text)}`:e.kind==="error"?`error ${mo(e.message)}`:`span ${e.name} ${e.statusCode} ${String(Math.round(e.durationMs))}ms`}function Bd(e){let r=e.split("?")[0]??e;return r.length>60?`\u2026${r.slice(-57)}`:r}function mo(e){let r=e.replaceAll(/\s+/g," ").trim();return r.length>100?`${r.slice(0,97)}\u2026`:r}function fo(e,r){return qd(e)?c.bad(r):r}function qd(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function wo(e){return[Vd(e.world),"",zd(e.factOrigins),Jd(e.timeline,e.factOrigins)].filter(r=>r.length>0).join(`
332
+ `)}function Vd(e){return e==null?c.dim("world (couldn't resolve the run's test \u2014 offline, or it left the model)"):["world the model set up",...[...e.world.map(n=>` - ${Hd(n)}`),...e.absent.map(n=>` - ${Kd(n)}`),...Object.entries(e.singletons).map(([n,t])=>` - ${n} = ${vo(t)}`),` - actor: ${Gd(e)}`]].join(`
333
+ `)}function Hd(e){return`${e.entity} as ${e.as} ${c.dim(bo(e.set))}`}function bo(e){return`{ ${Object.entries(e).map(([n,t])=>`${n}: ${vo(t)}`).join(", ")} }`}function vo(e){return e==null?"\u2205":typeof e=="object"?"ref"in e?`\u2192${e.ref}`:JSON.stringify(e):String(e)}function Kd(e){return`no ${e.entity} where ${c.dim(bo(e.where))}`}function Gd(e){return e.actor.kind==="user"?`signed in as ${e.actor.alias}`:"signed out"}function zd(e){return e.length===0?"":["facts checked here were declared in",...e.map(n=>` - ${n}`),""].join(`
334
+ `)}function Jd(e,r){return e.length===0?c.dim("timeline (no steps captured)"):["what happened, step by step",...e.map(t=>Qd(t,r))].join(`
335
+ `)}function Qd(e,r){let n=` ${String(e.index+1)}. ${e.title}${Xd(e.workflow)}${Yd(e.url)}`,t=e.changes.length===0?[]:[` \u0394 ${e.changes.join(", ")}`],o=e.failures.map(s=>` ${c.bad("\u2717")} ${Zd(s,r)}`),i=e.checksHeld===0?[]:[c.dim(` ${String(e.checksHeld)} checks held`)];return[n,...t,...o,...i].join(`
336
+ `)}function Xd(e){if(e==null)return"";let r=`(${e})`;return` ${c.dim(r)}`}function Yd(e){if(e==null)return"";let r=`@ ${e}`;return` ${c.dim(r)}`}function Zd(e,r){switch(e.kind){case"check":{let n=e.event.origin.kind==="fact"?eu(r):"";return`${zr(e.event)}${n}`}case"stepError":return`driver error \u2014 ${ae(e.event.error)}`;case"finding":return ru(e.payload)}}function eu(e){if(e.length===0)return"";let r=`(fact from ${e.join(", ")})`;return` ${c.dim(r)}`}function ru(e){switch(e.kind){case"unrunnable":{let r=e.unmet==null?"":`: needs ${e.unmet}`;return`couldn't run \u2014 ${e.reason}${r}`}case"impossibleAction":return`impossible action: ${e.action} on ${e.subject}`;case"liftVisibility":{let r=String(e.visibleIndex+1),n=String(e.declaredIndex+1);return`${e.subject} visible by step ${r} but declared at step ${n}`}}}function So(e){return`Saved behavior.jsonl to ${e.path}`}function Q(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 Co({full:e,json:r,runId:n}){let t=process.cwd(),o=await J(t,n);o.isErr()&&(process.stderr.write(`${Q(o.error)}
337
+ `),process.exit(1));let i=await io(t,n);i.isErr()&&(process.stderr.write(`${yo(i.error)}
338
+ `),process.exit(1));let s=i.value;process.stdout.write(`${r?JSON.stringify(s,null,2):go(s)}
339
+ `),e&&!r&&await nu(t,n,tu(s))}async function nu(e,r,n){let t=y(e).unwrapOr(void 0);if(t==null)return;let o=await co(e,r,t);process.stdout.write(`
340
+ ${wo({...o,factOrigins:n})}
341
+ `)}function tu(e){let r=e.failures.filter(n=>n.ruleKind==="fact").flatMap(n=>n.rules).flatMap(n=>n.origins).map(n=>n.sourcePath==null?n.intent:`${n.intent} (${n.sourcePath})`);return[...new Set(r)]}async function xo({runId:e}){(await $e(process.cwd(),e)).match(n=>{process.stdout.write(`${So(n)}
342
+ `)},n=>{process.stderr.write(`${Q(n)}
343
+ `),process.exit(1)})}import{randomUUID as ou}from"crypto";import{existsSync as iu,readFileSync as su}from"fs";import rr from"path";import{graphql as $o}from"gql.tada";import{err as D,ok as Ro}from"neverthrow";async function Eo(e,r,n){let t=y(e).match(E=>E,E=>E.kind);if(typeof t=="string")return D({detail:t,kind:"config"});let o=await Or(e);if(o.result.isErr())return D({kind:"compile-failed"});let i=await d({config:t,document:du,variables:{id:r}}).catch(()=>null);if(i==null)return D({kind:"request-failed"});if(i.run==null)return D({kind:"not-found"});let s=i.run.reproJson;if(s==null)return D({kind:"no-repro"});let a=le.parse(JSON.parse(s)),l=await ce(e,o.result.value),u=await Tn(e);if(u==null)return D({kind:"compile-failed"});await jn({config:t,cwd:e,lockfile:l});let h=`replay-${ou()}`,f=rr.join(e,".ripplo","debug"),p=[],v=de({cacheDir:void 0,clientVersion:w(),debugDir:f,headed:!1,writeOtlpPortFile:!1});try{let E=await Zr({capture:!0,lockfile:l,options:{baseUrl:t.appUrl,engineUrl:t.engineUrl,fixturesDir:rr.join(e,Y),generate:Pr,headed:!1,secret:t.webhookSecret},repro:a,runId:h,session:v,signal:n,onEvent:S=>{p.push(S)}});return(await au({config:t,debugDir:f,events:p,lockfileHash:u,outcome:E,replayRunId:h,reproJson:s,stepSources:a.steps.map(S=>S.test)})).map(()=>({outcome:E,recordingCaptured:lu(f,h),replayRunId:h}))}finally{await v.close()}}async function au({config:e,debugDir:r,events:n,lockfileHash:t,outcome:o,replayRunId:i,reproJson:s,stepSources:a}){if(o.kind!=="resolved"&&o.kind!=="still-fails")return Ro(void 0);try{return await d({config:e,document:uu,variables:{lockfileHash:t,projectId:e.projectId,reproJson:s,runId:i}}),await Mn({config:e,debugDir:r,events:n,recordingOptional:!0,runId:i,stepSources:a}),await K({config:e,debugDir:r,runId:i}),Ro(void 0)}catch{return D({kind:"report-failed"})}}function lu(e,r){let n=rr.join(e,r,"behavior.jsonl");return iu(n)?su(n,"utf8").split(`
344
+ `).some(t=>t.includes('"kind":"rrweb"')):!1}var du=$o(`
345
345
  query RunRepro($id: String!) {
346
346
  run(id: $id) {
347
347
  id
348
348
  reproJson
349
349
  }
350
350
  }
351
- `),lu=xo(`
352
- mutation CreateReplayRun($projectId: String!, $runId: String!, $reproJson: String) {
353
- createExploreRun(projectId: $projectId, runId: $runId, reproJson: $reproJson) {
351
+ `),uu=$o(`
352
+ mutation CreateReplayRun(
353
+ $projectId: String!
354
+ $runId: String!
355
+ $reproJson: String
356
+ $lockfileHash: String!
357
+ ) {
358
+ createExploreRun(
359
+ projectId: $projectId
360
+ runId: $runId
361
+ reproJson: $reproJson
362
+ lockfileHash: $lockfileHash
363
+ ) {
354
364
  id
355
365
  }
356
366
  }
357
- `);function $o({outcome:e,recordingCaptured:r,replayRunId:n}){let t=du(e);if(e.kind!=="resolved"&&e.kind!=="still-fails")return t;let o=r?"":"\n! No page recording was captured \u2014 the page may never have loaded. Treat this verdict with suspicion and confirm with `npx ripplo run`.",i=e.kind==="resolved"?`
367
+ `);function Po({outcome:e,recordingCaptured:r,replayRunId:n}){let t=cu(e);if(e.kind!=="resolved"&&e.kind!=="still-fails")return t;let o=r?"":"\n! No page recording was captured \u2014 the page may never have loaded. Treat this verdict with suspicion and confirm with `npx ripplo run`.",i=e.kind==="resolved"?`
358
368
  ! A clean replay confirms the fix but doesn't explain the original failure. Classify the root cause \u2014 app bug or model gap \u2014 before you resolve. Don't file it as flake unless you know why it flaked.`:"";return`${t}${o}${i}
359
- Replay run ${n} \u2014 snapshot it, or cite it as resolve proof: \`npx ripplo tasks resolve <id> --run ${n}\`.`}function du(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.contradictions.length,"check")} still mismatch.`;case"unplannable":return"! Model changed \u2014 this trail's base state or actions no longer exist. Use `npx ripplo compile` and `npx ripplo run`.";case"state-unavailable":return`! Couldn't run the trail (${e.reason}).`;case"aborted":return"Replay aborted."}}function Eo(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 Po(e){return e.kind==="resolved"}async function Io({runId:e}){(await Ro(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${$o(n)}
360
- `),process.exit(Po(n.outcome)?0:1)},n=>{process.stderr.write(`${Eo(n)}
361
- `),process.exit(1)})}import Uo from"path";import{existsSync as wu}from"fs";import{writeFile as _o}from"fs/promises";import Wo from"path";import{err as te,ok as bu}from"neverthrow";import{createRequire as uu}from"module";import{readFile as jo}from"fs/promises";import{fileURLToPath as cu}from"url";import{z as ne}from"zod";var pu={height:800,width:1280};async function To(e){let r=await jo(e,"utf8");return mu(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}function mu(e){return e.split(`
362
- `).filter(r=>r.length>0).flatMap(r=>{let n=M(r);return n==null?[]:[n]})}var fu=ne.object({data:ne.looseObject({height:ne.number(),width:ne.number()}),type:ne.literal(4)});function nr(e){let r=e.flatMap(n=>{let t=fu.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?pu:{height:r.data.height,width:r.data.width}}var gu='<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>',yu=`.replayer-mouse-tail { display: none; }
369
+ Replay run ${n} \u2014 snapshot it, or cite it as resolve proof: \`npx ripplo tasks resolve <id> --run ${n}\`.`}function cu(e){switch(e.kind){case"resolved":return"\u2713 Resolved \u2014 the finding's trail ran clean.";case"still-fails":return`\u2717 Still failing \u2014 ${$(e.contradictions.length,"check")} still mismatch.`;case"unplannable":return"! Model changed \u2014 this trail's base state or actions no longer exist. Use `npx ripplo compile` and `npx ripplo run`.";case"state-unavailable":return`! Couldn't run the trail (${e.reason}).`;case"aborted":return"Replay aborted."}}function Io(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 Ao(e){return e.kind==="resolved"}async function jo({runId:e}){(await Eo(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${Po(n)}
370
+ `),process.exit(Ao(n.outcome)?0:1)},n=>{process.stderr.write(`${Io(n)}
371
+ `),process.exit(1)})}import qo from"path";import{existsSync as vu}from"fs";import{writeFile as Do}from"fs/promises";import Uo from"path";import{err as te,ok as Su}from"neverthrow";import{createRequire as pu}from"module";import{readFile as Mo}from"fs/promises";import{fileURLToPath as mu}from"url";import{z as ne}from"zod";var fu={height:800,width:1280};async function Lo(e){let r=await Mo(e,"utf8");return gu(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}function gu(e){return e.split(`
372
+ `).filter(r=>r.length>0).flatMap(r=>{let n=M(r);return n==null?[]:[n]})}var yu=ne.object({data:ne.looseObject({height:ne.number(),width:ne.number()}),type:ne.literal(4)});function nr(e){let r=e.flatMap(n=>{let t=yu.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?fu:{height:r.data.height,width:r.data.width}}var hu='<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>',ku=`.replayer-mouse-tail { display: none; }
363
373
  .replayer-mouse {
364
374
  position: absolute;
365
375
  width: 17px;
@@ -367,28 +377,28 @@ Replay run ${n} \u2014 snapshot it, or cite it as resolve proof: \`npx ripplo ta
367
377
  z-index: 9999;
368
378
  background-repeat: no-repeat;
369
379
  background-size: contain;
370
- background-image: url('data:image/svg+xml;utf8,${gu}');
371
- }`,hu=".replayer-mouse, .replayer-mouse-tail { display: none; }";function Mo(e){return`<!doctype html><html><head><style>
380
+ background-image: url('data:image/svg+xml;utf8,${hu}');
381
+ }`,wu=".replayer-mouse, .replayer-mouse-tail { display: none; }";function No(e){return`<!doctype html><html><head><style>
372
382
  html, body { margin: 0; padding: 0; }
373
383
  .replayer-wrapper { position: relative; }
374
- ${e?yu:hu}
384
+ ${e?ku:wu}
375
385
  iframe { border: none; }
376
- </style></head><body></body></html>`}var Lo="*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }";function No(){return`(async () => {
386
+ </style></head><body></body></html>`}var Oo="*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }";function Fo(){return`(async () => {
377
387
  const doc = document.querySelector(".replayer-wrapper iframe")?.contentDocument;
378
388
  if (doc?.fonts != null) {
379
389
  await doc.fonts.ready;
380
390
  }
381
391
  await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
382
- })()`}function Oo(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var Ao;function Fo(){return Ao??=jo(ku(),"utf8"),Ao}function ku(){let e=uu(import.meta.url);try{return e.resolve("@ripplo/rrweb-bundle/replay")}catch{return cu(new URL("assets/rrweb-replay.js",import.meta.url))}}async function Do({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!wu(e))return te({kind:"run-not-found",runId:t});let o=await To(e),i=o[0],s=o.at(-1);if(i==null||s==null)return te({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 te({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let u=Math.min(l,a),w=String(Math.round(u)),f=Wo.join(n,`snapshot-${w}ms.png`),p=Wo.join(n,`snapshot-${w}ms.html`);return(await vu({events:o,htmlPath:p,offsetMs:u,pngPath:f})).map(()=>({durationMs:a,htmlPath:p,offsetMs:u,pngPath:f,viewport:nr(o)}))}async function vu({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await Oo();if(o==null)return te({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await Su({browser:o,events:e,offsetMs:n});return await _o(t,s),await _o(r,i,"utf8"),bu(void 0)}catch(i){return te({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function Su({browser:e,events:r,offsetMs:n}){let t=nr(r),o=await e.newPage({viewport:t});await o.setContent(Mo(!1)),await o.addScriptTag({content:await Fo()}),await o.evaluate(Cu({events:r,offsetMs:n})),await o.evaluate(No());let i=o.locator(".replayer-wrapper iframe").first(),a=await(await i.count()>0?i:o).screenshot({type:"png"});return{html:await o.evaluate(xu()),png:a}}function Cu({events:e,offsetMs:r}){return`(() => {
392
+ })()`}function _o(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var To;function Wo(){return To??=Mo(bu(),"utf8"),To}function bu(){let e=pu(import.meta.url);try{return e.resolve("@ripplo/rrweb-bundle/replay")}catch{return mu(new URL("assets/rrweb-replay.js",import.meta.url))}}async function Bo({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!vu(e))return te({kind:"run-not-found",runId:t});let o=await Lo(e),i=o[0],s=o.at(-1);if(i==null||s==null)return te({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 te({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let u=Math.min(l,a),h=String(Math.round(u)),f=Uo.join(n,`snapshot-${h}ms.png`),p=Uo.join(n,`snapshot-${h}ms.html`);return(await Cu({events:o,htmlPath:p,offsetMs:u,pngPath:f})).map(()=>({durationMs:a,htmlPath:p,offsetMs:u,pngPath:f,viewport:nr(o)}))}async function Cu({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await _o();if(o==null)return te({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await xu({browser:o,events:e,offsetMs:n});return await Do(t,s),await Do(r,i,"utf8"),Su(void 0)}catch(i){return te({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function xu({browser:e,events:r,offsetMs:n}){let t=nr(r),o=await e.newPage({viewport:t});await o.setContent(No(!1)),await o.addScriptTag({content:await Wo()}),await o.evaluate(Ru({events:r,offsetMs:n})),await o.evaluate(Fo());let i=o.locator(".replayer-wrapper iframe").first(),a=await(await i.count()>0?i:o).screenshot({type:"png"});return{html:await o.evaluate($u()),png:a}}function Ru({events:e,offsetMs:r}){return`(() => {
383
393
  const replayer = new globalThis.__RipploReplayer(${JSON.stringify(e)}, {
384
- insertStyleRules: [${JSON.stringify(Lo)}],
394
+ insertStyleRules: [${JSON.stringify(Oo)}],
385
395
  mouseTail: false,
386
396
  root: document.body,
387
397
  showWarning: false,
388
398
  });
389
399
  replayer.pause(${String(r+.5)});
390
400
  globalThis.__ripploSnapshotReplayer = replayer;
391
- })()`}function xu(){return`(() => {
401
+ })()`}function $u(){return`(() => {
392
402
  const replayer = globalThis.__ripploSnapshotReplayer;
393
403
  if (replayer == null) {
394
404
  return "";
@@ -406,43 +416,43 @@ iframe { border: none; }
406
416
  }
407
417
  });
408
418
  return "<!doctype html>\\n" + doc.documentElement.outerHTML;
409
- })()`}function Bo({cwd:e,moment:r,runId:n}){let t=Uo.join(e,".ripplo","debug",n);return Do({jsonlPath:Uo.join(t,"behavior.jsonl"),moment:r,outDir:t,runId:n})}function qo(e){return[`${c.good("ok")} \u2014 rendered the page at ${String(Math.round(e.offsetMs))}ms into the recording (duration ${String(Math.round(e.durationMs))}ms, viewport ${String(e.viewport.width)}\xD7${String(e.viewport.height)})`,e.pngPath,"Read the PNG above to see the page state. Layout and text are faithful \u2014 URL-referenced images may be blank if the dev server is down.",e.htmlPath,"The HTML is the same frame with every element tagged `data-rrweb-id`. Grep it for your element's class or text to get the id for `tasks comment --element`."].join(`
410
- `)}function Vo(e){return`${c.bad("fail")} \u2014 ${Ru(e)}`}function Ho(){return`${c.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function Ru(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 Ko({at:e,offset:r,runId:n}){let t=$u({at:e,offset:r});t==null&&(process.stderr.write(`${Ho()}
411
- `),process.exit(1));let o=await G(process.cwd(),n);o.isErr()&&(process.stderr.write(`${z(o.error)}
412
- `),process.exit(1)),(await Bo({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${qo(s)}
413
- `)},s=>{process.stderr.write(`${Vo(s)}
414
- `),process.exit(1)})}function $u({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 Go(e,r){switch(e.kind){case"config-failed":return v(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: ${ae(e.error)}`;case"done":return Eu(e.result,r)}}function zo(e){return e.kind==="done"&&e.result.kind==="handed-over"}function Jo(e,r){return`landed at step ${String(e)} of ${r} \u2014 close the window to tear down`}function Eu(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
419
+ })()`}function Vo({cwd:e,moment:r,runId:n}){let t=qo.join(e,".ripplo","debug",n);return Bo({jsonlPath:qo.join(t,"behavior.jsonl"),moment:r,outDir:t,runId:n})}function Ho(e){return[`${c.good("ok")} \u2014 rendered the page at ${String(Math.round(e.offsetMs))}ms into the recording (duration ${String(Math.round(e.durationMs))}ms, viewport ${String(e.viewport.width)}\xD7${String(e.viewport.height)})`,e.pngPath,"Read the PNG above to see the page state. Layout and text are faithful \u2014 URL-referenced images may be blank if the dev server is down.",e.htmlPath,"The HTML is the same frame with every element tagged `data-rrweb-id`. Grep it for your element's class or text to get the id for `tasks comment --element`."].join(`
420
+ `)}function Ko(e){return`${c.bad("fail")} \u2014 ${Eu(e)}`}function Go(){return`${c.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function Eu(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 zo({at:e,offset:r,runId:n}){let t=Pu({at:e,offset:r});t==null&&(process.stderr.write(`${Go()}
421
+ `),process.exit(1));let o=await J(process.cwd(),n);o.isErr()&&(process.stderr.write(`${Q(o.error)}
422
+ `),process.exit(1)),(await Vo({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${Ho(s)}
423
+ `)},s=>{process.stderr.write(`${Ko(s)}
424
+ `),process.exit(1)})}function Pu({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 Jo(e,r){switch(e.kind){case"config-failed":return b(e.failure);case"compile-failed":return q(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: ${ae(e.error)}`;case"done":return Iu(e.result,r)}}function Qo(e){return e.kind==="done"&&e.result.kind==="handed-over"}function Xo(e,r){return`landed at step ${String(e)} of ${r} \u2014 close the window to tear down`}function Iu(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
415
425
 
416
- ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
426
+ ${e.contradictions.map(t=>Gr({contradiction:t,evidencePath:void 0})).join(`
417
427
 
418
- `)}`:`torn down \u2014 teleport session for ${r} ended`}async function Qo({ref:e,step:r}){let n=new AbortController;process.once("SIGINT",()=>{n.abort()});let t=()=>{process.stdout.write(`${Jo(r,e)}
419
- `)},o=await Ln({cwd:process.cwd(),onReady:t,signal:n.signal,step:r,target:{kind:"test",ref:e}});process.stdout.write(`${Go(o,e)}
420
- `),process.exit(zo(o)?0:1)}import Xo from"path";import{randomUUID as Pu}from"crypto";async function Yo({cwd:e,onReady:r,signal:n}){let t=h(e).match(s=>s,s=>s.kind);if(typeof t=="string")return{detail:t,kind:"config-failed"};let o=`capture-${Pu()}`;return(await Qr({clientVersion:b(),debugDir:Xo.join(t.cwd,".ripplo","debug"),onReady:r,profileDir:Xo.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 Zo(){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 ei(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.":Iu(e.behaviorPath,e.runId)}function ri(e){return e.kind==="done"}function Iu(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(`
421
- `)}async function ni(){let e=new AbortController;process.once("SIGINT",()=>{e.abort()});let r=await Yo({cwd:process.cwd(),onReady:Au,signal:e.signal});process.stdout.write(`${ei(r)}
422
- `),process.exit(ri(r)?0:1)}function Au(){process.stdout.write(`${Zo()}
423
- `)}import{existsSync as ju,readFileSync as Tu}from"fs";import Mu from"path";function ti(e,r){let n=Mu.join(e,".ripplo","debug",r,"behavior.jsonl");return ju(n)?{actions:Xr(Tu(n,{encoding:"utf8"})),kind:"ok"}:{kind:"not-found",runId:r}}function oi(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)=>Lu(r,n)).join(`
424
- `)}function ii(e){return e.kind==="ok"}function Lu(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 si({runId:e}){let r=ti(process.cwd(),e);process.stdout.write(`${oi(r)}
425
- `),process.exit(ii(r)?0:1)}async function ai(){let e=g();try{let n=(await Z(e.cwd,e)).match(i=>i,i=>{process.stderr.write(`${v(i)}
426
- `),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}
428
+ `)}`:`torn down \u2014 teleport session for ${r} ended`}async function Yo({ref:e,step:r}){let n=new AbortController;process.once("SIGINT",()=>{n.abort()});let t=()=>{process.stdout.write(`${Xo(r,e)}
429
+ `)},o=await On({cwd:process.cwd(),onReady:t,signal:n.signal,step:r,target:{kind:"test",ref:e}});process.stdout.write(`${Jo(o,e)}
430
+ `),process.exit(Qo(o)?0:1)}import Zo from"path";import{randomUUID as Au}from"crypto";async function ei({cwd:e,onReady:r,signal:n}){let t=y(e).match(s=>s,s=>s.kind);if(typeof t=="string")return{detail:t,kind:"config-failed"};let o=`capture-${Au()}`;return(await Xr({clientVersion:w(),debugDir:Zo.join(t.cwd,".ripplo","debug"),onReady:r,profileDir:Zo.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 ri(){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 ni(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.":ju(e.behaviorPath,e.runId)}function ti(e){return e.kind==="done"}function ju(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(`
431
+ `)}async function oi(){let e=new AbortController;process.once("SIGINT",()=>{e.abort()});let r=await ei({cwd:process.cwd(),onReady:Tu,signal:e.signal});process.stdout.write(`${ni(r)}
432
+ `),process.exit(ti(r)?0:1)}function Tu(){process.stdout.write(`${ri()}
433
+ `)}import{existsSync as Mu,readFileSync as Lu}from"fs";import Nu from"path";function ii(e,r){let n=Nu.join(e,".ripplo","debug",r,"behavior.jsonl");return Mu(n)?{actions:Yr(Lu(n,{encoding:"utf8"})),kind:"ok"}:{kind:"not-found",runId:r}}function si(e){return e.kind==="not-found"?`No capture found for run ${e.runId}. Run npx ripplo capture first.`:e.actions.length===0?"No user actions found in this capture.":e.actions.map((r,n)=>Ou(r,n)).join(`
434
+ `)}function ai(e){return e.kind==="ok"}function Ou(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 li({runId:e}){let r=ii(process.cwd(),e);process.stdout.write(`${si(r)}
435
+ `),process.exit(ai(r)?0:1)}async function di(){let e=g();try{let n=(await Z(e.cwd,e)).match(i=>i,i=>{process.stderr.write(`${b(i)}
436
+ `),process.exit(1)}),t=n.lockfile.workflows.length,o=n.lockfile.entities.length;process.stdout.write(`Synced ${$(t,"workflow")} and ${$(o,"entity","entities")} to dev session ${n.devSessionId}
427
437
  `)}catch(r){let n=r instanceof Error?r.message:String(r);process.stderr.write(`ripplo sync failed: ${n}
428
- `),process.stderr.write(`${C("setup","verify auth + server reachability")}
429
- `),process.exit(1)}}import{spawnSync as Fu}from"child_process";import _u from"fs";import Wu from"path";import Du from"semver";import Ee from"fs";import Nu from"os";import oe from"path";function li(e){return e.split(oe.sep).includes("_npx")?"npx":e.includes(oe.join("packages","cli"))?"workspace":"global"}function di(){let e=oe.join(Nu.homedir(),".npm","_npx");return Ee.existsSync(e)?Ee.readdirSync(e).map(r=>oe.join(e,r)).filter(r=>Ee.existsSync(oe.join(r,"node_modules","ripplo"))).map(r=>(Ee.rmSync(r,{force:!0,recursive:!0}),r)):[]}import{spawnSync as ui}from"child_process";var Ou=["user","project","local"];function tr(){return ui("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":Ou.find(n=>ui("claude",["plugin","update","ripplo","--scope",n],{stdio:"ignore"}).status===0)==null?"not-installed":"updated"}function ci(e){return`ripplo v${e} is already the latest version.`}function pi(e){return`ripplo v${e}: could not reach the npm registry to check for updates.`}function or({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 mi(){return"ripplo: this is a workspace build (packages/cli/dist) \u2014 update via git pull + `pnpm --filter ripplo build`."}function fi(e){return`ripplo: \`npm install -g ripplo@latest\` failed: ${e}`}function ir(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 gi(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 Uu=1e4;async function yi(){let e=b(),r=process.argv[1];Bu(process.cwd());let n=await ye(Uu);process.stdout.write(`${fe({current:e,latest:n})}
430
- `),n==null&&(process.stderr.write(`${pi(e)}
431
- `),process.exit(1)),Du.gt(n,e)||(process.stdout.write(`${ci(e)}
438
+ `),process.stderr.write(`${x("setup","verify auth + server reachability")}
439
+ `),process.exit(1)}}import{spawnSync as Wu}from"child_process";import Du from"fs";import Uu from"path";import Bu from"semver";import Ee from"fs";import Fu from"os";import oe from"path";function ui(e){return e.split(oe.sep).includes("_npx")?"npx":e.includes(oe.join("packages","cli"))?"workspace":"global"}function ci(){let e=oe.join(Fu.homedir(),".npm","_npx");return Ee.existsSync(e)?Ee.readdirSync(e).map(r=>oe.join(e,r)).filter(r=>Ee.existsSync(oe.join(r,"node_modules","ripplo"))).map(r=>(Ee.rmSync(r,{force:!0,recursive:!0}),r)):[]}import{spawnSync as pi}from"child_process";var _u=["user","project","local"];function tr(){return pi("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":_u.find(n=>pi("claude",["plugin","update","ripplo","--scope",n],{stdio:"ignore"}).status===0)==null?"not-installed":"updated"}function mi(e){return`ripplo v${e} is already the latest version.`}function fi(e){return`ripplo v${e}: could not reach the npm registry to check for updates.`}function or({evicted:e,latest:r,mode:n}){return n==="npx"?`ripplo: ${e===0?"npx cache had no stale copy":`cleared ${$(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 gi(){return"ripplo: this is a workspace build (packages/cli/dist) \u2014 update via git pull + `pnpm --filter ripplo build`."}function yi(e){return`ripplo: \`npm install -g ripplo@latest\` failed: ${e}`}function ir(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 hi(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 qu=1e4;async function ki(){let e=w(),r=process.argv[1];Vu(process.cwd());let n=await ye(qu);process.stdout.write(`${fe({current:e,latest:n})}
440
+ `),n==null&&(process.stderr.write(`${fi(e)}
441
+ `),process.exit(1)),Bu.gt(n,e)||(process.stdout.write(`${mi(e)}
432
442
  `),process.stdout.write(`${ir(tr())}
433
- `),process.exit(0));let t=r==null?"global":li(r);qu({latest:n,mode:t}),process.stdout.write(`${ir(tr())}
434
- `),await Hu(process.cwd()),process.exit(0)}function Bu(e){if(!_u.existsSync(Wu.join(e,".ripplo")))return;let r=we(e);r==="written"&&process.stdout.write(`${be(r).trim()}
435
- `)}function qu({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${mi()}
436
- `),process.exit(0)),r==="npx"){let n=di();process.stdout.write(`${or({evicted:n.length,latest:e,mode:r})}
437
- `);return}Vu(e)}function Vu(e){let r=`ripplo@${e}`,n=Fu("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${fi(t)}
443
+ `),process.exit(0));let t=r==null?"global":ui(r);Hu({latest:n,mode:t}),process.stdout.write(`${ir(tr())}
444
+ `),await Gu(process.cwd()),process.exit(0)}function Vu(e){if(!Du.existsSync(Uu.join(e,".ripplo")))return;let r=we(e);r==="written"&&process.stdout.write(`${be(r).trim()}
445
+ `)}function Hu({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${gi()}
446
+ `),process.exit(0)),r==="npx"){let n=ci();process.stdout.write(`${or({evicted:n.length,latest:e,mode:r})}
447
+ `);return}Ku(e)}function Ku(e){let r=`ripplo@${e}`,n=Wu("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${yi(t)}
438
448
  `),process.exit(1)}process.stdout.write(`${or({evicted:0,latest:e,mode:"global"})}
439
- `)}async function Hu(e){if((await fn(e)).kind==="not-running")return;let n=await mn(e);process.stdout.write(`${gi(n)}
440
- `)}async function hi({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-2IFILDIA.js");await n({format:"summary"});return}if(e==="stop"||e==="restart"){let n=await Ku();(e==="stop"||!n)&&process.exit(n?0:1)}Gu();let{runDaemon:r}=await import("./daemon-M52H2YF7.js");await r()}async function Ku(){let{stopDevDaemon:e}=await import("./daemon-lock-LTQMLU4Q.js"),{renderDaemonStopResult:r}=await import("./daemon-6B4OSRBS.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
441
- `),n.kind!=="timeout"}function Gu(){let e=Se(q());e!=null&&process.stderr.write(`${e}
442
- `)}function ki(e){return`executor: ${e}`}function wi(e){return e==="cloud"?"executor set to cloud \u2014 the daemon is bringing the tunnel up, the next run dispatches to the cloud fleet":"executor set to local \u2014 the next run executes on this machine"}function bi(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 vi({mode:e}){let r=h(process.cwd()).match(t=>t,t=>{process.stderr.write(`${v(t)}
443
- `),process.exit(1)});(e==null?await Fn(r):await _n(r,e)).match(t=>{process.stdout.write(`${e==null?ki(t):wi(t)}
444
- `)},t=>{process.stderr.write(`${bi(t)}
445
- `),process.exit(1)})}import{graphql as Si}from"gql.tada";import{err as sr,ok as ar}from"neverthrow";var zu=Si(`
449
+ `)}async function Gu(e){if((await gn(e)).kind==="not-running")return;let n=await fn(e);process.stdout.write(`${hi(n)}
450
+ `)}async function wi({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-PUV7KG33.js");await n({format:"summary"});return}if(e==="stop"||e==="restart"){let n=await zu();(e==="stop"||!n)&&process.exit(n?0:1)}Ju();let{runDaemon:r}=await import("./daemon-3CCSJNDP.js");await r()}async function zu(){let{stopDevDaemon:e}=await import("./daemon-lock-67AFXXED.js"),{renderDaemonStopResult:r}=await import("./daemon-QRMX6RPX.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
451
+ `),n.kind!=="timeout"}function Ju(){let e=Se(H());e!=null&&process.stderr.write(`${e}
452
+ `)}function bi(e){return`executor: ${e}`}function vi(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 Si(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 Ci({mode:e}){let r=y(process.cwd()).match(t=>t,t=>{process.stderr.write(`${b(t)}
453
+ `),process.exit(1)});(e==null?await Wn(r):await Dn(r,e)).match(t=>{process.stdout.write(`${e==null?bi(t):vi(t)}
454
+ `)},t=>{process.stderr.write(`${Si(t)}
455
+ `),process.exit(1)})}import{graphql as xi}from"gql.tada";import{err as sr,ok as ar}from"neverthrow";var Qu=xi(`
446
456
  query ExploreState($devSessionId: String!) {
447
457
  exploration(devSessionId: $devSessionId) {
448
458
  active
@@ -451,7 +461,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
451
461
  maxTrailLength
452
462
  }
453
463
  }
454
- `),Ju=Si(`
464
+ `),Xu=xi(`
455
465
  mutation SetExploration(
456
466
  $devSessionId: String!
457
467
  $active: Boolean!
@@ -472,11 +482,11 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
472
482
  maxTrailLength
473
483
  }
474
484
  }
475
- `);async function Ci(e){let r=await Ri(e);if(r.isErr())return sr(r.error);let n=await $i(e,r.value.id);return ar(Ei(r.value.executor,n))}async function xi(e,r){let n=await Ri(e);if(n.isErr())return sr(n.error);let t=await $i(e,n.value.id),o=Qu(n.value.executor,t,r),i=await d({config:e,document:Ju,variables:{devSessionId:n.value.id,...o}});return ar(Ei(n.value.executor,i.setExploration))}async function Ri(e){let r=await on(e);return r.kind==="active"?ar({executor:r.executor,id:r.id}):sr({kind:r.kind==="starting"?"starting":"no-session"})}async function $i(e,r){return(await d({config:e,document:zu,variables:{devSessionId:r}})).exploration??null}function Ei(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??De,workers:(n?r?.localWorkers:r?.cloudWorkers)??0}}function Qu(e,r,n){let t=e==="local",o=(t?r?.localWorkers:r?.cloudWorkers)??0,i=(t?r?.cloudWorkers:r?.localWorkers)??0,s=Xu(n,o);return{active:n.active,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??De}}function Xu(e,r){return e.active?e.workers!=null?e.workers:r>0?r:On:r}function Pi(e){return e.active?`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`:"explorer: off"}function Ii(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 Ai(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 ji({state:e,trail:r,workers:n}){let t=h(process.cwd()).match(i=>i,i=>{process.stderr.write(`${v(i)}
476
- `),process.exit(1)});(e==null?await Ci(t):await xi(t,{active:e==="on",trail:r,workers:n})).match(i=>{process.stdout.write(`${e==null?Pi(i):Ii(i)}
477
- `)},i=>{process.stderr.write(`${Ai(i)}
478
- `),process.exit(1)})}import{graphql as Pe}from"gql.tada";function Ti(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function Mi(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(`
479
- `)}import{graphql as Yu}from"gql.tada";var Li=Yu(`
485
+ `);async function Ri(e){let r=await Ei(e);if(r.isErr())return sr(r.error);let n=await Pi(e,r.value.id);return ar(Ii(r.value.executor,n))}async function $i(e,r){let n=await Ei(e);if(n.isErr())return sr(n.error);let t=await Pi(e,n.value.id),o=Yu(n.value.executor,t,r),i=await d({config:e,document:Xu,variables:{devSessionId:n.value.id,...o}});return ar(Ii(n.value.executor,i.setExploration))}async function Ei(e){let r=await sn(e);return r.kind==="active"?ar({executor:r.executor,id:r.id}):sr({kind:r.kind==="starting"?"starting":"no-session"})}async function Pi(e,r){return(await d({config:e,document:Qu,variables:{devSessionId:r}})).exploration??null}function Ii(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??De,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=Zu(n,o);return{active:n.active,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??De}}function Zu(e,r){return e.active?e.workers!=null?e.workers:r>0?r:_n:r}function Ai(e){return e.active?`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`:"explorer: off"}function ji(e){return e.active?`explorer on \u2014 walking ${String(e.workers)} background paths, trail ${String(e.maxTrailLength)}, on the ${e.executor} executor. Findings land as tasks \u2014 triage with /ripplo:tasks`:"explorer off \u2014 background exploration stopped"}function Ti(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 Mi({state:e,trail:r,workers:n}){let t=y(process.cwd()).match(i=>i,i=>{process.stderr.write(`${b(i)}
486
+ `),process.exit(1)});(e==null?await Ri(t):await $i(t,{active:e==="on",trail:r,workers:n})).match(i=>{process.stdout.write(`${e==null?Ai(i):ji(i)}
487
+ `)},i=>{process.stderr.write(`${Ti(i)}
488
+ `),process.exit(1)})}import{graphql as Pe}from"gql.tada";function Li(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function Ni(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(`
489
+ `)}import{graphql as ec}from"gql.tada";var Oi=ec(`
480
490
  query ScopeStatus($projectId: String!, $cwd: String!) {
481
491
  project(id: $projectId) {
482
492
  id
@@ -496,7 +506,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
496
506
  }
497
507
  }
498
508
  }
499
- `);var Zu=Pe(`
509
+ `);var rc=Pe(`
500
510
  query ScopeWorkflowBySlug($projectId: String!, $cwd: String!, $slug: String!) {
501
511
  project(id: $projectId) {
502
512
  id
@@ -509,7 +519,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
509
519
  }
510
520
  }
511
521
  }
512
- `),ec=Pe(`
522
+ `),nc=Pe(`
513
523
  mutation ScopeAddDirtyTests($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
514
524
  addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
515
525
  __typename
@@ -531,31 +541,31 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
531
541
  }
532
542
  }
533
543
  }
534
- `),rc=Pe(`
544
+ `),tc=Pe(`
535
545
  mutation ScopeLink($id: ID!, $workflowId: String!) {
536
546
  linkScopeItem(id: $id, workflowId: $workflowId) {
537
547
  id
538
548
  }
539
549
  }
540
- `),nc=Pe(`
550
+ `),oc=Pe(`
541
551
  mutation ScopeRemoveMany($ids: [ID!]!) {
542
552
  removeScopeItems(ids: $ids)
543
553
  }
544
- `);async function Ni(e){let r=g();await S(r);let t=(await d({config:r,document:Li,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
554
+ `);async function Fi(e){let r=g();await C(r);let t=(await d({config:r,document:Oi,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
545
555
  `);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??""}
546
556
  `);return}let s=i.spec==null?"stub":"implemented";process.stdout.write(` [${s}] (${o.id}) ${i.slug} \u2014 ${i.name}
547
- `)})}async function Oi({testIds:e}){let r=g();await S(r),(await Z(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${v(a)}
548
- `),process.exit(1)});let o=(await d({config:r,document:ec,variables:{cwd:r.cwd,projectId:r.projectId,workflowSlugs:e.map(a=>jr(a))}})).addDirtyTestsToScope;o?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${o.message}
549
- `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${Mi(o.slugs)}
550
- `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${Ti()}
551
- `);return}let s=i.map(a=>a.workflow?.slug??"?").join(", ");process.stdout.write(`Added ${R(i.length,"scope item")}: ${s}
552
- `)}async function Fi({id:e,testId:r}){let n=g();await S(n),(await Z(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${v(i)}
553
- `),process.exit(1)});let o=await tc({cfg:n,slug:r});await d({config:n,document:rc,variables:{id:e,workflowId:o}}),process.stdout.write(`Linked scope item ${e} to ${r}
554
- `)}async function _i({ids:e}){let r=g();await S(r);let t=(await d({config:r,document:nc,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${R(t,"scope item")}
555
- `)}async function tc({cfg:e,slug:r}){let t=(await d({config:e,document:Zu,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.
556
- `),process.stderr.write(`${C("create")}
557
- `),process.exit(1)),t.id}import{graphql as T}from"gql.tada";import{print as Ji}from"graphql";import{createClient as Qi}from"graphql-sse";import lr from"fs";import oc from"path";import{err as Ie,ok as ic}from"neverthrow";function Di({cwd:e,rrwebId:r,runId:n}){let t=Bi(e,n);if(!lr.existsSync(t))return Ie({kind:"no-behavior"});let o=Ki(Hi(t,r));if(o==null)return Ie({kind:"not-found"});let i=ur(o.node.type);return i===3?Ie({kind:"text-node",parentId:ur(o.parent?.id)}):i!==2?Ie({kind:"non-element",nodeType:i??-1}):ic({tagName:I(o.node.tagName)})}function Ui({cwd:e,rrwebId:r,runId:n}){let t=Hi(Bi(e,n),r);if(t==null)return null;let o=Ki(t);return o==null||ur(o.node.type)!==2?null:sc(t)}function Bi(e,r){return oc.join(e,".ripplo","debug",r,"behavior.jsonl")}function sc(e){let r=e.at(-1)??{},n=cr(r.attributes)??{},t=I(r.tagName);return{ariaName:I(n["aria-label"]),role:I(n.role),selector:lc(e),tagName:t==null?null:t.toLowerCase(),testId:I(n["data-testid"]),text:mc(pc(r))}}var ac=6;function lc(e){let r=qi(e,e.length-1,ac);return r.length===0?null:r.join(" > ")}function qi(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=dc(t);if(o!=null)return[o];let i=uc(t,e[r-1]);return r===0||n===1?[i]:[...qi(e,r-1,n-1),i]}function dc(e){let r=cr(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 uc(e,r){let n=(I(e.tagName)??"*").toLowerCase(),t=Vi(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 Vi(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>Ae(n)):[]}function Hi(e,r){return lr.existsSync(e)?lr.readFileSync(e,"utf8").split(`
558
- `).reduce((t,o)=>t!=null||o.length===0?t:cc(o,r),null):null}function cc(e,r){let n=M(e);if(n?.kind!=="rrweb")return null;let t=cr(n.event.data),o=dr(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??(Ae(a)?dr(a.node,r):null),null):null}function dr(e,r){if(!Ae(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??dr(i,r),null);return t==null?null:[e,...t]}function Ki(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var Wi=80;function pc(e){let r=Vi(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 mc(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>Wi?`${r.slice(0,Wi)}\u2026`:r}function cr(e){return Ae(e)?e:void 0}function Ae(e){return typeof e=="object"&&e!=null}function ur(e){return typeof e=="number"?e:null}function pr(e,r){let n=r.flatMap(o=>fc(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function fc(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 gc=T(`
557
+ `)})}async function _i({testIds:e}){let r=g();await C(r),(await Z(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${b(a)}
558
+ `),process.exit(1)});let o=(await d({config:r,document:nc,variables:{cwd:r.cwd,projectId:r.projectId,workflowSlugs:e.map(a=>Tr(a))}})).addDirtyTestsToScope;o?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${o.message}
559
+ `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${Ni(o.slugs)}
560
+ `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${Li()}
561
+ `);return}let s=i.map(a=>a.workflow?.slug??"?").join(", ");process.stdout.write(`Added ${$(i.length,"scope item")}: ${s}
562
+ `)}async function Wi({id:e,testId:r}){let n=g();await C(n),(await Z(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${b(i)}
563
+ `),process.exit(1)});let o=await ic({cfg:n,slug:r});await d({config:n,document:tc,variables:{id:e,workflowId:o}}),process.stdout.write(`Linked scope item ${e} to ${r}
564
+ `)}async function Di({ids:e}){let r=g();await C(r);let t=(await d({config:r,document:oc,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${$(t,"scope item")}
565
+ `)}async function ic({cfg:e,slug:r}){let t=(await d({config:e,document:rc,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.
566
+ `),process.stderr.write(`${x("create")}
567
+ `),process.exit(1)),t.id}import{graphql as T}from"gql.tada";import{print as Xi}from"graphql";import{createClient as Yi}from"graphql-sse";import lr from"fs";import sc from"path";import{err as Ie,ok as ac}from"neverthrow";function Bi({cwd:e,rrwebId:r,runId:n}){let t=Vi(e,n);if(!lr.existsSync(t))return Ie({kind:"no-behavior"});let o=zi(Gi(t,r));if(o==null)return Ie({kind:"not-found"});let i=ur(o.node.type);return i===3?Ie({kind:"text-node",parentId:ur(o.parent?.id)}):i!==2?Ie({kind:"non-element",nodeType:i??-1}):ac({tagName:I(o.node.tagName)})}function qi({cwd:e,rrwebId:r,runId:n}){let t=Gi(Vi(e,n),r);if(t==null)return null;let o=zi(t);return o==null||ur(o.node.type)!==2?null:lc(t)}function Vi(e,r){return sc.join(e,".ripplo","debug",r,"behavior.jsonl")}function lc(e){let r=e.at(-1)??{},n=cr(r.attributes)??{},t=I(r.tagName);return{ariaName:I(n["aria-label"]),role:I(n.role),selector:uc(e),tagName:t==null?null:t.toLowerCase(),testId:I(n["data-testid"]),text:gc(fc(r))}}var dc=6;function uc(e){let r=Hi(e,e.length-1,dc);return r.length===0?null:r.join(" > ")}function Hi(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=cc(t);if(o!=null)return[o];let i=pc(t,e[r-1]);return r===0||n===1?[i]:[...Hi(e,r-1,n-1),i]}function cc(e){let r=cr(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 pc(e,r){let n=(I(e.tagName)??"*").toLowerCase(),t=Ki(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 Ki(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>Ae(n)):[]}function Gi(e,r){return lr.existsSync(e)?lr.readFileSync(e,"utf8").split(`
568
+ `).reduce((t,o)=>t!=null||o.length===0?t:mc(o,r),null):null}function mc(e,r){let n=M(e);if(n?.kind!=="rrweb")return null;let t=cr(n.event.data),o=dr(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??(Ae(a)?dr(a.node,r):null),null):null}function dr(e,r){if(!Ae(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??dr(i,r),null);return t==null?null:[e,...t]}function zi(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var Ui=80;function fc(e){let r=Ki(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 gc(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>Ui?`${r.slice(0,Ui)}\u2026`:r}function cr(e){return Ae(e)?e:void 0}function Ae(e){return typeof e=="object"&&e!=null}function ur(e){return typeof e=="number"?e:null}function pr(e,r){let n=r.flatMap(o=>yc(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function yc(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 hc=T(`
559
569
  query WorkList($projectId: String!, $cwd: String!) {
560
570
  project(id: $projectId) {
561
571
  id
@@ -573,7 +583,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
573
583
  }
574
584
  }
575
585
  }
576
- `),yc=T(`
586
+ `),kc=T(`
577
587
  query WatchSeed($projectId: String!, $cwd: String!) {
578
588
  project(id: $projectId) {
579
589
  id
@@ -593,7 +603,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
593
603
  }
594
604
  }
595
605
  }
596
- `),Xi=T(`
606
+ `),Zi=T(`
597
607
  subscription WatchTasks($devSessionId: String!) {
598
608
  tasksChanged(devSessionId: $devSessionId) {
599
609
  devSession {
@@ -612,7 +622,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
612
622
  }
613
623
  }
614
624
  }
615
- `),hc=T(`
625
+ `),wc=T(`
616
626
  query WorkShow($id: String!) {
617
627
  task(id: $id) {
618
628
  id
@@ -629,7 +639,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
629
639
  }
630
640
  }
631
641
  }
632
- `),kc=T(`
642
+ `),bc=T(`
633
643
  mutation WorkComment(
634
644
  $taskId: String!
635
645
  $body: String!
@@ -655,7 +665,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
655
665
  }
656
666
  }
657
667
  }
658
- `),wc=T(`
668
+ `),vc=T(`
659
669
  mutation WorkResolve($taskId: String!, $runId: String!, $note: String, $authorName: String) {
660
670
  agentResolveTask(taskId: $taskId, runId: $runId, note: $note, authorName: $authorName) {
661
671
  __typename
@@ -667,7 +677,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
667
677
  }
668
678
  }
669
679
  }
670
- `),bc=T(`
680
+ `),Sc=T(`
671
681
  mutation WorkStart($taskId: String!) {
672
682
  agentStartTask(taskId: $taskId) {
673
683
  __typename
@@ -680,7 +690,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
680
690
  }
681
691
  }
682
692
  }
683
- `),vc=T(`
693
+ `),Cc=T(`
684
694
  mutation WorkClarify($taskId: String!, $body: String!, $authorName: String) {
685
695
  agentSetNeedsClarification(taskId: $taskId, body: $body, authorName: $authorName) {
686
696
  __typename
@@ -692,7 +702,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
692
702
  }
693
703
  }
694
704
  }
695
- `),Sc=T(`
705
+ `),xc=T(`
696
706
  mutation WorkDismiss($taskId: String!, $note: String, $authorName: String) {
697
707
  agentDismissTask(taskId: $taskId, note: $note, authorName: $authorName) {
698
708
  __typename
@@ -707,21 +717,21 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
707
717
  }
708
718
  }
709
719
  }
710
- `),Cc=18e4;async function Yi(e){let r=g();await S(r);let n=await Gi(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await xc({cfg:r,devSessionId:n.devSessionId});let o=await Gi(r);zi(o.items,e.format);return}zi(n.items,e.format)}async function Gi(e){let n=(await d({config:e,document:gc,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return{devSessionId:n?.id??null,items:n?.tasks??[]}}function zi(e,r){if(r==="json"){process.stdout.write(`${JSON.stringify(e,null,2)}
711
- `);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(`${Wn(n)}
712
- `)}function xc({cfg:e,devSessionId:r}){let n=Qi({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,Cc),o.dispose=n.subscribe({query:Ji(Xi),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function Zi(){let e=g();await S(e);let n=(await d({config:e,document:yc,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=pr(new Map,rs(n.tasks??[])),o=Qi({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});Rc({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function Rc({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:Ji(Xi),variables:{devSessionId:e}},{complete:()=>{},error:o=>{process.stderr.write(`task watch error: ${String(o)}
713
- `)},next:o=>{let i=o.data?.tasksChanged?.devSession?.tasks??[],s=pr(t,rs(i));s.changes.forEach(a=>{process.stdout.write(`${Un(a)}
714
- `)}),t=s.seen}})}async function es(e){let r=g();await S(r);let t=(await d({config:r,document:hc,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${Bn(e.id)}
720
+ `),Rc=18e4;async function es(e){let r=g();await C(r);let n=await Ji(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await $c({cfg:r,devSessionId:n.devSessionId});let o=await Ji(r);Qi(o.items,e.format);return}Qi(n.items,e.format)}async function Ji(e){let n=(await d({config:e,document:hc,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)}
721
+ `);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(`${Un(n)}
722
+ `)}function $c({cfg:e,devSessionId:r}){let n=Yi({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,Rc),o.dispose=n.subscribe({query:Xi(Zi),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function rs(){let e=g();await C(e);let n=(await d({config:e,document:kc,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=pr(new Map,ts(n.tasks??[])),o=Yi({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});Ec({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function Ec({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:Xi(Zi),variables:{devSessionId:e}},{complete:()=>{},error:o=>{process.stderr.write(`task watch error: ${String(o)}
723
+ `)},next:o=>{let i=o.data?.tasksChanged?.devSession?.tasks??[],s=pr(t,ts(i));s.changes.forEach(a=>{process.stdout.write(`${qn(a)}
724
+ `)}),t=s.seen}})}async function ns(e){let r=g();await C(r);let t=(await d({config:r,document:wc,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${Vn(e.id)}
715
725
  `),process.exit(1)),e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
716
- `);return}let o=[...new Set((t.messages??[]).flatMap(s=>s.runId==null?[]:[s.runId]))];await Promise.all(o.map(s=>G(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:Ui({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(`${Dn(i)}
717
- `)}function rs(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 ns(e){let r=g();if(await S(r),e.elementId!=null&&e.runId!=null){let t=Di({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${$c(t,e.elementId,e.runId)}
718
- `),process.exit(1))}let n=await d({config:r,document:kc,variables:{authorName:e.authorName??null,body:e.body,frameMs:e.offsetMs??null,rrwebId:e.elementId??null,runId:e.runId??null,taskId:e.id}});je(n.agentCommentOnTask),process.stdout.write(`${qn(e.id)}
719
- `)}async function ts(e){let r=g();await S(r);let n=await d({config:r,document:wc,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});je(n.agentResolveTask),process.stdout.write(`${zn(e.id)}
720
- `)}async function os(e){let r=g();await S(r);let n=await d({config:r,document:bc,variables:{taskId:e.id}});je(n.agentStartTask),process.stdout.write(`${Jn(e.id)}
721
- `)}async function is(e){e.body.trim().length===0&&(process.stderr.write(`${Vn()}
722
- `),process.exit(1));let r=g();await S(r);let n=await d({config:r,document:vc,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});je(n.agentSetNeedsClarification),process.stdout.write(`${Qn(e.id)}
723
- `)}async function ss(e){let r=g();await S(r);let t=(await d({config:r,document:Sc,variables:{authorName:e.authorName??null,note:e.note??null,taskId:e.id}})).agentDismissTask;(t?.__typename==="FindingNotDismissableError"||t?.__typename==="NoActiveDevSessionError")&&(process.stderr.write(`${t.message}
724
- `),process.exit(1)),process.stdout.write(`${Xn(e.id)}
726
+ `);return}let o=[...new Set((t.messages??[]).flatMap(s=>s.runId==null?[]:[s.runId]))];await Promise.all(o.map(s=>J(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:qi({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(`${Bn(i)}
727
+ `)}function ts(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 os(e){let r=g();if(await C(r),e.elementId!=null&&e.runId!=null){let t=Bi({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${Pc(t,e.elementId,e.runId)}
728
+ `),process.exit(1))}let n=await d({config:r,document:bc,variables:{authorName:e.authorName??null,body:e.body,frameMs:e.offsetMs??null,rrwebId:e.elementId??null,runId:e.runId??null,taskId:e.id}});je(n.agentCommentOnTask),process.stdout.write(`${Hn(e.id)}
729
+ `)}async function is(e){let r=g();await C(r);let n=await d({config:r,document:vc,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});je(n.agentResolveTask),process.stdout.write(`${Qn(e.id)}
730
+ `)}async function ss(e){let r=g();await C(r);let n=await d({config:r,document:Sc,variables:{taskId:e.id}});je(n.agentStartTask),process.stdout.write(`${Xn(e.id)}
731
+ `)}async function as(e){e.body.trim().length===0&&(process.stderr.write(`${Kn()}
732
+ `),process.exit(1));let r=g();await C(r);let n=await d({config:r,document:Cc,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});je(n.agentSetNeedsClarification),process.stdout.write(`${Yn(e.id)}
733
+ `)}async function ls(e){let r=g();await C(r);let t=(await d({config:r,document:xc,variables:{authorName:e.authorName??null,note:e.note??null,taskId:e.id}})).agentDismissTask;(t?.__typename==="FindingNotDismissableError"||t?.__typename==="NoActiveDevSessionError")&&(process.stderr.write(`${t.message}
734
+ `),process.exit(1)),process.stdout.write(`${Zn(e.id)}
725
735
  `)}function je(e){e?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${e.message}
726
- `),process.exit(1))}function $c(e,r,n){return e.kind==="text-node"?Hn(r,e.parentId):e.kind==="not-found"?Kn(r,n):Gn(r)}function as(e){return e.command("list","List open tasks for this dev session",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}).option("wait",{default:!1,describe:"Block until the first explorer finding lands (or a timeout)",type:"boolean"}),r=>Yi({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,()=>Zi()).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=>es({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=>ns({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=>os({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=>ts({authorName:r.as,id:r.id,note:r.note,runId:r.run})).command("clarify <id> <body>","Mark a task as needing clarification from the user",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).positional("body",{demandOption:!0,describe:"What you need clarified",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>is({authorName:r.as,body:r.body,id:r.id})).command("dismiss <id>","Dismiss a task as not actionable",r=>r.positional("id",{demandOption:!0,describe:"Task id",type:"string"}).option("note",{describe:"Optional reason",type:"string"}).option("as",{describe:"Agent display name shown on the message",type:"string"}),r=>ss({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}Cr();X(process.cwd());br();async function jc(){ie(b()),Tr({size:Math.max(1,Math.min(10,Ec()-2)),workerUrl:rt()}),Pc({pkg:{name:"ripplo",version:b()}}).notify({message:nt()}),await Ic(Ac(process.argv)).scriptName("ripplo").version(b()).command(Mc()).command(Lc()).command(Nc()).command(qc()).command("auth <subcommand>","Manage authentication",Jc).command("projects <subcommand>","List or create Ripplo projects",zc).command("hooks <subcommand>","Pause or resume Ripplo hooks",Gc).command(_c()).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=>Mt({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`)",Hc,e=>Kt({all:e.all,headed:e.headed,ids:e.ids})).command(Dc()).command(Vc()).command(Uc()).command(Bc()).command(Tc()).command(Wc()).command(Oc()).command(Fc()).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>ai()).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=>ut({check:e.check})).command("update","Update ripplo to the latest published version (and hand the daemon off to it)",()=>{},()=>yi()).command("doctor","Check project health",()=>{},()=>vt()).command("status","Report stub tests and daemon status",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>Nn({format:e.format})).command("scope <subcommand>","Manage testing scope",Kc).command("tasks <subcommand>","Manage tasks for this dev session",as).command("run-worker",!1,()=>{},()=>Xt()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(Yn),demandOption:!0,type:"string"}),e=>Zn(e.name)).strict().help().parse(),Mr()}jc().catch(e=>{process.stderr.write(`${_r(e)}
727
- `),process.exit(1)});function Tc(){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=>qt({kind:e.kind,rootCause:e["root-cause"],runId:e.run,surfacedBy:e["surfaced-by"],title:e.title})}}function Mc(){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=>hi({action:e.action})}}function Lc(){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=>vi({mode:e.mode})}}function Nc(){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=>ji({state:e.state,trail:e.trail,workers:e.workers})}}function Oc(){return{command:"explain <runId>",describe:"Explain a run's failing checks \u2014 what failed, where it came from, and what happened around it",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("json",{default:!1,describe:"Machine-readable output",type:"boolean"}).option("full",{default:!1,describe:"Also dump the world the model set up and a step-by-step timeline of the run",type:"boolean"}),handler:e=>vo({full:e.full,json:e.json,runId:e.runId})}}function Fc(){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=>Io({runId:e.runId})}}function _c(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{Ut()}}}function Wc(){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=>So({runId:e.runId})}}function Dc(){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=>Ko({at:e.at,offset:e.offset,runId:e.runId})}}function Uc(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>ni()}}function Bc(){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=>{si({runId:e.runId})}}}function qc(){return{command:"concurrency [value]",describe:"Show or set max local concurrent runs (daemon applies live)",builder:e=>e.positional("value",{type:"number"}),handler:e=>pt({value:e.value})}}function Vc(){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=>Qo({ref:e.ref,step:e.step})}}function Hc(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 Kc(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>Ni({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=>Oi({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=>Fi({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=>_i({ids:r.ids})).demandCommand(1)}function Gc(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>St()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>Ct()).demandCommand(1)}function zc(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>Ot()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>Ft({name:r.name,orgId:r.org})).demandCommand(1)}function Jc(e){return e.command("login","Authenticate via device flow",()=>{},()=>at()).command("status","Show authentication status",()=>{},()=>lt()).command("logout","Remove the saved token",()=>{},()=>{dt()}).demandCommand(1)}export{jc as main};
736
+ `),process.exit(1))}function Pc(e,r,n){return e.kind==="text-node"?Gn(r,e.parentId):e.kind==="not-found"?zn(r,n):Jn(r)}function ds(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=>es({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,()=>rs()).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=>ns({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=>os({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=>ss({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=>is({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=>as({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=>ls({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}xr();X(process.cwd());vr();async function Mc(){ie(w()),Mr({size:Math.max(1,Math.min(10,Ic()-2)),workerUrl:tt()}),Ac({pkg:{name:"ripplo",version:w()}}).notify({message:ot()}),await jc(Tc(process.argv)).scriptName("ripplo").version(w()).command(Nc()).command(Oc()).command(Fc()).command(Hc()).command("auth <subcommand>","Manage authentication",Xc).command("projects <subcommand>","List or create Ripplo projects",Qc).command("hooks <subcommand>","Pause or resume Ripplo hooks",Jc).command(Dc()).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=>Nt({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`)",Gc,e=>zt({all:e.all,headed:e.headed,ids:e.ids})).command(Bc()).command(Kc()).command(qc()).command(Vc()).command(Lc()).command(Uc()).command(_c()).command(Wc()).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>di()).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=>pt({check:e.check})).command("update","Update ripplo to the latest published version (and hand the daemon off to it)",()=>{},()=>ki()).command("doctor","Check project health",()=>{},()=>Ct()).command("status","Report stub tests and daemon status",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>Fn({format:e.format})).command("scope <subcommand>","Manage testing scope",zc).command("tasks <subcommand>","Manage tasks for this dev session",ds).command("run-worker",!1,()=>{},()=>Zt()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(et),demandOption:!0,type:"string"}),e=>rt(e.name)).strict().help().parse(),Lr()}Mc().catch(e=>{process.stderr.write(`${Wr(e)}
737
+ `),process.exit(1)});function Lc(){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=>Ht({kind:e.kind,rootCause:e["root-cause"],runId:e.run,surfacedBy:e["surfaced-by"],title:e.title})}}function Nc(){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=>wi({action:e.action})}}function Oc(){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=>Ci({mode:e.mode})}}function Fc(){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=>Mi({state:e.state,trail:e.trail,workers:e.workers})}}function _c(){return{command:"explain <runId>",describe:"Explain a run's failing checks \u2014 what failed, where it came from, and what happened around it",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("json",{default:!1,describe:"Machine-readable output",type:"boolean"}).option("full",{default:!1,describe:"Also dump the world the model set up and a step-by-step timeline of the run",type:"boolean"}),handler:e=>Co({full:e.full,json:e.json,runId:e.runId})}}function Wc(){return{command:"replay <runId>",describe:"Re-run an explore finding's trail to confirm it's resolved",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}),handler:e=>jo({runId:e.runId})}}function Dc(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{qt()}}}function Uc(){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=>xo({runId:e.runId})}}function Bc(){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=>zo({at:e.at,offset:e.offset,runId:e.runId})}}function qc(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>oi()}}function Vc(){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=>{li({runId:e.runId})}}}function Hc(){return{command:"concurrency [value]",describe:"Show or set max local concurrent runs (daemon applies live)",builder:e=>e.positional("value",{type:"number"}),handler:e=>ft({value:e.value})}}function Kc(){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=>Yo({ref:e.ref,step:e.step})}}function Gc(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 zc(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>Fi({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=>_i({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=>Wi({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=>Di({ids:r.ids})).demandCommand(1)}function Jc(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>xt()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>Rt()).demandCommand(1)}function Qc(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>_t()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>Wt({name:r.name,orgId:r.org})).demandCommand(1)}function Xc(e){return e.command("login","Authenticate via device flow",()=>{},()=>dt()).command("status","Show authentication status",()=>{},()=>ut()).command("logout","Remove the saved token",()=>{},()=>{ct()}).demandCommand(1)}export{Mc as main};