ripplo 0.7.58 → 0.7.59
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-2IWN2ZTE.js +287 -0
- package/dist/{chunk-3FARSAHN.js → chunk-6AY37H4A.js} +48 -48
- package/dist/chunk-ORRK3V4W.js +10 -0
- package/dist/{chunk-4R7FSKJN.js → chunk-QKILUEUW.js} +1 -1
- package/dist/{daemon-UA5NKLGP.js → daemon-F37HB3DX.js} +1 -1
- package/dist/{daemon-36KZWUQ3.js → daemon-FU4HDRVQ.js} +19 -19
- package/dist/index.js +212 -214
- package/dist/{status-A7PIUHKG.js → status-UUQN6ZEI.js} +1 -1
- package/package.json +3 -3
- package/dist/chunk-I4PAABD3.js +0 -287
- package/dist/chunk-OKXS4DMM.js +0 -12
|
@@ -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{g as a}from"./chunk-
|
|
4
|
+
import{g as a}from"./chunk-QKILUEUW.js";import"./chunk-ORRK3V4W.js";import"./chunk-PXYDLKAG.js";import"./chunk-6AY37H4A.js";import"./chunk-63TU4VJ7.js";export{a as statusCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ripplo",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.59",
|
|
4
4
|
"description": "CLI for Ripplo — AI-powered end-to-end testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://ripplo.ai",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"eslint-plugin-neverthrow": "^1.1.4",
|
|
68
68
|
"tsup": "^8.5.1",
|
|
69
69
|
"vitest": "^4.1.4",
|
|
70
|
+
"@ripplo/core": "^0.0.0",
|
|
70
71
|
"@ripplo/eslint-config": "0.0.0",
|
|
71
72
|
"@ripplo/run-report": "0.0.0",
|
|
72
|
-
"@ripplo/core": "^0.0.0",
|
|
73
|
-
"@ripplo/runtime": "^0.0.0",
|
|
74
73
|
"@ripplo/solver": "^0.0.0",
|
|
74
|
+
"@ripplo/runtime": "^0.0.0",
|
|
75
75
|
"@ripplo/spec": "^0.0.0",
|
|
76
76
|
"@ripplo/rrweb-bundle": "0.0.0",
|
|
77
77
|
"@ripplo/graphql": "^0.0.0"
|
package/dist/chunk-I4PAABD3.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
-
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{c as sn}from"./chunk-ZPCVY23H.js";import{A as cn,E as un,F as pn,G as fn,H as yn,I as gn,a as T,b as M,c as Be,d as Ve,e as Ke,f as $,g as Je,i as O,w as ln,x as dn}from"./chunk-OKXS4DMM.js";import{b as _e,e as u,f as p,i as Ne,j as qe}from"./chunk-PXYDLKAG.js";import{N as Xe,O as Ye,P as v,Q as Ze,S as en,U as nn,Z as rn,a as j,b as I,c as We,da as tn,ea as on,ha as an,ia as U,j as He,k as F,l as g,q as Qe,r as le,s as h,t as P,u as ze,v as Ge,x as D}from"./chunk-3FARSAHN.js";import hn from"fs";import W from"path";import{config as Mr}from"dotenv";import{z as N}from"zod";import{err as $r,ok as Sn}from"neverthrow";import _ from"fs";import ue from"path";import{err as de,ok as mn}from"neverthrow";import{z as L}from"zod";var Cr=ue.join(".ripplo","project.json"),ce=[".env",".env.local"],Tr=L.object({envFiles:L.array(L.string().min(1)).optional(),projectId:L.string().min(1)});function Rn(e){return ue.join(e,Cr)}function pe(e){let n=Rn(e);return _.existsSync(n)?jr(n).andThen(r=>{let t=Tr.safeParse(r);return t.success?mn({envFiles:t.data.envFiles??ce,projectId:t.data.projectId}):de({issues:t.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):de({kind:"project-file-missing",path:n})}function fe(e){return pe(e).match(n=>n,()=>{})}function jr(e){try{return mn(JSON.parse(_.readFileSync(e,"utf8")))}catch(n){return de({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function $i({cwd:e,envFiles:n,projectId:r}){let t=Rn(e);_.mkdirSync(ue.dirname(t),{recursive:!0});let o={projectId:r};n!=null&&!Fr(n)&&(o.envFiles=[...n]),_.writeFileSync(t,JSON.stringify(o,null,2)+`
|
|
5
|
-
`)}function Fr(e){return e.length!==ce.length?!1:e.every((n,r)=>n===ce[r])}function Wi(e){let r=fe(e)?.envFiles??[".env",".env.local"],t=W.join(e,".ripplo");r.forEach(o=>{let i=W.resolve(t,o);hn.existsSync(i)&&Mr({override:!0,path:i,quiet:!0})}),q=void 0}var Or=N.object({RIPPLO_APP_URL:N.url(),RIPPLO_ENGINE_URL:N.url(),RIPPLO_WEBHOOK_SECRET:N.string().min(1)}),q;function H(){return q!=null?Sn(q):Ur().map(e=>(q=e,e))}function Dr(e){let r=fe(e)?.envFiles??[],t=W.join(e,".ripplo");return r.map(o=>W.resolve(t,o)).filter(o=>!hn.existsSync(o))}function Ur(){let e=Or.safeParse(process.env);if(!e.success)return $r({issues:e.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`),kind:"env-invalid",missingEnvFiles:Dr(process.cwd())});let n=e.data;return Sn({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}var B=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function Qi(e){return e instanceof B?ye(e.failure):e instanceof Error?e.message:String(e)}function ye(e){switch(e.kind){case"project-file-missing":return[`Missing ${e.path} \u2014 this directory is not a Ripplo project.`,"Run `npx ripplo init` to create it (or cd into the project root).",Je("setup")].join(`
|
|
6
|
-
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(n=>` ${n}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
7
|
-
`);case"not-authenticated":return["Not signed in. Run `npx ripplo auth login`.","(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)"].join(`
|
|
8
|
-
`);case"env-invalid":return Lr(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
9
|
-
`);case"gitdir-unrecognized":return`Unrecognized .git file at ${e.marker} \u2014 expected a directory or a "gitdir:" pointer (worktree). Is the repo corrupted?`;case"gitdir-empty":return`Empty gitdir pointer at ${e.marker} \u2014 the worktree's .git file points nowhere. Re-create the worktree.`;case"oauth-device-code-failed":return[`Could not start sign-in (device-code request failed): ${e.description}`,"Is the Ripplo server reachable? Check RIPPLO_SERVER_URL and retry."].join(`
|
|
10
|
-
`);case"oauth-authorization-failed":return[`Sign-in failed (${e.code}): ${e.description}`,e.code==="expired_token"?"The approval window expired \u2014 run `npx ripplo auth login` again.":"Run `npx ripplo auth login` to retry."].join(`
|
|
11
|
-
`);case"compilation-failed":return O(e.error)}}function Lr(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(r=>` ${r}`),"In a git worktree? Env files aren't copied from the main checkout \u2014 recreate them, or symlink to a shared file outside the working tree."];return["Env config invalid:",...e.issues.map(r=>` ${r}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
|
|
12
|
-
`)}import{err as qr,ok as Wr}from"neverthrow";import{z as ge}from"zod";var _r="https://ripplo.ai";function vn(){return xn().RIPPLO_SERVER_URL}function wn(){return xn().RIPPLO_PROJECT_ID}var Nr=ge.object({RIPPLO_PROJECT_ID:ge.string().min(1).optional(),RIPPLO_SERVER_URL:ge.string().min(1).default(_r)}),kn;function xn(){return kn??=Nr.parse(process.env),kn}import bn from"fs";import me from"path";function En(e){let n=bn.realpathSync(e),r=n,t=me.dirname(r);for(;t!==r;){if(bn.existsSync(me.join(r,".git")))return r;r=t,t=me.dirname(r)}return n}function V(e){return pe(e).andThen(n=>H().andThen(r=>{let t=vn(),o=qe(t);return o==null?qr({kind:"not-authenticated"}):Wr({appUrl:r.appUrl,cwd:En(e),engineUrl:r.engineUrl,projectId:wn()??n.projectId,ripploServerUrl:t,token:o,webhookSecret:r.webhookSecret})}))}import{graphql as In}from"gql.tada";var Hr=In(`
|
|
13
|
-
query OpenFindingsForRetire($projectId: String!) {
|
|
14
|
-
exploreFindings(projectId: $projectId, status: open) {
|
|
15
|
-
signature
|
|
16
|
-
reproRun {
|
|
17
|
-
reproJson
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
`),Br=In(`
|
|
22
|
-
mutation RetireStaleFinding($projectId: String!, $signature: String!) {
|
|
23
|
-
retireStaleFinding(projectId: $projectId, signature: $signature)
|
|
24
|
-
}
|
|
25
|
-
`);async function Pn({config:e,lockfile:n}){let t=(await u({config:e,document:Hr,variables:{projectId:e.projectId}})).exploreFindings,o=await Vr(t,n);o.length!==0&&(await Promise.all(o.map(i=>Jr(e,i))),p.info({count:o.length},"retired findings whose trail no longer replays"))}async function Vr(e,n){return(await Promise.all(e.map(async t=>await Kr(t,n)?t.signature:null))).filter(t=>t!=null)}async function Kr(e,n){let r=e.reproRun?.reproJson;if(r==null)return!1;let t=rn.safeParse(JSON.parse(r));return t.success?(await U(n,t.data)).kind==="unplannable":!1}function Jr(e,n){return u({config:e,document:Br,variables:{projectId:e.projectId,signature:n}})}import Qr from"p-queue";var zr=4,Gr={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},K=new Qr({concurrency:zr}),S={headedActive:0,interactiveActive:0,interactiveQueued:0},An={current:null};function fa({headed:e,task:n,workClass:r}){let t=Gr[r];return r==="p3-explore"?K.add(n,{priority:t}):(S.interactiveQueued+=1,J(),K.add(()=>Xr({headed:e,task:n}),{priority:t}))}function ya(e){!Number.isFinite(e)||e<1||(K.concurrency=Math.floor(e),J())}function Re(){return{active:S.interactiveActive,headedActive:S.headedActive,poolSize:K.concurrency,queued:S.interactiveQueued}}function ga(e){An.current=e}async function Xr({headed:e,task:n}){S.interactiveQueued-=1,S.interactiveActive+=1,S.headedActive+=e?1:0,J();try{return await n()}finally{S.interactiveActive-=1,S.headedActive-=e?1:0,J()}}function J(){An.current?.()}import he from"fs";import Se from"path";function Cn(e){try{let n=Yr(e);if(n==null)return;let r=Se.join(n,"HEAD"),t=he.readFileSync(r,"utf8").trim(),o="ref: refs/heads/";return t.startsWith(o)?t.slice(o.length):t.length===0?void 0:t.slice(0,7)}catch{return}}function Yr(e){let n=Se.join(e,".git");if(he.statSync(n).isDirectory())return n;let t=he.readFileSync(n,"utf8").trim(),o="gitdir:";if(!t.startsWith(o))return;let i=t.slice(o.length).trim();if(i.length!==0)return Se.resolve(e,i)}import Zr from"crypto";import{readFile as Tn}from"fs/promises";import jn from"path";import{graphql as ke}from"gql.tada";import{err as et,ok as nt}from"neverthrow";var rt=ke(`
|
|
26
|
-
mutation SyncDevSession(
|
|
27
|
-
$projectId: String!
|
|
28
|
-
$cwd: String!
|
|
29
|
-
$branch: String
|
|
30
|
-
$lockfileContent: String
|
|
31
|
-
$fixtures: [SyncDevFixtureInput!]
|
|
32
|
-
$preconditions: [SyncDevPreconditionInput!]!
|
|
33
|
-
$singletons: [SyncDevSingletonInput!]
|
|
34
|
-
$workflows: [SyncDevWorkflowInput!]!
|
|
35
|
-
) {
|
|
36
|
-
syncDevSession(
|
|
37
|
-
projectId: $projectId
|
|
38
|
-
cwd: $cwd
|
|
39
|
-
branch: $branch
|
|
40
|
-
lockfileContent: $lockfileContent
|
|
41
|
-
fixtures: $fixtures
|
|
42
|
-
preconditions: $preconditions
|
|
43
|
-
singletons: $singletons
|
|
44
|
-
workflows: $workflows
|
|
45
|
-
) {
|
|
46
|
-
id
|
|
47
|
-
hooksPaused
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
`);async function Ta(e,n){let r=await $(e);if(r.isErr())return et({error:r.error,kind:"compilation-failed"});let t=await w({config:n,cwd:e,lockfile:r.value});return nt({devSessionId:t.devSessionId,lockfile:r.value})}async function w(e){let n=He(e.lockfile);return it({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}var tt=ke(`
|
|
51
|
-
query DevSessionSyncState($projectId: String!, $cwd: String!) {
|
|
52
|
-
project(id: $projectId) {
|
|
53
|
-
devSession(cwd: $cwd) {
|
|
54
|
-
id
|
|
55
|
-
hooksPaused
|
|
56
|
-
lockfileHash
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
`),ot=ke(`
|
|
61
|
-
mutation AnnounceDevSessionActive($projectId: String!, $cwd: String!) {
|
|
62
|
-
announceDevSessionActive(projectId: $projectId, cwd: $cwd)
|
|
63
|
-
}
|
|
64
|
-
`);async function ja(e){let n=await ve(e.cwd);if(n!=null){let t=(await u({config:e.config,document:tt,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null))?.project?.devSession;if(t!=null&&t.lockfileHash===n)return await u({config:e.config,document:ot,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null),{devSessionId:t.id,hooksPaused:t.hooksPaused}}return w(e)}async function ve(e){let n=await Fn(e);return n==null?null:Zr.createHash("sha256").update(n).digest("hex")}async function it({config:e,cwd:n,fixtures:r,payload:t}){let o=Cn(n),i=await Fn(n),s=await at(n,r),l=await u({config:e,document:rt,variables:{branch:o??null,cwd:n,fixtures:s,lockfileContent:i,preconditions:t.preconditions.map(a=>({depends:[...a.depends],description:a.description,name:a.name,returns:[...a.returns]})),projectId:e.projectId,singletons:t.singletons.map(a=>({defaultValue:a.defaultValue,description:a.description,name:a.name,type:a.type})),workflows:t.workflows.map(a=>({expectedOutcome:a.expectedOutcome,name:a.name,preconditions:[...a.preconditions],requiresKeys:a.requiresKeys.map(c=>({namespace:c.namespace,preconditionName:c.preconditionName})),slug:a.slug,sourcePath:a.sourcePath,spec:JSON.stringify(a.spec)}))}});if(l.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:l.syncDevSession.id,hooksPaused:l.syncDevSession.hooksPaused}}async function at(e,n){let r=Object.entries(n);return Promise.all(r.map(async([t,o])=>({contentBase64:(await Tn(jn.join(e,M,t))).toString("base64"),sha256:o.sha256})))}async function Fn(e){try{return await Tn(jn.join(e,Be),"utf8")}catch{return null}}import{randomUUID as $t}from"crypto";import{createId as Ot}from"@paralleldrive/cuid2";import{CancellationTokenSource as Dt,ResponseError as Ut}from"vscode-jsonrpc/node";async function Mn(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(2e3)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function $n(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(25e3)}),null}catch(n){return n instanceof Error?n.message:String(n)}}import{graphql as st}from"gql.tada";var lt=st(`
|
|
65
|
-
mutation DaemonCreateRun(
|
|
66
|
-
$id: String
|
|
67
|
-
$workflowId: String!
|
|
68
|
-
$testId: String
|
|
69
|
-
$clientVersion: String
|
|
70
|
-
$executor: RunExecutor
|
|
71
|
-
$target: RunTarget
|
|
72
|
-
$lockfileHash: String
|
|
73
|
-
) {
|
|
74
|
-
createRun(
|
|
75
|
-
id: $id
|
|
76
|
-
workflowId: $workflowId
|
|
77
|
-
testId: $testId
|
|
78
|
-
executor: $executor
|
|
79
|
-
target: $target
|
|
80
|
-
clientVersion: $clientVersion
|
|
81
|
-
lockfileHash: $lockfileHash
|
|
82
|
-
) {
|
|
83
|
-
__typename
|
|
84
|
-
... on MutationCreateRunSuccess {
|
|
85
|
-
data {
|
|
86
|
-
id
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
... on LimitExceededError {
|
|
90
|
-
code
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
`);async function On(e){try{let r=(await u({config:e.config,document:lt,variables:dt(e)})).createRun;return r==null?Q({detail:"create-run-null",type:"generic"}):r.__typename==="MutationCreateRunSuccess"?null:r.__typename==="LimitExceededError"?Q({code:r.code,type:"limit"}):Q({detail:r.__typename,type:"generic"})}catch(n){return ct(n)}}function dt({executor:e,lockfileHash:n,runId:r,target:t}){return{clientVersion:T(),executor:e,id:r,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:t.testId,workflowId:t.workflowId}}function Q(e){return{kind:"dispatch-error",reason:e}}function ct(e){return e instanceof _e?{detail:e.message,kind:"infra-error"}:Q({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{graphql as ut}from"gql.tada";async function Dn(e,n){let t=(await u({config:e,document:pt,variables:{cwd:n,projectId:e.projectId}})).project?.devSession?.workflows??[];return new Map(t.flatMap(o=>o.tests.map(i=>[`${o.slug}/${i.slug}`,{testId:i.id,workflowId:o.id}])))}var pt=ut(`
|
|
95
|
-
query DaemonWorkflows($projectId: String!, $cwd: String!) {
|
|
96
|
-
project(id: $projectId) {
|
|
97
|
-
id
|
|
98
|
-
devSession(cwd: $cwd) {
|
|
99
|
-
id
|
|
100
|
-
workflows {
|
|
101
|
-
id
|
|
102
|
-
slug
|
|
103
|
-
tests {
|
|
104
|
-
id
|
|
105
|
-
slug
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
`);import{CancellationTokenSource as ft}from"vscode-jsonrpc/node";function we(e){return`${e.workflowSlug}/${e.testSlug}`}function Un(e){let{headed:n,inflight:r,jobId:t,lockfileHashValue:o,onExpire:i,runId:s,selection:l,timeoutMs:a}=e,c=we(l),d=`${c}@${o}@${String(n)}`,f=r.get(d);if(f!=null)return f.jobIds.add(t),null;let y={cancellation:new ft,claimed:!1,claimKey:c,headed:n,inflightKey:d,jobIds:new Set([t]),runId:s,testName:l.testName,timer:null,workflowName:l.workflowName};return y.timer=setTimeout(()=>{z(r,y),i(y)},a),r.set(d,y),y}function z(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function xe(e,n){let r=[...e.values()].find(t=>t.runId===n&&!t.claimed);return r==null?null:(r.claimed=!0,r.timer!=null&&(clearTimeout(r.timer),r.timer=null),r)}function Ln(e,n){[...e.values()].filter(r=>r.jobIds.has(n)).forEach(r=>{r.jobIds.delete(n),r.jobIds.size===0&&(z(e,r),r.cancellation.cancel())})}import{err as be,ok as _n}from"neverthrow";function qn({all:e,ids:n,lockfile:r}){if(e&&n.length>0)return be({kind:"conflicting-flags"});if(e)return _n(r.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>h(s))));if(n.length===0)return be({kind:"nothing-selected"});let t=n.map(i=>({id:i,refs:gt(r,i)})),o=t.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?be({kind:"unknown-ids",known:yt(r),unknown:o}):_n([...new Set(t.flatMap(i=>i.refs))])}function Wn(e,n){let r=new Map(P(e).map(t=>[t.ref,{testName:t.test.name,testSlug:t.test.slug,workflowName:t.workflow.name,workflowSlug:g(t.workflow.name)}]));return n.map(t=>{let o=r.get(t);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${t}`);return o})}function yt(e){return e.workflows.map(n=>g(n.name))}function gt(e,n){let r=e.workflows.find(t=>t.name===n||g(t.name)===g(n));return r!=null?r.tests.map(t=>h(t)):P(e).filter(t=>t.ref===n||Nn(t.ref)===Nn(n)).map(t=>t.ref)}function Nn(e){let n=e.lastIndexOf("/");return n===-1?g(e):`${g(e.slice(0,n))}/${g(e.slice(n+1))}`}import{err as Pe,ok as Qn}from"neverthrow";import{graphql as zn}from"gql.tada";import{graphql as wt}from"gql.tada";import{execFileSync as mt}from"child_process";var Rt=256*1024*1024;function A(e,n){return mt("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Rt,stdio:["ignore","pipe","pipe"]})}function Qa(e,n){try{return A(e,n)}catch{return""}}import kt from"fs";import ht from"fs";import Ee from"path";var St=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function Za(e){return Bn(e)!=null}function Hn(e){let n=Bn(e);return n==null?!1:St.some(r=>ht.existsSync(Ee.join(n,r)))}function Bn(e){try{let n=A(["rev-parse","--git-dir"],e).trim();return n.length===0?null:Ee.isAbsolute(n)?n:Ee.resolve(e,n)}catch{return null}}function vt(e){return Ne(e,"hooks-paused")}function Vn(e){return kt.existsSync(vt(e))||Hn(e)?!1:sn(e)}var xt=wt(`
|
|
112
|
-
mutation AutoScopeAddDirty($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
113
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
114
|
-
__typename
|
|
115
|
-
... on MutationAddDirtyTestsToScopeSuccess {
|
|
116
|
-
data {
|
|
117
|
-
id
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
`);async function fs({cwd:e,lockfile:n}){if(!Vn(e))return{addedSlugs:[]};let r=Ie(e);if(r.length===0)return{addedSlugs:[]};let t=new Set(r),o=n.workflows.filter(a=>a.sourcePath!=null&&t.has(a.sourcePath)).map(a=>g(a.name));if(o.length===0)return{addedSlugs:[]};let i=V(e).unwrapOr(void 0);return i==null?{addedSlugs:[]}:await w({config:i,cwd:e,lockfile:n}).catch(a=>(p.warn("auto-sync failed: %s",a instanceof Error?a.message:String(a)),null))==null?{addedSlugs:[]}:{addedSlugs:await bt({cfg:i,slugs:o})?o:[]}}async function bt({cfg:e,slugs:n}){let t=(await u({config:e,document:xt,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:[...n]}}).catch(o=>(p.warn("auto-scope failed: %s",o instanceof Error?o.message:String(o)),null)))?.addDirtyTestsToScope;return t?.__typename!=="MutationAddDirtyTestsToScopeSuccess"?!1:t.data.length>0}var Kn=".ripplo/workflows/",Jn=" -> ";function Ie(e){let n;try{n=A(["status","--porcelain","-uall","--",".ripplo/workflows"],e)}catch{return[]}return n.split(`
|
|
123
|
-
`).map(r=>r.slice(3).trim()).map(r=>r.includes(Jn)?r.split(Jn)[1]:r).filter(r=>r!=null).filter(r=>r.startsWith(Kn)&&r.endsWith(".ts")).map(r=>r.slice(Kn.length)).filter(r=>r!=="index.ts"&&!r.endsWith("/index.ts"))}async function Gn({config:e,cwd:n,lockfile:r}){await It({config:e,cwd:n,lockfile:r});let t=await At(e);if(t.isErr())return Pe(t.error);let o=new Map(r.workflows.filter(s=>!s.stub).map(s=>[g(s.name),s])),i=[...new Set(t.value)].flatMap(s=>{let l=o.get(s);return l==null?[]:l.tests.map(a=>h(a))});return i.length===0?Pe({kind:"scope-empty"}):Qn(i)}var Et=zn(`
|
|
124
|
-
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
125
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
126
|
-
__typename
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
`);async function It({config:e,cwd:n,lockfile:r}){let t=new Set(Ie(n)),o=r.workflows.filter(i=>i.sourcePath!=null&&t.has(i.sourcePath)).map(i=>g(i.name));o.length!==0&&await u({config:e,document:Et,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{p.warn({err:i},"auto-scope of dirty tests failed")})}var Pt=zn(`
|
|
130
|
-
query ScopeSelection($projectId: String!, $cwd: String!) {
|
|
131
|
-
project(id: $projectId) {
|
|
132
|
-
id
|
|
133
|
-
devSession(cwd: $cwd) {
|
|
134
|
-
id
|
|
135
|
-
scopeItems {
|
|
136
|
-
id
|
|
137
|
-
workflow {
|
|
138
|
-
id
|
|
139
|
-
slug
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
`);async function At(e){try{let r=(await u({config:e,document:Pt,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return Qn(r.flatMap(t=>t.workflow==null?[]:[t.workflow.slug]))}catch(n){return Pe({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}import{graphql as Ct}from"gql.tada";var Tt=2e3,jt=Ct(`
|
|
146
|
-
query DaemonCloudRunStatus($runId: String!) {
|
|
147
|
-
run(id: $runId) {
|
|
148
|
-
status
|
|
149
|
-
failureReason
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
`);function Yn({config:e,onComplete:n,onStarted:r,runId:t,signal:o}){let i=!1,s,l=!1,a=async()=>{if(i||o.aborted)return;let c=await Ft(e,t).catch(()=>"unknown");if(!(i||o.aborted)){if(!l&&(c==="running"||Xn(c))&&(l=!0,r()),Xn(c)){i=!0,n(Mt(c));return}s=setTimeout(()=>{a()},Tt)}};return a(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function Ft(e,n){let t=(await u({config:e,document:jt,variables:{runId:n}})).run?.status;return t??"unknown"}function Xn(e){return e==="passed"||e==="failed"||e==="cancelled"||e==="unready"}function Mt(e){return e==="passed"?{kind:"pass"}:e==="failed"?{detail:"failed",kind:"error"}:e==="cancelled"?{detail:"cancelled",kind:"error"}:e==="unready"?{detail:"unready",kind:"error"}:{detail:"unknown",kind:"error"}}var Lt=12e4,_t=-32099,Ae=new Set,Zn=new Map;function Ws(e){Ae.add(e)}function Nt(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function Hs(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:r=>Vt(n,r),handleConnection:r=>{qt(n,r)},idle:()=>rr(n)}}function qt(e,n){let r=ln(n);r.onRequest(un,(t,o)=>Wt({connection:r,ctx:e,params:t,token:o})),r.onRequest(pn,()=>{let t=Re();return{active:t.active,queued:t.queued,sseHealth:e.sseHealth(),version:T(),...e.explorationStatus()}}),r.onRequest(fn,()=>{let t=rr(e);return t&&e.onShutdownRequest(),t}),r.onClose(()=>{Ht(e,r)}),r.onError(t=>{p.warn({err:t},"ipc connection error")}),n.on("error",t=>{p.warn({err:t},"ipc socket error")}),r.listen()}function rr(e){let n=Re();return e.jobs.size===0&&n.active===0&&n.queued===0}async function Wt({connection:e,ctx:n,params:r,token:t}){let o=dn.safeParse(r);if(!o.success)throw er({code:"bad-message"});await n.ready;let i=await Jt({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw er(i.error);let s=$t(),l=new Dt;return t.onCancellationRequested(()=>{tr(n,s)}),n.jobs.set(s,{cancellation:l,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),eo({ctx:n,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:l.token}).catch(a=>{p.error({err:a},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function er(e){return new Ut(_t,e.code,e)}function tr(e,n){let r=e.jobs.get(n);r!=null&&(r.cancellation.cancel(),e.jobs.delete(n),Ln(e.inflight,n))}function Ht(e,n){[...e.jobs.entries()].filter(([,r])=>r.connection===n).forEach(([r])=>{tr(e,r)})}function or(e,n,r){let t=e.jobs.get(n);t!=null&&(nr(()=>t.connection.sendNotification(yn,{event:r,jobId:n})),r.kind==="test-outcome"&&(Bt(t,r.outcome.kind),t.passed+t.failed+t.notRun>=t.total&&(nr(()=>t.connection.sendNotification(gn,{failed:t.failed,jobId:n,notRun:t.notRun,passed:t.passed})),e.jobs.delete(n))))}function nr(e){Promise.resolve().then(e).catch(n=>{p.warn({err:n},"ipc notification failed")})}function Bt(e,n){if(n==="pass"){e.passed+=1;return}if(n==="dispatch-error"||n==="dispatch-timeout"||n==="infra-error"){e.notRun+=1;return}e.failed+=1}function x(e,n,r){n.jobIds.forEach(t=>{or(e,t,r)})}function Vt(e,n){let r=xe(e.inflight,n);return r==null?null:{headed:r.headed,token:r.cancellation.token,finished:(t,o)=>{e.inflight.delete(r.inflightKey),x(e,r,{kind:"test-outcome",outcome:o,runId:r.runId,testName:r.testName,workflowName:r.workflowName})},started:()=>{x(e,r,{kind:"test-started",runId:r.runId,testName:r.testName,workflowName:r.workflowName})}}}function Kt(e){return e.kind==="typecheck-failed"?e.diagnostics.slice(0,5):e.kind==="invalid-lockfile"?e.issues.slice(0,5):e.kind==="load-threw"?[e.message]:[]}async function Jt({config:e,cwd:n,message:r}){return(await Ve(n)).match(o=>Qt({config:e,cwd:n,lockfile:o,message:r}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...Kt(o)]},kind:"error"}))}async function Qt({config:e,cwd:n,lockfile:r,message:t}){let o=await Mn(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await $n(e.engineUrl);if(i!=null)return{error:{code:"engine-unreachable",detail:i,url:e.engineUrl},kind:"error"};let s=await ve(n);if(s==null)return{error:{code:"sync-failed",detail:"lockfile-missing"},kind:"error"};if(!Ae.has(s)){let a=await Gt({config:e,cwd:n,lockfile:r});if(a!=null)return{error:{code:"sync-failed",detail:a},kind:"error"};Ae.add(s),Pn({config:e,lockfile:r}).catch(c=>{p.warn({err:c},"retire stale findings failed")})}return(await Xt({config:e,cwd:n,lockfile:r,message:t})).match(async a=>({kind:"ready",lockfileHashValue:s,selections:Wn(r,a),targetsByClaimKey:await zt({config:e,cwd:n,hash:s})}),a=>Promise.resolve({error:a,kind:"error"}))}async function zt({config:e,cwd:n,hash:r}){let t=Zn.get(r);if(t!=null)return t;let o=await Dn(e,n);return Zn.set(r,o),o}async function Gt(e){try{return await w(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function Xt({config:e,cwd:n,lockfile:r,message:t}){return!t.all&&t.tests.length===0?(await Gn({config:e,cwd:n,lockfile:r})).mapErr(Yt):qn({all:t.all,ids:t.tests,lockfile:r}).mapErr(Zt)}function Yt(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function Zt(e){switch(e.kind){case"conflicting-flags":return{code:"selection-conflicting-flags"};case"nothing-selected":return{code:"selection-nothing-selected"};case"unknown-ids":return{code:"selection-unknown-ids",known:[...e.known],unknown:[...e.unknown]}}}async function eo(e){await e.selections.reduce((n,r)=>n.then(()=>no(e,r)),Promise.resolve())}async function no(e,n){let{ctx:r,headed:t,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:l}=e;if(l.isCancellationRequested)return;let a=we(n),c=s.get(a);if(c==null){or(r,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:n.testName,workflowName:n.workflowName});return}let d=Un({headed:t,inflight:r.inflight,jobId:o,lockfileHashValue:i,runId:Ot(),selection:n,timeoutMs:Lt,onExpire:m=>{x(r,m,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:m.testName,workflowName:m.workflowName})}});if(d==null)return;let f=r.executor(),y=await ro({ctx:r,executor:f,lockfileHashValue:i,run:d,target:c});if(y!=null){z(r.inflight,d),x(r,d,{kind:"test-outcome",outcome:y,runId:"",testName:n.testName,workflowName:n.workflowName});return}f==="cloud"&&to(r,d)}function ro({ctx:e,executor:n,lockfileHashValue:r,run:t,target:o}){return On({config:e.config,executor:n,lockfileHash:r,runId:t.runId,target:o})}function to(e,n){let r=xe(e.inflight,n.runId);r!=null&&Yn({config:e.config,runId:r.runId,signal:Nt(r.cancellation.token),onComplete:t=>{e.inflight.delete(r.inflightKey),x(e,r,{kind:"test-outcome",outcome:t,runId:r.runId,testName:r.testName,workflowName:r.workflowName})},onStarted:()=>{x(e,r,{kind:"test-started",runId:r.runId,testName:r.testName,workflowName:r.workflowName})}})}import oo from"fs";import io from"path";async function Xs(e){let n=io.join(e,".ripplo","index.ts");if(!oo.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let r=await $(e);return r.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:O(r.error),path:".ripplo/"}],valid:!1,warnings:[]}:H().match(t=>({appUrl:t.appUrl,engineUrl:t.engineUrl,errors:[],valid:!0,warnings:[]}),t=>({appUrl:void 0,engineUrl:void 0,errors:[{message:ye(t),path:""}],valid:!1,warnings:[]}))}async function Ys(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`appUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}async function Zs({appUrl:e,engineUrl:n}){let r=n.startsWith("http://")||n.startsWith("https://")?n:`${e}${n}`;try{return(await fetch(`${r}/setup`,{body:JSON.stringify({}),headers:{"Content-Type":"application/json"},method:"PUT",signal:AbortSignal.timeout(5e3)})).ok?"Engine endpoint accepted an unsigned request \u2014 webhook signature verification may be missing.":void 0}catch{return}}function ao(e){let{backoffActive:n,exploreEnabled:r,headedActive:t,interactiveActive:o,interactiveQueued:i}=e,{explorationActive:s,exploreConcurrency:l,poolSize:a}=e;if(!r||t||i>0)return{abortCount:s,refillCount:0};if(n)return{abortCount:0,refillCount:0};let c=Math.min(l,a-1,a-o);return{abortCount:0,refillCount:Math.max(0,c-s)}}function nl(e){let n={active:new Map,backoffUntil:0,cancelBackoffTimer:null,cancelHeartbeat:null,prevInteractiveActive:e.probe().interactiveActive,stopped:!1};return sr(n,e),{explorationActive:()=>n.active.size,notifyQueueChange:()=>{so(n,e)},stop:()=>{n.stopped=!0,n.cancelBackoffTimer?.(),n.cancelBackoffTimer=null,n.cancelHeartbeat?.(),n.cancelHeartbeat=null,lr(n,n.active.size)}}}function sr(e,n){e.stopped||(e.cancelHeartbeat=n.setTimer(()=>{G(e,n),sr(e,n)},15e3))}function G(e,n){if(e.stopped)return;let r=n.probe(),t=ao({backoffActive:n.now()<e.backoffUntil,explorationActive:e.active.size,exploreConcurrency:n.exploreConcurrency(),exploreEnabled:n.exploreEnabled(),headedActive:r.headedActive>0,interactiveActive:r.interactiveActive,interactiveQueued:r.interactiveQueued,poolSize:r.poolSize});lr(e,t.abortCount),dr({count:t.refillCount,params:n,state:e})}function lr(e,n){[...e.active.values()].slice(0,n).forEach(({controller:r})=>{r.abort()})}function so(e,n){let r=n.probe();r.interactiveActive<e.prevInteractiveActive&&lo(e,n),e.prevInteractiveActive=r.interactiveActive,G(e,n)}function lo(e,n){e.backoffUntil=n.now()+3e4,e.cancelBackoffTimer?.(),e.cancelBackoffTimer=n.setTimer(()=>{e.cancelBackoffTimer=null,G(e,n)},3e4)}function dr({count:e,params:n,state:r}){if(e<=0)return;let t=co(n.sources);t!=null&&(uo({params:n,pulled:t,state:r}),dr({count:e-1,params:n,state:r}))}function co(e){return e.reduce((n,r)=>{if(n!=null)return n;let t=r.next();return t==null?null:{job:t,source:r}},null)}function uo({params:e,pulled:n,state:r}){let{job:t,source:o}=n,i=new AbortController;r.active.set(t.id,{controller:i,job:t,source:o}),e.execute({job:t,priority:o.priority,signal:i.signal}).then(()=>{ar({job:t,outcome:ir(i.signal,null),params:e,source:o,state:r})}).catch(s=>{ar({job:t,outcome:ir(i.signal,{error:s}),params:e,source:o,state:r})})}function ir(e,n){return e.aborted?{kind:"aborted"}:n==null?{kind:"completed"}:{error:n.error,kind:"error"}}function ar({job:e,outcome:n,params:r,source:t,state:o}){o.active.delete(e.id),t.onResult(e,n),G(o,r)}import{createMessageConnection as cr,IPCMessageReader as ur,IPCMessageWriter as pr,NotificationType as po,NotificationType0 as fr,RequestType as yr,RequestType0 as fo}from"vscode-jsonrpc/node";import{z as R}from"zod";var sl=R.object({headed:R.boolean(),runId:R.string().min(1),testRef:R.string().min(1)}),ll=R.object({lockfileJson:R.string().optional(),unavailable:R.string().optional()}),dl=R.object({runId:R.string().min(1),span:We}),cl=R.object({outcome:cn,serverNotified:R.boolean()}),ul=new fr("worker/ready"),pl=new yr("worker/run"),fl=new fo("worker/lockfile"),yl=new yr("worker/exploreTrail"),gl=new po("worker/span"),ml=new fr("worker/shutdown");function Rl(e){let n=cr(new ur(e),new pr(e));return n.listen(),n}function hl(){let e=cr(new ur(process),new pr(process));return e.listen(),e}import{gzipSync as wo}from"zlib";import{appendFileSync as xo,existsSync as Y,readFileSync as Sr,writeFileSync as hr}from"fs";import k from"path";import{graphql as Te}from"gql.tada";function X(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}function gr(e,n){return{kind:"finding",payload:Ro(e),source:"verifier",step:n.step,stepIndex:n.stepIndex,timeNanos:n.timeNanos}}var yo={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},go={"data-rule":"dataRule",fact:"fact",step:"step"},mo={aborted:"aborted","action-failed":"actionFailed","app-not-ready":"appNotReady","check-failed":"checkFailed","client-mount-missing":"clientMountMissing","conflicting-sessions":"conflictingSessions","driver-launch":"driverLaunch","engine-decode":"engineDecode","engine-http":"engineHttp","engine-network":"engineNetwork","engine-unreachable":"engineUnreachable","setup-missing-row":"setupMissingRow","state-identity":"stateIdentity"};function Ro(e){return e.kind==="consistency"?{kind:"mismatch",mismatch:vo(e.mismatch),pending:e.pending,wait:e.budget,waitMs:le[e.budget]}:e.kind==="pending-check"?{...ho(e.source),kind:"pendingCheck",source:go[e.source.kind],wait:e.budget,waitMs:le[e.budget]}:e.kind==="unrunnable"?{kind:"unrunnable",reason:yo[e.reason]}:e.kind==="impossible-action"?{action:So(e.step.action),kind:"impossibleAction",subject:Rr(e.step.action)}:e.kind==="lift-visibility"?{declaredIndex:e.declaredIndex,kind:"liftVisibility",subject:I(e.locator),visibleIndex:e.visibleIndex}:{errorKind:mo[e.error.kind],kind:"driverError",message:ko(e.error)}}function ho(e){return"check"in e?mr(e.check,!1):{checkKind:null,expected:null,negated:!1,subject:Ye(e.dataRule)}}function mr(e,n){return e.kind==="not"?mr(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value??null,negated:n,subject:Qe(e.key)}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:I(e.locator)}:{checkKind:e.kind,expected:null,negated:n,subject:I(e.locator)}}function So(e){return`${e.kind} ${Rr(e)}`.trim()}function Rr(e){return e.locator==null?e.url??"":I(e.locator)}function ko(e){return"message"in e?e.message:"detail"in e?e.detail:null}function vo(e){if(e.kind==="wrong-value")return{actual:v(e.sut),entity:e.entity,expected:v(e.snapshot),field:e.field,key:e.key,kind:"wrongValue"};if(e.kind==="expected-change"){let n=e.direction==null?"change":e.direction.replace(/d$/,"");return{actual:v(e.value),entity:e.entity,expected:`${n} from ${v(e.from)}`,field:e.field,key:e.key,kind:"expectedChange"}}return e.kind==="scalar-mismatch"?{actual:v(e.sut),expected:Ze(e.want),kind:"scalarMismatch",subject:Xe(e.subject)}:e.kind==="missing-row"?{entity:e.entity,key:e.key,kind:"missingRow"}:{entity:e.entity,key:e.key,kind:"unexpectedRow"}}function ee({config:e,fixturesDir:n,headed:r}){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:j,headed:r,secret:e.webhookSecret}}async function je(e){let n=ne(e);await Fe(e.config,e.runId,n)}function ne({debugDir:e,events:n,recordingOptional:r,runId:t,stepSources:o}){let i=Me(n),s=jo(e,t);if(s==null&&!r)throw new Error("recording-missing");let l=i.map((c,d)=>Wo({aliases:[...$o(n),...Oo(i)],generated:Do(n),generatedSingletons:Uo(n),origin:s==null?To(i):s.origin,record:c,rrwebEvents:s==null?[]:s.events,sourceTest:o?.[d]??null})),a=i.flatMap(c=>c.findings.map(d=>gr(d,{step:X(F(c.source,c.index)),stepIndex:c.index,timeNanos:kr(c)})));return bo({debugDir:e,events:[...l,...a],runId:t}),i}function bo({debugDir:e,events:n,runId:r}){if(n.length===0)return;let t=k.join(e,r,"behavior.jsonl");if(!Y(t))return;let o=n.map(i=>JSON.stringify(i)).join(`
|
|
153
|
-
`);xo(t,`${o}
|
|
154
|
-
`)}function kr(e){return String(BigInt(Math.max(0,Math.round(e.endMs)))*1000000n)}async function Fe(e,n,r){let t=r.filter(s=>s.findings.length>0).length,o=r.length-t,i=r.reduce((s,l)=>s+Math.max(0,l.endMs-l.startMs),0);await u({config:e,document:Vo,variables:{items:[{duration:i,failCount:t,firstFailedStepTitle:Eo(r),passCount:o,runId:n,status:t>0?"failed":"passed"}]}})}function Eo(e){let n=e.filter(r=>r.findings.length>0).toSorted((r,t)=>r.index-t.index).at(0);return n==null?null:X(F(n.source,n.index))}function Me(e){return e.flatMap(n=>n.kind==="step"?[{annotations:n.annotations,endMs:n.endMs,findings:n.findings,index:n.index,source:n.source,startMs:n.startMs,state:n.state,url:n.url}]:[])}async function vr(e,n){await u({config:e,document:Ko,variables:{runIds:[n]}})}var Z=".uploaded";async function Io({config:e,debugDir:n,runId:r}){let t=k.join(n,r),o=k.join(t,"behavior.jsonl");if(Y(k.join(t,Z)))return;if(!Y(o)){p.warn({runId:r},"behavior upload skipped: behavior.jsonl missing on disk");return}await[0,1e3,3e3].reduce((s,l)=>s.then(async a=>a?!0:(await new Promise(c=>setTimeout(c,l)),Po({behaviorPath:o,config:e,runDir:t,runId:r}))),Promise.resolve(!1))}async function Po({behaviorPath:e,config:n,runDir:r,runId:t}){try{let o=await u({config:n,document:Bo,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:wo(Sr(e)),headers:{"content-type":Co},method:"PUT"});return i.ok?(await vr(n,t),hr(k.join(r,Z),""),!0):(p.warn({runId:t,status:i.status},"behavior upload PUT failed"),!1)}catch(o){return Ao(o)?(p.warn({runId:t},"behavior upload refused by server; run unknown \u2014 not retrying"),hr(k.join(r,Z),""),!0):(p.warn({error:o,runId:t},"behavior upload failed"),!1)}}function Ao(e){if(typeof e!="object"||e==null||!("errors"in e))return!1;let{errors:n}=e;return Array.isArray(n)&&n.some(r=>{if(typeof r!="object"||r==null||!("extensions"in r))return!1;let{extensions:t}=r;return typeof t=="object"&&t!=null&&"code"in t&&t.code==="FORBIDDEN"})}var Co="application/x-ndjson";function To(e){return e.reduce((n,r)=>Math.min(n,r.startMs),e[0]?.startMs??0)}function jo(e,n){let r=k.join(e,n,"behavior.jsonl");if(!Y(r))return null;let t=Sr(r,"utf8").split(`
|
|
155
|
-
`).filter(i=>i.length>0).map(i=>Fo(i)).flatMap(i=>Mo(i)?[i.event]:[]),o=t[0];return o==null?null:{events:t,origin:o.timestamp}}function Fo(e){return JSON.parse(e)}function Mo(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function $o(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function Oo(e){return e.flatMap(n=>{let r=Lo(n.source);return r.flatMap(t=>{let i=r.filter(l=>l.entity===t.entity).indexOf(t),s=n.state.rows.filter(l=>l.status==="created"&&l.entity===t.entity).at(i);return s==null?[]:[{alias:t.as,entity:t.entity,key:s.key}]})})}function Do(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(r=>wr(r)):[]))}function wr({entity:e,field:n,key:r}){return`${e} ${r} ${n}`}function Uo(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Lo(e){return e==null?[]:e.expect.flatMap(n=>Ce(n))}function Ce(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>Ce(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(r=>Ce(r))):[]}var _o=3,No=0;function qo({endMs:e,rrwebEvents:n,startMs:r}){let t=n.find(o=>o.type===_o&&o.data?.source===No&&o.timestamp>=r&&o.timestamp<=e);return t==null?r:t.timestamp}function Wo({aliases:e,generated:n,generatedSingletons:r,origin:t,record:o,rrwebEvents:i,sourceTest:s}){let l=F(o.source,o.index),a=qo({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs});return{annotations:[...o.annotations.map(d=>({ephemeral:d.ephemeral,kind:d.kind,label:d.label,outcome:d.outcome,recordingStartMs:Math.max(0,(d.kind==="action"?a:d.atMs)-t),rrwebIds:[...d.rrwebIds],url:d.url,value:d.value??null}))],duration:Math.max(0,o.endMs-o.startMs),kind:"step",nodeType:l.kind,pageUrl:o.url,recordingEndMs:Math.max(0,o.endMs-t),recordingStartMs:Math.max(0,a-t),source:"verifier",sourceTest:s,stateRows:o.state.rows.map(d=>Ho({aliases:e,generated:n,row:d})),stateSingletons:o.state.singletons.map(d=>({changed:d.changed,generated:r.has(d.name),name:d.name,value:d.value==null?null:String(d.value)})),stepIndex:o.index,timeNanos:kr(o),title:X(l)}}function Ho({aliases:e,generated:n,row:r}){let t=e.find(o=>o.entity===r.entity&&o.key===r.key);return{entity:r.entity,fields:r.fields.map(o=>({changed:o.changed,field:o.field,generated:n.has(wr({entity:r.entity,field:o.field,key:r.key})),value:o.value==null?null:String(o.value)})),key:r.key,label:t?.alias??r.key,status:r.status}}var Bo=Te(`
|
|
156
|
-
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
157
|
-
debugArtifactUploadUrl(runId: $runId)
|
|
158
|
-
}
|
|
159
|
-
`),Vo=Te(`
|
|
160
|
-
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
161
|
-
completeRunsBatch(items: $items) {
|
|
162
|
-
id
|
|
163
|
-
status
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
`),Ko=Te(`
|
|
167
|
-
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
168
|
-
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
169
|
-
}
|
|
170
|
-
`);import{graphql as b}from"gql.tada";function Jo(e){let n=e.trail;if(!(n==null||!Qo(e.kind)))return{baseLabel:n.baseLabel,baseState:n.baseState,durationMs:n.durationMs,outcome:e.kind,runId:e.runId,signature:n.signature,steps:n.steps}}function Qo(e){return e==="clean"||e==="flaky"||e==="finding"}async function $e({baseState:e,category:n,config:r,debugDir:t,devSessionId:o,events:i,lockfileHash:s,reproJson:l,runId:a,signature:c,spec:d,stepSources:f,summary:y,workflowSlug:m}){await u({config:r,document:Zo,variables:{devSessionId:o??null,lockfileHash:s??null,projectId:r.projectId,reproJson:l,runId:a,spec:d??null,workflowSlug:m??null}}),await je({config:r,debugDir:t,events:i,recordingOptional:!0,runId:a,stepSources:f}),await u({config:r,document:ei,variables:{baseState:e,category:n,projectId:r.projectId,reproRunId:a,signature:c,summary:y}})}async function re(e,n,r){return(await u({config:e,document:ni,variables:{lockfileHash:r,projectId:e.projectId,signature:n}})).exploreFindingExists}async function zo({attempts:e,config:n,devSessionId:r,findings:t,trail:o}){await u({config:n,document:Xo,variables:{attempts:e,devSessionId:r,findings:t,trail:o==null?null:{baseLabel:o.baseLabel,baseState:o.baseState,durationMs:o.durationMs,findingRunId:o.runId??null,findingSignature:o.signature??null,outcome:o.outcome,steps:o.steps.map(i=>({test:i.test,text:i.text}))}}})}async function Go(e,n){return(await u({config:e,document:Yo,variables:{devSessionId:n}}).catch(t=>(p.warn({error:t},"reportExploreUnhealthy failed"),null)))?.reportExploreUnhealthy??!1}var Xo=b(`
|
|
171
|
-
mutation RecordExplorationProgress(
|
|
172
|
-
$devSessionId: String!
|
|
173
|
-
$attempts: Int!
|
|
174
|
-
$findings: Int!
|
|
175
|
-
$trail: ExploreTrailInput
|
|
176
|
-
) {
|
|
177
|
-
recordExplorationProgress(
|
|
178
|
-
devSessionId: $devSessionId
|
|
179
|
-
attempts: $attempts
|
|
180
|
-
findings: $findings
|
|
181
|
-
trail: $trail
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
`),Yo=b(`
|
|
185
|
-
mutation ReportExploreUnhealthy($devSessionId: String!) {
|
|
186
|
-
reportExploreUnhealthy(devSessionId: $devSessionId)
|
|
187
|
-
}
|
|
188
|
-
`),Zo=b(`
|
|
189
|
-
mutation CreateExploreRun(
|
|
190
|
-
$projectId: String!
|
|
191
|
-
$runId: String!
|
|
192
|
-
$devSessionId: String
|
|
193
|
-
$lockfileHash: String
|
|
194
|
-
$spec: String
|
|
195
|
-
$reproJson: String
|
|
196
|
-
$workflowSlug: String
|
|
197
|
-
) {
|
|
198
|
-
createExploreRun(
|
|
199
|
-
projectId: $projectId
|
|
200
|
-
runId: $runId
|
|
201
|
-
devSessionId: $devSessionId
|
|
202
|
-
lockfileHash: $lockfileHash
|
|
203
|
-
spec: $spec
|
|
204
|
-
reproJson: $reproJson
|
|
205
|
-
workflowSlug: $workflowSlug
|
|
206
|
-
) {
|
|
207
|
-
id
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
`),ei=b(`
|
|
211
|
-
mutation SubmitExploreFinding(
|
|
212
|
-
$projectId: String!
|
|
213
|
-
$signature: String!
|
|
214
|
-
$summary: String!
|
|
215
|
-
$baseState: String!
|
|
216
|
-
$category: ExploreFindingCategory!
|
|
217
|
-
$reproRunId: String!
|
|
218
|
-
) {
|
|
219
|
-
submitExploreFinding(
|
|
220
|
-
projectId: $projectId
|
|
221
|
-
signature: $signature
|
|
222
|
-
summary: $summary
|
|
223
|
-
baseState: $baseState
|
|
224
|
-
category: $category
|
|
225
|
-
reproRunId: $reproRunId
|
|
226
|
-
) {
|
|
227
|
-
id
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
`),Ul=b(`
|
|
231
|
-
mutation SetExploreFindingStatus(
|
|
232
|
-
$projectId: String!
|
|
233
|
-
$signature: String!
|
|
234
|
-
$status: ExploreFindingStatus!
|
|
235
|
-
) {
|
|
236
|
-
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
237
|
-
}
|
|
238
|
-
`),ni=b(`
|
|
239
|
-
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
240
|
-
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
241
|
-
}
|
|
242
|
-
`);import oi from"path";import{graphql as ii}from"gql.tada";import{graphql as te}from"gql.tada";function Oe(e){switch(e.kind){case"app-not-ready":return"appNotReady";case"client-mount-missing":return"appNotReady";case"engine-network":case"engine-http":return"backendUnreachable";case"engine-unreachable":return"engineUnreachable";case"engine-decode":case"state-identity":case"setup-missing-row":case"conflicting-sessions":case"driver-launch":case"action-failed":case"check-failed":case"aborted":return null}}async function De(e,n,r){await u({config:e,document:ri,variables:{reason:r,runId:n}}).catch(t=>{p.error(t,"failRun submission failed")})}async function Ue(e,n,r){await u({config:e,document:ti,variables:{cause:r,runId:n}}).catch(t=>{p.error(t,"markRunUnready submission failed")})}var ql=te(`
|
|
243
|
-
mutation ReleaseRun($runId: String!) {
|
|
244
|
-
releaseRun(runId: $runId)
|
|
245
|
-
}
|
|
246
|
-
`),Wl=te(`
|
|
247
|
-
mutation HeartbeatRun($runId: String!) {
|
|
248
|
-
heartbeatRun(runId: $runId)
|
|
249
|
-
}
|
|
250
|
-
`),ri=te(`
|
|
251
|
-
mutation FailRun($runId: String!, $reason: String!) {
|
|
252
|
-
failRun(runId: $runId, reason: $reason)
|
|
253
|
-
}
|
|
254
|
-
`),ti=te(`
|
|
255
|
-
mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
|
|
256
|
-
markRunUnready(runId: $runId, cause: $cause)
|
|
257
|
-
}
|
|
258
|
-
`);async function ai({config:e,cwd:n,errorSettle:r,fixturesDir:t,headed:o,lockfile:i,onPhase:s,runId:l,session:a,signal:c,test:d}){if(!await li(e,l))return{outcome:{kind:"dispatch-failed",reason:"already-claimed",runId:l},persisted:Promise.resolve()};let y=oi.join(n,".ripplo","debug"),m=[];return(await a.runOnce({capture:!0,lockfile:i,onPhase:s,options:ee({config:e,fixturesDir:t,headed:o}),params:void 0,runId:l,sequence:void 0,test:d,onEvent:E=>{m.push(E)}},c)).match(async E=>{let Le=Me(m),ae=Le.flatMap(Ar=>Ar.findings),se=si(ae);if(se!=null)return ne({config:e,debugDir:y,events:m,recordingOptional:!0,runId:l,stepSources:void 0}),await xr({config:e,error:se,errorSettle:r,runId:l}),{outcome:{error:se,kind:"error",runId:l},persisted:Promise.resolve()};await Fe(e,l,Le),ne({config:e,debugDir:y,events:m,recordingOptional:!0,runId:l,stepSources:void 0});let Pr=Promise.resolve();return{outcome:ae.length>0?{findings:ae,kind:"findings",runId:l}:{kind:"pass",runId:l},persisted:Pr}},async E=>(await xr({config:e,error:E,errorSettle:r,runId:l}),{outcome:{error:E,kind:"error",runId:l},persisted:Promise.resolve()}))}async function xr({config:e,error:n,errorSettle:r,runId:t}){if(r==="defer")return;let o=Oe(n);if(o!=null){await Ue(e,t,o);return}await De(e,t,D(n))}function si(e){let n=e.find(r=>r.kind==="driver-error"&&Ge(r.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function li(e,n){return((await u({config:e,document:di,variables:{runIds:[n]}})).startRunsBatch??[]).some(t=>t.id===n)}var di=ii(`
|
|
259
|
-
mutation StartRunsBatch($runIds: [String!]!) {
|
|
260
|
-
startRunsBatch(runIds: $runIds) {
|
|
261
|
-
id
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
`);import{randomUUID as ci}from"crypto";async function ui({assign:e,config:n,debugDir:r,devSessionId:t,fixturesDir:o,headed:i,lockfile:s,report:l,session:a,signal:c}){let d=ze(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let f=vi(d,e.stepRuns),y=await an({baseState:{name:h(e.baseStateTest),test:e.baseStateTest},corpus:d,lockfile:s,options:ee({config:n,fixturesDir:o,headed:i}),seenSignature:l?C=>re(n,C,e.lockfileHash):void 0,session:a,stepRuns:e.stepRuns,runIdFor:C=>`explore-${ci()}-${String(C)}`},c),m=l?await Ri({baseStateTest:e.baseStateTest,config:n,debugDir:r,devSessionId:t,lockfileHash:e.lockfileHash,outcome:y,reproJson:gi(d,e),stepSources:mi(f)}):!1;return yi(y,f.length),wi(y,m,pi(f,e,y))}function pi(e,n,r){if(r.kind==="error"||r.kind==="aborted")return;let t=r.timing.confirm;return{baseLabel:n.baseStateTest.intent,baseState:h(n.baseStateTest),durationMs:Math.round(oe(r.timing.detect)+(t==null?0:oe(t))),signature:r.kind==="finding"||r.kind==="seen"?r.signature:void 0,steps:fi(e.slice(0,r.ranCount))}}function fi(e){return e.flatMap(n=>{let r=n.label.split("#")[0]??n.label;return n.actions.map(t=>({test:r,text:t}))})}function oe(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function yi(e,n){if(e.kind==="error"){p.info({detail:D(e.error),kind:e.kind,reason:e.error.kind,steps:n},"explore trail");return}if(e.kind==="aborted"||e.kind==="seen"){p.info({kind:e.kind,steps:n},"explore trail");return}let r=e.timing.detect,t=e.timing.confirm;p.info({browserMs:r.browserMs,confirmMs:t==null?void 0:oe(t),detectMs:oe(r),driveMs:r.driveMs,engineMs:r.engineMs,kind:e.kind,steps:n,teardownMs:r.teardownMs,worldMs:r.worldMs},"explore trail")}function gi(e,n){let r=n.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),t={baseStateRef:h(n.baseStateTest),steps:r};return JSON.stringify(t)}function mi(e){return e.flatMap(n=>{let r=n.label.split("#")[0]??n.label;return n.actions.map(()=>r)})}async function Ri({baseStateTest:e,config:n,debugDir:r,devSessionId:t,lockfileHash:o,outcome:i,reproJson:s,stepSources:l}){return i.kind!=="finding"||i.captureEvents.length===0?!1:await re(n,i.signature,o)?(p.info({devSessionId:t,signature:i.signature},"explore finding already reported, skipping duplicate"),!1):(await $e({baseState:i.baseState,category:hi(i.verifierLayer),config:n,debugDir:r,devSessionId:t,events:i.captureEvents,lockfileHash:o,reproJson:s,runId:i.runId,signature:i.signature,spec:ki(e,i.captureEvents),stepSources:l,summary:Si(i.captureEvents,i.title),workflowSlug:i.sourceTest?.split("/")[0]}).catch(a=>{p.warn({error:a},"explore finding report failed")}),!0)}function hi(e){return e==="data-rule"?"dataRule":e==="model-drift"?"modelDrift":e}function Si(e,n){let r=e.flatMap(t=>t.kind==="step"?[...t.findings]:[]).at(0);if(r!=null)return en(r);if(n!=null)return n;throw new Error("explore finding has no findings to summarize")}function ki(e,n){let r=n.flatMap(o=>o.kind==="step"?[o.source]:[]),t={absent:e.absent,actor:e.actor,exclusive:e.exclusive,intent:e.intent,maybe:[],name:e.name,params:e.params,singletons:e.singletons,steps:r,stub:!1,tests:[],world:e.world};return JSON.stringify(t)}function vi(e,n){return n.flatMap(r=>{let t=e[r.idx];return t==null?[]:[{actions:[...t.nav,...t.steps].map(o=>nn(o.action)),label:`${t.test}#${String(t.index)}`}]})}function wi(e,n,r){return e.kind==="error"?{kind:e.kind,reason:`runtime:${e.error.kind}`}:e.kind==="finding"?{kind:e.kind,runId:n?e.runId:void 0,trail:r}:{kind:e.kind,trail:r}}import xi from"path";import{randomUUID as bi}from"crypto";async function hd({cwd:e,onReady:n,signal:r,step:t,target:o}){let i=V(e).match(f=>({config:f}),f=>({failure:f}));if("failure"in i)return{failure:i.failure,kind:"config-failed"};let s=i.config,l=await Ke(e);if(l.result.isErr())return{error:l.result.error,kind:"compile-failed"};let a=l.result.value,c=await Ei(a,o);return c.kind!=="ok"?c:(await tn({lockfile:a,onReady:n,options:Ii(s),runId:`teleport-${bi()}`,sequence:c.sequence,stopAfterStep:t,test:c.test},r)).match(f=>({kind:"done",result:f}),f=>({error:f,kind:"run-failed"}))}async function Ei(e,n){if(n.kind==="explore"){let t=await U(e,n.repro);return t.kind==="unplannable"?{kind:"unplannable"}:{kind:"ok",sequence:t.sequence,test:t.baseTest}}let r=P(e).find(t=>t.ref===n.ref);return r==null?{kind:"no-test",ref:n.ref}:{kind:"ok",sequence:on(e,r.test,void 0),test:r.test}}function Ii(e){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:xi.join(e.cwd,M),generate:j,headed:!0,secret:e.webhookSecret}}import{graphql as br}from"gql.tada";import{err as ie,ok as Er}from"neverthrow";var Pi=br(`
|
|
265
|
-
query ExecutorSession($projectId: String!, $cwd: String!) {
|
|
266
|
-
project(id: $projectId) {
|
|
267
|
-
id
|
|
268
|
-
devSession(cwd: $cwd) {
|
|
269
|
-
id
|
|
270
|
-
executor
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
`),Ai=br(`
|
|
275
|
-
mutation SetDevSessionExecutor($devSessionId: String!, $executor: RunExecutor!) {
|
|
276
|
-
setDevSessionExecutor(devSessionId: $devSessionId, executor: $executor) {
|
|
277
|
-
__typename
|
|
278
|
-
... on DevSession {
|
|
279
|
-
id
|
|
280
|
-
executor
|
|
281
|
-
}
|
|
282
|
-
... on DevSessionEndedError {
|
|
283
|
-
message
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
`);async function xd(e){return(await Ir(e)).map(r=>r.executor)}async function bd(e,n){let r=await Ir(e);if(r.isErr())return ie(r.error);let o=(await u({config:e,document:Ai,variables:{devSessionId:r.value.id,executor:n}})).setDevSessionExecutor;return o==null?ie({kind:"empty-response"}):o.__typename!=="DevSession"?ie({kind:"session-ended"}):Er(o.executor)}async function Ir(e){let r=(await u({config:e,document:Pi,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return r==null?ie({kind:"no-session"}):Er({executor:r.executor,id:r.id})}export{$i as a,Wi as b,H as c,Dr as d,Qi as e,ye as f,vn as g,xn as h,V as i,Qa as j,Za as k,Hn as l,Xs as m,Ys as n,Zs as o,vt as p,Vn as q,nl as r,sl as s,dl as t,cl as u,ul as v,pl as w,fl as x,yl as y,gl as z,ml as A,Rl as B,hl as C,Pn as D,fa as E,ya as F,Re as G,ga as H,Cn as I,Ta as J,w as K,ja as L,ve as M,fs as N,Ws as O,Nt as P,Hs as Q,Z as R,Io as S,De as T,ai as U,Jo as V,zo as W,Go as X,ui as Y,hd as Z,xd as _,bd as $};
|
package/dist/chunk-OKXS4DMM.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
-
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{i as T}from"./chunk-PXYDLKAG.js";import{B as Y,D as Q,E as Z,f as R,g as p,h as q,i as l,m as X,n as V,o as B,p as K,z as G}from"./chunk-3FARSAHN.js";import{readFileSync as Se}from"fs";import{z as ee}from"zod";var Le=ee.object({version:ee.string()});function xt(){let e=Se(new URL("../package.json",import.meta.url),"utf8");return Le.parse(JSON.parse(e)).version}import w from"fs";import h from"path";import{createJiti as ze}from"jiti";import{err as E,ok as H,ResultAsync as He}from"neverthrow";import be from"fs";import S from"path";import f from"typescript";function te(e){let t=S.join(e,"index.ts"),n=ve(e);be.mkdirSync(S.dirname(n.tsBuildInfoFile??""),{recursive:!0});let o=f.createIncrementalCompilerHost(n),i=f.createIncrementalProgram({host:o,options:n,rootNames:[t]}),a=[...i.getSyntacticDiagnostics(),...i.getSemanticDiagnostics()];i.emit();let u=a.filter(s=>we(s,e));if(u.length===0)return{diagnostics:[],ok:!0};let v={getCanonicalFileName:s=>s,getCurrentDirectory:()=>S.dirname(e),getNewLine:()=>`
|
|
5
|
-
`};return{diagnostics:f.formatDiagnosticsWithColorAndContext(u,v).split(`
|
|
6
|
-
`).filter(s=>s.length>0),ok:!1}}function we(e,t){let n=e.file?.fileName;return n==null?!0:n.startsWith(t)}var Ee=S.join(".local","tsbuildinfo");function ve(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:f.ModuleKind.Preserve,moduleResolution:f.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:f.ScriptTarget.ES2022,tsBuildInfoFile:S.join(e,Ee)}}import L from"fs";import A from"safe-stable-stringify";import{err as Re,ok as I}from"neverthrow";async function ne(e,t){let n={entities:e.entities,singletonSchemas:e.singletons,valueSpaces:e.valueSpaces},o=m(t)?void 0:Ce(t),i=Pe(e,o);return(await e.workflows.reduce(async(u,v)=>{let d=await u;return d.isErr()?d:(await je({context:n,reusable:i,workflow:v})).map(D=>[...d.value,D])},Promise.resolve(I([])))).map(u=>({...e,workflows:[...u]}))}function m(e){let t=process.argv[1];if(t==null||!L.existsSync(e))return!1;try{return L.statSync(t).mtimeMs>L.statSync(e).mtimeMs}catch{return!1}}async function je({context:e,reusable:t,workflow:n}){let o=t.get(oe(n));if(o!=null)return I({...n,tests:o.tests});try{return I(await X({context:e,workflow:n}))}catch(i){let a=i instanceof Error?i.message:String(i);return Re({kind:"expand-failed",message:a,workflow:n.name})}}function oe(e){let t=A({...e,tests:[]});if(t==null)throw new Error("solver: workflow is not serializable");return t}function Pe(e,t){return t==null||A(re(t))!==A(re(e))?new Map:new Map(t.workflows.map(n=>[oe(n),n]))}function re(e){return{entities:e.entities,singletons:e.singletons,valueSpaces:e.valueSpaces}}function Ce(e){if(L.existsSync(e))try{return p(l,L.readFileSync(e,"utf8"))}catch{return}}import{createHash as Fe}from"crypto";import ie from"fs/promises";import M from"path";import{err as g,ok as O,Result as Te}from"neverthrow";var Ae=".ripplo/fixtures",$=10*1024*1024,_=50*1024*1024;async function ae(e,t){let n=Ie(t);if(n.length===0)return O({});let o=M.join(e,Ae),i=await Promise.all(n.map(a=>Me({fixturesRoot:o,name:a})));return Te.combine(i).andThen(Oe)}function Ie(e){let n=e.workflows.flatMap(o=>[...o.steps,...o.tests.flatMap(i=>i.steps)]).flatMap(o=>o.action.kind==="upload"?o.action.files:[]);return[...new Set(n)].toSorted((o,i)=>o.localeCompare(i))}async function Me({fixturesRoot:e,name:t}){if(t.includes("..")||M.isAbsolute(t))return g({kind:"fixture-invalid-name",name:t});let n=M.join(e,t),o=await ie.lstat(n).catch(()=>null);if(o==null)return g({kind:"fixture-missing",name:t,path:n});if(o.isSymbolicLink())return g({kind:"fixture-symlink",name:t});if(!o.isFile())return g({kind:"fixture-not-file",name:t});let i=await ie.readFile(n);if(i.byteLength>$)return g({kind:"fixture-too-large",name:t,size:i.byteLength});let a=Fe("sha256").update(i).digest("hex");return O([t,{sha256:a,size:i.byteLength}])}function Oe(e){let t=e.reduce((n,[,o])=>n+o.size,0);return t>_?g({kind:"fixtures-total-too-large",total:t}):O(Object.fromEntries(e))}import{createHash as $e}from"crypto";import y from"fs";import z from"path";import{z as N}from"zod";function se({cwd:e,fingerprint:t}){let n=Ne(e);if(n==null||n.fingerprint!==j(t))return;let o=z.join(e,".ripplo","ripplo.lock");if(!y.existsSync(o))return;let i=y.readFileSync(o,"utf8");if(j(i)===n.lockfileHash)try{return p(l,i)}catch{return}}function le({cwd:e,fingerprint:t,lockfile:n}){let o={fingerprint:j(t),lockfileHash:j(R(l,n))},i=ce(e);y.mkdirSync(z.dirname(i),{recursive:!0}),y.writeFileSync(i,JSON.stringify(o))}var _e=N.object({fingerprint:N.string(),lockfileHash:N.string()});function Ne(e){let t=ce(e);if(!(!y.existsSync(t)||m(t)))try{let n=_e.safeParse(JSON.parse(y.readFileSync(t,"utf8")));return n.success?n.data:void 0}catch{return}}function ce(e){return z.join(e,".ripplo",".local","load-cache.json")}function j(e){return $e("sha256").update(e).digest("base64")}var c=".ripplo/ripplo.lock",b;async function Qt(e){let{result:t}=await Je(e);return t}async function Je(e){let t=de(h.join(e,".ripplo"));if(b!=null&&b.fingerprint===t&&b.result.isOk())return{fingerprint:t,result:b.result};let n=await J(e);return b={fingerprint:t,result:n},{fingerprint:t,result:n}}async function J(e){let t=h.join(e,".ripplo"),n=h.join(t,"index.ts"),o=de(t),i=se({cwd:e,fingerprint:o});if(i!=null)return H(i);let a=te(t);if(!a.ok)return E({diagnostics:a.diagnostics,kind:"typecheck-failed"});let d=await(await De(n)).andThen(s=>Xe({entryPath:n,exported:s})).match(async s=>(await ae(e,s)).map(x=>({...s,fixtures:x})).mapErr(x=>({error:x,kind:"fixture-failed"})).asyncAndThen(x=>new He(ne(x,h.join(e,c))).mapErr(xe=>xe)),s=>Promise.resolve(E(s)));return d.isOk()&&le({cwd:e,fingerprint:o,lockfile:d.value}),d}var Ue=new Set([".local","debug","node_modules","ripplo.lock"]);function de(e){let t=h.join(e,"..","node_modules","@ripplo","testing","package.json");return[...ue(e),...We(t)].toSorted((n,o)=>n.localeCompare(o)).join("|")}function ue(e){return(w.existsSync(e)?w.readdirSync(e,{withFileTypes:!0}):[]).flatMap(n=>{if(Ue.has(n.name))return[];let o=h.join(e,n.name);if(n.isDirectory())return ue(o);let i=w.statSync(o);return[`${o}:${String(i.mtimeMs)}:${String(i.size)}`]})}function We(e){if(!w.existsSync(e))return[];let t=w.statSync(e);return[`${e}:${String(t.mtimeMs)}:${String(t.size)}`]}async function De(e){try{let n=await ze(import.meta.url,{fsCache:!1,moduleCache:!1,sourceMaps:!0}).import(e),o=n!=null&&typeof n=="object"&&"default"in n?Reflect.get(n,"default"):n;return H(o)}catch(t){return E({kind:"load-threw",message:qe(t)})}}function qe(e){return e instanceof Error?e.message:String(e)}function Xe({entryPath:e,exported:t}){if(t==null||typeof t!="object"||!("lockfile"in t))return E({entryPath:e,kind:"not-ripplo"});let n=q.safeParse(Reflect.get(t,"lockfile"));return n.success?H(n.data):E({issues:n.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"invalid-lockfile"})}function P(e,t){return t==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${t}.`}function er(e){return e.length===1?P(e[0]):`Before proceeding, load the ${e.map(n=>`\`/ripplo:${n}\``).join(" and ")} skills \u2014 every one, each carries rules the others don't.`}function ir(e){return[`Compilation failed: ${Ve(e)}`,P("create","DSL authoring rules")].join(`
|
|
7
|
-
`)}function ar(){return`${c} is up to date`}function sr(e){return[`${c} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit the result`,P("setup")].join(`
|
|
8
|
-
`)}function lr(){return`Wrote ${c}`}function Ve(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...pe(e.diagnostics)].join(`
|
|
9
|
-
`);case"not-ripplo":return`${e.entryPath} must default-export a Ripplo (createRipplo({ entities, singletons, workflows })). Check that the default export is the value returned by createRipplo, not a function or a re-export.`;case"invalid-lockfile":return["Lockfile failed schema validation (stale or hand-edited .ripplo/ripplo.lock?):",...pe(e.issues),"Regenerate with `npx ripplo compile` \u2014 never hand-edit the lockfile."].join(`
|
|
10
|
-
`);case"load-threw":return[`.ripplo/index.ts threw while loading: ${e.message}`,"Usually a bad import or a top-level throw in .ripplo/ \u2014 run `npx ripplo compile` for the stack."].join(`
|
|
11
|
-
`);case"fixture-failed":return Be(e.error);case"expand-failed":return[`Could not resolve tests for workflow "${e.workflow}": ${e.message}`,"Check the branch conditions and the seeded state in given \u2014 a branch may need state no seed can produce."].join(`
|
|
12
|
-
`)}}function pe(e,t=8){return e.length<=t?e:[...e.slice(0,t),`\u2026 and ${String(e.length-t)} more`]}function Be(e){switch(e.kind){case"fixture-missing":return`Fixture "${e.name}" not found at ${e.path} \u2014 add the file under .ripplo/fixtures/ or fix the upload() name.`;case"fixture-invalid-name":return`Invalid fixture name "${e.name}" \u2014 upload() takes a bare name under .ripplo/fixtures/, no .. or absolute paths.`;case"fixture-symlink":return`Fixture "${e.name}" is a symlink \u2014 only regular files are allowed.`;case"fixture-not-file":return`Fixture "${e.name}" is not a regular file.`;case"fixture-too-large":return`Fixture "${e.name}" is ${C(e.size)} \u2014 over the ${C($)} per-file limit.`;case"fixtures-total-too-large":return`Fixtures total ${C(e.total)} \u2014 over the ${C(_)} limit.`}}function C(e){return`${String(Math.round(e/(1024*1024)*10)/10)} MB`}import{writeFile as et}from"fs/promises";import tt from"path";import{createHash as fe}from"crypto";import k from"fs";import W from"path";import Ke from"safe-stable-stringify";import{z as U}from"zod";function me({context:e,cwd:t}){V(e);let n=Ye(t,F(e));n!=null&&B(e,n)}function xr({context:e,cwd:t}){let n=Ze(t);if(!(n==null||n.model!==F(e)))return n.cleanLockfile??void 0}function Sr({cleanLockfileHash:e,context:t,cwd:n}){let o=ge(n);k.mkdirSync(W.dirname(o),{recursive:!0}),k.writeFileSync(o,JSON.stringify({cleanLockfile:e,model:F(t)}))}function Lr(e){return fe("sha256").update(e).digest("base64")}var Ge=U.object({cleanLockfile:U.string().nullable(),model:U.string()});function Ye(e,t){let n=W.join(e,c);if(!k.existsSync(n)||m(n))return null;let o=Qe(n);return o==null?null:F({entities:o.entities,singletonSchemas:o.singletons,valueSpaces:o.valueSpaces})===t?o.solved:null}function Qe(e){try{return p(l,k.readFileSync(e,"utf8"))}catch{return null}}function F(e){let t=Ke({entities:e.entities,singletons:e.singletonSchemas,valueSpaces:e.valueSpaces});if(t==null)throw new Error("solve-cache: context is not serializable");return fe("sha256").update(t).digest("base64")}function Ze(e){let t=ge(e);if(!(!k.existsSync(t)||m(t)))try{let n=Ge.safeParse(JSON.parse(k.readFileSync(t,"utf8")));return n.success?n.data:void 0}catch{return}}function ge(e){return W.join(e,".ripplo",".local","solve-cache.json")}async function Fr(e){let t=await J(e);return t.isOk()&&await rt(e,t.value),t}async function rt(e,t){let n=await nt(e,t);return await et(tt.join(e,c),R(l,n)),n}var ye=new WeakMap;function nt(e,t){let n=ye.get(t);if(n!=null)return n;let o=ot(e,t);return ye.set(t,o),o}function Tr(e){return e.workflows.filter(t=>t.stub).map(t=>t.name)}async function ot(e,t){let n=Y(t);me({context:n,cwd:e});let o=await Z(t),i=await Q(t);await G({context:n,facts:i.facts});let a=await K(n);return{...t,checks:o,solved:a}}import{createMessageConnection as it,NotificationType as he,RequestType as at,RequestType0 as ke,SocketMessageReader as st,SocketMessageWriter as lt}from"vscode-jsonrpc/node";import{z as r}from"zod";var ct="daemon.sock",dt="daemon.log";function $r(e){return T(e,ct)}function _r(e){return T(e,dt)}function Nr(e){return it(new st(e),new lt(e))}var zr=r.object({all:r.boolean(),headed:r.boolean(),tests:r.array(r.string())}),Hr=r.object({jobId:r.string(),total:r.number()}),ut=r.enum(["on","off"]),pt=r.object({attempts:r.number(),findings:r.number()}),Jr=r.object({active:r.number(),explorer:ut,exploring:r.number(),progress:pt,queued:r.number(),sseHealth:r.object({detail:r.string().optional(),ok:r.boolean()}).optional(),version:r.string().optional()}),ft=r.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),mt=r.discriminatedUnion("type",[r.object({code:ft,type:r.literal("limit")}),r.object({detail:r.string(),type:r.literal("generic")})]),gt=r.discriminatedUnion("kind",[r.object({kind:r.literal("pass")}),r.object({findingLines:r.array(r.string()),kind:r.literal("findings")}),r.object({detail:r.string(),kind:r.literal("error")}),r.object({kind:r.literal("dispatch-error"),reason:mt}),r.object({detail:r.string(),kind:r.literal("dispatch-timeout")}),r.object({detail:r.string(),kind:r.literal("infra-error")})]),yt=r.discriminatedUnion("kind",[r.object({kind:r.literal("test-started"),runId:r.string(),testName:r.string(),workflowName:r.string()}),r.object({kind:r.literal("test-outcome"),outcome:gt,runId:r.string(),testName:r.string(),workflowName:r.string()})]),Ur=r.object({event:yt,jobId:r.string()}),Wr=r.object({failed:r.number(),jobId:r.string(),notRun:r.number(),passed:r.number()}),Dr=r.discriminatedUnion("code",[r.object({code:r.literal("compile-failed"),detail:r.string(),diagnostics:r.array(r.string()).default([])}),r.object({code:r.literal("selection-conflicting-flags")}),r.object({code:r.literal("selection-nothing-selected")}),r.object({code:r.literal("selection-unknown-ids"),known:r.array(r.string()),unknown:r.array(r.string())}),r.object({code:r.literal("scope-failed"),detail:r.string()}),r.object({code:r.literal("app-unreachable"),detail:r.string(),url:r.string()}),r.object({code:r.literal("engine-unreachable"),detail:r.string(),url:r.string()}),r.object({code:r.literal("sync-failed"),detail:r.string()}),r.object({code:r.literal("bad-message")})]),qr=new at("ripplo/enqueue"),Xr=new ke("ripplo/status"),Vr=new ke("ripplo/shutdownIfIdle"),Br=new he("ripplo/jobEvent"),Kr=new he("ripplo/jobDone");export{xt as a,Ae as b,c,Qt as d,Je as e,J as f,P as g,er as h,ir as i,ar as j,sr as k,lr as l,me as m,xr as n,Sr as o,Lr as p,Fr as q,rt as r,nt as s,Tr as t,$r as u,_r as v,Nr as w,zr as x,Hr as y,Jr as z,gt as A,Ur as B,Wr as C,Dr as D,qr as E,Xr as F,Vr as G,Br as H,Kr as I};
|