ripplo 0.8.1 → 0.8.2

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 (71) hide show
  1. package/dist/{chunk-NWWET7CM.js → chunk-2MT2MZJW.js} +1 -1
  2. package/dist/{chunk-GD2AESFG.js → chunk-4FKGHWCC.js} +1 -1
  3. package/dist/{chunk-HGL5SE75.js → chunk-4W6WIT7T.js} +1 -1
  4. package/dist/{chunk-OAXYJKXD.js → chunk-5SM4TCSW.js} +2 -2
  5. package/dist/{chunk-TPTG6RR4.js → chunk-7TYUZIUO.js} +1 -1
  6. package/dist/{chunk-WK7VO5JE.js → chunk-A7SHHSB3.js} +1 -1
  7. package/dist/{chunk-KSNZWWHX.js → chunk-AQ3DMGAY.js} +1 -1
  8. package/dist/{chunk-7YPITJA2.js → chunk-AVBP7Q2M.js} +1 -1
  9. package/dist/chunk-CRELTIU2.js +242 -0
  10. package/dist/{chunk-WOHPPHUD.js → chunk-DBIXYJRB.js} +1 -1
  11. package/dist/{chunk-FCEWYZLQ.js → chunk-EGETJKAQ.js} +1 -1
  12. package/dist/chunk-EK6TENV6.js +4 -0
  13. package/dist/{chunk-ZH3HY7BS.js → chunk-ESOXRGIY.js} +1 -1
  14. package/dist/{chunk-4AGLYPJ5.js → chunk-I2M24U3N.js} +2 -2
  15. package/dist/{chunk-PBL3TBB7.js → chunk-I5BHCICM.js} +1 -1
  16. package/dist/chunk-KOKEEAEF.js +6 -0
  17. package/dist/{chunk-CLFA4JSB.js → chunk-L7GWKDGD.js} +1 -1
  18. package/dist/{chunk-42LZFMNX.js → chunk-LEFXRK53.js} +1 -1
  19. package/dist/{chunk-VYQ5CDRX.js → chunk-LKYTQXPR.js} +1 -1
  20. package/dist/{chunk-EXV2RD7Z.js → chunk-M7VQD4VO.js} +1 -1
  21. package/dist/{chunk-G22LPS47.js → chunk-N2B5GZPU.js} +1 -1
  22. package/dist/{chunk-FZIMQTFG.js → chunk-OY6HNCAZ.js} +1 -1
  23. package/dist/chunk-PE5WVWI5.js +48 -0
  24. package/dist/{chunk-TEP6ETHQ.js → chunk-PXZV5X3C.js} +1 -1
  25. package/dist/{chunk-U4LC56T3.js → chunk-SWOTFHBR.js} +1 -1
  26. package/dist/{chunk-XGMM2RKR.js → chunk-T5VLZ43M.js} +1 -1
  27. package/dist/{chunk-4DXOF4WS.js → chunk-UVYCSHOJ.js} +1 -1
  28. package/dist/chunk-WHSQBXWO.js +7 -0
  29. package/dist/{chunk-VETETUHZ.js → chunk-XBD3OTIW.js} +1 -1
  30. package/dist/{chunk-3SCOYB4C.js → chunk-XWUIRXMS.js} +1 -1
  31. package/dist/{cli-error-J7LD2VWZ.js → cli-error-SLG6JHK2.js} +1 -1
  32. package/dist/compile-write-7AV66JUA.js +4 -0
  33. package/dist/daemon-BN42ZNCJ.js +139 -0
  34. package/dist/{daemon-JJ6MZPIA.js → daemon-LFFCR3TB.js} +1 -1
  35. package/dist/{daemon-lock-FLZHWM2F.js → daemon-lock-LTQMLU4Q.js} +1 -1
  36. package/dist/{dsl-loader-IOQUYVQH.js → dsl-loader-H25XGSHJ.js} +1 -1
  37. package/dist/{exit-plan-gate-TTJ7U2AP.js → exit-plan-gate-BNAUL4FC.js} +1 -1
  38. package/dist/hook.js +1 -1
  39. package/dist/index.js +150 -150
  40. package/dist/{plan-reminder-Q4A5WM2G.js → plan-reminder-VMBDQTAP.js} +1 -1
  41. package/dist/post-edit-2VFE6QND.js +4 -0
  42. package/dist/post-edit-analyze-VETPP5Z4.js +4 -0
  43. package/dist/post-edit-flag-stubs-J3MCGLXI.js +4 -0
  44. package/dist/{pre-bash-run-gate-C73XUNRE.js → pre-bash-run-gate-PWLARIYK.js} +1 -1
  45. package/dist/pre-edit-Q4U5LSWG.js +4 -0
  46. package/dist/{pre-edit-ripplo-skill-gate-63HGCUPG.js → pre-edit-ripplo-skill-gate-JD4BDCA3.js} +1 -1
  47. package/dist/{pre-edit-scope-gate-WIORRC2B.js → pre-edit-scope-gate-NZO4HVGT.js} +1 -1
  48. package/dist/{pre-edit-watch-gate-3VSMTCE4.js → pre-edit-watch-gate-EUZGEH2J.js} +1 -1
  49. package/dist/prompt-submit-MPRVCWOI.js +4 -0
  50. package/dist/scope-reminder-CBY4I5SG.js +4 -0
  51. package/dist/{session-preamble-HNQKBR27.js → session-preamble-RJ4WNGJN.js} +1 -1
  52. package/dist/solve-worker.js +1 -1
  53. package/dist/status-UBUNHH5O.js +4 -0
  54. package/dist/{stop-enforce-I27VU4IR.js → stop-enforce-UXBQRTFP.js} +1 -1
  55. package/dist/{tasks-reminder-A4AIFNQJ.js → tasks-reminder-LKSUZUFD.js} +1 -1
  56. package/dist/{track-skill-load-3IPC45UX.js → track-skill-load-CJ74GD3Q.js} +1 -1
  57. package/package.json +3 -3
  58. package/dist/chunk-G7ZQUZ2X.js +0 -242
  59. package/dist/chunk-HYHAOKYP.js +0 -7
  60. package/dist/chunk-IW2P4NKR.js +0 -4
  61. package/dist/chunk-LB2L72ZU.js +0 -48
  62. package/dist/chunk-S7GMY5LS.js +0 -6
  63. package/dist/compile-write-OKTXD7JL.js +0 -4
  64. package/dist/daemon-O2VR45XP.js +0 -139
  65. package/dist/post-edit-PMSJ6CLE.js +0 -4
  66. package/dist/post-edit-analyze-2AJVDFTK.js +0 -4
  67. package/dist/post-edit-flag-stubs-ORFV452V.js +0 -4
  68. package/dist/pre-edit-H6ZOQSXF.js +0 -4
  69. package/dist/prompt-submit-PSXSUTY3.js +0 -4
  70. package/dist/scope-reminder-TGDQCKLN.js +0 -4
  71. package/dist/status-QBBCVTXV.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 ln,c as dn,d as un,e as cn,f as pn,g as pe}from"./chunk-VYQ5CDRX.js";import{a as An,b as jn,d as Tn,e as Mn,f as Ln,g as Nn,h as On,i as _n,j as Fn,k as Wn,l as Dn,m as Un,n as qn}from"./chunk-CDPYJKK7.js";import{a as Pn}from"./chunk-VETETUHZ.js";import{b as tn,c as on,d as sn,f as an}from"./chunk-FCEWYZLQ.js";import{A as Cn,B as me,D as Sn,H as Rn,I as En,J as $n,K as In,a as Qr,b as Xr,c as Yr,d as Zr,e as Ne,f as en,h as fn,i as gn,k as yn,l as hn,m as kn,n as wn,o as bn,p as vn,r as xn,y as Fe}from"./chunk-G7ZQUZ2X.js";import{b as nn,c as ce}from"./chunk-FZIMQTFG.js";import{a as Gr}from"./chunk-MOI4L3EX.js";import{a as de,b as zr,c as ue,d as Jr}from"./chunk-TEP6ETHQ.js";import{a as R}from"./chunk-OQ6KNYPG.js";import{b as J}from"./chunk-4DXOF4WS.js";import{a as C,b as Tr,c as y}from"./chunk-42LZFMNX.js";import{a as Mr}from"./chunk-7WZ3VIUU.js";import{e as Oe,f as rn}from"./chunk-HGL5SE75.js";import{a as kr,b as Bn,c as Vn}from"./chunk-HYHAOKYP.js";import{a as w}from"./chunk-R4ZTRVDQ.js";import{b as wr,c as G,d as br,e as vr}from"./chunk-FEHVIHVA.js";import"./chunk-S7GMY5LS.js";import{a as jr,b}from"./chunk-NWWET7CM.js";import{a as D,b as $r,c as Ir,d as Ar}from"./chunk-7YPITJA2.js";import{a as x}from"./chunk-MHNGR6M7.js";import{e as Kr,g as U}from"./chunk-IW2P4NKR.js";import{b as z,e as T,g as Pr,h as se}from"./chunk-KSNZWWHX.js";import"./chunk-WOHPPHUD.js";import{a as dr,b as ur,c as cr,d as u,e as _,g as pr,i as P,j as mr,k as fr,l as Me,m as gr,n as yr,o as hr}from"./chunk-LB2L72ZU.js";import{a as te}from"./chunk-CJUKILIO.js";import{k as _e,l as mn}from"./chunk-EXV2RD7Z.js";import{F as Dr,K as Le,N as Ur,O as qr,T as Br,W as le,X as Vr,_ as Hr,e as ae,i as Lr,j as Nr,l as Or,m as _r,w as p,x as Fr,y as Wr}from"./chunk-ZH3HY7BS.js";import{A as oe,B as ie,H as j,I as Cr,N as Sr,S as Rr,T as Er,i as xr,n as F,o as W}from"./chunk-OAXYJKXD.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{availableParallelism as Uu}from"os";import{existsSync as Hn}from"fs";function Kn(){let e=new URL("solve-worker.js",import.meta.url);if(Hn(e))return e;let r=new URL("../dist/solve-worker.js",import.meta.url);if(Hn(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 qu from"update-notifier";import Bu from"yargs";import{hideBin as Vu}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 Gn(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as ds}from"gql.tada";import{exec as es}from"child_process";import{createAuthClient as Yi}from"better-auth/client";import{deviceAuthorizationClient as Zi}from"better-auth/client/plugins";function zn({baseURL:e}){return Yi({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Zi()]})}import{err as Jn,ok as rs}from"neverthrow";var ns=5e3,Qn="ripplo-cli";async function Xn({onDeviceCode:e,url:r}){let n=r??Tr().RIPPLO_SERVER_URL,t=zn({baseURL:n}),o=await t.device.code({client_id:Qn});if(o.error!=null)return Jn({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}),ls(a),(await ts({authClient:t,deviceCode:i})).map(d=>(mr({serverUrl:n,token:d}),d))}async function ts({authClient:e,deviceCode:r}){for(;;){await ss(ns);let n=await e.device.token({client_id:Qn,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return rs(n.data.access_token);if(n.error==null)continue;if(!is(n.error.error))return Jn({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var os=new Set(["authorization_pending","slow_down"]);function is(e){return os.has(e)}function ss(e){return new Promise(r=>{setTimeout(r,e)})}function as(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function ls(e){let r=as();es(`${r} "${e}"`,()=>{})}function I({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var us=ds(`
4
+ import{a as dn,c as un,d as cn,e as pn,f as mn,g as ce}from"./chunk-LKYTQXPR.js";import{a as jn,b as Tn,d as Mn,e as Ln,f as Nn,g as On,h as _n,i as Fn,j as Wn,k as Dn,l as Un,m as qn,n as Bn}from"./chunk-CDPYJKK7.js";import{a as $n}from"./chunk-XBD3OTIW.js";import{b as on,c as sn,d as an,f as ln}from"./chunk-EGETJKAQ.js";import{A as Sn,B as pe,D as Rn,H as En,I as Pn,J as In,K as An,a as Xr,b as Yr,c as Zr,d as en,e as Le,f as rn,h as gn,i as yn,k as hn,l as kn,m as wn,n as bn,o as vn,p as xn,r as Cn,y as _e}from"./chunk-CRELTIU2.js";import{b as tn,c as ue}from"./chunk-OY6HNCAZ.js";import{a as zr}from"./chunk-MOI4L3EX.js";import{a as ae,b as Jr,c as de,d as Qr}from"./chunk-PXZV5X3C.js";import{a as R}from"./chunk-OQ6KNYPG.js";import{b as z}from"./chunk-UVYCSHOJ.js";import{a as C,b as Tr,c as y}from"./chunk-LEFXRK53.js";import{a as Mr}from"./chunk-7WZ3VIUU.js";import{e as Ne,f as nn}from"./chunk-4W6WIT7T.js";import{a as hr,b as Vn,c as Hn}from"./chunk-WHSQBXWO.js";import{a as w}from"./chunk-R4ZTRVDQ.js";import{b as kr,c as K,d as wr,e as br}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as jr,b}from"./chunk-2MT2MZJW.js";import{a as D,b as $r,c as Ir,d as Ar}from"./chunk-AVBP7Q2M.js";import{a as x}from"./chunk-MHNGR6M7.js";import{e as Kr,g as le,h as Gr}from"./chunk-EK6TENV6.js";import{b as G,e as j,g as Pr,h as oe}from"./chunk-AQ3DMGAY.js";import"./chunk-DBIXYJRB.js";import{a as lr,b as dr,c as ur,d as u,f as O,h as cr,j as P,k as pr,l as mr,m as Te,n as fr,o as gr,p as yr}from"./chunk-PE5WVWI5.js";import{a as ne}from"./chunk-CJUKILIO.js";import{k as Oe,l as fn}from"./chunk-M7VQD4VO.js";import{F as Dr,K as Me,N as Ur,O as qr,T as Br,W as se,X as Vr,_ as Hr,e as ie,i as Lr,j as Nr,l as Or,m as _r,w as p,x as Fr,y as Wr}from"./chunk-ESOXRGIY.js";import{A as xr,B as te,H as W,I as Cr,N as Sr,S as Rr,T as Er,i as vr,n as _,o as F}from"./chunk-5SM4TCSW.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{availableParallelism as Uu}from"os";import{existsSync as Kn}from"fs";function Gn(){let e=new URL("solve-worker.js",import.meta.url);if(Kn(e))return e;let r=new URL("../dist/solve-worker.js",import.meta.url);if(Kn(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 qu from"update-notifier";import Bu from"yargs";import{hideBin as Vu}from"yargs/helpers";function me({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 zn(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as us}from"gql.tada";import{exec as rs}from"child_process";import{createAuthClient as Zi}from"better-auth/client";import{deviceAuthorizationClient as es}from"better-auth/client/plugins";function Jn({baseURL:e}){return Zi({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[es()]})}import{err as Qn,ok as ns}from"neverthrow";var ts=5e3,Xn="ripplo-cli";async function Yn({onDeviceCode:e,url:r}){let n=r??Tr().RIPPLO_SERVER_URL,t=Jn({baseURL:n}),o=await t.device.code({client_id:Xn});if(o.error!=null)return Qn({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}),ds(a),(await os({authClient:t,deviceCode:i})).map(d=>(pr({serverUrl:n,token:d}),d))}async function os({authClient:e,deviceCode:r}){for(;;){await as(ts);let n=await e.device.token({client_id:Xn,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return ns(n.data.access_token);if(n.error==null)continue;if(!ss(n.error.error))return Qn({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var is=new Set(["authorization_pending","slow_down"]);function ss(e){return is.has(e)}function as(e){return new Promise(r=>{setTimeout(r,e)})}function ls(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function ds(e){let r=ls();rs(`${r} "${e}"`,()=>{})}function I({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var cs=us(`
5
5
  query AuthViewer {
6
6
  currentUser {
7
7
  name
8
8
  email
9
9
  }
10
10
  }
11
- `);async function Yn(){let e=C(),r=P(e);if(r!=null&&await cs(e,r))return;let t=(await Xn({url:e,onDeviceCode:a=>{process.stdout.write(`Opening your browser to finish sign-in.
11
+ `);async function Zn(){let e=C(),r=P(e);if(r!=null&&await ps(e,r))return;let t=(await Yn({url:e,onDeviceCode:a=>{process.stdout.write(`Opening your browser to finish sign-in.
12
12
  `),process.stdout.write(`If it didn't open, visit: ${a.verificationUrl}
13
13
  `),process.stdout.write(`Verification code: ${a.userCode}
14
14
 
15
15
  `),process.stdout.write(`Waiting for approval...
16
16
  `)}})).match(a=>a,a=>{process.stderr.write(`${b(a)}
