ripplo 0.9.6 → 0.9.8
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.
- package/dist/{chunk-WCSDBWCI.js → chunk-22JUAYHM.js} +1 -1
- package/dist/{chunk-V4CLXOCP.js → chunk-2GFHB4LD.js} +1 -1
- package/dist/{chunk-A5EBMT2E.js → chunk-3UZZBLVA.js} +1 -1
- package/dist/{chunk-BDWNZMUM.js → chunk-64OQXBRG.js} +1 -1
- package/dist/{chunk-T76D4SYI.js → chunk-7EL64XR6.js} +1 -1
- package/dist/{chunk-5DT43ABQ.js → chunk-7IIRERCW.js} +1 -1
- package/dist/{chunk-FJPJDGSS.js → chunk-7VGCLQGP.js} +1 -1
- package/dist/{chunk-DK4NUWRX.js → chunk-7W237JFM.js} +1 -1
- package/dist/{chunk-TQANCEOL.js → chunk-7YQOAAKF.js} +3 -3
- package/dist/{chunk-TPQIFYHW.js → chunk-AGK6XOX2.js} +1 -1
- package/dist/{chunk-L2ZJK7MP.js → chunk-AWPZTNYU.js} +1 -1
- package/dist/{chunk-HD7WIBP2.js → chunk-CB74TAUC.js} +1 -1
- package/dist/chunk-CTTC4KKQ.js +83 -0
- package/dist/{chunk-GFKK7K6T.js → chunk-GI65FUDI.js} +1 -1
- package/dist/{chunk-NOT5PEHM.js → chunk-GZ3M7PNW.js} +1 -1
- package/dist/{chunk-VCY2CEE2.js → chunk-IDPJESOE.js} +1 -1
- package/dist/{chunk-XJJDHGK4.js → chunk-IKYR3UCU.js} +9 -9
- package/dist/chunk-IPSXNIXC.js +48 -0
- package/dist/{chunk-6SYRXU4Q.js → chunk-N2OBRCPQ.js} +1 -1
- package/dist/{chunk-RIVHBABX.js → chunk-NY6EIQR4.js} +1 -1
- package/dist/{chunk-Z6UPZDW6.js → chunk-OAU4HUD2.js} +1 -1
- package/dist/{chunk-5D6PNHDQ.js → chunk-OES7HGNF.js} +1 -1
- package/dist/{chunk-CY5FJBHP.js → chunk-OQ4TDIP3.js} +1 -1
- package/dist/{chunk-5IMT3SAH.js → chunk-OQS63V7U.js} +2 -2
- package/dist/{chunk-36NPGS6X.js → chunk-R3DZ6JPY.js} +1 -1
- package/dist/{chunk-SXDYA2OR.js → chunk-SNU66GSR.js} +1 -1
- package/dist/{chunk-GKYP7AMJ.js → chunk-TOBC3SQA.js} +1 -1
- package/dist/{chunk-AIIZRQXH.js → chunk-TPHOSZAK.js} +1 -1
- package/dist/{chunk-NOKKMFJP.js → chunk-YQ2RBEOJ.js} +1 -1
- package/dist/{cli-error-OIG4RO4E.js → cli-error-TS4FNZ6F.js} +1 -1
- package/dist/{compile-write-OLP4DB4P.js → compile-write-BLJH647I.js} +1 -1
- package/dist/{daemon-WEKGUIRK.js → daemon-QKBWYQJA.js} +1 -1
- package/dist/daemon-UMZJZ7BY.js +152 -0
- package/dist/{daemon-lock-YRKNXWGO.js → daemon-lock-OAARBZ4O.js} +1 -1
- package/dist/{dsl-loader-IRBKYLNW.js → dsl-loader-NGW4V4A3.js} +1 -1
- package/dist/{exit-plan-gate-X3TX6QWS.js → exit-plan-gate-HSTV7UO4.js} +1 -1
- package/dist/hook.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{plan-reminder-AR3TJXLA.js → plan-reminder-RBCRBCKC.js} +1 -1
- package/dist/post-edit-MVGQGAW4.js +4 -0
- package/dist/post-edit-analyze-XWTZMQCB.js +4 -0
- package/dist/post-edit-flag-stubs-4MQZATJE.js +4 -0
- package/dist/{pre-bash-run-gate-LQK52CAV.js → pre-bash-run-gate-B42YNDQF.js} +1 -1
- package/dist/pre-edit-YF6WNE6G.js +4 -0
- package/dist/{pre-edit-ripplo-skill-gate-XJHLJN2F.js → pre-edit-ripplo-skill-gate-QHUD7QGU.js} +1 -1
- package/dist/{pre-edit-scope-gate-K5NYCES7.js → pre-edit-scope-gate-2YIFSEDY.js} +1 -1
- package/dist/{pre-edit-watch-gate-5YWMODVX.js → pre-edit-watch-gate-SJ3RCYH5.js} +1 -1
- package/dist/{prompt-submit-PXMO75JB.js → prompt-submit-YX7GMTC4.js} +1 -1
- package/dist/scope-reminder-DIDCHDAA.js +4 -0
- package/dist/solve-worker.js +1 -1
- package/dist/status-HPMHJBKH.js +4 -0
- package/dist/{stop-enforce-56SLPUYT.js → stop-enforce-VWOM5EZY.js} +1 -1
- package/dist/{tasks-reminder-OJEB6HE5.js → tasks-reminder-SDS6RNLP.js} +1 -1
- package/package.json +2 -2
- package/dist/chunk-4GA5662U.js +0 -83
- package/dist/chunk-AJXAWZQO.js +0 -48
- package/dist/daemon-ZHTQ472Q.js +0 -152
- package/dist/post-edit-VUBL7RDW.js +0 -4
- package/dist/post-edit-analyze-ECCVJCPQ.js +0 -4
- package/dist/post-edit-flag-stubs-AHP6XA2S.js +0 -4
- package/dist/pre-edit-4MNJA3OT.js +0 -4
- package/dist/scope-reminder-LDBXUQZH.js +0 -4
- package/dist/status-2FS6ZFIU.js +0 -4
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{b as E}from"./chunk-LOEAZGYO.js";import{a as U}from"./chunk-NNH3YVVO.js";import{b as $}from"./chunk-KMZ3L5YA.js";var F=15e3,G=3,L=300,f=class extends Error{detail;serverUrl;constructor({detail:r,serverUrl:t}){super(`Failed to connect to Ripplo server at ${t}. Check the server is running and reachable. Details: ${r}`),this.name="GqlConnectionError",this.detail=r,this.serverUrl=t}},u=class extends Error{errors;constructor(r){super(r.map(t=>t.message).join(", ")),this.name="GqlRequestError",this.errors=r}};function N(e){if(e instanceof u)return e.errors[0]?.extensions?.code}var j={attempts:G,timeoutMs:F},V={attempts:1,timeoutMs:3e3};async function x(e){return T(e,j)}async function W(e){return T(e,V)}async function T(e,r){let{print:t}=await import("graphql"),n=t(e.document),o=JSON.stringify({query:n,variables:e.variables}),a=`${e.config.ripploServerUrl}/graphql`,s=await B({init:{body:o,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json",...E()},method:"POST"},policy:r,serverUrl:e.config.ripploServerUrl,url:a}),l=await J({res:s,url:a});if(!Q(l))throw new Error("Invalid GraphQL response");if(X(l))throw new u(l.errors);if(l.data==null)throw new Error("No data returned from server");return l.data}async function B({init:e,policy:r,serverUrl:t,url:n}){let o=1,a=await b({init:e,timeoutMs:r.timeoutMs,url:n});for(;a.retryable&&o<r.attempts;)await K(H(o)),o+=1,a=await b({init:e,timeoutMs:r.timeoutMs,url:n});let{response:s}=a;if(s!=null&&s.status<500)return s;throw new f({detail:s==null?a.detail:`server returned status ${String(s.status)}`,serverUrl:t})}async function b({init:e,timeoutMs:r,url:t}){try{let n=await fetch(t,{...e,signal:AbortSignal.timeout(r)});return{detail:"",response:n,retryable:n.status>=500}}catch(n){return{detail:n instanceof Error?n.message:String(n),response:void 0,retryable:!0}}}function H(e){return L*3**(e-1)*(.5+Math.random())}function K(e){return new Promise(r=>{setTimeout(r,e)})}async function J({res:e,url:r}){let t=await e.text();if(t.length===0)throw new Error(`Empty response from Ripplo server at ${r} (status ${String(e.status)}). The server may have restarted or the request was rejected before a body was sent.`);try{return JSON.parse(t)}catch{throw new Error(`Non-JSON response from Ripplo server at ${r} (status ${String(e.status)}): ${t.slice(0,200)}`)}}function Q(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function X(e){return Array.isArray(e.errors)&&e.errors.length>0}import Y from"pino";import z from"pino-pretty";var y=Y({level:process.env.LOG_LEVEL??"info"},z({ignore:"pid,hostname"}));import{readdir as Z,rm as ee,stat as re}from"fs/promises";import{existsSync as k}from"fs";import w from"path";var v=".uploaded";var C=w.join(process.cwd(),".ripplo","debug"),D=360*60*1e3;async function te({maxRuns:e}){try{let t=(await Z(C,{withFileTypes:!0})).filter(i=>i.isDirectory()),n=Date.now(),o=await Promise.all(t.map(async i=>{let m=w.join(C,i.name),O=await re(m);return{dirPath:m,mtime:O.mtimeMs,pendingUpload:ne(m)}})),a=o.filter(i=>n-i.mtime>D),s=o.filter(i=>n-i.mtime<=D&&!i.pendingUpload).toSorted((i,m)=>m.mtime-i.mtime).slice(e),l=[...a,...s];if(l.length===0)return;await Promise.allSettled(l.map(i=>ee(i.dirPath,{force:!0,recursive:!0}))),y.debug("Pruned %d old debug run(s)",l.length)}catch{y.warn("Debug run pruning failed, ignoring")}}function ne(e){return k(w.join(e,"behavior.jsonl"))&&!k(w.join(e,v))}import d from"fs";import oe from"os";import g from"path";var ie=".local",ae=".ripplo";function h(e){return g.join(e,".ripplo",ie)}function se(e){let r=h(e);d.existsSync(r)||d.mkdirSync(r,{recursive:!0});let t=g.join(r,".gitignore");return d.existsSync(t)||d.writeFileSync(t,`*
|
|
5
|
+
`),r}function le(e,r){return g.join(h(e),r)}function P(){return g.join(oe.homedir(),ae)}function S(){let e=P();return d.existsSync(e)?d.chmodSync(e,448):d.mkdirSync(e,{mode:448,recursive:!0}),e}function A(e){return g.join(P(),e)}import{Agent as de,RetryAgent as ce,setGlobalDispatcher as me}from"undici";var ue=1500,ge=4e3,pe=3,fe=50,ye=100,I=!1;function we(){if(I)return;I=!0;let e=new de({connections:ye,keepAliveMaxTimeout:ge,keepAliveTimeout:ue}),r=new ce(e,{errorCodes:["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_REQ_CONTENT_LENGTH_MISMATCH","UND_ERR_SOCKET"],maxRetries:pe,methods:["GET","POST","HEAD","OPTIONS","PUT","DELETE"],minTimeout:fe});me(r)}import{graphql as p}from"gql.tada";var We=p(`
|
|
6
|
+
query AgentReviewContextWorker($reviewId: String!) {
|
|
7
|
+
agentReview(id: $reviewId) {
|
|
8
|
+
id
|
|
9
|
+
runId
|
|
10
|
+
agentProfile {
|
|
11
|
+
id
|
|
12
|
+
name
|
|
13
|
+
description
|
|
14
|
+
output
|
|
15
|
+
successCriteria
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`);var Be=p(`
|
|
20
|
+
mutation StartAgentReviewWorker($reviewId: String!) {
|
|
21
|
+
startAgentReview(reviewId: $reviewId)
|
|
22
|
+
}
|
|
23
|
+
`);var He=p(`
|
|
24
|
+
mutation CompleteAgentReviewWorker(
|
|
25
|
+
$reviewId: String!
|
|
26
|
+
$markdown: String!
|
|
27
|
+
$shortSummary: String!
|
|
28
|
+
$verdict: AgentReviewVerdict!
|
|
29
|
+
$comments: [AgentReviewCommentInput!]!
|
|
30
|
+
) {
|
|
31
|
+
completeAgentReview(
|
|
32
|
+
reviewId: $reviewId
|
|
33
|
+
markdown: $markdown
|
|
34
|
+
shortSummary: $shortSummary
|
|
35
|
+
verdict: $verdict
|
|
36
|
+
comments: $comments
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
`);var Ke=p(`
|
|
40
|
+
mutation UpdateAgentReviewProgressWorker($reviewId: String!, $text: String!) {
|
|
41
|
+
updateAgentReviewProgress(reviewId: $reviewId, text: $text)
|
|
42
|
+
}
|
|
43
|
+
`);var Je=p(`
|
|
44
|
+
mutation FailAgentReviewWorker($reviewId: String!, $reason: String!) {
|
|
45
|
+
failAgentReview(reviewId: $reviewId, reason: $reason)
|
|
46
|
+
}
|
|
47
|
+
`);import c from"fs";import _ from"path";function Re(e){let r=process.env.RIPPLO_TOKEN;if(r!=null&&r.trim().length>0)return r.trim();let t=R(e);if(!c.existsSync(t))return null;let n=c.readFileSync(t,"utf8").trim();return n.length===0?null:n}function ve({serverUrl:e,token:r}){S();let t=R(e);c.mkdirSync(_.dirname(t),{mode:448,recursive:!0}),c.writeFileSync(t,r+`
|
|
48
|
+
`,{mode:384})}function he(e){let r=R(e);return c.existsSync(r)?(c.unlinkSync(r),!0):!1}function R(e){return A(_.join("tokens",Pe(e)))}function Pe(e){return new URL(e).host.replaceAll(/[^a-zA-Z0-9.]/g,"_")}var M=$(U(),1);import q from"crypto";function Se({body:e,secret:r}){let t=new M.Webhook(r),n=`msg_${q.randomUUID()}`,o=new Date,a=t.sign(n,o,e),s=Math.floor(o.getTime()/1e3);return{"webhook-id":n,"webhook-signature":a,"webhook-timestamp":String(s)}}function Ae(){return`whsec_${q.randomBytes(24).toString("base64")}`}export{f as a,u as b,N as c,x as d,W as e,y as f,v as g,te as h,se as i,le as j,Re as k,ve as l,he as m,R as n,we as o,Se as p,Ae as q};
|
|
@@ -1,6 +1,6 @@
|
|
|
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 p}from"./chunk-JJ4QQPAV.js";import{b as l}from"./chunk-
|
|
4
|
+
import{a as p}from"./chunk-JJ4QQPAV.js";import{b as l}from"./chunk-TPHOSZAK.js";import{j as c}from"./chunk-IPSXNIXC.js";import{createHash as S}from"crypto";import{mkdirSync as b,readFileSync as v,writeFileSync as A}from"fs";import x from"path";import*as e from"zod/mini";import{createHash as P}from"crypto";import a from"picomatch";function m(t){return l(["diff","--name-only","HEAD"],t).split(`
|
|
5
5
|
`).filter(r=>r.length>0)}function g({cwd:t,ignoreGlobs:r,watchGlobs:n}){let o=a([...n]),i=a([...r]);return m(t).filter(s=>o(s)&&!i(s))}function z(t){return l(["ls-files","--others","--exclude-standard"],t).split(`
|
|
6
6
|
`).filter(r=>r.length>0)}function d({cwd:t,ignoreGlobs:r,watchGlobs:n}){let o=a([...n]),i=a([...r]);return z(t).filter(s=>o(s)&&!i(s))}var F=e.object({label:e.nullable(e.string()),slug:e.nullable(e.string()),status:e.enum(["intent","stub","implemented"])}),C=e.object({intent:e.string(),name:e.string(),sourcePath:e.nullable(e.string()),stub:e.boolean()}),R=e.object({changedAppFiles:e.readonly(e.array(e.string())),scope:e.object({available:e.boolean(),items:e.readonly(e.array(F))}),tests:e._default(e.readonly(e.array(C)),[]),untrackedAppFiles:e.readonly(e.array(e.string()))});function O({cwd:t,scope:r}){let n=h(t);u(t,{...f(t),scope:r,tests:n?.tests??[]})}function T({cwd:t,tests:r}){let n=h(t);u(t,{...f(t),scope:n?.scope??{available:!1,items:[]},tests:r??n?.tests??[]})}function h(t){let r=R.safeParse(k(y(t)));return r.success?r.data:null}function k(t){try{return JSON.parse(v(t,"utf8"))}catch{return null}}function y(t){return c(t,"coverage-context.json")}function u(t,r){let n=y(t);b(x.dirname(n),{recursive:!0});let o=S("sha256").update(JSON.stringify(r)).digest("hex");A(n,JSON.stringify({...r,inputHash:o},null,2))}function f(t){let{ignorePaths:r,watchPaths:n}=p(),o={cwd:t,ignoreGlobs:r,watchGlobs:n};return{changedAppFiles:g(o),untrackedAppFiles:d(o)}}export{O as a,T as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
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,b as y,c as d,d as P,e as x,f as w,j as f,k as l,n as B}from"./chunk-
|
|
4
|
+
import{a,b as y,c as d,d as P,e as x,f as w,j as f,k as l,n as B}from"./chunk-AWPZTNYU.js";import{q as F,s as b,t as H,u as E}from"./chunk-CTTC4KKQ.js";import{J as k,K as i,Q as n,R as h,ca as S,ga as C,ha as g}from"./chunk-IKYR3UCU.js";import{readFile as W,writeFile as z}from"fs/promises";import T from"path";import{err as u,ok as N}from"neverthrow";import s from"fs";import v from"path";import{z as m}from"zod";function O({context:e,cwd:o}){S(e);let r=K(o,L(e));r!=null&&C(e,r)}function ie({context:e,cwd:o}){let r=D(o);if(!(r==null||r.model!==L(e)))return r.cleanLockfile??void 0}function le({cleanLockfileHash:e,context:o,cwd:r}){let t=R(r);s.mkdirSync(v.dirname(t),{recursive:!0}),s.writeFileSync(t,JSON.stringify({bundle:a(),cleanLockfile:e,model:L(o)}))}function se(e){return f(e)}var I=m.object({bundle:m.string().nullable(),cleanLockfile:m.string().nullable(),model:m.string()});function K(e,o){let r=v.join(e,l),t=_(r);return t==null||!d(t)?null:f(x(t))===o?t.solved:null}function _(e){try{return i(n,s.readFileSync(e,"utf8"))}catch{return null}}function L(e){return f(w(e))}function D(e){let o=R(e);if(s.existsSync(o))try{let r=I.safeParse(JSON.parse(s.readFileSync(o,"utf8")));return!r.success||!P(r.data.bundle)?void 0:r.data}catch{return}}function R(e){return v.join(e,".ripplo",".local","solve-cache.json")}async function Le(e){let o=await B(e);return o.isOk()&&await q(e,o.value),o}async function q(e,o){let r=await G(e,o);return await z(T.join(e,l),k(n,r)),r}var M=new WeakMap;function G(e,o){let r=M.get(o);if(r!=null)return r;let t=A(e,o).then(c=>c.match(p=>Promise.resolve(p),()=>Q(e,o)));return M.set(o,t),t}function Se(e,o){return A(e,o)}function Ce(e){return e.workflows.filter(o=>o.stub).map(o=>o.name)}async function ge(e,o){let r=await j(e);return r==null?"missing":r.checks==null?"stale":y(r,o)?"match":"stale"}async function A(e,o){let r=await j(e);return r==null?u({kind:"no-lockfile"}):r.checks==null?u({kind:"unstamped"}):d(r)?y(r,o)?N(h(r)):u({kind:"dsl-drift"}):u({kind:"expander-newer"})}async function j(e){try{let o=await W(T.join(e,l),"utf8");return i(n,o)}catch{return null}}async function Q(e,o){let r=F(o);O({context:r,cwd:e});let t=await H(o),c=await b(o);await E({context:r,facts:c.facts});let p=await g(r),V=a(),J={...o,checks:{...t,expanderHash:V??void 0},solved:p};return h(i(n,k(n,J)))}export{O as a,ie as b,le as c,se as d,Le as e,q as f,G as g,Se as h,Ce as i,ge as j};
|
|
@@ -1,7 +1,7 @@
|
|
|
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 d,b as f,c as g}from"./chunk-
|
|
4
|
+
import{a as d,b as f,c as g}from"./chunk-CB74TAUC.js";import{a as w}from"./chunk-N2OBRCPQ.js";import{c as u}from"./chunk-7W237JFM.js";import{a as c}from"./chunk-7WZ3VIUU.js";import{f as m}from"./chunk-TPHOSZAK.js";import{a as i}from"./chunk-MHNGR6M7.js";import{e as a}from"./chunk-IPSXNIXC.js";import{graphql as h}from"gql.tada";var S=h(`
|
|
5
5
|
query ScopeReminder($projectId: String!, $cwd: String!) {
|
|
6
6
|
project(id: $projectId) {
|
|
7
7
|
id
|
|
@@ -1,4 +1,4 @@
|
|
|
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 S,d as u,e as y,f as E,h as w,i as C,k as b,l as g,m as R,n as h,o as v,p as m,q as M,r as N}from"./chunk-
|
|
4
|
+
import{a as S,d as u,e as y,f as E,h as w,i as C,k as b,l as g,m as R,n as h,o as v,p as m,q as M,r as N}from"./chunk-22JUAYHM.js";import{a as P}from"./chunk-R4ZTRVDQ.js";import{i as D}from"./chunk-IPSXNIXC.js";import{spawn as L}from"child_process";import q from"fs";import V from"net";import{setTimeout as p}from"timers/promises";import{err as d,ok as f}from"neverthrow";import{ResponseError as j}from"vscode-jsonrpc/node";var I=12e4,_=300,x=5e3;async function an({cliEntry:o,cwd:n}){let e=u(n),t=await s(e);return t!=null?A({cliEntry:o,connection:l(t,!1),cwd:n}):T({cliEntry:o,cwd:n,versionNote:void 0})}async function sn({cliEntry:o,cwd:n}){let e=await s(u(n));return e==null?d({kind:"not-running"}):A({cliEntry:o,connection:l(e,!1),cwd:n})}async function T({cliEntry:o,cwd:n,versionNote:e}){let t=H({cliEntry:o,cwd:n});if(t!=null)return d(t);let r=await Q(u(n));return r==null?d({deadlineMs:I,kind:"connect-timeout",logPath:y(n)}):f({...l(r,!0),versionNote:e})}async function A({cliEntry:o,connection:n,cwd:e}){let t=await O(n);if(t==null||t.version===P()&&!G(t))return f(n);let r={daemonVersion:t.version};return await J(n)?(n.socket.destroy(),await B(u(e))?T({cliEntry:o,cwd:e,versionNote:{...r,kind:"restarted"}}):d({kind:"connection-lost"})):f({...n,versionNote:{...r,kind:"stale-busy"}})}var U=1e3;function G(o){let n=S(process.argv[1]);return n==null||o.bundleMtimeMs==null?!1:n>o.bundleMtimeMs+U}async function J(o){try{return await o.rpc.sendRequest(m)}catch{return!1}}var K=1e4;async function B(o){let n=Date.now()+K,e=await s(o);for(;e!=null&&Date.now()<n;)e.destroy(),await p(_),e=await s(o);return e?.destroy(),e==null}async function cn({connection:o,onEvent:n,request:e,token:t}){let r=await F({connection:o,onEvent:n,request:e,token:t});return r.kind==="transport"?d(r.error):f(r)}async function un(o){let n=await s(u(o));if(n==null)return!1;let e=l(n,!1);try{return await e.rpc.sendRequest(m)}catch{return!1}finally{n.destroy()}}async function dn(o){try{await o.rpc.sendRequest(m)}catch{}}async function ln(o){let n=await s(u(o));if(n==null)return{kind:"not-running"};let e=l(n,!1),t=await Promise.race([O(e),p(x).then(()=>null)]);return n.destroy(),t==null?{kind:"unresponsive",timeoutMs:x}:{kind:"running",status:t}}async function O(o){try{let n=await o.rpc.sendRequest(v),e=C.safeParse(n);return e.success?e.data:null}catch{return null}}function F({connection:o,onEvent:n,request:e,token:t}){let{rpc:r}=o;return new Promise(k=>{let i=a=>{k(a)};r.onNotification(M,a=>{let c=b.safeParse(a);if(!c.success){i({error:{kind:"bad-frame"},kind:"transport"});return}n(c.data.event)}),r.onNotification(N,a=>{let c=g.safeParse(a);if(!c.success){i({error:{kind:"bad-frame"},kind:"transport"});return}i({failed:c.data.failed,kind:"done",notRun:c.data.notRun,passed:c.data.passed})}),r.onClose(()=>{i({error:{kind:"connection-lost"},kind:"transport"})}),r.sendRequest(h,e,t).then(a=>{w.safeParse(a).success||i({error:{kind:"bad-frame"},kind:"transport"})}).catch(a=>{i(z(a))})})}function z(o){if(o instanceof j){let n=R.safeParse(o.data);return n.success?{error:n.data,kind:"daemon-error"}:{error:{kind:"bad-frame"},kind:"transport"}}return{error:{kind:"connection-lost"},kind:"transport"}}function l(o,n){let e=E(o);return e.listen(),{rpc:e,socket:o,spawned:n,versionNote:void 0}}function s(o){return new Promise(n=>{let e=V.connect(o);e.once("connect",()=>{n(e)}),e.once("error",()=>{n(null)})})}function H({cliEntry:o,cwd:n}){try{D(n);let e=q.openSync(y(n),"a");return L(process.execPath,[o,"daemon"],{cwd:n,detached:!0,stdio:["ignore",e,e]}).unref(),q.closeSync(e),null}catch(e){return{kind:"spawn-failed",message:e instanceof Error?e.message:String(e)}}}async function Q(o){let n=Date.now()+I,e=await s(o);for(;e==null&&Date.now()<n;)await p(_),e=await s(o);return e}export{an as a,sn as b,cn as c,un as d,dn as e,ln as f};
|
|
@@ -1,7 +1,7 @@
|
|
|
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{c as P}from"./chunk-
|
|
4
|
+
import{c as P}from"./chunk-7W237JFM.js";import{a as I,f as v}from"./chunk-TPHOSZAK.js";import{g as h,k as w,n as k}from"./chunk-AWPZTNYU.js";import{d as a,f}from"./chunk-IPSXNIXC.js";import{U as S,W as m}from"./chunk-IKYR3UCU.js";import y from"fs";import p from"path";function D(e){try{let n=A(e);if(n==null)return;let t=p.join(n,"HEAD"),o=y.readFileSync(t,"utf8").trim(),r="ref: refs/heads/";return o.startsWith(r)?o.slice(r.length):o.length===0?void 0:o.slice(0,7)}catch{return}}function A(e){let n=p.join(e,".git");if(y.statSync(n).isDirectory())return n;let o=y.readFileSync(n,"utf8").trim(),r="gitdir:";if(!o.startsWith(r))return;let s=o.slice(r.length).trim();if(s.length!==0)return p.resolve(e,s)}import E from"crypto";import{readFile as R}from"fs/promises";import x from"path";import{graphql as g}from"gql.tada";import{err as L,ok as T}from"neverthrow";var C=g(`
|
|
5
5
|
mutation SyncDevSession(
|
|
6
6
|
$projectId: String!
|
|
7
7
|
$cwd: String!
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
4
|
import{a as p,c as t}from"./chunk-KOKEEAEF.js";import{c as s}from"./chunk-LOEAZGYO.js";function l(){let o=process.cwd(),e=s(o);e!=null&&e!==o&&(process.chdir(e),process.stderr.write(`ripplo: resolved .ripplo/ at ${e}
|
|
5
|
-
`))}var d={"exit-plan-gate":()=>import("./exit-plan-gate-
|
|
6
|
-
`),process.exit(1));let i=await m(),r=await p(await e(),i);if(r.kind==="crash"){let{renderHookCrash:a}=await import("./cli-error-
|
|
5
|
+
`))}var d={"exit-plan-gate":()=>import("./exit-plan-gate-HSTV7UO4.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-RBCRBCKC.js").then(o=>t("UserPromptSubmit",o.planReminder)),"post-edit":()=>import("./post-edit-MVGQGAW4.js").then(o=>o.postEditHook),"post-edit-analyze":()=>import("./post-edit-analyze-XWTZMQCB.js").then(o=>t("PostToolUse",o.postEditAnalyze)),"post-edit-flag-stubs":()=>import("./post-edit-flag-stubs-4MQZATJE.js").then(o=>t("PostToolUse",o.postEditFlagStubs)),"pre-bash-run-gate":()=>import("./pre-bash-run-gate-B42YNDQF.js").then(o=>o.preBashRunGateHook),"pre-edit":()=>import("./pre-edit-YF6WNE6G.js").then(o=>o.preEditHook),"pre-edit-ripplo-skill-gate":()=>import("./pre-edit-ripplo-skill-gate-QHUD7QGU.js").then(o=>t("PreToolUse",o.preEditRipploSkillGate)),"pre-edit-scope-gate":()=>import("./pre-edit-scope-gate-2YIFSEDY.js").then(o=>t("PreToolUse",o.preEditScopeGate)),"pre-edit-watch-gate":()=>import("./pre-edit-watch-gate-SJ3RCYH5.js").then(o=>t("PreToolUse",o.preEditWatchGate)),"prompt-submit":()=>import("./prompt-submit-YX7GMTC4.js").then(o=>o.promptSubmitHook),"scope-reminder":()=>import("./scope-reminder-DIDCHDAA.js").then(o=>t("UserPromptSubmit",o.scopeReminder)),"session-preamble":()=>import("./session-preamble-ZYVRDSGA.js").then(o=>o.sessionPreambleHook),"stop-enforce":()=>import("./stop-enforce-VWOM5EZY.js").then(o=>o.stopEnforceHook),"tasks-reminder":()=>import("./tasks-reminder-SDS6RNLP.js").then(o=>t("UserPromptSubmit",o.tasksReminder)),"tasks-reminder-tool":()=>Promise.resolve(t("PostToolUse",()=>{})),"track-skill-load":()=>import("./track-skill-load-CJ74GD3Q.js").then(o=>o.trackSkillLoadHook),"track-skill-prompt":()=>import("./track-skill-prompt-YSB6OOQN.js").then(o=>t("UserPromptSubmit",o.trackSkillPrompt))},n=d;async function P(o){let e=n[o];e==null&&(process.stderr.write(`Unknown hook: ${o}
|
|
6
|
+
`),process.exit(1));let i=await m(),r=await p(await e(),i);if(r.kind==="crash"){let{renderHookCrash:a}=await import("./cli-error-TS4FNZ6F.js");process.stderr.write(`${a(o,r.error)}
|
|
7
7
|
`),process.exit(0)}r.stdout!=null&&process.stdout.write(r.stdout),process.exit(0)}function m(){return new Promise((o,e)=>{if(process.stdin.isTTY){o("");return}let i=[];process.stdin.on("data",r=>i.push(r)),process.stdin.on("end",()=>{o(Buffer.concat(i).toString("utf8"))}),process.stdin.on("error",e)})}export{l as a,n as b,P as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{i as s,j as a}from"./chunk-
|
|
4
|
+
import{i as s,j as a}from"./chunk-IPSXNIXC.js";import d from"fs";import{setTimeout as p}from"timers/promises";import{checkSync as m,lockSync as f}from"proper-lockfile";var y="dev.pid",l=15e3,h=1e4,k=250;function g(n){return u(i(n))}async function b(n){let r=g(n);if(r==null||!c(n))return{kind:"not-running"};try{process.kill(r,"SIGTERM")}catch{return{kind:"not-running"}}let e=Date.now()+h;for(;Date.now()<e;){if(!c(n))return{kind:"stopped",pid:r};await p(k)}return{kind:"timeout",pid:r}}function c(n){try{return m(i(n),{realpath:!1,stale:l})}catch{return!1}}function i(n){return a(n,y)}var o=class extends Error{pid;cwd;constructor({cwd:r,pid:e}){super("dev-lock-held"),this.name="DevLockHeldError",this.pid=e,this.cwd=r}};function E({cwd:n,onCompromised:r}){s(n);let e=i(n),t=w({cwd:n,onCompromised:r,path:e});return d.writeFileSync(e,String(process.pid)),()=>{try{t()}catch{}}}function w({cwd:n,onCompromised:r,path:e}){try{return f(e,{realpath:!1,stale:l,onCompromised:()=>{r()}})}catch(t){throw D(t)?new o({cwd:n,pid:u(e)}):t}}function D(n){if(!(n instanceof Error)||!("code"in n))return!1;let{code:r}=n;return r==="ELOCKED"}function u(n){try{let r=d.readFileSync(n,"utf8").trim(),e=Number.parseInt(r,10);return Number.isFinite(e)&&e>0?e:null}catch{return null}}export{g as a,b,c,i as d,o as e,E as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{b as a}from"./chunk-OWN4P2K7.js";import{a as s}from"./chunk-7WZ3VIUU.js";import{f as l}from"./chunk-
|
|
4
|
+
import{b as a}from"./chunk-OWN4P2K7.js";import{a as s}from"./chunk-7WZ3VIUU.js";import{f as l}from"./chunk-TPHOSZAK.js";import p from"path";import*as t from"zod/mini";var n=new Set(["Edit","Write","NotebookEdit"]),d=t.looseObject({file_path:t.string()}),c="create",k=e=>{if(!n.has(e.tool_name))return;let i=d.safeParse(e.tool_input);if(!i.success)return;let{cwd:o}=e;if(!s(o)||!l(o))return;let r=p.relative(o,i.data.file_path);if(!(r.startsWith("..")||r!==".ripplo"&&!r.startsWith(".ripplo/"))&&!a(o,e.session_id,c))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Editing \`.ripplo/\` files (${r}) requires the \`/ripplo:create\` skill loaded first. Load \`/ripplo:create\` then retry \u2014 it carries the DSL builder shape, model rules, and the parallelization guidance you'll need.`}}};export{k as a};
|
|
@@ -1,7 +1,7 @@
|
|
|
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{b as w,c as P}from"./chunk-
|
|
4
|
+
import{b as w,c as P}from"./chunk-CB74TAUC.js";import{a as m}from"./chunk-MOI4L3EX.js";import{a as u,c as y,d as g}from"./chunk-7VGCLQGP.js";import{a as h}from"./chunk-OQ6KNYPG.js";import{f as S}from"./chunk-OQ4TDIP3.js";import{a as c}from"./chunk-7WZ3VIUU.js";import{f as k}from"./chunk-TPHOSZAK.js";import{a as l}from"./chunk-7IIRERCW.js";import{a as s}from"./chunk-MHNGR6M7.js";import{e as f,f as p}from"./chunk-NY6EIQR4.js";import{b as d}from"./chunk-CTTC4KKQ.js";import{createHash as b}from"crypto";import*as a from"zod/mini";var v=a.looseObject({file_path:a.string()}),J=async e=>{let o=v.safeParse(e.tool_input);if(!o.success||!/\/\.ripplo\/.*\.ts$/.test(o.data.file_path))return;let{cwd:t}=e;if(!c(t))return;if(!k(t))return{hookSpecificOutput:{additionalContext:"Ripplo hooks are paused \u2014 DSL compile and lockfile sync did not run for this edit. Resume with `npx ripplo hooks resume` when ready.",hookEventName:"PostToolUse"}};let r=await f(t);if(r.isErr())return{decision:"block",reason:`${l(r.error)}
|
|
5
5
|
${s("create","DSL authoring rules")}`};let n=await F({cwd:t,filePath:o.data.file_path,lockfile:r.value});if("block"in n)return{decision:"block",reason:n.block};let{addedSlugs:i}=await S({cwd:t,editedPath:o.data.file_path,lockfile:r.value,requireHooks:!0,syncFirst:!0});return L(z({addedSlugs:i,cwd:t,elsewhere:n.elsewhere,lockfile:r.value}))};function z({addedSlugs:e,cwd:o,elsewhere:t,lockfile:r}){return[...e.length>0?[`Auto-scoped ${e.join(", ")} (dirty tests).`]:[],...t>0?[A(t).trimStart()]:[],...H(o,r)]}async function F({cwd:e,filePath:o,lockfile:t}){let r=await u({cwd:e,lockfile:t});await p(e,t);let n=N(r,t,o),i=r.length-n.length;return n.length===0?{elsewhere:i}:{block:`${y(n)}${A(i)}
|
|
6
6
|
${s("create")}`}}function N(e,o,t){let r=new Set(d(o).filter(({workflow:n})=>n.sourcePath!=null&&t.endsWith(n.sourcePath)).map(({ref:n})=>n));return r.size===0?e:e.filter(n=>{let i=R(n);return i==null||r.has(i)})}function R(e){return e.kind==="unreachable-interaction"?e.violation.test:e.kind==="redundant-assertion"?e.redundancy.test:e.kind==="missing-precondition"?e.missing.test:null}function A(e){return e===0?"":`
|
|
7
7
|
${h(e,"finding")} in other files \u2014 \`npx ripplo compile\` for the full list.`}function L(e){if(e.length!==0)return{hookSpecificOutput:{additionalContext:e.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
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{c as o}from"./chunk-
|
|
4
|
+
import{c as o}from"./chunk-R3DZ6JPY.js";import{j as e}from"./chunk-IPSXNIXC.js";import m from"fs";import p from"fs";import i from"path";import{execFileSync as a}from"child_process";var f=256*1024*1024;function n(r,t){return a("git",[...r],{cwd:t,encoding:"utf8",maxBuffer:f,stdio:["ignore","pipe","pipe"]})}function E(r,t){try{return n(r,t)}catch{return""}}var g=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function d(r){return u(r)!=null}function s(r){let t=u(r);return t==null?!1:g.some(l=>p.existsSync(i.join(t,l)))}function u(r){try{let t=n(["rev-parse","--git-dir"],r).trim();return t.length===0?null:i.isAbsolute(t)?t:i.resolve(r,t)}catch{return null}}function c(r){return e(r,"hooks-paused")}function v(r){return m.existsSync(c(r))||s(r)?!1:o(r)}export{n as a,E as b,d as c,s as d,c as e,v as f};
|
|
@@ -1,7 +1,7 @@
|
|
|
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 l}from"./chunk-JJ4QQPAV.js";import{c}from"./chunk-
|
|
4
|
+
import{a as l}from"./chunk-JJ4QQPAV.js";import{c}from"./chunk-7W237JFM.js";import{a as p}from"./chunk-7WZ3VIUU.js";import{f as d}from"./chunk-TPHOSZAK.js";import{b as a}from"./chunk-MHNGR6M7.js";import{e as s}from"./chunk-IPSXNIXC.js";import f from"path";import u from"picomatch";import{graphql as m}from"gql.tada";import*as n from"zod/mini";var h=new Set(["Edit","Write","NotebookEdit"]),g=n.looseObject({file_path:n.string()}),S=m(`
|
|
5
5
|
query PreEditScopeGate($projectId: String!, $cwd: String!) {
|
|
6
6
|
project(id: $projectId) {
|
|
7
7
|
id
|
|
@@ -1,4 +1,4 @@
|
|
|
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,b,c}from"./chunk-
|
|
4
|
+
import{a,b,c}from"./chunk-2GFHB4LD.js";import"./chunk-7IIRERCW.js";import"./chunk-MHNGR6M7.js";import"./chunk-AWPZTNYU.js";import"./chunk-IKYR3UCU.js";import"./chunk-KMZ3L5YA.js";export{b as renderCliFailure,c as renderHookCrash,a as renderTopLevelError};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{e as a,f as b,g as c,h as d,i as e,j as f}from"./chunk-
|
|
4
|
+
import{e as a,f as b,g as c,h as d,i as e,j as f}from"./chunk-NY6EIQR4.js";import"./chunk-AWPZTNYU.js";import"./chunk-CTTC4KKQ.js";import"./chunk-IKYR3UCU.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as compileAndWrite,f as lockfileModelStatus,c as stampedLockfile,d as stampedLockfileFromDisk,e as stubbedWorkflows,b as writeStampedLockfile};
|
|
@@ -1,4 +1,4 @@
|
|
|
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,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-GI65FUDI.js";import"./chunk-CTTC4KKQ.js";import"./chunk-IKYR3UCU.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{b as renderDaemonBindError,h as renderDaemonLockCompromised,f as renderDaemonLockHeld,e as renderDaemonReady,i as renderDaemonStatus,g as renderDaemonStopResult,k as renderDaemonVersionNote,j as renderExplorationProgress,d as renderNotSignedIn,c as renderProjectAccessDenied,a as renderTunnelProvisionFailed,l as wireOutcome};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{A,C as Xe,D as Ye,E as Ze,G as er,H as N,I as B,J as rr,K as nr,L as K,M as tr,e as Pe,i as Ue,j as We,k as $e,l as Me,m as _e,n as Oe,o as Fe,p as je,r as C,s as L,t as Ne,u as j,v as ze,w as Je,x as Ge,z as Ve}from"./chunk-7YQOAAKF.js";import{d as Te}from"./chunk-22JUAYHM.js";import{a as Be,c as Ke,d as Qe,e as h}from"./chunk-OQ4TDIP3.js";import{c as S}from"./chunk-7W237JFM.js";import{e as Ie}from"./chunk-TPHOSZAK.js";import{a as ue}from"./chunk-R4ZTRVDQ.js";import{c as se}from"./chunk-FEHVIHVA.js";import{b as me}from"./chunk-2GFHB4LD.js";import{a as P}from"./chunk-7IIRERCW.js";import"./chunk-MHNGR6M7.js";import{g as Re,h as T}from"./chunk-NY6EIQR4.js";import{a as pe,l as k,m as fe,n as E}from"./chunk-AWPZTNYU.js";import{e as be,f as Ee}from"./chunk-R3DZ6JPY.js";import{a as te,c as oe,d as u,f as s,g as ie,h as F,i as ae}from"./chunk-IPSXNIXC.js";import"./chunk-LOEAZGYO.js";import{b as Ce,c as Le,d as Ae,e as De,f as qe,h as He}from"./chunk-GI65FUDI.js";import{F as ge,I,J as Se,K as ke,M as he,N as we,Q as ve,X as xe,a as ye}from"./chunk-CTTC4KKQ.js";import{J as le,Q as de,W as ce}from"./chunk-IKYR3UCU.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import to from"path";import{createClient as oo}from"graphql-sse";import{graphql as ee}from"gql.tada";import An,{AbortError as Dn}from"p-retry";import{graphql as fn}from"gql.tada";import{print as mn}from"graphql";async function or({config:e,cwd:r,headed:n,pool:t,runId:o,signal:i,testSlug:a,workClass:l,workflowSlug:d}){let c=await k(r);if(c.isErr())return await A({config:e,ownerToken:null,reason:`lockfile:${c.error.kind}`,runId:o}),{kind:"dispatch-error",reason:{detail:`lockfile:${c.error.kind}`,type:"generic"}};let p=pn(c.value,{testSlug:a,workflowSlug:d});if(p==null)return await A({config:e,ownerToken:null,reason:`no-test:${d}/${a}`,runId:o}),{kind:"dispatch-error",reason:{detail:`no-test:${d}/${a}`,type:"generic"}};let f=await C({headed:n,workClass:l,task:()=>t.execute({headed:n,runId:o,testRef:p},i)});return!f.serverNotified&&f.outcome.kind==="error"&&await A({config:e,ownerToken:null,reason:f.outcome.detail,runId:o}),f.outcome}function pn(e,{testSlug:r,workflowSlug:n}){let o=e.workflows.find(i=>ce(i.name)===n)?.tests.find(i=>i.slug===r);return o==null?void 0:ye(o)}var yn=6e4,gn=fn(`
|
|
5
|
+
subscription RunRequestedWatch($devSessionId: String!) {
|
|
6
|
+
runRequested(devSessionId: $devSessionId) {
|
|
7
|
+
runId
|
|
8
|
+
testSlug
|
|
9
|
+
workflowId
|
|
10
|
+
workflowSlug
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`);async function ir(e){let r=Math.min(1e3*2**e,yn)+wn();await new Promise(n=>setTimeout(n,r))}function ar({claim:e,cwd:r,devSessionId:n,onSubscriptionDead:t,pool:o,sseClient:i,sseHealth:a}){let l=new Set,d=Sn(r);return i.subscribe({query:mn(gn),variables:{devSessionId:n}},{complete:()=>{s.warn("runRequested SSE completed unexpectedly; re-registering session"),t("stream completed")},error:c=>{let p=c instanceof Error?c.message:String(c);s.warn("runRequested SSE failed: %s; re-registering session",p),t(p)},next:c=>{kn({claim:e,dispatchConfig:d,event:c.data?.runRequested,inFlightRunIds:l,pool:o})}},{connected:()=>{a.onConnected()},connecting:c=>{a.onConnecting(c),c&&s.debug("runRequested SSE reconnecting")}})}function Sn(e){return se(e),{config:S(e).match(r=>r,r=>{s.error({failure:r},"failed to load env for run dispatch")}),cwd:e}}function kn({claim:e,dispatchConfig:r,event:n,inFlightRunIds:t,pool:o}){if(n==null)return;if(t.has(n.runId)){s.warn({runId:n.runId,workflowSlug:n.workflowSlug},"duplicate runRequested event; skipping dispatch");return}if(r.config==null){s.error({runId:n.runId},"run dispatch skipped, env failed to load at startup");return}t.add(n.runId),process.stdout.write(`ripplo: run ${n.workflowSlug}
|
|
14
|
+
`);let i=hn(e(n.runId),n);i.started(),or({config:r.config,cwd:r.cwd,headed:i.headed,pool:o,runId:n.runId,signal:i.signal,testSlug:n.testSlug,workClass:i.workClass,workflowSlug:n.workflowSlug}).then(a=>{i.finished(a)}).catch(a=>{s.error({err:a,runId:n.runId,workflowSlug:n.workflowSlug},"run execution failed; daemon continuing"),i.finished({detail:a instanceof Error?a.message:String(a),kind:"error"})}).finally(()=>{t.delete(n.runId)})}function hn(e,r){return e==null?(s.debug({runId:r.runId,workflowSlug:r.workflowSlug},"dispatching unclaimed run (externally triggered or replayed)"),{headed:!1,signal:new AbortController().signal,workClass:"p0-ui",finished:()=>{},started:()=>{}}):{headed:e.headed,signal:Je(e.token),workClass:"p1-cli",finished:n=>{e.finished(r.runId,n)},started:()=>{e.started(r.runId)}}}function wn(){return Math.floor(Math.random()*2700)+300}import{graphql as Q}from"gql.tada";import{print as vn}from"graphql";var xn=Q(`
|
|
15
|
+
subscription TeleportRequestedWatch($devSessionId: String!) {
|
|
16
|
+
teleportRequested(devSessionId: $devSessionId) {
|
|
17
|
+
runId
|
|
18
|
+
stepIndex
|
|
19
|
+
kind
|
|
20
|
+
testSlug
|
|
21
|
+
workflowSlug
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`),Rn=Q(`
|
|
25
|
+
query TeleportRunRepro($id: String!) {
|
|
26
|
+
run(id: $id) {
|
|
27
|
+
id
|
|
28
|
+
reproJson
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`),bn=Q(`
|
|
32
|
+
mutation ReportTeleportResult($devSessionId: String!, $runId: String!, $status: String!) {
|
|
33
|
+
reportTeleportResult(devSessionId: $devSessionId, runId: $runId, status: $status)
|
|
34
|
+
}
|
|
35
|
+
`);function sr({cwd:e,devSessionId:r,onSubscriptionDead:n,sseClient:t}){let o=new Set,i=t.subscribe({query:vn(xn),variables:{devSessionId:r}},{complete:()=>{s.warn("teleportRequested SSE completed unexpectedly; re-registering session"),n("stream completed")},error:a=>{let l=a instanceof Error?a.message:String(a);s.warn("teleportRequested SSE failed: %s; re-registering session",l),n(l)},next:a=>{En({cwd:e,devSessionId:r,event:a.data?.teleportRequested,running:o})}});return()=>{o.forEach(a=>{a.abort()}),o.clear(),i()}}function En({cwd:e,devSessionId:r,event:n,running:t}){if(n==null)return;let o=new AbortController;t.add(o),Pn({cwd:e,devSessionId:r,event:n,signal:o.signal}).catch(i=>{s.error({err:i},"teleport failed; daemon continuing")}).finally(()=>{t.delete(o)})}async function Pn({cwd:e,devSessionId:r,event:n,signal:t}){let o=d=>In({cwd:e,devSessionId:r,runId:n.runId,status:d}),i=await Tn(e,n);if(i==null){s.warn({runId:n.runId},"teleport could not resolve target"),await o("unplannable");return}process.stdout.write(`ripplo: teleport ${Ln(n)} step ${String(n.stepIndex+1)}
|
|
36
|
+
`);let l=await er({cwd:e,onReady:()=>{o("opened")},signal:t,step:n.stepIndex+1,target:i});l.kind==="done"&&l.result.kind==="handed-over"||(s.warn({kind:l.kind,runId:n.runId},"teleport could not open"),await o(l.kind==="unplannable"?"unplannable":"error"))}async function In({cwd:e,devSessionId:r,runId:n,status:t}){let o=S(e).match(i=>i,()=>null);o!=null&&await u({config:o,document:bn,variables:{devSessionId:r,runId:n,status:t}}).catch(()=>null)}async function Tn(e,r){if(r.kind==="explore"){let n=await Cn(e,r.runId);return n==null?null:{kind:"explore",repro:n}}return r.testSlug==null||r.workflowSlug==null?null:{kind:"test",ref:`${r.workflowSlug}/${r.testSlug}`}}async function Cn(e,r){let n=S(e).match(o=>o,()=>null);if(n==null)return null;let t=await u({config:n,document:Rn,variables:{id:r}}).catch(()=>null);return t?.run?.reproJson==null?null:I.parse(JSON.parse(t.run.reproJson))}function Ln(e){return e.kind==="explore"?"explore finding":`${String(e.workflowSlug)}/${String(e.testSlug)}`}function lr({claim:e,config:r,cwd:n,initialId:t,pool:o,sseClient:i,sseHealth:a}){let l=t,d=null,c=m=>{y(m)},p=()=>{let m=ar({claim:e,cwd:n,devSessionId:l,onSubscriptionDead:c,pool:o,sseClient:i,sseHealth:a}),g=sr({cwd:n,devSessionId:l,onSubscriptionDead:c,sseClient:i});return()=>{m(),g()}},f=p(),M=async m=>{a.markUnhealthy(m);let g=await E(n);if(g.isErr()){s.error("re-register: compile failed: %s",P(g.error));return}let _=await z(()=>Ke({config:r,cwd:n,lockfile:g.value}),{config:r,label:"re-register sync"});f(),l=_.devSessionId,f=p(),s.info("re-registered dev session as %s",l)},y=m=>(d!=null||(d=M(m).finally(()=>{d=null})),d);return{getId:()=>l,reregister:()=>y("dev session ended server-side"),stop:()=>{f()}}}function z(e,{config:r,label:n}){let t=r.ripploServerUrl.includes("localhost")||r.ripploServerUrl.includes("127.0.0.1");return An(async()=>{try{return await e()}catch(o){if(qn({config:r,error:o}),!(o instanceof te)){let i=o instanceof Error?o.message:String(o);throw s.error("%s failed: %s",n,i),new Dn(i)}throw o}},{factor:2,maxTimeout:t?2e3:1e4,minTimeout:t?100:1e3,retries:1/0,onFailedAttempt:({attemptNumber:o,error:i})=>{s.warn("%s attempt %d failed \u2014 retrying: %s",n,o,i.message)}})}function qn({config:e,error:r}){let n=oe(r);n==="UNAUTHENTICATED"&&(process.stderr.write(`ripplo: ${Ae()}
|
|
37
|
+
`),process.exit(1)),n==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${Le({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
|
|
38
|
+
`),process.exit(1))}import{graphql as dr}from"gql.tada";var Hn=dr(`
|
|
39
|
+
query OpenFindingsForRetire($projectId: String!) {
|
|
40
|
+
exploreFindings(projectId: $projectId, status: open) {
|
|
41
|
+
signature
|
|
42
|
+
reproRun {
|
|
43
|
+
reproJson
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`),Un=dr(`
|
|
48
|
+
mutation RetireStaleFinding($projectId: String!, $signature: String!) {
|
|
49
|
+
retireStaleFinding(projectId: $projectId, signature: $signature)
|
|
50
|
+
}
|
|
51
|
+
`);async function cr({config:e,cwd:r,lockfile:n}){let o=(await u({config:e,document:Hn,variables:{projectId:e.projectId}})).exploreFindings,i=await T(r,n);if(i.isErr())return s.info({block:i.error.kind},"skipping finding retire until next compile"),!1;let a=await Wn(o,i.value);return a.length===0||(await Promise.all(a.map(l=>Mn(e,l))),s.info({count:a.length},"retired findings whose trail no longer replays")),!0}async function Wn(e,r){return(await Promise.all(e.map(async t=>await $n(t,r)?t.signature:null))).filter(t=>t!=null)}async function $n(e,r){let n=e.reproRun?.reproJson;if(n==null)return!1;let t=I.safeParse(JSON.parse(n));return t.success?(await xe(r,t.data)).kind==="unplannable":!1}function Mn(e,r){return u({config:e,document:Un,variables:{projectId:e.projectId,signature:r}})}var _n=6e4;function ur(e){let r={retiredKey:null,running:!1,stopped:!1},n=async()=>{if(!(r.running||r.stopped)){r.running=!0;try{r.retiredKey=await On(e,r.retiredKey)}catch(o){s.warn({err:o},"retire stale findings failed \u2014 retrying on next tick")}finally{r.running=!1}}},t={timer:setTimeout(function o(){n(),r.stopped||(t.timer=setTimeout(o,_n))},0)};return()=>{r.stopped=!0,clearTimeout(t.timer)}}async function On({config:e,cwd:r},n){let t=await h(r),o=pe();if(t==null||o==null)return n;let i=`${t}@${o}`;if(i===n)return n;let a=await k(r);return a.isErr()?n:await cr({config:e,cwd:r,lockfile:a.value})?i:n}import{Agent as Fn,fetch as jn}from"undici";var Nn=3e4;function pr(e=Nn){let r=new Fn({bodyTimeout:e});return(n,t)=>jn(n,{...t,dispatcher:r})}function fr(){let e=!0,r,n=null,t=()=>{n!=null&&(clearTimeout(n),n=null)};return{markUnhealthy:o=>{e=!1,r=o,t()},onConnected:()=>{t(),n=setTimeout(()=>{e=!0,r=void 0,n=null},1e4)},onConnecting:()=>{t()},snapshot:()=>({detail:r,ok:e})}}import Bn from"fs";import Sr from"net";import{err as kr,ok as Kn}from"neverthrow";async function hr({cwd:e,onConnection:r}){ae(e);let n=Te(e),t=await mr({onConnection:r,socketPath:n});return t.isOk()||t.error.kind!=="stale-candidate"?t.map(yr(n)).mapErr(gr(n)):await Qn(n)?kr({kind:"already-running",socketPath:n}):(wr(n),(await mr({onConnection:r,socketPath:n})).map(yr(n)).mapErr(gr(n)))}function Qn(e){return new Promise(r=>{let n=Sr.connect(e);n.once("connect",()=>{n.destroy(),r(!0)}),n.once("error",()=>{r(!1)})})}async function mr(e){let r=await zn(e);return r.kind==="listening"?Kn(r.server):kr(r.error)}function zn({onConnection:e,socketPath:r}){return new Promise(n=>{let t=Sr.createServer(e);t.once("error",o=>{n({error:o.code==="EADDRINUSE"?{kind:"stale-candidate"}:{kind:"listen-failed",message:o.message},kind:"failed"})}),t.listen(r,()=>{n({kind:"listening",server:t})})})}function yr(e){return r=>({socketPath:e,close:()=>{r.close(),wr(e)}})}function wr(e){Bn.rmSync(e,{force:!0})}function gr(e){return r=>r.kind==="stale-candidate"?{kind:"already-running",socketPath:e}:{kind:"bind-failed",message:r.message}}import{randomInt as tt,randomUUID as ot}from"crypto";function vr(){return{attempts:0,backoffUntil:0,consecutiveErrors:0,desired:{active:!1,localWorkers:rr,maxTrailLength:nr},executorLocal:!0,findings:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"loading"},prevInteractiveActive:0,stopped:!1,trails:new Map}}function xr(e,r){if(e.stopped)return{effects:[],state:e};switch(r.kind){case"tick":return J(e,r.now,r.queue);case"desired-changed":return J({...e,desired:r.desired},r.now,r.queue);case"executor-changed":return{effects:[],state:{...e,executorLocal:r.local}};case"load-settled":return Gn(e,r.outcome);case"trail-started":return{effects:[],state:{...e,trails:new Map([...e.trails,[r.id,{startedAt:r.now}]])}};case"trail-settled":return Vn(e,r);case"stopped":return{effects:[{ids:[...e.trails.keys()],kind:"abort"}],state:{...e,stopped:!0,trails:new Map}}}}function Rr(e,r,n){return K(Er(e),Pr(e,r,n)).health}function J(e,r,n){let t=Jn(e,r,n),o={...e,...t,prevInteractiveActive:n.active},i=K(Er(o),Pr(o,r,n)),a=o.lockfile.kind!=="ready"&&!o.loading;return{effects:[...a?[{kind:"load"}]:[],...i.abortIds.length>0?[{ids:i.abortIds,kind:"abort"}]:[],...i.launchCount>0?[{count:i.launchCount,kind:"launch",maxTrailLength:o.desired.maxTrailLength}]:[]],state:{...o,loading:o.loading||a}}}function Jn(e,r,n){return n.active<e.prevInteractiveActive?{backoffUntil:Math.max(e.backoffUntil,r+B)}:{backoffUntil:e.backoffUntil}}function Gn(e,r){return r.kind==="blocked"?{effects:[],state:{...e,loading:!1,lockfile:{kind:"blocked",reason:r.reason}}}:{effects:[],state:{...e,consecutiveErrors:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"ready"}}}}function Vn(e,r){let n=new Map([...e.trails].filter(([i])=>i!==r.id)),t=Xn({...e,trails:n},r.settled,r.now),o=J(t.state,r.now,r.queue);return{effects:[...t.effects,...o.effects],state:o.state}}function Xn(e,r,n){switch(r.kind){case"aborted":case"crashed":return{effects:[],state:e};case"app-unreachable":return br({category:"driver",now:n,state:e,subject:"app-unreachable"});case"error":return Yn(e,r.error,n);case"done":return et(e,r.result)}}function Yn(e,r,n){if(r.source==="lockfile-stale")return{effects:[{kind:"reload"}],state:{...e,loading:!0,lockfile:{kind:"loading"}}};let t=Se(r);return t==="trail"?{effects:[],state:{...e,consecutiveErrors:0,lastUnhealthyReportAt:null}}:br({category:t,now:n,state:e,subject:Zn(r)})}function Zn(e){switch(e.source){case"transport":case"config":return`${e.source}: ${e.detail}`;case"runtime":return`runtime: ${e.kind}`;case"empty-trail":case"bad-assign":case"lockfile-stale":return e.source}}function et(e,r){let n=r.kind==="finding";return{effects:[{finding:n,kind:"report",result:r}],state:{...e,attempts:e.attempts+1,consecutiveErrors:0,findings:e.findings+(n?1:0),lastUnhealthyReportAt:null}}}var rt=6,nt=2e4;function br({category:e,now:r,state:n,subject:t}){let o=n.consecutiveErrors+1;if(o<rt)return{effects:[],state:{...n,consecutiveErrors:o}};let i=e==="driver"?Math.max(n.backoffUntil,r+B):n.backoffUntil,a=n.lastUnhealthyReportAt==null||r-n.lastUnhealthyReportAt>=nt;return{effects:a?[{kind:"report-unhealthy",subject:t}]:[],state:{...n,backoffUntil:i,consecutiveErrors:o,lastUnhealthyReportAt:a?r:n.lastUnhealthyReportAt}}}function Er(e){return{enabled:e.desired.active,executorLocal:e.executorLocal,maxTrailLength:e.desired.maxTrailLength,workers:e.desired.localWorkers}}function Pr(e,r,n){return{backoffActive:r<e.backoffUntil,headedActive:n.headedActive>0,interactiveActive:n.active,interactiveQueued:n.queued,lockfile:e.lockfile,poolSize:n.poolSize,trails:[...e.trails.entries()].map(([t,o])=>({ageMs:r-o.startedAt,id:t}))}}function Tr(e){let r=it(e),n=lt(()=>{r.dispatch(x())});return j(()=>{r.dispatch(x())}),r.dispatch(x()),{notifyQueueChange:()=>{r.dispatch({kind:"executor-changed",local:e.executorIsLocal()}),r.dispatch(x())},setDesired:t=>{r.dispatch({desired:t,kind:"desired-changed",now:Date.now(),queue:D()})},status:()=>st(r.current()),stop:()=>{n(),j(null),r.dispatch({kind:"stopped"})}}}function it(e){let r={draining:!1,queue:[],runtime:at(e)},n=i=>{r.runtime=i(r.runtime)},t=i=>{r.queue.push(i),!r.draining&&(r.draining=!0,o(),r.draining=!1)},o=()=>{let i=r.queue.shift();if(i==null)return;let a=xr(r.runtime.state,i);n(l=>({...l,state:a.state})),a.effects.forEach(l=>{dt({commit:n,dispatch:t,effect:l,params:e,runtime:r.runtime})}),o()};return{dispatch:t,current:()=>r.runtime}}function at(e){return{controllers:new Map,prepared:null,state:{...vr(),executorLocal:e.executorIsLocal()}}}function st(e){return{explorer:Rr(e.state,Date.now(),D()),exploring:e.state.trails.size,progress:{attempts:e.state.attempts,findings:e.state.findings}}}function D(){let e=Ne();return{active:e.active,headedActive:e.headedActive,poolSize:e.poolSize,queued:e.queued}}function x(){return{kind:"tick",now:Date.now(),queue:D()}}function lt(e){let r={timer:setTimeout(function n(){e(),r.timer=setTimeout(n,N)},N)};return()=>{clearTimeout(r.timer)}}function dt({commit:e,dispatch:r,effect:n,params:t,runtime:o}){switch(n.kind){case"load":case"reload":{ct(t.cwd,o.prepared).then(({outcome:i,prepared:a})=>{e(l=>({...l,prepared:a})),r({kind:"load-settled",now:Date.now(),outcome:i}),r(x())});return}case"abort":{n.ids.forEach(i=>{o.controllers.get(i)?.abort()});return}case"launch":{Array.from({length:n.count}).forEach(()=>{ut({commit:e,dispatch:r,maxTrailLength:n.maxTrailLength,params:t,prepared:o.prepared})});return}case"report":{t.report({attempts:1,findings:n.finding?1:0,result:n.result}),n.finding&&s.info("exploration finding recorded");return}case"report-unhealthy":s.warn("exploration unhealthy after repeated infra errors (last: %s)",n.subject),t.reportUnhealthy()}}async function ct(e,r){let n=await h(e);if(n==null)return{outcome:{kind:"blocked",reason:"no-lockfile"},prepared:null};if(r?.rawHash===n)return{outcome:{kind:"ready",rawHash:n},prepared:r};let{result:t}=await fe(e);if(t.isErr())return{outcome:{kind:"blocked",reason:"load-failed"},prepared:null};let o=await T(e,t.value);if(o.isErr())return{outcome:{kind:"blocked",reason:o.error.kind},prepared:null};let i=await he(o.value);return i==null?{outcome:{kind:"blocked",reason:"load-failed"},prepared:null}:{outcome:{kind:"ready",rawHash:n},prepared:{exploration:i,rawHash:n}}}function ut({commit:e,dispatch:r,maxTrailLength:n,params:t,prepared:o}){if(o==null)return;let i=we({lockfileHash:o.rawHash,prepared:o.exploration,random:pt,strategy:{...ge("even"),maxAttemptLength:n}});if(i==null)return;let a=`explore:${ot()}`,l=new AbortController;e(d=>({...d,controllers:new Map([...d.controllers,[a,l]])})),r({id:a,kind:"trail-started",now:Date.now()}),C({headed:!1,workClass:"p3-explore",task:()=>ft({assign:i,params:t,signal:l.signal})}).catch(d=>(s.debug({err:d},"exploration trail crashed"),{kind:"crashed"})).then(d=>{e(c=>({...c,controllers:new Map([...c.controllers].filter(([p])=>p!==a))})),r({id:a,kind:"trail-settled",now:Date.now(),queue:D(),settled:d})})}var Ir=2**31;function pt(){return tt(Ir)/Ir}async function ft({assign:e,params:r,signal:n}){let t=await r.executeTrail(e,n);return t.kind==="aborted"?{kind:"aborted"}:t.kind==="error"?mt(r,t.error):{kind:"done",result:t}}async function mt(e,r){let n=await Pe(e.appUrl);return n!=null?(s.debug("exploration app probe failed: %s",n),{kind:"app-unreachable"}):(s.debug({error:r},"exploration trail error"),{error:r,kind:"error"})}import{graphql as Lt}from"gql.tada";import{connect as gt}from"net";import St from"ssh2";import{WebSocket as Lr,createWebSocketStream as kt}from"ws";var yt="ripplo-";function G(e){return Object.entries(e).map(([r,n])=>`${yt}${r}.${n}`)}var{Server:ht,utils:Cr}=St;function Ar(){let e=Cr.generateKeyPairSync("ed25519"),r=Cr.parseKey(e.private);if(r instanceof Error)throw r;return{fingerprint:r.getPublicSSH().toString("base64"),privateKey:e.private}}function Dr(e){return new Promise((r,n)=>{let t={closers:new Set,stopped:!1},o=new Lr(e.relayUrl,G({grant:e.grant,role:"daemon-control"}));o.on("open",()=>{s.info("cloud-executor relay control up"),r({stop:wt(o,t)})}),o.on("message",i=>{vt(e,t,i)}),o.on("close",(i,a)=>{t.stopped||s.warn({code:i,reason:a.toString()},"relay control closed"),Ct(e,t)}),o.on("error",i=>{n(i instanceof Error?i:new Error(String(i)))})})}function wt(e,r){return()=>(r.stopped=!0,r.closers.forEach(n=>{n()}),e.close(),Promise.resolve())}function vt(e,r,n){let t=xt(n);t!=null&&bt(e,r,t.pipeId)}function xt(e){try{let r=JSON.parse(Rt(e));return typeof r=="object"&&r!=null&&"signal"in r&&r.signal==="open-data"&&"pipeId"in r&&typeof r.pipeId=="string"?{pipeId:r.pipeId}:null}catch{return null}}function Rt(e){return Buffer.isBuffer(e)?e.toString("utf8"):Array.isArray(e)?Buffer.concat(e).toString("utf8"):Buffer.from(e).toString("utf8")}function bt(e,r,n){if(r.stopped)return;let t=new Lr(e.relayUrl,G({pipeId:n,role:"daemon-data"}));t.on("open",()=>{Et(e,r,t)}),t.on("error",o=>{s.warn({err:o},"cloud-executor relay data pipe error")})}function Et(e,r,n){let t=kt(n);t.on("error",()=>{});let o=new ht({hostKeys:[e.hostKey.privateKey]},a=>{a.on("error",l=>{s.warn({err:l},"cloud-executor ssh connection error")}),a.on("authentication",l=>{It(l,e.secret)}),a.on("ready",()=>{a.on("tcpip",(l,d,c)=>{Tt({accept:l,allowedPorts:e.allowedPorts,deny:d,destPort:c.destPort})})})}),i=()=>{n.close()};r.closers.add(i),n.on("close",()=>r.closers.delete(i)),Pt(o,t)}function Pt(e,r){e.injectSocket(r)}function It(e,r){if(e.method==="password"&&e.password===r){e.accept();return}if(e.method==="none"){e.reject(["password"]);return}e.reject()}function Tt({accept:e,allowedPorts:r,deny:n,destPort:t}){if(!r.includes(t)){n();return}let o=!1,i=gt({autoSelectFamily:!0,host:"localhost",port:t},()=>{o=!0;let a=e();a.on("error",()=>{}),i.pipe(a).pipe(i)});i.on("error",()=>{o||n()})}function Ct(e,r){r.stopped||(r.stopped=!0,r.closers.forEach(n=>{n()}),e.onFatal())}var At=Lt(`
|
|
52
|
+
mutation EnterCloudMode(
|
|
53
|
+
$devSessionId: String!
|
|
54
|
+
$localUrl: String!
|
|
55
|
+
$engineUrl: String!
|
|
56
|
+
$hostKeyFingerprint: String!
|
|
57
|
+
) {
|
|
58
|
+
enterCloudMode(
|
|
59
|
+
devSessionId: $devSessionId
|
|
60
|
+
localUrl: $localUrl
|
|
61
|
+
engineUrl: $engineUrl
|
|
62
|
+
hostKeyFingerprint: $hostKeyFingerprint
|
|
63
|
+
) {
|
|
64
|
+
__typename
|
|
65
|
+
... on RelaySession {
|
|
66
|
+
generation
|
|
67
|
+
grant
|
|
68
|
+
relayUrl
|
|
69
|
+
secret
|
|
70
|
+
session
|
|
71
|
+
}
|
|
72
|
+
... on DevSessionEndedError {
|
|
73
|
+
message
|
|
74
|
+
}
|
|
75
|
+
... on TunnelNotConfiguredError {
|
|
76
|
+
message
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`),q=class extends Error{failure;constructor(r){super(r.kind),this.failure=r}};async function Hr({config:e,devSessionId:r,onFatal:n}){let t=Ar(),i=(await u({config:e,document:At,variables:{devSessionId:r,engineUrl:e.engineUrl,hostKeyFingerprint:t.fingerprint,localUrl:e.appUrl}})).enterCloudMode;if(i==null)throw new q({kind:"empty-response"});if(i.__typename!=="RelaySession")throw new q({kind:"server-error",typename:i.__typename});let a=await Dr({allowedPorts:[...new Set([qr(e.appUrl),qr(e.engineUrl)])],grant:i.grant,hostKey:t,onFatal:n,relayUrl:i.relayUrl,secret:i.secret});return s.info({session:i.session},"cloud-executor relay up"),{stop:a.stop}}function qr(e){let r=new URL(e);return r.port.length>0?Number(r.port):r.protocol==="https:"?443:80}var Ur=[1e3,3e3,8e3,15e3];function Wr(){return{attempt:0,desired:"local",devSessionId:null,stopped:!1,tunnel:"down"}}function $r(e,r){if(e.stopped)return{effects:[],state:e};switch(r.kind){case"requested":return qt(e,r.mode);case"connected":return V({...e,devSessionId:r.devSessionId},[]);case"tunnel-started":return Ht(e);case"tunnel-failed":case"tunnel-fatal":return Ut(e);case"retry-due":return e.tunnel==="down"?V(e,[]):{effects:[],state:e};case"stopped":return{effects:e.tunnel==="down"?[]:[{kind:"stop-tunnel"}],state:{...e,desired:"local",stopped:!0,tunnel:"down"}}}}function Dt(e){let r=Math.min(e,Ur.length-1),n=Ur[r];if(n==null)throw new Error("executor retry ladder is empty");return n}function qt(e,r){return r===e.desired?{effects:[],state:e}:V({...e,attempt:0,desired:r},[{kind:"notify-changed"}])}function V(e,r){return H(e)&&e.tunnel==="down"&&e.devSessionId!=null?{effects:[...r,{devSessionId:e.devSessionId,kind:"start-tunnel"}],state:{...e,tunnel:"starting"}}:!H(e)&&e.tunnel!=="down"?{effects:[...r,{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}:{effects:r,state:e}}function H(e){return e.desired==="cloud"&&e.devSessionId!=null&&!e.stopped}function Ht(e){return H(e)?{effects:[],state:{...e,attempt:0,tunnel:"up"}}:{effects:[{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}}function Ut(e){let r={...e,tunnel:"down"};return H(r)?{effects:[{delayMs:Dt(r.attempt),kind:"schedule-retry"}],state:{...r,attempt:r.attempt+1}}:{effects:[],state:r}}function Or(e){let r={draining:!1,io:Promise.resolve(),queue:[],retryTimer:null,state:Wr(),tunnel:null},n=t=>{r.queue.push(t),!r.draining&&(r.draining=!0,Fr(r,n,e),r.draining=!1)};return{connect:t=>{n({devSessionId:t,kind:"connected"})},current:()=>r.state.desired,request:t=>{n({kind:"requested",mode:t})},stop:async()=>{n({kind:"stopped"}),await r.io.catch(()=>{})}}}function Fr(e,r,n){let t=e.queue.shift();if(t==null)return;let o=$r(e.state,t);e.state=o.state,o.effects.forEach(i=>{Wt({cell:e,dispatch:r,effect:i,params:n})}),Fr(e,r,n)}function Wt({cell:e,dispatch:r,effect:n,params:t}){switch(n.kind){case"start-tunnel":{Mr(e,()=>$t({cell:e,devSessionId:n.devSessionId,dispatch:r,params:t}));return}case"stop-tunnel":{let o=e.tunnel;e.tunnel=null,_r(e),o!=null&&Mr(e,async()=>{await o.stop(),s.info("executor switched to local")});return}case"schedule-retry":{_r(e),s.warn({delayMs:n.delayMs},"cloud tunnel down; retrying \u2014 switch with npx ripplo executor local"),e.retryTimer=setTimeout(()=>{e.retryTimer=null,r({kind:"retry-due"})},n.delayMs);return}case"notify-changed":t.onChanged()}}async function $t({cell:e,devSessionId:r,dispatch:n,params:t}){try{let o=await Hr({config:t.config,devSessionId:r,onFatal:()=>{e.tunnel=null,n({kind:"tunnel-fatal"})}});e.tunnel=o,s.info("executor switched to cloud"),n({kind:"tunnel-started"})}catch(o){s.warn({err:o},"cloud tunnel failed to start; retrying in background"),n({kind:"tunnel-failed"})}}function Mr(e,r){e.io=e.io.then(r).catch(n=>{s.warn({err:n},"executor io failed")})}function _r(e){e.retryTimer!=null&&(clearTimeout(e.retryTimer),e.retryTimer=null)}import{readdir as Mt}from"fs/promises";import{existsSync as jr}from"fs";import X from"path";async function Nr({config:e,cwd:r}){let n=X.join(r,".ripplo","debug");await(await Mt(n,{withFileTypes:!0}).catch(()=>[])).filter(i=>i.isDirectory()).map(i=>i.name).filter(i=>!i.startsWith("replay-")&&!i.startsWith("explore-")&&!jr(X.join(n,i,ie))&&jr(X.join(n,i,"behavior.jsonl"))).reduce((i,a)=>i.then(()=>Ve({config:e,debugDir:n,runId:a}).catch(()=>{})),Promise.resolve(void 0))}import{fork as _t}from"child_process";import Br from"os";import{CancellationTokenSource as Kr,ResponseError as Qr}from"vscode-jsonrpc/node";function zr(e,r){return()=>{let n=_t(e,["run-worker"],{cwd:r,detached:!0,stdio:["ignore","inherit","inherit","ipc"]});return{connection:je(n),kill:()=>{Ot(n)},onExit:t=>{n.once("exit",t)}}}}function Jr(e){let r={closed:!1,devSessionId:e.devSessionId,lockfileProvider:e.lockfileProvider,nextId:0,size:e.initialSize,spawn:e.spawn,waiters:[],workers:[]};return Yr(r),{close:async()=>{r.closed=!0,await Promise.all([...r.workers].map(n=>Y(n,r)))},execute:(n,t)=>Nt(n,t,r),exploreTrail:(n,t)=>Kt(n,t,r),routeSpan:(n,t)=>{let o=r.workers.find(i=>i.runId===n);o?.worker.connection.sendNotification(Oe,{runId:n,span:t})},setSize:n=>{zt(n,r)}}}function Ot(e){let r=e.pid;if(r!=null)try{process.kill(-r,"SIGKILL")}catch{e.kill("SIGKILL")}}var Ft=1e4,jt=1e4,Gr=-32800;async function Nt(e,r,n){let t=await Vr(n);if(t.runId=e.runId,!t.alive)return U(t,n),{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1};let o=new Kr,i=()=>{o.cancel()};r.aborted&&o.cancel(),r.addEventListener("abort",i,{once:!0});try{let a=await t.worker.connection.sendRequest($e,e,o.token),l=Ue.safeParse(a);return l.success?l.data:{outcome:{detail:"bad-outcome-frame",kind:"error"},serverNotified:!1}}catch(a){return Bt(a,t)}finally{r.removeEventListener("abort",i),o.dispose(),U(t,n)}}async function Vr(e){let r=e.workers.find(n=>n.alive&&n.runId===void 0);if(r!=null)return r.runId="pending",await r.ready,r;if(e.workers.length<e.size){let n=Xr(e);return n.runId="pending",await n.ready,n}return new Promise(n=>{e.waiters.push(t=>{t.runId="pending",n(t)})})}function Xr(e){let r=e.spawn(),n={resolve:()=>{}},t={alive:!0,id:e.nextId,ready:new Promise(o=>{n.resolve=o,r.connection.onNotification(We,o)}),runId:void 0,worker:r};return e.nextId+=1,r.connection.onRequest(Me,()=>e.lockfileProvider()),r.onExit(()=>{t.alive=!1,e.workers=e.workers.filter(o=>o!==t),r.connection.dispose(),n.resolve()}),e.workers.push(t),t}function U(e,r){if(e.runId=void 0,!e.alive||r.closed)return;if(r.workers.length>r.size){Y(e,r);return}let n=r.waiters.shift();n?.(e)}async function Y(e,r){if(r.workers=r.workers.filter(o=>o!==e),!e.alive)return;let n=new Promise(o=>{e.worker.onExit(o)});await e.ready,await e.worker.connection.sendNotification(Fe).catch(()=>{});let t=setTimeout(()=>{e.worker.kill()},Ft);await n,clearTimeout(t)}function Bt(e,r){return e instanceof Qr&&e.code===Gr?{outcome:{detail:"aborted",kind:"error"},serverNotified:!1}:r.alive?{outcome:{detail:e instanceof Error?e.message:String(e),kind:"error"},serverNotified:!1}:{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1}}async function Kt(e,r,n){let t=await Vr(n);if(t.runId="explore",!t.alive)return U(t,n),{error:{detail:"worker-dead",source:"transport"},kind:"error"};let o=new Kr,i={cancel:()=>{}},a=()=>{o.cancel();let l=setTimeout(()=>{t.worker.kill()},jt);i.cancel=()=>{clearTimeout(l)}};r.aborted&&a(),r.addEventListener("abort",a,{once:!0});try{let l=await t.worker.connection.sendRequest(_e,{assign:e,devSessionId:n.devSessionId},o.token),d=ke.safeParse(l);return d.success?d.data:{error:{detail:"bad-result",source:"transport"},kind:"error"}}catch(l){return Qt(l)}finally{i.cancel(),r.removeEventListener("abort",a),o.dispose(),U(t,n)}}function Qt(e){return e instanceof Qr&&e.code===Gr?{kind:"aborted"}:{error:{detail:e instanceof Error?e.message.slice(0,120):"unknown",source:"transport"},kind:"error"}}function zt(e,r){r.size=e,e>Br.availableParallelism()&&s.warn({cores:Br.availableParallelism(),size:e},"worker pool size exceeds available cores");let n=r.workers.filter(o=>o.alive&&o.runId===void 0),t=r.workers.length-e;n.slice(0,Math.max(0,t)).forEach(o=>{Y(o,r)}),Yr(r)}function Yr(e){e.closed||Array.from({length:Math.max(0,e.size-e.workers.length)}).forEach(()=>{Xr(e)})}import W from"fs";import Jt from"p-retry";import{graphql as R}from"gql.tada";import{print as $}from"graphql";var Gt=R(`
|
|
81
|
+
query DaemonExploration($devSessionId: String!) {
|
|
82
|
+
exploration(devSessionId: $devSessionId) {
|
|
83
|
+
active
|
|
84
|
+
localWorkers
|
|
85
|
+
maxTrailLength
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`),Vt=R(`
|
|
89
|
+
subscription WatchExplorationChanged($devSessionId: String!) {
|
|
90
|
+
explorationChanged(devSessionId: $devSessionId) {
|
|
91
|
+
exploration {
|
|
92
|
+
active
|
|
93
|
+
localWorkers
|
|
94
|
+
maxTrailLength
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`);function Zr({config:e,devSessionId:r,exploration:n,sseClient:t}){return Jt(()=>Xt({config:e,devSessionId:r,exploration:n}),{factor:2,minTimeout:500,retries:6}).catch(o=>{s.warn({err:o},"initial exploration state read failed \u2014 explorer stays off")}),t.subscribe({query:$(Vt),variables:{devSessionId:r}},{complete:()=>{},error:o=>{s.error(o,"exploration subscription error")},next:o=>{en(n,o.data?.explorationChanged.exploration)}})}async function Xt({config:e,devSessionId:r,exploration:n}){let t=await u({config:e,document:Gt,variables:{devSessionId:r}});en(n,t.exploration)}function en(e,r){r!=null&&e.setDesired({active:r.active,localWorkers:r.localWorkers,maxTrailLength:r.maxTrailLength})}var Yt=R(`
|
|
99
|
+
subscription HooksPausedWatch($projectId: String!) {
|
|
100
|
+
hooksPausedRequested(projectId: $projectId) {
|
|
101
|
+
paused
|
|
102
|
+
projectId
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`),Zt=R(`
|
|
106
|
+
subscription WatchLocalConcurrencyChanged {
|
|
107
|
+
myMaxLocalConcurrentRunsChanged
|
|
108
|
+
}
|
|
109
|
+
`);function rn({pool:e,sseClient:r}){return r.subscribe({query:$(Zt)},{complete:()=>{},error:n=>{s.error(n,"localConcurrency subscription error")},next:n=>{let t=n.data?.myMaxLocalConcurrentRunsChanged;t!=null&&(L(t),e.setSize(t))}})}var eo=R(`
|
|
110
|
+
subscription WatchExecutorChangeRequested($devSessionId: String!) {
|
|
111
|
+
executorChangeRequested(devSessionId: $devSessionId) {
|
|
112
|
+
executor
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
`);function nn({config:e,devSessionId:r,sseClient:n,switcher:t}){return t.connect(r),ro({config:e,switcher:t}),no({devSessionId:r,sseClient:n,switcher:t})}async function ro({config:e,switcher:r}){let n=await tr(e);if(n.isErr()){s.warn({error:n.error},"initial executor fetch failed, staying local");return}r.request(n.value)}function no({devSessionId:e,sseClient:r,switcher:n}){return r.subscribe({query:$(eo),variables:{devSessionId:e}},{complete:()=>{},error:t=>{s.error(t,"executor subscription error")},next:t=>{let o=t.data?.executorChangeRequested?.executor;o!=null&&n.request(o)}})}function tn({cwd:e,projectId:r,sseClient:n}){return n.subscribe({query:$(Yt),variables:{projectId:r}},{complete:()=>{},error:t=>{s.error(t,"hooksPaused subscription error")},next:t=>{let o=t.data?.hooksPausedRequested?.paused;o!=null&&Z({cwd:e,paused:o})}})}function Z({cwd:e,paused:r}){let n=Ie(e);if(r&&!W.existsSync(n)){W.writeFileSync(n,"");return}!r&&W.existsSync(n)&&W.unlinkSync(n)}var io=6e4,on=500,ao=15e3,so=ee(`
|
|
116
|
+
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
117
|
+
heartbeatDevSession(id: $id) {
|
|
118
|
+
__typename
|
|
119
|
+
... on DevSession {
|
|
120
|
+
id
|
|
121
|
+
}
|
|
122
|
+
... on DevSessionEndedError {
|
|
123
|
+
message
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`),lo=ee(`
|
|
128
|
+
query WatchLocalConcurrency {
|
|
129
|
+
currentUser {
|
|
130
|
+
id
|
|
131
|
+
maxLocalConcurrentRuns
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`),co=ee(`
|
|
135
|
+
mutation EndDevSessionWatch($projectId: String!, $cwd: String!, $devSessionId: String) {
|
|
136
|
+
endDevSession(projectId: $projectId, cwd: $cwd, devSessionId: $devSessionId) {
|
|
137
|
+
__typename
|
|
138
|
+
... on DevSession {
|
|
139
|
+
id
|
|
140
|
+
}
|
|
141
|
+
... on NoActiveDevSessionError {
|
|
142
|
+
message
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`);async function Ya(){bo();let e=xo(process.cwd()),r=e.cwd,n=ko(r),t={current:null},o={handler:()=>{}},i=Or({config:e,onChanged:()=>{o.handler()}}),a={handler:()=>{}},l=wo(),d=fr(),c=Ge({config:e,cwd:r,executor:i.current,ready:l.promise,explorationStatus:()=>t.current?.status()??uo(),onShutdownRequest:()=>{a.handler()},sseHealth:()=>d.snapshot()}),p=await vo({cwd:r,ipc:c,releasePid:n}),f=await E(r);f.isErr()&&(process.stderr.write(`ripplo: ${P(f.error)}
|
|
147
|
+
`),process.exit(1));let M=f.value,y=await z(()=>Qe({config:e,cwd:r,lockfile:M}),{config:e,label:"initial sync"}),m=await h(r);m!=null&&ze(m);let g=ur({config:e,cwd:r}),_=await Po(e);Z({cwd:r,paused:y.hooksPaused});let re=Be(r);re!=null&&s.info("watching branch %s in %s",re,r);let ne=oo({fetchFn:pr(),headers:{Authorization:`Bearer ${e.token}`},retry:ir,retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});Nr({config:e,cwd:r}).catch(()=>{});let w=So({cwd:r,devSessionId:y.devSessionId,initialConcurrency:_}),b=fo({config:e,devSessionId:y.devSessionId,pool:w,executorIsLocal:()=>i.current()==="local"});t.current=b,o.handler=b.notifyQueueChange;let an=await mo({cwd:r,pool:w}),O=lr({claim:c.claim,config:e,cwd:r,initialId:y.devSessionId,pool:w,sseClient:ne,sseHealth:d}),sn=po({config:e,devSessionId:y.devSessionId,executorSwitch:i,exploration:b,pool:w,sseClient:ne}),ln=go({config:e,session:O}),dn=Ro();l.resolve(),yo(y.devSessionId);let cn=async()=>{ln(),dn(),g(),b.stop(),p.close(),O.stop(),sn(),await w.close(),await i.stop(),await an.stop().catch(()=>{}),await Promise.race([u({config:e,document:co,variables:{cwd:e.cwd,devSessionId:O.getId(),projectId:e.projectId}}).catch(()=>{}),new Promise(un=>setTimeout(un,3e3))]),n()},v=()=>{cn().finally(()=>process.exit(0))};a.handler=v,process.on("SIGINT",v),process.on("SIGTERM",v),process.on("SIGHUP",v),process.on("SIGBREAK",v),await new Promise(()=>{})}function uo(){return{explorer:{kind:"off"},exploring:0,progress:{attempts:0,findings:0}}}function po({config:e,devSessionId:r,executorSwitch:n,exploration:t,pool:o,sseClient:i}){let a=[nn({config:e,devSessionId:r,sseClient:i,switcher:n}),tn({cwd:e.cwd,projectId:e.projectId,sseClient:i}),rn({pool:o,sseClient:i}),Zr({config:e,devSessionId:r,exploration:t,sseClient:i})];return()=>{a.forEach(l=>{l()})}}function fo({config:e,devSessionId:r,executorIsLocal:n,pool:t}){return Tr({appUrl:e.appUrl,cwd:e.cwd,executorIsLocal:n,executeTrail:(o,i)=>t.exploreTrail(o,i),report:o=>{Ye({attempts:o.attempts,config:e,devSessionId:r,findings:o.findings,trail:Xe(o.result)}).catch(i=>{s.warn({error:i},"exploration progress report failed")})},reportUnhealthy:()=>{Ze(e,r).catch(o=>{s.warn({error:o},"exploration unhealthy report failed")})}})}function mo({cwd:e,pool:r}){return ve({localDir:to.join(e,".ripplo",".local"),writePortFile:!0,onRrwebBatch:()=>{},onSpan:n=>{let t=n.attributes["ripplo.run"];t!=null&&r.routeSpan(t,n)}})}function yo(e){process.stdout.write(`${De({devSessionId:e,version:ue()})}
|
|
148
|
+
`)}function go({config:e,session:r}){let n=async()=>{try{let o=await u({config:e,document:so,variables:{id:r.getId()}});o.heartbeatDevSession?.__typename==="DevSessionEndedError"&&(s.warn("dev session ended server-side (%s); re-registering",o.heartbeatDevSession.message),await r.reregister())}catch(o){s.warn("heartbeat failed: %s",o instanceof Error?o.message:String(o))}},t=setInterval(()=>{n()},ao);return()=>{clearInterval(t)}}function So({cwd:e,devSessionId:r,initialConcurrency:n}){return Jr({devSessionId:r,initialSize:n,spawn:zr(Io(),e),lockfileProvider:async()=>{let t=await k(e);if(t.isErr())return{unavailable:`daemon-load-failed:${t.error.kind}`};let o=await Re(e,t.value);return{lockfileJson:le(de,o)}}})}function ko(e){try{return Ee({cwd:e,onCompromised:ho})}catch(r){throw r instanceof be&&(process.stderr.write(`${qe({cwd:r.cwd,pid:r.pid})}
|
|
149
|
+
`),process.exit(1)),r}}function ho(){s.error("daemon lock compromised; shutting down"),process.stderr.write(`${He()}
|
|
150
|
+
`),process.exit(1)}function wo(){let e={handler:()=>{}};return{promise:new Promise(n=>{e.handler=n}),resolve:()=>{e.handler()}}}async function vo({cwd:e,ipc:r,releasePid:n}){return(await hr({cwd:e,onConnection:r.handleConnection})).match(o=>o,o=>{process.stderr.write(`${Ce(o)}
|
|
151
|
+
`),n(),process.exit(1)})}function xo(e){return S(e).match(r=>r,r=>{process.stderr.write(`${me(r)}
|
|
152
|
+
`),process.exit(1)})}function Ro(){F({maxRuns:on});let e=setInterval(()=>{F({maxRuns:on})},io);return()=>{clearInterval(e)}}function bo(){process.on("unhandledRejection",e=>{s.error({err:e},"unhandledRejection in watch; continuing")}),process.on("uncaughtException",e=>{s.error({err:e},"uncaughtException in watch; continuing")})}var Eo=4;async function Po(e){try{let n=(await u({config:e,document:lo,variables:void 0})).currentUser?.maxLocalConcurrentRuns;if(n!=null)return L(n),n}catch(r){s.warn({err:r},"failed to fetch local concurrency setting; using default")}return Eo}function Io(){let e=process.argv[1];if(e==null)throw new Error("cli entry unavailable");return e}export{Ya as runDaemon};
|
|
@@ -1,4 +1,4 @@
|
|
|
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,b,c,d,e,f}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f}from"./chunk-R3DZ6JPY.js";import"./chunk-IPSXNIXC.js";import"./chunk-LOEAZGYO.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{e as DevLockHeldError,f as acquireDevLock,d as devPidPath,c as isDevSessionAlive,a as readDevPid,b as stopDevDaemon};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{k as a,l as b,m as c,n as d}from"./chunk-
|
|
4
|
+
import{k as a,l as b,m as c,n as d}from"./chunk-AWPZTNYU.js";import"./chunk-IKYR3UCU.js";import"./chunk-KMZ3L5YA.js";export{a as LOCKFILE_RELATIVE_PATH,d as loadRipplo,b as loadRipploCached,c as loadRipploCachedWithFingerprint};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{f as r}from"./chunk-
|
|
4
|
+
import{f as r}from"./chunk-TPHOSZAK.js";import{c as s}from"./chunk-KOKEEAEF.js";import{a as n}from"./chunk-MHNGR6M7.js";import"./chunk-R3DZ6JPY.js";import"./chunk-IPSXNIXC.js";import"./chunk-LOEAZGYO.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import t from"fs";import a from"os";import l from"path";var w=s("PreToolUse",o=>{if(o.tool_name!=="ExitPlanMode"||!r(o.cwd))return;let i=p();if(i==null)return{hookSpecificOutput:{additionalContext:`Ripplo plan gate: no plan file found \u2014 the "Tests to implement" requirement was not checked. Before implementing, stub a .ripplo/workflows/ workflow per affected flow. ${n("discover")}`,hookEventName:"PreToolUse"}};let e=t.readFileSync(i,"utf8");if(!/\.ripplo\/tests|Tests to implement|No e2e coverage needed/.test(e))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Plan must cite ripplo test stubs. Add a "Tests to implement" section listing .ripplo/workflows/<id>.ts per affected flow, OR add "No e2e coverage needed: <reason>" if this plan touches no user-facing behavior. ${n("discover")}`}}});function p(){let o=l.join(a.homedir(),".claude","plans");return t.existsSync(o)?t.readdirSync(o).filter(e=>e.endsWith(".md")).map(e=>l.join(o,e)).map(e=>({full:e,mtime:t.statSync(e).mtimeMs})).sort((e,m)=>m.mtime-e.mtime)[0]?.full??null:null}export{w as exitPlanGateHook};
|
package/dist/hook.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 o,c as s}from"./chunk-
|
|
4
|
+
import{a as o,c as s}from"./chunk-OQS63V7U.js";import{a as i}from"./chunk-R4ZTRVDQ.js";import{c as e}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as r}from"./chunk-LOEAZGYO.js";import"./chunk-KMZ3L5YA.js";o();e(process.cwd());r(i());s(process.argv[2]??"").catch(async t=>{let{renderTopLevelError:p}=await import("./cli-error-TS4FNZ6F.js");process.stderr.write(`${p(t)}
|
|
5
5
|
`),process.exit(1)});
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 hn,c as kn,d as wn,e as bn,f as vn,g as me}from"./chunk-
|
|
4
|
+
import{a as hn,c as kn,d as wn,e as bn,f as vn,g as me}from"./chunk-IDPJESOE.js";import{a as Bn,b as qn,d as Vn,e as Hn,f as Kn,g as Gn,h as zn,i as Jn,j as Qn,k as Xn,l as Yn,m as Zn,n as et}from"./chunk-5E62BCS7.js";import{a as _n}from"./chunk-3UZZBLVA.js";import{b as mn,c as fn,d as gn,f as yn}from"./chunk-OES7HGNF.js";import{B as Nn,F as On,G as Fn,J as Wn,K as De,M as Dn,N as Un,a as an,b as ln,c as dn,d as un,e as Oe,f as cn,g as Cn,h as xn,j as Rn,k as $n,l as En,m as Pn,n as In,o as An,q as jn,w as We,y as Ln,z as K}from"./chunk-7YQOAAKF.js";import{b as pn,c as H}from"./chunk-22JUAYHM.js";import{a as tn}from"./chunk-MOI4L3EX.js";import{a as ue,b as on,c as pe,d as sn}from"./chunk-7VGCLQGP.js";import{a as $}from"./chunk-OQ6KNYPG.js";import{b as Z,c as Tn,e as Mn}from"./chunk-OQ4TDIP3.js";import{a as R,b as Dr,c as y}from"./chunk-7W237JFM.js";import{a as Ur}from"./chunk-7WZ3VIUU.js";import{e as Fe}from"./chunk-TPHOSZAK.js";import{a as xr,b as rt,c as nt}from"./chunk-OQS63V7U.js";import{a as w}from"./chunk-R4ZTRVDQ.js";import{b as Rr,c as X,d as $r,e as Er}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as Wr,b}from"./chunk-2GFHB4LD.js";import{a as q,b as Fr,c as Le,d as _r}from"./chunk-7IIRERCW.js";import{a as x}from"./chunk-MHNGR6M7.js";import{e as rn,g as ce,j as nn}from"./chunk-NY6EIQR4.js";import{b as Nr,g as Y,k as B,m as Or,n as se}from"./chunk-AWPZTNYU.js";import"./chunk-R3DZ6JPY.js";import{a as fr,b as gr,c as yr,d,f as U,g as hr,i as kr,k as P,l as wr,m as br,n as Me,o as vr,p as Sr,q as Cr}from"./chunk-IPSXNIXC.js";import{a as ie}from"./chunk-LOEAZGYO.js";import{k as _e,l as Sn}from"./chunk-GI65FUDI.js";import{B as Kr,C as Gr,H as zr,I as le,L as Jr,O as Qr,P as Xr,R as Yr,U as de,V as Zr,Y as en,b as V,f as ae,g as c,h as Br,i as qr,n as Ne,o as Vr,r as Hr}from"./chunk-CTTC4KKQ.js";import{$ as Mr,J as Ar,K as L,Q as A,R as jr,W as Tr,aa as Lr,i as Pr,q as M,r as _,u as Ir}from"./chunk-IKYR3UCU.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{availableParallelism as $c}from"os";import{existsSync as tt}from"fs";function ot(){let e=new URL("solve-worker.js",import.meta.url);if(tt(e))return e;let r=new URL("../dist/solve-worker.js",import.meta.url);if(tt(r))return r;throw new Error("solve worker missing \u2014 run `pnpm --filter ripplo build` first (Z3 solves run in the built worker, even when the CLI runs from source)")}import Ec from"update-notifier";import Pc from"yargs";import{hideBin as Ic}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 it(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as bs}from"gql.tada";import{exec as cs}from"child_process";import{createAuthClient as ds}from"better-auth/client";import{deviceAuthorizationClient as us}from"better-auth/client/plugins";function st({baseURL:e}){return ds({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[us()]})}import{err as at,ok as ps}from"neverthrow";var ms=5e3,lt="ripplo-cli";async function dt({onDeviceCode:e,url:r}){let n=r??Dr().RIPPLO_SERVER_URL,t=st({baseURL:n}),o=await t.device.code({client_id:lt});if(o.error!=null)return at({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}),ws(a),(await fs({authClient:t,deviceCode:i})).map(u=>(wr({serverUrl:n,token:u}),u))}async function fs({authClient:e,deviceCode:r}){for(;;){await hs(ms);let n=await e.device.token({client_id:lt,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return ps(n.data.access_token);if(n.error==null)continue;if(!ys(n.error.error))return at({code:n.error.error,description:n.error.error_description,kind:"oauth-authorization-failed"})}}var gs=new Set(["authorization_pending","slow_down"]);function ys(e){return gs.has(e)}function hs(e){return new Promise(r=>{setTimeout(r,e)})}function ks(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function ws(e){let r=ks();cs(`${r} "${e}"`,()=>{})}function j({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,webhookSecret:""}}var vs=bs(`
|
|
5
5
|
query AuthViewer {
|
|
6
6
|
currentUser {
|
|
7
7
|
name
|
|
@@ -447,7 +447,7 @@ ${e.contradictions.map(t=>Kr({contradiction:t,evidencePath:void 0})).join(`
|
|
|
447
447
|
`);return}qu(e)}function qu(e){let r=`ripplo@${e}`,n=Ou("npm",["install","-g",r],{stdio:"inherit"});if(n.status!==0){let t=`exit ${String(n.status)}`;process.stderr.write(`${gi(t)}
|
|
448
448
|
`),process.exit(1)}process.stdout.write(`${or({evicted:0,latest:e,mode:"global"})}
|
|
449
449
|
`)}async function Vu(e){if((await yn(e)).kind==="not-running")return;let n=await gn(e);process.stdout.write(`${yi(n)}
|
|
450
|
-
`)}async function ki({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-
|
|
450
|
+
`)}async function ki({action:e}){if(e==="status"){let{statusCommand:n}=await import("./status-HPMHJBKH.js");await n({format:"summary"});return}if(e==="stop"||e==="restart"){let n=await Hu();(e==="stop"||!n)&&process.exit(n?0:1)}Ku();let{runDaemon:r}=await import("./daemon-UMZJZ7BY.js");await r()}async function Hu(){let{stopDevDaemon:e}=await import("./daemon-lock-OAARBZ4O.js"),{renderDaemonStopResult:r}=await import("./daemon-QKBWYQJA.js"),n=await e(process.cwd());return process.stdout.write(`${r(n)}
|
|
451
451
|
`),n.kind!=="timeout"}function Ku(){let e=Se(H());e!=null&&process.stderr.write(`${e}
|
|
452
452
|
`)}function wi(e){return`executor: ${e}`}function bi(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 vi(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 Si({mode:e}){let r=y(process.cwd()).match(t=>t,t=>{process.stderr.write(`${b(t)}
|
|
453
453
|
`),process.exit(1)});(e==null?await Dn(r):await Un(r,e)).match(t=>{process.stdout.write(`${e==null?wi(t):bi(t)}
|
|
@@ -1,4 +1,4 @@
|
|
|
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}from"./chunk-
|
|
4
|
+
import{a}from"./chunk-64OQXBRG.js";import"./chunk-7WZ3VIUU.js";import"./chunk-TPHOSZAK.js";import"./chunk-R3DZ6JPY.js";import"./chunk-IPSXNIXC.js";import"./chunk-LOEAZGYO.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as planReminder};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{a as t}from"./chunk-TOBC3SQA.js";import"./chunk-CB74TAUC.js";import{a as e}from"./chunk-GZ3M7PNW.js";import"./chunk-N2OBRCPQ.js";import"./chunk-JJ4QQPAV.js";import"./chunk-MOI4L3EX.js";import"./chunk-7VGCLQGP.js";import"./chunk-OQ6KNYPG.js";import"./chunk-OQ4TDIP3.js";import"./chunk-7W237JFM.js";import"./chunk-7WZ3VIUU.js";import"./chunk-TPHOSZAK.js";import"./chunk-FEHVIHVA.js";import{b as o}from"./chunk-KOKEEAEF.js";import"./chunk-7IIRERCW.js";import"./chunk-MHNGR6M7.js";import"./chunk-NY6EIQR4.js";import"./chunk-AWPZTNYU.js";import"./chunk-R3DZ6JPY.js";import"./chunk-IPSXNIXC.js";import"./chunk-LOEAZGYO.js";import"./chunk-CTTC4KKQ.js";import"./chunk-IKYR3UCU.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";var r=o({event:"PostToolUse",handlers:[t,e],note:i=>({hookSpecificOutput:{additionalContext:i,hookEventName:"PostToolUse"}})});export{r as postEditHook};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{a}from"./chunk-TOBC3SQA.js";import"./chunk-CB74TAUC.js";import"./chunk-MOI4L3EX.js";import"./chunk-7VGCLQGP.js";import"./chunk-OQ6KNYPG.js";import"./chunk-OQ4TDIP3.js";import"./chunk-7W237JFM.js";import"./chunk-7WZ3VIUU.js";import"./chunk-TPHOSZAK.js";import"./chunk-FEHVIHVA.js";import"./chunk-7IIRERCW.js";import"./chunk-MHNGR6M7.js";import"./chunk-NY6EIQR4.js";import"./chunk-AWPZTNYU.js";import"./chunk-R3DZ6JPY.js";import"./chunk-IPSXNIXC.js";import"./chunk-LOEAZGYO.js";import"./chunk-CTTC4KKQ.js";import"./chunk-IKYR3UCU.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as postEditAnalyze};
|