ripplo 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/{chunk-5SM4TCSW.js → chunk-4F67XQYS.js} +19 -19
  2. package/dist/{chunk-EGETJKAQ.js → chunk-4H7EIC6W.js} +1 -1
  3. package/dist/{chunk-4FKGHWCC.js → chunk-AYDIXOW2.js} +1 -1
  4. package/dist/chunk-BR7W4UBJ.js +83 -0
  5. package/dist/{chunk-WHSQBXWO.js → chunk-EA62LNKT.js} +2 -2
  6. package/dist/chunk-EVVF662P.js +6 -0
  7. package/dist/{chunk-XBD3OTIW.js → chunk-FR4ENKCT.js} +1 -1
  8. package/dist/{chunk-N2B5GZPU.js → chunk-IRTBARRY.js} +1 -1
  9. package/dist/{chunk-PXZV5X3C.js → chunk-JXGIARTE.js} +1 -1
  10. package/dist/chunk-PRD7P6EF.js +6 -0
  11. package/dist/{chunk-2MT2MZJW.js → chunk-Q6IYTHMP.js} +1 -1
  12. package/dist/{chunk-7TYUZIUO.js → chunk-QQ7NFPJQ.js} +1 -1
  13. package/dist/chunk-U27IDW6O.js +229 -0
  14. package/dist/{chunk-SWOTFHBR.js → chunk-V4IQQT44.js} +1 -1
  15. package/dist/chunk-WZBLSDNV.js +4 -0
  16. package/dist/chunk-XVMIPWJQ.js +4 -0
  17. package/dist/{chunk-AVBP7Q2M.js → chunk-XZ2TPZLD.js} +1 -1
  18. package/dist/{chunk-LKYTQXPR.js → chunk-ZDA3E2AS.js} +1 -1
  19. package/dist/{chunk-UVYCSHOJ.js → chunk-ZUPS6XVH.js} +1 -1
  20. package/dist/{cli-error-SLG6JHK2.js → cli-error-J33JDZET.js} +1 -1
  21. package/dist/{compile-write-7AV66JUA.js → compile-write-H2GLCECO.js} +1 -1
  22. package/dist/{daemon-LFFCR3TB.js → daemon-3J3K4BOD.js} +1 -1
  23. package/dist/daemon-AS6IHTHD.js +152 -0
  24. package/dist/{dsl-loader-H25XGSHJ.js → dsl-loader-5Z2JRKY3.js} +1 -1
  25. package/dist/hook.js +1 -1
  26. package/dist/index.js +171 -172
  27. package/dist/{plan-reminder-VMBDQTAP.js → plan-reminder-E6AXT6OB.js} +1 -1
  28. package/dist/post-edit-LUPA46ZO.js +4 -0
  29. package/dist/post-edit-analyze-XY6C7ZFP.js +4 -0
  30. package/dist/post-edit-flag-stubs-ZMKN4DJZ.js +4 -0
  31. package/dist/{pre-edit-Q4U5LSWG.js → pre-edit-EJO3TUNQ.js} +1 -1
  32. package/dist/{pre-edit-watch-gate-EUZGEH2J.js → pre-edit-watch-gate-DZHQCMEI.js} +1 -1
  33. package/dist/{prompt-submit-MPRVCWOI.js → prompt-submit-U3QOU47D.js} +1 -1
  34. package/dist/{session-preamble-RJ4WNGJN.js → session-preamble-IHBGHKCW.js} +1 -1
  35. package/dist/solve-worker.js +1 -1
  36. package/dist/status-247DEYFK.js +4 -0
  37. package/dist/{stop-enforce-UXBQRTFP.js → stop-enforce-ZLQKGMSF.js} +1 -1
  38. package/package.json +6 -5
  39. package/dist/chunk-AQ3DMGAY.js +0 -6
  40. package/dist/chunk-CRELTIU2.js +0 -242
  41. package/dist/chunk-EK6TENV6.js +0 -4
  42. package/dist/chunk-ESOXRGIY.js +0 -83
  43. package/dist/chunk-M7VQD4VO.js +0 -6
  44. package/dist/chunk-OY6HNCAZ.js +0 -4
  45. package/dist/daemon-BN42ZNCJ.js +0 -139
  46. package/dist/post-edit-2VFE6QND.js +0 -4
  47. package/dist/post-edit-analyze-VETPP5Z4.js +0 -4
  48. package/dist/post-edit-flag-stubs-J3MCGLXI.js +0 -4
  49. package/dist/status-UBUNHH5O.js +0 -4