17
- `),process.exit(1)}),o=await We({serverUrl:e,token:t}),i=Mr(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
- `),process.stdout.write(o.kind==="ok"?`${s}, ${ps(o.viewer)}.
17
+ `),process.exit(1)}),o=await Fe({serverUrl:e,token:t}),i=Mr(process.cwd()),s=i?"Welcome back":"Welcome to Ripplo";process.stdout.write(`
18
+ `),process.stdout.write(o.kind==="ok"?`${s}, ${ms(o.viewer)}.
19
19
  `:`${s}.
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 cs(e,r){let n=await We({serverUrl:e,token:r});return n.kind==="ok"?(process.stdout.write(`Already signed in as ${n.viewer.email}. Run \`npx ripplo auth logout\` to switch accounts.
20
+ `),process.stdout.write(`Session saved to ${Te(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 ps(e,r){let n=await Fe({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 Zn(){let e=C(),r=P(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await We({serverUrl:e,token:r});n.kind==="unreachable"&&(process.stdout.write(`Could not reach the Ripplo server at ${e} (${n.message}). The token may still be valid \u2014 check the server / network and retry.
25
+ `),!1)}async function et(){let e=C(),r=P(e);r==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login`.\n"),process.exit(1));let n=await Fe({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 et(){let e=C();if(!fr(e)){process.stdout.write(`Already signed out.
29
- `);return}process.stdout.write(`Signed out. Removed ${Me(e)}.
30
- `)}async function We({serverUrl:e,token:r}){try{let t=(await u({config:I({serverUrl:e,token:r}),document:us,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return cr(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function ps(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as ms,writeFile as fs}from"fs/promises";import gs from"path";async function rt(e){let r=process.cwd(),n=await se(r);n.isErr()&&De(D(n.error));let t=n.value,[o,i]=await Promise.all([de({cwd:r,lockfile:t}),U(r,t)]);o.length>0&&De(ue(o));let s=oe(j,i),a=gs.join(r,T);if(e.check){await ys(a,s);return}await fs(a,s),hs(i)}function De(e){process.stderr.write(`${e}
31
- `),process.exit(1)}async function ys(e,r){let n=await ms(e,"utf8").catch(()=>null);n!==r&&De(Ir(n==null?"missing":"stale")),process.stdout.write(`${$r()}
32
- `)}function hs(e){let r=Gr(e),n=e.workflows.reduce((o,i)=>o+i.tests.length,0),t=[Ar(),...r.length>0?[Jr(r)]:[],zr(n)];process.stdout.write(`${t.join(`
28
+ `)}function rt(){let e=C();if(!mr(e)){process.stdout.write(`Already signed out.
29
+ `);return}process.stdout.write(`Signed out. Removed ${Te(e)}.
30
+ `)}async function Fe({serverUrl:e,token:r}){try{let t=(await u({config:I({serverUrl:e,token:r}),document:cs,variables:void 0})).currentUser;return t==null?{kind:"rejected"}:{kind:"ok",viewer:{email:t.email,name:t.name}}}catch(n){return ur(n)==="UNAUTHENTICATED"?{kind:"rejected"}:{kind:"unreachable",message:n instanceof Error?n.message:String(n)}}}function ms(e){let r=e.name.trim().split(/\s+/)[0];return r!=null&&r.length>0?r:e.email}import{readFile as fs,writeFile as gs}from"fs/promises";import ys from"path";async function nt(e){let r=process.cwd(),n=await oe(r);n.isErr()&&We(D(n.error));let t=n.value,[o,i]=await Promise.all([ae({cwd:r,lockfile:t}),le(r,t)]);o.length>0&&We(de(o));let s=xr(W,i),a=ys.join(r,j);if(e.check){await hs(a,s);return}await gs(a,s),ks(i)}function We(e){process.stderr.write(`${e}
31
+ `),process.exit(1)}async function hs(e,r){let n=await fs(e,"utf8").catch(()=>null);n!==r&&We(Ir(n==null?"missing":"stale")),process.stdout.write(`${$r()}
32
+ `)}function ks(e){let r=zr(e),n=e.workflows.reduce((o,i)=>o+i.tests.length,0),t=[Ar(),...r.length>0?[Qr(r)]:[],Jr(n)];process.stdout.write(`${t.join(`
33
33
  `)}
34
- `)}import{graphql as nt}from"gql.tada";function Ue(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 ks}from"gql.tada";var ws=ks(`
34
+ `)}import{graphql as tt}from"gql.tada";function De(e){return e==null?"Max local concurrent runs: unknown (not signed in?)":`Max local concurrent runs: ${String(e)} (the daemon applies changes live)`}import{graphql as ws}from"gql.tada";var bs=ws(`
35
35
  query DevSessionCheckPreflight($projectId: String!, $cwd: String!) {
36
36
  project(id: $projectId) {
37
37
  id
@@ -42,55 +42,55 @@ import{a as ln,c as dn,d as un,e as cn,f as pn,g as pe}from"./chunk-VYQ5CDRX.js"
42
42
  }
43
43
  `);function g(){return y(process.cwd()).match(e=>e,e=>{process.stderr.write(`${b(e)}
44
44
  `),process.stderr.write(`${x("setup")}
45
- `),process.exit(1)})}async function v(e){(await u({config:e,document:ws,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 bs=nt(`
45
+ `),process.exit(1)})}async function v(e){(await u({config:e,document:bs,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 vs=tt(`
47
47
  mutation CliUpdateMaxLocalConcurrentRuns($value: Int!) {
48
48
  updateMaxLocalConcurrentRuns(value: $value) {
49
49
  id
50
50
  maxLocalConcurrentRuns
51
51
  }
52
52
  }
53
- `),vs=nt(`
53
+ `),xs=tt(`
54
54
  query CliMaxLocalConcurrentRuns {
55
55
  currentUser {
56
56
  id
57
57
  maxLocalConcurrentRuns
58
58
  }
59
59
  }
60
- `);async function tt({value:e}){let r=g();if(e==null){let t=await u({config:r,document:vs,variables:{}});process.stdout.write(`${Ue(t.currentUser?.maxLocalConcurrentRuns)}
61
- `);return}let n=await u({config:r,document:bs,variables:{value:e}});process.stdout.write(`${Ue(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
- `)}function ot(e){switch(e.type){case"settings":return xs(e);case"env-files":return Cs(e);case"token":return Ss(e);case"dev-server":return Rs(e);case"dev-session":return Xr(e);case"entities":return Es(e);case"webhook-verification":return Ps(e);case"entities-validation":return $s(e);case"workflows":return Is(e);case"browser":return js(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 Ts(e);case"lockfile":return Ms(e);case"pre-commit-hook":return Ls(e);case"plugin-version":return Ns(e)}}function xs(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function Cs(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 ot({value:e}){let r=g();if(e==null){let t=await u({config:r,document:xs,variables:{}});process.stdout.write(`${De(t.currentUser?.maxLocalConcurrentRuns)}
61
+ `);return}let n=await u({config:r,document:vs,variables:{value:e}});process.stdout.write(`${De(n.updateMaxLocalConcurrentRuns?.maxLocalConcurrentRuns)}
62
+ `)}function it(e){switch(e.type){case"settings":return Cs(e);case"env-files":return Ss(e);case"token":return Rs(e);case"dev-server":return Es(e);case"dev-session":return Yr(e);case"entities":return Ps(e);case"webhook-verification":return $s(e);case"entities-validation":return Is(e);case"workflows":return As(e);case"browser":return Ts(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 Ms(e);case"lockfile":return Ls(e);case"pre-commit-hook":return Ns(e);case"plugin-version":return Os(e)}}function Cs(e){return e.valid?"\u2713 Settings: project configured":`\u2717 Settings: missing fields: ${e.missingFields.join(", ")}`}function Ss(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 Ss(e){switch(e.status){case"valid":return`\u2713 Auth: signed in as ${e.email??"unknown"}`;case"missing":return"\u2717 Auth: not signed in. Run `npx ripplo auth login`.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"invalid":return"\u2717 Auth: saved token rejected by the server. Run `npx ripplo auth login` to sign in again.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"unreachable":return`! Auth: could not reach ${C()} to validate the token.`}}function Rs(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function Es(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 Ps(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 $s(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 Rs(e){switch(e.status){case"valid":return`\u2713 Auth: signed in as ${e.email??"unknown"}`;case"missing":return"\u2717 Auth: not signed in. Run `npx ripplo auth login`.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"invalid":return"\u2717 Auth: saved token rejected by the server. Run `npx ripplo auth login` to sign in again.\n (Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)";case"unreachable":return`! Auth: could not reach ${C()} to validate the token.`}}function Es(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Start your dev server.`}function Ps(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 Is(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 Is(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=>As(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
67
+ `)}`}function As(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=>js(n));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
68
68
  ${r.join(`
69
- `)}`}function As(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
69
+ `)}`}function js(e){let r=e.errors.map(n=>" - "+(n.path===""?"":n.path+": ")+n.message);return" "+e.name+`:
70
70
  `+r.join(`
71
- `)}function js(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function Ts(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 Ms(e){switch(e.status){case"match":return`\u2713 Lockfile: ${T} is up to date`;case"missing":return`\u2717 Lockfile: ${T} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${T} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function Ls(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 Ns(e){return e.installed===e.cliVersion?`\u2713 Claude plugin: v${e.installed} matches CLI`:`! Claude plugin: installed v${e.installed}, CLI v${e.cliVersion} \u2014 run \`npx ripplo update\` (or /plugin in Claude Code)`}import q from"fs";import Ds from"os";import qe from"path";import{z as M}from"zod";import Os from"latest-version";import it from"semver";async function ge(e){try{return await Promise.race([Os("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function st(e){return e.filter(r=>it.valid(r)!=null).toSorted(it.rcompare)[0]}import{graphql as _s}from"gql.tada";var Fs=_s(`
71
+ `)}function Ts(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run `npx playwright install chromium`."}function Ms(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 Ls(e){switch(e.status){case"match":return`\u2713 Lockfile: ${j} is up to date`;case"missing":return`\u2717 Lockfile: ${j} is missing \u2014 run \`npx ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${j} is out of date \u2014 run \`npx ripplo compile\` and commit it`}}function Ns(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 Os(e){return e.installed===e.cliVersion?`\u2713 Claude plugin: v${e.installed} matches CLI`:`! Claude plugin: installed v${e.installed}, CLI v${e.cliVersion} \u2014 run \`npx ripplo update\` (or /plugin in Claude Code)`}import U from"fs";import Us from"os";import Ue from"path";import{z as T}from"zod";import _s from"latest-version";import st from"semver";async function fe(e){try{return await Promise.race([_s("ripplo"),new Promise(r=>setTimeout(()=>{r(void 0)},e))])}catch{return}}function at(e){return e.filter(r=>st.valid(r)!=null).toSorted(st.rcompare)[0]}import{graphql as Fs}from"gql.tada";var Ws=Fs(`
72
72
  query DoctorAuthViewer {
73
73
  currentUser {
74
74
  name
75
75
  email
76
76
  }
77
77
  }
78
- `),Ws="Failed to connect to Ripplo server";async function at({serverUrl:e,token:r}){try{let n=await u({config:I({serverUrl:e,token:r}),document:Fs,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(Ws)?{kind:"unreachable"}:{kind:"invalid"}}}function lt(e){switch(e.type){case"settings":return!e.valid;case"env-files":return e.missing.length>0;case"token":return e.status==="missing"||e.status==="invalid";case"dev-server":return!e.reachable;case"dev-session":return e.status!=="active";case"entities":return e.count>0&&!e.configured;case"engine-endpoint":return!e.reachable;case"adapter-enabled":return e.status!=="enabled";case"webhook-verification":return!e.rejectsUnsigned;case"entities-validation":return!e.valid;case"workflows":return e.invalidNames.length>0;case"browser":return!e.installed;case"lockfile":return e.status!=="match";case"pre-commit-hook":return!e.installed;case"plugin-version":return!1}}async function dt(e){let r=await Bs(e),n={missing:vr(e),type:"env-files"},t=await Vs(),o=await Hs(),i=await se(e),s=await Ks(e,i),a=Gs(i),l=await zs(e,i),d=Qs(e),f=qs(e),h=await Xs(r,i);return[r,n,t,...h,s,a,l,d,o,...f==null?[]:[f]]}var Us=M.object({plugins:M.record(M.string(),M.array(M.object({projectPath:M.string().optional(),scope:M.string().optional(),version:M.string()})))});function qs(e){let r=qe.join(Ds.homedir(),".claude","plugins","installed_plugins.json"),n=q.existsSync(r)?q.readFileSync(r,"utf8"):null;if(n==null)return null;let t=Us.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=st(o);return i==null?null:{cliVersion:w(),installed:i,type:"plugin-version"}}async function Bs(e){let r=await Zr(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 Vs(){let e=C(),r=P(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await at({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 Hs(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:q.existsSync(r),type:"browser"}}async function Ks(e,r){if(r.isErr())return{errorCount:1,errors:[{message:D(r.error),path:".ripplo/"}],found:!1,type:"entities-validation",valid:!1};let n=await de({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:ue(n),path:""}],found:!0,type:"entities-validation",valid:n.length===0}}function Gs(e){if(e.isErr())return{invalidNames:[],invalidWorkflows:[],total:0,type:"workflows",valid:0};let r=e.value.workflows.length;return{invalidNames:[],invalidWorkflows:[],total:r,type:"workflows",valid:r}}async function zs(e,r){if(r.isErr())return{status:"missing",type:"lockfile"};let n=await U(e,r.value),t=oe(j,n),o=await q.promises.readFile(qe.join(e,T),"utf8").catch(()=>null);return{status:Js(o,t),type:"lockfile"}}function Js(e,r){return e==null?"missing":e===r?"match":"stale"}function Qs(e){let r=qe.join(e,".git","hooks","pre-commit");return q.existsSync(r)?{installed:q.readFileSync(r,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function Xs(e,r){let n=br().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Ne(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await Yr(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await Ys(n,r);t.push(...s)}return t}async function Ys(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=ea(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Ne(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"entities"}),ut(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await en({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let d=await Zs({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:d,type:"adapter-enabled",url:i}),a}async function Zs({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",...yr({body:n,secret:r})},method:"PUT",signal:AbortSignal.timeout(5e3)});return t.status===404?"disabled":t.status===401||t.status===403?"bad-secret":"enabled"}catch{return"unreachable"}}function ut(e){return e.startsWith("http://")||e.startsWith("https://")}function ea(e,r){return ut(r)?r:`${e}${r}`}var ra=3e3;async function ct(){let e=process.cwd(),[r,n]=await Promise.all([ge(ra),dt(e)]);process.stdout.write(`${fe({current:w(),latest:r})}
79
- `);let t=n.map(i=>ot(i));process.stdout.write(t.join(`
78
+ `),Ds="Failed to connect to Ripplo server";async function lt({serverUrl:e,token:r}){try{let n=await u({config:I({serverUrl:e,token:r}),document:Ws,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(Ds)?{kind:"unreachable"}:{kind:"invalid"}}}function dt(e){switch(e.type){case"settings":return!e.valid;case"env-files":return e.missing.length>0;case"token":return e.status==="missing"||e.status==="invalid";case"dev-server":return!e.reachable;case"dev-session":return e.status!=="active";case"entities":return e.count>0&&!e.configured;case"engine-endpoint":return!e.reachable;case"adapter-enabled":return e.status!=="enabled";case"webhook-verification":return!e.rejectsUnsigned;case"entities-validation":return!e.valid;case"workflows":return e.invalidNames.length>0;case"browser":return!e.installed;case"lockfile":return e.status!=="match";case"pre-commit-hook":return!e.installed;case"plugin-version":return!1}}async function ut(e){let r=await Vs(e),n={missing:br(e),type:"env-files"},t=await Hs(),o=await Ks(),i=await oe(e),s=await Gs(e,i),a=zs(i),l=await Js(e,i),d=Qs(e),f=Bs(e),h=await Xs(r,i);return[r,n,t,...h,s,a,l,d,o,...f==null?[]:[f]]}var qs=T.object({plugins:T.record(T.string(),T.array(T.object({projectPath:T.string().optional(),scope:T.string().optional(),version:T.string()})))});function Bs(e){let r=Ue.join(Us.homedir(),".claude","plugins","installed_plugins.json"),n=U.existsSync(r)?U.readFileSync(r,"utf8"):null;if(n==null)return null;let t=qs.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=at(o);return i==null?null:{cliVersion:w(),installed:i,type:"plugin-version"}}async function Vs(e){let r=await en(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 Hs(){let e=C(),r=P(e);if(r==null||r.length===0)return{email:void 0,status:"missing",type:"token"};let n=await lt({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 Ks(){let{chromium:e}=await import("playwright"),r=e.executablePath();return{installed:U.existsSync(r),type:"browser"}}async function Gs(e,r){if(r.isErr())return{errorCount:1,errors:[{message:D(r.error),path:".ripplo/"}],found:!1,type:"entities-validation",valid:!1};let n=await ae({cwd:e,lockfile:r.value});return{errorCount:n.length,errors:n.length===0?[]:[{message:de(n),path:""}],found:!0,type:"entities-validation",valid:n.length===0}}function zs(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 Js(e,r){return r.isErr()?{status:"missing",type:"lockfile"}:await Gr(e,r.value)!=null?{status:"match",type:"lockfile"}:{status:await U.promises.readFile(Ue.join(e,j),"utf8").catch(()=>null)==null?"missing":"stale",type:"lockfile"}}function Qs(e){let r=Ue.join(e,".git","hooks","pre-commit");return U.existsSync(r)?{installed:U.readFileSync(r,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function Xs(e,r){let n=wr().map(s=>({appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret})).unwrapOr(void 0);if(n==null)return[];let t=[],o=await Le(n.appUrl)==null;t.push({appUrl:n.appUrl,reachable:o,type:"dev-server"});let i=await Zr(process.cwd());if(t.push(i),e.valid&&r.isOk()){let s=await Ys(n,r);t.push(...s)}return t}async function Ys(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=ea(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await Le(i)==null,a=[];if(a.push({configured:!0,count:n,endpointReachable:s,type:"entities"}),ct(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await rn({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let d=await Zs({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:d,type:"adapter-enabled",url:i}),a}async function Zs({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",...gr({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 ct(e){return e.startsWith("http://")||e.startsWith("https://")}function ea(e,r){return ct(r)?r:`${e}${r}`}var ra=3e3;async function pt(){let e=process.cwd(),[r,n]=await Promise.all([fe(ra),ut(e)]);process.stdout.write(`${me({current:w(),latest:r})}
79
+ `);let t=n.map(i=>it(i));process.stdout.write(t.join(`
80
80
  `)+`
81
- `);let o=n.some(i=>lt(i));process.exit(o?1:0)}import ye from"fs";import{graphql as na}from"gql.tada";var ta=na(`
81
+ `);let o=n.some(i=>dt(i));process.exit(o?1:0)}import ge from"fs";import{graphql as na}from"gql.tada";var ta=na(`
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 pt(){let e=process.cwd();pr(e);let r=Oe(e);if(ye.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}ye.writeFileSync(r,""),await ft(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 mt(){let e=process.cwd(),r=Oe(e);if(!ye.existsSync(r)){process.stdout.write(`Hooks already active.
88
- `);return}ye.unlinkSync(r),await ft(e,!1),process.stdout.write(`Hooks resumed.
89
- `)}async function ft(e,r){let n=y(e).unwrapOr(void 0);n!=null&&await u({config:n,document:ta,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 B from"fs";import V from"path";import{input as vt,select as xt}from"@inquirer/prompts";import{graphql as Oa}from"gql.tada";import{exec as oa,execFile as ia}from"child_process";import{err as sa,ok as gt}from"neverthrow";import m from"fs";import{createRequire as aa}from"module";import k from"path";import{promisify as ht}from"util";var la=["ripplo","@ripplo/testing","@ripplo/instrument"],yt=".ripplo/ripplo.lock linguist-generated=true",da=[".ripplo/debug/",".ripplo/.local/"],ua=ht(oa),ca=ht(ia);async function kt({cwd:e,onStep:r}){r("Scaffolding project files..."),xa({cwd:e}),r("Updating .gitignore..."),Sa(e),r("Marking ripplo.lock as generated..."),ga(e),r("Installing dependencies...");let n=await ma(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 fa(e);i!=null&&t.push({manualCommand:void 0,message:i})}return r("Setting up browser..."),(await pa()).map(()=>t)}async function pa(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return gt(void 0);_.info("Chromium not found. Installing via Playwright...");let n=aa(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)?gt(void 0):sa({kind:"playwright-install-failed"})}async function ma(e){let r=ya({cwd:e,pm:va(e)});_.info("Installing dependencies: %s",r);try{return await ua(r,{cwd:e}),{ok:!0}}catch(n){let t=n instanceof Error?n.message.split(`
91
- `)[0]??n.message:String(n);return _.warn("Install failed (%s): %s",r,t),{cmd:r,ok:!1,reason:t}}}async function fa(e){try{await Kr(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function ga(e){let r=k.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes(yt))return;let t=n.length===0||n.endsWith(`
87
+ `);async function mt(){let e=process.cwd();cr(e);let r=Ne(e);if(ge.existsSync(r)){process.stdout.write("Hooks already paused. Run `npx ripplo hooks resume` to re-enable.\n");return}ge.writeFileSync(r,""),await gt(e,!0),process.stdout.write("Hooks paused. Pre-edit gates and stop enforcement are off until you run `npx ripplo hooks resume`.\n")}async function ft(){let e=process.cwd(),r=Ne(e);if(!ge.existsSync(r)){process.stdout.write(`Hooks already active.
88
+ `);return}ge.unlinkSync(r),await gt(e,!1),process.stdout.write(`Hooks resumed.
89
+ `)}async function gt(e,r){let n=y(e).unwrapOr(void 0);n!=null&&await u({config:n,document:ta,variables:{paused:r,projectId:n.projectId}}).catch(t=>{process.stderr.write(`Warning: could not push hook-pause state to the server (${t instanceof Error?t.message:String(t)}) \u2014 the dashboard may show stale hook status.
90
+ `)})}import q from"fs";import B from"path";import{input as xt,select as Ct}from"@inquirer/prompts";import{graphql as Oa}from"gql.tada";import{exec as oa,execFile as ia}from"child_process";import{err as sa,ok as yt}from"neverthrow";import m from"fs";import{createRequire as aa}from"module";import k from"path";import{promisify as kt}from"util";var la=["ripplo","@ripplo/testing","@ripplo/instrument"],ht=".ripplo/ripplo.lock linguist-generated=true",da=[".ripplo/debug/",".ripplo/.local/"],ua=kt(oa),ca=kt(ia);async function wt({cwd:e,onStep:r}){r("Scaffolding project files..."),xa({cwd:e}),r("Updating .gitignore..."),Sa(e),r("Marking ripplo.lock as generated..."),ga(e),r("Installing dependencies...");let n=await ma(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 fa(e);i!=null&&t.push({manualCommand:void 0,message:i})}return r("Setting up browser..."),(await pa()).map(()=>t)}async function pa(){let{chromium:e}=await import("playwright"),r=e.executablePath();if(m.existsSync(r))return yt(void 0);O.info("Chromium not found. Installing via Playwright...");let n=aa(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)?yt(void 0):sa({kind:"playwright-install-failed"})}async function ma(e){let r=ya({cwd:e,pm:va(e)});O.info("Installing dependencies: %s",r);try{return await ua(r,{cwd:e}),{ok:!0}}catch(n){let t=n instanceof Error?n.message.split(`
91
+ `)[0]??n.message:String(n);return O.warn("Install failed (%s): %s",r,t),{cmd:r,ok:!1,reason:t}}}async function fa(e){try{await Kr(e);return}catch(r){return`Couldn't compile initial lockfile: ${r instanceof Error?r.message:String(r)}.`}}function ga(e){let r=k.join(e,".gitattributes"),n=m.existsSync(r)?m.readFileSync(r,"utf8"):"";if(n.includes(ht))return;let t=n.length===0||n.endsWith(`
92
92
  `)?"":`
93
- `;m.writeFileSync(r,`${n}${t}${yt}
93
+ `;m.writeFileSync(r,`${n}${t}${ht}
94
94
  `)}function ya({cwd:e,pm:r}){let n=la.join(" ");return r==="pnpm"?ha(e)?`pnpm add -wD ${n}`:`pnpm add -D ${n}`:r==="yarn"?ka({cwd:e,deps:n}):r==="bun"?`bun add -d ${n}`:`npm install -D ${n}`}function ha(e){return m.existsSync(k.join(e,"pnpm-workspace.yaml"))||m.existsSync(k.join(e,"pnpm-workspace.yml"))}function ka({cwd:e,deps:r}){return wa(e)?`yarn add -D ${r}`:ba(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`}function wa(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 ba(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 va(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 xa({cwd:e}){let r=k.join(e,".ripplo");Ma.forEach(({content:n,relPath:t})=>{let o=k.join(r,t);m.mkdirSync(k.dirname(o),{recursive:!0}),Ca(o,n)})}function Ca(e,r){m.existsSync(e)||m.writeFileSync(e,r)}function Sa(e){let r=k.join(e,".gitignore");if(!m.existsSync(r))return;let n=m.readFileSync(r,"utf8"),t=da.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(`
@@ -200,47 +200,47 @@ export default tseslint.config({
200
200
  },
201
201
  plugins: { "@typescript-eslint": tseslint.plugin },
202
202
  });
203
- `,Ma=[{content:Ra,relPath:"index.ts"},{content:Ea,relPath:"entities/index.ts"},{content:Pa,relPath:"singletons/index.ts"},{content:$a,relPath:"facts.ts"},{content:Ia,relPath:"givens.ts"},{content:Aa,relPath:"workflows/index.ts"},{content:ja,relPath:"tsconfig.json"},{content:Ta,relPath:"eslint.config.js"}];import he from"fs";import wt from"path";import{z as Be}from"zod";var La={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},bt=Be.record(Be.string(),Be.unknown());function ke(e){let r=wt.join(e,".claude","settings.json"),n=Na(r);if(n==null)return"unparseable";let t=bt.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:La}};return he.mkdirSync(wt.dirname(r),{recursive:!0}),he.writeFileSync(r,`${JSON.stringify(o,null,2)}
204
- `),"written"}function Na(e){if(!he.existsSync(e))return{};try{let r=bt.safeParse(JSON.parse(he.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function we(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 _a=Oa(`
203
+ `,Ma=[{content:Ra,relPath:"index.ts"},{content:Ea,relPath:"entities/index.ts"},{content:Pa,relPath:"singletons/index.ts"},{content:$a,relPath:"facts.ts"},{content:Ia,relPath:"givens.ts"},{content:Aa,relPath:"workflows/index.ts"},{content:ja,relPath:"tsconfig.json"},{content:Ta,relPath:"eslint.config.js"}];import ye from"fs";import bt from"path";import{z as qe}from"zod";var La={autoUpdate:!0,source:{repo:"ripplo/claude-plugin",source:"github"}},vt=qe.record(qe.string(),qe.unknown());function he(e){let r=bt.join(e,".claude","settings.json"),n=Na(r);if(n==null)return"unparseable";let t=vt.safeParse(n.extraKnownMarketplaces??{});if(!t.success)return"unparseable";if(t.data.ripplo!=null)return"already-present";let o={...n,extraKnownMarketplaces:{...t.data,ripplo:La}};return ye.mkdirSync(bt.dirname(r),{recursive:!0}),ye.writeFileSync(r,`${JSON.stringify(o,null,2)}
204
+ `),"written"}function Na(e){if(!ye.existsSync(e))return{};try{let r=vt.safeParse(JSON.parse(ye.readFileSync(e,"utf8")));return r.success?r.data:void 0}catch{return}}function ke(e){switch(e){case"written":return" registered ripplo plugin marketplace in .claude/settings.json (autoUpdate: true \u2014 Claude Code keeps the plugin current)";case"already-present":return" ripplo plugin marketplace already registered in .claude/settings.json";case"unparseable":return" ! .claude/settings.json could not be parsed \u2014 add the ripplo marketplace to extraKnownMarketplaces manually"}}var _a=Oa(`
205
205
  query InitProjects {
206
206
  projects {
207
207
  id
208
208
  name
209
209
  }
210
210
  }
211
- `),Ve=["../.env.local","../.env"];async function Ct(e=Da()){let r=process.cwd(),n=C(),t=P(n);t==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login` first.\n"),process.exit(1)),Fa(r)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${r}. To re-init, delete it first.
212
- `),process.exit(1));let o=await Wa({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 qa(o,e.projectId),s=await Ba(r,e.envFile),a=await Ha(e.appUrl),l=Ua(a,e.engineUrl),d=V.resolve(V.join(r,".ripplo"),s);wr({cwd:r,envFiles:[s],projectId:i}),Ga({appUrl:a,engineUrl:l,filePath:d}),process.stdout.write(`${we(ke(r))}
213
- `);let h=(await kt({cwd:r,onStep:c=>{process.stdout.write(` ${c}
211
+ `),Be=["../.env.local","../.env"];async function St(e=Da()){let r=process.cwd(),n=C(),t=P(n);t==null&&(process.stdout.write("Not signed in. Run `npx ripplo auth login` first.\n"),process.exit(1)),Fa(r)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${r}. To re-init, delete it first.
212
+ `),process.exit(1));let o=await Wa({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 qa(o,e.projectId),s=await Ba(r,e.envFile),a=await Ha(e.appUrl),l=Ua(a,e.engineUrl),d=B.resolve(B.join(r,".ripplo"),s);kr({cwd:r,envFiles:[s],projectId:i}),Ga({appUrl:a,engineUrl:l,filePath:d}),process.stdout.write(`${ke(he(r))}
213
+ `);let h=(await wt({cwd:r,onStep:c=>{process.stdout.write(` ${c}
214
214
  `)}})).match(c=>c,c=>{process.stderr.write(`${b(c)}
215
215
  `),process.exit(1)});if(h.length>0){process.stdout.write(`Done with warnings:
216
216
  `),h.forEach(c=>{process.stdout.write(` - ${c.message}
217
217
  `),c.manualCommand!=null&&process.stdout.write(` run: ${c.manualCommand}
218
- `)});return}process.stdout.write("Ready. Start `npx ripplo daemon` as a background process (or run `/ripplo:start` in Claude Code), then write workflows in `.ripplo/workflows/`.\n")}function Fa(e){return B.existsSync(V.join(e,".ripplo","index.ts"))}async function Wa({serverUrl:e,token:r}){return((await u({config:I({serverUrl:e,token:r}),document:_a,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function Da(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function Ua(e,r){if(r!=null){try{new URL(r)}catch{process.stdout.write(`--engine-url is not a valid URL: ${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 Fa(e){return q.existsSync(B.join(e,".ripplo","index.ts"))}async function Wa({serverUrl:e,token:r}){return((await u({config:I({serverUrl:e,token:r}),document:_a,variables:void 0})).projects??[]).map(t=>({id:t.id,name:t.name}))}function Da(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function Ua(e,r){if(r!=null){try{new URL(r)}catch{process.stdout.write(`--engine-url is not a valid URL: ${r}
219
219
  `),process.exit(1)}return r}return`${e.replace(/\/$/,"")}/ripplo`}async function qa(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 xt({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function Ba(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
223
- `),process.exit(1)),r):Va(e)}async function Va(e){let r=V.join(e,".ripplo"),n=Ve.find(o=>B.existsSync(V.resolve(r,o))),t=await xt({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:vt({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function Ha(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 Ka()}async function Ka(){return vt({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 Ga({appUrl:e,engineUrl:r,filePath:n}){B.mkdirSync(V.dirname(n),{recursive:!0});let t=B.existsSync(n)?B.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=${hr()}`),/^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 Ct({choices:e.map(n=>({name:n.name,value:n.id})),message:"Select a project"})}async function Ba(e,r){return r!=null?(r.trim().length===0&&(process.stdout.write(`--env must not be empty
223
+ `),process.exit(1)),r):Va(e)}async function Va(e){let r=B.join(e,".ripplo"),n=Be.find(o=>q.existsSync(B.resolve(r,o))),t=await Ct({choices:[...Be.map(o=>({name:n===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:n??Be[0],message:"Which env file should ripplo write RIPPLO_APP_URL, RIPPLO_ENGINE_URL, RIPPLO_WEBHOOK_SECRET, and ENABLE_RIPPLO_TESTING to?"});return t!=="__custom__"?t:xt({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function Ha(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 Ka()}async function Ka(){return xt({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 Ga({appUrl:e,engineUrl:r,filePath:n}){q.mkdirSync(B.dirname(n),{recursive:!0});let t=q.existsSync(n)?q.readFileSync(n,"utf8"):"",o=[];if(/^RIPPLO_APP_URL=/m.test(t)||o.push(`RIPPLO_APP_URL=${e}`),/^RIPPLO_ENGINE_URL=/m.test(t)||o.push(`RIPPLO_ENGINE_URL=${r}`),/^RIPPLO_WEBHOOK_SECRET=/m.test(t)||o.push(`RIPPLO_WEBHOOK_SECRET=${yr()}`),/^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
- `;B.writeFileSync(n,`${t}${i}${o.join(`
226
+ `;q.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 St(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function Rt(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 za=Ge(`
228
+ `)}import{graphql as Ke}from"gql.tada";function Ve(){return"Not signed in. Run `npx ripplo auth login` first."}function Rt(){return"No organization found for your account. Sign in to the dashboard once, then retry."}function Et(e){return["You belong to multiple organizations \u2014 pass `--org <id>`:",...e.map(n=>` ${n.id} ${n.name}`)].join(`
229
+ `)}function He(e){return`Could not create the project \u2014 ${e}`}var za=Ke(`
230
230
  query ProjectsList {
231
231
  projects {
232
232
  id
233
233
  name
234
234
  }
235
235
  }
236
- `),Ja=Ge(`
236
+ `),Ja=Ke(`
237
237
  query OrganizationsList {
238
238
  organizations {
239
239
  id
240
240
  name
241
241
  }
242
242
  }
243
- `),Qa=Ge(`
243
+ `),Qa=Ke(`
244
244
  mutation CliCreateProject($name: String!, $organizationId: String!) {
245
245
  createProject(cloudBaseUrl: "", name: $name, organizationId: $organizationId) {
246
246
  __typename
@@ -256,17 +256,17 @@ export default tseslint.config({
256
256
  }
257
257
  }
258
258
  }
259
- `);async function Et(){let e=C(),r=P(e);r==null&&(process.stderr.write(`${He()}
259
+ `);async function Pt(){let e=C(),r=P(e);r==null&&(process.stderr.write(`${Ve()}
260
260
  `),process.exit(1));let t=((await u({config:I({serverUrl:e,token:r}),document:za,variables:void 0})).projects??[]).map(o=>({id:o.id,name:o.name}));process.stdout.write(`${JSON.stringify({projects:t},null,2)}
261
- `)}async function Pt({name:e,orgId:r}){let n=C(),t=P(n);t==null&&(process.stderr.write(`${He()}
262
- `),process.exit(1));let o=I({serverUrl:n,token:t}),i=r??await Xa(o),a=(await u({config:o,document:Qa,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof ur&&(process.stderr.write(`${Ke(l.message)}
263
- `),process.exit(1)),l})).createProject;if(a?.__typename!=="Project"){let l=a?.message??"unknown error";process.stderr.write(`${Ke(l)}
261
+ `)}async function $t({name:e,orgId:r}){let n=C(),t=P(n);t==null&&(process.stderr.write(`${Ve()}
262
+ `),process.exit(1));let o=I({serverUrl:n,token:t}),i=r??await Xa(o),a=(await u({config:o,document:Qa,variables:{name:e,organizationId:i}}).catch(l=>{throw l instanceof dr&&(process.stderr.write(`${He(l.message)}
263
+ `),process.exit(1)),l})).createProject;if(a?.__typename!=="Project"){let l=a?.message??"unknown error";process.stderr.write(`${He(l)}
264
264
  `),process.exit(1)}process.stdout.write(`${JSON.stringify({project:{id:a.id,name:a.name}},null,2)}
265
- `)}async function Xa(e){let n=((await u({config:e,document:Ja,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?St():Rt(n)}
266
- `),process.exit(1)}import{spawnSync as be}from"child_process";function $t(){if(be("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};be("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=be("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:be("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function It(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function At(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 jt(){process.stdout.write(`${It()}
268
- `);let e=$t();e.kind!=="launched"&&(process.stderr.write(`${At(e)}
269
- `),process.exit(1)),process.exit(e.exitCode)}import{graphql as Ya}from"gql.tada";function Tt({id:e,kind:r,title:n}){return`Caught bug reported (${r}): "${n}" [${e}]`}var Za=Ya(`
265
+ `)}async function Xa(e){let n=((await u({config:e,document:Ja,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?Rt():Et(n)}
266
+ `),process.exit(1)}import{spawnSync as we}from"child_process";function It(){if(we("claude",["--version"],{stdio:"ignore"}).error!=null)return{kind:"claude-missing"};we("claude",["plugin","marketplace","add","ripplo/claude-plugin"],{stdio:"ignore"});let r=we("claude",["plugin","install","ripplo@ripplo"],{encoding:"utf8",stdio:["ignore","pipe","pipe"]}),n=/already installed/i.test(`${r.stdout}${r.stderr}`);return r.status!==0&&!n?{detail:r.stderr.trim(),kind:"plugin-install-failed"}:{exitCode:we("claude",["/ripplo:setup"],{stdio:"inherit"}).status??0,kind:"launched"}}function At(){return"Installing the Ripplo plugin for Claude Code, then handing off to a guided setup session."}function jt(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 Tt(){process.stdout.write(`${At()}
268
+ `);let e=It();e.kind!=="launched"&&(process.stderr.write(`${jt(e)}
269
+ `),process.exit(1)),process.exit(e.exitCode)}import{graphql as Ya}from"gql.tada";function Mt({id:e,kind:r,title:n}){return`Caught bug reported (${r}): "${n}" [${e}]`}var Za=Ya(`
270
270
  mutation ReportCaughtBug(
271
271
  $projectId: String!
272
272
  $kind: CaughtBugKind!
@@ -294,9 +294,9 @@ ${e.detail}`:""}`}function jt(){process.stdout.write(`${It()}
294
294
  }
295
295
  }
296
296
  }
297
- `);async function Mt(e){let r=g(),t=(await u({config:r,document:Za,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(`${Tt({id:t.id,kind:e.kind,title:e.title})}
299
- `)}import il from"path";import{CancellationTokenSource as sl}from"vscode-jsonrpc/node";import{graphql as Nt}from"gql.tada";import{err as ve,ok as Q}from"neverthrow";var rl=Nt(`
297
+ `);async function Lt(e){let r=g(),t=(await u({config:r,document:Za,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(`${Mt({id:t.id,kind:e.kind,title:e.title})}
299
+ `)}import il from"path";import{CancellationTokenSource as sl}from"vscode-jsonrpc/node";import{graphql as Ot}from"gql.tada";import{err as be,ok as J}from"neverthrow";var rl=Ot(`
300
300
  query ExploreState($devSessionId: String!) {
301
301
  exploration(devSessionId: $devSessionId) {
302
302
  active
@@ -305,7 +305,7 @@ ${e.detail}`:""}`}function jt(){process.stdout.write(`${It()}
305
305
  maxTrailLength
306
306
  }
307
307
  }
308
- `),nl=Nt(`
308
+ `),nl=Ot(`
309
309
  mutation SetExploration(
310
310
  $devSessionId: String!
311
311
  $active: Boolean!
@@ -326,40 +326,40 @@ ${e.detail}`:""}`}function jt(){process.stdout.write(`${It()}
326
326
  maxTrailLength
327
327
  }
328
328
  }
329
- `);async function ze(e){let r=await _t(e);if(r.isErr())return ve(r.error);let n=await Ft(e,r.value.id);return Q(Wt(r.value.executor,n))}async function Je(e,r){let n=await _t(e);if(n.isErr())return ve(n.error);let t=await Ft(e,n.value.id),o=tl(n.value.executor,t,r),i=await u({config:e,document:nl,variables:{devSessionId:n.value.id,...o}});return Q(Wt(n.value.executor,i.setExploration))}async function Ot(e){if(!rn(e.cwd))return Q({kind:"hooks-paused"});let r=await ze(e);return r.isErr()?ve(r.error):r.value.active?Q({kind:"already-on"}):(await Je(e,{active:!0,trail:void 0,workers:void 0})).map(t=>({kind:"enabled",settings:t}))}async function _t(e){let r=await Qr(e);return r.kind==="active"?Q({executor:r.executor,id:r.id}):ve({kind:r.kind==="starting"?"starting":"no-session"})}async function Ft(e,r){return(await u({config:e,document:rl,variables:{devSessionId:r}})).exploration??null}function Wt(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??12,workers:(n?r?.localWorkers:r?.cloudWorkers)??0}}function tl(e,r,n){let t=e==="local",o=(t?r?.localWorkers:r?.cloudWorkers)??0,i=(t?r?.cloudWorkers:r?.localWorkers)??0,s=ol(n,o);return{active:n.active,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??12}}function ol(e,r){return e.active?e.workers!=null?e.workers:r>0?r:2:r}function Dt(e){return e.active?`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`:"explorer: off"}function Ut(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 qt(e){return e.kind!=="enabled"?null:"explorer on \u2014 filling coverage gaps in the background. Findings arrive as tasks (/ripplo:tasks). Pause with npx ripplo explore off"}function Bt(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."}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 xe(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&&L(pe({kind:"spawn-failed",message:"process.argv[1] missing"})),ul();let i=await ln(t);i!=null&&L(cn(i));let a=(await tn({cliEntry:o,cwd:t})).match(c=>c,c=>L(pe(c)));a.versionNote?.kind==="stale-busy"&&L(_e(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${_e(a.versionNote)}
330
- `);let l=new sl;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let d=il.join(t,".ripplo","debug"),h=(await on({connection:a,request:{all:e,headed:r,tests:[...n]},token:l.token,onEvent:c=>{let S=un({debugDir:d,event:c});S!=null&&process.stdout.write(`${S}
331
- `)}})).match(c=>c,c=>L(pe(c)));await al({connection:a,cwd:t,result:h})}async function al({connection:e,cwd:r,result:n}){await new Promise(t=>{e.socket.end(t)}),n.kind==="daemon-error"&&L(pn(n.error)),process.stdout.write(`${dn(n)}
332
- `),n.failed>0&&process.exit(1),n.notRun===0&&await ll(r),process.exit(n.notRun>0?2:0)}function L(e){process.stderr.write(`${e}
333
- `),process.exit(1)}async function ll(e){let r=y(e).match(t=>t,()=>null);if(r==null)return;(await Ot(r)).match(dl,()=>{})}function dl(e){let r=qt(e);r!=null&&process.stdout.write(`${r}
334
- `)}function ul(){let e=ce();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=xe(e);L(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Vt(e.packages)}
335
- `),nn(e.workspaceRoot)||L(Ht())}import N from"path";import gl from"os";import{mkdtempSync as yl,rmSync as hl}from"fs";import{err as Re,ok as Ye}from"neverthrow";import{z as Gt}from"zod";import{readdir as cl,rm as pl,stat as ml}from"fs/promises";import{existsSync as fl}from"fs";import Qe from"path";async function Xe(e,r){let t=(await cl(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||fl(Qe.join(e,s,Cn)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await ml(Qe.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>pl(Qe.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var zt=50,kl=15e3;async function Jt(){te(w());let e=process.cwd(),r=_.child({worker:process.pid}),n=xn(),t=yl(N.join(gl.tmpdir(),"ripplo-browser-cache-")),o=le({cacheDir:t,clientVersion:w(),debugDir:N.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)},kl).unref(),bl(i).then(()=>o.close().catch(()=>{})).then(()=>{hl(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(hn,async(l,d)=>{let f=fn.safeParse(l);if(!f.success)return Ce("bad-run-assign");let h=f.data;G(e);let c=y(e).match(E=>E,E=>E.kind);if(typeof c=="string")return Ce(`config:${c}`);let S=await Qt(n);if(S.isErr())return Ce(`lockfile-unavailable:${S.error}`);let ne=S.value,O=ae(ne).find(E=>E.ref===h.testRef);if(O==null)return Ce(`no-test:${h.testRef}`);try{let{outcome:E,persisted:Te}=await Sn({config:c,cwd:e,errorSettle:"settle",fixturesDir:N.join(e,z),headed:h.headed,lockfile:ne,onPhase:void 0,runId:h.runId,session:o,signal:Fe(d),test:O.test}),lr=N.join(e,".ripplo","debug");return s(Promise.allSettled([Te]).then(()=>me({config:c,debugDir:lr,runId:h.runId})).then(()=>Xe(lr,zt)).catch(()=>{})),{outcome:mn(E),serverNotified:!0}}catch(E){let Te=N.join(e,".ripplo","debug");if(s(me({config:c,debugDir:Te,runId:h.runId}).catch(()=>{})),E instanceof dr)return{outcome:{detail:E.message,kind:"infra-error"},serverNotified:!1};throw E}}),n.onRequest(wn,(l,d)=>xl({connection:n,cwd:e,raw:l,session:o,token:d,track:s})),n.onNotification(bn,l=>{let d=gn.safeParse(l);d.success&&o.injectSpan(d.data.runId,d.data.span)}),n.onNotification(vn,()=>{a(0)}),n.sendNotification(yn),await new Promise(()=>{})}function Ce(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var wl=5e3;async function bl(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,wl)})])}var vl=Gt.object({assign:Ur,devSessionId:Gt.string().nullable()});async function xl({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=vl.safeParse(n);if(!s.success)return{kind:"error",reason:"bad-assign"};let{assign:a,devSessionId:l}=s.data;G(r);let d=y(r).match(O=>O,O=>O.kind);if(typeof d=="string")return{kind:"error",reason:`config:${d}`};let f=await Qt(e);if(f.isErr())return{kind:"error",reason:`lockfile:${f.error}`};let h=f.value,c=N.join(d.cwd,".ripplo","debug"),S=await Rn({assign:a,config:d,debugDir:c,devSessionId:l??void 0,fixturesDir:N.join(d.cwd,z),headed:!1,lockfile:h,report:!0,session:t,signal:Fe(o)}),ne=S.kind==="finding"&&S.runId!=null?me({config:d,debugDir:c,runId:S.runId}):Promise.resolve();return i(ne.then(()=>Xe(c,zt)).catch(()=>{})),S}async function Qt(e){return(await Cl(e)).andThen(n=>n.unavailable!=null?Re(n.unavailable):n.lockfileJson==null?Re("empty-reply"):Sl(n.lockfileJson))}async function Cl(e){try{return Ye(await e.sendRequest(kn))}catch(r){return Re(`transport:${r instanceof Error?r.message:"unknown"}`)}}var Se;function Sl(e){if(Se!==void 0&&Se.json===e)return Ye(Se.lockfile);try{let r=Cr(ie(j,e));return Se={json:e,lockfile:r},Ye(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 Ll}from"fs";import Nl from"path";import{ok as Ol}from"neverthrow";import{gunzipSync as Rl}from"zlib";import{mkdir as El,writeFile as Pl}from"fs/promises";import Yt from"path";import{graphql as $l}from"gql.tada";import{err as X,ok as Il}from"neverthrow";var Al=31,jl=139;async function Ee(e,r){let n=y(e).match(s=>s,s=>s.kind);if(typeof n=="string")return X({detail:n,kind:"config"});let t=await u({config:n,document:Tl,variables:{id:r}}).catch(()=>null);if(t==null)return X({kind:"request-failed"});if(t.run==null)return X({kind:"not-found"});if(t.run.behaviorUrl==null)return X({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return X({kind:"download-failed",status:o.status});let i=Yt.join(e,".ripplo","debug",r,"behavior.jsonl");return await El(Yt.dirname(i),{recursive:!0}),await Pl(i,Ml(Buffer.from(await o.arrayBuffer()))),Il({path:i,runId:r})}var Tl=$l(`
329
+ `);async function Ge(e){let r=await Ft(e);if(r.isErr())return be(r.error);let n=await Wt(e,r.value.id);return J(Dt(r.value.executor,n))}async function ze(e,r){let n=await Ft(e);if(n.isErr())return be(n.error);let t=await Wt(e,n.value.id),o=tl(n.value.executor,t,r),i=await u({config:e,document:nl,variables:{devSessionId:n.value.id,...o}});return J(Dt(n.value.executor,i.setExploration))}async function _t(e){if(!nn(e.cwd))return J({kind:"hooks-paused"});let r=await Ge(e);return r.isErr()?be(r.error):r.value.active?J({kind:"already-on"}):(await ze(e,{active:!0,trail:void 0,workers:void 0})).map(t=>({kind:"enabled",settings:t}))}async function Ft(e){let r=await Xr(e);return r.kind==="active"?J({executor:r.executor,id:r.id}):be({kind:r.kind==="starting"?"starting":"no-session"})}async function Wt(e,r){return(await u({config:e,document:rl,variables:{devSessionId:r}})).exploration??null}function Dt(e,r){let n=e==="local";return{active:r?.active??!1,executor:e,maxTrailLength:r?.maxTrailLength??12,workers:(n?r?.localWorkers:r?.cloudWorkers)??0}}function tl(e,r,n){let t=e==="local",o=(t?r?.localWorkers:r?.cloudWorkers)??0,i=(t?r?.cloudWorkers:r?.localWorkers)??0,s=ol(n,o);return{active:n.active,cloudWorkers:t?i:s,localWorkers:t?s:i,maxTrailLength:n.trail??r?.maxTrailLength??12}}function ol(e,r){return e.active?e.workers!=null?e.workers:r>0?r:2:r}function Ut(e){return e.active?`explorer: on | ${String(e.workers)} workers | trail ${String(e.maxTrailLength)} | ${e.executor}`:"explorer: off"}function qt(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 Bt(e){return e.kind!=="enabled"?null:"explorer on \u2014 filling coverage gaps in the background. Findings arrive as tasks (/ripplo:tasks). Pause with npx ripplo explore off"}function Vt(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."}function Ht(e){return`ripplo: workspace build is stale (${e.join(", ")}) \u2014 rebuilding`}function Kt(){return"ripplo: workspace build failed \u2014 fix the build, then rerun"}function ve(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 Gt({all:e,headed:r,ids:n}){let t=process.cwd(),o=process.argv[1];o==null&&M(ce({kind:"spawn-failed",message:"process.argv[1] missing"})),ul();let i=await dn(t);i!=null&&M(pn(i));let a=(await on({cliEntry:o,cwd:t})).match(c=>c,c=>M(ce(c)));a.versionNote?.kind==="stale-busy"&&M(Oe(a.versionNote)),a.versionNote!=null&&process.stderr.write(`${Oe(a.versionNote)}
330
+ `);let l=new sl;process.once("SIGINT",()=>{l.cancel(),a.socket.destroy(),process.exit(130)});let d=il.join(t,".ripplo","debug"),h=(await sn({connection:a,request:{all:e,headed:r,tests:[...n]},token:l.token,onEvent:c=>{let S=cn({debugDir:d,event:c});S!=null&&process.stdout.write(`${S}
331
+ `)}})).match(c=>c,c=>M(ce(c)));await al({connection:a,cwd:t,result:h})}async function al({connection:e,cwd:r,result:n}){await new Promise(t=>{e.socket.end(t)}),n.kind==="daemon-error"&&M(mn(n.error)),process.stdout.write(`${un(n)}
332
+ `),n.failed>0&&process.exit(1),n.notRun===0&&await ll(r),process.exit(n.notRun>0?2:0)}function M(e){process.stderr.write(`${e}
333
+ `),process.exit(1)}async function ll(e){let r=y(e).match(t=>t,()=>null);if(r==null)return;(await _t(r)).match(dl,()=>{})}function dl(e){let r=Bt(e);r!=null&&process.stdout.write(`${r}
334
+ `)}function ul(){let e=ue();if(e.kind==="fresh")return;if(e.kind==="foreign-binary"){let n=ve(e);M(n??"foreign binary in the ripplo workspace")}process.stderr.write(`${Ht(e.packages)}
335
+ `),tn(e.workspaceRoot)||M(Kt())}import L from"path";import gl from"os";import{mkdtempSync as yl,rmSync as hl}from"fs";import{err as Se,ok as Xe}from"neverthrow";import{z as zt}from"zod";import{readdir as cl,rm as pl,stat as ml}from"fs/promises";import{existsSync as fl}from"fs";import Je from"path";async function Qe(e,r){let t=(await cl(e,{withFileTypes:!0}).catch(()=>[])).filter(s=>s.isDirectory()).map(s=>s.name).filter(s=>s.startsWith("replay-")||s.startsWith("explore-")||fl(Je.join(e,s,Sn)));if(t.length<=r)return;let i=(await Promise.all(t.map(async s=>({mtime:(await ml(Je.join(e,s)).catch(()=>null))?.mtimeMs??0,name:s})))).toSorted((s,a)=>a.mtime-s.mtime).slice(r);await Promise.all(i.map(s=>pl(Je.join(e,s.name),{force:!0,recursive:!0}).catch(()=>{})))}var Jt=50,kl=15e3;async function Qt(){ne(w());let e=process.cwd(),r=O.child({worker:process.pid}),n=Cn(),t=yl(L.join(gl.tmpdir(),"ripplo-browser-cache-")),o=se({cacheDir:t,clientVersion:w(),debugDir:L.join(e,".ripplo","debug"),headed:!1,writeOtlpPortFile:!1}),i=new Set,s=l=>{i.add(l),l.finally(()=>i.delete(l))},a=l=>{setTimeout(()=>{process.exit(l)},kl).unref(),bl(i).then(()=>o.close().catch(()=>{})).then(()=>{hl(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(kn,async(l,d)=>{let f=gn.safeParse(l);if(!f.success)return xe("bad-run-assign");let h=f.data;K(e);let c=y(e).match(E=>E,E=>E.kind);if(typeof c=="string")return xe(`config:${c}`);let S=await Xt(n);if(S.isErr())return xe(`lockfile-unavailable:${S.error}`);let re=S.value,N=ie(re).find(E=>E.ref===h.testRef);if(N==null)return xe(`no-test:${h.testRef}`);try{let{outcome:E,persisted:je}=await Rn({config:c,cwd:e,errorSettle:"settle",fixturesDir:L.join(e,G),headed:h.headed,lockfile:re,onPhase:void 0,runId:h.runId,session:o,signal:_e(d),test:N.test}),ar=L.join(e,".ripplo","debug");return s(Promise.allSettled([je]).then(()=>pe({config:c,debugDir:ar,runId:h.runId})).then(()=>Qe(ar,Jt)).catch(()=>{})),{outcome:fn(E),serverNotified:!0}}catch(E){let je=L.join(e,".ripplo","debug");if(s(pe({config:c,debugDir:je,runId:h.runId}).catch(()=>{})),E instanceof lr)return{outcome:{detail:E.message,kind:"infra-error"},serverNotified:!1};throw E}}),n.onRequest(bn,(l,d)=>xl({connection:n,cwd:e,raw:l,session:o,token:d,track:s})),n.onNotification(vn,l=>{let d=yn.safeParse(l);d.success&&o.injectSpan(d.data.runId,d.data.span)}),n.onNotification(xn,()=>{a(0)}),n.sendNotification(hn),await new Promise(()=>{})}function xe(e){return{outcome:{detail:e,kind:"error"},serverNotified:!1}}var wl=5e3;async function bl(e){e.size!==0&&await Promise.race([Promise.allSettled(e),new Promise(r=>{setTimeout(r,wl)})])}var vl=zt.object({assign:Ur,devSessionId:zt.string().nullable()});async function xl({connection:e,cwd:r,raw:n,session:t,token:o,track:i}){let s=vl.safeParse(n);if(!s.success)return{kind:"error",reason:"bad-assign"};let{assign:a,devSessionId:l}=s.data;K(r);let d=y(r).match(N=>N,N=>N.kind);if(typeof d=="string")return{kind:"error",reason:`config:${d}`};let f=await Xt(e);if(f.isErr())return{kind:"error",reason:`lockfile:${f.error}`};let h=f.value,c=L.join(d.cwd,".ripplo","debug"),S=await En({assign:a,config:d,debugDir:c,devSessionId:l??void 0,fixturesDir:L.join(d.cwd,G),headed:!1,lockfile:h,report:!0,session:t,signal:_e(o)}),re=S.kind==="finding"&&S.runId!=null?pe({config:d,debugDir:c,runId:S.runId}):Promise.resolve();return i(re.then(()=>Qe(c,Jt)).catch(()=>{})),S}async function Xt(e){return(await Cl(e)).andThen(n=>n.unavailable!=null?Se(n.unavailable):n.lockfileJson==null?Se("empty-reply"):Sl(n.lockfileJson))}async function Cl(e){try{return Xe(await e.sendRequest(wn))}catch(r){return Se(`transport:${r instanceof Error?r.message:"unknown"}`)}}var Ce;function Sl(e){if(Ce!==void 0&&Ce.json===e)return Xe(Ce.lockfile);try{let r=Cr(te(W,e));return Ce={json:e,lockfile:r},Xe(r)}catch(r){return Se(`worker-decode-failed:${r instanceof Error?r.message.slice(0,200):"unknown"}`)}}async function Yt(){await Qt()}import{existsSync as Ll}from"fs";import Nl from"path";import{ok as Ol}from"neverthrow";import{gunzipSync as Rl}from"zlib";import{mkdir as El,writeFile as Pl}from"fs/promises";import Zt from"path";import{graphql as $l}from"gql.tada";import{err as Q,ok as Il}from"neverthrow";var Al=31,jl=139;async function Re(e,r){let n=y(e).match(s=>s,s=>s.kind);if(typeof n=="string")return Q({detail:n,kind:"config"});let t=await u({config:n,document:Tl,variables:{id:r}}).catch(()=>null);if(t==null)return Q({kind:"request-failed"});if(t.run==null)return Q({kind:"not-found"});if(t.run.behaviorUrl==null)return Q({kind:"not-uploaded"});let o=await fetch(t.run.behaviorUrl);if(!o.ok)return Q({kind:"download-failed",status:o.status});let i=Zt.join(e,".ripplo","debug",r,"behavior.jsonl");return await El(Zt.dirname(i),{recursive:!0}),await Pl(i,Ml(Buffer.from(await o.arrayBuffer()))),Il({path:i,runId:r})}var Tl=$l(`
336
336
  query RunBehaviorUrl($id: String!) {
337
337
  run(id: $id) {
338
338
  id
339
339
  behaviorUrl
340
340
  }
341
341
  }
342
- `);function Ml(e){return e[0]===Al&&e[1]===jl?Rl(e):e}async function H(e,r){let n=Nl.join(e,".ripplo","debug",r,"behavior.jsonl");return Ll(n)?Ol(void 0):(await Ee(e,r)).map(()=>{})}import{existsSync as eo,readFileSync as ro}from"fs";import no from"path";import{err as _l,ok as Fl}from"neverthrow";var to=" \u203A ",Wl=4e3,Dl=5,oo="fact ",io="step ",Ul="data rule ";async function so(e,r){let n=no.join(e,".ripplo","debug",r,"behavior.jsonl");if(!eo(n))return _l({kind:"run-not-found",runId:r});let t=ql(ro(n,"utf8")),o=id(e),i=o==null?[]:await Nr(o),s=[...t.assertions.filter(a=>a.outcome!=="passed").map(a=>Jl({assertion:a,facts:i,lockfile:o,run:t})),...t.findings.map(a=>Hl({event:a,facts:i,lockfile:o,run:t}))];return Fl({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,runId:r})}function ql(e){let r=e.split(`
343
- `).filter(s=>s.trim().length>0).flatMap(s=>{let a=F(s);return a==null?[]:[a]}),n=r.filter(s=>s.kind==="assertion"),t=r.filter(s=>s.kind==="finding"),o=r.flatMap(s=>Bl(s)),i=r.map(s=>W(s.timeNanos));return{assertions:n,causes:o,findings:t,firstTs:i.length===0?0:Math.min(...i),lastTs:i.length===0?0:Math.max(...i)}}function Bl(e){let r=Vl(e);return r==null?[]:[{detail:r,timestamp:W(e.timeNanos)}]}function Vl(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 Hl({event:e,facts:r,lockfile:n,run:t}){let o=W(e.timeNanos),i=e.payload,s=i.kind==="mismatch"?"fact":"unknown",a=i.kind==="mismatch"||i.kind==="pendingCheck";return{browserMismatch:void 0,causes:co(t.causes,o),label:Gl(i),outcome:"failed",pending:i.kind==="mismatch"?i.pending:void 0,ruleKind:s,rules:uo({check:ao(i),facts:r,lockfile:n,ruleKind:s,subjectKey:Kl(i)}),runWorkflow:e.step.split(to)[0]??e.step,snapshotAt:o,step:e.step,wait:a?i.wait:void 0,waitMs:a?i.waitMs:void 0}}function Kl(e){return e.kind==="mismatch"&&e.mismatch.kind==="scalarMismatch"?e.mismatch.subjectKey:void 0}function ao(e){return e.kind==="mismatch"?lo(e.mismatch):e.kind==="unrunnable"?e.reason:e.kind==="impossibleAction"?e.action:e.kind==="driverError"?e.errorKind:e.subject}function lo(e){return e.kind==="scalarMismatch"?e.subject:e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.entity} [${e.key}]`:`${e.entity}.${e.field} [${e.key}]`}function Gl(e){return e.kind==="mismatch"?zl(e.mismatch):e.kind==="pendingCheck"&&e.expected!=null?`${e.kind} ${e.subject}: expected ${e.expected}`:e.kind==="unrunnable"&&e.unmet!=null?`${e.kind} ${e.reason}: ${e.unmet}`:`${e.kind} ${ao(e)}`}function zl(e){let r=lo(e);return e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.kind} ${r}`:`${e.kind} ${r}: expected ${e.expected}, got ${e.actual}`}function Jl({assertion:e,facts:r,lockfile:n,run:t}){let o=Ql(e.label),i=W(e.timeNanos);return{browserMismatch:void 0,causes:co(t.causes,i),label:e.label,outcome:e.outcome==="error"?"error":"failed",pending:void 0,ruleKind:o,rules:uo({check:Xl(e.label,o),facts:r,lockfile:n,ruleKind:o,subjectKey:void 0}),runWorkflow:e.step.split(to)[0]??e.step,snapshotAt:i,step:e.step,wait:e.wait,waitMs:e.waitMs}}function Ql(e){return e.startsWith(oo)?"fact":e.startsWith(Ul)?"data-rule":e.startsWith(io)?"step":"unknown"}function Xl(e,r){return r==="fact"?e.slice(oo.length):r==="step"?e.slice(io.length):e}function uo({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>Yl({check:e,rule:i,subjectKey:o})).map(i=>({consequence:Le(i.consequence),origins:Zl(i.origin,n),provenance:nd(i.origin),url:Fr(i.when),when:Wr(i.when)}))}function Yl({check:e,rule:r,subjectKey:n}){return n!=null?Or(r)===n:Le(r.consequence)===e}function Zl(e,r){let n=ae(r),t=ed(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return rd(t)}function ed(e){return e==null?[]:e.kind==="declared"?[]:e.kind==="generalized"?_r(e):[e.test]}function rd(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function nd(e){return e!=null&&e.kind==="generalized"?"learned":"inferred"}function co(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Wl).toSorted((t,o)=>o.timestamp-t.timestamp);return td(n).toSorted((t,o)=>Number(Zt(o.detail))-Number(Zt(t.detail))).slice(0,Dl).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function td(e){return e.reduce((r,n)=>{let t=od(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function od(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 id(e){let r=no.join(e,".ripplo","ripplo.lock");if(!eo(r))return null;try{return ie(j,ro(r,"utf8"))}catch{return null}}var po=" \u203A ",sd=["fact ","data rule ","step "];function go(e){if(e.failures.length===0)return`${p.good("ok")} \u2014 ${e.runId}: no failing checks.`;let r=`${e.runId} \u2014 ${R(e.failures.length,"failing check")}`,n=e.lockfileLoaded?[]:[p.dim("(no lockfile \u2014 provenance unavailable)")],t=ad(e.failures).map(o=>ld(o,e.runId));return[r,...n,"",...t,x("tasks")].join(`
344
- `)}function yo(e){return`${p.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function ad(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function ld(e,r){let n=e.failures[0];if(n==null)return"";let t=dd(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>ko(s.label)))].join(", "),i=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${cd(e.step)} ${i}`,` ${p.dim("failed")} ${o}`,...pd(e),...hd(n),...kd(n.causes),` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
345
- `)}function dd(e,r){let n=e.failures[0],t=e.failures.flatMap(d=>d.browserMismatch==null?[]:[d.browserMismatch])[0],o=ho(e.failures.flatMap(d=>d.rules));if(n==null||t==null||o.length===0)return null;let i=ko(e.failures.find(d=>d.rules.length>0)?.label??n.label),s=[...new Set(o.map(d=>d.url))].join(", "),a=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${i} ${p.warn("(wrong page)")} ${a}`,` ${p.dim("rule learned for url")} ${s}`,` ${p.dim("browser was actually at")} ${t.actual}`,` ${p.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
346
- `)}function ho(e){let r=e.map(n=>[ud(n),n]);return[...new Map(r).values()]}function ud(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function ko(e){let r=sd.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function cd(e){let r=e.split(po);return r.length<2?e:r.slice(1).join(po)}function pd(e){let r=ho(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>md(n)),...yd(e,r)]}function md(e){let r=e.origins.length===0?p.dim("origin not in lockfile"):e.origins.map(n=>fd(n)).join(", ");return[` ${p.dim(gd(e.provenance))}`,` ${p.dim("from")} ${r}`,` ${p.dim("at")} ${e.url} ${p.dim("\u2014 holds only when")} ${e.when}`]}function fd(e){if(e.sourcePath==null)return e.intent;let r=p.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function gd(e){return e==="learned"?"learned \u2014 kept only the conditions these flows share":"inferred \u2014 from a flow that reaches this state"}function yd(e,r){let n=new Set(r.flatMap(o=>o.origins.map(i=>i.intent)));return e.failures.some(o=>n.has(o.runWorkflow))||n.size===0?[]:[` ${p.warn("\u21B3 learned from another flow \u2014 likely a fact scoped too broadly")}`]}function hd(e){if(e.waitMs==null||e.wait==null)return[];let r=`${String(Math.round(e.waitMs/1e3))}s`,n=e.pending===!0?" \u2014 value never changed (write may be slow or dropped)":"";return[` ${p.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function kd(e){if(e.length===0)return[];let r=wd(e),n=e.flatMap(t=>bd(t,r));return n.length===0?[]:[` ${p.dim("nearby")} ${n.join(" \xB7 ")}`]}function wd(e){let r=e.flatMap(n=>n.detail.kind==="span"&&n.detail.traceId!=null?[[n.detail.traceId,n.detail]]:[]);return new Map(r)}function bd(e,r){let n=e.detail;if(n.kind==="span"&&n.traceId!=null&&r.has(n.traceId))return[];if(n.kind==="network"&&n.traceId!=null){let t=r.get(n.traceId),o=t==null?"":` \u21B9 ${Ze(t)}`;return[fo(n,`${Ze(n)}${o}`)]}return[fo(n,Ze(n))]}function Ze(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${vd(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 vd(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 xd(e)?p.bad(r):r}function xd(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function wo(e){return`Saved behavior.jsonl to ${e.path}`}function K(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 bo({json:e,runId:r}){let n=await H(process.cwd(),r);n.isErr()&&(process.stderr.write(`${K(n.error)}
347
- `),process.exit(1)),(await so(process.cwd(),r)).match(o=>{let i=e?JSON.stringify(o,null,2):go(o);process.stdout.write(`${i}
348
- `)},o=>{process.stderr.write(`${yo(o)}
349
- `),process.exit(1)})}async function vo({runId:e}){(await Ee(process.cwd(),e)).match(n=>{process.stdout.write(`${wo(n)}
350
- `)},n=>{process.stderr.write(`${K(n)}
351
- `),process.exit(1)})}import{randomUUID as Cd}from"crypto";import xo from"path";import{graphql as Sd}from"gql.tada";import{err as Y,ok as Rd}from"neverthrow";async function Co(e,r,n){let t=y(e).match(f=>f,f=>f.kind);if(typeof t=="string")return Y({detail:t,kind:"config"});let o=await Pr(e);if(o.result.isErr())return Y({kind:"compile-failed"});let i=await u({config:t,document:Ed,variables:{id:r}}).catch(()=>null);if(i==null)return Y({kind:"request-failed"});if(i.run==null)return Y({kind:"not-found"});if(i.run.reproJson==null)return Y({kind:"no-repro"});let s=qr.parse(JSON.parse(i.run.reproJson)),a=await U(e,o.result.value),l=`replay-${Cd()}`,d=le({cacheDir:void 0,clientVersion:w(),debugDir:xo.join(e,".ripplo","debug"),headed:!1,writeOtlpPortFile:!1});try{let f=await Hr({capture:!0,lockfile:a,options:{baseUrl:t.appUrl,engineUrl:t.engineUrl,fixturesDir:xo.join(e,z),generate:xr,headed:!1,secret:t.webhookSecret},repro:s,runId:l,session:d,signal:n});return Rd({outcome:f,replayRunId:l})}finally{await d.close()}}var Ed=Sd(`
342
+ `);function Ml(e){return e[0]===Al&&e[1]===jl?Rl(e):e}async function V(e,r){let n=Nl.join(e,".ripplo","debug",r,"behavior.jsonl");return Ll(n)?Ol(void 0):(await Re(e,r)).map(()=>{})}import{existsSync as ro,readFileSync as no}from"fs";import to from"path";import{err as _l,ok as Fl}from"neverthrow";var oo=" \u203A ",Wl=4e3,Dl=5,io="fact ",so="step ",Ul="data rule ";async function ao(e,r){let n=to.join(e,".ripplo","debug",r,"behavior.jsonl");if(!ro(n))return _l({kind:"run-not-found",runId:r});let t=ql(no(n,"utf8")),o=id(e),i=o==null?[]:await Nr(o),s=[...t.assertions.filter(a=>a.outcome!=="passed").map(a=>Jl({assertion:a,facts:i,lockfile:o,run:t})),...t.findings.map(a=>Hl({event:a,facts:i,lockfile:o,run:t}))];return Fl({durationMs:Math.max(0,t.lastTs-t.firstTs),failures:s,lockfileLoaded:o!=null,runId:r})}function ql(e){let r=e.split(`
343
+ `).filter(s=>s.trim().length>0).flatMap(s=>{let a=_(s);return a==null?[]:[a]}),n=r.filter(s=>s.kind==="assertion"),t=r.filter(s=>s.kind==="finding"),o=r.flatMap(s=>Bl(s)),i=r.map(s=>F(s.timeNanos));return{assertions:n,causes:o,findings:t,firstTs:i.length===0?0:Math.min(...i),lastTs:i.length===0?0:Math.max(...i)}}function Bl(e){let r=Vl(e);return r==null?[]:[{detail:r,timestamp:F(e.timeNanos)}]}function Vl(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 Hl({event:e,facts:r,lockfile:n,run:t}){let o=F(e.timeNanos),i=e.payload,s=i.kind==="mismatch"?"fact":"unknown",a=i.kind==="mismatch"||i.kind==="pendingCheck";return{browserMismatch:void 0,causes:po(t.causes,o),label:Gl(i),outcome:"failed",pending:i.kind==="mismatch"?i.pending:void 0,ruleKind:s,rules:co({check:lo(i),facts:r,lockfile:n,ruleKind:s,subjectKey:Kl(i)}),runWorkflow:e.step.split(oo)[0]??e.step,snapshotAt:o,step:e.step,wait:a?i.wait:void 0,waitMs:a?i.waitMs:void 0}}function Kl(e){return e.kind==="mismatch"&&e.mismatch.kind==="scalarMismatch"?e.mismatch.subjectKey:void 0}function lo(e){return e.kind==="mismatch"?uo(e.mismatch):e.kind==="unrunnable"?e.reason:e.kind==="impossibleAction"?e.action:e.kind==="driverError"?e.errorKind:e.subject}function uo(e){return e.kind==="scalarMismatch"?e.subject:e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.entity} [${e.key}]`:`${e.entity}.${e.field} [${e.key}]`}function Gl(e){return e.kind==="mismatch"?zl(e.mismatch):e.kind==="pendingCheck"&&e.expected!=null?`${e.kind} ${e.subject}: expected ${e.expected}`:e.kind==="unrunnable"&&e.unmet!=null?`${e.kind} ${e.reason}: ${e.unmet}`:`${e.kind} ${lo(e)}`}function zl(e){let r=uo(e);return e.kind==="missingRow"||e.kind==="unexpectedRow"?`${e.kind} ${r}`:`${e.kind} ${r}: expected ${e.expected}, got ${e.actual}`}function Jl({assertion:e,facts:r,lockfile:n,run:t}){let o=Ql(e.label),i=F(e.timeNanos);return{browserMismatch:void 0,causes:po(t.causes,i),label:e.label,outcome:e.outcome==="error"?"error":"failed",pending:void 0,ruleKind:o,rules:co({check:Xl(e.label,o),facts:r,lockfile:n,ruleKind:o,subjectKey:void 0}),runWorkflow:e.step.split(oo)[0]??e.step,snapshotAt:i,step:e.step,wait:e.wait,waitMs:e.waitMs}}function Ql(e){return e.startsWith(io)?"fact":e.startsWith(Ul)?"data-rule":e.startsWith(so)?"step":"unknown"}function Xl(e,r){return r==="fact"?e.slice(io.length):r==="step"?e.slice(so.length):e}function co({check:e,facts:r,lockfile:n,ruleKind:t,subjectKey:o}){return t!=="fact"||n==null?[]:r.filter(i=>Yl({check:e,rule:i,subjectKey:o})).map(i=>({consequence:Me(i.consequence),origins:Zl(i.origin,n),provenance:nd(i.origin),url:Fr(i.when),when:Wr(i.when)}))}function Yl({check:e,rule:r,subjectKey:n}){return n!=null?Or(r)===n:Me(r.consequence)===e}function Zl(e,r){let n=ie(r),t=ed(e).flatMap(o=>{let i=n.find(s=>s.ref===o);return i==null?[]:[{intent:i.workflow.intent,sourcePath:i.workflow.sourcePath}]});return rd(t)}function ed(e){return e==null?[]:e.kind==="declared"?[]:e.kind==="generalized"?_r(e):[e.test]}function rd(e){return[...new Map(e.map(r=>[r.intent,r])).values()]}function nd(e){return e!=null&&e.kind==="generalized"?"learned":"inferred"}function po(e,r){let n=e.filter(t=>t.timestamp<=r&&t.timestamp>=r-Wl).toSorted((t,o)=>o.timestamp-t.timestamp);return td(n).toSorted((t,o)=>Number(eo(o.detail))-Number(eo(t.detail))).slice(0,Dl).map(t=>({deltaMs:r-t.timestamp,detail:t.detail}))}function td(e){return e.reduce((r,n)=>{let t=od(n.detail);return r.keys.has(t)?r:{keys:new Set([...r.keys,t]),out:[...r.out,n]}},{keys:new Set,out:[]}).out}function od(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 eo(e){return e.kind==="network"?e.status>=400:e.kind==="span"?e.statusCode==="error":!0}function id(e){let r=to.join(e,".ripplo","ripplo.lock");if(!ro(r))return null;try{return te(W,no(r,"utf8"))}catch{return null}}var mo=" \u203A ",sd=["fact ","data rule ","step "];function yo(e){if(e.failures.length===0)return`${p.good("ok")} \u2014 ${e.runId}: no failing checks.`;let r=`${e.runId} \u2014 ${R(e.failures.length,"failing check")}`,n=e.lockfileLoaded?[]:[p.dim("(no lockfile \u2014 provenance unavailable)")],t=ad(e.failures).map(o=>ld(o,e.runId));return[r,...n,"",...t,x("tasks")].join(`
344
+ `)}function ho(e){return`${p.bad("fail")} \u2014 no artifacts for ${e.runId}. Run \`npx ripplo pull ${e.runId}\` first.`}function ad(e){return[...new Set(e.map(n=>n.step))].map(n=>({failures:e.filter(t=>t.step===n),step:n}))}function ld(e,r){let n=e.failures[0];if(n==null)return"";let t=dd(e,r);if(t!=null)return t;let o=[...new Set(e.failures.map(s=>wo(s.label)))].join(", "),i=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${cd(e.step)} ${i}`,` ${p.dim("failed")} ${o}`,...pd(e),...hd(n),...kd(n.causes),` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
345
+ `)}function dd(e,r){let n=e.failures[0],t=e.failures.flatMap(d=>d.browserMismatch==null?[]:[d.browserMismatch])[0],o=ko(e.failures.flatMap(d=>d.rules));if(n==null||t==null||o.length===0)return null;let i=wo(e.failures.find(d=>d.rules.length>0)?.label??n.label),s=[...new Set(o.map(d=>d.url))].join(", "),a=p.dim(`(${n.runWorkflow})`);return[`${p.bad("\u2717")} ${i} ${p.warn("(wrong page)")} ${a}`,` ${p.dim("rule learned for url")} ${s}`,` ${p.dim("browser was actually at")} ${t.actual}`,` ${p.warn("\u21B3 declare the navigation: add url.path`...` to the step that caused it")}`,` ${p.dim("frame")} npx ripplo snapshot ${r} --at ${String(n.snapshotAt)}`,""].join(`
346
+ `)}function ko(e){let r=e.map(n=>[ud(n),n]);return[...new Map(r).values()]}function ud(e){return`${e.url}|${e.when}|${e.origins.map(r=>r.intent).join(",")}`}function wo(e){let r=sd.find(n=>e.startsWith(n));return r==null?e:e.slice(r.length)}function cd(e){let r=e.split(mo);return r.length<2?e:r.slice(1).join(mo)}function pd(e){let r=ko(e.failures.flatMap(n=>n.rules));return r.length===0?[]:[...r.flatMap(n=>md(n)),...yd(e,r)]}function md(e){let r=e.origins.length===0?p.dim("origin not in lockfile"):e.origins.map(n=>fd(n)).join(", ");return[` ${p.dim(gd(e.provenance))}`,` ${p.dim("from")} ${r}`,` ${p.dim("at")} ${e.url} ${p.dim("\u2014 holds only when")} ${e.when}`]}function fd(e){if(e.sourcePath==null)return e.intent;let r=p.dim(`(${e.sourcePath})`);return`${e.intent} ${r}`}function gd(e){return e==="learned"?"learned \u2014 kept only the conditions these flows share":"inferred \u2014 from a flow that reaches this state"}function yd(e,r){let n=new Set(r.flatMap(o=>o.origins.map(i=>i.intent)));return e.failures.some(o=>n.has(o.runWorkflow))||n.size===0?[]:[` ${p.warn("\u21B3 learned from another flow \u2014 likely a fact scoped too broadly")}`]}function hd(e){if(e.waitMs==null||e.wait==null)return[];let r=`${String(Math.round(e.waitMs/1e3))}s`,n=e.pending===!0?" \u2014 value never changed (write may be slow or dropped)":"";return[` ${p.dim("waited")} up to ${r} (wait: ${e.wait})${n}`]}function kd(e){if(e.length===0)return[];let r=wd(e),n=e.flatMap(t=>bd(t,r));return n.length===0?[]:[` ${p.dim("nearby")} ${n.join(" \xB7 ")}`]}function wd(e){let r=e.flatMap(n=>n.detail.kind==="span"&&n.detail.traceId!=null?[[n.detail.traceId,n.detail]]:[]);return new Map(r)}function bd(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 ${Ye(t)}`;return[go(n,`${Ye(n)}${o}`)]}return[go(n,Ye(n))]}function Ye(e){return e.kind==="network"?`${e.method} ${String(e.status)} ${vd(e.url)}`:e.kind==="console"?`console.${e.level} ${fo(e.text)}`:e.kind==="error"?`error ${fo(e.message)}`:`span ${e.name} ${e.statusCode} ${String(Math.round(e.durationMs))}ms`}function vd(e){let r=e.split("?")[0]??e;return r.length>60?`\u2026${r.slice(-57)}`:r}function fo(e){let r=e.replaceAll(/\s+/g," ").trim();return r.length>100?`${r.slice(0,97)}\u2026`:r}function go(e,r){return xd(e)?p.bad(r):r}function xd(e){return e.kind==="network"?e.status>=400:e.kind==="console"?e.level==="error":e.kind==="error"||e.statusCode==="error"}function bo(e){return`Saved behavior.jsonl to ${e.path}`}function H(e){switch(e.kind){case"config":return`Can't read project config (${e.detail}). Run this from your project root.`;case"request-failed":return"Couldn't reach the server. Check you're signed in with `npx ripplo auth`.";case"not-found":return"No run with that id.";case"not-uploaded":return"This run has no uploaded artifacts yet \u2014 it may still be running, or predates artifact upload.";case"download-failed":return`Download failed (HTTP ${String(e.status)}). The link may have expired \u2014 try again.`}}async function vo({json:e,runId:r}){let n=await V(process.cwd(),r);n.isErr()&&(process.stderr.write(`${H(n.error)}
347
+ `),process.exit(1)),(await ao(process.cwd(),r)).match(o=>{let i=e?JSON.stringify(o,null,2):yo(o);process.stdout.write(`${i}
348
+ `)},o=>{process.stderr.write(`${ho(o)}
349
+ `),process.exit(1)})}async function xo({runId:e}){(await Re(process.cwd(),e)).match(n=>{process.stdout.write(`${bo(n)}
350
+ `)},n=>{process.stderr.write(`${H(n)}
351
+ `),process.exit(1)})}import{randomUUID as Cd}from"crypto";import Co from"path";import{graphql as Sd}from"gql.tada";import{err as X,ok as Rd}from"neverthrow";async function So(e,r,n){let t=y(e).match(f=>f,f=>f.kind);if(typeof t=="string")return X({detail:t,kind:"config"});let o=await Pr(e);if(o.result.isErr())return X({kind:"compile-failed"});let i=await u({config:t,document:Ed,variables:{id:r}}).catch(()=>null);if(i==null)return X({kind:"request-failed"});if(i.run==null)return X({kind:"not-found"});if(i.run.reproJson==null)return X({kind:"no-repro"});let s=qr.parse(JSON.parse(i.run.reproJson)),a=await le(e,o.result.value),l=`replay-${Cd()}`,d=se({cacheDir:void 0,clientVersion:w(),debugDir:Co.join(e,".ripplo","debug"),headed:!1,writeOtlpPortFile:!1});try{let f=await Hr({capture:!0,lockfile:a,options:{baseUrl:t.appUrl,engineUrl:t.engineUrl,fixturesDir:Co.join(e,G),generate:vr,headed:!1,secret:t.webhookSecret},repro:s,runId:l,session:d,signal:n});return Rd({outcome:f,replayRunId:l})}finally{await d.close()}}var Ed=Sd(`
352
352
  query RunRepro($id: String!) {
353
353
  run(id: $id) {
354
354
  id
355
355
  reproJson
356
356
  }
357
357
  }
358
- `);function So({outcome:e,replayRunId:r}){let n=Pd(e);return e.kind!=="resolved"&&e.kind!=="still-fails"?n:`${n}
359
- Replay run ${r} \u2014 snapshot it, e.g. \`npx ripplo snapshot ${r} --offset <ms>\`.`}function Pd(e){switch(e.kind){case"resolved":return"\u2713 Resolved \u2014 the finding's trail ran clean.";case"still-fails":return`\u2717 Still failing \u2014 ${R(e.findings.length,"check")} still mismatch.`;case"unplannable":return"! Model changed \u2014 this trail's base state or actions no longer exist. Use `npx ripplo compile` and `npx ripplo run`.";case"state-unavailable":return`! Couldn't run the trail (${e.reason}).`;case"aborted":return"Replay aborted."}}function Ro(e){switch(e.kind){case"config":return`Can't read project config (${e.detail}). Run from your project root.`;case"compile-failed":return"Couldn't compile the local `.ripplo/` model. Run `npx ripplo compile` first.";case"request-failed":return"Couldn't reach the server. Check you're signed in with `npx ripplo auth`.";case"not-found":return"No run with that id.";case"no-repro":return"This run has no replayable trail \u2014 predates repro capture, or isn't an explore finding."}}function Eo(e){return e.kind==="resolved"}async function Po({runId:e}){(await Co(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${So(n)}
360
- `),process.exit(Eo(n.outcome)?0:1)},n=>{process.stderr.write(`${Ro(n)}
361
- `),process.exit(1)})}import Do from"path";import{existsSync as _d}from"fs";import{writeFile as _o}from"fs/promises";import Fo from"path";import{err as ee,ok as Fd}from"neverthrow";import{createRequire as $d}from"module";import{readFile as Io}from"fs/promises";import{fileURLToPath as Id}from"url";import{z as Z}from"zod";var Ad={height:800,width:1280};async function Ao(e){let r=await Io(e,"utf8");return jd(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}function jd(e){return e.split(`
362
- `).filter(r=>r.length>0).flatMap(r=>{let n=F(r);return n==null?[]:[n]})}var Td=Z.object({data:Z.looseObject({height:Z.number(),width:Z.number()}),type:Z.literal(4)});function jo(e){let r=e.flatMap(n=>{let t=Td.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?Ad:{height:r.data.height,width:r.data.width}}var Md='<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>',Ld=`.replayer-mouse-tail { display: none; }
358
+ `);function Ro({outcome:e,replayRunId:r}){let n=Pd(e);return e.kind!=="resolved"&&e.kind!=="still-fails"?n:`${n}
359
+ Replay run ${r} \u2014 snapshot it, e.g. \`npx ripplo snapshot ${r} --offset <ms>\`.`}function Pd(e){switch(e.kind){case"resolved":return"\u2713 Resolved \u2014 the finding's trail ran clean.";case"still-fails":return`\u2717 Still failing \u2014 ${R(e.findings.length,"check")} still mismatch.`;case"unplannable":return"! Model changed \u2014 this trail's base state or actions no longer exist. Use `npx ripplo compile` and `npx ripplo run`.";case"state-unavailable":return`! Couldn't run the trail (${e.reason}).`;case"aborted":return"Replay aborted."}}function 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."}}function Po(e){return e.kind==="resolved"}async function $o({runId:e}){(await So(process.cwd(),e,new AbortController().signal)).match(n=>{process.stdout.write(`${Ro(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 _d}from"fs";import{writeFile as Fo}from"fs/promises";import Wo from"path";import{err as Z,ok as Fd}from"neverthrow";import{createRequire as $d}from"module";import{readFile as Ao}from"fs/promises";import{fileURLToPath as Id}from"url";import{z as Y}from"zod";var Ad={height:800,width:1280};async function jo(e){let r=await Ao(e,"utf8");return jd(r).flatMap(n=>n.kind==="rrweb"?[n.event]:[])}function jd(e){return e.split(`
362
+ `).filter(r=>r.length>0).flatMap(r=>{let n=_(r);return n==null?[]:[n]})}var Td=Y.object({data:Y.looseObject({height:Y.number(),width:Y.number()}),type:Y.literal(4)});function To(e){let r=e.flatMap(n=>{let t=Td.safeParse(n);return t.success?[t.data]:[]})[0];return r==null?Ad:{height:r.data.height,width:r.data.width}}var Md='<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>',Ld=`.replayer-mouse-tail { display: none; }
363
363
  .replayer-mouse {
364
364
  position: absolute;
365
365
  width: 17px;
@@ -368,20 +368,20 @@ Replay run ${r} \u2014 snapshot it, e.g. \`npx ripplo snapshot ${r} --offset <ms
368
368
  background-repeat: no-repeat;
369
369
  background-size: contain;
370
370
  background-image: url('data:image/svg+xml;utf8,${Md}');
371
- }`,Nd=".replayer-mouse, .replayer-mouse-tail { display: none; }";function To(e){return`<!doctype html><html><head><style>
371
+ }`,Nd=".replayer-mouse, .replayer-mouse-tail { display: none; }";function Mo(e){return`<!doctype html><html><head><style>
372
372
  html, body { margin: 0; padding: 0; }
373
373
  .replayer-wrapper { position: relative; }
374
374
  ${e?Ld:Nd}
375
375
  iframe { border: none; }
376
- </style></head><body></body></html>`}var Mo="*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }";function Lo(){return`(async () => {
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 () => {
377
377
  const doc = document.querySelector(".replayer-wrapper iframe")?.contentDocument;
378
378
  if (doc?.fonts != null) {
379
379
  await doc.fonts.ready;
380
380
  }
381
381
  await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
382
- })()`}function No(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var $o;function Oo(){return $o??=Io(Od(),"utf8"),$o}function Od(){let e=$d(import.meta.url);try{return e.resolve("@ripplo/rrweb-bundle/replay")}catch{return Id(new URL("assets/rrweb-replay.js",import.meta.url))}}async function Wo({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!_d(e))return ee({kind:"run-not-found",runId:t});let o=await Ao(e),i=o[0],s=o.at(-1);if(i==null||s==null)return ee({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 ee({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let d=Math.min(l,a),f=String(Math.round(d)),h=Fo.join(n,`snapshot-${f}ms.png`),c=Fo.join(n,`snapshot-${f}ms.html`);return(await Wd({events:o,htmlPath:c,offsetMs:d,pngPath:h})).map(()=>({durationMs:a,htmlPath:c,offsetMs:d,pngPath:h}))}async function Wd({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await No();if(o==null)return ee({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await Dd({browser:o,events:e,offsetMs:n});return await _o(t,s),await _o(r,i,"utf8"),Fd(void 0)}catch(i){return ee({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function Dd({browser:e,events:r,offsetMs:n}){let t=jo(r),o=await e.newPage({viewport:t});await o.setContent(To(!1)),await o.addScriptTag({content:await Oo()}),await o.evaluate(Ud({events:r,offsetMs:n})),await o.evaluate(Lo());let i=o.locator(".replayer-wrapper iframe").first(),a=await(await i.count()>0?i:o).screenshot({type:"png"});return{html:await o.evaluate(qd()),png:a}}function Ud({events:e,offsetMs:r}){return`(() => {
382
+ })()`}function Oo(){return import("playwright").then(({chromium:e})=>e.launch({args:["--no-sandbox"],headless:!0})).catch(()=>null)}var Io;function _o(){return Io??=Ao(Od(),"utf8"),Io}function Od(){let e=$d(import.meta.url);try{return e.resolve("@ripplo/rrweb-bundle/replay")}catch{return Id(new URL("assets/rrweb-replay.js",import.meta.url))}}async function Do({jsonlPath:e,moment:r,outDir:n,runId:t}){if(!_d(e))return Z({kind:"run-not-found",runId:t});let o=await jo(e),i=o[0],s=o.at(-1);if(i==null||s==null)return Z({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 Z({durationMs:a,firstTimestamp:i.timestamp,kind:"moment-out-of-range",lastTimestamp:s.timestamp,moment:r});let d=Math.min(l,a),f=String(Math.round(d)),h=Wo.join(n,`snapshot-${f}ms.png`),c=Wo.join(n,`snapshot-${f}ms.html`);return(await Wd({events:o,htmlPath:c,offsetMs:d,pngPath:h})).map(()=>({durationMs:a,htmlPath:c,offsetMs:d,pngPath:h}))}async function Wd({events:e,htmlPath:r,offsetMs:n,pngPath:t}){let o=await Oo();if(o==null)return Z({detail:"chromium launch",kind:"browser-failed"});try{let{html:i,png:s}=await Dd({browser:o,events:e,offsetMs:n});return await Fo(t,s),await Fo(r,i,"utf8"),Fd(void 0)}catch(i){return Z({detail:i instanceof Error?i.message:String(i),kind:"browser-failed"})}finally{await o.close()}}async function Dd({browser:e,events:r,offsetMs:n}){let t=To(r),o=await e.newPage({viewport:t});await o.setContent(Mo(!1)),await o.addScriptTag({content:await _o()}),await o.evaluate(Ud({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(qd()),png:a}}function Ud({events:e,offsetMs:r}){return`(() => {
383
383
  const replayer = new globalThis.__RipploReplayer(${JSON.stringify(e)}, {
384
- insertStyleRules: [${JSON.stringify(Mo)}],
384
+ insertStyleRules: [${JSON.stringify(Lo)}],
385
385
  mouseTail: false,
386
386
  root: document.body,
387
387
  showWarning: false,
@@ -406,47 +406,47 @@ iframe { border: none; }
406
406
  }
407
407
  });
408
408
  return "<!doctype html>\\n" + doc.documentElement.outerHTML;
409
- })()`}function Uo({cwd:e,moment:r,runId:n}){let t=Do.join(e,".ripplo","debug",n);return Wo({jsonlPath:Do.join(t,"behavior.jsonl"),moment:r,outDir:t,runId:n})}function qo(e){return[`${p.good("ok")} \u2014 rendered the page at ${String(Math.round(e.offsetMs))}ms into the recording (duration ${String(Math.round(e.durationMs))}ms)`,e.pngPath,"Read the PNG above to see the page state. Layout and text are faithful \u2014 URL-referenced images may be blank if the dev server is down.",e.htmlPath,"The HTML is the same frame with every element tagged `data-rrweb-id`. Grep it for your element's class or text to get the id for `tasks comment --element`."].join(`
410
- `)}function Bo(e){return`${p.bad("fail")} \u2014 ${Bd(e)}`}function Vo(){return`${p.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function Bd(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 Ho({at:e,offset:r,runId:n}){let t=Vd({at:e,offset:r});t==null&&(process.stderr.write(`${Vo()}
411
- `),process.exit(1));let o=await H(process.cwd(),n);o.isErr()&&(process.stderr.write(`${K(o.error)}
412
- `),process.exit(1)),(await Uo({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${qo(s)}
413
- `)},s=>{process.stderr.write(`${Bo(s)}
414
- `),process.exit(1)})}function Vd({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 Ko(e,r){switch(e.kind){case"config-failed":return b(e.failure);case"compile-failed":return D(e.error);case"no-test":return`test "${e.ref}" not found \u2014 run npx ripplo compile to see available tests`;case"unplannable":return"the recorded walk no longer matches the model \u2014 run npx ripplo compile, then re-run";case"run-failed":return`teleport failed before reaching the step: ${Lr(e.error)}`;case"done":return Hd(e.result,r)}}function Go(e){return e.kind==="done"&&e.result.kind==="handed-over"}function zo(e,r){return`landed at step ${String(e)} of ${r} \u2014 close the window to tear down`}function Hd(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
409
+ })()`}function qo({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 Bo(e){return[`${p.good("ok")} \u2014 rendered the page at ${String(Math.round(e.offsetMs))}ms into the recording (duration ${String(Math.round(e.durationMs))}ms)`,e.pngPath,"Read the PNG above to see the page state. Layout and text are faithful \u2014 URL-referenced images may be blank if the dev server is down.",e.htmlPath,"The HTML is the same frame with every element tagged `data-rrweb-id`. Grep it for your element's class or text to get the id for `tasks comment --element`."].join(`
410
+ `)}function Vo(e){return`${p.bad("fail")} \u2014 ${Bd(e)}`}function Ho(){return`${p.bad("fail")} \u2014 pass exactly one of --at <epoch-ms from behavior.jsonl> or --offset <ms from the start of the recording>.`}function Bd(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 Ko({at:e,offset:r,runId:n}){let t=Vd({at:e,offset:r});t==null&&(process.stderr.write(`${Ho()}
411
+ `),process.exit(1));let o=await V(process.cwd(),n);o.isErr()&&(process.stderr.write(`${H(o.error)}
412
+ `),process.exit(1)),(await qo({cwd:process.cwd(),moment:t,runId:n})).match(s=>{process.stdout.write(`${Bo(s)}
413
+ `)},s=>{process.stderr.write(`${Vo(s)}
414
+ `),process.exit(1)})}function Vd({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 b(e.failure);case"compile-failed":return D(e.error);case"no-test":return`test "${e.ref}" not found \u2014 run npx ripplo compile to see available tests`;case"unplannable":return"the recorded walk no longer matches the model \u2014 run npx ripplo compile, then re-run";case"run-failed":return`teleport failed before reaching the step: ${Lr(e.error)}`;case"done":return Hd(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 Hd(e,r){return e.kind==="failed"?`couldn't reach the step \u2014 the run failed first.
415
415
 
416
416
  ${e.findings.map(t=>Dr({evidencePath:void 0,finding:t})).join(`
417
417
 
418
- `)}`:`torn down \u2014 teleport session for ${r} ended`}async function Jo({ref:e,step:r}){let n=new AbortController;process.once("SIGINT",()=>{n.abort()});let t=()=>{process.stdout.write(`${zo(r,e)}
419
- `)},o=await En({cwd:process.cwd(),onReady:t,signal:n.signal,step:r,target:{kind:"test",ref:e}});process.stdout.write(`${Ko(o,e)}
420
- `),process.exit(Go(o)?0:1)}import Qo from"path";import{randomUUID as Kd}from"crypto";async function Xo({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-${Kd()}`;return(await Br({clientVersion:w(),debugDir:Qo.join(t.cwd,".ripplo","debug"),onReady:r,profileDir:Qo.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 Yo(){return"Capturing. Sign in if needed, click through your flow, then press Ctrl-C here to finish. Your login is remembered for next time."}function Zo(e){return e.kind==="config-failed"?`Could not read project config: ${e.detail}`:e.kind==="run-failed"?"Capture failed to start. Could not launch the browser.":Gd(e.behaviorPath,e.runId)}function ei(e){return e.kind==="done"}function Gd(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 ri(){let e=new AbortController;process.once("SIGINT",()=>{e.abort()});let r=await Xo({cwd:process.cwd(),onReady:zd,signal:e.signal});process.stdout.write(`${Zo(r)}
422
- `),process.exit(ei(r)?0:1)}function zd(){process.stdout.write(`${Yo()}
423
- `)}import{existsSync as Jd,readFileSync as Qd}from"fs";import Xd from"path";function ni(e,r){let n=Xd.join(e,".ripplo","debug",r,"behavior.jsonl");return Jd(n)?{actions:Vr(Qd(n,{encoding:"utf8"})),kind:"ok"}:{kind:"not-found",runId:r}}function ti(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)=>Yd(r,n)).join(`
424
- `)}function oi(e){return e.kind==="ok"}function Yd(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 ii({runId:e}){let r=ni(process.cwd(),e);process.stdout.write(`${ti(r)}
425
- `),process.exit(oi(r)?0:1)}async function si(){let e=g();try{let n=(await J(e.cwd,e)).match(i=>i,i=>{process.stderr.write(`${b(i)}
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 Pn({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 Kd}from"crypto";async function Yo({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-${Kd()}`;return(await Br({clientVersion:w(),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.":Gd(e.behaviorPath,e.runId)}function ri(e){return e.kind==="done"}function Gd(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:zd,signal:e.signal});process.stdout.write(`${ei(r)}
422
+ `),process.exit(ri(r)?0:1)}function zd(){process.stdout.write(`${Zo()}
423
+ `)}import{existsSync as Jd,readFileSync as Qd}from"fs";import Xd from"path";function ti(e,r){let n=Xd.join(e,".ripplo","debug",r,"behavior.jsonl");return Jd(n)?{actions:Vr(Qd(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)=>Yd(r,n)).join(`
424
+ `)}function ii(e){return e.kind==="ok"}function Yd(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(`${b(i)}
426
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}
427
427
  `)}catch(r){let n=r instanceof Error?r.message:String(r);process.stderr.write(`ripplo sync failed: ${n}
428
428
  `),process.stderr.write(`${x("setup","verify auth + server reachability")}
429
- `),process.exit(1)}}import{spawnSync as ru}from"child_process";import nu from"fs";import tu from"path";import ou from"semver";import Pe from"fs";import Zd from"os";import re from"path";function ai(e){return e.split(re.sep).includes("_npx")?"npx":e.includes(re.join("packages","cli"))?"workspace":"global"}function li(){let e=re.join(Zd.homedir(),".npm","_npx");return Pe.existsSync(e)?Pe.readdirSync(e).map(r=>re.join(e,r)).filter(r=>Pe.existsSync(re.join(r,"node_modules","ripplo"))).map(r=>(Pe.rmSync(r,{force:!0,recursive:!0}),r)):[]}import{spawnSync as di}from"child_process";var eu=["user","project","local"];function er(){return di("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":eu.find(n=>di("claude",["plugin","update","ripplo","--scope",n],{stdio:"ignore"}).status===0)==null?"not-installed":"updated"}function ui(e){return`ripplo v${e} is already the latest version.`}function ci(e){return`ripplo v${e}: could not reach the npm registry to check for updates.`}function rr({evicted:e,latest:r,mode:n}){return n==="npx"?`ripplo: ${e===0?"npx cache had no stale copy":`cleared ${R(e,"stale npx cache entry","stale npx cache entries")}`} \u2014 the next \`npx ripplo\` command runs v${r}.`:`ripplo: updated global install to v${r}.`}function pi(){return"ripplo: this is a workspace build (packages/cli/dist) \u2014 update via git pull + `pnpm --filter ripplo build`."}function mi(e){return`ripplo: \`npm install -g ripplo@latest\` failed: ${e}`}function nr(e){switch(e){case"updated":return"ripplo: Claude plugin updated \u2014 restart Claude Code (or /reload-plugins) to apply.";case"not-installed":return"ripplo: Claude plugin not installed in this project \u2014 skipped.";case"claude-missing":return"ripplo: claude binary not found \u2014 skipped plugin update."}}function fi(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 iu=1e4;async function gi(){let e=w(),r=process.argv[1];su(process.cwd());let n=await ge(iu);process.stdout.write(`${fe({current:e,latest:n})}
430
- `),n==null&&(process.stderr.write(`${ci(e)}
431
- `),process.exit(1)),ou.gt(n,e)||(process.stdout.write(`${ui(e)}
432
- `),process.stdout.write(`${nr(er())}
433
- `),process.exit(0));let t=r==null?"global":ai(r);au({latest:n,mode:t}),process.stdout.write(`${nr(er())}
434
- `),await du(process.cwd()),process.exit(0)}function su(e){if(!nu.existsSync(tu.join(e,".ripplo")))return;let r=ke(e);r==="written"&&process.stdout.write(`${we(r).trim()}
435
- `)}function au({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${pi()}
436
- `),process.exit(0)),r==="npx"){let n=li();process.stdout.write(`${rr({evicted:n.length,latest:e,mode:r})}
437
- `);return}lu(e)}function lu(e){let r=`ripplo@${e}`,n=ru("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${mi(t)}
438
- `),process.exit(1)}process.stdout.write(`${rr({evicted:0,latest:e,mode:"global"})}
439
- `)}async function du(e){if((await an(e)).kind==="not-running")return;let n=await sn(e);process.stdout.write(`${fi(n)}
440
- `)}async function yi({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-QBBCVTXV.js");await n({format:"summary"});return}if(e==="stop"||e==="restart"){let n=await uu();(e==="stop"||!n)&&process.exit(n?0:1)}cu();let{runDaemon:r}=await import("./daemon-O2VR45XP.js");await r()}async function uu(){let{stopDevDaemon:e}=await import("./daemon-lock-FLZHWM2F.js"),{renderDaemonStopResult:r}=await import("./daemon-JJ6MZPIA.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
441
- `),n.kind!=="timeout"}function cu(){let e=xe(ce());e!=null&&process.stderr.write(`${e}
442
- `)}function hi(e){return`executor: ${e}`}function ki(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 wi(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 bi({mode:e}){let r=y(process.cwd()).match(t=>t,t=>{process.stderr.write(`${b(t)}
443
- `),process.exit(1)});(e==null?await $n(r):await In(r,e)).match(t=>{process.stdout.write(`${e==null?hi(t):ki(t)}
444
- `)},t=>{process.stderr.write(`${wi(t)}
445
- `),process.exit(1)})}async function vi({state:e,trail:r,workers:n}){let t=y(process.cwd()).match(i=>i,i=>{process.stderr.write(`${b(i)}
446
- `),process.exit(1)});(e==null?await ze(t):await Je(t,{active:e==="on",trail:r,workers:n})).match(i=>{process.stdout.write(`${e==null?Dt(i):Ut(i)}
447
- `)},i=>{process.stderr.write(`${Bt(i)}
448
- `),process.exit(1)})}import{graphql as $e}from"gql.tada";function xi(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function Ci(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(`
449
- `)}import{graphql as pu}from"gql.tada";var Si=pu(`
429
+ `),process.exit(1)}}import{spawnSync as ru}from"child_process";import nu from"fs";import tu from"path";import ou from"semver";import Ee from"fs";import Zd from"os";import ee from"path";function li(e){return e.split(ee.sep).includes("_npx")?"npx":e.includes(ee.join("packages","cli"))?"workspace":"global"}function di(){let e=ee.join(Zd.homedir(),".npm","_npx");return Ee.existsSync(e)?Ee.readdirSync(e).map(r=>ee.join(e,r)).filter(r=>Ee.existsSync(ee.join(r,"node_modules","ripplo"))).map(r=>(Ee.rmSync(r,{force:!0,recursive:!0}),r)):[]}import{spawnSync as ui}from"child_process";var eu=["user","project","local"];function Ze(){return ui("claude",["--version"],{stdio:"ignore"}).error!=null?"claude-missing":eu.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 er({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 rr(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 iu=1e4;async function yi(){let e=w(),r=process.argv[1];su(process.cwd());let n=await fe(iu);process.stdout.write(`${me({current:e,latest:n})}
430
+ `),n==null&&(process.stderr.write(`${pi(e)}
431
+ `),process.exit(1)),ou.gt(n,e)||(process.stdout.write(`${ci(e)}
432
+ `),process.stdout.write(`${rr(Ze())}
433
+ `),process.exit(0));let t=r==null?"global":li(r);au({latest:n,mode:t}),process.stdout.write(`${rr(Ze())}
434
+ `),await du(process.cwd()),process.exit(0)}function su(e){if(!nu.existsSync(tu.join(e,".ripplo")))return;let r=he(e);r==="written"&&process.stdout.write(`${ke(r).trim()}
435
+ `)}function au({latest:e,mode:r}){if(r==="workspace"&&(process.stdout.write(`${mi()}
436
+ `),process.exit(0)),r==="npx"){let n=di();process.stdout.write(`${er({evicted:n.length,latest:e,mode:r})}
437
+ `);return}lu(e)}function lu(e){let r=`ripplo@${e}`,n=ru("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${fi(t)}
438
+ `),process.exit(1)}process.stdout.write(`${er({evicted:0,latest:e,mode:"global"})}
439
+ `)}async function du(e){if((await ln(e)).kind==="not-running")return;let n=await an(e);process.stdout.write(`${gi(n)}
440
+ `)}async function hi({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-UBUNHH5O.js");await n({format:"summary"});return}if(e==="stop"||e==="restart"){let n=await uu();(e==="stop"||!n)&&process.exit(n?0:1)}cu();let{runDaemon:r}=await import("./daemon-BN42ZNCJ.js");await r()}async function uu(){let{stopDevDaemon:e}=await import("./daemon-lock-LTQMLU4Q.js"),{renderDaemonStopResult:r}=await import("./daemon-LFFCR3TB.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
441
+ `),n.kind!=="timeout"}function cu(){let e=ve(ue());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=y(process.cwd()).match(t=>t,t=>{process.stderr.write(`${b(t)}
443
+ `),process.exit(1)});(e==null?await In(r):await An(r,e)).match(t=>{process.stdout.write(`${e==null?ki(t):wi(t)}
444
+ `)},t=>{process.stderr.write(`${bi(t)}
445
+ `),process.exit(1)})}async function xi({state:e,trail:r,workers:n}){let t=y(process.cwd()).match(i=>i,i=>{process.stderr.write(`${b(i)}
446
+ `),process.exit(1)});(e==null?await Ge(t):await ze(t,{active:e==="on",trail:r,workers:n})).match(i=>{process.stdout.write(`${e==null?Ut(i):qt(i)}
447
+ `)},i=>{process.stderr.write(`${Vt(i)}
448
+ `),process.exit(1)})}import{graphql as Pe}from"gql.tada";function Ci(){return"No scope items added \u2014 matched tests already in scope (`npx ripplo scope status`)."}function Si(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(`
449
+ `)}import{graphql as pu}from"gql.tada";var Ri=pu(`
450
450
  query ScopeStatus($projectId: String!, $cwd: String!) {
451
451
  project(id: $projectId) {
452
452
  id
@@ -466,7 +466,7 @@ ${e.findings.map(t=>Dr({evidencePath:void 0,finding:t})).join(`
466
466
  }
467
467
  }
468
468
  }
469
- `);var mu=$e(`
469
+ `);var mu=Pe(`
470
470
  query ScopeWorkflowBySlug($projectId: String!, $cwd: String!, $slug: String!) {
471
471
  project(id: $projectId) {
472
472
  id
@@ -479,7 +479,7 @@ ${e.findings.map(t=>Dr({evidencePath:void 0,finding:t})).join(`
479
479
  }
480
480
  }
481
481
  }
482
- `),fu=$e(`
482
+ `),fu=Pe(`
483
483
  mutation ScopeAddDirtyTests($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
484
484
  addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
485
485
  __typename
@@ -501,31 +501,31 @@ ${e.findings.map(t=>Dr({evidencePath:void 0,finding:t})).join(`
501
501
  }
502
502
  }
503
503
  }
504
- `),gu=$e(`
504
+ `),gu=Pe(`
505
505
  mutation ScopeLink($id: ID!, $workflowId: String!) {
506
506
  linkScopeItem(id: $id, workflowId: $workflowId) {
507
507
  id
508
508
  }
509
509
  }
510
- `),yu=$e(`
510
+ `),yu=Pe(`
511
511
  mutation ScopeRemoveMany($ids: [ID!]!) {
512
512
  removeScopeItems(ids: $ids)
513
513
  }
514
- `);async function Ri(e){let r=g();await v(r);let t=(await u({config:r,document:Si,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
514
+ `);async function Ei(e){let r=g();await v(r);let t=(await u({config:r,document:Ri,variables:{cwd:r.cwd,projectId:r.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
515
515
  `);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??""}
516
516
  `);return}let s=i.spec==null?"stub":"implemented";process.stdout.write(` [${s}] (${o.id}) ${i.slug} \u2014 ${i.name}
517
- `)})}async function Ei({testIds:e}){let r=g();await v(r),(await J(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${b(a)}
517
+ `)})}async function Pi({testIds:e}){let r=g();await v(r),(await z(r.cwd,r)).match(()=>{},a=>{process.stderr.write(`${b(a)}
518
518
  `),process.exit(1)});let o=(await u({config:r,document:fu,variables:{cwd:r.cwd,projectId:r.projectId,workflowSlugs:e.map(a=>Sr(a))}})).addDirtyTestsToScope;o?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${o.message}
519
- `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${Ci(o.slugs)}
520
- `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${xi()}
519
+ `),process.exit(1)),o?.__typename==="UnknownWorkflowSlugsError"&&(process.stderr.write(`${Si(o.slugs)}
520
+ `),process.exit(1));let i=o?.__typename==="MutationAddDirtyTestsToScopeSuccess"?o.data:[];if(i.length===0){process.stdout.write(`${Ci()}
521
521
  `);return}let s=i.map(a=>a.workflow?.slug??"?").join(", ");process.stdout.write(`Added ${R(i.length,"scope item")}: ${s}
522
- `)}async function Pi({id:e,testId:r}){let n=g();await v(n),(await J(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${b(i)}
522
+ `)}async function $i({id:e,testId:r}){let n=g();await v(n),(await z(n.cwd,n)).match(()=>{},i=>{process.stderr.write(`${b(i)}
523
523
  `),process.exit(1)});let o=await hu({cfg:n,slug:r});await u({config:n,document:gu,variables:{id:e,workflowId:o}}),process.stdout.write(`Linked scope item ${e} to ${r}
524
- `)}async function $i({ids:e}){let r=g();await v(r);let t=(await u({config:r,document:yu,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${R(t,"scope item")}
524
+ `)}async function Ii({ids:e}){let r=g();await v(r);let t=(await u({config:r,document:yu,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${R(t,"scope item")}
525
525
  `)}async function hu({cfg:e,slug:r}){let t=(await u({config:e,document:mu,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.
526
526
  `),process.stderr.write(`${x("create")}
527
- `),process.exit(1)),t.id}import{graphql as A}from"gql.tada";import{print as Wi}from"graphql";import{createClient as Di}from"graphql-sse";import tr from"fs";import ku from"path";import{err as Ie,ok as wu}from"neverthrow";function Ai({cwd:e,rrwebId:r,runId:n}){let t=Ti(e,n);if(!tr.existsSync(t))return Ie({kind:"no-behavior"});let o=Oi(Ni(t,r));if(o==null)return Ie({kind:"not-found"});let i=ir(o.node.type);return i===3?Ie({kind:"text-node",parentId:ir(o.parent?.id)}):i!==2?Ie({kind:"non-element",nodeType:i??-1}):wu({tagName:$(o.node.tagName)})}function ji({cwd:e,rrwebId:r,runId:n}){let t=Ni(Ti(e,n),r);if(t==null)return null;let o=Oi(t);return o==null||ir(o.node.type)!==2?null:bu(t)}function Ti(e,r){return ku.join(e,".ripplo","debug",r,"behavior.jsonl")}function bu(e){let r=e.at(-1)??{},n=sr(r.attributes)??{},t=$(r.tagName);return{ariaName:$(n["aria-label"]),role:$(n.role),selector:xu(e),tagName:t==null?null:t.toLowerCase(),testId:$(n["data-testid"]),text:Pu(Eu(r))}}var vu=6;function xu(e){let r=Mi(e,e.length-1,vu);return r.length===0?null:r.join(" > ")}function Mi(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=Cu(t);if(o!=null)return[o];let i=Su(t,e[r-1]);return r===0||n===1?[i]:[...Mi(e,r-1,n-1),i]}function Cu(e){let r=sr(e.attributes)??{},n=$(r["data-testid"]);if(n!=null)return`[data-testid="${n}"]`;let t=$(r.id);return t!=null&&t.length>0?`#${t}`:null}function Su(e,r){let n=($(e.tagName)??"*").toLowerCase(),t=Li(r).filter(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 Li(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>Ae(n)):[]}function Ni(e,r){return tr.existsSync(e)?tr.readFileSync(e,"utf8").split(`
528
- `).reduce((t,o)=>t!=null||o.length===0?t:Ru(o,r),null):null}function Ru(e,r){let n=F(e);if(n?.kind!=="rrweb")return null;let t=sr(n.event.data),o=or(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??(Ae(a)?or(a.node,r):null),null):null}function or(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??or(i,r),null);return t==null?null:[e,...t]}function Oi(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var Ii=80;function Eu(e){let r=Li(e).filter(n=>n.type===3).map(n=>$(n.textContent)).filter(n=>n!=null);return r.length===0?null:r.join(" ")}function $(e){return typeof e=="string"?e:null}function Pu(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>Ii?`${r.slice(0,Ii)}\u2026`:r}function sr(e){return Ae(e)?e:void 0}function Ae(e){return typeof e=="object"&&e!=null}function ir(e){return typeof e=="number"?e:null}function ar(e,r){let n=r.flatMap(o=>$u(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function $u(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 Iu=A(`
527
+ `),process.exit(1)),t.id}import{graphql as A}from"gql.tada";import{print as Di}from"graphql";import{createClient as Ui}from"graphql-sse";import nr from"fs";import ku from"path";import{err as $e,ok as wu}from"neverthrow";function ji({cwd:e,rrwebId:r,runId:n}){let t=Mi(e,n);if(!nr.existsSync(t))return $e({kind:"no-behavior"});let o=_i(Oi(t,r));if(o==null)return $e({kind:"not-found"});let i=or(o.node.type);return i===3?$e({kind:"text-node",parentId:or(o.parent?.id)}):i!==2?$e({kind:"non-element",nodeType:i??-1}):wu({tagName:$(o.node.tagName)})}function Ti({cwd:e,rrwebId:r,runId:n}){let t=Oi(Mi(e,n),r);if(t==null)return null;let o=_i(t);return o==null||or(o.node.type)!==2?null:bu(t)}function Mi(e,r){return ku.join(e,".ripplo","debug",r,"behavior.jsonl")}function bu(e){let r=e.at(-1)??{},n=ir(r.attributes)??{},t=$(r.tagName);return{ariaName:$(n["aria-label"]),role:$(n.role),selector:xu(e),tagName:t==null?null:t.toLowerCase(),testId:$(n["data-testid"]),text:Pu(Eu(r))}}var vu=6;function xu(e){let r=Li(e,e.length-1,vu);return r.length===0?null:r.join(" > ")}function Li(e,r,n){let t=e[r];if(t==null||n<=0)return[];let o=Cu(t);if(o!=null)return[o];let i=Su(t,e[r-1]);return r===0||n===1?[i]:[...Li(e,r-1,n-1),i]}function Cu(e){let r=ir(e.attributes)??{},n=$(r["data-testid"]);if(n!=null)return`[data-testid="${n}"]`;let t=$(r.id);return t!=null&&t.length>0?`#${t}`:null}function Su(e,r){let n=($(e.tagName)??"*").toLowerCase(),t=Ni(r).filter(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 Ni(e){let r=e?.childNodes;return Array.isArray(r)?r.filter(n=>Ie(n)):[]}function Oi(e,r){return nr.existsSync(e)?nr.readFileSync(e,"utf8").split(`
528
+ `).reduce((t,o)=>t!=null||o.length===0?t:Ru(o,r),null):null}function Ru(e,r){let n=_(e);if(n?.kind!=="rrweb")return null;let t=ir(n.event.data),o=tr(t?.node,r);if(o!=null)return o;let i=t?.adds;return Array.isArray(i)?i.reduce((s,a)=>s??(Ie(a)?tr(a.node,r):null),null):null}function tr(e,r){if(!Ie(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??tr(i,r),null);return t==null?null:[e,...t]}function _i(e){let r=e?.at(-1);return r==null?null:{node:r,parent:e?.at(-2)}}var Ai=80;function Eu(e){let r=Ni(e).filter(n=>n.type===3).map(n=>$(n.textContent)).filter(n=>n!=null);return r.length===0?null:r.join(" ")}function $(e){return typeof e=="string"?e:null}function Pu(e){let r=e==null?"":e.replaceAll(/\s+/g," ").trim();return r.length===0?null:r.length>Ai?`${r.slice(0,Ai)}\u2026`:r}function ir(e){return Ie(e)?e:void 0}function Ie(e){return typeof e=="object"&&e!=null}function or(e){return typeof e=="number"?e:null}function sr(e,r){let n=r.flatMap(o=>$u(e,o)),t=new Map(r.map(o=>[o.id,o.fingerprint]));return{changes:n,seen:t}}function $u(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 Iu=A(`
529
529
  query WorkList($projectId: String!, $cwd: String!) {
530
530
  project(id: $projectId) {
531
531
  id
@@ -563,7 +563,7 @@ ${e.findings.map(t=>Dr({evidencePath:void 0,finding:t})).join(`
563
563
  }
564
564
  }
565
565
  }
566
- `),Ui=A(`
566
+ `),qi=A(`
567
567
  subscription WatchTasks($devSessionId: String!) {
568
568
  tasksChanged(devSessionId: $devSessionId) {
569
569
  devSession {
@@ -677,21 +677,21 @@ ${e.findings.map(t=>Dr({evidencePath:void 0,finding:t})).join(`
677
677
  }
678
678
  }
679
679
  }
680
- `),_u=18e4;async function qi(e){let r=g();await v(r);let n=await _i(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await Fu({cfg:r,devSessionId:n.devSessionId});let o=await _i(r);Fi(o.items,e.format);return}Fi(n.items,e.format)}async function _i(e){let n=(await u({config:e,document:Iu,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return{devSessionId:n?.id??null,items:n?.tasks??[]}}function Fi(e,r){if(r==="json"){process.stdout.write(`${JSON.stringify(e,null,2)}
681
- `);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(`${An(n)}
682
- `)}function Fu({cfg:e,devSessionId:r}){let n=Di({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,_u),o.dispose=n.subscribe({query:Wi(Ui),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function Bi(){let e=g();await v(e);let n=(await u({config:e,document:Au,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=ar(new Map,Hi(n.tasks??[])),o=Di({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});Wu({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function Wu({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:Wi(Ui),variables:{devSessionId:e}},{complete:()=>{},error:o=>{process.stderr.write(`task watch error: ${String(o)}
683
- `)},next:o=>{let i=o.data?.tasksChanged?.devSession?.tasks??[],s=ar(t,Hi(i));s.changes.forEach(a=>{process.stdout.write(`${Tn(a)}
684
- `)}),t=s.seen}})}async function Vi(e){let r=g();await v(r);let t=(await u({config:r,document:ju,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${Mn(e.id)}
680
+ `),_u=18e4;async function Bi(e){let r=g();await v(r);let n=await Fi(r),t=n.items.some(o=>o.kind==="finding");if(e.wait&&!t&&n.devSessionId!=null){await Fu({cfg:r,devSessionId:n.devSessionId});let o=await Fi(r);Wi(o.items,e.format);return}Wi(n.items,e.format)}async function Fi(e){let n=(await u({config:e,document:Iu,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return{devSessionId:n?.id??null,items:n?.tasks??[]}}function Wi(e,r){if(r==="json"){process.stdout.write(`${JSON.stringify(e,null,2)}
681
+ `);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(`${jn(n)}
682
+ `)}function Fu({cfg:e,devSessionId:r}){let n=Ui({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,_u),o.dispose=n.subscribe({query:Di(qi),variables:{devSessionId:r}},{complete:i,error:()=>{i()},next:s=>{(s.data?.tasksChanged?.devSession?.tasks??[]).some(l=>l.kind==="finding")&&i()}})})}async function Vi(){let e=g();await v(e);let n=(await u({config:e,document:Au,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(n==null)throw new Error("dev session vanished between preflight and seed");let t=sr(new Map,Ki(n.tasks??[])),o=Ui({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});Wu({devSessionId:n.id,seen:t.seen,sseClient:o}),await new Promise(()=>{})}function Wu({devSessionId:e,seen:r,sseClient:n}){let t=r;n.subscribe({query:Di(qi),variables:{devSessionId:e}},{complete:()=>{},error:o=>{process.stderr.write(`task watch error: ${String(o)}
683
+ `)},next:o=>{let i=o.data?.tasksChanged?.devSession?.tasks??[],s=sr(t,Ki(i));s.changes.forEach(a=>{process.stdout.write(`${Mn(a)}
684
+ `)}),t=s.seen}})}async function Hi(e){let r=g();await v(r);let t=(await u({config:r,document:ju,variables:{id:e.id}})).task;if(t==null&&(process.stderr.write(`${Ln(e.id)}
685
685
  `),process.exit(1)),e.format==="json"){process.stdout.write(`${JSON.stringify(t,null,2)}
686
- `);return}let o=[...new Set((t.messages??[]).flatMap(s=>s.runId==null?[]:[s.runId]))];await Promise.all(o.map(s=>H(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:ji({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(`${jn(i)}
687
- `)}function Hi(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 Ki(e){let r=g();if(await v(r),e.elementId!=null&&e.runId!=null){let t=Ai({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${Du(t,e.elementId,e.runId)}
688
- `),process.exit(1))}let n=await u({config:r,document:Tu,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(`${Ln(e.id)}
689
- `)}async function Gi(e){let r=g();await v(r);let n=await u({config:r,document:Mu,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});je(n.agentResolveTask),process.stdout.write(`${Wn(e.id)}
690
- `)}async function zi(e){let r=g();await v(r);let n=await u({config:r,document:Lu,variables:{taskId:e.id}});je(n.agentStartTask),process.stdout.write(`${Dn(e.id)}
691
- `)}async function Ji(e){e.body.trim().length===0&&(process.stderr.write(`${Nn()}
692
- `),process.exit(1));let r=g();await v(r);let n=await u({config:r,document:Nu,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});je(n.agentSetNeedsClarification),process.stdout.write(`${Un(e.id)}
693
- `)}async function Qi(e){let r=g();await v(r);let t=(await u({config:r,document:Ou,variables:{authorName:e.authorName??null,note:e.note??null,taskId:e.id}})).agentDismissTask;(t?.__typename==="FindingNotDismissableError"||t?.__typename==="NoActiveDevSessionError")&&(process.stderr.write(`${t.message}
694
- `),process.exit(1)),process.stdout.write(`${qn(e.id)}
695
- `)}function je(e){e?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${e.message}
696
- `),process.exit(1))}function Du(e,r,n){return e.kind==="text-node"?On(r,e.parentId):e.kind==="not-found"?_n(r,n):Fn(r)}function Xi(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=>qi({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,()=>Bi()).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=>Vi({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=>Ki({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=>zi({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=>Gi({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=>Ji({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=>Qi({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}kr();G(process.cwd());gr();async function Hu(){te(w()),Rr({size:Math.max(1,Math.min(10,Uu()-2)),workerUrl:Kn()}),qu({pkg:{name:"ripplo",version:w()}}).notify({message:Gn()}),await Bu(Vu(process.argv)).scriptName("ripplo").version(w()).command(Gu()).command(zu()).command(Ju()).command(tc()).command("auth <subcommand>","Manage authentication",dc).command("projects <subcommand>","List or create Ripplo projects",lc).command("hooks <subcommand>","Pause or resume Ripplo hooks",ac).command(Yu()).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=>Ct({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`)",ic,e=>Kt({all:e.all,headed:e.headed,ids:e.ids})).command(ec()).command(oc()).command(rc()).command(nc()).command(Ku()).command(Zu()).command(Qu()).command(Xu()).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>si()).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=>rt({check:e.check})).command("update","Update ripplo to the latest published version (and hand the daemon off to it)",()=>{},()=>gi()).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=>Pn({format:e.format})).command("scope <subcommand>","Manage testing scope",sc).command("tasks <subcommand>","Manage tasks for this dev session",Xi).command("run-worker",!1,()=>{},()=>Xt()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(Bn),demandOption:!0,type:"string"}),e=>Vn(e.name)).strict().help().parse(),Er()}Hu().catch(e=>{process.stderr.write(`${jr(e)}
697
- `),process.exit(1)});function Ku(){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=>Mt({kind:e.kind,rootCause:e["root-cause"],runId:e.run,surfacedBy:e["surfaced-by"],title:e.title})}}function Gu(){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=>yi({action:e.action})}}function zu(){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=>bi({mode:e.mode})}}function Ju(){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=>vi({state:e.state,trail:e.trail,workers:e.workers})}}function Qu(){return{command:"explain <runId>",describe:"Explain a run's failing checks \u2014 what failed, where it came from, and what happened around it",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("json",{default:!1,describe:"Machine-readable output",type:"boolean"}),handler:e=>bo({json:e.json,runId:e.runId})}}function Xu(){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=>Po({runId:e.runId})}}function Yu(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{jt()}}}function Zu(){return{command:"pull <runId>",describe:"Download a run's behavior.jsonl from the server",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}),handler:e=>vo({runId:e.runId})}}function ec(){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=>Ho({at:e.at,offset:e.offset,runId:e.runId})}}function rc(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>ri()}}function nc(){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=>{ii({runId:e.runId})}}}function tc(){return{command:"concurrency [value]",describe:"Show or set max local concurrent runs (daemon applies live)",builder:e=>e.positional("value",{type:"number"}),handler:e=>tt({value:e.value})}}function oc(){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=>Jo({ref:e.ref,step:e.step})}}function ic(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 sc(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>Ri({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=>Ei({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=>Pi({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 ac(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>pt()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>mt()).demandCommand(1)}function lc(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>Et()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>Pt({name:r.name,orgId:r.org})).demandCommand(1)}function dc(e){return e.command("login","Authenticate via device flow",()=>{},()=>Yn()).command("status","Show authentication status",()=>{},()=>Zn()).command("logout","Remove the saved token",()=>{},()=>{et()}).demandCommand(1)}export{Hu as main};
686
+ `);return}let o=[...new Set((t.messages??[]).flatMap(s=>s.runId==null?[]:[s.runId]))];await Promise.all(o.map(s=>V(r.cwd,s).then(a=>a.isErr())));let i={id:t.id,kind:t.kind,lastMessage:(t.messages??[]).at(-1)?.body??null,messages:(t.messages??[]).map(s=>({author:s.author,authorName:s.authorName,body:s.body,element:s.runId==null||s.rrwebId==null?null:Ti({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(`${Tn(i)}
687
+ `)}function Ki(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 Gi(e){let r=g();if(await v(r),e.elementId!=null&&e.runId!=null){let t=ji({cwd:r.cwd,rrwebId:e.elementId,runId:e.runId}).match(()=>null,o=>o);t!=null&&t.kind!=="no-behavior"&&(process.stderr.write(`${Du(t,e.elementId,e.runId)}
688
+ `),process.exit(1))}let n=await u({config:r,document:Tu,variables:{authorName:e.authorName??null,body:e.body,frameMs:e.offsetMs??null,rrwebId:e.elementId??null,runId:e.runId??null,taskId:e.id}});Ae(n.agentCommentOnTask),process.stdout.write(`${Nn(e.id)}
689
+ `)}async function zi(e){let r=g();await v(r);let n=await u({config:r,document:Mu,variables:{authorName:e.authorName??null,note:e.note??null,runId:e.runId,taskId:e.id}});Ae(n.agentResolveTask),process.stdout.write(`${Dn(e.id)}
690
+ `)}async function Ji(e){let r=g();await v(r);let n=await u({config:r,document:Lu,variables:{taskId:e.id}});Ae(n.agentStartTask),process.stdout.write(`${Un(e.id)}
691
+ `)}async function Qi(e){e.body.trim().length===0&&(process.stderr.write(`${On()}
692
+ `),process.exit(1));let r=g();await v(r);let n=await u({config:r,document:Nu,variables:{authorName:e.authorName??null,body:e.body,taskId:e.id}});Ae(n.agentSetNeedsClarification),process.stdout.write(`${qn(e.id)}
693
+ `)}async function Xi(e){let r=g();await v(r);let t=(await u({config:r,document:Ou,variables:{authorName:e.authorName??null,note:e.note??null,taskId:e.id}})).agentDismissTask;(t?.__typename==="FindingNotDismissableError"||t?.__typename==="NoActiveDevSessionError")&&(process.stderr.write(`${t.message}
694
+ `),process.exit(1)),process.stdout.write(`${Bn(e.id)}
695
+ `)}function Ae(e){e?.__typename==="NoActiveDevSessionError"&&(process.stderr.write(`${e.message}
696
+ `),process.exit(1))}function Du(e,r,n){return e.kind==="text-node"?_n(r,e.parentId):e.kind==="not-found"?Fn(r,n):Wn(r)}function Yi(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=>Bi({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,()=>Vi()).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=>Hi({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=>Gi({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=>Ji({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=>zi({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=>Qi({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=>Xi({authorName:r.as,id:r.id,note:r.note})).demandCommand(1)}hr();K(process.cwd());fr();async function Hu(){ne(w()),Rr({size:Math.max(1,Math.min(10,Uu()-2)),workerUrl:Gn()}),qu({pkg:{name:"ripplo",version:w()}}).notify({message:zn()}),await Bu(Vu(process.argv)).scriptName("ripplo").version(w()).command(Gu()).command(zu()).command(Ju()).command(tc()).command("auth <subcommand>","Manage authentication",dc).command("projects <subcommand>","List or create Ripplo projects",lc).command("hooks <subcommand>","Pause or resume Ripplo hooks",ac).command(Yu()).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=>St({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`)",ic,e=>Gt({all:e.all,headed:e.headed,ids:e.ids})).command(ec()).command(oc()).command(rc()).command(nc()).command(Ku()).command(Zu()).command(Qu()).command(Xu()).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=>nt({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",()=>{},()=>pt()).command("status","Report stub tests and daemon status",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>$n({format:e.format})).command("scope <subcommand>","Manage testing scope",sc).command("tasks <subcommand>","Manage tasks for this dev session",Yi).command("run-worker",!1,()=>{},()=>Yt()).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(Vn),demandOption:!0,type:"string"}),e=>Hn(e.name)).strict().help().parse(),Er()}Hu().catch(e=>{process.stderr.write(`${jr(e)}
697
+ `),process.exit(1)});function Ku(){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=>Lt({kind:e.kind,rootCause:e["root-cause"],runId:e.run,surfacedBy:e["surfaced-by"],title:e.title})}}function Gu(){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 zu(){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 Ju(){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=>xi({state:e.state,trail:e.trail,workers:e.workers})}}function Qu(){return{command:"explain <runId>",describe:"Explain a run's failing checks \u2014 what failed, where it came from, and what happened around it",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}).option("json",{default:!1,describe:"Machine-readable output",type:"boolean"}),handler:e=>vo({json:e.json,runId:e.runId})}}function Xu(){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=>$o({runId:e.runId})}}function Yu(){return{command:"setup",describe:"Install the Ripplo plugin for Claude Code and start a guided setup session",builder:e=>e,handler:()=>{Tt()}}}function Zu(){return{command:"pull <runId>",describe:"Download a run's behavior.jsonl from the server",builder:e=>e.positional("runId",{demandOption:!0,type:"string"}),handler:e=>xo({runId:e.runId})}}function ec(){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 rc(){return{command:"capture",describe:"Open your signed-in browser, record a flow, and hand the log to Claude",builder:e=>e,handler:()=>ni()}}function nc(){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 tc(){return{command:"concurrency [value]",describe:"Show or set max local concurrent runs (daemon applies live)",builder:e=>e.positional("value",{type:"number"}),handler:e=>ot({value:e.value})}}function oc(){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 ic(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 sc(e){return e.command("status","Print the current scope",r=>r.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),r=>Ei({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=>Pi({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=>$i({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=>Ii({ids:r.ids})).demandCommand(1)}function ac(e){return e.command("pause","Disable all Ripplo pre-edit gates and stop enforcement until resumed",()=>{},()=>mt()).command("resume","Re-enable Ripplo hooks paused via `ripplo hooks pause`",()=>{},()=>ft()).demandCommand(1)}function lc(e){return e.command("list","List projects you have access to (JSON)",()=>{},()=>Pt()).command("create <name>","Create a project (JSON)",r=>r.positional("name",{demandOption:!0,type:"string"}).option("org",{describe:"Organization id",type:"string"}),r=>$t({name:r.name,orgId:r.org})).demandCommand(1)}function dc(e){return e.command("login","Authenticate via device flow",()=>{},()=>Zn()).command("status","Show authentication status",()=>{},()=>et()).command("logout","Remove the saved token",()=>{},()=>{rt()}).demandCommand(1)}export{Hu as main};