@rulemetric/cli 0.16.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-command.js +1 -1
- package/dist/{chunk-DHIEGG4T.js → chunk-26XE3JCL.js} +1 -1
- package/dist/chunk-2IQBXE6F.js +1 -0
- package/dist/{chunk-IG4JMWFK.js → chunk-2K4TF5RM.js} +1 -1
- package/dist/chunk-3IAZMJA4.js +1 -0
- package/dist/chunk-3WNQ52TW.js +1 -0
- package/dist/{chunk-KEVDLLHT.js → chunk-433HK3QQ.js} +1 -1
- package/dist/{chunk-KR36ZDGN.js → chunk-4GM4OEQY.js} +1 -1
- package/dist/{chunk-5A6TMSRO.js → chunk-4XRPSKIJ.js} +1 -1
- package/dist/{chunk-65LFPUDB.js → chunk-52OHAULM.js} +1 -1
- package/dist/{chunk-T7HZZ4DJ.js → chunk-55HFAX5Y.js} +1 -1
- package/dist/{chunk-QPAOX7P2.js → chunk-57YXM7AI.js} +1 -1
- package/dist/{chunk-SFZPFNC6.js → chunk-6YSTU453.js} +1 -1
- package/dist/{chunk-3H44B6PB.js → chunk-7V6LLVAY.js} +1 -1
- package/dist/{chunk-USKRCVX3.js → chunk-ACJ2DBOE.js} +1 -1
- package/dist/{chunk-LJE5J3EW.js → chunk-ANHFE6US.js} +1 -1
- package/dist/{chunk-FADINV4H.js → chunk-AXTEV56C.js} +1 -1
- package/dist/{chunk-HBDKOU2N.js → chunk-AZB34RT6.js} +7 -6
- package/dist/{chunk-WOANSBMJ.js → chunk-AZK4Y5DB.js} +1 -1
- package/dist/{chunk-TU2AR6XO.js → chunk-B22HYCBV.js} +1 -1
- package/dist/{chunk-GIQ2HK3W.js → chunk-BLGICIV4.js} +1 -1
- package/dist/{chunk-6QMIDH6X.js → chunk-BV3JMD3A.js} +1 -1
- package/dist/{chunk-ZKPURXUS.js → chunk-CEM7JMUW.js} +1 -1
- package/dist/{chunk-NWV66NMA.js → chunk-CWVXTLXZ.js} +1 -1
- package/dist/{chunk-XQCGAPLN.js → chunk-CXSDZ473.js} +1 -1
- package/dist/chunk-DB4ZM5N3.js +1 -0
- package/dist/{chunk-QPVUGTDP.js → chunk-EOTSCWFS.js} +1 -1
- package/dist/chunk-FLXWL4F4.js +8 -0
- package/dist/{chunk-7YZURVZD.js → chunk-FPEC6DJV.js} +1 -1
- package/dist/chunk-G2226CG6.js +1 -0
- package/dist/{chunk-KOORMTZO.js → chunk-GLZBTGN5.js} +1 -1
- package/dist/{chunk-5TM7AOH2.js → chunk-GPWLS64K.js} +1 -1
- package/dist/chunk-HB4RUEEE.js +1 -0
- package/dist/{chunk-UVCVJKEN.js → chunk-JEZ5ZTKR.js} +1 -1
- package/dist/{chunk-ISYU5BMU.js → chunk-JQ2ZCUEC.js} +1 -1
- package/dist/{chunk-RIYVZDOQ.js → chunk-KSKC5SEQ.js} +1 -1
- package/dist/{chunk-ISEUEYSC.js → chunk-L3AXNCWC.js} +1 -1
- package/dist/chunk-LARY6ZFT.js +1 -0
- package/dist/{chunk-E4CIJ67Z.js → chunk-LEUXIXIS.js} +1 -1
- package/dist/{chunk-GGUXEZC3.js → chunk-LMNUO32P.js} +1 -1
- package/dist/{chunk-6T6YFPBW.js → chunk-LMQDS47I.js} +1 -1
- package/dist/{chunk-VUNJGZPP.js → chunk-M2CPTQZL.js} +1 -1
- package/dist/{chunk-WUCACPGC.js → chunk-MOQTSJNZ.js} +1 -1
- package/dist/chunk-N7P3HUPD.js +3 -0
- package/dist/{chunk-7LE2W3WP.js → chunk-PHBPHZSZ.js} +1 -1
- package/dist/{chunk-TSLBCZ5P.js → chunk-QH7JB4UQ.js} +1 -1
- package/dist/{chunk-CVPAKEEZ.js → chunk-R7URROQD.js} +1 -1
- package/dist/{chunk-EFEPD4AZ.js → chunk-RAIXY6YA.js} +1 -1
- package/dist/chunk-RCJTCLZO.js +1 -0
- package/dist/chunk-SVZYRGO5.js +4 -0
- package/dist/chunk-SW24KZ5C.js +1 -0
- package/dist/{chunk-WL5ZWQAS.js → chunk-TDDJOSFQ.js} +1 -1
- package/dist/{chunk-GDLQNY4V.js → chunk-TDRUVE4J.js} +1 -1
- package/dist/chunk-TFJAT263.js +2 -0
- package/dist/{chunk-PDXHRF4E.js → chunk-TL57YUJV.js} +1 -1
- package/dist/{chunk-QNSIBPWG.js → chunk-TZC4CYPD.js} +1 -1
- package/dist/{chunk-FG343JM3.js → chunk-U6AASXY3.js} +1 -1
- package/dist/{chunk-BDQTVYYF.js → chunk-UDNEOJWY.js} +1 -1
- package/dist/{chunk-PJ4RIUI3.js → chunk-UPJVMMDK.js} +1 -1
- package/dist/{chunk-Q7IDLOSP.js → chunk-V2G6E53W.js} +1 -1
- package/dist/chunk-VBGHPAUT.js +2 -0
- package/dist/{chunk-MYGVN6X4.js → chunk-VF54EOLZ.js} +1 -1
- package/dist/{chunk-KE5K3F7J.js → chunk-VFWQ2W4B.js} +1 -1
- package/dist/chunk-VZYNZS5U.js +1 -0
- package/dist/{chunk-DX6IPDED.js → chunk-WDLAPZPN.js} +1 -1
- package/dist/{chunk-D4FP5M2B.js → chunk-WM437XV6.js} +1 -1
- package/dist/chunk-WULEBQPI.js +1 -0
- package/dist/chunk-WWL4HNXM.js +28 -0
- package/dist/{chunk-NBTC5FNV.js → chunk-X23L2MF6.js} +1 -1
- package/dist/chunk-XFOG2PDJ.js +1 -0
- package/dist/{chunk-KGU2IW54.js → chunk-YSY25OGG.js} +1 -1
- package/dist/{chunk-WL34G6IR.js → chunk-YVEI7XR6.js} +1 -1
- package/dist/{chunk-YXMAGC53.js → chunk-YX2IGS72.js} +1 -1
- package/dist/chunk-Z7UN4R7T.js +1 -0
- package/dist/{chunk-TQM7MF5C.js → chunk-ZZZ7ECPT.js} +1 -1
- package/dist/commands/antigravity/backfill.js +1 -1
- package/dist/commands/auth/create-key.js +1 -1
- package/dist/commands/auth/login.js +1 -1
- package/dist/commands/auth/logout.js +1 -1
- package/dist/commands/auth/revoke-key.js +1 -1
- package/dist/commands/auth/signup.js +1 -1
- package/dist/commands/auth/status.js +1 -1
- package/dist/commands/capture/scope.js +1 -1
- package/dist/commands/catalog/index.js +1 -1
- package/dist/commands/catalog/recommend.js +1 -1
- package/dist/commands/crons/list.js +1 -1
- package/dist/commands/crons/run.js +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/diagnostics.js +1 -1
- package/dist/commands/eval-targets/create.js +1 -1
- package/dist/commands/eval-targets/list.js +1 -1
- package/dist/commands/evals/agent.js +1 -1
- package/dist/commands/evals/auto-run.js +1 -1
- package/dist/commands/evals/benchmark.js +1 -1
- package/dist/commands/evals/compare.js +1 -1
- package/dist/commands/evals/create.js +1 -1
- package/dist/commands/evals/optimize-description.js +1 -1
- package/dist/commands/evals/optimize.js +1 -1
- package/dist/commands/evals/refine-cases.js +1 -1
- package/dist/commands/evals/run.js +1 -1
- package/dist/commands/evals/validate-judge.js +1 -1
- package/dist/commands/experiments/list.js +1 -1
- package/dist/commands/gateway/ensure.js +1 -1
- package/dist/commands/hooks/install.js +1 -1
- package/dist/commands/hooks/run.js +1 -1
- package/dist/commands/hooks/uninstall.js +1 -1
- package/dist/commands/instructions/create.js +1 -1
- package/dist/commands/instructions/dedupe.js +1 -1
- package/dist/commands/instructions/delete.js +1 -1
- package/dist/commands/instructions/fork.js +1 -1
- package/dist/commands/instructions/get.js +1 -1
- package/dist/commands/instructions/list.js +1 -1
- package/dist/commands/instructions/promote.js +1 -1
- package/dist/commands/instructions/pull.js +1 -1
- package/dist/commands/instructions/restore.js +1 -1
- package/dist/commands/instructions/retract.js +1 -1
- package/dist/commands/instructions/upstream.js +1 -1
- package/dist/commands/instructions/versions.js +1 -1
- package/dist/commands/launcher.js +1 -1
- package/dist/commands/local/down.js +1 -1
- package/dist/commands/local/up.js +1 -1
- package/dist/commands/org/current.js +1 -1
- package/dist/commands/org/list.js +1 -1
- package/dist/commands/org/switch.js +1 -1
- package/dist/commands/packs/add-instruction.js +1 -1
- package/dist/commands/packs/apply.js +1 -1
- package/dist/commands/packs/create.js +1 -1
- package/dist/commands/packs/fork.js +1 -1
- package/dist/commands/packs/get.js +1 -1
- package/dist/commands/packs/list.js +1 -1
- package/dist/commands/packs/remove-instruction.js +1 -1
- package/dist/commands/proxy/env.js +1 -1
- package/dist/commands/proxy/logs.js +1 -1
- package/dist/commands/proxy/restart.js +1 -1
- package/dist/commands/proxy/setup.js +1 -1
- package/dist/commands/proxy/start.js +1 -1
- package/dist/commands/proxy/status.js +1 -1
- package/dist/commands/proxy/stop.js +1 -1
- package/dist/commands/research/backfill.js +1 -1
- package/dist/commands/research/resume-scoped-outcomes.js +1 -0
- package/dist/commands/research/tail-transcript.js +1 -1
- package/dist/commands/service/install.js +1 -1
- package/dist/commands/service/status.js +1 -1
- package/dist/commands/service/uninstall.js +1 -1
- package/dist/commands/sessions/analyze.js +1 -1
- package/dist/commands/sessions/delete.js +1 -1
- package/dist/commands/sessions/end.js +1 -1
- package/dist/commands/sessions/import.js +1 -1
- package/dist/commands/sessions/list.js +1 -1
- package/dist/commands/sessions/start.js +1 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/skills/export-approved.js +1 -1
- package/dist/commands/skills/install.js +1 -1
- package/dist/commands/skills/list.js +1 -1
- package/dist/commands/skills/publish.js +1 -1
- package/dist/commands/skills/search.js +1 -1
- package/dist/commands/skills/update.js +1 -1
- package/dist/commands/suggestions/accept.js +1 -1
- package/dist/commands/suggestions/auto.js +1 -1
- package/dist/commands/suggestions/dismiss.js +1 -1
- package/dist/commands/suggestions/list.js +1 -1
- package/dist/commands/suggestions/refresh.js +1 -1
- package/dist/commands/suggestions/undo.js +1 -1
- package/dist/dashboard/Dashboard.js +1 -1
- package/dist/dashboard/data.js +1 -1
- package/dist/dashboard/launcher/ActiveJobsList.js +1 -1
- package/dist/dashboard/launcher/LauncherOverlay.js +1 -1
- package/dist/dashboard/launcher/NewLaunchForm.js +1 -1
- package/dist/dashboard/launcher/api.js +1 -1
- package/dist/dashboard/launcher/useLaunchJobs.js +1 -1
- package/dist/dashboard/panels/measurement.js +1 -1
- package/dist/{dist-UAAG2IWQ.js → dist-WGZCHQTC.js} +1 -1
- package/dist/lib/active-org-refresh.js +1 -1
- package/dist/lib/actor-env.js +1 -0
- package/dist/lib/agent-loop.js +1 -1
- package/dist/lib/agent-presence.js +1 -0
- package/dist/lib/antigravity-transcript.js +1 -1
- package/dist/lib/api-client.js +1 -1
- package/dist/lib/codex-exec.js +1 -1
- package/dist/lib/ensure-api-key.js +1 -1
- package/dist/lib/ensure-fresh-token.js +1 -1
- package/dist/lib/eval-analyzer.js +1 -1
- package/dist/lib/eval-benchmark.js +1 -1
- package/dist/lib/eval-candidate-run.js +1 -1
- package/dist/lib/eval-case-generator.js +1 -1
- package/dist/lib/eval-conversation-handler.js +1 -1
- package/dist/lib/eval-executor.js +1 -1
- package/dist/lib/eval-grader.js +1 -1
- package/dist/lib/eval-meta-judge.js +1 -1
- package/dist/lib/eval-resume.js +1 -1
- package/dist/lib/eval-run-batch.js +1 -1
- package/dist/lib/eval-trigger-tester.js +1 -1
- package/dist/lib/evolution-enrolment.js +1 -1
- package/dist/lib/insights/nomination/nominate.js +1 -1
- package/dist/lib/instruction-proposer.js +1 -1
- package/dist/lib/instruction-restoration.js +1 -1
- package/dist/lib/instructions/acceptance/accept-events.js +1 -1
- package/dist/lib/instructions/acceptance/accept-hook.js +1 -1
- package/dist/lib/instructions/acceptance/reverse-applications.js +1 -1
- package/dist/lib/instructions/acceptance/suggestion-accept.js +1 -1
- package/dist/lib/jobs/handlers/cron-auto-accept-suggestions.js +1 -1
- package/dist/lib/jobs/handlers/cron-eval-autorun.js +1 -1
- package/dist/lib/jobs/handlers/cron-instruction-evolution.js +1 -1
- package/dist/lib/jobs/handlers/cron-instruction-training.js +1 -1
- package/dist/lib/jobs/handlers/cron-reconcile-attribution.js +1 -1
- package/dist/lib/jobs/handlers/cron-refine-cases.js +1 -1
- package/dist/lib/jobs/handlers/cron-refresh-pricing.js +1 -1
- package/dist/lib/jobs/handlers/cron-refresh-skills.js +1 -1
- package/dist/lib/jobs/handlers/cron-retire-unused-skills.js +1 -1
- package/dist/lib/jobs/handlers/cron-suggest-instructions.js +1 -1
- package/dist/lib/jobs/handlers/distill-memories.js +1 -1
- package/dist/lib/jobs/handlers/finalize-scoped-launch.js +1 -1
- package/dist/lib/jobs/handlers/prepare-suggestion-live.js +1 -1
- package/dist/lib/jobs/handlers/process-conversation.js +1 -1
- package/dist/lib/jobs/handlers/process-eval.js +1 -1
- package/dist/lib/jobs/handlers/process-insights.js +1 -1
- package/dist/lib/jobs/handlers/process-judge-review.js +1 -1
- package/dist/lib/jobs/handlers/process-launch.js +1 -1
- package/dist/lib/jobs/handlers/process-memory-ab.js +1 -1
- package/dist/lib/jobs/handlers/process-run-cleanup.js +1 -1
- package/dist/lib/jobs/handlers/process-session-goal.js +1 -1
- package/dist/lib/jobs/handlers/process-suggestion-eval.js +1 -1
- package/dist/lib/jobs/shed-retry.js +1 -1
- package/dist/lib/judge-review-runner.js +1 -1
- package/dist/lib/llm-client.js +1 -1
- package/dist/lib/manual-tasks.js +1 -1
- package/dist/lib/measurement-llm.js +1 -1
- package/dist/lib/projects/workspace/eval-workspace.js +1 -1
- package/dist/lib/projects/workspace/worktree.js +1 -1
- package/dist/lib/refine-cases.js +1 -1
- package/dist/lib/repository-capabilities.js +1 -0
- package/dist/lib/research-client.js +1 -1
- package/dist/lib/scoped-outcome-store.js +1 -0
- package/dist/lib/setup-steps.js +1 -1
- package/dist/lib/telemetry.js +1 -1
- package/dist/lib/terminal-target-heartbeat.js +1 -1
- package/dist/lib/work-report.js +1 -1
- package/oclif.manifest.json +43 -1
- package/package.json +4 -4
- package/dist/chunk-3WCX2SLU.js +0 -1
- package/dist/chunk-4GOXEEXZ.js +0 -1
- package/dist/chunk-CZBO3A6B.js +0 -3
- package/dist/chunk-EHW2KS6R.js +0 -1
- package/dist/chunk-GIXHG5FK.js +0 -1
- package/dist/chunk-HYQ5YKBC.js +0 -1
- package/dist/chunk-I6W2KC6W.js +0 -1
- package/dist/chunk-JNLDISBA.js +0 -4
- package/dist/chunk-MMMT34KO.js +0 -28
- package/dist/chunk-OCCJEWOF.js +0 -1
- package/dist/chunk-PZS55PW2.js +0 -1
- package/dist/chunk-SWSOEYC7.js +0 -1
- package/dist/chunk-TTZWVZIW.js +0 -1
- package/dist/chunk-U3YPVLM3.js +0 -1
- package/dist/chunk-XXPWPKTD.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-ZLLER3HP.js";import{createHash as I,randomUUID as T}from"node:crypto";import{closeSync as w,fsyncSync as _,linkSync as b,openSync as L,existsSync as u,mkdirSync as a,readdirSync as x,readFileSync as d,renameSync as P,rmSync as R,statSync as N,writeFileSync as C}from"node:fs";import{homedir as k}from"node:os";import{join as s}from"node:path";var E=1,z=["session","reimport","verify","settle"];function O(){let e=process.env.RULEMETRIC_CONFIG_DIR??s(k(),".config","rulemetric");return s(e,"scoped-outcomes")}r(O,"scopedOutcomeStoreRoot");var A=r(e=>I("sha256").update(e).digest("hex"),"sha256");function v(e,t){if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(e))throw new Error(`Unsafe ${t} for the outcome store: ${JSON.stringify(e)}`);return e}r(v,"safeSegment");function g(e,t,o=!1){let n=`${e}.tmp-${T()}`,c=L(n,"wx",384);try{C(c,t),_(c)}finally{w(c)}try{return o?b(n,e):P(n,e),!0}catch(i){if(o&&i.code==="EEXIST")return!1;throw i}finally{R(n,{force:!0})}}r(g,"writeAtomic");function p(e){return u(e)?JSON.parse(d(e,"utf8")):null}r(p,"readJson");function f(e){return s(O(),v(e,"confirmation id"))}r(f,"confirmationDir");function M(e,t){return s(f(e),v(t,"session id"))}r(M,"outcomeDir");var h=r(e=>s(f(e),"protocol.json"),"protocolPath"),S=r(e=>s(e,"transcript.jsonl"),"transcriptPath"),l=r(e=>s(e,"receipt.json"),"receiptPath"),D=r(e=>s(e,"delivery.json"),"ledgerPath");function V(e,t){let o=h(e);return a(f(e),{recursive:!0,mode:448}),g(o,JSON.stringify(t)),o}r(V,"stageProtocol");function Z(e){return p(h(e))}r(Z,"readStagedProtocol");function G(e,t){a(e,{recursive:!0,mode:448});let o=S(e);u(o)||g(o,d(t),!0);let n=d(o);return{path:o,sha256:A(n),bytes:n.length}}r(G,"preserveTranscript");function H(e,t){let o=p(l(e));if(o)return{record:o,created:!1};a(e,{recursive:!0,mode:448});let n={version:E,...t},c=g(l(e),JSON.stringify(n,null,2),!0);return{record:c?n:p(l(e)),created:c}}r(H,"writeReceiptOnce");function J(e){return p(l(e))}r(J,"readReceipt");function U(e){return p(D(e))??{version:E,sessionId:null,completed:[],attempts:0,lastError:null,completedAt:null}}r(U,"readLedger");function X(e,t){return a(e,{recursive:!0,mode:448}),g(D(e),JSON.stringify(t,null,2)),t}r(X,"writeLedger");function Y(e){return d(S(e))}r(Y,"transcriptBytes");function q(e){try{return N(e).size}catch{return null}}r(q,"transcriptSize");function K(){let e=O();if(!u(e))return[];let t=[];for(let o of x(e,{withFileTypes:!0}).filter(n=>n.isDirectory()).map(n=>n.name)){let n=s(e,o);for(let c of x(n,{withFileTypes:!0}).filter(i=>i.isDirectory()).map(i=>i.name)){let i=s(n,c),m=null,y=null;try{m=J(i),y=U(i)}catch{}t.push({dir:i,confirmationId:o,externalSessionId:c,receipt:m,ledger:y,hasTranscript:u(S(i))})}}return t}r(K,"listScopedOutcomeEntries");function Q(e){return!!e.ledger?.completedAt}r(Q,"isDelivered");function W(e){R(e,{recursive:!0,force:!0})}r(W,"removeScopedOutcomeEntry");export{E as a,z as b,O as c,f as d,M as e,h as f,S as g,l as h,D as i,V as j,Z as k,G as l,H as m,J as n,U as o,X as p,Y as q,q as r,K as s,Q as t,W as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _e}from"./chunk-M7QSC64D.js";import{i as Me}from"./chunk-ZKPURXUS.js";import{a as Pe}from"./chunk-ISEUEYSC.js";import{b as pe,i as me,j as ge,k as fe,l as he,m as be,n as $e}from"./chunk-GYKYJJNF.js";import{c as Re}from"./chunk-G7V4ZZZ3.js";import{a as xe,b as Se,c as De,d as Ie,e as se,f as Oe}from"./chunk-LJE5J3EW.js";import{a as re}from"./chunk-AHLVY52I.js";import{d as ke,f as Ce,g as Ee,i as Ae}from"./chunk-YXMAGC53.js";import{a as we}from"./chunk-T7HZZ4DJ.js";import{c as ye}from"./chunk-FADINV4H.js";import{b as ve}from"./chunk-SWSOEYC7.js";import{d as ue,e as ne,f as de}from"./chunk-KFNFLMUR.js";import{e as y,f as te}from"./chunk-GIXHG5FK.js";import{a as g}from"./chunk-ZLLER3HP.js";import{createHash as Ge}from"node:crypto";import{existsSync as Te,readFileSync as Ne,writeFileSync as Xe}from"node:fs";var H=g(t=>Ge("sha256").update(t).digest("hex"),"sha256"),Le=1.3,ae=4,ze=20;function Be(t,o){if(!t.configured||o<=0)return ae;let e=Math.ceil(t.minPairs*Le/o);return Math.min(ze,Math.max(ae,e))}g(Be,"passCapFor");function Qe(t,o=10,e=ae){if(t<=0)return{passes:0,expectedPairs:0,feasible:!1,reason:"no live cases"};let i=Math.ceil(o*Le),l=Math.min(e,Math.ceil(i/t)),r=l*t;return r<o?{passes:l,expectedPairs:r,feasible:!1,reason:`${t} live case(s) x ${e} passes = ${t*e} pairs at best, below the ${o} a controlled verdict requires \u2014 add cases rather than replaying these`}:{passes:l,expectedPairs:r,feasible:!0}}g(Qe,"planPasses");var Ve=60,Ye=5,We=g(t=>Array.isArray(t)?t.filter(o=>typeof o=="string"):[],"stringList"),J=g(t=>typeof t=="number"&&Number.isFinite(t)?t:null,"finite");function Ze(t,o,e=Ye){let i=[...t].filter(s=>s.fromContentHash===o).sort((s,c)=>Date.parse(c.createdAt)-Date.parse(s.createdAt)),l=[],r=new Set;for(let s of i){let c=s.toContentHash??s.id;if(r.has(c))continue;r.add(c);let d=s.verdict??null,k=J(d?.delta),M=J(d?.ci?.lower),x=J(d?.ci?.upper),S=J(d?.nWith),L=d?.sufficient===!0&&k!=null&&M!=null&&x!=null&&S!=null?{delta:k,ciLower:M,ciUpper:x,nPairs:S}:null;if(l.push({decision:typeof s.decision=="string"?s.decision:"unknown",applied:s.applied===!0,at:typeof s.createdAt=="string"?s.createdAt:"",rationale:typeof s.proposalRationale=="string"?s.proposalRationale:"",touched:We(s.touchedSections),refusals:We(s.refusals),measured:L}),l.length>=e)break}return l}g(Ze,"summarisePriorDecisions");function et(t,o){let e=o.accumulate??(t.autoEvolveAccumulate===!0||t.autoEvolveAccumulate==="true"),i=o.accumulateTargetPairs??t.autoEvolveAccumulateTarget,l=typeof i=="string"?Number.parseInt(i,10):i,r=typeof l=="number"&&Number.isInteger(l)&&l>0?l:Ve;return{enabled:e,targetPairs:r}}g(et,"readAccumulateConfig");function tt(t){let o=t.accumulateEnabled&&t.pairCount<t.targetPairs;return{apply:t.consented&&!o,peeking:o}}g(tt,"resolveApply");async function Pt(t,o){if(t.restoration)return Pe(t.evalTargetId,t.restoration);let e=g(n=>o?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:i}=t,l=t.measurement?ye(t):{},r=`[cron_instruction_evolution] ${i}`,s=await y(`/api/eval-targets/${i}`),c=s.metadata??{},d=t.measurement?JSON.stringify([l.engine,l.model,l.graderEngine,l.graderModel,s.type,ve(t.measurement.engine)]):void 0,k=null,M=!1;if(s.name.startsWith("/")&&Te(s.name))try{if(k=Ne(s.name,"utf8"),k!==s.content){let n=await te(`/api/eval-targets/${i}/sync-content`,{content:k});M=n.synced,e(`${r}: target content drifted from disk by ${Math.abs(k.length-s.content.length)} chars \u2014 synced to disk truth (v${n.version}). Prior verdicts against the old text dissolve via content-hash keying.`),s={...s,content:k,version:n.version}}}catch(n){e(`${r}: disk sync failed (${n instanceof Error?n.message:String(n)}) \u2014 measuring the stored snapshot`)}let x=!1;try{x=(await y("/api/settings/evolution-account")).paused}catch(n){e(`${r}: could not read the account switch (${n instanceof Error?n.message:String(n)}) \u2014 pausing to be safe`),x=!0}if(x)return e(`${r}: PAUSED for the whole account (profiles.evolution_paused) \u2014 no model budget spent.`),{skipped:"paused-account"};if(ge(c))return e(`${r}: PAUSED (metadata.autoEvolvePaused) \u2014 no model budget spent. Opt-in is intact.`),{skipped:"paused"};let S=_e(s);if(S)return e(`${r}: ${S.reason}`),S;let L=t.apply??(c.autoEvolveApply===!0||c.autoEvolveApply==="true"),F=nt(c);if(F==null){if(L)return e(`${r}: refusing \u2014 metadata.immutableSections is unset. Set it (use [] to explicitly protect nothing) before letting the loop edit this target unattended.`),{skipped:"immutable-sections-unset"};e(`${r}: metadata.immutableSections unset \u2014 measure-only cycle proceeds with [] (nothing protected). Writing still requires setting it explicitly.`),F=[]}let v=(await y(`/api/eval-targets/${i}/evals`)).filter(n=>!n.retiredAt);if(v.length===0)return{skipped:"no-live-cases"};let j=me(c);j.note&&e(`${r}: ${j.note}`);let C=Qe(v.length,j.minPairs,Be(j,v.length));if(!C.feasible)return e(`${r}: cannot reach a sufficient verdict \u2014 ${C.reason}`),{skipped:"cannot-reach-min-n",reason:C.reason};let Fe=fe({liveCases:v.length,passes:C.passes});e(`${r}: budget for this run \u2014 ${$e(Fe)}`);let G=await y(`/api/eval-targets/${i}/judge-calibration`);if(!G.powerCheck.adequate){let n=(G.powerCheck.reasons??[]).join("; ");return e(`${r}: not adequately powered, skipping before spending budget \u2014 ${n}`),{skipped:"not-adequate",reason:n}}let oe=de,je=Date.now()-oe*24*60*60*1e3,X=await y(`/api/eval-targets/${i}/promotions?limit=200`),ie=X.promotions.filter(n=>n.applied&&Date.parse(n.createdAt)>=je).length;if(ie>=ne)return e(`${r}: change budget looks exhausted (${ie}/${ne} applied in ${oe}d), skipping before spending budget`),{skipped:"budget-exhausted"};try{let n=await y("/api/usage/current-limits"),u=Re({limits:n,now:new Date});if(!u.ok)return e(`${r}: deferring before spending budget \u2014 ${u.reason}`),{skipped:"quota-exhausted",reason:u.reason}}catch(n){e(`${r}: quota unknown (${n instanceof Error?n.message:String(n)}) \u2014 proceeding`)}let U=ue();if(!U.green)return e(`${r}: A/A canary is RED \u2014 halting. ${U.failures.join(" | ")}`),{skipped:"canary-red",reason:U.failures.join(" | ")};let z=s.content,D=H(z),f=et(c,t),w=f.enabled?re(X.promotions,D,f.targetPairs,d):null,b,q,$=[],_=0,B=pe,p=w?null:Se(c,D,d);if(p){b=p.content,q="",B=0;try{$=await Ie({evalTargetId:i,candidateContentHash:p.hash,executionKey:d,observedKey:p.observedKey})}catch(n){return e(`${r}: could not rebuild banked pairs (${n instanceof Error?n.message:String(n)})`),{skipped:"resume-read-failed",reason:p.hash}}e(`${r}: resuming interrupted cycle \u2014 ${$.length}/${p.plannedPairs} pair(s) rebuilt from eval_runs, no proposal call spent`)}else if(w){let n=await y(`/api/promotions/${w.promotionId}`);if(H(n.toContent)!==w.candidateContentHash)return e(`${r}: stored candidate does not match its recorded hash \u2014 refusing to continue`),{skipped:"accumulation-hash-mismatch",reason:w.promotionId};b=n.toContent,q=n.proposalRationale??"",$=w.pairs,_=w.runs,B=0,e(`${r}: continuing accumulation ${w.promotionId} \u2014 ${$.length}/${f.targetPairs} pair(s) carried from ${_} prior run(s)`)}else{let n=G.caseDiscrimination?.cases??[],u=[];if(s.name.startsWith("/")){let a=s.name.slice(0,s.name.lastIndexOf("/"));try{let m=await y(`/api/insights/evidence?projectPath=${encodeURIComponent(a)}`);m.analyzedAt&&(u=[...m.friction.map(ee=>`Real-session friction (insights, ${m.analyzedAt.slice(0,10)}): ${ee}`),...m.whatWorks.map(ee=>`Working well in real sessions \u2014 do not break: ${ee}`)],u.length>0&&e(`${r}: proposer sees ${m.friction.length} friction + ${m.whatWorks.length} what-works item(s) from insights`))}catch(m){e(`${r}: insights evidence unavailable (${m instanceof Error?m.message:String(m)}) \u2014 proposing without it`)}}let N=[];try{N=Ze(X.promotions,D)}catch(a){e(`${r}: could not summarise prior decisions (${a instanceof Error?a.message:String(a)}) \u2014 proposing without them`)}N.length>0&&e(`${r}: proposer sees ${N.length} prior decision(s) against this exact body (${N.map(a=>`${a.decision}${a.measured?"/measured":""}`).join(", ")})`);let W=await Me({currentContent:s.content,targetType:s.type,targetName:s.name,immutableSections:F,evidence:{nonDiscriminating:n.filter(a=>!a.discriminating).map(a=>`${a.name??a.assertion??"unnamed"} \u2014 ${a.note}`),weakest:n.filter(a=>a.discriminating&&a.withPassRate<a.withoutPassRate).map(a=>({name:a.name??a.assertion??"unnamed",withPassRate:a.withPassRate,withoutPassRate:a.withoutPassRate})),priorDecisions:N,notes:u}},void 0,t.measurement?(a,m)=>we(t.measurement,a,m):void 0);if(!W.ok)return e(`${r}: no usable proposal \u2014 ${W.reason}`),{skipped:"no-proposal",reason:W.reason};b=W.proposal.candidateContent,q=W.proposal.rationale}let I=p?De({plannedPairs:p.plannedPairs||C.expectedPairs,carriedPairs:$.length,liveCases:v.length}):C.passes;e(`${r}: measuring ${v.length} case(s) x ${I} pass(es) = up to ${v.length*I} pairs, candidate vs prior version`+(p?` (resumed; ${$.length} pair(s) already banked)`:""));let E=[],K=[],Ue=Date.now(),le=0,Q=0;for(let n=1;n<=I;n++){let u=await Ae({cases:v,candidateContent:b,priorVersionContent:z,concurrency:t.concurrency??2,runNumber:n,opts:{targetId:i,targetVersion:s.version??1,iteration:1,timeout:t.timeout??24e4,model:t.model,graderModel:t.graderModel,graderEngine:t.graderEngine,...l,executionKey:d,skipGrading:!1,targetType:s.type,targetName:s.name,candidateContentHash:H(b)},onLog:e});if(E.push(...u.pairs),K.push(...u.results),le+=u.completed,Q+=u.failed,e(`${r}: pass ${n}/${I} \u2014 ${u.pairs.length} pair(s), running total ${E.length}`),u.abortedForQuota){e(`${r}: stopping after pass ${n}/${I} \u2014 ${u.abortedForQuota}. Remaining passes would spend against an exhausted account.`);break}}let O=ke(K),qe=p?.observedKey??w?.observedKey;if(t.measurement&&E.length>0&&(!O||$.length>0&&qe!==O))return{skipped:"incomparable-execution",reason:"Actual actor/judge models or delivery changed; recorded runs are retained, but incompatible evidence cannot be pooled or promoted."};let A=[...$,...E],T=Ce(K),V=E.length>0,h=he({runs:K,plannedPairs:C.expectedPairs,usablePairs:E.length,verdictPairs:V?A.length:E.length,proposalCalls:B,passes:I,liveCases:v.length,wallMs:Date.now()-Ue});if(e(`${r}: ${le} completed, ${Q} failed, ${E.length} usable pair(s) \u2014 spent ~${h.modelCalls} model calls (${h.proposalCalls} proposal + ${h.executorCalls} executor + >=${h.graderCalls} grader) in ${(h.wallMs/6e4).toFixed(1)} min`+(V?`; the ${h.verdictPairs} pair(s) behind this verdict resolve +/-${be(h.mde)} at 80% power`:"")),!V)return{skipped:T.infrastructureFailed?"infrastructure-failure":"no-pairs",reason:T.infrastructureFailed?`${T.infrastructureFailed} run(s) never executed (${T.summary.describe()}) \u2014 the environment failed, not the target`:`${Q} run(s) failed or were ungradeable`,cost:h};let Y=Ee({pairs:A.length,minPairs:10,accounting:T});if(Y.kind==="infrastructure-incomplete")return e(`${r}: not posting a verdict \u2014 ${Y.reason}`),await se({evalTargetId:i,meta:c,blob:Oe({executionKey:d,...O?{observedKey:O}:{},content:b,hash:H(b),priorHash:D,plannedPairs:p?.plannedPairs||C.expectedPairs,now:new Date}),log:e,tag:r}),{skipped:"infrastructure-incomplete",reason:Y.reason,cost:h};f.enabled&&e(`${r}: accumulated ${A.length}/${f.targetPairs} pair(s) over ${_+1} run(s) on one candidate`);let ce=L,{apply:Ke,peeking:Je}=tt({consented:ce,accumulateEnabled:f.enabled,pairCount:A.length,targetPairs:f.targetPairs});ce&&Je&&e(`${r}: interim readout at ${A.length}/${f.targetPairs} pairs \u2014 recording the decision but not acting until the target is reached`);let P=await te(`/api/eval-targets/${i}/promotions`,{candidateContent:b,proposalSource:"llm",proposalRationale:q,pairs:A,canaryGreen:U.green,measuredAgainstContentHash:D,immutableSections:F,apply:Ke,measurementCost:h,...f.enabled?{accumulation:{executionKey:d,...O?{observedKey:O}:{},candidateContentHash:H(b),priorContentHash:D,targetPairs:f.targetPairs,carriedPairs:$.length,runs:_+1}}:{}});e(`${r}: ${P.decision}${P.applied?" (APPLIED)":""} \u2014 ${P.rationale}`+(P.refusals.length>0?` | refusals: ${P.refusals.join("; ")}`:"")),(p||c[xe])&&await se({evalTargetId:i,meta:c,blob:null,log:e,tag:r});let Z=!1,R;if(P.applied&&s.name.startsWith("/"))try{Te(s.name)?Ne(s.name,"utf8")!==z?R="file changed since measurement started \u2014 refusing to clobber; next cycle re-syncs":(Xe(s.name,b,"utf8"),Z=!0):R="file no longer exists on disk",e(Z?`${r}: measured improvement written to ${s.name} (undo: git checkout -- ${s.name})`:`${r}: NOT written to disk \u2014 ${R}`)}catch(n){R=n instanceof Error?n.message:String(n),e(`${r}: disk write-back failed \u2014 ${R}. The eval target is updated; the file is not.`)}return{decision:P.decision,applied:P.applied,nPairs:A.length,promotionId:P.id,cost:h,diskSynced:M,...P.applied?{fileWritten:Z,...R?{fileWriteSkipped:R}:{}}:{},...f.enabled?{carriedPairs:$.length,accumulationRuns:_+1}:{}}}g(Pt,"cronInstructionEvolution");function nt(t){let o=t.immutableSections;return o==null||!Array.isArray(o)?null:o.filter(e=>typeof e=="string")}g(nt,"readImmutableSections");export{Le as a,ae as b,ze as c,Be as d,Qe as e,Ve as f,Ye as g,Ze as h,et as i,tt as j,Pt as k,nt as l};
|
|
1
|
+
import{a as _e}from"./chunk-M7QSC64D.js";import{i as Me}from"./chunk-CEM7JMUW.js";import{a as Pe}from"./chunk-L3AXNCWC.js";import{a as xe,b as Se,c as De,d as Ie,e as se,f as Oe}from"./chunk-ANHFE6US.js";import{b as pe,i as me,j as ge,k as fe,l as he,m as be,n as $e}from"./chunk-GYKYJJNF.js";import{c as Re}from"./chunk-G7V4ZZZ3.js";import{a as re}from"./chunk-AHLVY52I.js";import{d as ke,f as Ce,g as Ee,i as Ae}from"./chunk-YX2IGS72.js";import{a as we}from"./chunk-55HFAX5Y.js";import{c as ye}from"./chunk-AXTEV56C.js";import{b as ve}from"./chunk-VZYNZS5U.js";import{d as ue,e as ne,f as de}from"./chunk-KFNFLMUR.js";import{e as y,f as te}from"./chunk-Z7UN4R7T.js";import{a as g}from"./chunk-ZLLER3HP.js";import{createHash as Ge}from"node:crypto";import{existsSync as Te,readFileSync as Ne,writeFileSync as Xe}from"node:fs";var H=g(t=>Ge("sha256").update(t).digest("hex"),"sha256"),Le=1.3,ae=4,ze=20;function Be(t,o){if(!t.configured||o<=0)return ae;let e=Math.ceil(t.minPairs*Le/o);return Math.min(ze,Math.max(ae,e))}g(Be,"passCapFor");function Qe(t,o=10,e=ae){if(t<=0)return{passes:0,expectedPairs:0,feasible:!1,reason:"no live cases"};let i=Math.ceil(o*Le),l=Math.min(e,Math.ceil(i/t)),r=l*t;return r<o?{passes:l,expectedPairs:r,feasible:!1,reason:`${t} live case(s) x ${e} passes = ${t*e} pairs at best, below the ${o} a controlled verdict requires \u2014 add cases rather than replaying these`}:{passes:l,expectedPairs:r,feasible:!0}}g(Qe,"planPasses");var Ve=60,Ye=5,We=g(t=>Array.isArray(t)?t.filter(o=>typeof o=="string"):[],"stringList"),J=g(t=>typeof t=="number"&&Number.isFinite(t)?t:null,"finite");function Ze(t,o,e=Ye){let i=[...t].filter(s=>s.fromContentHash===o).sort((s,c)=>Date.parse(c.createdAt)-Date.parse(s.createdAt)),l=[],r=new Set;for(let s of i){let c=s.toContentHash??s.id;if(r.has(c))continue;r.add(c);let d=s.verdict??null,k=J(d?.delta),M=J(d?.ci?.lower),x=J(d?.ci?.upper),S=J(d?.nWith),L=d?.sufficient===!0&&k!=null&&M!=null&&x!=null&&S!=null?{delta:k,ciLower:M,ciUpper:x,nPairs:S}:null;if(l.push({decision:typeof s.decision=="string"?s.decision:"unknown",applied:s.applied===!0,at:typeof s.createdAt=="string"?s.createdAt:"",rationale:typeof s.proposalRationale=="string"?s.proposalRationale:"",touched:We(s.touchedSections),refusals:We(s.refusals),measured:L}),l.length>=e)break}return l}g(Ze,"summarisePriorDecisions");function et(t,o){let e=o.accumulate??(t.autoEvolveAccumulate===!0||t.autoEvolveAccumulate==="true"),i=o.accumulateTargetPairs??t.autoEvolveAccumulateTarget,l=typeof i=="string"?Number.parseInt(i,10):i,r=typeof l=="number"&&Number.isInteger(l)&&l>0?l:Ve;return{enabled:e,targetPairs:r}}g(et,"readAccumulateConfig");function tt(t){let o=t.accumulateEnabled&&t.pairCount<t.targetPairs;return{apply:t.consented&&!o,peeking:o}}g(tt,"resolveApply");async function Pt(t,o){if(t.restoration)return Pe(t.evalTargetId,t.restoration);let e=g(n=>o?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:i}=t,l=t.measurement?ye(t):{},r=`[cron_instruction_evolution] ${i}`,s=await y(`/api/eval-targets/${i}`),c=s.metadata??{},d=t.measurement?JSON.stringify([l.engine,l.model,l.graderEngine,l.graderModel,s.type,ve(t.measurement.engine)]):void 0,k=null,M=!1;if(s.name.startsWith("/")&&Te(s.name))try{if(k=Ne(s.name,"utf8"),k!==s.content){let n=await te(`/api/eval-targets/${i}/sync-content`,{content:k});M=n.synced,e(`${r}: target content drifted from disk by ${Math.abs(k.length-s.content.length)} chars \u2014 synced to disk truth (v${n.version}). Prior verdicts against the old text dissolve via content-hash keying.`),s={...s,content:k,version:n.version}}}catch(n){e(`${r}: disk sync failed (${n instanceof Error?n.message:String(n)}) \u2014 measuring the stored snapshot`)}let x=!1;try{x=(await y("/api/settings/evolution-account")).paused}catch(n){e(`${r}: could not read the account switch (${n instanceof Error?n.message:String(n)}) \u2014 pausing to be safe`),x=!0}if(x)return e(`${r}: PAUSED for the whole account (profiles.evolution_paused) \u2014 no model budget spent.`),{skipped:"paused-account"};if(ge(c))return e(`${r}: PAUSED (metadata.autoEvolvePaused) \u2014 no model budget spent. Opt-in is intact.`),{skipped:"paused"};let S=_e(s);if(S)return e(`${r}: ${S.reason}`),S;let L=t.apply??(c.autoEvolveApply===!0||c.autoEvolveApply==="true"),F=nt(c);if(F==null){if(L)return e(`${r}: refusing \u2014 metadata.immutableSections is unset. Set it (use [] to explicitly protect nothing) before letting the loop edit this target unattended.`),{skipped:"immutable-sections-unset"};e(`${r}: metadata.immutableSections unset \u2014 measure-only cycle proceeds with [] (nothing protected). Writing still requires setting it explicitly.`),F=[]}let v=(await y(`/api/eval-targets/${i}/evals`)).filter(n=>!n.retiredAt);if(v.length===0)return{skipped:"no-live-cases"};let j=me(c);j.note&&e(`${r}: ${j.note}`);let C=Qe(v.length,j.minPairs,Be(j,v.length));if(!C.feasible)return e(`${r}: cannot reach a sufficient verdict \u2014 ${C.reason}`),{skipped:"cannot-reach-min-n",reason:C.reason};let Fe=fe({liveCases:v.length,passes:C.passes});e(`${r}: budget for this run \u2014 ${$e(Fe)}`);let G=await y(`/api/eval-targets/${i}/judge-calibration`);if(!G.powerCheck.adequate){let n=(G.powerCheck.reasons??[]).join("; ");return e(`${r}: not adequately powered, skipping before spending budget \u2014 ${n}`),{skipped:"not-adequate",reason:n}}let oe=de,je=Date.now()-oe*24*60*60*1e3,X=await y(`/api/eval-targets/${i}/promotions?limit=200`),ie=X.promotions.filter(n=>n.applied&&Date.parse(n.createdAt)>=je).length;if(ie>=ne)return e(`${r}: change budget looks exhausted (${ie}/${ne} applied in ${oe}d), skipping before spending budget`),{skipped:"budget-exhausted"};try{let n=await y("/api/usage/current-limits"),u=Re({limits:n,now:new Date});if(!u.ok)return e(`${r}: deferring before spending budget \u2014 ${u.reason}`),{skipped:"quota-exhausted",reason:u.reason}}catch(n){e(`${r}: quota unknown (${n instanceof Error?n.message:String(n)}) \u2014 proceeding`)}let U=ue();if(!U.green)return e(`${r}: A/A canary is RED \u2014 halting. ${U.failures.join(" | ")}`),{skipped:"canary-red",reason:U.failures.join(" | ")};let z=s.content,D=H(z),f=et(c,t),w=f.enabled?re(X.promotions,D,f.targetPairs,d):null,b,q,$=[],_=0,B=pe,p=w?null:Se(c,D,d);if(p){b=p.content,q="",B=0;try{$=await Ie({evalTargetId:i,candidateContentHash:p.hash,executionKey:d,observedKey:p.observedKey})}catch(n){return e(`${r}: could not rebuild banked pairs (${n instanceof Error?n.message:String(n)})`),{skipped:"resume-read-failed",reason:p.hash}}e(`${r}: resuming interrupted cycle \u2014 ${$.length}/${p.plannedPairs} pair(s) rebuilt from eval_runs, no proposal call spent`)}else if(w){let n=await y(`/api/promotions/${w.promotionId}`);if(H(n.toContent)!==w.candidateContentHash)return e(`${r}: stored candidate does not match its recorded hash \u2014 refusing to continue`),{skipped:"accumulation-hash-mismatch",reason:w.promotionId};b=n.toContent,q=n.proposalRationale??"",$=w.pairs,_=w.runs,B=0,e(`${r}: continuing accumulation ${w.promotionId} \u2014 ${$.length}/${f.targetPairs} pair(s) carried from ${_} prior run(s)`)}else{let n=G.caseDiscrimination?.cases??[],u=[];if(s.name.startsWith("/")){let a=s.name.slice(0,s.name.lastIndexOf("/"));try{let m=await y(`/api/insights/evidence?projectPath=${encodeURIComponent(a)}`);m.analyzedAt&&(u=[...m.friction.map(ee=>`Real-session friction (insights, ${m.analyzedAt.slice(0,10)}): ${ee}`),...m.whatWorks.map(ee=>`Working well in real sessions \u2014 do not break: ${ee}`)],u.length>0&&e(`${r}: proposer sees ${m.friction.length} friction + ${m.whatWorks.length} what-works item(s) from insights`))}catch(m){e(`${r}: insights evidence unavailable (${m instanceof Error?m.message:String(m)}) \u2014 proposing without it`)}}let N=[];try{N=Ze(X.promotions,D)}catch(a){e(`${r}: could not summarise prior decisions (${a instanceof Error?a.message:String(a)}) \u2014 proposing without them`)}N.length>0&&e(`${r}: proposer sees ${N.length} prior decision(s) against this exact body (${N.map(a=>`${a.decision}${a.measured?"/measured":""}`).join(", ")})`);let W=await Me({currentContent:s.content,targetType:s.type,targetName:s.name,immutableSections:F,evidence:{nonDiscriminating:n.filter(a=>!a.discriminating).map(a=>`${a.name??a.assertion??"unnamed"} \u2014 ${a.note}`),weakest:n.filter(a=>a.discriminating&&a.withPassRate<a.withoutPassRate).map(a=>({name:a.name??a.assertion??"unnamed",withPassRate:a.withPassRate,withoutPassRate:a.withoutPassRate})),priorDecisions:N,notes:u}},void 0,t.measurement?(a,m)=>we(t.measurement,a,m):void 0);if(!W.ok)return e(`${r}: no usable proposal \u2014 ${W.reason}`),{skipped:"no-proposal",reason:W.reason};b=W.proposal.candidateContent,q=W.proposal.rationale}let I=p?De({plannedPairs:p.plannedPairs||C.expectedPairs,carriedPairs:$.length,liveCases:v.length}):C.passes;e(`${r}: measuring ${v.length} case(s) x ${I} pass(es) = up to ${v.length*I} pairs, candidate vs prior version`+(p?` (resumed; ${$.length} pair(s) already banked)`:""));let E=[],K=[],Ue=Date.now(),le=0,Q=0;for(let n=1;n<=I;n++){let u=await Ae({cases:v,candidateContent:b,priorVersionContent:z,concurrency:t.concurrency??2,runNumber:n,opts:{targetId:i,targetVersion:s.version??1,iteration:1,timeout:t.timeout??24e4,model:t.model,graderModel:t.graderModel,graderEngine:t.graderEngine,...l,executionKey:d,skipGrading:!1,targetType:s.type,targetName:s.name,candidateContentHash:H(b)},onLog:e});if(E.push(...u.pairs),K.push(...u.results),le+=u.completed,Q+=u.failed,e(`${r}: pass ${n}/${I} \u2014 ${u.pairs.length} pair(s), running total ${E.length}`),u.abortedForQuota){e(`${r}: stopping after pass ${n}/${I} \u2014 ${u.abortedForQuota}. Remaining passes would spend against an exhausted account.`);break}}let O=ke(K),qe=p?.observedKey??w?.observedKey;if(t.measurement&&E.length>0&&(!O||$.length>0&&qe!==O))return{skipped:"incomparable-execution",reason:"Actual actor/judge models or delivery changed; recorded runs are retained, but incompatible evidence cannot be pooled or promoted."};let A=[...$,...E],T=Ce(K),V=E.length>0,h=he({runs:K,plannedPairs:C.expectedPairs,usablePairs:E.length,verdictPairs:V?A.length:E.length,proposalCalls:B,passes:I,liveCases:v.length,wallMs:Date.now()-Ue});if(e(`${r}: ${le} completed, ${Q} failed, ${E.length} usable pair(s) \u2014 spent ~${h.modelCalls} model calls (${h.proposalCalls} proposal + ${h.executorCalls} executor + >=${h.graderCalls} grader) in ${(h.wallMs/6e4).toFixed(1)} min`+(V?`; the ${h.verdictPairs} pair(s) behind this verdict resolve +/-${be(h.mde)} at 80% power`:"")),!V)return{skipped:T.infrastructureFailed?"infrastructure-failure":"no-pairs",reason:T.infrastructureFailed?`${T.infrastructureFailed} run(s) never executed (${T.summary.describe()}) \u2014 the environment failed, not the target`:`${Q} run(s) failed or were ungradeable`,cost:h};let Y=Ee({pairs:A.length,minPairs:10,accounting:T});if(Y.kind==="infrastructure-incomplete")return e(`${r}: not posting a verdict \u2014 ${Y.reason}`),await se({evalTargetId:i,meta:c,blob:Oe({executionKey:d,...O?{observedKey:O}:{},content:b,hash:H(b),priorHash:D,plannedPairs:p?.plannedPairs||C.expectedPairs,now:new Date}),log:e,tag:r}),{skipped:"infrastructure-incomplete",reason:Y.reason,cost:h};f.enabled&&e(`${r}: accumulated ${A.length}/${f.targetPairs} pair(s) over ${_+1} run(s) on one candidate`);let ce=L,{apply:Ke,peeking:Je}=tt({consented:ce,accumulateEnabled:f.enabled,pairCount:A.length,targetPairs:f.targetPairs});ce&&Je&&e(`${r}: interim readout at ${A.length}/${f.targetPairs} pairs \u2014 recording the decision but not acting until the target is reached`);let P=await te(`/api/eval-targets/${i}/promotions`,{candidateContent:b,proposalSource:"llm",proposalRationale:q,pairs:A,canaryGreen:U.green,measuredAgainstContentHash:D,immutableSections:F,apply:Ke,measurementCost:h,...f.enabled?{accumulation:{executionKey:d,...O?{observedKey:O}:{},candidateContentHash:H(b),priorContentHash:D,targetPairs:f.targetPairs,carriedPairs:$.length,runs:_+1}}:{}});e(`${r}: ${P.decision}${P.applied?" (APPLIED)":""} \u2014 ${P.rationale}`+(P.refusals.length>0?` | refusals: ${P.refusals.join("; ")}`:"")),(p||c[xe])&&await se({evalTargetId:i,meta:c,blob:null,log:e,tag:r});let Z=!1,R;if(P.applied&&s.name.startsWith("/"))try{Te(s.name)?Ne(s.name,"utf8")!==z?R="file changed since measurement started \u2014 refusing to clobber; next cycle re-syncs":(Xe(s.name,b,"utf8"),Z=!0):R="file no longer exists on disk",e(Z?`${r}: measured improvement written to ${s.name} (undo: git checkout -- ${s.name})`:`${r}: NOT written to disk \u2014 ${R}`)}catch(n){R=n instanceof Error?n.message:String(n),e(`${r}: disk write-back failed \u2014 ${R}. The eval target is updated; the file is not.`)}return{decision:P.decision,applied:P.applied,nPairs:A.length,promotionId:P.id,cost:h,diskSynced:M,...P.applied?{fileWritten:Z,...R?{fileWriteSkipped:R}:{}}:{},...f.enabled?{carriedPairs:$.length,accumulationRuns:_+1}:{}}}g(Pt,"cronInstructionEvolution");function nt(t){let o=t.immutableSections;return o==null||!Array.isArray(o)?null:o.filter(e=>typeof e=="string")}g(nt,"readImmutableSections");export{Le as a,ae as b,ze as c,Be as d,Qe as e,Ve as f,Ye as g,Ze as h,et as i,tt as j,Pt as k,nt as l};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as $}from"./chunk-
|
|
1
|
+
import{b as $}from"./chunk-AZB34RT6.js";import{a as C}from"./chunk-TL57YUJV.js";import{a as y}from"./chunk-U6AASXY3.js";import{g as f}from"./chunk-LARY6ZFT.js";import{e as h,f as w}from"./chunk-Z7UN4R7T.js";import{a as v}from"./chunk-ZLLER3HP.js";async function N(n,i,p){let{conversationId:a,messageId:g,messageContent:r}=n,o=await h(`/api/eval-targets/${i}`),c=await h(`/api/eval-targets/${i}/evals`),e=await h(`/api/eval-conversations/${a}/messages`),t=e.findIndex(l=>l.id===g);if(t>=0&&e.slice(t+1).some(u=>u.role==="assistant"&&(u.type==="results"||u.type==="proposal"||u.type==="generated"||u.type==="text"))){p(`Message ${g} already processed \u2014 skipping (idempotency guard)`);return}let s=v(async(l,u,m)=>{await w(`/api/eval-conversations/${a}/messages/assistant`,{content:l,type:u,data:m})},"postMessage"),d=await _(o,c,e,r,p);p(`Action: ${d.action}`);try{switch(d.action){case"run_evals":await x(o,c,a,s,p);break;case"generate_cases":await k(o,i,a,s,p);break;case"analyze_results":case"propose_changes":await E(o,c,e,r,a,s,p);break;case"respond":await s(d.response,"text");break}}catch(l){let u=l instanceof Error?l.message:String(l);throw await s(`Something went wrong: ${u}`,"text").catch(()=>{}),l}}v(N,"processConversationJob");async function _(n,i,p,a,g){let r=p.slice(-10).map(e=>`${e.role}: ${e.content.slice(0,200)}`).join(`
|
|
2
2
|
`),o=`You are an eval assistant. Decide what action to take based on the user's message.
|
|
3
3
|
|
|
4
4
|
## Current State
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as E}from"./chunk-
|
|
1
|
+
import{d as E}from"./chunk-AXTEV56C.js";import{b as F,c as x}from"./chunk-KGURGIZ2.js";import{f as R}from"./chunk-Z7UN4R7T.js";import{a}from"./chunk-ZLLER3HP.js";var _="with_candidate",w="with_prior_version";function S(e){return JSON.stringify([e.outputs.engine??null,e.outputs.model??null,e.outputs.methodology??null,e.outputs.deliveryRegime??null,e.grading.judge_engine??null,e.grading.judge_model??null])}a(S,"observedExecutionKey");function I(e){let r=e.filter(n=>n.status==="completed"),i=new Set(r.map(n=>JSON.stringify([n.outputs.engine??null,n.outputs.model??null,n.outputs.methodology??null,n.outputs.deliveryRegime??null]))),t=new Set(r.filter(n=>n.grading.judge_model!=null).map(n=>JSON.stringify([n.grading.judge_engine??"claude",n.grading.judge_model])));return i.size===1&&t.size<=1?JSON.stringify([[...i][0],[...t][0]??null]):null}a(I,"measurementBatchKey");function A(e){let r=e.filter(t=>t.configuration===_),i=[];for(let t of r){let n=e.find(s=>s.configuration===w&&s.evalId===t.evalId&&s.runNumber===t.runNumber);if(!n||S(n)!==S(t))continue;let l=h(t),m=h(n);l==null||m==null||i.push({withScore:l,withoutScore:m})}return i}a(A,"pairCandidateRuns");function h(e){return e.status!=="completed"?null:e.grading?.summary?.pass_rate??null}a(h,"evidenceOf");function $(e){let r=[],i=0;for(let t of e){if(t.status==="failed"){r.push(t.failure??{kind:"unknown",class:"infrastructure"});continue}h(t)==null&&(i+=1)}return{infrastructureFailed:r.length,ungradeable:i,summary:F(r)}}a($,"accountForFailures");function Q(e){let{pairs:r,minPairs:i,accounting:t}=e;return r>=i?{kind:"proceed"}:t.infrastructureFailed<=0?{kind:"proceed"}:{kind:"infrastructure-incomplete",reason:`${r}/${i} pair(s) \u2014 ${t.infrastructureFailed} run(s) never executed (${t.summary.describe()}). Retry when the environment recovers; this is not a statement about the target.`}}a(Q,"attributeShortfall");function k(e,r,i,t){let n=[];for(let l of e)n.push({eval_:l,configuration:_,targetContent:r,runNumber:t}),n.push({eval_:l,configuration:w,targetContent:i,runNumber:t});return n}a(k,"buildCandidateQueue");async function j(e){let{cases:r,candidateContent:i,priorVersionContent:t,concurrency:n,runNumber:l,opts:m,onLog:s=a(()=>{},"onLog")}=e,g=k(r,i,t,l),o=[],y=Math.max(1,n),p=null;for(let u=0;u<g.length;u+=y){let d=g.slice(u,u+y);o.push(...await Promise.all(d.map(c=>E(c,m,s))));let C=o.find(c=>c.failure&&x(c.failure.kind));if(C?.failure){p=C.failure.kind;let c=g.length-o.length;s(` \u26D4 aborting batch \u2014 ${p}: the account is out of quota. Skipped ${c} remaining run(s) that would certainly have failed.`);break}}for(let u of o)try{await R("/api/eval-runs",u)}catch(d){s(` \u26A0 failed to post a run result: ${d instanceof Error?d.message:String(d)}`)}let b=A(o),f=$(o),v=r.length-b.length;if(v>0){let u=f.infrastructureFailed?` \u2014 ${f.infrastructureFailed} run(s) never executed (${f.summary.describe()})`:"";s(` \u26A0 ${v}/${r.length} case(s) produced no usable pair (failed or ungradeable arm)${u}`)}return{completed:o.filter(u=>u.status==="completed").length,failed:o.filter(u=>u.status==="failed").length,results:o,pairs:b,accounting:f,abortedForQuota:p}}a(j,"runCandidateBatchAndPost");export{_ as a,w as b,S as c,I as d,A as e,$ as f,Q as g,k as h,j as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as A}from"./chunk-X6CF5KTW.js";import{a as T,e as w}from"./chunk-PZNWH4VQ.js";import{a as n}from"./chunk-ZLLER3HP.js";import{fileURLToPath as _}from"node:url";import{existsSync as v,readFileSync as O}from"node:fs";import{dirname as E,join as b}from"node:path";function k(){let t=E(_(import.meta.url));for(let e=0;e<8;e++){let s=b(t,"package.json");if(v(s))try{let i=JSON.parse(O(s,"utf8"));if(i.name==="@rulemetric/cli"&&i.version)return i.version}catch{}let o=E(t);if(o===t)break;t=o}return"0.0.0"}n(k,"readCliVersion");var x=k(),C="https://rulemetric.com",u=class extends Error{constructor(s,o){super(o);this.statusCode=s;this.name="ApiError"}static{n(this,"ApiError")}};function M(){let t=T(),e=process.env.RULEMETRIC_API_URL??t.apiUrl;if(!e){if(process.env.RULEMETRIC_STRICT_LOCAL==="1"||t.strictLocal==="1")throw new Error("RULEMETRIC_STRICT_LOCAL is set but no RULEMETRIC_API_URL is configured \u2014 refusing the cloud default. Set RULEMETRIC_API_URL in the environment or ~/.config/rulemetric/env.");e=C}let s=new URL(e);if(s.protocol==="http:"&&s.hostname!=="localhost"&&s.hostname!=="127.0.0.1")throw new Error(`API URL must use HTTPS for non-localhost hosts: ${e}`);return e}n(M,"getBaseUrl");async function c(t,e={}){let o=`${M()}${t}`,i={"Content-Type":"application/json","User-Agent":`rulemetric-cli/${x}`,...e.headers},m=T(),d=process.env.RULEMETRIC_API_KEY||m.apiKey||w()?.accessToken||m.accessToken;d&&(i.Authorization=`Bearer ${d}`);let h=new URL(o),f=h.hostname==="localhost"||h.hostname==="127.0.0.1",g=process.env.HTTPS_PROXY,P=process.env.HTTP_PROXY;f&&(delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY);let a=e.timeoutMs?new AbortController:void 0,R=!1,y=a?setTimeout(()=>{R=!0,a.abort()},e.timeoutMs):void 0,r;try{r=await fetch(o,{method:e.method??"GET",headers:i,body:e.body?JSON.stringify(e.body):void 0,signal:a&&e.signal?AbortSignal.any([a.signal,e.signal]):e.signal??a?.signal})}catch(p){if(R){let L=new URL(o).host,U=Math.round(e.timeoutMs/1e3);throw new u(408,`Request to ${L} timed out after ${U}s. This is usually transient or a local proxy/gateway issue \u2014 retry, and if it persists check HTTPS_PROXY / the RuleMetric gateway (:8787).`)}throw p}finally{y&&clearTimeout(y),f&&(g!==void 0&&(process.env.HTTPS_PROXY=g),P!==void 0&&(process.env.HTTP_PROXY=P))}let l;if(r.headers.get("content-type")?.includes("application/json")?l=await r.json():l=await r.text(),!r.ok){let{message:p}=A(r.status,l);throw new u(r.status,p)}return l}n(c,"api");var j=n((t,e)=>c(t,e),"apiGet"),F=n((t,e,s={})=>c(t,{...s,method:"POST",body:e}),"apiPost"),B=n((t,e)=>c(t,{method:"PUT",body:e}),"apiPut"),D=n((t,e,s={})=>c(t,{...s,method:"PATCH",body:e}),"apiPatch"),G=n(t=>c(t,{method:"DELETE"}),"apiDelete");export{C as a,u as b,M as c,c as d,j as e,F as f,B as g,D as h,G as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G,c as I}from"./chunk-
|
|
1
|
+
import{a as G,c as I}from"./chunk-AXTEV56C.js";import{f as j}from"./chunk-VZYNZS5U.js";import{a as R}from"./chunk-U6AASXY3.js";import{b as U}from"./chunk-KFNFLMUR.js";import{g as A}from"./chunk-LARY6ZFT.js";import{b as P,e as C,h as _}from"./chunk-Z7UN4R7T.js";import{a as x}from"./chunk-ZLLER3HP.js";var J=x(l=>l.summary.pass_rate===1?1:0,"fullPassScore");async function z(l,d={}){let $=d.executeEval??A,M=d.grade??R,q=d.getExperiment??(async o=>{try{return await C(`/api/memory-experiments/${o}`)}catch(e){if(e instanceof P&&e.statusCode===404)return null;throw e}}),B=d.getMemoryBody??(async o=>{try{let e=await C(`/api/memories/${o}`);return t?.memoryVersion!=null&&e.version!==t.memoryVersion?null:e.body}catch(e){if(e instanceof P&&e.statusCode===404)return null;throw e}}),p=d.updateExperiment??(async(o,e)=>{await _(`/api/memory-experiments/${o}`,e)}),t=await q(l.experimentId);if(!t)return{skipped:"not_found"};if(t.status==="completed"||t.status==="failed")return{skipped:"already_terminal",status:t.status};let E=t.memoryBody??await B(t.memoryId);if(E==null)return await p(t.id,{status:"failed",error:"memory no longer exists or its queued version is no longer available"}),{skipped:"memory_gone",status:"failed"};await p(t.id,{status:"running"});let v=t.expectations??[],c=t.model??void 0,i=t.engine??"claude",g=G({engine:i,model:c},{engine:l.graderEngine,model:l.graderModel}),f=x(async o=>{let e=(d.createWorkspace??j)({engine:i,targetType:"prompt",targetContent:o});try{if(e.leakedFiles.length)throw new Error("Contaminated memory trial workspace");return await $({prompt:t.taskPrompt,targetContent:e.systemPrompt,appendTarget:!0,ignoreContextFiles:!0,workDir:e.workDir,model:c,engine:i})}finally{e.cleanup()}},"executeArm"),s=[],u=new Set,b,k,m=[],w=0;try{if(l.measurement){let e=I(l);if(e.engine!==i||e.model!==c)throw new Error("Memory experiment differs from its queued measurement snapshot");g={engine:e.graderEngine,model:e.graderModel}}for(let e=0;e<t.trials;e++){let[r,n]=e%2===0?[await f(E),await f()]:await(async()=>{let y=await f();return[await f(E),y]})();if(r.error||n.error||r.exitCode!==0||n.exitCode!==0||!r.output.trim()||!n.output.trim()){w++,m.push({trial:e+1,reason:(r.error??n.error??"Nonzero exit or empty output").slice(0,500)});continue}if(r.engine!==i||n.engine!==i||!r.model||!n.model||r.model!==n.model||r.provider!==n.provider||r.model&&u.size>0&&!u.has(r.model)||i==="pi"&&c&&r.model!==`pi:${c}`){w++,m.push({trial:e+1,reason:"Harness, provider or model changed within the experiment"});continue}r.model&&u.add(r.model),n.model&&u.add(n.model);let[a,h]=await Promise.all([M({prompt:t.taskPrompt,output:r.output,expectations:v,...g}),M({prompt:t.taskPrompt,output:n.output,expectations:v,...g})]),T=JSON.stringify([a.judge_engine??null,a.judge_model??null]);if([a,h].some(y=>y.summary.pass_rate==null||y.summary.errored||y.summary.total!==v.length)||a.judge_model!==h.judge_model||a.judge_engine!==h.judge_engine||b!==void 0&&b!==T){w++,m.push({trial:e+1,reason:"Grading incomplete or judge changed; not a model failure"});continue}b=T,k={engine:a.judge_engine??null,model:a.judge_model??null},s.push({withScore:J(a),withoutScore:J(h),withLatency:r.durationMs/1e3,withoutLatency:n.durationMs/1e3,withTokens:r.totalTokens,withoutTokens:n.totalTokens,...r.costUsd!==void 0?{withCostUsd:r.costUsd}:{},...n.costUsd!==void 0?{withoutCostUsd:n.costUsd}:{}})}if(s.length===0){let e=`no trials completed (${w}/${t.trials} runs errored \u2014 is the ${i} CLI available?)`;return await p(t.id,{status:"failed",error:e,result:{pairs:s,excluded:m,completedTrials:0,engine:i}}),{status:"failed",requestedTrials:t.trials,completedTrials:0}}let o=U(s.map(e=>({...e,withCost:e.withCostUsd,withoutCost:e.withoutCostUsd})));return await p(t.id,{status:"completed",result:{verdict:o,pairs:s,excluded:m,judge:g,actualJudge:k,methodology:"v2-neutral-appended-memory",completedTrials:s.length,engine:i,model:[...u][0]}}),{status:"completed",requestedTrials:t.trials,completedTrials:s.length,significant:o.significant,delta:o.delta}}catch(o){let e=o instanceof Error?o.message:String(o);return await p(t.id,{status:"failed",error:e.slice(0,500),result:{pairs:s,excluded:m,completedTrials:s.length,engine:i,model:[...u][0]??null,judge:g,actualJudge:k,methodology:"v2-neutral-appended-memory"}}).catch(()=>{}),{status:"failed",requestedTrials:t.trials,completedTrials:s.length}}}x(z,"processMemoryAb");export{z as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as v,b as u,e as y,g as d}from"../../chunk-
|
|
1
|
+
import{a as v,b as u,e as y,g as d}from"../../chunk-UDNEOJWY.js";import{a as h}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as p}from"../../chunk-ZLLER3HP.js";import{Args as k,Flags as o}from"@oclif/core";import{existsSync as T}from"node:fs";import{homedir as P}from"node:os";import{join as I}from"node:path";var A=I(P(),".gemini","antigravity-ide","brain"),g=class x extends h{static{p(this,"AntigravityBackfill")}static description="Backfill historical events from an Antigravity conversation transcript into a RuleMetric session. Useful for seeding a conversation that existed before hooks were installed \u2014 the live hook intentionally only captures forward.";static examples=["<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --session 158db9aa-68ee-43fc-961b-f3a180578694","<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --dry-run"];static args={conversationId:k.string({description:"Antigravity conversationId (UUID) \u2014 the directory name under ~/.gemini/antigravity-ide/brain/",required:!0})};static flags={session:o.string({char:"s",description:"RuleMetric session UUID to POST events into. If omitted, resolved from the hook tmp file ($TMPDIR/rulemetric/<conversationId>) \u2014 fails if neither is present."}),transcript:o.string({description:"Path to the transcript.jsonl file. Defaults to ~/.gemini/antigravity-ide/brain/<conversationId>/.system_generated/logs/transcript.jsonl"}),"after-step":o.integer({description:"Only emit records with step_index > this value. Default: read from existing state file, else -1 (everything)."}),limit:o.integer({description:"Cap on the number of records to process this run."}),"dry-run":o.boolean({default:!1,description:"Classify records without POSTing. Reports counts only."}),"save-state":o.boolean({default:!0,allowNo:!0,description:"After backfill, persist the highest step_index so the live hook resumes from there."})};async run(){let{args:b,flags:e}=await this.parse(x),t=b.conversationId;d.loadEnvFile(),process.env.RULEMETRIC_API_URL||this.error("RULEMETRIC_API_URL is not set. Configure it via env or ~/.config/rulemetric/env.");let l=e.transcript??I(A,t,".system_generated","logs","transcript.jsonl");T(l)||this.error(`Transcript not found: ${l}`);let m=e.session??d.resolveRwSessionId(t);m||this.error(`No RuleMetric session resolved. Pass --session <uuid>, or run the Antigravity hook at least once so $TMPDIR/rulemetric/${t} is populated.`);let n=e["after-step"];n===void 0&&(n=d.load(t)?.lastStepIdx??-1);let i=v(l,n);e.limit!==void 0&&i.length>e.limit&&(i=i.slice(0,e.limit));let R=u(l);if(this.log(`Conversation ${t}: transcript max step = ${R}, after-step = ${n}, records to process = ${i.length}`),i.length===0){this.log("Nothing to backfill.");return}if(e["dry-run"]){let r=0,a=0,c={};for(let S of i){let f=(await import("../../lib/antigravity-transcript.js")).classifyRecord(S,0);f?(r++,c[f.eventType]=(c[f.eventType]??0)+1):a++}this.log(`Dry run: would emit ${r}, skip ${a}. By eventType: ${JSON.stringify(c)}`);return}let w=Date.now(),s=await y(i,m,t,n,{onProgress:p(({attempted:r,total:a})=>{(r%100===0||r===a)&&process.stderr.write(` \u2026${r}/${a}
|
|
2
2
|
`)},"onProgress")}),$=((Date.now()-w)/1e3).toFixed(1);this.log(`Backfill complete in ${$}s. attempted=${s.attempted} emitted=${s.emitted} skipped=${s.skipped} failed=${s.failed} highestStepIdx=${s.highestStepIdx}`),e["save-state"]?(d.save(t,{lastStepIdx:s.highestStepIdx}),this.log(`State saved \u2192 live hook will resume from step_index > ${s.highestStepIdx}.`)):this.log("State NOT saved (--no-save-state). Live hook will re-emit any new records from after-step.")}};export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"../../chunk-
|
|
1
|
+
import{a as n}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{f as r}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import{i as o,l as s}from"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import*as c from"node:path";import{Flags as l}from"@oclif/core";var t=class g extends n{static{a(this,"AuthCreateKey")}static description="Create a long-lived API key for CLI and proxy authentication";static examples=['<%= config.bin %> auth create-key --name "laptop"','<%= config.bin %> auth create-key --name "ci token" --no-save'];static flags={name:l.string({char:"n",description:"Name for this key",required:!0}),save:l.boolean({char:"s",description:"Save key to ~/.config/rulemetric/env for hooks/proxy",default:!0,allowNo:!0})};async run(){let{flags:i}=await this.parse(g),e=await r("/api/auth/api-keys",{name:i.name});this.log(""),this.log("API key created successfully:"),this.log(""),this.log(` Name: ${e.name}`),this.log(` Key: ${e.key}`),this.log(` Prefix: ${e.keyPrefix}`),this.log(""),this.warn("Save this key now \u2014 it will not be shown again."),i.save&&(o(e.key,process.env.RULEMETRIC_API_URL),this.log(""),this.log(`Key saved to ${c.join(s(),"env")} (RULEMETRIC_API_KEY)`),this.log("Hooks and proxy will use this key automatically."))}};export{t as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as f}from"../../chunk-
|
|
1
|
+
import{a as f}from"../../chunk-EOTSCWFS.js";import{a as w}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import{c}from"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import{b as n}from"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{b as r,d as a}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import{b as m,d,h as u,i as g}from"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{Flags as p}from"@oclif/core";var h=class y extends w{static{l(this,"AuthLogin")}static description="Log in to RuleMetric";static examples=["<%= config.bin %> auth login","<%= config.bin %> auth login -e user@example.com"];static flags={email:p.string({char:"e",description:"Email address"}),password:p.string({char:"p",description:"Password (for non-interactive use)"}),"api-key":p.string({description:"Authenticate with an API key from https://rulemetric.com/connect (required for Google/GitHub sign-ins, which have no password)",exclusive:["password"]})};async run(){let{flags:s}=await this.parse(y);if(s["api-key"]){await this.loginWithApiKey(s["api-key"]);return}let e=s.email,t=s.password;if(!e||!t){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p, or set RULEMETRIC_API_KEY (create a key at https://rulemetric.com/connect).");let{input:o,password:k}=await import("@inquirer/prompts");this.log("Signed up with Google or GitHub? You have no password \u2014 press Ctrl-C and run:"),this.log(" rulemetric auth login --api-key <key> (create one at https://rulemetric.com/connect)"),this.log(""),e||(e=await o({message:"Email:"})),t||(t=await k({message:"Password:"}))}let i;try{i=await a("/auth/login",{method:"POST",body:{email:e,password:t},timeoutMs:2e4})}catch(o){throw o instanceof r&&o.statusCode===401&&this.error(`Invalid email or password.
|
|
2
2
|
|
|
3
3
|
If you signed up with Google or GitHub, you have no password \u2014 that is why this cannot work. Create an API key at https://rulemetric.com/connect, then run:
|
|
4
4
|
rulemetric auth login --api-key <key>`),o}let v=i.expiresAt??new Date(Date.now()+3600*1e3).toISOString();d({accessToken:i.accessToken,refreshToken:i.refreshToken,expiresAt:v,email:i.email}),u(i.accessToken,process.env.RULEMETRIC_API_URL),await n(),await f(this.log.bind(this),this.warn.bind(this),this.config.version),c("auth_login",{},this.config.version),this.log(`Logged in as ${i.email}`)}async loginWithApiKey(s){let e=s.trim();e||this.error("Empty --api-key. Create one at https://rulemetric.com/connect"),process.env.RULEMETRIC_API_KEY=e;try{await a("/api/setup/status",{timeoutMs:2e4})}catch(t){throw delete process.env.RULEMETRIC_API_KEY,t instanceof r&&(t.statusCode===401||t.statusCode===403)&&this.error("That API key was rejected. Check you copied it whole (it is shown only once at creation) or mint a new one at https://rulemetric.com/connect"),t}g(e,process.env.RULEMETRIC_API_URL),m(),await n(),c("auth_login",{method:"api_key"},this.config.version),this.log(`Authenticated with API key ${e.slice(0,11)}...`),this.log("Verify any time with: rulemetric auth status")}};export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../../chunk-
|
|
1
|
+
import{a as s}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import{f as i,j as r}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";var e=class t extends s{static{o(this,"AuthLogout")}static description="Log out of RuleMetric";static examples=["<%= config.bin %> auth logout"];async run(){await this.parse(t),i(),r(),this.log("Logged out successfully.")}};export{e as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k}from"../../chunk-
|
|
1
|
+
import{a as k}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{e as n,i as c}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as s}from"../../chunk-ZLLER3HP.js";import{Args as y}from"@oclif/core";var a=class m extends k{static{s(this,"AuthRevokeKey")}static description="Revoke an API key (run with no argument to list active keys)";static examples=["<%= config.bin %> auth revoke-key","<%= config.bin %> auth revoke-key rm_abc12345",'<%= config.bin %> auth revoke-key "my-laptop (auto)"'];static args={id:y.string({description:"API key ID, prefix (rm_xxxxxxxx), or name"})};async run(){let{args:o}=await this.parse(m),r=(await n("/api/auth/api-keys")).filter(e=>!e.revokedAt);if(!o.id){if(r.length===0){this.log("No active API keys.");return}this.log(`Active API keys \u2014 pass an id, prefix, or name to revoke one:
|
|
2
2
|
`);for(let e of r)this.log(` ${e.id} ${e.keyPrefix}... ${e.name}`);return}let i=o.id,t=r.filter(e=>e.id===i||e.name===i||i.startsWith("rm_")&&i.startsWith(e.keyPrefix));t.length===0&&this.error(`No active API key matches "${i}". Run \`rulemetric auth revoke-key\` with no argument to list keys.`),t.length>1&&this.error(`"${i}" matches ${t.length} keys \u2014 use the exact key ID:
|
|
3
3
|
`+t.map(e=>` ${e.id} ${e.keyPrefix}... ${e.name}`).join(`
|
|
4
4
|
`)),await c(`/api/auth/api-keys/${t[0].id}`),this.log(`API key ${t[0].keyPrefix}... ("${t[0].name}") revoked.`)}};export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g}from"../../chunk-
|
|
1
|
+
import{a as g}from"../../chunk-EOTSCWFS.js";import{a as h}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import{c as d}from"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import{b as l}from"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{b as m,d as p}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import{d as n,h as c}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as u}from"@oclif/core";var t=class f extends h{static{o(this,"AuthSignup")}static description="Create a RuleMetric account from the CLI";static examples=["<%= config.bin %> auth signup","<%= config.bin %> auth signup -e user@example.com"];static flags={email:u.string({char:"e",description:"Email address"}),password:u.string({char:"p",description:"Password (min 8 chars; for non-interactive use)"})};async run(){let{flags:a}=await this.parse(f),i=a.email,r=a.password;if(!i||!r){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p.");let{input:s,password:v}=await import("@inquirer/prompts");i||(i=await s({message:"Email:"})),r||(r=await v({message:"Password (min 8 chars):"}))}let e;try{e=await p("/auth/signup",{method:"POST",body:{email:i,password:r},timeoutMs:2e4})}catch(s){throw s instanceof m&&s.statusCode===409&&this.error(`An account with ${i} already exists. Run: rulemetric auth login -e ${i}`),s}if(e.confirmationRequired||!e.accessToken||!e.refreshToken){this.log(`Account created for ${e.email}.`),this.log("Check your email and click the confirmation link, then run:"),this.log(` rulemetric auth login -e ${e.email}`);return}let w=e.expiresAt??new Date(Date.now()+3600*1e3).toISOString();n({accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:w,email:e.email}),c(e.accessToken,process.env.RULEMETRIC_API_URL),await l(),await g(this.log.bind(this),this.warn.bind(this),this.config.version),d("auth_signup",{},this.config.version),this.log(`Signed up and logged in as ${e.email}`)}};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"../../chunk-W2MV25SB.js";import{a as g}from"../../chunk-
|
|
1
|
+
import{a as c}from"../../chunk-W2MV25SB.js";import{a as g}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import{a,e as l,l as t}from"../../chunk-PZNWH4VQ.js";import{a as r}from"../../chunk-ZLLER3HP.js";import*as u from"node:path";var o=class h extends g{static{r(this,"AuthStatus")}static description="Show current authentication status";static examples=["<%= config.bin %> auth status"];async run(){await this.parse(h);let e=l(),i=process.env.RULEMETRIC_API_KEY,s=a().apiKey;if(i||s){let m=i||s,p=i?"RULEMETRIC_API_KEY env var":u.join(t(),"env");this.log(`Authenticated via API key ${m.slice(0,11)}... (${p})`),e&&this.log(`Logged in as: ${e.email}`),this.log(`Config: ${t()}`);return}if(!e){this.log("Not logged in. Run `rulemetric auth login` to authenticate.");return}let n=new Date(e.expiresAt).getTime();if(Number.isNaN(n)||Date.now()>=n){this.log("Session expired. Run `rulemetric auth login` to re-authenticate.");return}this.log(`Logged in as: ${e.email}`),this.log(`Session expires: ${c(e.expiresAt)}`),this.log(`Config: ${t()}`)}};export{o as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as f,b as k,c as S,d as x,e as R,f as n,g as y}from"../../chunk-VALRPZXH.js";import{b as C,c as w,g as v,h as b}from"../../chunk-QI3FJKGK.js";import{a as u}from"../../chunk-
|
|
1
|
+
import{a as f,b as k,c as S,d as x,e as R,f as n,g as y}from"../../chunk-VALRPZXH.js";import{b as C,c as w,g as v,h as b}from"../../chunk-QI3FJKGK.js";import{a as u}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import{l as m}from"../../chunk-PZNWH4VQ.js";import{a as h}from"../../chunk-ZLLER3HP.js";import{existsSync as O}from"node:fs";import{Flags as c}from"@oclif/core";var g=class E extends u{static{h(this,"CaptureScope")}static description="Show or set which projects RuleMetric captures \u2014 the Codex sweep and hook-driven sessions each have their own scope";static examples=["<%= config.bin %> <%= command.id %>","<%= config.bin %> <%= command.id %> --add ~/work/client-a --add ~/work/client-b","<%= config.bin %> <%= command.id %> --tool hooks --add ~/work/client-a","<%= config.bin %> <%= command.id %> --tool hooks --off","<%= config.bin %> <%= command.id %> --remove ~/work/client-a","<%= config.bin %> <%= command.id %> --off","<%= config.bin %> <%= command.id %> --all"];static flags={tool:c.string({description:'Which capture path to edit: "codex" (the worker transcript sweep, the default) or "hooks" (Claude Code / Cursor / Copilot / Antigravity hook sessions).',options:["codex","hooks"],default:"codex"}),add:c.string({description:"Capture sessions under this path (repeatable). Implies an allowlist.",multiple:!0}),remove:c.string({description:"Stop capturing under this path (repeatable).",multiple:!0}),off:c.boolean({description:"Turn this capture path off entirely.",exclusive:["all"]}),all:c.boolean({description:"Capture every project (the default).",exclusive:["off"]}),clear:c.boolean({description:"Remove this scope, restoring the default."})};async run(){let{flags:o}=await this.parse(E),s=m(),d=f(s);if(!((o.add?.length??0)>0||(o.remove?.length??0)>0||o.off||o.all||o.clear)){await this.show(s,d);return}for(let t of[...o.add??[],...o.remove??[]])R(t)||this.error(`Not an absolute path: ${t}
|
|
2
2
|
Use an absolute path or ~/\u2026 \u2014 relative paths cannot be matched against a session's cwd.`);for(let t of o.add??[]){let a=x(t);O(a)||this.warn(`${a} does not exist yet \u2014 added anyway, but nothing will match until it does.`)}let e;try{e=k(s)}catch(t){o.clear||this.error(t instanceof Error?t.message:String(t));let a=y(s);this.warn(`${f(s)} was not valid JSON \u2014 saved it to ${a} and starting fresh.`),e={}}let i=o.tool??"codex",r=void 0,l=!1;if(o.clear&&({config:e}=n(e,{op:"clear"},r,i)),o.off&&({config:e}=n(e,{op:"mode",mode:"off"},r,i)),o.all&&({config:e}=n(e,{op:"mode",mode:"all"},r,i)),o.remove?.length){let t=n(e,{op:"remove",roots:o.remove},r,i);e=t.config,l=t.emptiedToOff}o.add?.length&&({config:e}=n(e,{op:"add",roots:o.add},r,i)),S(s,e),l&&(this.log(`Removed the last root \u2014 ${i==="hooks"?"hook":"Codex"} capture is now OFF rather than silently capturing everything.`),this.log("Use --all to go back to capturing every project.")),await this.show(s,d),this.log(""),this.log(i==="hooks"?"Takes effect on the next hook fire. No restart needed.":"Takes effect on the next sweep (within ~30s). No restart needed.")}async show(o,s){let d=await C({configDir:o}),p=await w({configDir:o}),e=h((i,r,l,t)=>{if(this.log(`${i}: ${l}`),r.roots.length)for(let a of r.roots)this.log(` \u2022 ${a}`);r.error&&(this.log(" This scope is FAILING CLOSED \u2014 nothing is being captured on this path."),this.log(` Fix the file, or run \`rulemetric capture scope ${i==="Hook capture"?"--tool hooks ":""}--clear\` to start over.`)),r.source==="env"&&this.log(` Set by environment variable, which outranks the config file (${t}).`)},"print");e("Codex capture",d,v(d),"RULEMETRIC_CODEX_CAPTURE / RULEMETRIC_CODEX_ROOTS"),e("Hook capture",p,b(p),"RULEMETRIC_HOOKS_CAPTURE / RULEMETRIC_HOOKS_ROOTS"),this.log(`Config: ${s}`)}};export{g as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g,b as d,c as p}from"../../chunk-W2MV25SB.js";import{a as c}from"../../chunk-
|
|
1
|
+
import{a as g,b as d,c as p}from"../../chunk-W2MV25SB.js";import{a as c}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Flags as i}from"@oclif/core";var o=class m extends c{static{a(this,"Catalog")}static description="Browse the org instruction catalog";static flags={badge:i.string({description:"Filter by badge",options:["recommended","required"]}),scope:i.string({description:"Filter by scope",options:["org","team"]}),search:i.string({description:"Search by name or description"})};async run(){let{flags:e}=await this.parse(m);this.requireAuth();let s=new URLSearchParams;e.badge&&s.set("badge",e.badge),e.scope&&s.set("scope",e.scope),e.search&&s.set("search",e.search);let r=await n(`/api/catalog?${s.toString()}`);if(r.length===0){this.log("No instructions found in catalog.");return}for(let t of r){let l=t.badge?` [${t.badge}]`:"",f=t.tags?.length?` (${t.tags.join(", ")})`:"";this.log(` ${d(t.name,40)} \u2014 ${p(t.scope)}${l} v${t.version}${f} ${g(t.updatedAt)}`)}this.log(`
|
|
2
2
|
${r.length} instruction(s) found.`)}};export{o as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as i}from"../../chunk-
|
|
1
|
+
import{a as i}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{f as n}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as t}from"../../chunk-ZLLER3HP.js";import{Args as c}from"@oclif/core";var o=class s extends i{static{t(this,"CatalogRecommend")}static description="Get AI-powered instruction recommendations for a project";static args={projectId:c.string({description:"ID of the project",required:!0})};async run(){let{args:a}=await this.parse(s);this.requireAuth(),this.log(`Analyzing project and generating recommendations...
|
|
2
2
|
`);let r=await n(`/api/projects/${a.projectId}/recommendations`,{});if(r.error&&this.warn(`Note: ${r.error}`),r.recommendations.length===0){this.log("No recommendations found.");return}for(let e of r.recommendations)this.log(` ${(e.score*100).toFixed(0)}% \u2014 ${e.instructionId}`),this.log(` ${e.reason}
|
|
3
3
|
`)}};export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"../../chunk-4VN5PG2S.js";import{a as n}from"../../chunk-
|
|
1
|
+
import{a as o}from"../../chunk-4VN5PG2S.js";import{a as n}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{printTable as t}from"@oclif/table";var a=class s extends n{static{i(this,"CronsList")}static description="List manually-runnable maintenance tasks";static examples=["<%= config.bin %> crons list"];async run(){await this.parse(s),t({data:o.map(e=>({Name:e.name,"Scheduled by":e.scheduledBy,Description:e.description})),columns:["Name","Scheduled by","Description"]}),this.log(""),this.log("Scheduled crons run in Supabase pg_cron \u2014 audit them with:"),this.log(` psql "$DATABASE_URL" -c 'select jobname, schedule, active from cron.job;'`),this.log("Run any task above on demand with: rulemetric crons run <name>")}};export{a as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as $}from"../../chunk-4VN5PG2S.js";import{a as k}from"../../chunk-
|
|
1
|
+
import{a as $}from"../../chunk-4VN5PG2S.js";import{a as k}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{e as b}from"../../chunk-Z7UN4R7T.js";import{A as f,B as g,z as h}from"../../chunk-X6CF5KTW.js";import{f as p}from"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as d}from"../../chunk-ZLLER3HP.js";import{Args as _,Flags as y}from"@oclif/core";var l=class w extends k{static{d(this,"CronsRun")}static description="Run a maintenance task synchronously, right now";static examples=["<%= config.bin %> crons run cron_check_changelog","<%= config.bin %> crons run cron_suggest_instructions --quiet"];static args={name:_.string({description:"Task name (run `rulemetric crons list` to see all)",required:!0})};static flags={"dry-run":y.boolean({description:"For Harbor, print the saved engine/model and supported tasks without running them"}),quiet:y.boolean({char:"q",description:"Suppress per-line log output; print summary only"})};async run(){let{args:s,flags:a}=await this.parse(w);this.requireAuth();let o=$.find(e=>e.name===s.name);o||this.error(`Unknown task: ${s.name}
|
|
2
2
|
Run \`rulemetric crons list\` to see available tasks.`);let t=null;if(s.name==="harbor_ab"){let e=await b("/api/settings/measurement");t=e.execution.harbor?p.parse(e.execution.harbor):null;for(let r of h("proven")){let m=f(r,t);if(m){this.log(`Unsupported: ${m}`);continue}let i=g(r,"manual",t);this.log(`${r.task}: ${t?.engine??"claude"} / ${i.model}, ${i.class}, ${i.nTrials} trials per arm`)}if(a["dry-run"])return}else a["dry-run"]&&this.error("--dry-run is currently supported only for harbor_ab");let u;try{({runManualTask:u}=await import("../../lib/manual-tasks.js"))}catch(e){let r=e?.code;throw(r==="ERR_MODULE_NOT_FOUND"||r==="MODULE_NOT_FOUND")&&this.error("`crons run` needs the worker runtime, which isn't available in this install.\nReinstall the CLI and verify that its runtime dependencies are present. A database credential is not required for end-user maintenance tasks."),e}this.log(`\u25B6 Running ${o.name} \u2026`);let v=Date.now(),n=await u(s.name,{measurement:t});if(!a.quiet)for(let e of n.logs){let r=e.level==="error"||e.level==="warn"?`[${e.level}]`:"";this.log(` ${r} ${e.message}`)}let c=((n.durationMs??Date.now()-v)/1e3).toFixed(1);n.ok?this.log(`\u2713 ${o.name} completed in ${c}s (${n.logs.length} log line${n.logs.length===1?"":"s"})`):this.error(`\u2717 ${o.name} failed after ${c}s: ${n.error}`)}};export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"../chunk-
|
|
1
|
+
import{a as o}from"../chunk-MOQTSJNZ.js";import"../chunk-IZTIYR5Q.js";import"../chunk-TDDJOSFQ.js";import"../chunk-433HK3QQ.js";import"../chunk-WDLAPZPN.js";import"../chunk-3AV3GTMP.js";import"../chunk-Z7UN4R7T.js";import"../chunk-X6CF5KTW.js";import"../chunk-XQYAVSUQ.js";import"../chunk-PZNWH4VQ.js";import{a as i}from"../chunk-ZLLER3HP.js";import{Flags as r}from"@oclif/core";var a=class s extends o{static{i(this,"Dashboard")}static description="Interactive TUI dashboard showing session analytics, outcomes, friction, and insights";static examples=["<%= config.bin %> dashboard","<%= config.bin %> dashboard --period 30days","<%= config.bin %> dashboard --launcher"];static flags={period:r.string({char:"p",default:"week",options:["today","week","30days","month","all"],description:"Initial time period"}),launcher:r.boolean({char:"l",default:!1,description:"Open the launcher overlay immediately"})};async run(){let{flags:e}=await this.parse(s),{renderDashboard:t}=await import("../dashboard/Dashboard.js");await t(e.period,{openLauncher:e.launcher})}};export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as q,d as K}from"../chunk-TYFEWLYZ.js";import{b as L,c as W}from"../chunk-V5U3E4BZ.js";import{a as J}from"../chunk-2TJ7Q2OU.js";import{e as O,f as _,g as M}from"../chunk-QWCEZEDO.js";import"../chunk-KKDHD4XA.js";import"../chunk-SZ62CP55.js";import{d as oe,e as ne}from"../chunk-KGU2IW54.js";import"../chunk-M7QSC64D.js";import"../chunk-ZKPURXUS.js";import"../chunk-ISEUEYSC.js";import{i as z,j as Q,k as Z,m as ee,n as te}from"../chunk-GYKYJJNF.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-LJE5J3EW.js";import"../chunk-AHLVY52I.js";import"../chunk-YXMAGC53.js";import"../chunk-T7HZZ4DJ.js";import"../chunk-DHIEGG4T.js";import"../chunk-PPAHIVG5.js";import"../chunk-5MXZJWQS.js";import"../chunk-CT7FWSIU.js";import"../chunk-N7ODX6PO.js";import{a as V}from"../chunk-OZQNSELV.js";import"../chunk-HFGO5762.js";import"../chunk-VS5ROGDP.js";import"../chunk-FADINV4H.js";import"../chunk-SWSOEYC7.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-GYNZ3OZF.js";import"../chunk-UPFH72PF.js";import"../chunk-FG343JM3.js";import"../chunk-CDY7TQFZ.js";import"../chunk-KFNFLMUR.js";import"../chunk-4GOXEEXZ.js";import"../chunk-JP6ULOEX.js";import"../chunk-JNLDISBA.js";import{d as F}from"../chunk-GPBN4ROE.js";import"../chunk-6XTLP2G7.js";import"../chunk-PJ3WHQ67.js";import{a as X,b as D,c as Y,g as j,h as G}from"../chunk-QI3FJKGK.js";import{a as B}from"../chunk-WUCACPGC.js";import"../chunk-IZTIYR5Q.js";import"../chunk-WL5ZWQAS.js";import"../chunk-KEVDLLHT.js";import"../chunk-DX6IPDED.js";import"../chunk-3AV3GTMP.js";import{a as U,e as y}from"../chunk-GIXHG5FK.js";import"../chunk-X6CF5KTW.js";import"../chunk-XQYAVSUQ.js";import{a as N,g as v,l as x}from"../chunk-PZNWH4VQ.js";import{a as S}from"../chunk-ZLLER3HP.js";import{spawnSync as le}from"node:child_process";import{existsSync as ce,readFileSync as ue}from"node:fs";import{join as se}from"node:path";var I=class h extends B{static{S(this,"Diagnostics")}static description='Diagnose capture / proxy / connectivity problems (e.g. a client-side "502 Bad Gateway")';static examples=["<%= config.bin %> diagnostics"];baseUrl(){return process.env.RULEMETRIC_API_URL??N().apiUrl??U}async checkDirect(){let r=process.env.HTTPS_PROXY,i=process.env.HTTP_PROXY;delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY;let s=new AbortController,l=setTimeout(()=>s.abort(),8e3);try{return(await globalThis.fetch(`${this.baseUrl()}/health`,{signal:s.signal})).ok}catch{return!1}finally{clearTimeout(l),r!==void 0&&(process.env.HTTPS_PROXY=r),i!==void 0&&(process.env.HTTP_PROXY=i)}}configuredProxy(){if(process.env.HTTPS_PROXY)return process.env.HTTPS_PROXY;for(let r of["settings.local.json","settings.json"]){let i=se(process.cwd(),".claude",r);if(ce(i))try{let s=JSON.parse(ue(i,"utf8"));if(s.env?.HTTPS_PROXY)return s.env.HTTPS_PROXY}catch{}}return null}checkThroughProxy(r){let i=le("curl",["-sS","-x",r,"--max-time","8","-o","/dev/null","-w","%{http_code}",`${this.baseUrl()}/health`],{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return i.error||typeof i.stdout!="string"?null:i.stdout.trim()==="200"}async run(){await this.parse(h);let r=process.version,i=this.configuredProxy(),s=i!=null,[l,m,d]=await Promise.all([this.checkDirect(),M(O),M(_)]),p=s&&i?this.checkThroughProxy(i):null,t=S((e,c,T)=>{let u=c===null?"\u2013":c?"[OK]":"[!!]";this.log(` ${u} ${e.padEnd(22)} ${T}`)},"line");this.log("RuleMetric diagnostics"),this.log(""),t("Node",!L(r),`${r}${L(r)?" (< 20.11 \u2014 breaks the bundled proxy)":""}`),t("API (direct)",l,`${this.baseUrl()}/health ${l?"reachable":"UNREACHABLE"}`),t("Authenticated",v(),v()?"yes":"no \u2014 run `rulemetric auth login`"),t("Proxy configured",s?!0:null,s?i:"no HTTPS_PROXY set"),s&&(t("Gateway :"+O,m,m?"listening":"NOT listening"),t("mitmproxy :"+_,d,d?"listening":"not listening (gateway should route direct)"),t("API (via proxy)",p,p===null?"inconclusive (curl unavailable)":p?"reachable":"FAILED \u2014 502/blocked through your proxy"));let a=F();t("claude CLI",a.claudeBin!=null,a.claudeBin??"not found \u2014 LLM features (grading, distill) will no-op"),t("codex CLI",a.codexBin!=null?!0:null,a.codexBin?`${a.codexBin}${a.codexConfiguredModel?` (model ${a.codexConfiguredModel})`:""}`:"not found \u2014 optional; enables the cross-vendor reviewer (evals validate-judge)");let o=null;if(v()&&l)try{o=await y("/api/workers/health")}catch{o=null}if(o){let e=o.worker;t("Worker",!!e.active,e.present?e.active?`online (last heartbeat ${e.ageSeconds??"?"}s ago${e.clientVersion?`, v${e.clientVersion}`:""})`:`NOT RUNNING \u2014 last heartbeat ${A(e.ageSeconds)} ago`:"never connected \u2014 no worker has ever reported in");let c=o.worker.engines;if(c!=null){let u=[c.claude&&"claude",c.codex&&"codex"].filter(Boolean);t("LLM engine",u.length>0,u.length>0?`${u.join(" + ")} available to the worker`:"NONE \u2014 the worker found no `claude` and no `codex`. LLM jobs will complete with empty output rather than failing.")}let T=o.pending.reduce((u,E)=>u+E.count,0);if(T>0){let u=o.verdict.stuck.reduce(($,k)=>$+k.count,0),E=o.verdict.unclaimable.reduce(($,k)=>$+k.count,0),R=(o.verdict.engineBlocked??[]).reduce(($,k)=>$+k.count,0);t("Job queue",u===0&&R===0,`${T} pending`+(u>0?` \u2014 ${u} waiting on this worker`:"")+(R>0?` \u2014 ${R} need a local LLM engine`:"")+(E>0?` \u2014 ${E} need a worker with DATABASE_URL`:""))}else t("Job queue",!0,"empty")}else v()&&l&&t("Worker",null,"could not read /workers/health (older API?)");let n=o?.worker.machine;if(n){let e=n.suspends+n.stalls,c=n.lastPause;t("Worker pauses",e===0?!0:null,e===0?`none since ${n.since} \u2014 no sleep or stall seen by the worker`:`${n.suspends} suspend${n.suspends===1?"":"s"}`+(n.stalls>0?` + ${n.stalls} event-loop stall${n.stalls===1?"":"s"}`:"")+` since ${n.since}, ${A(Math.round(n.pausedMs/1e3))} paused total`+(c?`; last: ${c.kind} of ${A(Math.round(c.wallGapMs/1e3))} ending ${c.detectedAt}`:"")+" \u2014 jobs in flight during a suspend lose their lease and are redone on wake")}let f=await q();if(f){t("Machine sleep (pmset)",f.sleeps===0?!0:null,K(f));for(let e of f.recent.slice(-3)){let c=e.seconds!=null?` (${A(e.seconds)})`:"";this.log(` \u21B3 ${e.at.toISOString()} ${e.kind}${c}: ${e.reason.slice(0,80)}`)}}let C=V(process.cwd()),g=await D({configDir:x()}),re=await Y({configDir:x()}),w=` \u2014 ${G(re)}`,b=J(process.cwd()),H=[b.user&&`user hooks (${b.user})`,b.workspace&&`workspace hooks (${b.workspace})`].filter(Boolean),ie={claude_code:`session hooks (+ proxy for instruction linking)${w}`,codex:`worker transcript sync of ~/.codex/sessions \u2014 ${j(g)}`,cursor:`user hooks (~/.cursor/hooks.json)${w}`,copilot_agent:`workspace hooks${w}`,antigravity:H.length>0?`${H.join(" + ")}${w}`:"NOT CAPTURED \u2014 no rulemetric block in ~/.gemini/config/hooks.json or .agents/hooks.json; run `rulemetric hooks install` (user hooks are on by default)"};this.log(""),this.log(" Capture coverage (agents found on this machine):");for(let e of C)this.log(` \u2022 ${e.padEnd(15)} ${ie[e]??"captured"}`);if(C.includes("codex"))if(g.error)this.log(` ! ${g.error}`);else if(g.mode==="allowlist")for(let e of g.roots)this.log(` \u21B3 ${e}`);else g.mode==="all"&&this.log(` \u21B3 scope it with ${se(x(),X)} ({"codex":{"roots":["/path/to/repo"]}}) or RULEMETRIC_CODEX_CAPTURE=off`);o&&!o.worker.active&&C.includes("codex")&&g.mode!=="off"&&this.log(" ! Codex capture runs INSIDE the worker \u2014 it is stopped while the worker is down."),v()&&l&&await this.reportEvolutionSpend();let P=W({nodeVersion:r,directApiOk:l,httpsProxySet:s,gatewayAlive:m,mitmproxyAlive:d,proxyPathOk:p});this.log("");let ae=P.severity==="ok"?"[OK]":P.severity==="warn"?"[!!]":"[XX]";this.log(`${ae} ${P.headline}`);for(let e of P.hints)this.log(` \u2022 ${e}`);if(o&&o.verdict.severity!=="ok"){let e=o.verdict.severity==="warn"?"[!!]":"[XX]";this.log(""),this.log(`${e} ${o.verdict.headline}`);for(let c of o.verdict.hints)this.log(` \u2022 ${c}`)}}async reportEvolutionSpend(){let r;try{r=await y("/api/eval-targets?type=instruction&limit=200")}catch{return}let i=r.filter(s=>{let l=s.metadata??{};return l.autoEvolveEnabled===!0||l.autoEvolveEnabled==="true"});if(i.length!==0){this.log(""),this.log(" Nightly instruction evolution (cron_instruction_evolution, 07:30 UTC):");for(let s of i){let l=s.metadata??{},m=Q(l),d=z(l);if(m){this.log(` \u2022 ${s.name} \u2014 PAUSED (metadata.autoEvolvePaused). Opt-in preserved.`),this.log(" \u21B3 resume: set autoEvolvePaused=false");continue}let p=null;try{p=(await y(`/api/eval-targets/${s.id}/evals`)).filter(a=>!a.retiredAt).length}catch{}if(this.log(` \u2022 ${s.name}`),p!=null){let t=ne(p,d.minPairs,oe(d,p));if(!t.feasible)this.log(` \u21B3 cannot reach a verdict \u2014 ${t.reason}`);else{let a=Z({liveCases:p,passes:t.passes});this.log(` \u21B3 each night: ${te(a)}`)}}this.log(` \u21B3 pairs budget ${d.minPairs}`+(d.configured?" (metadata.autoEvolvePairs)":" (default)")+` \xB7 writes ${l.autoEvolveApply===!0||l.autoEvolveApply==="true"?"ENABLED":"off (dry run)"}`),d.note&&this.log(` ! ${d.note}`);try{let t=await y(`/api/eval-targets/${s.id}/promotions?limit=1`),a=t.promotions[0];if(a){let n=a.gates?.cost,f=n?.modelCalls?`${n.modelCalls} model calls, ${n.usablePairs??"?"} usable pair(s)`+(n.mde!=null?`, resolved +/-${ee(n.mde)}`:"")+(n.wallMs?`, ${(n.wallMs/6e4).toFixed(0)} min`:""):"cost not recorded (decision predates cost tracking)";this.log(` \u21B3 last run ${new Date(a.createdAt).toISOString().slice(0,10)}: ${a.decision}${a.applied?" (APPLIED)":""} \u2014 ${f}`)}let o=t.counts??{};this.log(` \u21B3 lifetime: ${o.promote??0} promote / ${o.revert??0} revert / ${o.refuse??0} refuse`)}catch{}}this.log(" \u21B3 pause the spend: metadata.autoEvolvePaused=true (keeps the opt-in)")}}};function A(h){if(h===null)return"never";if(h<90)return`${Math.round(h)}s`;let r=Math.round(h/60);return r<90?`${r}m`:`${Math.round(r/60)}h`}S(A,"formatAge");export{I as default};
|
|
1
|
+
import{c as q,d as K}from"../chunk-TYFEWLYZ.js";import{b as L,c as W}from"../chunk-V5U3E4BZ.js";import{a as J}from"../chunk-2TJ7Q2OU.js";import{e as O,f as _,g as M}from"../chunk-QWCEZEDO.js";import"../chunk-KKDHD4XA.js";import"../chunk-SZ62CP55.js";import{d as oe,e as ne}from"../chunk-YSY25OGG.js";import"../chunk-M7QSC64D.js";import"../chunk-CEM7JMUW.js";import"../chunk-L3AXNCWC.js";import"../chunk-ANHFE6US.js";import{i as z,j as Q,k as Z,m as ee,n as te}from"../chunk-GYKYJJNF.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-AHLVY52I.js";import"../chunk-YX2IGS72.js";import"../chunk-55HFAX5Y.js";import"../chunk-26XE3JCL.js";import"../chunk-PPAHIVG5.js";import"../chunk-5MXZJWQS.js";import"../chunk-CT7FWSIU.js";import"../chunk-N7ODX6PO.js";import{a as V}from"../chunk-OZQNSELV.js";import"../chunk-HFGO5762.js";import"../chunk-VS5ROGDP.js";import"../chunk-AXTEV56C.js";import"../chunk-VZYNZS5U.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-GYNZ3OZF.js";import"../chunk-UPFH72PF.js";import"../chunk-U6AASXY3.js";import"../chunk-CDY7TQFZ.js";import"../chunk-KFNFLMUR.js";import"../chunk-LARY6ZFT.js";import"../chunk-JP6ULOEX.js";import"../chunk-SVZYRGO5.js";import"../chunk-WULEBQPI.js";import{d as F}from"../chunk-GPBN4ROE.js";import"../chunk-6XTLP2G7.js";import"../chunk-PJ3WHQ67.js";import{a as X,b as D,c as Y,g as j,h as G}from"../chunk-QI3FJKGK.js";import{a as B}from"../chunk-MOQTSJNZ.js";import"../chunk-IZTIYR5Q.js";import"../chunk-TDDJOSFQ.js";import"../chunk-433HK3QQ.js";import"../chunk-WDLAPZPN.js";import"../chunk-3AV3GTMP.js";import{a as U,e as y}from"../chunk-Z7UN4R7T.js";import"../chunk-X6CF5KTW.js";import"../chunk-XQYAVSUQ.js";import{a as N,g as v,l as x}from"../chunk-PZNWH4VQ.js";import{a as S}from"../chunk-ZLLER3HP.js";import{spawnSync as le}from"node:child_process";import{existsSync as ce,readFileSync as ue}from"node:fs";import{join as se}from"node:path";var I=class h extends B{static{S(this,"Diagnostics")}static description='Diagnose capture / proxy / connectivity problems (e.g. a client-side "502 Bad Gateway")';static examples=["<%= config.bin %> diagnostics"];baseUrl(){return process.env.RULEMETRIC_API_URL??N().apiUrl??U}async checkDirect(){let r=process.env.HTTPS_PROXY,i=process.env.HTTP_PROXY;delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY;let s=new AbortController,l=setTimeout(()=>s.abort(),8e3);try{return(await globalThis.fetch(`${this.baseUrl()}/health`,{signal:s.signal})).ok}catch{return!1}finally{clearTimeout(l),r!==void 0&&(process.env.HTTPS_PROXY=r),i!==void 0&&(process.env.HTTP_PROXY=i)}}configuredProxy(){if(process.env.HTTPS_PROXY)return process.env.HTTPS_PROXY;for(let r of["settings.local.json","settings.json"]){let i=se(process.cwd(),".claude",r);if(ce(i))try{let s=JSON.parse(ue(i,"utf8"));if(s.env?.HTTPS_PROXY)return s.env.HTTPS_PROXY}catch{}}return null}checkThroughProxy(r){let i=le("curl",["-sS","-x",r,"--max-time","8","-o","/dev/null","-w","%{http_code}",`${this.baseUrl()}/health`],{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return i.error||typeof i.stdout!="string"?null:i.stdout.trim()==="200"}async run(){await this.parse(h);let r=process.version,i=this.configuredProxy(),s=i!=null,[l,m,d]=await Promise.all([this.checkDirect(),M(O),M(_)]),p=s&&i?this.checkThroughProxy(i):null,t=S((e,c,T)=>{let u=c===null?"\u2013":c?"[OK]":"[!!]";this.log(` ${u} ${e.padEnd(22)} ${T}`)},"line");this.log("RuleMetric diagnostics"),this.log(""),t("Node",!L(r),`${r}${L(r)?" (< 20.11 \u2014 breaks the bundled proxy)":""}`),t("API (direct)",l,`${this.baseUrl()}/health ${l?"reachable":"UNREACHABLE"}`),t("Authenticated",v(),v()?"yes":"no \u2014 run `rulemetric auth login`"),t("Proxy configured",s?!0:null,s?i:"no HTTPS_PROXY set"),s&&(t("Gateway :"+O,m,m?"listening":"NOT listening"),t("mitmproxy :"+_,d,d?"listening":"not listening (gateway should route direct)"),t("API (via proxy)",p,p===null?"inconclusive (curl unavailable)":p?"reachable":"FAILED \u2014 502/blocked through your proxy"));let a=F();t("claude CLI",a.claudeBin!=null,a.claudeBin??"not found \u2014 LLM features (grading, distill) will no-op"),t("codex CLI",a.codexBin!=null?!0:null,a.codexBin?`${a.codexBin}${a.codexConfiguredModel?` (model ${a.codexConfiguredModel})`:""}`:"not found \u2014 optional; enables the cross-vendor reviewer (evals validate-judge)");let o=null;if(v()&&l)try{o=await y("/api/workers/health")}catch{o=null}if(o){let e=o.worker;t("Worker",!!e.active,e.present?e.active?`online (last heartbeat ${e.ageSeconds??"?"}s ago${e.clientVersion?`, v${e.clientVersion}`:""})`:`NOT RUNNING \u2014 last heartbeat ${A(e.ageSeconds)} ago`:"never connected \u2014 no worker has ever reported in");let c=o.worker.engines;if(c!=null){let u=[c.claude&&"claude",c.codex&&"codex"].filter(Boolean);t("LLM engine",u.length>0,u.length>0?`${u.join(" + ")} available to the worker`:"NONE \u2014 the worker found no `claude` and no `codex`. LLM jobs will complete with empty output rather than failing.")}let T=o.pending.reduce((u,E)=>u+E.count,0);if(T>0){let u=o.verdict.stuck.reduce(($,k)=>$+k.count,0),E=o.verdict.unclaimable.reduce(($,k)=>$+k.count,0),R=(o.verdict.engineBlocked??[]).reduce(($,k)=>$+k.count,0);t("Job queue",u===0&&R===0,`${T} pending`+(u>0?` \u2014 ${u} waiting on this worker`:"")+(R>0?` \u2014 ${R} need a local LLM engine`:"")+(E>0?` \u2014 ${E} need a worker with DATABASE_URL`:""))}else t("Job queue",!0,"empty")}else v()&&l&&t("Worker",null,"could not read /workers/health (older API?)");let n=o?.worker.machine;if(n){let e=n.suspends+n.stalls,c=n.lastPause;t("Worker pauses",e===0?!0:null,e===0?`none since ${n.since} \u2014 no sleep or stall seen by the worker`:`${n.suspends} suspend${n.suspends===1?"":"s"}`+(n.stalls>0?` + ${n.stalls} event-loop stall${n.stalls===1?"":"s"}`:"")+` since ${n.since}, ${A(Math.round(n.pausedMs/1e3))} paused total`+(c?`; last: ${c.kind} of ${A(Math.round(c.wallGapMs/1e3))} ending ${c.detectedAt}`:"")+" \u2014 jobs in flight during a suspend lose their lease and are redone on wake")}let f=await q();if(f){t("Machine sleep (pmset)",f.sleeps===0?!0:null,K(f));for(let e of f.recent.slice(-3)){let c=e.seconds!=null?` (${A(e.seconds)})`:"";this.log(` \u21B3 ${e.at.toISOString()} ${e.kind}${c}: ${e.reason.slice(0,80)}`)}}let C=V(process.cwd()),g=await D({configDir:x()}),re=await Y({configDir:x()}),w=` \u2014 ${G(re)}`,b=J(process.cwd()),H=[b.user&&`user hooks (${b.user})`,b.workspace&&`workspace hooks (${b.workspace})`].filter(Boolean),ie={claude_code:`session hooks (+ proxy for instruction linking)${w}`,codex:`worker transcript sync of ~/.codex/sessions \u2014 ${j(g)}`,cursor:`user hooks (~/.cursor/hooks.json)${w}`,copilot_agent:`workspace hooks${w}`,antigravity:H.length>0?`${H.join(" + ")}${w}`:"NOT CAPTURED \u2014 no rulemetric block in ~/.gemini/config/hooks.json or .agents/hooks.json; run `rulemetric hooks install` (user hooks are on by default)"};this.log(""),this.log(" Capture coverage (agents found on this machine):");for(let e of C)this.log(` \u2022 ${e.padEnd(15)} ${ie[e]??"captured"}`);if(C.includes("codex"))if(g.error)this.log(` ! ${g.error}`);else if(g.mode==="allowlist")for(let e of g.roots)this.log(` \u21B3 ${e}`);else g.mode==="all"&&this.log(` \u21B3 scope it with ${se(x(),X)} ({"codex":{"roots":["/path/to/repo"]}}) or RULEMETRIC_CODEX_CAPTURE=off`);o&&!o.worker.active&&C.includes("codex")&&g.mode!=="off"&&this.log(" ! Codex capture runs INSIDE the worker \u2014 it is stopped while the worker is down."),v()&&l&&await this.reportEvolutionSpend();let P=W({nodeVersion:r,directApiOk:l,httpsProxySet:s,gatewayAlive:m,mitmproxyAlive:d,proxyPathOk:p});this.log("");let ae=P.severity==="ok"?"[OK]":P.severity==="warn"?"[!!]":"[XX]";this.log(`${ae} ${P.headline}`);for(let e of P.hints)this.log(` \u2022 ${e}`);if(o&&o.verdict.severity!=="ok"){let e=o.verdict.severity==="warn"?"[!!]":"[XX]";this.log(""),this.log(`${e} ${o.verdict.headline}`);for(let c of o.verdict.hints)this.log(` \u2022 ${c}`)}}async reportEvolutionSpend(){let r;try{r=await y("/api/eval-targets?type=instruction&limit=200")}catch{return}let i=r.filter(s=>{let l=s.metadata??{};return l.autoEvolveEnabled===!0||l.autoEvolveEnabled==="true"});if(i.length!==0){this.log(""),this.log(" Nightly instruction evolution (cron_instruction_evolution, 07:30 UTC):");for(let s of i){let l=s.metadata??{},m=Q(l),d=z(l);if(m){this.log(` \u2022 ${s.name} \u2014 PAUSED (metadata.autoEvolvePaused). Opt-in preserved.`),this.log(" \u21B3 resume: set autoEvolvePaused=false");continue}let p=null;try{p=(await y(`/api/eval-targets/${s.id}/evals`)).filter(a=>!a.retiredAt).length}catch{}if(this.log(` \u2022 ${s.name}`),p!=null){let t=ne(p,d.minPairs,oe(d,p));if(!t.feasible)this.log(` \u21B3 cannot reach a verdict \u2014 ${t.reason}`);else{let a=Z({liveCases:p,passes:t.passes});this.log(` \u21B3 each night: ${te(a)}`)}}this.log(` \u21B3 pairs budget ${d.minPairs}`+(d.configured?" (metadata.autoEvolvePairs)":" (default)")+` \xB7 writes ${l.autoEvolveApply===!0||l.autoEvolveApply==="true"?"ENABLED":"off (dry run)"}`),d.note&&this.log(` ! ${d.note}`);try{let t=await y(`/api/eval-targets/${s.id}/promotions?limit=1`),a=t.promotions[0];if(a){let n=a.gates?.cost,f=n?.modelCalls?`${n.modelCalls} model calls, ${n.usablePairs??"?"} usable pair(s)`+(n.mde!=null?`, resolved +/-${ee(n.mde)}`:"")+(n.wallMs?`, ${(n.wallMs/6e4).toFixed(0)} min`:""):"cost not recorded (decision predates cost tracking)";this.log(` \u21B3 last run ${new Date(a.createdAt).toISOString().slice(0,10)}: ${a.decision}${a.applied?" (APPLIED)":""} \u2014 ${f}`)}let o=t.counts??{};this.log(` \u21B3 lifetime: ${o.promote??0} promote / ${o.revert??0} revert / ${o.refuse??0} refuse`)}catch{}}this.log(" \u21B3 pause the spend: metadata.autoEvolvePaused=true (keeps the opt-in)")}}};function A(h){if(h===null)return"never";if(h<90)return`${Math.round(h)}s`;let r=Math.round(h/60);return r<90?`${r}m`:`${Math.round(r/60)}h`}S(A,"formatAge");export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{f as s}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as e}from"@oclif/core";import{readFileSync as p}from"node:fs";var n=class c extends a{static{o(this,"EvalTargetCreate")}static description="Create an eval target (instruction, skill, prompt, or plan to test)";static examples=["<%= config.bin %> eval-targets create --name my-rules --type instruction --file ./CLAUDE.md",'<%= config.bin %> eval-targets create --name my-prompt --type prompt --content "Always use TypeScript"'];static flags={name:e.string({char:"n",description:"Name for the eval target",required:!0}),type:e.string({char:"t",description:"Target type",options:["instruction","skill","prompt","plan"],required:!0}),file:e.string({char:"f",description:"Path to content file"}),content:e.string({char:"c",description:"Content string (alternative to --file)"}),description:e.string({char:"d",description:"Description of the target",default:""})};async run(){let{flags:t}=await this.parse(c);this.requireAuth();let i;t.file?i=p(t.file,"utf-8"):t.content?i=t.content:this.error("Provide either --file or --content");let r=await s("/api/eval-targets",{name:t.name,type:t.type,content:i,description:t.description});this.log(`Created eval target: ${r.name} (${r.id}) v${r.version}`)}};export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p,b as e}from"../../chunk-W2MV25SB.js";import{a as o}from"../../chunk-
|
|
1
|
+
import{a as p,b as e}from"../../chunk-W2MV25SB.js";import{a as o}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as s}from"../../chunk-ZLLER3HP.js";import{Flags as m}from"@oclif/core";import{printTable as d}from"@oclif/table";var r=class l extends o{static{s(this,"EvalTargetList")}static description="List eval targets";static examples=["<%= config.bin %> eval-targets list","<%= config.bin %> eval-targets list --type instruction"];static flags={type:m.string({char:"t",description:"Filter by type",options:["instruction","skill","prompt","plan"]})};async run(){let{flags:i}=await this.parse(l);this.requireAuth();let c=i.type?`?type=${i.type}`:"",a=await n(`/api/eval-targets${c}`);if(a.length===0){this.log("No eval targets found. Create one with `rulemetric eval-targets create`.");return}d({data:a.map(t=>({Name:e(t.name,30),Type:t.type,Version:`v${t.version}`,Description:e(t.description,40),Updated:p(t.updatedAt)})),columns:["Name","Type","Version","Description","Updated"]})}};export{r as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as G,b as V,c as j,d as q}from"../../chunk-J4W6GNCF.js";import{b as M}from"../../chunk-GH4EZK2O.js";import{c as g}from"../../chunk-HTAHNQZJ.js";import{e as D}from"../../chunk-
|
|
1
|
+
import{a as G,b as V,c as j,d as q}from"../../chunk-J4W6GNCF.js";import{b as M}from"../../chunk-GH4EZK2O.js";import{c as g}from"../../chunk-HTAHNQZJ.js";import{e as D}from"../../chunk-2IQBXE6F.js";import"../../chunk-GPWLS64K.js";import"../../chunk-IEQDLURA.js";import"../../chunk-KINIFUZQ.js";import"../../chunk-HB4RUEEE.js";import"../../chunk-TFJAT263.js";import"../../chunk-JU5ZNXPK.js";import"../../chunk-GLZBTGN5.js";import"../../chunk-V2G6E53W.js";import"../../chunk-G2226CG6.js";import"../../chunk-ZZZ7ECPT.js";import"../../chunk-AZK4Y5DB.js";import"../../chunk-2K4TF5RM.js";import"../../chunk-ZYGBABMZ.js";import"../../chunk-5RBLIVBF.js";import"../../chunk-BLGICIV4.js";import"../../chunk-RAIXY6YA.js";import"../../chunk-HOQPVOMF.js";import"../../chunk-LEUXIXIS.js";import"../../chunk-FZMO7XSN.js";import"../../chunk-MOJY6S5J.js";import"../../chunk-RCJTCLZO.js";import"../../chunk-VBGHPAUT.js";import"../../chunk-4XRPSKIJ.js";import"../../chunk-M2CPTQZL.js";import"../../chunk-LMNUO32P.js";import"../../chunk-N7P3HUPD.js";import"../../chunk-ACJ2DBOE.js";import"../../chunk-FPEC6DJV.js";import"../../chunk-SW24KZ5C.js";import"../../chunk-57YXM7AI.js";import"../../chunk-3ZHVP3KE.js";import"../../chunk-WM437XV6.js";import"../../chunk-R7URROQD.js";import"../../chunk-VFWQ2W4B.js";import"../../chunk-GLBWNB2N.js";import"../../chunk-CQD2R3BA.js";import"../../chunk-3UKZJAFS.js";import"../../chunk-77FH6UZP.js";import"../../chunk-YVEI7XR6.js";import"../../chunk-4GM4OEQY.js";import"../../chunk-GIRPEMTW.js";import"../../chunk-DQYYHX6K.js";import"../../chunk-DB4ZM5N3.js";import"../../chunk-3WNQ52TW.js";import"../../chunk-PIVEJTNF.js";import"../../chunk-KSKC5SEQ.js";import"../../chunk-LMQDS47I.js";import"../../chunk-DANMUHNW.js";import"../../chunk-JQ2ZCUEC.js";import"../../chunk-WWL4HNXM.js";import"../../chunk-3IAZMJA4.js";import"../../chunk-XFOG2PDJ.js";import"../../chunk-SIGZEQ3K.js";import"../../chunk-FXQS7AEZ.js";import"../../chunk-LJRE3LZ2.js";import"../../chunk-QH7JB4UQ.js";import"../../chunk-52OHAULM.js";import"../../chunk-AZB34RT6.js";import"../../chunk-FLXWL4F4.js";import"../../chunk-7V6LLVAY.js";import"../../chunk-6UEFCMR2.js";import"../../chunk-MODXEGCU.js";import"../../chunk-MHVHGKDK.js";import"../../chunk-RBSEE2Z6.js";import"../../chunk-TL57YUJV.js";import"../../chunk-YSY25OGG.js";import"../../chunk-M7QSC64D.js";import"../../chunk-CEM7JMUW.js";import"../../chunk-L3AXNCWC.js";import"../../chunk-ANHFE6US.js";import"../../chunk-GYKYJJNF.js";import"../../chunk-G7V4ZZZ3.js";import"../../chunk-AHLVY52I.js";import"../../chunk-YX2IGS72.js";import"../../chunk-55HFAX5Y.js";import"../../chunk-26XE3JCL.js";import"../../chunk-PPAHIVG5.js";import"../../chunk-5MXZJWQS.js";import"../../chunk-CT7FWSIU.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-OZQNSELV.js";import"../../chunk-HFGO5762.js";import"../../chunk-VS5ROGDP.js";import"../../chunk-AXTEV56C.js";import"../../chunk-VZYNZS5U.js";import"../../chunk-U2NT5OSQ.js";import"../../chunk-KGURGIZ2.js";import"../../chunk-GYNZ3OZF.js";import"../../chunk-UPFH72PF.js";import"../../chunk-U6AASXY3.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-KFNFLMUR.js";import"../../chunk-LARY6ZFT.js";import"../../chunk-JP6ULOEX.js";import"../../chunk-SVZYRGO5.js";import"../../chunk-WULEBQPI.js";import"../../chunk-GPBN4ROE.js";import"../../chunk-6XTLP2G7.js";import"../../chunk-PJ3WHQ67.js";import{b as A,d as C,g as S,i as E,j as L,k as $}from"../../chunk-QI3FJKGK.js";import{a as O}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{f as m}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import{e as I,l as p}from"../../chunk-PZNWH4VQ.js";import{a as e}from"../../chunk-ZLLER3HP.js";import{trace as de,context as me}from"@opentelemetry/api";import{NodeSDK as W}from"@opentelemetry/sdk-node";import{OTLPTraceExporter as Y}from"@opentelemetry/exporter-trace-otlp-http";import{BatchSpanProcessor as J,ConsoleSpanExporter as z,SimpleSpanProcessor as Q}from"@opentelemetry/sdk-trace-node";import{Resource as Z}from"@opentelemetry/resources";import{ATTR_SERVICE_NAME as ee,ATTR_SERVICE_VERSION as te}from"@opentelemetry/semantic-conventions";function F(r){if(!r)return{};let n={};for(let o of r.split(",")){let s=o.indexOf("=");if(s===-1)continue;let i=o.slice(0,s).trim(),c=o.slice(s+1).trim();i&&(n[i]=c)}return n}e(F,"parseOtlpHeaders");var u=null;function T(){return process.env.TELEMETRY_ENABLED!=="false"}e(T,"isTelemetryEnabled");function x(r){if(!T()||u!==null)return"off";let n=new Z({[ee]:r.serviceName,[te]:r.serviceVersion??"0.1.0"}),o=process.env.OTEL_EXPORTER_OTLP_ENDPOINT,s,i;if(o){let c=F(process.env.OTEL_EXPORTER_OTLP_HEADERS),l=new Y({url:`${o}/v1/traces`,headers:c});i=new J(l),s="otlp"}else if(process.env.OTEL_SPAN_EXPORT==="none")i=void 0,s="silent";else{let c=new z;i=new Q(c),s="console"}return u=new W({resource:n,spanProcessors:i?[i]:[]}),u.start(),s}e(x,"initTelemetry");async function h(){u&&(await u.shutdown(),u=null)}e(h,"shutdownTelemetry");import{SpanKind as Pe,SpanStatusCode as Re}from"@opentelemetry/api";import{trace as Ie,context as Oe}from"@opentelemetry/api";import*as f from"@sentry/node";var v=!1;function w(r){if(v)return!1;let n=process.env.SENTRY_DSN;return n?(f.init({dsn:n,serverName:r.serviceName,environment:process.env.NODE_ENV??"development",tracesSampleRate:0}),v=!0,!0):!1}e(w,"initSentry");async function y(r){v&&await f.flush(r)}e(y,"flushSentry");import{existsSync as ne,mkdirSync as oe,readFileSync as k,unlinkSync as X,writeFileSync as U}from"node:fs";import{dirname as se,join as R}from"node:path";import{execFileSync as ie}from"node:child_process";var a=R(p(),"evals-agent.lock");function ce(r){try{return process.kill(r,0),!0}catch(n){return n.code==="EPERM"}}e(ce,"pidAlive");function ae(r){if(!ce(r))return!1;try{let n=ie("ps",["-p",String(r),"-o","command="],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]});return/run\.js\s+evals\s+agent|evals\s+agent/.test(n)}catch{return!0}}e(ae,"isLiveAgent");function le(){try{oe(se(a),{recursive:!0})}catch{}for(let r=0;r<2;r++)try{return U(a,String(process.pid),{flag:"wx"}),{ok:!0}}catch(n){if(n.code!=="EEXIST")throw n;let o=0;try{o=Number(k(a,"utf-8").trim())}catch{}if(o&&o!==process.pid&&ae(o))return{ok:!1,holder:o};try{X(a)}catch{}}try{U(a,String(process.pid))}catch{}return{ok:!0}}e(le,"acquireAgentLock");function P(){try{ne(a)&&Number(k(a,"utf-8").trim())===process.pid&&X(a)}catch{}}e(P,"releaseAgentLock");var N=class r extends O{static{e(this,"EvalAgentCommand")}static description="The worker daemon: long-polls /api/work/next, claims jobs, and runs them locally. Installed as a launchd service by `rulemetric service install`.";static examples=["<%= config.bin %> evals agent"];async run(){await this.parse(r),this.requireAuth();let n=le();if(!n.ok){this.log(`Another rulemetric evals agent is already running (pid ${n.holder}). Refusing to start a second instance.`);return}process.env.PG_APPLICATION_NAME||="rulemetric-agent",w({serviceName:"rulemetric-agent"})&&this.log("[sentry] error capture enabled");let s=x({serviceName:"rulemetric-agent"});s==="otlp"?this.log(`[otel] traces exporting to ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}`):s==="console"?this.log("[otel] cron spans printing to stdout (set OTEL_EXPORTER_OTLP_ENDPOINT to ship to a backend)"):this.log("[otel] disabled (TELEMETRY_ENABLED=false)"),!I()&&!process.env.RULEMETRIC_API_KEY&&this.error("No auth token found. Run `rulemetric auth login` first."),this.log("Starting thin agent (Phase 4b parallel-run)..."),this.log(`Long-polling /api/work/next. Press Ctrl+C to stop.
|
|
2
2
|
`);let c=new AbortController,l=await A({configDir:p()});if(this.log(`[transcript-sync] Codex capture: ${S(l)}`),l.error)this.log(`[transcript-sync] WARNING: ${l.error}`);else if(l.mode==="allowlist")for(let t of l.roots)this.log(`[transcript-sync] \u2022 ${t}`);let d=await C({configDir:p()});if(this.log(`[transcript-sync] Pi capture: ${E(d)}`),d.error)this.log(`[transcript-sync] WARNING: ${d.error}`);else if(d.mode==="allowlist")for(let t of d.roots)this.log(`[transcript-sync] \u2022 ${t}`);let B=new M({postSnapshot:e((t,K)=>m(`/api/sessions/${t}/context-snapshots`,K),"postSnapshot"),linkInstructions:e(t=>m("/api/sessions/link-instructions",{sessionId:t}),"linkInstructions"),log:e(t=>this.log(`[transcript-sync] ${t}`),"log")}),H=new G({providers:[V(void 0,void 0,L({configDir:p(),onChange:e(t=>this.log(`[transcript-sync] Codex capture changed: ${S(t)}`),"onChange")})),j(void 0,void 0,$({configDir:p(),onChange:e(t=>this.log(`[transcript-sync] Pi capture changed: ${E(t)}`),"onChange")}))],statePath:R(p(),"transcript-sync-state.json"),importTranscript:e(t=>m("/api/sessions/import",t),"importTranscript"),emitInstructions:e(t=>B.emit(t),"emitInstructions"),log:e(t=>this.log(`[transcript-sync] ${t}`),"log")});q(H,{signal:c.signal,log:e(t=>this.log(`[transcript-sync] ${t}`),"log")});let _=e(async t=>{this.log(`
|
|
3
3
|
[${t}] shutting down agent...`),c.abort(),await Promise.allSettled([y(2e3),h(),g()]),P(),process.exit(0)},"shutdown");process.on("SIGINT",()=>{_("SIGINT")}),process.on("SIGTERM",()=>{_("SIGTERM")});let b=!1;try{await D({signal:c.signal,log:e(t=>this.log(t),"log"),version:this.config.version,readInstalledVersion:e(()=>{try{return JSON.parse(k(R(this.config.root,"package.json"),"utf-8")).version??null}catch{return null}},"readInstalledVersion"),onVersionDrift:e(()=>{b=!0},"onVersionDrift")}),b&&(this.log("[upgrade] Installed CLI version changed \u2014 restarting worker onto the new code."),await Promise.allSettled([y(2e3),h(),g()]),P(),process.exit(1))}finally{P(),await g()}}};export{N as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k}from"../../chunk-RBSEE2Z6.js";import{e as $}from"../../chunk-
|
|
1
|
+
import{a as k}from"../../chunk-RBSEE2Z6.js";import{e as $}from"../../chunk-AXTEV56C.js";import"../../chunk-VZYNZS5U.js";import"../../chunk-U2NT5OSQ.js";import"../../chunk-KGURGIZ2.js";import"../../chunk-GYNZ3OZF.js";import"../../chunk-UPFH72PF.js";import"../../chunk-U6AASXY3.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-LARY6ZFT.js";import"../../chunk-JP6ULOEX.js";import"../../chunk-SVZYRGO5.js";import"../../chunk-WULEBQPI.js";import"../../chunk-GPBN4ROE.js";import"../../chunk-6XTLP2G7.js";import"../../chunk-PJ3WHQ67.js";import{a as w}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as h}from"../../chunk-ZLLER3HP.js";import{Args as A,Flags as r}from"@oclif/core";var m=class y extends w{static{h(this,"EvalAutoRun")}static description="Run evals in a loop until the effect verdict is statistically powered (\xA76f auto-run-to-power)";static examples=["<%= config.bin %> evals auto-run <target-id> # preview (cost + plan)","<%= config.bin %> evals auto-run <target-id> --yes # run until powered / budget","<%= config.bin %> evals auto-run <target-id> --yes --max-runs 120 --batch-parallel 4"];static args={targetId:A.string({description:"Eval target ID",required:!0})};static flags={yes:r.boolean({char:"y",description:"Actually run. Without this, only previews the plan + cost."}),"max-runs":r.integer({description:"Hard ceiling on completed runs",default:200}),"batch-parallel":r.integer({description:"Concurrent executions within a batch",default:3}),timeout:r.integer({description:"Timeout per eval in ms",default:12e4}),model:r.string({description:"Model for eval execution"}),"grader-model":r.string({description:"Model for grading"}),"skip-baseline":r.boolean({description:"Skip without_target runs (no delta \u2014 not recommended)",default:!1})};async run(){let{args:C,flags:e}=await this.parse(y);this.requireAuth();let i=C.targetId,c=20,a=await n(`/api/eval-targets/${i}`),l=await n(`/api/eval-targets/${i}/evals`);l.length===0&&this.error(`No active cases on "${a.name}". Generate some (\`evals create\` / the web Generate button) or run \`evals refine-cases\` first.`);let b=l.length*(e["skip-baseline"]?1:2),f=Math.ceil(e["max-runs"]/b);if(this.log(`Auto-run "${a.name}" v${a.version} toward a powered \xB1${c}pp verdict.`),this.log(`Plan: up to ${e["max-runs"]} runs (${l.length} active case(s) \xD7 ${e["skip-baseline"]?1:2}/batch = ${b}/batch, \u2264${f} batches). Each run is a synthetic \`claude -p\` execution + grade.`),this.log('Note: this is a controlled synthetic A/B. For a DEPLOYED instruction with real usage, the Insights observational verdict is cheaper and uses real sessions \u2014 auto-run is for pre-deploy, catalog skills, or targets with no real "without" cohort.'),!e.yes){this.log(`
|
|
2
2
|
Preview only. Re-run with --yes to start.`);return}let t={runsCompleted:0,maxRuns:e["max-runs"],batchesRun:0,maxBatches:f},x={targetId:i,targetVersion:a.version,iteration:1,timeout:e.timeout,model:e.model,graderModel:e["grader-model"],skipGrading:!1,targetType:a.type,targetName:a.name};for(;;){let s;try{s=await n(`/api/eval-targets/${i}/judge-calibration`)}catch(o){this.log(`
|
|
3
3
|
\u25A0 stopping \u2014 could not read the power check: ${o instanceof Error?o.message:String(o)}`);break}let E={powered:s.powerCheck?.powered??!1,mde:s.powerCheck?.mde==null?1/0:s.powerCheck.mde},B=s.caseDiscrimination??{total:0,discriminating:0,nonDiscriminating:0,unpaired:0},p=k(E,B,t,{targetEffectPp:c});if(this.log(`
|
|
4
4
|
${p.action==="stop"?"\u25A0":"\u25B8"} ${p.reason}`),p.action==="stop")break;let v=await n(`/api/eval-targets/${i}/evals`);if(v.length===0){this.log("\u25A0 no active cases left \u2014 stopping.");break}let{completed:g,failed:D}=await $({cases:v,targetContent:a.content,concurrency:e["batch-parallel"],runNumber:t.batchesRun+1,opts:x,skipBaseline:e["skip-baseline"],onLog:h(o=>this.log(o),"onLog")});if(t.runsCompleted+=g,t.batchesRun+=1,this.log(`Batch ${t.batchesRun}: ${g} completed, ${D} failed \u2014 ${t.runsCompleted}/${t.maxRuns} runs, ${t.batchesRun}/${t.maxBatches} batches.`),g===0){this.log("\u25A0 batch produced 0 completed runs \u2014 the executor appears broken (check the model / `claude -p`). Aborting.");break}}let d=await n(`/api/eval-targets/${i}/judge-calibration`),u=d.powerCheck?.mde,R=u==null||!Number.isFinite(u)?"unknown":`\xB1${Math.round(u*100)}pp`;this.log(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as h,c as f}from"../../chunk-
|
|
1
|
+
import{b as h,c as f}from"../../chunk-PHBPHZSZ.js";import"../../chunk-KFNFLMUR.js";import{a as m}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{e as c}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as u}from"../../chunk-ZLLER3HP.js";import{Args as p,Flags as v}from"@oclif/core";var d=class b extends m{static{u(this,"EvalBenchmarkCommand")}static description="Aggregate eval runs into a benchmark for a target";static examples=["<%= config.bin %> evals benchmark <target-id>","<%= config.bin %> evals benchmark <target-id> --iteration 2"];static args={targetId:p.string({description:"Eval target ID",required:!0})};static flags={iteration:v.integer({description:"Filter runs by iteration",default:1})};async run(){let{args:o,flags:l}=await this.parse(b);this.requireAuth();let g=await c(`/api/eval-targets/${o.targetId}`);this.log(`Aggregating benchmark for "${g.name}" v${g.version}, iteration ${l.iteration}`);let a=await h(o.targetId,l.iteration);a.totalRuns===0&&this.error("No completed runs found. Run evals first with `rulemetric evals run`."),this.log(`
|
|
2
2
|
Aggregated ${a.totalRuns} runs
|
|
3
3
|
`);for(let[e,n]of Object.entries(a.runSummary)){this.log(`${e}:`);for(let[r,i]of Object.entries(n)){let s=i;this.log(` ${r}: mean=${s.mean} stddev=${s.stddev} [${s.min}, ${s.max}]`)}}let t=a.verdict;if(t)if(this.log(`
|
|
4
4
|
Verdict (${t.mode}, baseline=${t.baseline}):`),!t.sufficient)this.log(` ${t.insufficientReason??"insufficient data"} \u2014 no effect claimed`);else{let e=t.delta>=0?"+":"";this.log(` pass-rate delta: ${e}${(t.delta*100).toFixed(0)}% (n=${t.nWith} paired)`),this.log(` 95% CI: ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%`),t.pValue!=null&&this.log(` McNemar p: ${t.pValue.toFixed(4)}`),this.log(` significant: ${t.significant?"YES":"no"}`)}if(a.notes.length>0){this.log(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as $,b as A}from"../../chunk-647M2I2Y.js";import{
|
|
1
|
+
import{a as $,b as A}from"../../chunk-647M2I2Y.js";import{g as p}from"../../chunk-LARY6ZFT.js";import"../../chunk-JP6ULOEX.js";import"../../chunk-SVZYRGO5.js";import"../../chunk-WULEBQPI.js";import"../../chunk-GPBN4ROE.js";import"../../chunk-6XTLP2G7.js";import"../../chunk-PJ3WHQ67.js";import{a as f}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{e as l,f as w}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as h}from"../../chunk-ZLLER3HP.js";import{Args as B,Flags as b}from"@oclif/core";var c=class I extends f{static{h(this,"EvalCompareCommand")}static description="Blind A/B comparison between two eval target versions";static examples=["<%= config.bin %> evals compare <target-a> <target-b>"];static args={targetA:B.string({description:"First eval target ID",required:!0}),targetB:B.string({description:"Second eval target ID",required:!0})};static flags={model:b.string({description:"Model for execution and comparison"}),timeout:b.integer({description:"Timeout per eval in ms",default:12e4})};async run(){let{args:g,flags:o}=await this.parse(I);this.requireAuth();let[e,r]=await Promise.all([l(`/api/eval-targets/${g.targetA}`),l(`/api/eval-targets/${g.targetB}`)]),m=await l(`/api/eval-targets/${g.targetA}/evals`);m.length===0&&this.error("No evals found for target A. Create some first."),this.log(`Comparing "${e.name}" v${e.version} vs "${r.name}" v${r.version}`),this.log(`Running ${m.length} eval(s)...
|
|
2
2
|
`);let a=Math.random()>.5,E=a?r.content:e.content,T=a?e.content:r.content,C=a?r.name:e.name,x=a?e.name:r.name,v=[];for(let t of m){this.log(`[${t.name}] Running A...`);let s=await p({prompt:t.prompt,targetContent:E,timeout:o.timeout,model:o.model});this.log(`[${t.name}] Running B...`);let d=await p({prompt:t.prompt,targetContent:T,timeout:o.timeout,model:o.model});(s.error||d.error)&&this.error(`[${t.name}] execution failed (A: ${s.error??"ok"} | B: ${d.error??"ok"}) \u2014 aborting before the blind comparison`),v.push({evalName:t.name,outputA:s.output,outputB:d.output})}this.log(`
|
|
3
3
|
Running blind comparison...`);let N=v.map(t=>`
|
|
4
4
|
## Eval: ${t.evalName}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"../../chunk-
|
|
1
|
+
import{a as c}from"../../chunk-MOQTSJNZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-TDDJOSFQ.js";import"../../chunk-433HK3QQ.js";import"../../chunk-WDLAPZPN.js";import"../../chunk-3AV3GTMP.js";import{f as i}from"../../chunk-Z7UN4R7T.js";import"../../chunk-X6CF5KTW.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as m}from"../../chunk-ZLLER3HP.js";import{Args as f,Flags as r}from"@oclif/core";import{readFileSync as g}from"node:fs";var s=class d extends c{static{m(this,"EvalCreate")}static description="Create test cases (evals) for an eval target";static examples=['<%= config.bin %> evals create <target-id> --name "ts-check" --prompt "Write a function to add two numbers"',"<%= config.bin %> evals create <target-id> --from-file evals.json"];static args={targetId:f.string({description:"Eval target ID",required:!0})};static flags={name:r.string({char:"n",description:"Eval name"}),prompt:r.string({char:"p",description:"Test prompt"}),expectations:r.string({char:"e",description:"Assertion (repeatable)",multiple:!0}),"from-file":r.string({description:"Bulk create from JSON file"})};async run(){let{args:n,flags:e}=await this.parse(d);if(this.requireAuth(),e["from-file"]){let a=JSON.parse(g(e["from-file"],"utf-8")),p=Array.isArray(a)?a:a.evals;for(let t of p){let l=await i(`/api/eval-targets/${n.targetId}/evals`,{name:t.name,prompt:t.prompt,expectations:t.expectations??[],files:t.files??[]});this.log(`Created eval: ${l.name} (${l.id})`)}this.log(`Created ${p.length} evals.`);return}(!e.name||!e.prompt)&&this.error("Provide --name and --prompt, or use --from-file for bulk creation");let o=await i(`/api/eval-targets/${n.targetId}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations??[]});this.log(`Created eval: ${o.name} (${o.id})`)}};export{s as default};
|