@@ -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-CJUKILIO.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-BNAUL4FC.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-VMBDQTAP.js").then(o=>t("UserPromptSubmit",o.planReminder)),"post-edit":()=>import("./post-edit-2VFE6QND.js").then(o=>o.postEditHook),"post-edit-analyze":()=>import("./post-edit-analyze-VETPP5Z4.js").then(o=>t("PostToolUse",o.postEditAnalyze)),"post-edit-flag-stubs":()=>import("./post-edit-flag-stubs-J3MCGLXI.js").then(o=>t("PostToolUse",o.postEditFlagStubs)),"pre-bash-run-gate":()=>import("./pre-bash-run-gate-PWLARIYK.js").then(o=>o.preBashRunGateHook),"pre-edit":()=>import("./pre-edit-Q4U5LSWG.js").then(o=>o.preEditHook),"pre-edit-ripplo-skill-gate":()=>import("./pre-edit-ripplo-skill-gate-JD4BDCA3.js").then(o=>t("PreToolUse",o.preEditRipploSkillGate)),"pre-edit-scope-gate":()=>import("./pre-edit-scope-gate-NZO4HVGT.js").then(o=>t("PreToolUse",o.preEditScopeGate)),"pre-edit-watch-gate":()=>import("./pre-edit-watch-gate-EUZGEH2J.js").then(o=>t("PreToolUse",o.preEditWatchGate)),"prompt-submit":()=>import("./prompt-submit-MPRVCWOI.js").then(o=>o.promptSubmitHook),"scope-reminder":()=>import("./scope-reminder-CBY4I5SG.js").then(o=>t("UserPromptSubmit",o.scopeReminder)),"session-preamble":()=>import("./session-preamble-RJ4WNGJN.js").then(o=>o.sessionPreambleHook),"stop-enforce":()=>import("./stop-enforce-UXBQRTFP.js").then(o=>o.stopEnforceHook),"tasks-reminder":()=>import("./tasks-reminder-LKSUZUFD.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-SLG6JHK2.js");process.stderr.write(`${a(o,r.error)}
5
+ `))}var d={"exit-plan-gate":()=>import("./exit-plan-gate-BNAUL4FC.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-E6AXT6OB.js").then(o=>t("UserPromptSubmit",o.planReminder)),"post-edit":()=>import("./post-edit-LUPA46ZO.js").then(o=>o.postEditHook),"post-edit-analyze":()=>import("./post-edit-analyze-XY6C7ZFP.js").then(o=>t("PostToolUse",o.postEditAnalyze)),"post-edit-flag-stubs":()=>import("./post-edit-flag-stubs-ZMKN4DJZ.js").then(o=>t("PostToolUse",o.postEditFlagStubs)),"pre-bash-run-gate":()=>import("./pre-bash-run-gate-PWLARIYK.js").then(o=>o.preBashRunGateHook),"pre-edit":()=>import("./pre-edit-EJO3TUNQ.js").then(o=>o.preEditHook),"pre-edit-ripplo-skill-gate":()=>import("./pre-edit-ripplo-skill-gate-JD4BDCA3.js").then(o=>t("PreToolUse",o.preEditRipploSkillGate)),"pre-edit-scope-gate":()=>import("./pre-edit-scope-gate-NZO4HVGT.js").then(o=>t("PreToolUse",o.preEditScopeGate)),"pre-edit-watch-gate":()=>import("./pre-edit-watch-gate-DZHQCMEI.js").then(o=>t("PreToolUse",o.preEditWatchGate)),"prompt-submit":()=>import("./prompt-submit-U3QOU47D.js").then(o=>o.promptSubmitHook),"scope-reminder":()=>import("./scope-reminder-CBY4I5SG.js").then(o=>t("UserPromptSubmit",o.scopeReminder)),"session-preamble":()=>import("./session-preamble-IHBGHKCW.js").then(o=>o.sessionPreambleHook),"stop-enforce":()=>import("./stop-enforce-ZLQKGMSF.js").then(o=>o.stopEnforceHook),"tasks-reminder":()=>import("./tasks-reminder-LKSUZUFD.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-J33JDZET.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};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __ripploCreateRequire } from "node:module";
3
+ const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
4
+ import{E as v,F as L,K as j,L as g,Y as B}from"./chunk-4F67XQYS.js";import c from"fs";import l from"path";import{createHash as Se}from"crypto";import{pathToFileURL as Re}from"url";import{build as be}from"esbuild";import{err as x,ok as C,ResultAsync as Fe}from"neverthrow";import ee from"fs";import y from"path";import u from"typescript";function A(e){let n=y.join(e,"index.ts"),t=re(e);ee.mkdirSync(y.dirname(t.tsBuildInfoFile??""),{recursive:!0});let r=u.createIncrementalCompilerHost(t),o=u.createIncrementalProgram({host:r,options:t,rootNames:[n]}),i=[...o.getSyntacticDiagnostics(),...o.getSemanticDiagnostics()];o.emit();let s=i.filter(a=>ne(a,e));if(s.length===0)return{diagnostics:[],ok:!0};let T={getCanonicalFileName:a=>a,getCurrentDirectory:()=>y.dirname(e),getNewLine:()=>`
5
+ `};return{diagnostics:u.formatDiagnosticsWithColorAndContext(s,T).split(`
6
+ `).filter(a=>a.length>0),ok:!1}}function ne(e,n){let t=e.file?.fileName;return t==null?!0:t.startsWith(n)}var te=y.join(".local","tsbuildinfo");function re(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:u.ModuleKind.Preserve,moduleResolution:u.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:u.ScriptTarget.ES2022,tsBuildInfoFile:y.join(e,te)}}import U from"fs";import R from"safe-stable-stringify";import{err as se,ok as N,Result as ae}from"neverthrow";import M from"safe-stable-stringify";import{createHash as oe}from"crypto";import H from"fs";function h(){return S===void 0&&(S=ie()),S}var S;function ie(){let e=process.argv[1];if(e==null)return null;try{let n=H.readFileSync(H.realpathSync(e));return oe("sha256").update(n).digest("hex")}catch{return null}}function I(e){return{...e,checks:void 0,solved:{cosat:{},subsume:{}}}}function Xe(e,n){return M(I(e))===M(I(n))}function O(e){return _(e.checks?.expanderHash,h())}function _(e,n){return e!=null&&n!=null&&e===n}function W(e){return _(e??void 0,h())}async function D(e,n){let t={entities:e.entities,singletonSchemas:e.singletons,valueSpaces:e.valueSpaces},r=le(n),o=ue(e,r),i=await Promise.all(e.workflows.map(s=>de({context:t,reusable:o,workflow:s})));return ae.combine(i).map(s=>({...e,workflows:[...s]}))}function le(e){let n=ce(e);if(!(n==null||!O(n)))return n}function ce(e){if(U.existsSync(e))try{return L(g,U.readFileSync(e,"utf8"))}catch{return}}async function de({context:e,reusable:n,workflow:t}){let r=n.get($(t));if(r!=null)return N({...t,tests:r.tests});try{return N(await B({context:e,workflow:t}))}catch(o){let i=o instanceof Error?o.message:String(o);return se({kind:"expand-failed",message:i,workflow:t.name})}}function $(e){let n=R({...e,tests:[]});if(n==null)throw new Error("solver: workflow is not serializable");return n}function ue(e,n){return n==null||R(z(n))!==R(z(e))?new Map:new Map(n.workflows.map(t=>[$(t),t]))}function z(e){return{entities:e.entities,singletons:e.singletons,valueSpaces:e.valueSpaces}}import{createHash as fe}from"crypto";import J from"fs/promises";import b from"path";import{err as f,ok as F,Result as pe}from"neverthrow";var me=".ripplo/fixtures",ge=10*1024*1024,ye=50*1024*1024;async function K(e,n){let t=he(n);if(t.length===0)return F({});let r=b.join(e,me),o=await Promise.all(t.map(i=>ke({fixturesRoot:r,name:i})));return pe.combine(o).andThen(xe)}function he(e){let t=e.workflows.flatMap(r=>[...r.steps,...r.tests.flatMap(o=>o.steps)]).flatMap(r=>r.action.kind==="upload"?r.action.files:[]);return[...new Set(t)].toSorted((r,o)=>r.localeCompare(o))}async function ke({fixturesRoot:e,name:n}){if(n.includes("..")||b.isAbsolute(n))return f({kind:"fixture-invalid-name",name:n});let t=b.join(e,n),r=await J.lstat(t).catch(()=>null);if(r==null)return f({kind:"fixture-missing",name:n,path:t});if(r.isSymbolicLink())return f({kind:"fixture-symlink",name:n});if(!r.isFile())return f({kind:"fixture-not-file",name:n});let o=await J.readFile(t);if(o.byteLength>ge)return f({kind:"fixture-too-large",name:n,size:o.byteLength});let i=fe("sha256").update(o).digest("hex");return F([n,{sha256:i,size:o.byteLength}])}function xe(e){let n=e.reduce((t,[,r])=>t+r.size,0);return n>ye?f({kind:"fixtures-total-too-large",total:n}):F(Object.fromEntries(e))}import{createHash as Le}from"crypto";import p from"fs";import P from"path";import{z as w}from"zod";function X({cwd:e,fingerprint:n}){let t=Ee(e);if(t==null||t.fingerprint!==E(n))return;let r=P.join(e,".ripplo","ripplo.lock");if(!p.existsSync(r))return;let o=p.readFileSync(r,"utf8");if(E(o)===t.lockfileHash)try{return L(g,o)}catch{return}}function V({cwd:e,fingerprint:n,lockfile:t}){let r={bundle:h(),fingerprint:E(n),lockfileHash:E(v(g,t))},o=Y(e);p.mkdirSync(P.dirname(o),{recursive:!0}),p.writeFileSync(o,JSON.stringify(r))}var we=w.object({bundle:w.string().nullable(),fingerprint:w.string(),lockfileHash:w.string()});function Ee(e){let n=Y(e);if(p.existsSync(n))try{let t=we.safeParse(JSON.parse(p.readFileSync(n,"utf8")));return!t.success||!W(t.data.bundle)?void 0:t.data}catch{return}}function Y(e){return P.join(e,".ripplo",".local","load-cache.json")}function E(e){return Le("sha256").update(e).digest("base64")}var Pe=".ripplo/ripplo.lock",k;async function Pn(e){let{result:n}=await Ce(e);return n}async function Ce(e){let n=q(l.join(e,".ripplo"));if(k!=null&&k.fingerprint===n&&k.result.isOk())return{fingerprint:n,result:k.result};let t=await Te(e);return k={fingerprint:n,result:t},{fingerprint:n,result:t}}async function Te(e){let n=l.join(e,".ripplo"),t=l.join(n,"index.ts"),r=q(n),o=X({cwd:e,fingerprint:r});if(o!=null)return C(o);let i=Be(t);i.catch(()=>{});let s=A(n);if(!s.ok)return x({diagnostics:s.diagnostics,kind:"typecheck-failed"});let a=await(await Ae(t,i)).andThen(d=>Ie({entryPath:t,exported:d})).match(async d=>(await K(e,d)).map(m=>({...d,fixtures:m})).mapErr(m=>({error:m,kind:"fixture-failed"})).asyncAndThen(m=>new Fe(D(m,l.join(e,Pe))).mapErr(Z=>Z)),d=>Promise.resolve(x(d)));return a.isOk()&&V({cwd:e,fingerprint:r,lockfile:a.value}),a}var ve=new Set([".local","debug","node_modules","ripplo.lock"]);function q(e){let n=l.join(e,"..","node_modules","@ripplo","testing","package.json");return[...G(e),...je(n)].toSorted((t,r)=>t.localeCompare(r)).join("|")}function G(e){return(c.existsSync(e)?c.readdirSync(e,{withFileTypes:!0}):[]).flatMap(t=>{if(ve.has(t.name))return[];let r=l.join(e,t.name);if(t.isDirectory())return G(r);let o=c.statSync(r);return[`${r}:${String(o.mtimeMs)}:${String(o.size)}`]})}function je(e){if(!c.existsSync(e))return[];let n=c.statSync(e);return[`${e}:${String(n.mtimeMs)}:${String(n.size)}`]}async function Be(e){let t=(await be({bundle:!0,entryPoints:[e],format:"esm",logLevel:"silent",platform:"node",sourcemap:"inline",target:"node22",write:!1})).outputFiles[0];if(t==null)throw new Error("dsl bundle produced no output");return t.text}async function Ae(e,n){try{let t=await n;process.setSourceMapsEnabled(!0);let r=await import(He(e,t)),o=r!=null&&typeof r=="object"&&"default"in r?Reflect.get(r,"default"):r;return C(o)}catch(t){return x({kind:"load-threw",message:Me(t)})}}function He(e,n){let t=l.join(l.dirname(e),".local");c.mkdirSync(t,{recursive:!0});let r=Se("sha256").update(n).digest("hex").slice(0,16),o=l.join(t,`dsl-bundle-${r}.mjs`);return c.writeFileSync(o,n),Re(o).href}function Me(e){return e instanceof Error?e.message:String(e)}function Ie({entryPath:e,exported:n}){if(n==null||typeof n!="object"||!("lockfile"in n))return x({entryPath:e,kind:"not-ripplo"});let t=j.safeParse(Reflect.get(n,"lockfile"));return t.success?C(t.data):x({issues:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`),kind:"invalid-lockfile"})}export{h as a,Xe as b,O as c,W as d,me as e,ge as f,ye as g,Pe as h,Pn as i,Ce as j,Te as k};
@@ -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{f as a}from"./chunk-EGETJKAQ.js";import{a as n}from"./chunk-AVBP7Q2M.js";import{i}from"./chunk-EK6TENV6.js";import{h as e}from"./chunk-AQ3DMGAY.js";import{i as u}from"./chunk-M7VQD4VO.js";async function x(m){let o=process.cwd(),r=await e(o);r.isErr()&&(process.stderr.write(`${n(r.error)}
4
+ import{f as a}from"./chunk-4H7EIC6W.js";import{a as n}from"./chunk-XZ2TPZLD.js";import{i}from"./chunk-XVMIPWJQ.js";import{k as e}from"./chunk-EVVF662P.js";import{i as u}from"./chunk-PRD7P6EF.js";async function x(m){let o=process.cwd(),r=await e(o);r.isErr()&&(process.stderr.write(`${n(r.error)}
5
5
  `),process.exit(1));let s=i(r.value),t=await a(o);if(m.format==="summary"){s.length>0&&process.stdout.write(`stub workflows: ${s.join(", ")}
6
6
  `),process.stdout.write(`${u(t)}
7
7
  `);return}let p={daemon:t.kind==="running"?{active:t.status.active,explorer:t.status.explorer,exploring:t.status.exploring,progress:t.status.progress,queued:t.status.queued,running:!0}:{running:t.kind==="unresponsive",state:t.kind},tests:s.map(d=>({id:d,implemented:!1}))};process.stdout.write(`${JSON.stringify(p,null,2)}
@@ -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}from"./chunk-7WZ3VIUU.js";import{e as p}from"./chunk-4W6WIT7T.js";import{a as i}from"./chunk-MHNGR6M7.js";import{h as n}from"./chunk-AQ3DMGAY.js";import{c as a}from"./chunk-DBIXYJRB.js";import l from"fs";import d from"path";import*as r from"zod/mini";var c=new Set(["Edit","Write","NotebookEdit"]),u=r.looseObject({file_path:r.string()}),D=async t=>{if(!c.has(t.tool_name))return;let e=m(t);if(e==null)return;let{cwd:o}=t;return l.existsSync(p(o))||a(o)?void 0:(await n(o)).isErr()?{hookSpecificOutput:{additionalContext:`\`ripplo daemon\` isn't running and the DSL isn't compiling, so this edit is allowed through without dev-mode guardrails. Run \`npx ripplo compile\` to see the errors, or \`/ripplo:start\` to bring the daemon up. ${i("create","DSL authoring rules")}`,hookEventName:"PreToolUse"}}:{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`\`ripplo daemon\` is not running \u2014 this edit to \`${e}\` won't sync and dev-mode guardrails won't fire. Run \`/ripplo:start\`, then retry (\`npx ripplo doctor\` checks the daemon and dev server). If the daemon can't start, the user can bypass with \`npx ripplo hooks pause\`. ${i("start")}`}}};function m(t){let e=u.safeParse(t.tool_input);if(!e.success||!s(t.cwd))return null;let o=d.relative(t.cwd,e.data.file_path);return o.startsWith("..")||o!==".ripplo"&&!o.startsWith(".ripplo/")?null:o}export{D as a};
4
+ import{a as s}from"./chunk-7WZ3VIUU.js";import{e as p}from"./chunk-4W6WIT7T.js";import{a as i}from"./chunk-MHNGR6M7.js";import{k as n}from"./chunk-EVVF662P.js";import{c as a}from"./chunk-DBIXYJRB.js";import l from"fs";import d from"path";import*as r from"zod/mini";var c=new Set(["Edit","Write","NotebookEdit"]),u=r.looseObject({file_path:r.string()}),D=async t=>{if(!c.has(t.tool_name))return;let e=m(t);if(e==null)return;let{cwd:o}=t;return l.existsSync(p(o))||a(o)?void 0:(await n(o)).isErr()?{hookSpecificOutput:{additionalContext:`\`ripplo daemon\` isn't running and the DSL isn't compiling, so this edit is allowed through without dev-mode guardrails. Run \`npx ripplo compile\` to see the errors, or \`/ripplo:start\` to bring the daemon up. ${i("create","DSL authoring rules")}`,hookEventName:"PreToolUse"}}:{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`\`ripplo daemon\` is not running \u2014 this edit to \`${e}\` won't sync and dev-mode guardrails won't fire. Run \`/ripplo:start\`, then retry (\`npx ripplo doctor\` checks the daemon and dev server). If the daemon can't start, the user can bypass with \`npx ripplo hooks pause\`. ${i("start")}`}}};function m(t){let e=u.safeParse(t.tool_input);if(!e.success||!s(t.cwd))return null;let o=d.relative(t.cwd,e.data.file_path);return o.startsWith("..")||o!==".ripplo"&&!o.startsWith(".ripplo/")?null:o}export{D 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{a as r}from"./chunk-OQ6KNYPG.js";import{a as s}from"./chunk-MHNGR6M7.js";import{a as k,b as C,c as F,d as b}from"./chunk-EK6TENV6.js";import{L as $,f as u,k as c,n as f,p as m,q as p,r as g,s as y,t as h,u as S,v,w as o}from"./chunk-ESOXRGIY.js";import{A as d,H as l}from"./chunk-5SM4TCSW.js";async function P({cwd:e,lockfile:n}){let i=c(n),a=b(d(l,n));if(C({context:i,cwd:e})===a)return[];k({context:i,cwd:e});let t=await x(n);return F({cleanLockfileHash:t.length===0?a:null,context:i,cwd:e}),t}async function x(e){let n=u(e),i=await f(e),a=await m({context:c(e),facts:i.facts});return[...g(e).map(t=>({kind:"missing-precondition",missing:t})),...p(n,i.dataRules).map(t=>({gap:t,kind:"cascade-gap"})),...a.map(t=>({conflict:t,kind:"fact-conflict"})),...y(e).map(t=>({kind:"unreachable-interaction",violation:t})),...h(e).map(t=>({kind:"redundant-assertion",redundancy:t})),...S(e).map(t=>({kind:"unmodeled-surface",surface:t})),...v(e).map(t=>({content:t,kind:"unpinned-surface-content"}))]}function U(e){return`${o.good("ok")} \u2014 no static model violations (${r(e,"test")})`}function O(e){let i=e.some(a=>a.kind==="unmodeled-surface")?[`Elements that hide together are one surface. ${s("create","surfaces")}`]:[];return[`${o.bad("fail")} \u2014 ${r(e.length,"static model violation")}:`,...e.map(a=>$(a)),...i].join(`
4
+ import{a as r}from"./chunk-OQ6KNYPG.js";import{a as s}from"./chunk-MHNGR6M7.js";import{a as k,b as C,c as F,d as b}from"./chunk-XVMIPWJQ.js";import{L as $,f as u,k as c,n as f,p as m,q as p,r as g,s as y,t as h,u as S,v,w as o}from"./chunk-BR7W4UBJ.js";import{E as d,L as l}from"./chunk-4F67XQYS.js";async function P({cwd:e,lockfile:n}){let i=c(n),a=b(d(l,n));if(C({context:i,cwd:e})===a)return[];k({context:i,cwd:e});let t=await x(n);return F({cleanLockfileHash:t.length===0?a:null,context:i,cwd:e}),t}async function x(e){let n=u(e),i=await f(e),a=await m({context:c(e),facts:i.facts});return[...g(e).map(t=>({kind:"missing-precondition",missing:t})),...p(n,i.dataRules).map(t=>({gap:t,kind:"cascade-gap"})),...a.map(t=>({conflict:t,kind:"fact-conflict"})),...y(e).map(t=>({kind:"unreachable-interaction",violation:t})),...h(e).map(t=>({kind:"redundant-assertion",redundancy:t})),...S(e).map(t=>({kind:"unmodeled-surface",surface:t})),...v(e).map(t=>({content:t,kind:"unpinned-surface-content"}))]}function U(e){return`${o.good("ok")} \u2014 no static model violations (${r(e,"test")})`}function O(e){let i=e.some(a=>a.kind==="unmodeled-surface")?[`Elements that hide together are one surface. ${s("create","surfaces")}`]:[];return[`${o.bad("fail")} \u2014 ${r(e.length,"static model violation")}:`,...e.map(a=>$(a)),...i].join(`
5
5
 
6
6
  `)}function E(e){return[`${o.warn("warn")} \u2014 ${r(e.length,"model coverage gap")} (not blocking):`,...e.map(n=>` ${A(n)}`),`Stub the missing flows. ${s("discover")}`].join(`
7
7
  `)}function A(e){switch(e.kind){case"entity-never-given":return`${e.entity} \u2014 declared but no test seeds it`;case"entity-never-mutated":return`${e.entity} \u2014 seeded but never asserted created/updated/deleted`;case"unmatchable-delete-key":return`test ${e.workflow}/${e.testSlug} asserts ${e.entity} deleted with literal ${e.field} but no seeded ${e.entity} sets ${e.field} \u2014 solver treats it as no-match`}}export{P as a,U as b,O as c,E as d};
@@ -0,0 +1,6 @@
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 i,C as s,F as d,i as t}from"./chunk-BR7W4UBJ.js";function y(e){switch(e.kind){case"empty-response":return"ripplo daemon: cloud tunnel provisioning returned no result. Check server logs and retry.";case"server-error":return`ripplo daemon: cloud tunnel provisioning failed (${e.typename}). Run \`npx ripplo doctor\` to check your setup.`}}function $(e){switch(e.kind){case"already-running":return`ripplo daemon: daemon already running (socket ${e.socketPath}).`;case"bind-failed":return`ripplo daemon: failed to bind IPC socket: ${e.message}`}}function b({projectId:e,serverUrl:n}){return[`Project "${e}" (from .ripplo/project.json) was not found on ${n}, or this account does not have access to it.`,"Run `npx ripplo projects list` to see your projects, then update .ripplo/project.json (or re-run `npx ripplo init --project <id>`)."].join(`
5
+ `)}function w(){return"Not signed in. Run `npx ripplo auth login`, then start the daemon again."}function v({devSessionId:e,version:n}){return`ripplo daemon: v${n} ready as local executor for session ${e} (switch with \`npx ripplo executor cloud\` \u2014 Ctrl-C to stop)`}function S({cwd:e,pid:n}){return`ripplo daemon: another daemon is already running for this project${n==null?"":` (pid ${String(n)})`} (cwd ${e}) \u2014 this one is exiting. Run \`npx ripplo daemon status\` to inspect it, or \`npx ripplo daemon stop\` to stop it.`}function j(e){switch(e.kind){case"not-running":return"ripplo daemon: not running.";case"stopped":return`ripplo daemon: stopped (pid ${String(e.pid)}).`;case"timeout":return`ripplo daemon: pid ${String(e.pid)} did not exit within 10s \u2014 it may be finishing a run. Check again with \`npx ripplo daemon status\`.`}}function R(){return"ripplo daemon: lock compromised \u2014 another daemon likely took over this project. Shutting down."}function P(e){if(e.kind==="not-running")return"daemon: not running";if(e.kind==="unresponsive")return`daemon: running but no reply within ${String(e.timeoutMs/1e3)}s \u2014 likely busy executing runs, retry when the batch drains`;let{status:n}=e,r=n.version==null?"version unknown (pre-0.7.8)":`v${n.version}`,p=`${String(n.active)} active, ${String(n.queued)} queued`,l=m(n.explorer,n.exploring),o=`daemon: running (${r} | ${p} | ${l} | ${u(n.progress)})`;if(n.sseHealth!=null&&!n.sseHealth.ok){let c=n.sseHealth.detail==null?"":`: ${n.sseHealth.detail}`;return`${o}
6
+ daemon: cannot subscribe to run dispatch${c} \u2014 server-side, restarting the daemon will not help`}return o}function u(e){return e.attempts===0?"explore: idle":`explore: ${String(e.attempts)} attempts, ${String(e.findings)} findings`}function D(e){let n=e.daemonVersion==null?"an older build":`v${e.daemonVersion}`;return e.kind==="restarted"?`ripplo: daemon was on ${n} \u2014 restarted on the current build`:`ripplo: daemon is on a stale build (${n}) with runs in flight \u2014 rerun once it drains, or npx ripplo daemon restart`}function F(e){switch(e.kind){case"pass":return{kind:"pass"};case"findings":return{findingLines:f(e.findings).map(n=>d({evidencePath:`.ripplo/debug/${e.runId}/behavior.jsonl`,finding:n})),kind:"findings"};case"error":return{detail:t(e.error),kind:"error"};case"dispatch-failed":return{kind:"dispatch-error",reason:{detail:e.reason,type:"generic"}}}}function m(e,n){switch(e.kind){case"off":return"explorer: off";case"on":return`explorer: on, ${String(n)} exploring`;case"paused":return"explorer: paused for active runs or a short cooldown \u2014 resumes on its own";case"blocked":return`explorer: blocked \u2014 ${g(e.reason)}`}}function g(e){switch(e){case"no-lockfile":return"no lockfile found, run npx ripplo compile";case"unstamped":return"lockfile has no compiled checks, run npx ripplo compile";case"expander-newer":return"lockfile predates the current CLI build, run npx ripplo compile";case"dsl-drift":return"workflow sources changed since the last compile, run npx ripplo compile";case"load-failed":return"workflow definitions do not compile, run npx ripplo compile for details"}}function f(e){let n=new Set(e.flatMap(r=>h(r)?[a(r)]:[]));return e.filter(r=>!(k(r)&&n.has(a(r))))}function h(e){return e.kind==="pending-check"&&e.source.kind==="step"}function a(e){return e.kind!=="pending-check"||e.source.kind==="data-rule"?"":`${i(e.source.check)}|${s(e.step)}`}function k(e){return e.kind==="pending-check"&&e.source.kind==="fact"}export{y as a,$ as b,b as c,w as d,v as e,S as f,j as g,R as h,P as i,u as j,D as k,F as l};
@@ -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 o}from"./chunk-AVBP7Q2M.js";import{a as t}from"./chunk-MHNGR6M7.js";var r=class extends Error{failure;constructor(i){super(i.kind),this.name="CliError",this.failure=i}};function u(e){return e instanceof r?a(e.failure):e instanceof Error?e.message:String(e)}function a(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).",t("setup")].join(`
4
+ import{a as o}from"./chunk-XZ2TPZLD.js";import{a as t}from"./chunk-MHNGR6M7.js";var r=class extends Error{failure;constructor(i){super(i.kind),this.name="CliError",this.failure=i}};function u(e){return e instanceof r?a(e.failure):e instanceof Error?e.message:String(e)}function a(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).",t("setup")].join(`
5
5
  `);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(i=>` ${i}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
