ripplo 0.10.0 → 0.11.0

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