6
6
  `);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(`
7
7
  `);case"env-invalid":return s(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(`
@@ -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-T5VLZ43M.js";import{a as m}from"./chunk-MOI4L3EX.js";import{a as u,c as y,d as g}from"./chunk-PXZV5X3C.js";import{a as h}from"./chunk-OQ6KNYPG.js";import{f as S}from"./chunk-UVYCSHOJ.js";import{a as c}from"./chunk-7WZ3VIUU.js";import{f as k}from"./chunk-4W6WIT7T.js";import{a as l}from"./chunk-AVBP7Q2M.js";import{a as s}from"./chunk-MHNGR6M7.js";import{e as f,f as p}from"./chunk-EK6TENV6.js";import{e as d}from"./chunk-ESOXRGIY.js";import{createHash as b}from"crypto";import*as a from"zod/mini";var v=a.looseObject({file_path:a.string()}),M=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)}
4
+ import{b as w,c as P}from"./chunk-T5VLZ43M.js";import{a as m}from"./chunk-MOI4L3EX.js";import{a as u,c as y,d as g}from"./chunk-JXGIARTE.js";import{a as h}from"./chunk-OQ6KNYPG.js";import{f as S}from"./chunk-ZUPS6XVH.js";import{a as c}from"./chunk-7WZ3VIUU.js";import{f as k}from"./chunk-4W6WIT7T.js";import{a as l}from"./chunk-XZ2TPZLD.js";import{a as s}from"./chunk-MHNGR6M7.js";import{e as f,f as p}from"./chunk-XVMIPWJQ.js";import{e as d}from"./chunk-BR7W4UBJ.js";import{createHash as b}from"crypto";import*as a from"zod/mini";var v=a.looseObject({file_path:a.string()}),M=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 N({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});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()]:[],...T(o,r)]}async function N({cwd:e,filePath:o,lockfile:t}){let r=await u({cwd:e,lockfile:t});await p(e,t);let n=R(r,t,o),i=r.length-n.length;return n.length===0?{elsewhere:i}:{block:`${y(n)}${A(i)}
6
6
  ${s("create")}`}}function R(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=F(n);return i==null||r.has(i)})}function F(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(`
@@ -0,0 +1,229 @@
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 We,f as Ke,g as Be,j as Ve,n as Qe,o as Je,p as ze,q as Ge,r as Ye}from"./chunk-WZBLSDNV.js";import{c as Xe,e as Ze,g as en}from"./chunk-ZUPS6XVH.js";import{c as F}from"./chunk-LEFXRK53.js";import{d as _e}from"./chunk-4W6WIT7T.js";import{a as $}from"./chunk-R4ZTRVDQ.js";import{d as he}from"./chunk-FEHVIHVA.js";import{b as be}from"./chunk-Q6IYTHMP.js";import{a as xe}from"./chunk-XZ2TPZLD.js";import{g as He}from"./chunk-XVMIPWJQ.js";import{e as ke,i as Se,j as we,k as ve}from"./chunk-EVVF662P.js";import{c as D}from"./chunk-DBIXYJRB.js";import{a as me,d as u,f as p}from"./chunk-PE5WVWI5.js";import{$ as Le,B as Me,D as v,E as $e,G as je,H as Fe,J as De,N as Oe,W as Ue,X as Ne,_ as qe,a as Ee,b as Ie,c as Y,d as R,e as T,f as Te,g as Ae,h as Ce,i as j,z as Pe}from"./chunk-BR7W4UBJ.js";import{Q as M,R as m,i as P,l as I,m as Re}from"./chunk-4F67XQYS.js";import Gn from"p-queue";var Yn=4,Xn={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},O=new Gn({concurrency:Yn}),k={headedActive:0,interactiveActive:0,interactiveQueued:0},nn={current:null};function mo({headed:e,task:n,workClass:t}){let r=Xn[t];return t==="p3-explore"?O.add(n,{priority:r}):(k.interactiveQueued+=1,U(),O.add(()=>Zn({headed:e,task:n}),{priority:r}))}function ho(e){!Number.isFinite(e)||e<1||(O.concurrency=Math.floor(e),U())}function X(){return{active:k.interactiveActive,headedActive:k.headedActive,poolSize:O.concurrency,queued:k.interactiveQueued}}function Ro(e){nn.current=e}async function Zn({headed:e,task:n}){k.interactiveQueued-=1,k.interactiveActive+=1,k.headedActive+=e?1:0,U();try{return await n()}finally{k.interactiveActive-=1,k.headedActive-=e?1:0,U()}}function U(){nn.current?.()}async function tn(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 rn(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 et}from"gql.tada";async function on(e,n){let r=(await u({config:e,document:nt,variables:{cwd:n,projectId:e.projectId}})).project?.devSession?.workflows??[];return new Map(r.flatMap(o=>o.tests.map(i=>[`${o.slug}/${i.slug}`,{testId:i.id,workflowId:o.id}])))}var nt=et(`
5
+ query DaemonWorkflows($projectId: String!, $cwd: String!) {
6
+ project(id: $projectId) {
7
+ id
8
+ devSession(cwd: $cwd) {
9
+ id
10
+ workflows {
11
+ id
12
+ slug
13
+ tests {
14
+ id
15
+ slug
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
21
+ `);import{err as Z,ok as an}from"neverthrow";function ln({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return Z({kind:"conflicting-flags"});if(e)return an(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>R(s))));if(n.length===0)return Z({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:rt(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?Z({kind:"unknown-ids",known:tt(t),unknown:o}):an([...new Set(r.flatMap(i=>i.refs))])}function dn(e,n){let t=new Map(T(e).map(r=>[r.ref,{testName:r.test.name,testSlug:r.test.slug,workflowName:r.workflow.name,workflowSlug:m(r.workflow.name)}]));return n.map(r=>{let o=t.get(r);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${r}`);return o})}function tt(e){return e.workflows.map(n=>m(n.name))}function rt(e,n){let t=e.workflows.find(r=>r.name===n||m(r.name)===m(n));return t!=null?t.tests.map(r=>R(r)):T(e).filter(r=>r.ref===n||sn(r.ref)===sn(n)).map(r=>r.ref)}function sn(e){let n=e.lastIndexOf("/");return n===-1?m(e):`${m(e.slice(0,n))}/${m(e.slice(n+1))}`}import{err as ee,ok as cn}from"neverthrow";import{graphql as un}from"gql.tada";async function pn({config:e,cwd:n,lockfile:t}){await it({config:e,cwd:n,lockfile:t});let r=await st(e);if(r.isErr())return ee(r.error);let o=new Map(t.workflows.filter(s=>!s.stub).map(s=>[m(s.name),s])),i=[...new Set(r.value)].flatMap(s=>{let a=o.get(s);return a==null?[]:a.tests.map(l=>R(l))});return i.length===0?ee({kind:"scope-empty"}):cn(i)}var ot=un(`
22
+ mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
23
+ addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
24
+ __typename
25
+ }
26
+ }
27
+ `);async function it({config:e,cwd:n,lockfile:t}){let r=new Set(en(n)),o=t.workflows.filter(i=>i.sourcePath!=null&&r.has(i.sourcePath)).map(i=>m(i.name));o.length!==0&&await u({config:e,document:ot,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{p.warn({err:i},"auto-scope of dirty tests failed")})}var at=un(`
28
+ query ScopeSelection($projectId: String!, $cwd: String!) {
29
+ project(id: $projectId) {
30
+ id
31
+ devSession(cwd: $cwd) {
32
+ id
33
+ scopeItems {
34
+ id
35
+ workflow {
36
+ id
37
+ slug
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ `);async function st(e){try{let t=(await u({config:e,document:at,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return cn(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return ee({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}var ne=new Set,fn=new Map;function Ho(e){ne.add(e)}function lt(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 yn({config:e,cwd:n,message:t}){return(await Se(n)).match(o=>dt({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...lt(o)]},kind:"error"}))}async function dt({config:e,cwd:n,lockfile:t,message:r}){let o=await tn(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await rn(e.engineUrl);if(i!=null)return{error:{code:"engine-unreachable",detail:i,url:e.engineUrl},kind:"error"};let s=await Ze(n);if(s==null)return{error:{code:"sync-failed",detail:"lockfile-missing"},kind:"error"};if(!ne.has(s)){let l=await ut({config:e,cwd:n,lockfile:t});if(l!=null)return{error:{code:"sync-failed",detail:l},kind:"error"};ne.add(s)}return(await pt({config:e,cwd:n,lockfile:t,message:r})).match(async l=>({kind:"ready",lockfileHashValue:s,selections:dn(t,l),targetsByClaimKey:await ct({config:e,cwd:n,hash:s})}),l=>Promise.resolve({error:l,kind:"error"}))}async function ct({config:e,cwd:n,hash:t}){let r=fn.get(t);if(r!=null)return r;let o=await on(e,n);return fn.set(t,o),o}async function ut(e){try{return await Xe(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function pt({config:e,cwd:n,lockfile:t,message:r}){return!r.all&&r.tests.length===0?(await pn({config:e,cwd:n,lockfile:t})).mapErr(ft):ln({all:r.all,ids:r.tests,lockfile:t}).mapErr(yt)}function ft(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function yt(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]}}}import{randomUUID as Et}from"crypto";import{createId as It}from"@paralleldrive/cuid2";import{CancellationTokenSource as In,ResponseError as Tt}from"vscode-jsonrpc/node";import{graphql as gt}from"gql.tada";var mt=gt(`
44
+ mutation DaemonCreateRun(
45
+ $id: String
46
+ $workflowId: String!
47
+ $testId: String
48
+ $clientVersion: String
49
+ $executor: RunExecutor
50
+ $target: RunTarget
51
+ $lockfileHash: String
52
+ ) {
53
+ createRun(
54
+ id: $id
55
+ workflowId: $workflowId
56
+ testId: $testId
57
+ executor: $executor
58
+ target: $target
59
+ clientVersion: $clientVersion
60
+ lockfileHash: $lockfileHash
61
+ ) {
62
+ __typename
63
+ ... on MutationCreateRunSuccess {
64
+ data {
65
+ id
66
+ }
67
+ }
68
+ ... on LimitExceededError {
69
+ code
70
+ }
71
+ }
72
+ }
73
+ `);async function gn(e){try{let t=(await u({config:e.config,document:mt,variables:ht(e)})).createRun;return t==null?N({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?N({code:t.code,type:"limit"}):N({detail:t.__typename,type:"generic"})}catch(n){return Rt(n)}}function ht({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:$(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function N(e){return{kind:"dispatch-error",reason:e}}function Rt(e){return e instanceof me?{detail:e.message,kind:"infra-error"}:N({detail:e instanceof Error?e.message:String(e),type:"generic"})}function mn(){return new Map}function q(e){return`${e.workflowSlug}/${e.testSlug}`}function kt(e){return`${q(e)}@${e.lockfileHash}@${String(e.headed)}`}function hn(e,n){let t=kt(n.identity),r=e.get(t);if(r!=null){let i={...r,jobIds:new Set([...r.jobIds,n.jobId])};return{entry:i,kind:"joined",state:te(e,i)}}let o={claimed:!1,claimKey:q(n.identity),deadlineAt:n.deadlineAt,headed:n.identity.headed,inflightKey:t,jobIds:new Set([n.jobId]),runId:n.runId,testName:n.testName,workflowName:n.workflowName};return{entry:o,kind:"created",state:te(e,o)}}function te(e,n){return new Map([...e,[n.inflightKey,n]])}function re(e,n){let t=[...e.values()].find(o=>o.runId===n&&!o.claimed);if(t==null)return{entry:null,state:e};let r={...t,claimed:!0};return{entry:r,state:te(e,r)}}function Rn(e,n){return new Map([...e].filter(([t])=>t!==n))}function kn(e,n){let t=[...e.values()].filter(a=>a.jobIds.has(n)),r=t.filter(a=>a.jobIds.size===1),o=t.filter(a=>a.jobIds.size>1).map(a=>({...a,jobIds:new Set([...a.jobIds].filter(l=>l!==n))})),i=new Set(r.map(a=>a.inflightKey)),s=new Map([...e].filter(([a])=>!i.has(a)).map(([a,l])=>{let c=o.find(d=>d.inflightKey===a);return[a,c??l]}));return{cancelled:r,state:s}}function Sn(e,n){let t=[...e.values()].filter(o=>!o.claimed&&o.deadlineAt<=n),r=new Set(t.map(o=>o.inflightKey));return{expired:t,state:new Map([...e].filter(([o])=>!r.has(o)))}}import{graphql as St}from"gql.tada";var wt=2e3,vt=St(`
74
+ query DaemonCloudRunStatus($runId: String!) {
75
+ run(id: $runId) {
76
+ status
77
+ failureReason
78
+ }
79
+ }
80
+ `);function vn({config:e,onComplete:n,onStarted:t,runId:r,signal:o}){let i=!1,s,a=!1,l=async()=>{if(i||o.aborted)return;let c=await xt(e,r).catch(()=>"unknown");if(!(i||o.aborted)){if(!a&&(c==="running"||wn(c))&&(a=!0,t()),wn(c)){i=!0,n(bt(c));return}s=setTimeout(()=>{l()},wt)}};return l(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function xt(e,n){let r=(await u({config:e,document:vt,variables:{runId:n}})).run?.status;return r??"unknown"}function wn(e){return e==="passed"||e==="failed"||e==="cancelled"||e==="unready"}function bt(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 At=We(process.argv[1]),xn=12e4,Ct=-32099;function Pt(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function di(e){let n={...e,cancellations:new Map,cell:{inflight:mn()},jobs:new Map,timers:new Map};return{claim:t=>Ot(n,t),handleConnection:t=>{Mt(n,t)},idle:()=>Tn(n)}}function Mt(e,n){let t=Ke(n);t.onRequest(Qe,(r,o)=>$t({connection:t,ctx:e,params:r,token:o})),t.onRequest(Je,()=>{let r=X();return{active:r.active,bundleMtimeMs:At,queued:r.queued,sseHealth:e.sseHealth(),version:$(),...e.explorationStatus()}}),t.onRequest(ze,()=>{let r=Tn(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{Dt(e,t)}),t.onError(r=>{p.warn({err:r},"ipc connection error")}),n.on("error",r=>{p.warn({err:r},"ipc socket error")}),t.listen()}function Tn(e){let n=X();return e.jobs.size===0&&n.active===0&&n.queued===0}async function $t({connection:e,ctx:n,params:t,token:r}){let o=Be.safeParse(t);if(!o.success)throw bn({code:"bad-message"});await n.ready;let i=await yn({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw bn(i.error);let s=Et(),a=new In;return r.onCancellationRequested(()=>{An(n,s)}),n.jobs.set(s,{cancellation:a,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),Ut({ctx:n,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:a.token}).catch(l=>{p.error({err:l},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function bn(e){return new Tt(Ct,e.code,e)}function An(e,n){let t=e.jobs.get(n);if(t==null)return;t.cancellation.cancel(),e.jobs.delete(n);let r=kn(e.cell.inflight,n);e.cell.inflight=r.state,r.cancelled.forEach(o=>{C(e,o.inflightKey,"cancel")})}function C(e,n,t){let r=e.timers.get(n);r!=null&&(clearTimeout(r),e.timers.delete(n)),t==="cancel"&&(e.cancellations.get(n)?.cancel(),e.cancellations.delete(n))}function oe(e,n,t){e.cell.inflight=Rn(e.cell.inflight,n),C(e,n,t),t==="keep"&&e.cancellations.delete(n)}function jt(e){let n=Sn(e.cell.inflight,Date.now());e.cell.inflight=n.state,n.expired.forEach(t=>{C(e,t.inflightKey,"cancel"),x(e,t,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:t.testName,workflowName:t.workflowName})})}function x(e,n,t){n.jobIds.forEach(r=>{Cn(e,r,t)})}function Cn(e,n,t){let r=e.jobs.get(n);r!=null&&(En(()=>r.connection.sendNotification(Ge,{event:t,jobId:n})),t.kind==="test-outcome"&&(Ft(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(En(()=>r.connection.sendNotification(Ye,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function En(e){Promise.resolve().then(e).catch(n=>{p.warn({err:n},"ipc notification failed")})}function Ft(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 Dt(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{An(e,t)})}function Ot(e,n){let t=re(e.cell.inflight,n);e.cell.inflight=t.state;let r=t.entry;if(r==null)return null;C(e,r.inflightKey,"keep");let o=e.cancellations.get(r.inflightKey);return o==null?null:{headed:r.headed,token:o.token,finished:(i,s)=>{let a=A(e,r);oe(e,r.inflightKey,"keep"),x(e,a,{kind:"test-outcome",outcome:s,runId:r.runId,testName:r.testName,workflowName:r.workflowName})},started:()=>{x(e,A(e,r),{kind:"test-started",runId:r.runId,testName:r.testName,workflowName:r.workflowName})}}}async function Ut(e){await e.selections.reduce((n,t)=>n.then(()=>Nt(e,t)),Promise.resolve())}async function Nt(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:a}=e;if(a.isCancellationRequested)return;let l=q(n),c=s.get(l);if(c==null){Cn(t,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=hn(t.cell.inflight,{deadlineAt:Date.now()+xn,identity:{headed:r,lockfileHash:i,testSlug:n.testSlug,workflowSlug:n.workflowSlug},jobId:o,runId:It(),testName:n.testName,workflowName:n.workflowName});if(t.cell.inflight=d.state,d.kind==="joined")return;let f=d.entry;t.cancellations.set(f.inflightKey,new In),t.timers.set(f.inflightKey,setTimeout(()=>{jt(t)},xn));let y=t.executor(),g=await qt({ctx:t,entry:f,executor:y,lockfileHashValue:i,target:c});if(g!=null){let w=A(t,f);oe(t,f.inflightKey,"cancel"),x(t,w,{kind:"test-outcome",outcome:g,runId:"",testName:n.testName,workflowName:n.workflowName});return}y==="cloud"&&Lt(t,f)}function A(e,n){return e.cell.inflight.get(n.inflightKey)??n}function qt({ctx:e,entry:n,executor:t,lockfileHashValue:r,target:o}){return gn({config:e.config,executor:t,lockfileHash:r,runId:n.runId,target:o})}function Lt(e,n){let t=re(e.cell.inflight,n.runId);e.cell.inflight=t.state;let r=t.entry;if(r==null)return;C(e,r.inflightKey,"keep");let o=e.cancellations.get(r.inflightKey);o!=null&&vn({config:e.config,runId:r.runId,signal:Pt(o.token),onComplete:i=>{let s=A(e,r);oe(e,r.inflightKey,"keep"),x(e,s,{kind:"test-outcome",outcome:i,runId:r.runId,testName:r.testName,workflowName:r.workflowName})},onStarted:()=>{x(e,A(e,r),{kind:"test-started",runId:r.runId,testName:r.testName,workflowName:r.workflowName})}})}import{graphql as b}from"gql.tada";import{gzipSync as zt}from"zlib";import{appendFileSync as Gt,existsSync as H,readFileSync as Fn,writeFileSync as jn}from"fs";import S from"path";import{graphql as ae}from"gql.tada";function L(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}function Pn(e,n){return{kind:"finding",payload:Kt(e),source:"verifier",step:n.step,stepIndex:n.stepIndex,timeNanos:n.timeNanos}}var Ht={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},_t={"data-rule":"dataRule",fact:"fact",step:"step"},Wt={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 Kt(e){return e.kind==="consistency"?{kind:"mismatch",mismatch:Jt(e.mismatch),pending:e.pending,wait:e.budget,waitMs:Y[e.budget]}:e.kind==="pending-check"?{...Bt(e.source),kind:"pendingCheck",source:_t[e.source.kind],wait:e.budget,waitMs:Y[e.budget]}:e.kind==="unrunnable"?{kind:"unrunnable",reason:Ht[e.reason],unmet:e.unmet==null?void 0:Fe(e.unmet)}:e.kind==="impossible-action"?{action:Vt(e.step.action),kind:"impossibleAction",subject:$n(e.step.action)}:e.kind==="lift-visibility"?{declaredIndex:e.declaredIndex,kind:"liftVisibility",subject:I(e.locator),visibleIndex:e.visibleIndex}:{errorKind:Wt[e.error.kind],kind:"driverError",message:Qt(e.error)}}function Bt(e){return"check"in e?Mn(e.check,!1):{checkKind:null,expected:null,negated:!1,subject:Me(e.dataRule)}}function Mn(e,n){return e.kind==="not"?Mn(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value??null,negated:n,subject:Ee(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 Vt(e){return`${e.kind} ${$n(e)}`.trim()}function $n(e){return e.locator==null?e.url??"":I(e.locator)}function Qt(e){return"message"in e?e.message:"detail"in e?e.detail:null}function Jt(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:$e(e.want),kind:"scalarMismatch",subject:Pe(e.subject),subjectKey:Ie(e.subject)}:e.kind==="missing-row"?{entity:e.entity,key:e.key,kind:"missingRow"}:{entity:e.entity,key:e.key,kind:"unexpectedRow"}}function W({config:e,fixturesDir:n,headed:t}){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:P,headed:t,secret:e.webhookSecret}}async function se(e){let n=K(e);await le(e.config,e.runId,n)}function K({debugDir:e,events:n,recordingOptional:t,runId:r,stepSources:o}){let i=de(n),s=or(e,r);if(s==null&&!t)throw new Error("recording-missing");let a=i.map((c,d)=>gr({aliases:[...sr(n),...lr(i)],generated:dr(n),generatedSingletons:cr(n),origin:s==null?rr(i):s.origin,record:c,rrwebEvents:s==null?[]:s.events,sourceTest:o?.[d]??null})),l=i.flatMap(c=>c.findings.map(d=>Pn(d,{step:L(M(c.source,c.index)),stepIndex:c.index,timeNanos:Dn(c)})));return Yt({debugDir:e,events:[...a,...l],runId:r}),i}function Yt({debugDir:e,events:n,runId:t}){if(n.length===0)return;let r=S.join(e,t,"behavior.jsonl");if(!H(r))return;let o=n.map(i=>JSON.stringify(i)).join(`
81
+ `);Gt(r,`${o}
82
+ `)}function Dn(e){return String(BigInt(Math.max(0,Math.round(e.endMs)))*1000000n)}async function le(e,n,t){let r=t.filter(s=>s.findings.length>0).length,o=t.length-r,i=t.reduce((s,a)=>s+Math.max(0,a.endMs-a.startMs),0);await u({config:e,document:Rr,variables:{items:[{duration:i,failCount:r,firstFailedStepTitle:Xt(t),passCount:o,runId:n,status:r>0?"failed":"passed"}]}})}function Xt(e){let n=e.filter(t=>t.findings.length>0).toSorted((t,r)=>t.index-r.index).at(0);return n==null?null:L(M(n.source,n.index))}function de(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 On(e,n){await u({config:e,document:kr,variables:{runIds:[n]}})}var _=".uploaded";async function Zt({config:e,debugDir:n,runId:t}){let r=S.join(n,t),o=S.join(r,"behavior.jsonl");if(H(S.join(r,_)))return;if(!H(o)){p.warn({runId:t},"behavior upload skipped: behavior.jsonl missing on disk");return}await[0,1e3,3e3].reduce((s,a)=>s.then(async l=>l?!0:(await new Promise(c=>setTimeout(c,a)),er({behaviorPath:o,config:e,runDir:r,runId:t}))),Promise.resolve(!1))}async function er({behaviorPath:e,config:n,runDir:t,runId:r}){try{let o=await u({config:n,document:hr,variables:{runId:r}}),i=await fetch(o.debugArtifactUploadUrl,{body:zt(Fn(e)),headers:{"content-type":tr},method:"PUT"});return i.ok?(await On(n,r),jn(S.join(t,_),""),!0):(p.warn({runId:r,status:i.status},"behavior upload PUT failed"),!1)}catch(o){return nr(o)?(p.warn({runId:r},"behavior upload refused by server; run unknown \u2014 not retrying"),jn(S.join(t,_),""),!0):(p.warn({error:o,runId:r},"behavior upload failed"),!1)}}function nr(e){if(typeof e!="object"||e==null||!("errors"in e))return!1;let{errors:n}=e;return Array.isArray(n)&&n.some(t=>{if(typeof t!="object"||t==null||!("extensions"in t))return!1;let{extensions:r}=t;return typeof r=="object"&&r!=null&&"code"in r&&r.code==="FORBIDDEN"})}var tr="application/x-ndjson";function rr(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function or(e,n){let t=S.join(e,n,"behavior.jsonl");if(!H(t))return null;let r=Fn(t,"utf8").split(`
83
+ `).filter(i=>i.length>0).map(i=>ir(i)).flatMap(i=>ar(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function ir(e){return JSON.parse(e)}function ar(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function sr(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function lr(e){return e.flatMap(n=>{let t=ur(n.source);return t.flatMap(r=>{let i=t.filter(a=>a.entity===r.entity).indexOf(r),s=n.state.rows.filter(a=>a.status==="created"&&a.entity===r.entity).at(i);return s==null?[]:[{alias:r.as,entity:r.entity,key:s.key}]})})}function dr(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>Un(t)):[]))}function Un({entity:e,field:n,key:t}){return`${e} ${t} ${n}`}function cr(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function ur(e){return e==null?[]:e.expect.flatMap(n=>ie(n))}function ie(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>ie(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(t=>ie(t))):[]}var pr=3,fr=0;function yr({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===pr&&o.data?.source===fr&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function gr({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let a=M(o.source,o.index),l=yr({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"?l:d.atMs)-r),rrwebIds:[...d.rrwebIds],url:d.url,value:d.value??null}))],duration:Math.max(0,o.endMs-o.startMs),kind:"step",nodeType:a.kind,pageUrl:o.url,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,l-r),source:"verifier",sourceTest:s,stateRows:o.state.rows.map(d=>mr({aliases:e,generated:n,row:d})),stateSingletons:o.state.singletons.map(d=>({changed:d.changed,generated:t.has(d.name),name:d.name,value:d.value==null?null:String(d.value)})),stepIndex:o.index,timeNanos:Dn(o),title:L(a)}}function mr({aliases:e,generated:n,row:t}){let r=e.find(o=>o.entity===t.entity&&o.key===t.key);return{entity:t.entity,fields:t.fields.map(o=>({changed:o.changed,field:o.field,generated:n.has(Un({entity:t.entity,field:o.field,key:t.key})),value:o.value==null?null:String(o.value)})),key:t.key,label:r?.alias??t.key,status:t.status}}var hr=ae(`
84
+ mutation DebugArtifactUploadUrl($runId: String!) {
85
+ debugArtifactUploadUrl(runId: $runId)
86
+ }
87
+ `),Rr=ae(`
88
+ mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
89
+ completeRunsBatch(items: $items) {
90
+ id
91
+ status
92
+ }
93
+ }
94
+ `),kr=ae(`
95
+ mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
96
+ markRunArtifactsUploadedBatch(runIds: $runIds)
97
+ }
98
+ `);function Sr(e){if(e.kind!=="clean"&&e.kind!=="flaky"&&e.kind!=="finding")return;let{trail:n}=e;return{baseLabel:n.baseLabel,baseState:n.baseState,durationMs:n.durationMs,outcome:e.kind,runId:e.kind==="finding"?e.runId:void 0,signature:n.signature,steps:n.steps}}async function ce({baseState:e,category:n,config:t,debugDir:r,devSessionId:o,events:i,lockfileHash:s,reproJson:a,runId:l,signature:c,spec:d,stepSources:f,summary:y,workflowSlug:g}){await u({config:t,document:Er,variables:{devSessionId:o??null,lockfileHash:s??null,projectId:t.projectId,reproJson:a,runId:l,spec:d??null,workflowSlug:g??null}}),await se({config:t,debugDir:r,events:i,recordingOptional:!0,runId:l,stepSources:f}),await u({config:t,document:Ir,variables:{baseState:e,category:n,projectId:t.projectId,reproRunId:l,signature:c,summary:y}})}async function B(e,n,t){return(await u({config:e,document:Tr,variables:{lockfileHash:t,projectId:e.projectId,signature:n}})).exploreFindingExists}async function wr({attempts:e,config:n,devSessionId:t,findings:r,trail:o}){await u({config:n,document:xr,variables:{attempts:e,devSessionId:t,findings:r,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 vr(e,n){return(await u({config:e,document:br,variables:{devSessionId:n}}).catch(r=>(p.warn({error:r},"reportExploreUnhealthy failed"),null)))?.reportExploreUnhealthy??!1}var xr=b(`
99
+ mutation RecordExplorationProgress(
100
+ $devSessionId: String!
101
+ $attempts: Int!
102
+ $findings: Int!
103
+ $trail: ExploreTrailInput
104
+ ) {
105
+ recordExplorationProgress(
106
+ devSessionId: $devSessionId
107
+ attempts: $attempts
108
+ findings: $findings
109
+ trail: $trail
110
+ )
111
+ }
112
+ `),br=b(`
113
+ mutation ReportExploreUnhealthy($devSessionId: String!) {
114
+ reportExploreUnhealthy(devSessionId: $devSessionId)
115
+ }
116
+ `),Er=b(`
117
+ mutation CreateExploreRun(
118
+ $projectId: String!
119
+ $runId: String!
120
+ $devSessionId: String
121
+ $lockfileHash: String
122
+ $spec: String
123
+ $reproJson: String
124
+ $workflowSlug: String
125
+ ) {
126
+ createExploreRun(
127
+ projectId: $projectId
128
+ runId: $runId
129
+ devSessionId: $devSessionId
130
+ lockfileHash: $lockfileHash
131
+ spec: $spec
132
+ reproJson: $reproJson
133
+ workflowSlug: $workflowSlug
134
+ ) {
135
+ id
136
+ }
137
+ }
138
+ `),Ir=b(`
139
+ mutation SubmitExploreFinding(
140
+ $projectId: String!
141
+ $signature: String!
142
+ $summary: String!
143
+ $baseState: String!
144
+ $category: ExploreFindingCategory!
145
+ $reproRunId: String!
146
+ ) {
147
+ submitExploreFinding(
148
+ projectId: $projectId
149
+ signature: $signature
150
+ summary: $summary
151
+ baseState: $baseState
152
+ category: $category
153
+ reproRunId: $reproRunId
154
+ ) {
155
+ id
156
+ }
157
+ }
158
+ `),Ai=b(`
159
+ mutation SetExploreFindingStatus(
160
+ $projectId: String!
161
+ $signature: String!
162
+ $status: ExploreFindingStatus!
163
+ ) {
164
+ setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
165
+ }
166
+ `),Tr=b(`
167
+ query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
168
+ exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
169
+ }
170
+ `);import Pr from"path";import{graphql as Mr}from"gql.tada";import{graphql as V}from"gql.tada";function ue(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 pe(e,n,t){await u({config:e,document:Ar,variables:{reason:t,runId:n}}).catch(r=>{p.error(r,"failRun submission failed")})}async function fe(e,n,t){await u({config:e,document:Cr,variables:{cause:t,runId:n}}).catch(r=>{p.error(r,"markRunUnready submission failed")})}var $i=V(`
171
+ mutation ReleaseRun($runId: String!) {
172
+ releaseRun(runId: $runId)
173
+ }
174
+ `),ji=V(`
175
+ mutation HeartbeatRun($runId: String!) {
176
+ heartbeatRun(runId: $runId)
177
+ }
178
+ `),Ar=V(`
179
+ mutation FailRun($runId: String!, $reason: String!) {
180
+ failRun(runId: $runId, reason: $reason)
181
+ }
182
+ `),Cr=V(`
183
+ mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
184
+ markRunUnready(runId: $runId, cause: $cause)
185
+ }
186
+ `);async function $r({config:e,cwd:n,errorSettle:t,fixturesDir:r,headed:o,lockfile:i,onPhase:s,runId:a,session:l,signal:c,test:d}){if(!await Fr(e,a))return{outcome:{kind:"dispatch-failed",reason:"already-claimed",runId:a},persisted:Promise.resolve()};let y=Pr.join(n,".ripplo","debug"),g=[];return(await l.runOnce({capture:!0,lockfile:i,onPhase:s,options:W({config:e,fixturesDir:r,headed:o}),params:void 0,runId:a,sequence:void 0,test:d,onEvent:E=>{g.push(E)}},c)).match(async E=>{let ge=de(g),z=ge.flatMap(zn=>zn.findings),G=jr(z);if(G!=null)return K({config:e,debugDir:y,events:g,recordingOptional:!0,runId:a,stepSources:void 0}),await Nn({config:e,error:G,errorSettle:t,runId:a}),{outcome:{error:G,kind:"error",runId:a},persisted:Promise.resolve()};await le(e,a,ge),K({config:e,debugDir:y,events:g,recordingOptional:!0,runId:a,stepSources:void 0});let Jn=Promise.resolve();return{outcome:z.length>0?{findings:z,kind:"findings",runId:a}:{kind:"pass",runId:a},persisted:Jn}},async E=>(await Nn({config:e,error:E,errorSettle:t,runId:a}),{outcome:{error:E,kind:"error",runId:a},persisted:Promise.resolve()}))}async function Nn({config:e,error:n,errorSettle:t,runId:r}){if(t==="defer")return;let o=ue(n);if(o!=null){await fe(e,r,o);return}await pe(e,r,j(n))}function jr(e){let n=e.find(t=>t.kind==="driver-error"&&Ae(t.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function Fr(e,n){return((await u({config:e,document:Dr,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var Dr=Mr(`
187
+ mutation StartRunsBatch($runIds: [String!]!) {
188
+ startRunsBatch(runIds: $runIds) {
189
+ id
190
+ }
191
+ }
192
+ `);import{randomUUID as Or}from"crypto";async function Ur({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:a,session:l,signal:c}){let d=Te(s);if(e.stepRuns.length===0)return{error:{source:"empty-trail"},kind:"error"};let f=Qr(d,e.stepRuns),y=await qe({baseState:{name:R(e.baseStateTest),test:e.baseStateTest},corpus:d,lockfile:s,options:W({config:n,fixturesDir:o,headed:i}),seenSignature:a?w=>B(n,w,e.lockfileHash):void 0,session:l,stepRuns:e.stepRuns,runIdFor:w=>`explore-${Or()}-${String(w)}`},c),g=a?await Wr({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:Hr(d,e),stepSources:_r(f)}):!1;return Lr(y,f.length),Jr(y,g,Nr(f,e,y))}function Nr(e,n,t){if(t.kind==="error"||t.kind==="aborted")return;let r=t.timing.confirm;return{baseLabel:n.baseStateTest.intent,baseState:R(n.baseStateTest),durationMs:Math.round(Q(t.timing.detect)+(r==null?0:Q(r))),signature:t.kind==="finding"||t.kind==="seen"?t.signature:void 0,steps:qr(e.slice(0,t.ranCount))}}function qr(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(r=>({test:t,text:r}))})}function Q(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function Lr(e,n){if(e.kind==="error"){p.info({detail:j(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 t=e.timing.detect,r=e.timing.confirm;p.info({browserMs:t.browserMs,confirmMs:r==null?void 0:Q(r),detectMs:Q(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function Hr(e,n){let t=n.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),r={baseStateRef:R(n.baseStateTest),steps:t};return JSON.stringify(r)}function _r(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function Wr({baseStateTest:e,config:n,debugDir:t,devSessionId:r,lockfileHash:o,outcome:i,reproJson:s,stepSources:a}){return i.kind!=="finding"||i.captureEvents.length===0?!1:await B(n,i.signature,o)?(p.info({devSessionId:r,signature:i.signature},"explore finding already reported, skipping duplicate"),!1):(await ce({baseState:i.baseState,category:Kr(i.verifierLayer),config:n,debugDir:t,devSessionId:r,events:i.captureEvents,lockfileHash:o,reproJson:s,runId:i.runId,signature:i.signature,spec:Vr(e,i.captureEvents),stepSources:a,summary:Br(i.captureEvents,i.title),workflowSlug:i.sourceTest?.split("/")[0]}).catch(l=>{p.warn({error:l},"explore finding report failed")}),!0)}function Kr(e){return e==="data-rule"?"dataRule":e==="model-drift"?"modelDrift":e}function Br(e,n){let t=e.flatMap(r=>r.kind==="step"?[...r.findings]:[]).at(0);if(t!=null)return je(t);if(n!=null)return n;throw new Error("explore finding has no findings to summarize")}function Vr(e,n){let t=n.flatMap(o=>o.kind==="step"?[o.source]:[]),r={absent:e.absent,actor:e.actor,exclusive:e.exclusive,intent:e.intent,maybe:[],name:e.name,params:e.params,singletons:e.singletons,steps:t,stub:!1,tests:[],viewports:[e.viewport],world:e.world};return JSON.stringify(r)}function Qr(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>De(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Jr(e,n,t){if(e.kind==="aborted")return{kind:"aborted"};if(e.kind==="error")return{error:{category:zr(e.error.kind),kind:e.error.kind,source:"runtime"},kind:"error"};if(t==null)throw new Error("trail summary missing for completed trail");return e.kind==="finding"?{kind:e.kind,runId:n?e.runId:void 0,trail:t}:{kind:e.kind,trail:t}}function zr(e){return e==="driver-launch"?"driver":Ce(e)?"infra":"trail"}import Gr from"fs";import Yr from"path";async function da(e){let n=Yr.join(e,".ripplo","index.ts");if(!Gr.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let t=await ve(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:xe(t.error),path:".ripplo/"}],valid:!1,warnings:[]}:he().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:be(r),path:""}],valid:!1,warnings:[]}))}async function ca(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 ua({appUrl:e,engineUrl:n}){let t=n.startsWith("http://")||n.startsWith("https://")?n:`${e}${n}`;try{return(await fetch(`${t}/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}}import{createMessageConnection as qn,IPCMessageReader as Ln,IPCMessageWriter as Hn,NotificationType as Xr,NotificationType0 as _n,RequestType as Wn,RequestType0 as Zr}from"vscode-jsonrpc/node";import{z as h}from"zod";var ha=h.object({headed:h.boolean(),runId:h.string().min(1),testRef:h.string().min(1)}),Ra=h.object({lockfileJson:h.string().optional(),unavailable:h.string().optional()}),ka=h.object({runId:h.string().min(1),span:Re}),Sa=h.object({outcome:Ve,serverNotified:h.boolean()}),wa=new _n("worker/ready"),va=new Wn("worker/run"),xa=new Zr("worker/lockfile"),ba=new Wn("worker/exploreTrail"),Ea=new Xr("worker/span"),Ia=new _n("worker/shutdown");function Ta(e){let n=qn(new Ln(e),new Hn(e));return n.listen(),n}function Aa(){let e=qn(new Ln(process),new Hn(process));return e.listen(),e}import eo from"path";import{randomUUID as no}from"crypto";async function Ua({cwd:e,onReady:n,signal:t,step:r,target:o}){let i=F(e).match(f=>({config:f}),f=>({failure:f}));if("failure"in i)return{failure:i.failure,kind:"config-failed"};let s=i.config,a=await we(e);if(a.result.isErr())return{error:a.result.error,kind:"compile-failed"};let l=await He(e,a.result.value),c=await to(l,o);return c.kind!=="ok"?c:(await Ue({lockfile:l,onReady:n,options:ro(s),runId:`teleport-${no()}`,sequence:c.sequence,stopAfterStep:r,test:c.test},t)).match(f=>({kind:"done",result:f}),f=>({error:f,kind:"run-failed"}))}async function to(e,n){if(n.kind==="explore"){let r=await Le(e,n.repro);return r.kind==="unplannable"?{kind:"unplannable"}:{kind:"ok",sequence:r.sequence,test:r.baseTest}}let t=T(e).find(r=>r.ref===n.ref);return t==null?{kind:"no-test",ref:n.ref}:{kind:"ok",sequence:Ne(e,t.test,void 0),test:t.test}}function ro(e){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:eo.join(e.cwd,ke),generate:P,headed:!0,secret:e.webhookSecret}}var La=15e3,Ha=3e4,_a=2,Wa=12;function Ka(e,n){let t=oo(e,n);if(!e.enabled||!e.executorLocal)return{abortIds:ye(n),health:{kind:"off"},launchCount:0};if(io(n))return{abortIds:ye(n),health:{kind:"paused"},launchCount:0};if(n.lockfile.kind==="blocked")return{abortIds:ye(n),health:{kind:"blocked",reason:n.lockfile.reason},launchCount:0};if(n.backoffActive||n.lockfile.kind==="loading")return{abortIds:t,health:{kind:"paused"},launchCount:0};let r=Math.min(e.workers,n.poolSize-1),o=n.trails.length-t.length;return{abortIds:t,health:{kind:"on"},launchCount:Math.max(0,r-o)}}function oo(e,n){let t=Oe(e.maxTrailLength);return n.trails.filter(r=>r.ageMs>=t).map(r=>r.id)}function ye(e){return e.trails.map(n=>n.id)}function io(e){return e.headedActive||e.interactiveActive>0||e.interactiveQueued>0}import{graphql as po}from"gql.tada";import{err as J,ok as Vn}from"neverthrow";import ao,{AbortError as so}from"p-retry";import{graphql as Kn}from"gql.tada";var lo=Kn(`
193
+ query AwaitDevSession($projectId: String!, $cwd: String!) {
194
+ project(id: $projectId) {
195
+ devSession(cwd: $cwd) {
196
+ id
197
+ executor
198
+ }
199
+ }
200
+ }
201
+ `);async function Bn(e){return ao(async()=>{let r=(await u({config:e,document:lo,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(r!=null)return{executor:r.executor,id:r.id,kind:"active"};throw D(e.cwd)?new Error("starting"):new so("missing")},{factor:1,maxTimeout:400,minTimeout:400,retries:25}).catch(()=>D(e.cwd)?{kind:"starting"}:{kind:"missing"})}var co=Kn(`
202
+ query DevSessionCheckHealth($projectId: String!, $cwd: String!) {
203
+ activeDevSessions(projectId: $projectId) {
204
+ id
205
+ cwd
206
+ branch
207
+ }
208
+ project(id: $projectId) {
209
+ id
210
+ devSession(cwd: $cwd) {
211
+ id
212
+ }
213
+ }
214
+ }
215
+ `);function Xa(e){switch(e.status){case"active":return e.gitMidOperation?"\u2713 Dev session: ripplo daemon is live (hooks auto-paused while git is mid-merge/rebase/cherry-pick \u2014 they resume when the operation ends)":"\u2713 Dev session: ripplo daemon is live for this directory";case"starting":return"! Dev session: the daemon is running locally but hasn't registered with the server yet. Wait a few seconds and re-run `npx ripplo doctor`. If it persists, check the daemon output for auth or network errors.";case"missing":{let n="\u2717 Dev session: no daemon running for this directory. Start `npx ripplo daemon` as a background process (separate from your app's dev server). Without it, `npx ripplo run` refuses to dispatch and scope/coverage hooks won't arm.";return e.elsewhere.length===0?n:[n," A daemon is running for a different directory:",...uo(e.elsewhere)].join(`
216
+ `)}}}async function Za(e){let n=D(e),t=_e(e),r=F(e).unwrapOr(void 0);if(r==null)return{elsewhere:[],gitMidOperation:t,status:n?"starting":"missing",type:"dev-session"};let o=await u({config:r,document:co,variables:{cwd:r.cwd,projectId:r.projectId}}).catch(()=>null);return o?.project?.devSession!=null?{elsewhere:[],gitMidOperation:t,status:"active",type:"dev-session"}:{elsewhere:(o?.activeDevSessions??[]).filter(a=>a.cwd!==r.cwd).map(a=>({branch:a.branch,cwd:a.cwd})),gitMidOperation:t,status:n?"starting":"missing",type:"dev-session"}}function uo(e){return e.map(n=>{let t=n.branch==null?"":` (${n.branch})`;return` - ${n.cwd}${t}`})}var fo=po(`
217
+ mutation SetDevSessionExecutor($devSessionId: String!, $executor: RunExecutor!) {
218
+ setDevSessionExecutor(devSessionId: $devSessionId, executor: $executor) {
219
+ __typename
220
+ ... on DevSession {
221
+ id
222
+ executor
223
+ }
224
+ ... on DevSessionEndedError {
225
+ message
226
+ }
227
+ }
228
+ }
229
+ `);async function is(e){return(await Qn(e)).map(t=>t.executor)}async function as(e,n){let t=await Qn(e);if(t.isErr())return J(t.error);let o=(await u({config:e,document:fo,variables:{devSessionId:t.value.id,executor:n}})).setDevSessionExecutor;return o==null?J({kind:"empty-response"}):o.__typename!=="DevSession"?J({kind:"session-ended"}):Vn(o.executor)}async function Qn(e){let n=await Bn(e);return n.kind==="active"?Vn({executor:n.executor,id:n.id}):J({kind:n.kind==="starting"?"starting":"no-session"})}export{Bn as a,Xa as b,Za as c,da as d,ca as e,ua as f,ha as g,ka as h,Sa as i,wa as j,va as k,xa as l,ba as m,Ea as n,Ia as o,Ta as p,Aa as q,mo as r,ho as s,X as t,Ro as u,Ho as v,Pt as w,di as x,_ as y,Zt as z,pe as A,$r as B,Sr as C,wr as D,vr as E,Ur as F,Ua as G,La as H,Ha as I,_a as J,Wa as K,Ka as L,is as M,as as N};
@@ -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 u}from"./chunk-I5BHCICM.js";import{a as f}from"./chunk-JJ4QQPAV.js";import{a as m}from"./chunk-7WZ3VIUU.js";import{f as c}from"./chunk-4W6WIT7T.js";import{i as p}from"./chunk-EK6TENV6.js";import{h as l}from"./chunk-AQ3DMGAY.js";import v from"path";import h from"picomatch";import*as s from"zod/mini";var w=s.looseObject({file_path:s.string()}),R=async n=>{let i=w.safeParse(n.tool_input);if(!i.success)return;let d=i.data.file_path,{cwd:t}=n;if(!m(t)||!c(t))return;let r=v.relative(t,d);if(r.startsWith(".."))return;let{ignorePaths:b,watchPaths:k}=f(),P=h([...k]),g=h([...b]);if(!P(r)||g(r))return;let o=await l(t);if(u({cwd:t,tests:o.isOk()?o.value.workflows.map(e=>({intent:e.intent,name:e.name,sourcePath:e.sourcePath??null,stub:e.stub})):void 0}),o.isErr())return;let a=p(o.value);if(a.length!==0)return{hookSpecificOutput:{additionalContext:`Reminder: stub workflows still unimplemented \u2014 ${a.join(", ")}. Implement with \`workflow("Intent", () => ({ given, steps }))\`.`,hookEventName:"PostToolUse"}}};export{R as a};
4
+ import{b as u}from"./chunk-I5BHCICM.js";import{a as f}from"./chunk-JJ4QQPAV.js";import{a as m}from"./chunk-7WZ3VIUU.js";import{f as c}from"./chunk-4W6WIT7T.js";import{i as p}from"./chunk-XVMIPWJQ.js";import{k as l}from"./chunk-EVVF662P.js";import v from"path";import h from"picomatch";import*as s from"zod/mini";var w=s.looseObject({file_path:s.string()}),R=async n=>{let i=w.safeParse(n.tool_input);if(!i.success)return;let d=i.data.file_path,{cwd:t}=n;if(!m(t)||!c(t))return;let r=v.relative(t,d);if(r.startsWith(".."))return;let{ignorePaths:b,watchPaths:k}=f(),P=h([...k]),g=h([...b]);if(!P(r)||g(r))return;let o=await l(t);if(u({cwd:t,tests:o.isOk()?o.value.workflows.map(e=>({intent:e.intent,name:e.name,sourcePath:e.sourcePath??null,stub:e.stub})):void 0}),o.isErr())return;let a=p(o.value);if(a.length!==0)return{hookSpecificOutput:{additionalContext:`Reminder: stub workflows still unimplemented \u2014 ${a.join(", ")}. Implement with \`workflow("Intent", () => ({ given, steps }))\`.`,hookEventName:"PostToolUse"}}};export{R as a};
@@ -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{i as c}from"./chunk-PE5WVWI5.js";import{spawnSync as y}from"child_process";import{existsSync as s,readdirSync as d,readFileSync as g,realpathSync as u,statSync as m}from"fs";import i from"path";var k=2e3;function _(t){if(t!=null)try{return m(u(t)).mtimeMs}catch{return}}function D(t){return y("pnpm",["turbo","run","build","--filter=ripplo..."],{cwd:t,stdio:"inherit"}).status===0}function U(){let t=process.argv[1];if(t==null)return{kind:"fresh"};let n=u(t),r=n.includes(`${i.sep}src${i.sep}`),o=l(i.dirname(n));if(o!=null)return r?{kind:"fresh"}:h(o);let a=l(process.cwd());return a!=null&&j(a)?{kind:"foreign-binary",workspaceRoot:a}:{kind:"fresh"}}function l(t){let n=i.dirname(t);return s(i.join(t,"pnpm-workspace.yaml"))?t:n===t?void 0:l(n)}function h(t){let n=i.join(t,"packages");if(!s(n))return{kind:"fresh"};let r=d(n).map(o=>({dist:i.join(n,o,"dist"),name:o,src:i.join(n,o,"src")})).filter(o=>s(o.src)&&s(o.dist)).filter(o=>p(o.src)>p(o.dist)+k).map(o=>o.name);return r.length===0?{kind:"fresh"}:{kind:"stale",packages:r,workspaceRoot:t}}function p(t){let n=m(t);if(!n.isDirectory())return n.mtimeMs;let r=d(t).map(o=>p(i.join(t,o)));return Math.max(n.mtimeMs,...r)}function j(t){let n=i.join(t,"packages","cli","package.json");if(!s(n))return!1;let r=JSON.parse(g(n,"utf8"));return typeof r=="object"&&r!=null&&"name"in r&&r.name==="ripplo"}import{createMessageConnection as S,NotificationType as f,RequestType as x,RequestType0 as b,SocketMessageReader as R,SocketMessageWriter as w}from"vscode-jsonrpc/node";import{z as e}from"zod";var E="daemon.sock",P="daemon.log";function K(t){return c(t,E)}function B(t){return c(t,P)}function X(t){return S(new R(t),new w(t))}var G=e.object({all:e.boolean(),headed:e.boolean(),tests:e.array(e.string())}),$=e.object({jobId:e.string(),total:e.number()}),M=e.enum(["no-lockfile","unstamped","expander-newer","dsl-drift","load-failed"]),q=e.discriminatedUnion("kind",[e.object({kind:e.literal("off")}),e.object({kind:e.literal("on")}),e.object({kind:e.literal("paused")}),e.object({kind:e.literal("blocked"),reason:M})]),v=e.object({attempts:e.number(),findings:e.number()}),H=e.object({active:e.number(),bundleMtimeMs:e.number().optional(),explorer:q,exploring:e.number(),progress:v,queued:e.number(),sseHealth:e.object({detail:e.string().optional(),ok:e.boolean()}).optional(),version:e.string().optional()}),z=e.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),I=e.discriminatedUnion("type",[e.object({code:z,type:e.literal("limit")}),e.object({detail:e.string(),type:e.literal("generic")})]),A=e.discriminatedUnion("kind",[e.object({kind:e.literal("pass")}),e.object({findingLines:e.array(e.string()),kind:e.literal("findings")}),e.object({detail:e.string(),kind:e.literal("error")}),e.object({kind:e.literal("dispatch-error"),reason:I}),e.object({detail:e.string(),kind:e.literal("dispatch-timeout")}),e.object({detail:e.string(),kind:e.literal("infra-error")})]),C=e.discriminatedUnion("kind",[e.object({kind:e.literal("test-started"),runId:e.string(),testName:e.string(),workflowName:e.string()}),e.object({kind:e.literal("test-outcome"),outcome:A,runId:e.string(),testName:e.string(),workflowName:e.string()})]),V=e.object({event:C,jobId:e.string()}),Q=e.object({failed:e.number(),jobId:e.string(),notRun:e.number(),passed:e.number()}),Y=e.discriminatedUnion("code",[e.object({code:e.literal("compile-failed"),detail:e.string(),diagnostics:e.array(e.string()).default([])}),e.object({code:e.literal("selection-conflicting-flags")}),e.object({code:e.literal("selection-nothing-selected")}),e.object({code:e.literal("selection-unknown-ids"),known:e.array(e.string()),unknown:e.array(e.string())}),e.object({code:e.literal("scope-failed"),detail:e.string()}),e.object({code:e.literal("app-unreachable"),detail:e.string(),url:e.string()}),e.object({code:e.literal("engine-unreachable"),detail:e.string(),url:e.string()}),e.object({code:e.literal("sync-failed"),detail:e.string()}),e.object({code:e.literal("bad-message")})]),Z=new x("ripplo/enqueue"),ee=new b("ripplo/status"),te=new b("ripplo/shutdownIfIdle"),ne=new f("ripplo/jobEvent"),oe=new f("ripplo/jobDone");export{_ as a,D as b,U as c,K as d,B as e,X as f,G as g,$ as h,H as i,A as j,V as k,Q as l,Y as m,Z as n,ee as o,te as p,ne as q,oe as r};
@@ -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 c,b as g,c as d,d as C,h as s,k as P}from"./chunk-EVVF662P.js";import{k as w,n as x,o as b,p as F}from"./chunk-BR7W4UBJ.js";import{E as k,F as i,L as n,M as h,Z as S,ba as y,ca as L}from"./chunk-4F67XQYS.js";import{readFile as z,writeFile as D}from"fs/promises";import R from"path";import{err as m,ok as W}from"neverthrow";import{createHash as H}from"crypto";import l from"fs";import v from"path";import V from"safe-stable-stringify";import{z as f}from"zod";function B({context:e,cwd:o}){S(e);let r=M(o,u(e));r!=null&&y(e,r)}function ne({context:e,cwd:o}){let r=_(o);if(!(r==null||r.model!==u(e)))return r.cleanLockfile??void 0}function ie({cleanLockfileHash:e,context:o,cwd:r}){let t=E(r);l.mkdirSync(v.dirname(t),{recursive:!0}),l.writeFileSync(t,JSON.stringify({bundle:c(),cleanLockfile:e,model:u(o)}))}function se(e){return H("sha256").update(e).digest("base64")}var J=f.object({bundle:f.string().nullable(),cleanLockfile:f.string().nullable(),model:f.string()});function M(e,o){let r=v.join(e,s),t=I(r);return t==null||!d(t)?null:u({entities:t.entities,singletonSchemas:t.singletons,valueSpaces:t.valueSpaces})===o?t.solved:null}function I(e){try{return i(n,l.readFileSync(e,"utf8"))}catch{return null}}function u(e){let o=V({entities:e.entities,singletons:e.singletonSchemas,valueSpaces:e.valueSpaces});if(o==null)throw new Error("solve-cache: context is not serializable");return H("sha256").update(o).digest("base64")}function _(e){let o=E(e);if(l.existsSync(o))try{let r=J.safeParse(JSON.parse(l.readFileSync(o,"utf8")));return!r.success||!C(r.data.bundle)?void 0:r.data}catch{return}}function E(e){return v.join(e,".ripplo",".local","solve-cache.json")}async function Se(e){let o=await P(e);return o.isOk()&&await K(e,o.value),o}async function K(e,o){let r=await N(e,o);return await D(R.join(e,s),k(n,r)),r}var O=new WeakMap;function N(e,o){let r=O.get(o);if(r!=null)return r;let t=T(e,o).then(a=>a.match(p=>Promise.resolve(p),()=>G(e,o)));return O.set(o,t),t}function ye(e,o){return T(e,o)}function Le(e){return e.workflows.filter(o=>o.stub).map(o=>o.name)}async function T(e,o){let r=await q(e);return r==null?m({kind:"no-lockfile"}):r.checks==null?m({kind:"unstamped"}):d(r)?g(r,o)?W(h(r)):m({kind:"dsl-drift"}):m({kind:"expander-newer"})}async function q(e){try{let o=await z(R.join(e,s),"utf8");return i(n,o)}catch{return null}}async function G(e,o){let r=w(o);B({context:r,cwd:e});let t=await b(o),a=await x(o);await F({context:r,facts:a.facts});let p=await L(r),A=c(),j={...o,checks:{...t,expanderHash:A??void 0},solved:p};return h(i(n,k(n,j)))}export{B as a,ne as b,ie as c,se as d,Se as e,K as f,N as g,ye as h,Le as i};
@@ -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 n}from"./chunk-MHNGR6M7.js";import{c as o,d as a,e as i}from"./chunk-AQ3DMGAY.js";function c(e){return[`Compilation failed: ${s(e)}`,n("create","DSL authoring rules")].join(`
4
+ import{a as n}from"./chunk-MHNGR6M7.js";import{f as o,g as a,h as i}from"./chunk-EVVF662P.js";function c(e){return[`Compilation failed: ${s(e)}`,n("create","DSL authoring rules")].join(`
5
5
  `)}function m(){return`${i} is up to date`}function g(e){return[`${i} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit it`,n("setup")].join(`
6
6
  `)}function x(){return`Wrote ${i}`}function s(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...l(e.diagnostics)].join(`
7
7
  `);case"not-ripplo":return`${e.entryPath} must default-export createRipplo({ entities, singletons, workflows }).`;case"invalid-lockfile":return["Lockfile failed schema validation (stale or hand-edited .ripplo/ripplo.lock):",...l(e.issues),"Regenerate with `npx ripplo compile`."].join(`
@@ -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 c}from"./chunk-OQ6KNYPG.js";import{c as p}from"./chunk-LEFXRK53.js";import{c as l}from"./chunk-FEHVIHVA.js";import{a}from"./chunk-MHNGR6M7.js";import{I as u,w as t}from"./chunk-ESOXRGIY.js";import{N as d}from"./chunk-5SM4TCSW.js";var f=3e3;async function S(e){l(e);let n=p(e).unwrapOr(void 0);if(n==null)return null;try{return await fetch(`${n.ripploServerUrl}/health`,{signal:AbortSignal.timeout(f)}),null}catch(r){return{detail:r instanceof Error?r.message:String(r),serverUrl:n.ripploServerUrl}}}function m(e){return e.includes("localhost")||e.includes("127.0.0.1")}import g from"fuse.js";function s(e){switch(e.kind){case"conflicting-flags":return"Pass either --all or test ids, not both.";case"nothing-selected":return`No tests selected \u2014 scope empty, no dirty .ripplo/workflows files. Pass test ids, add to scope (${a("run")}), or use --all.`;case"unknown-ids":{let n=e.known,r=e.unknown.flatMap(i=>y(i,n)),o=r.length>0?[`Did you mean: ${[...new Set(r)].join(", ")}`]:[];return[`Unknown ${e.unknown.length===1?"id":"ids"}: ${e.unknown.join(", ")}`,...o,"Pass a workflow slug for all its tests, or workflow/test for one. Known workflows:",...n.map(i=>` ${i}`)].join(`
4
+ import{a as c}from"./chunk-OQ6KNYPG.js";import{c as p}from"./chunk-LEFXRK53.js";import{c as l}from"./chunk-FEHVIHVA.js";import{a}from"./chunk-MHNGR6M7.js";import{I as u,w as t}from"./chunk-BR7W4UBJ.js";import{R as d}from"./chunk-4F67XQYS.js";var f=3e3;async function S(e){l(e);let n=p(e).unwrapOr(void 0);if(n==null)return null;try{return await fetch(`${n.ripploServerUrl}/health`,{signal:AbortSignal.timeout(f)}),null}catch(r){return{detail:r instanceof Error?r.message:String(r),serverUrl:n.ripploServerUrl}}}function m(e){return e.includes("localhost")||e.includes("127.0.0.1")}import g from"fuse.js";function s(e){switch(e.kind){case"conflicting-flags":return"Pass either --all or test ids, not both.";case"nothing-selected":return`No tests selected \u2014 scope empty, no dirty .ripplo/workflows files. Pass test ids, add to scope (${a("run")}), or use --all.`;case"unknown-ids":{let n=e.known,r=e.unknown.flatMap(i=>y(i,n)),o=r.length>0?[`Did you mean: ${[...new Set(r)].join(", ")}`]:[];return[`Unknown ${e.unknown.length===1?"id":"ids"}: ${e.unknown.join(", ")}`,...o,"Pass a workflow slug for all its tests, or workflow/test for one. Known workflows:",...n.map(i=>` ${i}`)].join(`
5
5
  `)}}}function L({failed:e,notRun:n,passed:r}){let o=n>0?`, ${String(n)} not run`:"";return`${String(r)} passed, ${String(e)} failed${o} (${String(r+e+n)} total)`}function A({debugDir:e,event:n}){let r=`${n.workflowName} \u2192 ${n.testName}`;if(n.kind==="test-started")return`${t.dim("run ")} ${r}`;switch(n.outcome.kind){case"pass":return`${t.good("pass")} ${r} ${t.dim(n.runId)}`;case"findings":return[`${t.bad("fail")} ${r} \u2014 ${c(n.outcome.findingLines.length,"finding")}`,...n.outcome.findingLines,u({debugDir:e,runId:n.runId}),`${t.dim("why")} npx ripplo explain ${n.runId}`].join(`
6
6
  `);case"error":return`${t.bad("error")} ${r} \u2014 ${n.outcome.detail} ${t.dim(n.runId)}`;case"dispatch-error":return`${t.bad("error")} ${r} \u2014 ${w(n.outcome.reason)}`;case"dispatch-timeout":return`${t.bad("error")} ${r} \u2014 not run: dispatch timed out (transient): ${n.outcome.detail}`;case"infra-error":return`${t.bad("error")} ${r} \u2014 not run: Ripplo server unreachable: ${n.outcome.detail}`}}var h={MAX_AGENTS:"agent limit reached for your plan \u2014 upgrade to add more",MAX_CONCURRENT_RUNS:"concurrent run limit reached for your plan \u2014 upgrade or wait for runs to finish",MAX_PROJECTS:"project limit reached for your plan \u2014 upgrade to add more",MAX_RUNS:"run limit reached for your plan \u2014 enable overage or upgrade",OVERAGE_CAP:"overage cap reached \u2014 raise the cap or upgrade"};function j({detail:e,serverUrl:n}){return m(n)?`Ripplo server at ${n} not running (${e}). Start the dev server with \`pnpm dev\`.`:`Ripplo server at ${n} unreachable (${e}) \u2014 server-side, not your local environment.`}function N(e){switch(e.code){case"compile-failed":{let n=e.diagnostics.length===0?[]:["",...e.diagnostics];return[`Compilation failed in the daemon (${e.detail}). Run \`npx ripplo compile\` for full output.`,...n].join(`
7
7
  `)}case"selection-conflicting-flags":return s({kind:"conflicting-flags"});case"selection-nothing-selected":return s({kind:"nothing-selected"});case"selection-unknown-ids":return s({kind:"unknown-ids",known:e.known,unknown:e.unknown});case"app-unreachable":return`Your dev server not responding at ${e.url} (${e.detail}) \u2014 your local environment, not the Ripplo server.`;case"engine-unreachable":return`Ripplo engine not responding at ${e.url} (${e.detail}) \u2014 adapter unmounted, behind a build error, or RIPPLO_ENGINE_URL points at the wrong path.`;case"scope-failed":return`Could not resolve the dev-session scope: ${e.detail}
@@ -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 k}from"./chunk-LEFXRK53.js";import{a as P,f as I}from"./chunk-4W6WIT7T.js";import{b as m,e as h,h as w}from"./chunk-AQ3DMGAY.js";import{d as c,f as d}from"./chunk-PE5WVWI5.js";import{L as g,N as S}from"./chunk-5SM4TCSW.js";import u from"fs";import f from"path";function v(e){try{let n=A(e);if(n==null)return;let t=f.join(n,"HEAD"),o=u.readFileSync(t,"utf8").trim(),i="ref: refs/heads/";return o.startsWith(i)?o.slice(i.length):o.length===0?void 0:o.slice(0,7)}catch{return}}function A(e){let n=f.join(e,".git");if(u.statSync(n).isDirectory())return n;let o=u.readFileSync(n,"utf8").trim(),i="gitdir:";if(!o.startsWith(i))return;let s=o.slice(i.length).trim();if(s.length!==0)return f.resolve(e,s)}import b from"crypto";import{readFile as D}from"fs/promises";import x from"path";import{graphql as y}from"gql.tada";import{err as E,ok as L}from"neverthrow";var T=y(`
4
+ import{c as k}from"./chunk-LEFXRK53.js";import{a as P,f as I}from"./chunk-4W6WIT7T.js";import{e as m,h,k as w}from"./chunk-EVVF662P.js";import{d as c,f as d}from"./chunk-PE5WVWI5.js";import{P as g,R as S}from"./chunk-4F67XQYS.js";import u from"fs";import f from"path";function v(e){try{let n=A(e);if(n==null)return;let t=f.join(n,"HEAD"),o=u.readFileSync(t,"utf8").trim(),i="ref: refs/heads/";return o.startsWith(i)?o.slice(i.length):o.length===0?void 0:o.slice(0,7)}catch{return}}function A(e){let n=f.join(e,".git");if(u.statSync(n).isDirectory())return n;let o=u.readFileSync(n,"utf8").trim(),i="gitdir:";if(!o.startsWith(i))return;let s=o.slice(i.length).trim();if(s.length!==0)return f.resolve(e,s)}import b from"crypto";import{readFile as D}from"fs/promises";import x from"path";import{graphql as y}from"gql.tada";import{err as E,ok as L}from"neverthrow";var T=y(`
5
5
  mutation SyncDevSession(
6
6
  $projectId: String!
7
7
  $cwd: String!
@@ -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-2MT2MZJW.js";import"./chunk-AVBP7Q2M.js";import"./chunk-MHNGR6M7.js";import"./chunk-AQ3DMGAY.js";import"./chunk-5SM4TCSW.js";import"./chunk-KMZ3L5YA.js";export{b as renderCliFailure,c as renderHookCrash,a as renderTopLevelError};
4
+ import{a,b,c}from"./chunk-Q6IYTHMP.js";import"./chunk-XZ2TPZLD.js";import"./chunk-MHNGR6M7.js";import"./chunk-EVVF662P.js";import"./chunk-4F67XQYS.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}from"./chunk-EK6TENV6.js";import"./chunk-AQ3DMGAY.js";import"./chunk-ESOXRGIY.js";import"./chunk-5SM4TCSW.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as compileAndWrite,c as stampedLockfile,d as stampedLockfileFromDisk,e as stubbedWorkflows,b as writeStampedLockfile};
4
+ import{e as a,f as b,g as c,h as d,i as e}from"./chunk-XVMIPWJQ.js";import"./chunk-EVVF662P.js";import"./chunk-BR7W4UBJ.js";import"./chunk-4F67XQYS.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as compileAndWrite,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-M7VQD4VO.js";import"./chunk-ESOXRGIY.js";import"./chunk-5SM4TCSW.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};
4
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-PRD7P6EF.js";import"./chunk-BR7W4UBJ.js";import"./chunk-4F67XQYS.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};