@rulemetric/cli 0.7.44 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/base-command.js +1 -1
- package/dist/{chunk-4Q72B377.js → chunk-2B7Y6JNB.js} +1 -1
- package/dist/{chunk-Z2MZOQCD.js → chunk-3AZV7ZPJ.js} +1 -1
- package/dist/chunk-3DGL2ZY3.js +1 -0
- package/dist/chunk-3PUOJ6F2.js +45 -0
- package/dist/{chunk-QFVGUZDO.js → chunk-4PWGV2OW.js} +9 -8
- package/dist/{chunk-5ZACMVV3.js → chunk-5EDINFHF.js} +1 -1
- package/dist/{chunk-FAXV5AAG.js → chunk-6M74HH6Y.js} +1 -1
- package/dist/chunk-7FZB65VH.js +1 -0
- package/dist/{chunk-4VZLIGMS.js → chunk-AFYZYXQ3.js} +1 -1
- package/dist/{chunk-TU2AR6XO.js → chunk-B22HYCBV.js} +1 -1
- package/dist/{chunk-RJLAAKEN.js → chunk-BPP7AEFW.js} +1 -1
- package/dist/{chunk-MOAJLSYV.js → chunk-C2275MFP.js} +1 -1
- package/dist/{chunk-T4ZIK6RS.js → chunk-CBUTNIJA.js} +1 -1
- package/dist/{chunk-ULMEKK7C.js → chunk-CDDICCY2.js} +1 -1
- package/dist/chunk-DZ3FBQYD.js +17 -0
- package/dist/{chunk-5KD2N2MH.js → chunk-E2NVNLFD.js} +1 -1
- package/dist/{chunk-NIRD7ETU.js → chunk-EQHKCGSX.js} +1 -1
- package/dist/chunk-FP6QAPNK.js +1 -0
- package/dist/chunk-FWTYR36W.js +1 -0
- package/dist/chunk-G7V4ZZZ3.js +1 -0
- package/dist/chunk-GF76D2DU.js +1 -0
- package/dist/chunk-HOQPVOMF.js +2 -0
- package/dist/{chunk-ATA4J4ZG.js → chunk-HYDGERWD.js} +1 -1
- package/dist/chunk-IVDTORX5.js +1 -0
- package/dist/{chunk-4L2ZEIRE.js → chunk-JPUH3V67.js} +1 -1
- package/dist/chunk-K4B24SMJ.js +1 -0
- package/dist/chunk-KGURGIZ2.js +1 -0
- package/dist/{chunk-2DXBC2JQ.js → chunk-KHWG7ZG4.js} +1 -1
- package/dist/{chunk-KGQ5W54Y.js → chunk-KWNIKGAE.js} +1 -1
- package/dist/{chunk-H7VP4SDO.js → chunk-L54TWWBY.js} +1 -1
- package/dist/{chunk-5XUN743A.js → chunk-LLIHRQPH.js} +1 -1
- package/dist/chunk-MMPZIZYZ.js +10 -0
- package/dist/chunk-MO57LGGK.js +1 -0
- package/dist/{chunk-LLNQZ4SZ.js → chunk-PKLXZYBY.js} +1 -1
- package/dist/{chunk-5RUEROLC.js → chunk-PQN2GAG4.js} +1 -1
- package/dist/chunk-QAV4HW7D.js +1 -0
- package/dist/{chunk-YW3JQKGY.js → chunk-QTZPLAYC.js} +1 -1
- package/dist/chunk-QWPWY3SW.js +1 -0
- package/dist/chunk-R6JXE273.js +13 -0
- package/dist/chunk-RZTVYUX4.js +11 -0
- package/dist/{chunk-HXZM2UHO.js → chunk-S62MK372.js} +1 -1
- package/dist/{chunk-BLCMXTIK.js → chunk-SANYAPBK.js} +1 -1
- package/dist/{chunk-AI6FMGKM.js → chunk-SYTQDPPN.js} +1 -1
- package/dist/chunk-TZA4HAVF.js +1 -0
- package/dist/{chunk-6VKQT2J3.js → chunk-UUZB4IKU.js} +1 -1
- package/dist/{chunk-QY3UKLDE.js → chunk-VA5DPQB4.js} +1 -1
- package/dist/{chunk-AF3ITIZ4.js → chunk-VFYT3SC5.js} +2 -2
- package/dist/{chunk-O2BKBW7Z.js → chunk-WKDXH7NO.js} +1 -1
- package/dist/{chunk-NBTC5FNV.js → chunk-X23L2MF6.js} +1 -1
- package/dist/{chunk-W76EQSEV.js → chunk-X3RTCN6S.js} +1 -1
- package/dist/{chunk-EN43UYBN.js → chunk-X3VL5H24.js} +1 -1
- package/dist/{chunk-YQ56FQEO.js → chunk-XFAFMYIP.js} +1 -1
- package/dist/{chunk-IQCE4VBP.js → chunk-YFQ4FOAS.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/convert.js +1 -1
- package/dist/commands/converters.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 -0
- 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/import.js +1 -1
- package/dist/commands/instructions/create.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 -0
- 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/tail-transcript.js +1 -1
- package/dist/commands/service/install.js +6 -6
- 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 -11
- package/dist/commands/suggestions/auto.js +1 -0
- 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 -0
- 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/lib/active-org-refresh.js +1 -1
- package/dist/lib/agent-loop.js +1 -1
- package/dist/lib/antigravity-transcript.js +1 -1
- package/dist/lib/api-client.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-conversation-handler.js +1 -1
- package/dist/lib/eval-executor.js +1 -1
- package/dist/lib/eval-failure-classifier.js +1 -0
- package/dist/lib/eval-grader.js +1 -1
- package/dist/lib/eval-meta-judge.js +1 -1
- package/dist/lib/eval-quota-gate.js +1 -0
- package/dist/lib/eval-resume.js +1 -0
- 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 -0
- package/dist/lib/handlers/cron-auto-accept-suggestions.js +1 -0
- package/dist/lib/handlers/cron-eval-autorun.js +1 -1
- package/dist/lib/handlers/cron-instruction-evolution.js +1 -1
- package/dist/lib/handlers/cron-instruction-training.js +1 -0
- package/dist/lib/handlers/cron-refresh-pricing.js +1 -1
- package/dist/lib/handlers/cron-suggest-instructions.js +1 -1
- package/dist/lib/handlers/distill-memories.js +1 -1
- package/dist/lib/handlers/process-changelog.js +1 -1
- package/dist/lib/handlers/process-conversation.js +1 -1
- package/dist/lib/handlers/process-eval.js +1 -1
- package/dist/lib/handlers/process-insights.js +1 -1
- package/dist/lib/handlers/process-judge-review.js +1 -1
- package/dist/lib/handlers/process-launch.js +1 -1
- package/dist/lib/handlers/process-memory-ab.js +1 -1
- package/dist/lib/handlers/process-run-cleanup.js +1 -1
- package/dist/lib/handlers/process-session-goal.js +1 -1
- package/dist/lib/insights-prompts.js +1 -1
- package/dist/lib/instruction-proposer.js +1 -1
- package/dist/lib/judge-review-runner.js +1 -1
- package/dist/lib/manual-tasks.js +1 -1
- package/dist/lib/project-context.js +1 -0
- package/dist/lib/research-client.js +1 -1
- package/dist/lib/retraction.js +1 -0
- package/dist/lib/setup-steps.js +1 -1
- package/dist/lib/suggestion-accept.js +1 -0
- package/dist/lib/telemetry.js +1 -1
- package/dist/lib/terminal-target-heartbeat.js +1 -1
- package/oclif.manifest.json +237 -1
- package/package.json +9 -5
- package/dist/chunk-2RCWYVEU.js +0 -1
- package/dist/chunk-5R5RGKOW.js +0 -38
- package/dist/chunk-ATL4WZBF.js +0 -1
- package/dist/chunk-DBELYMDA.js +0 -1
- package/dist/chunk-FFI3C3B3.js +0 -1
- package/dist/chunk-HMMO27U4.js +0 -1
- package/dist/chunk-I7QSMY3Z.js +0 -1
- package/dist/chunk-KLEF5D3A.js +0 -1
- package/dist/chunk-O7PSLZO6.js +0 -15
- package/dist/chunk-RMDLJN4L.js +0 -8
- package/dist/chunk-V2IEFHT7.js +0 -1
- package/dist/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as J}from"./chunk-LLIHRQPH.js";import{b as L}from"./chunk-SANYAPBK.js";import{a as D}from"./chunk-CBUTNIJA.js";import{a as V}from"./chunk-X3RTCN6S.js";import{a as P}from"./chunk-RSKQRVPJ.js";import{a as x}from"./chunk-S62MK372.js";import{a as A}from"./chunk-UF6US7VU.js";import{e as S}from"./chunk-3DGL2ZY3.js";import{b as C}from"./chunk-QTZPLAYC.js";import{a as N}from"./chunk-WKDXH7NO.js";import{a as T}from"./chunk-KWNIKGAE.js";import{a as M}from"./chunk-DZ3FBQYD.js";import{b as R}from"./chunk-5RBLIVBF.js";import{a as B}from"./chunk-C2275MFP.js";import{a as $}from"./chunk-QWPWY3SW.js";import{a as W}from"./chunk-X3VL5H24.js";import{a as F}from"./chunk-K4B24SMJ.js";import{a as O}from"./chunk-6M74HH6Y.js";import{l as H}from"./chunk-IVDTORX5.js";import{d as y}from"./chunk-NTKO4H2K.js";import{b as E,e as I,f}from"./chunk-QAV4HW7D.js";import{a as o}from"./chunk-ZLLER3HP.js";var X={process_eval:T,process_insights:M,process_launch:L,process_send_message:P,process_conversation:N,process_session_goal:x,distill_memories:C,memory_ab:D,process_run_cleanup:V,cron_suggest_instructions:S,cron_refresh_skills:A,cron_refresh_pricing:O,cron_eval_autorun:W,cron_auto_accept_suggestions:$,cron_instruction_training:F,cron_instruction_evolution:H,process_judge_review:B},K=Object.keys(X),z=new Set([]);function Z(e=process.env){return e.DATABASE_URL?K:K.filter(n=>!z.has(n))}o(Z,"availableCapabilities");var j=3e4,ee=3e4,ne=3e4,U=250,G=5e3,re=`thin-agent-${process.pid}`,h=null;function te(e,n,r,l){let a;try{let u=y();a={claude:u.claudeBin!=null,codex:u.codexBin!=null,codexModel:u.codexConfiguredModel}}catch{}let m=o(u=>{f("/api/workers/heartbeat",{workerType:"cli-worker",clientName:re,clientVersion:l,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:u,metadata:{capabilities:e,mode:"thin-agent",llmEngines:a}}).then(c=>{let i=c?.advisory;i&&i.message!==h?(h=i.message,s(r,{event:"worker_advisory",code:i.code,message:i.message})):i||(h=null)}).catch(c=>{s(r,{event:"presence_heartbeat_error",error:c instanceof Error?c.message:String(c)})})},"send");m("alive");let t=setInterval(()=>m("alive"),ne);n.addEventListener("abort",()=>{clearInterval(t),m("shutting_down")},{once:!0})}o(te,"startPresenceHeartbeat");function s(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}o(s,"structuredLog");function q(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let l=setTimeout(()=>{n.removeEventListener("abort",a),r(!0)},e),a=o(()=>{clearTimeout(l),n.removeEventListener("abort",a),r(!1)},"onAbort");n.addEventListener("abort",a,{once:!0})})}o(q,"abortableSleep");async function oe(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,l=await I(`/api/work/next?${r}`);return l==null||typeof l=="string"?null:l}o(oe,"pollForWork");function se(e,n){return{logger:{info:o(r=>n(r),"info"),warn:o(r=>n(r),"warn"),error:o(r=>n(r),"error")},job:{attempts:e}}}o(se,"makeHelpers");async function ae(e,n,r){let l=X[e.kind],a=Date.now();if(s(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!l){let t=`unknown kind: ${e.kind}`;s(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:t}),await f(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:t,terminal:!0}).catch(()=>{});return}let m=setInterval(()=>{s(r,{event:"heartbeat",jobId:e.id}),f(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(t=>{s(r,{event:"heartbeat_error",jobId:e.id,error:t instanceof Error?t.message:String(t)})})},n);try{let t=se(e.attempts,r),u=await l(e.payload,t)??{};clearInterval(m),s(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-a}),await f(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:u})}catch(t){clearInterval(m);let u=R(t),c=t instanceof Error?t.message:String(t);s(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-a,terminal:u,error:c}),await f(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:c,terminal:u}).catch(i=>{s(r,{event:"fail_post_error",jobId:e.id,error:i instanceof Error?i.message:String(i)})})}}o(ae,"runOne");var Q=new Set(["process_eval","process_conversation","process_insights","process_session_goal","distill_memories","memory_ab","cron_suggest_instructions","cron_eval_autorun","cron_instruction_evolution","process_judge_review"]);async function Te(e){let n=e.log??(()=>{}),r=e.pollWaitMs??j,l=e.heartbeatIntervalMs??ee,a=e.capabilities??Z();s(n,{event:"agent_start",capabilities:a,pollWaitMs:r,heartbeatIntervalMs:l}),te(a,e.signal,n,e.version),J({signal:e.signal,log:n}).catch(d=>{s(n,{event:"tt_heartbeat_fatal",error:d instanceof Error?d.message:String(d)})});let m=5*6e4,t=0,u=o(()=>{if(!e.readInstalledVersion||!e.version)return!1;let d=Date.now();if(d-t<m)return!1;t=d;let _=e.readInstalledVersion();return!!(_&&_!==e.version)},"versionDrifted"),c=new AbortController,i=c.signal;e.signal.aborted?c.abort():e.signal.addEventListener("abort",()=>c.abort(),{once:!0});let v=o(async(d,_)=>{let g=U;for(;!i.aborted;){if(u()){s(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),c.abort(),e.onVersionDrift?.();break}let b=null;try{b=await oe([..._],r)}catch(p){let Y=p instanceof E?p.statusCode:void 0;if(s(n,{event:"poll_error",lane:d,status:Y,error:p instanceof Error?p.message:String(p)}),!await q(g,i))break;g=Math.min(g*2,G);continue}if(!b){if(s(n,{event:"poll_204",lane:d}),!await q(g,i))break;g=Math.min(g*2,G);continue}g=U,await ae(b,l,n)}},"runLane"),k=a.filter(d=>Q.has(d)),w=a.filter(d=>!Q.has(d));k.length>0&&w.length>0?(s(n,{event:"agent_lanes",heavy:k.length,fast:w.length}),await Promise.all([v("heavy",k),v("fast",w)])):await v("single",a),s(n,{event:"agent_stop"})}o(Te,"runAgentLoop");export{X as a,K as b,Z as c,oe as d,Te as e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as c}from"./chunk-ZLLER3HP.js";import{closeSync as m,existsSync as y,openSync as h,readSync as k,statSync as w}from"node:fs";import u from"node:path";var A=16e3,l=300,E=25,R=12;function a(e){let t=null;try{if(!y(e))return null;let n=w(e);if(!n.isFile())return null;let i=Math.min(n.size,A);if(i===0)return"";let o=Buffer.allocUnsafe(i);t=h(e,"r");let f=k(t,o,0,i,0);return o.subarray(0,f).toString("utf8")}catch{return null}finally{if(t!==null)try{m(t)}catch{}}}c(a,"readCapped");function S(e){for(let t of e.split(`
|
|
2
|
+
`)){let n=t.trim();if(n&&!n.startsWith("#")&&!n.startsWith("<")&&!n.startsWith("!")&&!n.startsWith("[!")&&!/^[-*=_]{3,}$/.test(n)&&!n.startsWith("```")&&!n.startsWith(">")&&!/^(\[[^\]]*\]\([^)]*\)\s*)+$/.test(n))return n.slice(0,l)}return null}c(S,"firstProseLine");function d(e){return!e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e)}c(d,"depNames");function D(e,t){let n=new Set,i=[];for(let o of[...e,...t])if(!n.has(o)&&(n.add(o),i.push(o),i.length>=E))break;return i}c(D,"rankDependencies");function M(e){let t=null,n=[],i=[],o=[],f=a(u.join(e,"package.json"));if(f)try{let s=JSON.parse(f);if(typeof s.description=="string"&&s.description.trim()&&(t=s.description.trim().slice(0,l)),Array.isArray(s.keywords))for(let r of s.keywords)typeof r=="string"&&r.trim()&&n.length<R&&n.push(r.trim());i=d(s.dependencies),o=d(s.devDependencies)}catch{}if(!t||i.length===0){let s=a(u.join(e,"pyproject.toml"));if(s){if(!t){let r=s.match(/^\s*description\s*=\s*["']([^"'\n]+)["']/m);r?.[1]&&(t=r[1].trim().slice(0,l))}if(i.length===0){let r=s.match(/dependencies\s*=\s*\[([^\]]*)\]/);if(r?.[1])for(let g of r[1].split(",")){let p=g.trim().replace(/^["']|["']$/g,"").split(/[<>=!~[\s]/)[0];p&&i.push(p)}}}}if(!t)for(let s of["README.md","readme.md","README.rst","README.txt"]){let r=a(u.join(e,s));if(r&&(t=S(r),t))break}return{description:t,topics:n,dependencies:D(i,o)}}c(M,"readProjectContext");export{S as a,D as b,M as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as j}from"./chunk-CDDICCY2.js";import{b as I,c as P,d as v}from"./chunk-PQN2GAG4.js";import{a as E}from"./chunk-X23L2MF6.js";import{a as J}from"./chunk-B22HYCBV.js";import{d as T}from"./chunk-NJ5UED3H.js";import{a as b}from"./chunk-ZLLER3HP.js";import{useEffect as R,useState as i}from"react";import{Box as l,Text as s,useInput as Z}from"ink";import{jsx as t,jsxs as a}from"react/jsx-runtime";function K({onClose:A,activeOrg:F,defaultProjectPath:y,width:_}){let{jobs:u,error:L,loading:$,refetch:S}=j(20),[M,C]=i([]),[d,m]=i("list"),[f,w]=i(0),[h,g]=i(null),[x,B]=i(null),[p,c]=i(null);R(()=>{v().then(C).catch(o=>{let r=o instanceof Error?o.message:String(o);c(`couldn't load launchers: ${r}`),C([{tool:"claude_code",capabilities:{headless:!0,interactive:!0,remoteSpawn:!0}}])})},[]),R(()=>{if(!p)return;let o=setTimeout(()=>c(null),5e3);return()=>clearTimeout(o)},[p]),Z((o,r)=>{if(h){if(o==="y"||o==="Y"){let e=h.id;g(null),P(e).then(()=>{S(),c(`cancelled ${e.slice(0,8)}`)}).catch(n=>c(`cancel failed: ${n instanceof Error?n.message:String(n)}`))}else(o==="n"||o==="N"||r.escape)&&g(null);return}if(r.escape){if(d!=="none"){m("none");return}A();return}if(r.tab){m(e=>e==="list"?"form":e==="form"?"none":"list");return}if(o!=="q"&&d==="list"){if(r.upArrow)w(e=>Math.max(0,e-1));else if(r.downArrow)w(e=>Math.min(u.length-1,e+1));else if(o==="c"){let e=u[f];e&&(e.status==="running"||e.status==="queued"||e.status==="pending")&&g(e)}else if(o==="r"){let e=u[f],n=e?.result?.externalSessionId;e&&e.tool==="claude_code"&&n?(B({tool:"claude_code",projectPath:e.config.projectPath,resumeSessionId:n}),m("form")):c("resume needs a Claude Code session with a session id")}else if(o==="o"){let n=u[f]?.result?.externalSessionId;if(n){let O=process.env.RULEMETRIC_WEB_URL??"http://localhost:5174";import("node:child_process").then(({spawn:U})=>{U("open",[`${O}/sessions/${n}`],{detached:!0,stdio:"ignore"}).unref()})}}}});async function N(o){await I(o),B(null),m("list"),c("launched"),S()}return b(N,"handleSubmit"),a(l,{flexDirection:"column",borderStyle:"round",borderColor:T,width:_,paddingX:1,children:[a(l,{children:[t(s,{bold:!0,color:T,children:"Launcher"}),t(s,{dimColor:!0,children:" active org: "}),t(s,{children:F??"(none)"}),$&&t(s,{dimColor:!0,children:" loading\u2026"}),L&&a(s,{color:"#F55B5B",children:[" \u26A0 ",L]})]}),t(l,{marginTop:1,children:t(E,{jobs:u,selectedIndex:f,focused:d==="list"})}),t(l,{marginTop:1,children:t(J,{launchers:M,defaultProjectPath:x?.projectPath??y,defaultTool:x?.tool,defaultResumeSessionId:x?.resumeSessionId,focused:d==="form",onSubmit:N})}),h&&t(l,{marginTop:1,children:a(s,{color:"#FFD700",children:["Cancel job ",h.id.slice(0,8),"? (y/n)"]})}),p&&t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\xB7 ",p]})}),t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\u2191\u2193 select tab focus c cancel r resume o open esc ",d==="none"?"close":"back"]})})]})}b(K,"LauncherOverlay");export{K as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as Ce}from"./chunk-RZTVYUX4.js";import{a as we,b as Pe,c as ye,d as ve,e as ee,f as ke}from"./chunk-FWTYR36W.js";import{b as le,i as ce,j as ue,k as pe,l as de,m as ge,n as me}from"./chunk-BL4BN6RU.js";import{c as $e}from"./chunk-G7V4ZZZ3.js";import{d as fe,e as he,g as be}from"./chunk-7FZB65VH.js";import{d as oe,e as Z,f as se}from"./chunk-G5BXZT6F.js";import{e as P,f as K}from"./chunk-QAV4HW7D.js";import{a as u}from"./chunk-ZLLER3HP.js";import{createHash as Te}from"node:crypto";import{existsSync as Ae,readFileSync as Re,writeFileSync as Me}from"node:fs";var M=u(a=>Te("sha256").update(a).digest("hex"),"sha256"),xe=1.3,te=4,We=20;function Ne(a,o){if(!a.configured||o<=0)return te;let t=Math.ceil(a.minPairs*xe/o);return Math.min(We,Math.max(te,t))}u(Ne,"passCapFor");function Le(a,o=10,t=te){if(a<=0)return{passes:0,expectedPairs:0,feasible:!1,reason:"no live cases"};let l=Math.ceil(o*xe),e=Math.min(t,Math.ceil(l/a)),r=e*a;return r<o?{passes:e,expectedPairs:r,feasible:!1,reason:`${a} live case(s) x ${t} passes = ${a*t} pairs at best, below the ${o} a controlled verdict requires \u2014 add cases rather than replaying these`}:{passes:e,expectedPairs:r,feasible:!0}}u(Le,"planPasses");var Fe=60,je=u(a=>typeof a=="object"&&a!==null&&typeof a.withScore=="number"&&typeof a.withoutScore=="number","isPair");function Ue(a,o,t){let l=[...a].sort((e,r)=>Date.parse(r.createdAt)-Date.parse(e.createdAt));for(let e of l){if(e.applied)continue;let r=e.gates?.accumulation;if(!r||typeof r!="object"||r.priorContentHash!==o||r.targetPairs!==t||typeof r.candidateContentHash!="string"||!Array.isArray(r.pairs))continue;let i=r.pairs.filter(je);if(i.length===r.pairs.length&&!(i.length>=t))return{promotionId:e.id,candidateContentHash:r.candidateContentHash,pairs:i,runs:typeof r.runs=="number"?r.runs:1}}return null}u(Ue,"findOpenAccumulation");var qe=5,Ee=u(a=>Array.isArray(a)?a.filter(o=>typeof o=="string"):[],"stringList"),F=u(a=>typeof a=="number"&&Number.isFinite(a)?a:null,"finite");function Ge(a,o,t=qe){let l=[...a].filter(i=>i.fromContentHash===o).sort((i,m)=>Date.parse(m.createdAt)-Date.parse(i.createdAt)),e=[],r=new Set;for(let i of l){let m=i.toContentHash??i.id;if(r.has(m))continue;r.add(m);let y=i.verdict??null,S=F(y?.delta),I=F(y?.ci?.lower),C=F(y?.ci?.upper),j=F(y?.nWith),p=y?.sufficient===!0&&S!=null&&I!=null&&C!=null&&j!=null?{delta:S,ciLower:I,ciUpper:C,nPairs:j}:null;if(e.push({decision:typeof i.decision=="string"?i.decision:"unknown",applied:i.applied===!0,at:typeof i.createdAt=="string"?i.createdAt:"",rationale:typeof i.proposalRationale=="string"?i.proposalRationale:"",touched:Ee(i.touchedSections),refusals:Ee(i.refusals),measured:p}),e.length>=t)break}return e}u(Ge,"summarisePriorDecisions");function Be(a,o){let t=o.accumulate??(a.autoEvolveAccumulate===!0||a.autoEvolveAccumulate==="true"),l=o.accumulateTargetPairs??a.autoEvolveAccumulateTarget,e=typeof l=="string"?Number.parseInt(l,10):l,r=typeof e=="number"&&Number.isInteger(e)&&e>0?e:Fe;return{enabled:t,targetPairs:r}}u(Be,"readAccumulateConfig");function Xe(a){let o=a.accumulateEnabled&&a.pairCount<a.targetPairs;return{apply:a.consented&&!o,peeking:o}}u(Xe,"resolveApply");async function rt(a,o){let t=u(n=>o?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:l}=a,e=`[cron_instruction_evolution] ${l}`,r=await P(`/api/eval-targets/${l}`),i=r.metadata??{},m=null,y=!1;if(r.name.startsWith("/")&&Ae(r.name))try{if(m=Re(r.name,"utf8"),m!==r.content){let n=await K(`/api/eval-targets/${l}/sync-content`,{content:m});y=n.synced,t(`${e}: target content drifted from disk by ${Math.abs(m.length-r.content.length)} chars \u2014 synced to disk truth (v${n.version}). Prior verdicts against the old text dissolve via content-hash keying.`),r={...r,content:m,version:n.version}}}catch(n){t(`${e}: disk sync failed (${n instanceof Error?n.message:String(n)}) \u2014 measuring the stored snapshot`)}let S=!1;try{S=(await P("/api/settings/evolution-account")).paused}catch(n){t(`${e}: could not read the account switch (${n instanceof Error?n.message:String(n)}) \u2014 pausing to be safe`),S=!0}if(S)return t(`${e}: PAUSED for the whole account (profiles.evolution_paused) \u2014 no model budget spent.`),{skipped:"paused-account"};if(ue(i))return t(`${e}: PAUSED (metadata.autoEvolvePaused) \u2014 no model budget spent. Opt-in is intact.`),{skipped:"paused"};let I=a.apply??(i.autoEvolveApply===!0||i.autoEvolveApply==="true"),C=ze(i);if(C==null){if(I)return t(`${e}: 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"};t(`${e}: metadata.immutableSections unset \u2014 measure-only cycle proceeds with [] (nothing protected). Writing still requires setting it explicitly.`),C=[]}let p=(await P(`/api/eval-targets/${l}/evals`)).filter(n=>!n.retiredAt);if(p.length===0)return{skipped:"no-live-cases"};let W=ce(i);W.note&&t(`${e}: ${W.note}`);let v=Le(p.length,W.minPairs,Ne(W,p.length));if(!v.feasible)return t(`${e}: cannot reach a sufficient verdict \u2014 ${v.reason}`),{skipped:"cannot-reach-min-n",reason:v.reason};let De=pe({liveCases:p.length,passes:v.passes});t(`${e}: budget for this run \u2014 ${me(De)}`);let U=await P(`/api/eval-targets/${l}/judge-calibration`);if(!U.powerCheck.adequate){let n=(U.powerCheck.reasons??[]).join("; ");return t(`${e}: not adequately powered, skipping before spending budget \u2014 ${n}`),{skipped:"not-adequate",reason:n}}let ne=se,Ie=Date.now()-ne*24*60*60*1e3,q=await P(`/api/eval-targets/${l}/promotions?limit=200`),re=q.promotions.filter(n=>n.applied&&Date.parse(n.createdAt)>=Ie).length;if(re>=Z)return t(`${e}: change budget looks exhausted (${re}/${Z} applied in ${ne}d), skipping before spending budget`),{skipped:"budget-exhausted"};try{let n=await P("/api/usage/current-limits"),c=$e({limits:n,now:new Date});if(!c.ok)return t(`${e}: deferring before spending budget \u2014 ${c.reason}`),{skipped:"quota-exhausted",reason:c.reason}}catch(n){t(`${e}: quota unknown (${n instanceof Error?n.message:String(n)}) \u2014 proceeding`)}let N=oe();if(!N.green)return t(`${e}: A/A canary is RED \u2014 halting. ${N.failures.join(" | ")}`),{skipped:"canary-red",reason:N.failures.join(" | ")};let G=r.content,x=M(G),d=Be(i,a),k=d.enabled?Ue(q.promotions,x,d.targetPairs):null,f,L,w=[],H=0,B=le,h=k?null:Pe(i,x);if(h){f=h.content,L="",B=0;try{w=await ve({evalTargetId:l,candidateContentHash:h.hash})}catch(n){return t(`${e}: could not rebuild banked pairs (${n instanceof Error?n.message:String(n)})`),{skipped:"resume-read-failed",reason:h.hash}}t(`${e}: resuming interrupted cycle \u2014 ${w.length}/${h.plannedPairs} pair(s) rebuilt from eval_runs, no proposal call spent`)}else if(k){let n=await P(`/api/promotions/${k.promotionId}`);if(M(n.toContent)!==k.candidateContentHash)return t(`${e}: stored candidate does not match its recorded hash \u2014 refusing to continue`),{skipped:"accumulation-hash-mismatch",reason:k.promotionId};f=n.toContent,L=n.proposalRationale??"",w=k.pairs,H=k.runs,B=0,t(`${e}: continuing accumulation ${k.promotionId} \u2014 ${w.length}/${d.targetPairs} pair(s) carried from ${H} prior run(s)`)}else{let n=U.caseDiscrimination?.cases??[],c=[];if(r.name.startsWith("/")){let s=r.name.slice(0,r.name.lastIndexOf("/"));try{let $=await P(`/api/insights/evidence?projectPath=${encodeURIComponent(s)}`);$.analyzedAt&&(c=[...$.friction.map(Y=>`Real-session friction (insights, ${$.analyzedAt.slice(0,10)}): ${Y}`),...$.whatWorks.map(Y=>`Working well in real sessions \u2014 do not break: ${Y}`)],c.length>0&&t(`${e}: proposer sees ${$.friction.length} friction + ${$.whatWorks.length} what-works item(s) from insights`))}catch($){t(`${e}: insights evidence unavailable (${$ instanceof Error?$.message:String($)}) \u2014 proposing without it`)}}let O=[];try{O=Ge(q.promotions,x)}catch(s){t(`${e}: could not summarise prior decisions (${s instanceof Error?s.message:String(s)}) \u2014 proposing without them`)}O.length>0&&t(`${e}: proposer sees ${O.length} prior decision(s) against this exact body (${O.map(s=>`${s.decision}${s.measured?"/measured":""}`).join(", ")})`);let T=await Ce({currentContent:r.content,targetType:r.type,targetName:r.name,immutableSections:C,evidence:{nonDiscriminating:n.filter(s=>!s.discriminating).map(s=>`${s.name??s.assertion??"unnamed"} \u2014 ${s.note}`),weakest:n.filter(s=>s.discriminating&&s.withPassRate<s.withoutPassRate).map(s=>({name:s.name??s.assertion??"unnamed",withPassRate:s.withPassRate,withoutPassRate:s.withoutPassRate})),priorDecisions:O,notes:c}});if(!T.ok)return t(`${e}: no usable proposal \u2014 ${T.reason}`),{skipped:"no-proposal",reason:T.reason};f=T.proposal.candidateContent,L=T.proposal.rationale}let D=h?ye({plannedPairs:h.plannedPairs||v.expectedPairs,carriedPairs:w.length,liveCases:p.length}):v.passes;t(`${e}: measuring ${p.length} case(s) x ${D} pass(es) = up to ${p.length*D} pairs, candidate vs prior version`+(h?` (resumed; ${w.length} pair(s) already banked)`:""));let A=[],X=[],He=Date.now(),ae=0,z=0;for(let n=1;n<=D;n++){let c=await be({cases:p,candidateContent:f,priorVersionContent:G,concurrency:a.concurrency??2,runNumber:n,opts:{targetId:l,targetVersion:r.version??1,iteration:1,timeout:a.timeout??24e4,model:a.model,graderModel:a.graderModel,skipGrading:!1,targetType:r.type,targetName:r.name,candidateContentHash:M(f)},onLog:t});if(A.push(...c.pairs),X.push(...c.results),ae+=c.completed,z+=c.failed,t(`${e}: pass ${n}/${D} \u2014 ${c.pairs.length} pair(s), running total ${A.length}`),c.abortedForQuota){t(`${e}: stopping after pass ${n}/${D} \u2014 ${c.abortedForQuota}. Remaining passes would spend against an exhausted account.`);break}}let R=[...w,...A],_=fe(X),Q=A.length>0,g=de({runs:X,plannedPairs:v.expectedPairs,usablePairs:A.length,verdictPairs:Q?R.length:A.length,proposalCalls:B,passes:D,liveCases:p.length,wallMs:Date.now()-He});if(t(`${e}: ${ae} completed, ${z} failed, ${A.length} usable pair(s) \u2014 spent ~${g.modelCalls} model calls (${g.proposalCalls} proposal + ${g.executorCalls} executor + >=${g.graderCalls} grader) in ${(g.wallMs/6e4).toFixed(1)} min`+(Q?`; the ${g.verdictPairs} pair(s) behind this verdict resolve +/-${ge(g.mde)} at 80% power`:"")),!Q)return{skipped:_.infrastructureFailed?"infrastructure-failure":"no-pairs",reason:_.infrastructureFailed?`${_.infrastructureFailed} run(s) never executed (${_.summary.describe()}) \u2014 the environment failed, not the target`:`${z} run(s) failed or were ungradeable`,cost:g};let V=he({pairs:R.length,minPairs:10,accounting:_});if(V.kind==="infrastructure-incomplete")return t(`${e}: not posting a verdict \u2014 ${V.reason}`),await ee({evalTargetId:l,meta:i,blob:ke({content:f,hash:M(f),priorHash:x,plannedPairs:h?.plannedPairs||v.expectedPairs,now:new Date}),log:t,tag:e}),{skipped:"infrastructure-incomplete",reason:V.reason,cost:g};d.enabled&&t(`${e}: accumulated ${R.length}/${d.targetPairs} pair(s) over ${H+1} run(s) on one candidate`);let ie=I,{apply:_e,peeking:Oe}=Xe({consented:ie,accumulateEnabled:d.enabled,pairCount:R.length,targetPairs:d.targetPairs});ie&&Oe&&t(`${e}: interim readout at ${R.length}/${d.targetPairs} pairs \u2014 recording the decision but not acting until the target is reached`);let b=await K(`/api/eval-targets/${l}/promotions`,{candidateContent:f,proposalSource:"llm",proposalRationale:L,pairs:R,canaryGreen:N.green,measuredAgainstContentHash:x,immutableSections:C,apply:_e,measurementCost:g,...d.enabled?{accumulation:{candidateContentHash:M(f),priorContentHash:x,targetPairs:d.targetPairs,carriedPairs:w.length,runs:H+1}}:{}});t(`${e}: ${b.decision}${b.applied?" (APPLIED)":""} \u2014 ${b.rationale}`+(b.refusals.length>0?` | refusals: ${b.refusals.join("; ")}`:"")),(h||i[we])&&await ee({evalTargetId:l,meta:i,blob:null,log:t,tag:e});let J=!1,E;if(b.applied&&r.name.startsWith("/"))try{Ae(r.name)?Re(r.name,"utf8")!==G?E="file changed since measurement started \u2014 refusing to clobber; next cycle re-syncs":(Me(r.name,f,"utf8"),J=!0):E="file no longer exists on disk",t(J?`${e}: measured improvement written to ${r.name} (undo: git checkout -- ${r.name})`:`${e}: NOT written to disk \u2014 ${E}`)}catch(n){E=n instanceof Error?n.message:String(n),t(`${e}: disk write-back failed \u2014 ${E}. The eval target is updated; the file is not.`)}return{decision:b.decision,applied:b.applied,nPairs:R.length,promotionId:b.id,cost:g,diskSynced:y,...b.applied?{fileWritten:J,...E?{fileWriteSkipped:E}:{}}:{},...d.enabled?{carriedPairs:w.length,accumulationRuns:H+1}:{}}}u(rt,"cronInstructionEvolution");function ze(a){let o=a.immutableSections;return o==null||!Array.isArray(o)?null:o.filter(t=>typeof t=="string")}u(ze,"readImmutableSections");export{xe as a,te as b,We as c,Ne as d,Le as e,Fe as f,Ue as g,qe as h,Ge as i,Be as j,Xe as k,rt as l,ze as m};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as S,b as _}from"./chunk-CDY7TQFZ.js";import{c as w}from"./chunk-XRTZU7IZ.js";import{
|
|
1
|
+
import{a as S,b as _}from"./chunk-CDY7TQFZ.js";import{c as w}from"./chunk-XRTZU7IZ.js";import{d as A}from"./chunk-TZA4HAVF.js";import{a as u}from"./chunk-ZLLER3HP.js";var E=`You are a rigorous eval grader. Your job is to evaluate whether an AI assistant's output meets a set of expectations.
|
|
2
2
|
|
|
3
3
|
You will receive:
|
|
4
4
|
1. The original prompt that was given to the AI
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as c,f as d}from"./chunk-QAV4HW7D.js";import{a as m}from"./chunk-ZLLER3HP.js";async function f(g,p){let r=m(e=>p?.logger?.info?.(e)??console.log(e),"log"),{projectPath:s}=g,i=`[cron_instruction_training] ${s}`;if(!s)return{skipped:"no-project-path"};let n=await d("/api/instruction-experiments/settle",{projectPath:s}),o=n.settled.map(e=>e.outcome),a=o.filter(e=>e==="graduated").length;for(let e of n.settled)r(`${i}: experiment ${e.experimentId} \u2192 ${e.outcome}`);n.examined>0&&r(`${i}: examined ${n.examined} running experiment(s) \u2014 ${n.settled.length} settled (${a} graduated), ${n.stillRunning} still gathering`);let t=await c(`/api/instruction-suggestions/trialable?projectPath=${encodeURIComponent(s)}`);for(let e of t.refused)r(`${i}: not trialling "${e.name}" \u2014 ${e.reason}`);if(t.candidates.length===0)return r(`${i}: no new trial started (${t.running}/${t.limits.maxConcurrent} running, ${t.slots} slot(s) free)`),{examined:n.examined,settled:n.settled.length,graduated:a,nominated:0,running:t.running,outcomes:o};let u=0;for(let e of t.candidates)try{await d("/api/instruction-experiments",{instructionId:e.instructionId,projectPath:s,source:"trial"}),u+=1,r(`${i}: now measuring "${e.name}" (score ${e.score.toFixed(2)})`)}catch(l){r(`${i}: could not measure "${e.name}" \u2014 ${l instanceof Error?l.message:String(l)}`)}return{examined:n.examined,settled:n.settled.length,graduated:a,nominated:u,running:t.running+u,outcomes:o}}m(f,"cronInstructionTraining");export{f as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"./chunk-ZLLER3HP.js";var c=[{kind:"usage_credits",test:/out of (?:usage )?credits|\/usage-credits|out of extra usage/i},{kind:"rate_limit",test:/rate[_ ]limit|\b429\b|exceed your account's rate limit/i},{kind:"timeout",test:/timed out after/i},{kind:"spawn",test:/failed to spawn/i}];function d(t){let i=t??"";for(let n of c)if(n.test.test(i))return{kind:n.kind,class:"infrastructure"};return{kind:"unknown",class:"infrastructure"}}s(d,"classifyEvalFailure");function f(t){let i={},n=0,u=0;for(let e of t)e.class==="infrastructure"?n+=1:u+=1,i[e.kind]=(i[e.kind]??0)+1;let o=null,l=0;for(let e of t){if(e.class!=="infrastructure")continue;let r=i[e.kind]??0;r>l&&(l=r,o=e.kind)}return{infrastructure:n,measurement:u,byKind:i,dominantKind:o,describe(){return Object.entries(i).sort((r,a)=>a[1]-r[1]).map(([r,a])=>`${a} ${r}`).join(", ")}}}s(f,"summarizeFailures");function m(t){return t==="rate_limit"||t==="usage_credits"}s(m,"isQuotaExhaustion");export{d as a,f as b,m as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as c,c as d}from"./chunk-IZTIYR5Q.js";import{
|
|
1
|
+
import{a as c,c as d}from"./chunk-IZTIYR5Q.js";import{d as u}from"./chunk-UUZB4IKU.js";import{a}from"./chunk-EQHKCGSX.js";import{a as n}from"./chunk-VA5DPQB4.js";import{b as i}from"./chunk-QAV4HW7D.js";import{g as r}from"./chunk-JZ5Z2BRO.js";import{a as s}from"./chunk-ZLLER3HP.js";import{Command as f,Flags as h}from"@oclif/core";function p(t){return t instanceof i?t.statusCode>=500||t.statusCode===408||t.statusCode===0:/fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|bad gateway|timed out/i.test(t.message??"")}s(p,"isAvailabilityError");var m=class extends f{static{s(this,"BaseCommand")}static baseFlags={"api-url":h.string({description:"Override API base URL",env:"RULEMETRIC_API_URL",hidden:!0})};async init(){await super.init();let{flags:e}=await this.parse(this.constructor);e["api-url"]&&(process.env.RULEMETRIC_API_URL=e["api-url"]);let o=d(this.config.version);o&&!this.argv.includes("--quiet")&&!process.env.RULEMETRIC_QUIET&&process.stderr.write(`
|
|
2
2
|
${o}
|
|
3
3
|
|
|
4
4
|
`),c();try{await a()}catch{}}requireAuth(){r()||this.error("Not logged in. Run `rulemetric auth login` to authenticate."),n()}async catch(e){throw p(e)&&await u({command:this.id,statusCode:e instanceof i?e.statusCode:void 0,message:e.message,cliVersion:this.config.version}),e instanceof i&&(e.statusCode===401&&this.error("Session expired. Run `rulemetric auth login` to re-authenticate."),this.error(e.message)),(e.message?.includes("fetch failed")||e.message?.includes("ECONNREFUSED"))&&this.error("Could not connect to the API server. Is it running?"),e}};export{m as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T}from"./chunk-5RBLIVBF.js";import{a as S}from"./chunk-
|
|
1
|
+
import{a as T}from"./chunk-5RBLIVBF.js";import{a as S}from"./chunk-XFAFMYIP.js";import{b as A}from"./chunk-CNOD6HWU.js";import{e as x}from"./chunk-L2CFSMBC.js";import{a as C}from"./chunk-JPUH3V67.js";import{d as M}from"./chunk-TZA4HAVF.js";import{e as k,f as E,h as p}from"./chunk-QAV4HW7D.js";import{a as w}from"./chunk-ZLLER3HP.js";async function W(v,f){let{mirrorId:i,evalTargetId:g,config:o}=v,a=w(e=>f.logger.info(e),"log"),s=await k(`/api/eval-targets/${g}`),$=await k(`/api/eval-targets/${g}/evals`);if($.length===0&&o.generateIfEmpty){a("No eval cases on target \u2014 generating from content via local LLM...");let e=await A({content:s.content,name:s.name});if(e===null)throw new Error("Case generation requires an LLM backend (claude CLI on PATH or ANTHROPIC_API_KEY) \u2014 none available on this worker.");let n=[];for(let t of e)n.push(await E(`/api/eval-targets/${g}/evals`,t));$=n,a(`Generated ${n.length} eval case(s)`)}if($.length===0)throw new T("No evals defined for target");let G=o.runsPerEval??1,R=o.timeout??12e4,j=o.iteration??1,y=new Set;if(f.job.attempts>1)for(let n=0;;n+=100){let t=await k(`/api/eval-targets/${g}/runs?jobId=${i}&limit=100&offset=${n}`);for(let r of t)y.add(`${r.evalId}|${r.configuration}|${r.runNumber}|${r.iteration}`);if(t.length<100)break}let _=[{name:"with_target",content:s.content}];o.skipBaseline||_.push({name:"without_target"});let d=[];for(let e of $)for(let n of _)for(let t=1;t<=G;t++)y.has(`${e.id}|${n.name}|${t}|${j}`)||d.push({eval_:e,configuration:n.name,targetContent:n.content,runNumber:t});y.size>0&&a(`Resuming attempt ${f.job.attempts}: ${y.size} run(s) already persisted, ${d.length} remaining`);let l=d.length,u=0,m=Math.min(o.parallel??1,4);await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:0,current:null,message:`Starting ${l} eval runs (concurrency: ${m})...`}});let b=[];async function I(e){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`;a(`[${u+1}/${l}] ${n}`);let t=x({targetType:s.type,targetContent:e.targetContent,targetName:s.name});t.leakedFiles.length&&a(`\u26A0 CONTAMINATED ${n}: ${t.leakedFiles.join(", ")} survived the strip`);try{let r=await M({prompt:e.eval_.prompt,targetContent:t.systemPrompt,workDir:t.workDir,timeout:R,model:o.model}),c={};return!o.skipGrading&&e.eval_.expectations.length>0&&!r.error&&(c=await C({prompt:e.eval_.prompt,output:r.output,expectations:e.eval_.expectations,model:o.graderModel??o.model,timeout:R})),{jobId:i,evalId:e.eval_.id,evalTargetId:s.id,evalTargetVersion:s.version,configuration:e.configuration,runNumber:e.runNumber,iteration:j,status:r.error?"failed":"completed",outputs:{...r.error?{error:r.error}:{transcript:r.output,...r.model?{model:r.model}:{}},methodology:t.methodology,delivery:t.delivery,isolated:t.isWorktree,...t.leakedFiles.length?{leakedFiles:t.leakedFiles}:{}},timing:{duration_ms:r.durationMs,total_tokens:r.totalTokens},grading:c,worktree:t.isWorktree?!0:void 0}}finally{t.cleanup()}}if(w(I,"processItem"),m<=1)for(let e of d){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Executing ${n}...`}});let t=await I(e);await E("/api/eval-runs",t),b.push(t),u++,await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Completed ${n}`}})}else{a(`Running ${l} evals with concurrency=${m} (worktree isolation)`);for(let e=0;e<d.length;e+=m){let n=d.slice(e,e+m),t=`batch ${Math.floor(e/m)+1}/${Math.ceil(d.length/m)}`;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:t,message:`Executing ${t} (${n.length} parallel)...`}});let r=await Promise.all(n.map(I));for(let c of r)await E("/api/eval-runs",c),b.push(c),u++;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:t,message:`Completed ${t}`}})}}let P=J(b),h;if(!o.skipGrading&&b.some(e=>e.grading&&Object.keys(e.grading).length>0))try{a(`Running meta-judge for job ${i}...`);let e=$.map(n=>{let r=b.filter(c=>c.evalId===n.id&&c.configuration==="with_target")[0];return{evalName:n.name,prompt:n.prompt,expectations:n.expectations,grading:r?.grading?r.grading:null,output:r?.outputs?.transcript?.slice(0,500)}});h=await S({targetName:s.name,evalResults:e,model:o.graderModel??o.model,timeout:6e4}),a(`Meta-judge: quality=${h.quality_score}/5, issues=${h.issues.length}`)}catch(e){a(`Meta-judge failed (non-fatal): ${e instanceof Error?e.message:String(e)}`)}let N=h?{...P,meta_judgement:h}:P;return a(`Job ${i} completed: ${u}/${l} runs`),await p(`/api/eval-jobs/${i}/state`,{result:N}).catch(e=>{a(`result persist failed: ${e instanceof Error?e.message:String(e)}`)}),N}w(W,"processEval");function J(v){let f=v.filter(a=>a.status==="completed"),i=v.filter(a=>a.status==="failed"),g=f.filter(a=>{let s=a.grading;return s&&Object.keys(s).length>0}),o=g.length>0?g.reduce((a,s)=>a+(s.grading?.summary?.pass_rate??0),0)/g.length:null;return{total:v.length,completed:f.length,failed:i.length,avgPassRate:o}}w(J,"buildSummary");export{W as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as p}from"./chunk-TZA4HAVF.js";import{a as l}from"./chunk-ZLLER3HP.js";var k=[{name:"git-commit-helper",description:"Writes conventional commit messages and PR descriptions from a diff"},{name:"sql-query-optimizer",description:"Analyzes slow SQL queries and proposes indexes and rewrites"},{name:"i18n-string-extractor",description:"Finds hardcoded UI strings and extracts them into translation files"}],T=`You are an AI coding assistant with access to a set of optional skills. When a user request matches a skill's description, you invoke that skill before answering; when no skill applies, you answer directly without one. Descriptions are your ONLY information about each skill.
|
|
2
2
|
|
|
3
3
|
{{CATALOG}}
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as g,c as m}from"./chunk-N7ODX6PO.js";import{e as s,h as c}from"./chunk-
|
|
1
|
+
import{b as g,c as m}from"./chunk-N7ODX6PO.js";import{e as s,h as c}from"./chunk-QAV4HW7D.js";import{a as i}from"./chunk-ZLLER3HP.js";var u=6e4;function o(t,e){try{t(JSON.stringify({ts:new Date().toISOString(),...e}))}catch{t(`[tt-heartbeat] log_error event=${e.event}`)}}i(o,"structuredLog");function d(t,e){return e.aborted?Promise.resolve(!1):t<=0?Promise.resolve(!0):new Promise(r=>{let a=setTimeout(()=>{e.removeEventListener("abort",n),r(!0)},t),n=i(()=>{clearTimeout(a),e.removeEventListener("abort",n),r(!1)},"onAbort");e.addEventListener("abort",n,{once:!0})})}i(d,"abortableSleep");async function l(t,e){if(t.kind!=="tmux")return;let a=(await g(m(t.target))).code===0?"active":"missing";try{await c(`/api/terminal-targets/${t.id}/status`,{status:a,lastSeenAt:new Date().toISOString()}),o(e,{event:"tt_heartbeat",targetId:t.id,target:t.target,status:a})}catch(n){o(e,{event:"tt_heartbeat_error",targetId:t.id,target:t.target,error:n instanceof Error?n.message:String(n)})}}i(l,"probeAndReport");async function b(t){let e;try{e=await s("/api/terminal-targets?status=active")}catch(r){o(t,{event:"tt_heartbeat_list_error",error:r instanceof Error?r.message:String(r)});return}for(let r of e.targets??[])try{await l(r,t)}catch(a){o(t,{event:"tt_heartbeat_probe_error",targetId:r.id,error:a instanceof Error?a.message:String(a)})}}i(b,"runOneHeartbeatCycle");async function p(t){let e=t.log??(()=>{}),r=t.intervalMs??u;for(o(e,{event:"tt_heartbeat_start",intervalMs:r});!t.signal.aborted&&(await b(e),!!await d(r,t.signal)););o(e,{event:"tt_heartbeat_stop"})}i(p,"startTerminalTargetHeartbeat");export{l as a,b,p as c};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{e as m,f as l,i as p}from"./chunk-QAV4HW7D.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as s from"node:fs";import*as g from"node:path";function y(e,t,n){let i=g.join(e,"CLAUDE.md"),r=`<!-- rulemetric:start ${t} -->`,a=`<!-- rulemetric:end ${t} -->`,o=s.existsSync(i)?s.readFileSync(i,"utf8"):"";if(o.includes(r))return!1;let u=`${o.length>0&&!o.endsWith(`
|
|
2
|
+
`)?`
|
|
3
|
+
|
|
4
|
+
`:o.length>0?`
|
|
5
|
+
`:""}
|
|
6
|
+
${r}
|
|
7
|
+
${n}
|
|
8
|
+
${a}
|
|
9
|
+
`;return s.writeFileSync(i,o+u,"utf8"),!0}c(y,"appendToCLAUDEmd");function A(e,t){let n=g.join(e,"CLAUDE.md");if(!s.existsSync(n))return!1;let i=`<!-- rulemetric:start ${t} -->`,r=`<!-- rulemetric:end ${t} -->`,a=s.readFileSync(n,"utf8"),o=a.indexOf(i);if(o===-1)return!1;let d=a.indexOf(r,o);if(d===-1)return!1;let u=a.slice(0,o),h=a.slice(d+r.length),I=(u.replace(/\n+$/,"")+`
|
|
10
|
+
`+h.replace(/^\n+/,"")).replace(/^\n+/,"");return s.writeFileSync(n,I,"utf8"),!0}c(A,"removeFromCLAUDEmd");function $(e){return m(`/api/instruction-suggestions/${encodeURIComponent(e)}`)}c($,"fetchSuggestion");async function f(e,t,n,i){await l(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:"accepted",projectPath:t,instructionId:n,actor:i})}c(f,"logAccepted");async function b(e){let t=e.suggestion??await $(e.suggestionId);if(t.kind==="remove")return x(e,t);if(t.kind==="trim")return w(e,t);let n=t.instructionId;t.instructionScope==="public"&&(n=(await l(`/api/instructions/${encodeURIComponent(t.instructionId)}/promote-from-public`,{targetScope:"personal"})).instructionId);let i=await m(`/api/instructions/${encodeURIComponent(n)}`),r=y(e.dir,n,i.content);return await f(e.suggestionId,e.projectPath,n,e.actor),{action:r?"added":"already-present",instructionId:n,name:i.name,fileModified:r,messages:r?[`Accepted: added ${i.name} to CLAUDE.md. It will be active starting in your next session.`]:[`Already present: ${i.name} is already in CLAUDE.md (block id: ${n}).`]}}c(b,"acceptSuggestion");async function w(e,t){let n=t.estimatedTokens?` It currently costs roughly ${t.estimatedTokens} tokens per session (estimated).`:"";return await f(e.suggestionId,e.projectPath,t.instructionId,e.actor),{action:"acknowledged",instructionId:t.instructionId,name:t.name,fileModified:!1,messages:[`Noted: ${t.name} is measured neutral, not harmful.${n}`,"Nothing was changed \u2014 trimming is a judgement call about which parts carry the value,","and the measurement only found the absence of a detectable effect, not which half to cut.",` View it: rulemetric instructions get ${t.instructionId}`," Then edit CLAUDE.md (or the instruction) and let the next measurement cycle re-check it.","This suggestion will stop re-surfacing."]}}c(w,"acknowledgeTrim");async function x(e,t){let n=A(e.dir,t.instructionId);await p(`/api/instructions/${encodeURIComponent(t.instructionId)}`);let i=t.estimatedTokens?` Frees roughly ${t.estimatedTokens} tokens of context per session (estimated).`:"",r=n?[`Retired: removed ${t.name} from CLAUDE.md and archived it.${i}`]:[`Archived ${t.name}.${i}`,"CLAUDE.md was not modified \u2014 no rulemetric-managed block for this instruction was found in this directory. If you added it by hand, remove it yourself."];return r.push("Undo with: rulemetric instructions restore "+t.instructionId),await f(e.suggestionId,e.projectPath,t.instructionId,e.actor),{action:n?"retired":"archived-only",instructionId:t.instructionId,name:t.name,fileModified:n,messages:r}}c(x,"acceptRemoval");export{y as a,A as b,$ as c,b as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as k}from"./chunk-L2CFSMBC.js";import{a as f}from"./chunk-KGURGIZ2.js";import{a as $}from"./chunk-JPUH3V67.js";import{d as v}from"./chunk-TZA4HAVF.js";import{f as p}from"./chunk-QAV4HW7D.js";import{a as c}from"./chunk-ZLLER3HP.js";async function x(m,t,s=()=>{}){let{eval_:r,configuration:i,targetContent:g,runNumber:o}=m;s(`[${i}] ${r.name} run#${o} \u2014 executing...`);let a=k({targetType:t.targetType,targetContent:g,targetName:t.targetName}),d={methodology:a.methodology,delivery:a.delivery,isolated:a.isWorktree,...t.candidateContentHash?{candidateContentHash:t.candidateContentHash}:{},...a.leakedFiles.length?{leakedFiles:a.leakedFiles}:{}};a.isWorktree||s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 no git worktree; running without repo context`),a.leakedFiles.length&&s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 CONTAMINATED: ${a.leakedFiles.join(", ")} survived the strip`);try{let n=await v({prompt:r.prompt,targetContent:a.systemPrompt,workDir:a.workDir,timeout:t.timeout,model:t.model});if(n.error){let e=f(n.error);return s(`[${i}] ${r.name} run#${o} \u2014 FAILED (${e.kind}): ${n.error}`),{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"failed",outputs:{error:n.error,failureKind:e.kind,failureClass:e.class,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens},grading:{},failure:e}}s(`[${i}] ${r.name} run#${o} \u2014 completed in ${(n.durationMs/1e3).toFixed(1)}s`);let u={};if(!t.skipGrading&&r.expectations.length>0){s(`[${i}] ${r.name} run#${o} \u2014 grading...`);let e=await $({prompt:r.prompt,output:n.output,expectations:r.expectations,model:t.graderModel??t.model,timeout:t.timeout});u=e,s(`[${i}] ${r.name} run#${o} \u2014 grading done: pass_rate=${e.summary.pass_rate==null?"n/a (all assertions errored)":`${(e.summary.pass_rate*100).toFixed(0)}%`}`)}return{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"completed",outputs:{transcript:n.output,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens,total_duration_seconds:n.durationMs/1e3},grading:u}}finally{a.cleanup()}}c(x,"executeAndGradeCase");async function R(m){let{cases:t,targetContent:s,concurrency:r,runNumber:i,opts:g,skipBaseline:o,onLog:a=c(()=>{},"onLog")}=m,d=o?["with_target"]:["with_target","without_target"],n=[];for(let e of t)for(let l of d)n.push({eval_:e,configuration:l,targetContent:l==="with_target"?s:void 0,runNumber:i});let u=[];for(let e=0;e<n.length;e+=Math.max(1,r)){let l=n.slice(e,e+Math.max(1,r)),h=await Promise.all(l.map(b=>x(b,g,a)));u.push(...h)}for(let e of u)try{await p("/api/eval-runs",e)}catch(l){a(` \u26A0 failed to post a run result: ${l instanceof Error?l.message:String(l)}`)}try{await p(`/api/eval-targets/${g.targetId}/label-state`,{})}catch(e){a(` \u26A0 label-state notification skipped: ${e instanceof Error?e.message:String(e)}`)}return{completed:u.filter(e=>e.status==="completed").length,failed:u.filter(e=>e.status==="failed").length,results:u}}c(R,"runBatchAndPost");export{x as a,R as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,f as a}from"./chunk-
|
|
1
|
+
import{b as o,f as a}from"./chunk-QAV4HW7D.js";import{a as n}from"./chunk-ZLLER3HP.js";function c(e){return e==null?e??null:e instanceof Date?e.toISOString():e}n(c,"serializeDate");async function d(e){let r={provider:e.provider,plan:e.plan,limitType:e.limitType,value:e.value,unit:e.unit,comparator:e.comparator,resetsAt:c(e.resetsAt),sourceType:e.sourceType,sourceUrl:e.sourceUrl,sourceEvidence:e.sourceEvidence,confidence:e.confidence,observedAt:c(e.observedAt)};return a("/api/internal/research/observe",r)}n(d,"postObservation");async function f(e){let r=0,i=0,s=[];for(let u of e)try{await d(u),r++}catch(t){i++;let p=t instanceof o?`HTTP ${t.statusCode}: ${t.message}`:String(t);s.length<5&&s.push(p)}return{posted:r,failed:i,errors:s}}n(f,"postObservations");export{d as a,f as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-QAV4HW7D.js";import{a as e}from"./chunk-ZLLER3HP.js";function i(){return process.env.RULEMETRIC_API_URL??a}e(i,"apiUrl");function u(){let n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)throw new Error("not signed in \u2014 run `rulemetric auth login`");return n}e(u,"authToken");async function t(n,o){let r=await fetch(`${i()}${n}`,{...o,headers:{Authorization:`Bearer ${u()}`,"Content-Type":"application/json",...o?.headers??{}},signal:AbortSignal.timeout(1e4)});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return await r.json()}e(t,"request");function c({limit:n}){return t(`/api/launch-jobs?limit=${n}`)}e(c,"fetchLaunchJobs");function h(n){return t("/api/launch-jobs",{method:"POST",body:JSON.stringify(n)})}e(h,"createLaunchJob");function l(n){return t(`/api/launch-jobs/${n}/cancel`,{method:"POST"})}e(l,"cancelLaunchJob");function p(){return t("/api/launchers")}e(p,"listLaunchers");export{c as a,h as b,l as c,p as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as E}from"./chunk-3PUOJ6F2.js";import{a as p,e as w}from"./chunk-JZ5Z2BRO.js";import{a as o}from"./chunk-ZLLER3HP.js";import{fileURLToPath as v}from"node:url";import{existsSync as A,readFileSync as b}from"node:fs";import{dirname as L,join as x}from"node:path";function C(){let t=L(v(import.meta.url));for(let e=0;e<8;e++){let s=x(t,"package.json");if(A(s))try{let i=JSON.parse(b(s,"utf8"));if(i.name==="@rulemetric/cli"&&i.version)return i.version}catch{}let n=L(t);if(n===t)break;t=n}return"0.0.0"}o(C,"readCliVersion");var O=C(),I="https://rulemetric.com",l=class extends Error{constructor(s,n){super(n);this.statusCode=s;this.name="ApiError"}static{o(this,"ApiError")}};function S(){let t=p(),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=I}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}o(S,"getBaseUrl");async function a(t,e={}){let n=`${S()}${t}`,i={"Content-Type":"application/json","User-Agent":`rulemetric-cli/${O}`,...e.headers},m=p(),d=process.env.RULEMETRIC_API_KEY||m.apiKey||w()?.accessToken||m.accessToken;d&&(i.Authorization=`Bearer ${d}`);let h=new URL(n),f=h.hostname==="localhost"||h.hostname==="127.0.0.1",P=process.env.HTTPS_PROXY,R=process.env.HTTP_PROXY;f&&(delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY);let u=e.timeoutMs?new AbortController:void 0,g=!1,y=u?setTimeout(()=>{g=!0,u.abort()},e.timeoutMs):void 0,r;try{r=await fetch(n,{method:e.method??"GET",headers:i,body:e.body?JSON.stringify(e.body):void 0,signal:u?.signal})}catch(T){if(g){let U=new URL(n).host,_=Math.round(e.timeoutMs/1e3);throw new l(408,`Request to ${U} timed out after ${_}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 T}finally{y&&clearTimeout(y),f&&(P!==void 0&&(process.env.HTTPS_PROXY=P),R!==void 0&&(process.env.HTTP_PROXY=R))}let c;if(r.headers.get("content-type")?.includes("application/json")?c=await r.json():c=await r.text(),!r.ok){let{message:T}=E(r.status,c);throw new l(r.status,T)}return c}o(a,"api");var j=o(t=>a(t),"apiGet"),F=o((t,e)=>a(t,{method:"POST",body:e}),"apiPost"),B=o((t,e)=>a(t,{method:"PUT",body:e}),"apiPut"),D=o((t,e)=>a(t,{method:"PATCH",body:e}),"apiPatch"),G=o(t=>a(t,{method:"DELETE"}),"apiDelete");export{I as a,l as b,S as c,a as d,j as e,F as f,B as g,D as h,G as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as E}from"./chunk-B3BHB26P.js";import{b,e as y,f as k,h as M}from"./chunk-
|
|
1
|
+
import{f as E}from"./chunk-B3BHB26P.js";import{b,e as y,f as k,h as M}from"./chunk-QAV4HW7D.js";import{a as u}from"./chunk-ZLLER3HP.js";var v=50,I=24e3,P=3,R=3,C=40,N=4e3,x=new Set(["fact","decision","correction","convention"]),L=`You are distilling DURABLE, PROJECT-SPECIFIC knowledge from an AI coding session so a future agent working on the SAME project starts smarter.
|
|
2
2
|
|
|
3
3
|
Extract ONLY facts / decisions / corrections / conventions that will STILL be true and useful in FUTURE sessions \u2014 architecture facts, deliberate design decisions, corrections of a wrong approach, or project conventions.
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as g}from"./chunk-MMPZIZYZ.js";import{e as p}from"./chunk-QAV4HW7D.js";import{a as d}from"./chunk-ZLLER3HP.js";import{existsSync as f,statSync as $}from"node:fs";async function A(l,m){let n=d(t=>m?.logger?.info?.(t)??console.log(t),"log"),{projectPath:s}=l,o=`[cron_auto_accept_suggestions] ${s}`;if(!s)return{skipped:"no-project-path"};if(!f(s)||!$(s).isDirectory())return n(`${o}: project directory no longer exists on this machine \u2014 skipping`),{skipped:"project-path-missing"};let e=await p(`/api/instruction-suggestions/auto-acceptable?projectPath=${encodeURIComponent(s)}`);if(!e.consent.allowed)return n(`${o}: ${e.consent.reason??"no consent"} (${e.consent.source})`),{skipped:"no-consent",reason:e.consent.reason};for(let t of e.refused)n(`${o}: refused "${t.name}" \u2014 ${t.reason}`);if(e.eligible.length===0)return n(`${o}: nothing to adopt`+(e.budget?` (${e.budget.used}/${e.budget.max} used in ${e.budget.windowDays}d)`:"")),{skipped:"nothing-eligible",refused:e.refused.length,adopted:0};let i=0,a=0,c=0,u=[];for(let t of e.eligible)try{let r=await g({suggestionId:t.id,dir:s,projectPath:s,actor:"auto"});r.action==="added"?(i+=1,u.push(r.name),n(`${o}: adopted "${r.name}" (score ${t.score.toFixed(2)})`)):(a+=1,n(`${o}: "${r.name}" was already in CLAUDE.md`))}catch(r){c+=1,n(`${o}: failed to adopt "${t.name}" \u2014 ${r instanceof Error?r.message:String(r)}`)}return n(`${o}: ${i} adopted, ${a} already present, ${c} failed, ${e.refused.length} refused. Undo any of them with \`rulemetric suggestions undo <instruction-id>\`.`),{adopted:i,alreadyPresent:a,failed:c,refused:e.refused.length,names:u}}d(A,"cronAutoAcceptSuggestions");export{A as a};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{f as g,g as f,h as p,i as m,j as k}from"./chunk-3PUOJ6F2.js";import{a as o}from"./chunk-ZLLER3HP.js";import{existsSync as d,readFileSync as u,writeFileSync as _,copyFileSync as v,rmSync as S,statSync as P,readdirSync as x,mkdirSync as R}from"node:fs";import{join as i,dirname as $}from"node:path";import{homedir as c}from"node:os";var j=["/plugins/cache/","/plugins/marketplaces/","/node_modules/","/.git/"];function h(e){return j.some(t=>e.includes(t))}o(h,"isUnownedPath");function K(e,t){let n=i(c(),".config","rulemetric","retraction-backups",t),r=e.replace(/^\/+/,"").replace(/\//g,"__");return i(n,r)}o(K,"backupPathFor");function y(e){return e.split(`
|
|
2
|
+
`).slice(0,40).map(t=>`- ${t}`).join(`
|
|
3
|
+
`)}o(y,"shortDiff");function a(e,t,n){return{kind:e,path:t,ok:!1,refusal:n,preview:"",warnings:[]}}o(a,"refuse");function M(e){let[t,...n]=e.split("::"),r=n.join("::");if(!r)return null;switch(t){case"claude_md":return{kind:"claude_md_section",target:r};case"memory":return{kind:"memory_section",target:r};case"skill":return{kind:"skill_file",target:r};default:return null}}o(M,"pathFromContextIdentity");function F(e,t){let n=e.replace(/^skills--/,"");return[...[i(t,".claude","skills",n,"SKILL.md"),i(t,".claude","skills",`${n}.md`),i(c(),".claude","skills",n,"SKILL.md"),i(c(),".claude","skills",`${n}.md`)],...I(n)]}o(F,"candidateSkillPaths");function I(e){let t=i(c(),".claude","plugins","marketplaces");if(!d(t))return[];let n=[];try{for(let r of x(t))n.push(i(t,r,"skills",e,"SKILL.md"),i(t,r,"plugins",e,"SKILL.md"),i(t,r,"skills",`${e}.md`))}catch{}return n}o(I,"pluginSkillPaths");function O(e){switch(e.kind){case"claude_md_section":case"memory_section":case"claude_md_block":return C(e);case"skill_file":return D(e);case"settings_hook":case"mcp_server":return L(e)}}o(O,"planRetraction");function C(e){let t=e.target;if(!d(t))return a(e.kind,t,`File does not exist: ${t}`);if(h(t))return a(e.kind,t,`Refusing to edit a path this tool does not own: ${t}`);let n=u(t,"utf-8"),r=e.body?f(n,e.body):g(n,e.heading??"");if(!r.removed){let l={"not-found":"The content is not present in this file (already removed, or edited since).",ambiguous:"The content appears more than once \u2014 refusing to guess which copy the verdict was about.","would-empty-file":"Removing it would empty the file. Delete the file by hand if that is really the intent."}[r.reason??"not-found"];return a(e.kind,t,l)}let s=[];return w(t,e.cwd)||s.push("This file is not tracked by git in this repo \u2014 the timestamped backup is your only undo."),{kind:e.kind,path:t,ok:!0,preview:y(r.removedText??""),nextContent:r.content,warnings:s}}o(C,"planFileEdit");function D(e){let t=e.target.startsWith("/")?[e.target]:F(e.target,e.cwd),n=t.find(l=>d(l));if(!n)return a("skill_file",t[0]??e.target,`No local skill file found for "${e.target}". Searched:
|
|
4
|
+
${t.join(`
|
|
5
|
+
`)}`);if(h(n))return a("skill_file",n,`"${e.target}" is installed by a plugin (${n}).
|
|
6
|
+
Deleting it would be undone by the next plugin update, and the files are not ours to remove.
|
|
7
|
+
Uninstall the plugin that provides it instead.`);let r=u(n,"utf-8"),s=[];return w(n,e.cwd)||s.push("Not tracked by git \u2014 the timestamped backup is your only undo."),{kind:"skill_file",path:n,ok:!0,deletesFile:!0,preview:y(r.split(`
|
|
8
|
+
`).slice(0,20).join(`
|
|
9
|
+
`)),warnings:s}}o(D,"planSkillDelete");function L(e){let t=e.kind==="mcp_server"?[i(e.cwd,".mcp.json"),i(e.cwd,".claude","settings.json"),i(c(),".claude","settings.json")]:[i(e.cwd,".claude","settings.json"),i(c(),".claude","settings.json"),i(e.cwd,".claude","settings.local.json")];for(let n of t){if(!d(n))continue;let r;try{r=JSON.parse(u(n,"utf-8"))}catch{continue}let s=e.kind==="mcp_server"?m(r,e.target):p(r,e.target);if(!s.removed)continue;let l=k(r,s.value);return l.length>0?a(e.kind,n,`Refusing: this rewrite would drop ${l.join(", ")} from ${n}. A settings file missing these breaks Claude Code entirely.`):{kind:e.kind,path:n,ok:!0,preview:s.removedDescriptions.map(b=>`- ${b}`).join(`
|
|
10
|
+
`),nextContent:`${JSON.stringify(s.value,null,2)}
|
|
11
|
+
`,warnings:n.endsWith("settings.local.json")?["Editing settings.local.json \u2014 this file also carries the proxy env block."]:[]}}return a(e.kind,t[0],`"${e.target}" was not found in any settings file. Searched:
|
|
12
|
+
${t.join(`
|
|
13
|
+
`)}`)}o(L,"planSettingsEdit");function w(e,t){try{let n=i(t,".git");return e.startsWith(t)&&d(n)&&P(n).isDirectory()}catch{return!1}}o(w,"isGitTracked");function U(e,t){if(!e.ok)return{applied:!1,backupPath:null,error:e.refusal??"plan is not applicable"};let n=K(e.path,t);try{R($(n),{recursive:!0}),v(e.path,n)}catch(r){return{applied:!1,backupPath:null,error:`backup failed, nothing written: ${String(r)}`}}try{return e.deletesFile?S(e.path,{force:!0}):_(e.path,e.nextContent??""),{applied:!0,backupPath:n}}catch(r){return{applied:!1,backupPath:n,error:`write failed: ${String(r)}`}}}o(U,"applyRetraction");export{K as a,M as b,F as c,O as d,U as e};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{g as d}from"./chunk-B3BHB26P.js";import{a as s}from"./chunk-ZLLER3HP.js";var c="<<<FILE-CONTENT-BEGIN>>>",p="<<<FILE-CONTENT-END>>>",E="<RATIONALE>",T="</RATIONALE>",l="<PROPOSED_INSTRUCTION>",h="</PROPOSED_INSTRUCTION>",f=.5,m=3;function b(e){let t=e.immutableSections.length>0?e.immutableSections.map(n=>` - ${n}`).join(`
|
|
2
|
+
`):" (none)",i=e.evidence.priorDecisions.length>0?["6. You have edited this file before. The attempts are listed below with"," how each was judged. Do not re-propose an edit that was MEASURED and"," rejected: it was replayed against this exact file and did not beat it,"," so measuring it again spends the same budget for the same answer. An"," attempt marked NOT MEASURED is different \u2014 the gate stopped it before"," it earned a verdict, so whether it would have helped is still unknown."]:[];return["You are improving an AI coding assistant instruction file so that it scores","better on a fixed set of evaluation cases.","",`The file is a ${e.targetType} named "${e.targetName}".`,"","RULES",`0. The current file is EXACTLY the text between ${c} and`,` ${p} in the data message. Headings after the closing`," sentinel (underperforming cases, notes, prior attempts) are evidence",' ABOUT the file \u2014 they are not in the file, and "removing" one of them'," is not an edit. Do not include the sentinels in your output.","1. Return the COMPLETE new file, not a diff, not a patch, not a summary,"," and not an excerpt. Everything you omit will be DELETED from the file.","2. Preserve everything you are not deliberately changing, byte for byte.","3. Make a focused edit. You are one step in a measured loop: a small change"," that can be attributed beats a rewrite that cannot.","4. Do not edit these sections or anything nested under them \u2014 an edit that"," touches them is refused downstream and the whole proposal is wasted:",t,"5. Do not add meta-commentary about the evaluation, the loop, or this"," prompt to the file. The file is read by other agents as instructions.",...i,"","OUTPUT FORMAT \u2014 exactly this, with no text before or after:",E,"One or two sentences: what you changed and which evidence motivated it.",T,l,"The complete new file content.",h].join(`
|
|
3
|
+
`)}s(b,"buildProposerSystemPrompt");var a=s(e=>`${e>=0?"+":"-"}${Math.abs(e*100).toFixed(1)}pp`,"signedPp");function O(e){let t=/^\d{4}-\d{2}-\d{2}/.exec(e.at??"")?.[0]??"undated",i;if(e.measured){let o=e.measured;i=`MEASURED against this exact file and ${e.decision==="promote"?"ACCEPTED":"REJECTED"}: ${a(o.delta)} (CI ${a(o.ciLower)} to ${a(o.ciUpper)}, ${o.nPairs} paired cases)`}else i=`NOT MEASURED \u2014 the gate refused it, so its merit is still unknown: ${e.refusals.length>0?e.refusals.join("; "):"no reason recorded"}`;let n=[`- ${t} \u2014 ${i}`];return e.decision==="promote"&&n.push(e.applied?" The file WAS rewritten by this decision.":" Dry run: the file was NOT rewritten, so this edit is still available."),e.touched.length>0&&n.push(` Sections touched: ${e.touched.join(", ")}`),e.rationale.trim()!==""&&n.push(` You said at the time: ${e.rationale.trim()}`),n.join(`
|
|
4
|
+
`)}s(O,"describePriorDecision");function N(e){let t=e.evidence,i=["## CURRENT FILE CONTENT","","The file is EXACTLY the text between the two sentinel lines below \u2014","nothing before the first sentinel or after the second is part of it.","Everything after the closing sentinel is evidence ABOUT the file.","",c,e.currentContent,p,""];if(t.weakest.length>0){i.push("## CASES WHERE THIS FILE CURRENTLY UNDERPERFORMS","");for(let n of t.weakest)i.push(`- ${n.name}: passes ${(n.withPassRate*100).toFixed(0)}% with the file vs ${(n.withoutPassRate*100).toFixed(0)}% without it`);i.push("")}return t.nonDiscriminating.length>0&&i.push("## CASES THAT CARRY NO SIGNAL EITHER WAY","","These score the same with and without the file. Changing the file to chase","them is unlikely to move anything.","",...t.nonDiscriminating.map(n=>`- ${n}`),""),t.priorDecisions.length>0&&i.push("## WHAT YOU ALREADY PROPOSED FOR THIS FILE, AND HOW IT WAS JUDGED","","Newest first. Every attempt listed here was made against the file above,","byte for byte. Attempts against a different version of the file are not","shown, because a verdict earned by different text says nothing about this","one.","",...t.priorDecisions.map(O),""),t.notes.length>0&&i.push("## NOTES","",...t.notes.map(n=>`- ${n}`),""),i.join(`
|
|
5
|
+
`)}s(N,"buildProposerData");function g(e,t,i){let n=e.lastIndexOf(i);if(n<0)return null;let o=e.lastIndexOf(t,n);return o<0?null:e.slice(o+t.length,n)}s(g,"between");function R(e){let t=e.split(`
|
|
6
|
+
`);for(;t.length>0&&t[0].trim()==="";)t.shift();for(;t.length>0&&t[t.length-1].trim()==="";)t.pop();if(t.length<2)return t.join(`
|
|
7
|
+
`);let i=t[0].trim(),n=t[t.length-1].trim(),o=/^(`{3,}|~{3,})[a-zA-Z0-9_-]*$/.test(i),r=/^(`{3,}|~{3,})$/.test(n);return o&&r?t.slice(1,-1).join(`
|
|
8
|
+
`):t.join(`
|
|
9
|
+
`)}s(R,"stripWrappingFence");function P(e,t){if(!e||e.trim()==="")return{ok:!1,reason:"proposer returned nothing"};let i=g(e,l,h);if(i==null)return{ok:!1,reason:`proposer reply had no ${l}\u2026${h} block`};let n=R(i).split(`
|
|
10
|
+
`).filter(w=>{let u=w.trim();return u!==c&&u!==p}).join(`
|
|
11
|
+
`).trim();if(n==="")return{ok:!1,reason:"proposed content was empty"};if(n===t.trim())return{ok:!1,reason:"proposal is identical to the current version"};let o=n.length/Math.max(1,t.trim().length);if(o<f)return{ok:!1,reason:`proposal retains only ${(o*100).toFixed(0)}% of the predecessor's length (floor ${(f*100).toFixed(0)}%) \u2014 treating it as a truncated or summarised reply rather than an edit`};if(o>m)return{ok:!1,reason:`proposal is ${o.toFixed(1)}x the predecessor's length (ceiling ${m}x) \u2014 treating it as runaway generation`};let r=(g(e,E,T)??"").trim();return{ok:!0,proposal:{candidateContent:n,rationale:r===""?"(proposer supplied no rationale)":r}}}s(P,"parseProposalResponse");async function y(e,t=16e3){let i=await d(b(e),N(e),t);return i==null?{ok:!1,reason:"no LLM backend available, or the proposer call failed"}:P(i,e.currentContent)}s(y,"proposeInstructionEdit");export{c as a,p as b,f as c,m as d,b as e,O as f,N as g,P as h,y as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f}from"./chunk-B3BHB26P.js";import{b as S,e as a,h as y}from"./chunk-
|
|
1
|
+
import{f}from"./chunk-B3BHB26P.js";import{b as S,e as a,h as y}from"./chunk-QAV4HW7D.js";import{a as p}from"./chunk-ZLLER3HP.js";var _=1800*1e3,G=300*1e3,T=10,h=`Given these messages from an AI coding session, write a 1-2 sentence summary of what the user is trying to accomplish. Focus on the goal, not the steps. No preamble.
|
|
2
2
|
|
|
3
3
|
Return strict JSON in the form: {"goalSummary": "..."}`;async function k(n,e={}){let d=e.llm??f,o=e.now??Date.now,w=e.getSession??(async s=>{try{return await a(`/api/sessions/${s}`)}catch(t){if(t instanceof S&&t.statusCode===404)return null;throw t}}),m=e.getEvents??((s,t)=>a(`/api/sessions/${s}/events?limit=${t.limit}&sort=${t.sort}`)),v=e.saveGoal??(async(s,t)=>{await y(`/api/sessions/${s}/enrich`,{analysis:t})}),i=await w(n.sessionId);if(!i)return{skipped:"not_found"};let[P]=await m(n.sessionId,{limit:1,sort:"desc"}),A=new Date(P?.timestamp??i.startedAt).getTime();if(o()-A>_)return{skipped:"stale"};let l=i.analysis??{},c=l.goalSummaryAt?new Date(l.goalSummaryAt).getTime():0;if(c&&o()-c<G)return{skipped:"recent"};let g=(await m(n.sessionId,{limit:T*2,sort:"asc"})).filter(s=>s.content&&(s.eventType==="user_message"||s.eventType==="assistant_response")).map(s=>`${s.eventType==="user_message"?"USER":"ASSISTANT"}: ${s.content}`).join(`
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as l}from"./chunk-6QKI756T.js";import{a as p}from"./chunk-5RBLIVBF.js";import{h}from"./chunk-
|
|
1
|
+
import{b as l}from"./chunk-6QKI756T.js";import{a as p}from"./chunk-5RBLIVBF.js";import{h}from"./chunk-QAV4HW7D.js";import{a as c}from"./chunk-ZLLER3HP.js";async function g(t){if(!t.worktree?.create)return t;let{branch:e,baseRef:s}=t.worktree,n=await l({repoRoot:t.projectPath,branch:e,baseRef:s});return{...t,projectPath:n.path,gitBranch:n.branch}}c(g,"resolveWorktreeForLaunch");async function L(t,e){let{mirrorId:s,tool:n}=t,{config:r}=t,a=c(o=>e.logger.info(o),"log");if(e.job.attempts>1)throw new p(`process_launch is not safe to retry (attempt ${e.job.attempts}). Re-launch manually.`);r=await g(r),r.worktree?.create&&a(`Worktree resolved: ${r.projectPath} (branch ${r.gitBranch})`),a(`Launching ${n}...`);let{getLauncher:f}=await import("./dist-FAVALJ5C.js"),i=await f(n).launch(r);a(`Launch completed: sessionId=${i.sessionId}`);let u={...i,worktreePath:r.worktree?.create?r.projectPath:void 0,runId:r.runId};return await h(`/api/launch-jobs/${s}/state`,{result:u}).catch(o=>{a(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),u}c(L,"processLaunch");export{g as a,L as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as D,c as j}from"./chunk-6UEFCMR2.js";import{b as B,c as R,d as N,e as z}from"./chunk-NTKO4H2K.js";import{a as G}from"./chunk-
|
|
1
|
+
import{b as D,c as j}from"./chunk-6UEFCMR2.js";import{b as B,c as R,d as N,e as z}from"./chunk-NTKO4H2K.js";import{a as G}from"./chunk-JPUH3V67.js";import{c as J}from"./chunk-XRTZU7IZ.js";import{e as f,g as T}from"./chunk-QAV4HW7D.js";import{a as p}from"./chunk-ZLLER3HP.js";function W(r,a,s){return s?r.reviewerModel===s||r.reviewerModel===`${a}:${s}`:r.reviewerEngine===a}p(W,"reviewMatchesReviewer");var C=100;function Z(r){let a=new Set;return r.forEach((s,d)=>{s.method!=="deterministic"&&a.add(d)}),a}p(Z,"llmExpectationIndexes");var w=class extends Error{constructor(s,d){super(d);this.reason=s}static{p(this,"JudgeReviewSkip")}};async function oe(r){let a=r.log??(()=>{}),s=r.warn??a,d=r.targetId,K=r.parallel??3,U=r.timeoutMs??12e4,v=await f(`/api/eval-targets/${d}`),u=(await f(`/api/eval-targets/${d}/annotations?limit=500`)).filter(e=>e.judgeMethod==="llm");if(u.length===0)throw new w("no-labels",`No human labels on "${v.name}" yet \u2014 label some runs in the Review tab first.`);let n;try{n=z({engineFlag:r.engineFlag??"auto",modelFlag:r.modelFlag,availability:N(),judgeModels:[...new Set(u.map(e=>e.judgeModel).filter(e=>e!=null))]})}catch(e){throw new w("no-engine",e instanceof Error?e.message:String(e))}a(`Reviewer: ${n.rationale}`);let c=0,b=u;if(r.skipReviewed){let e=await f(`/api/eval-targets/${d}/judge-reviews`),t=new Set(e.filter(i=>W(i,n.engine,r.modelFlag)).map(i=>`${i.evalRunId}:${i.expectationIndex}`));if(b=u.filter(i=>!t.has(`${i.evalRunId}:${i.expectationIndex}`)),c=u.length-b.length,b.length===0)return{targetName:v.name,reviewer:n,judgeModels:[],reviewerModel:n.model??`${n.engine} (CLI default)`,report:j([],0),persisted:0,alreadyReviewed:c,deferredPartialRuns:0}}let y=new Map;for(let e=0;;e+=C){let t=await f(`/api/eval-targets/${d}/runs?limit=${C}&offset=${e}`);for(let i of t)y.set(i.id,i);if(t.length<C)break}let q=await f(`/api/eval-targets/${d}/evals`),X=new Map(q.map(e=>[e.id,e.prompt])),o=new Map;for(let e of b){let t=o.get(e.evalRunId)??[];t.push(e),o.set(e.evalRunId,t)}let P=new Map;for(let e of u){let t=P.get(e.evalRunId)??new Set;t.add(e.expectationIndex),P.set(e.evalRunId,t)}let x=0;for(let[e]of[...o]){let t=y.get(e)?.grading?.expectations;if(!t)continue;let i=Z(t),g=P.get(e)??new Set;[...i].every(h=>g.has(h))||(o.delete(e),x+=1)}if(x>0&&a(`${x} partially-labeled run(s) deferred \u2014 a run is re-graded once, after all its assertions are labeled.`),o.size===0)return{targetName:v.name,reviewer:n,judgeModels:[],reviewerModel:n.model??`${n.engine} (CLI default)`,report:j([],0),persisted:0,alreadyReviewed:c,deferredPartialRuns:x};if(n.engine==="codex"&&n.model){let e=await J({prompt:"Reply with exactly: OK",model:n.model,timeout:6e4});if(e.error&&B(e.error)){if(n.model===R)throw new w("preflight-failed",`Codex fallback model ${R} is also unrunnable: ${e.error}`);s(`Your codex model "${n.model}" can't run on the installed CLI/account \u2014 falling back to ${R}.`),n={...n,model:R}}else if(e.error)throw new w("preflight-failed",`Codex preflight failed: ${e.error}`)}let S=[...o.values()].flat(),Y=[...new Set(S.map(e=>e.judgeModel).filter(e=>e!=null))];a(`Re-grading ${o.size} annotated run(s) / ${S.length} assertion(s) on "${v.name}"`+(c?` (${c} already reviewed \u2014 skipped)`:"")+".");let $=[],I=0,k=new Set,m=r.limit!=null?[...o.entries()].slice(0,Math.max(1,r.limit)):[...o.entries()];m.length<o.size&&a(`Sampling ${m.length} of ${o.size} annotated runs (limit).`);let H=0,Q=p(async()=>{for(;;){let e=H++;if(e>=m.length)return;let[t,i]=m[e],g=y.get(t),h=g?.grading?.expectations,O=g?.outputs?.transcript,F=g?X.get(g.evalId):void 0;if(!g||!h?.length||!O||!F){I+=i.length,s(`run ${t.slice(0,8)}: missing output/expectations/prompt \u2014 skipped`);continue}let M=await G({prompt:F,output:O,expectations:h.map(l=>l.text),model:n.model??void 0,timeout:U,engine:n.engine});M.judge_model&&k.add(M.judge_model);for(let l of i){let L=h[l.expectationIndex],A=M.expectations[l.expectationIndex];if(!L||!A||L.text!==l.expectationText){I+=1;continue}if(M.judge_model==null&&A.method==="llm"){I+=1;continue}$.push({runId:t,expectationIndex:l.expectationIndex,text:l.expectationText,humanPassed:D(l.verdict,l.judgePassed),judgeAPassed:l.judgePassed,judgeBPassed:A.passed})}a(` ${e+1}/${m.length} re-graded`)}},"workerFn");await Promise.all(Array.from({length:Math.max(1,Math.min(K,m.length))},Q));let V=j($,I),_=[...k][0]??n.model??`${n.engine} (CLI default)`,E=0;if($.length>0)try{E=(await T(`/api/eval-targets/${d}/judge-reviews`,{reviewerEngine:n.engine,reviewerModel:_,verdicts:$.map(t=>({evalRunId:t.runId,expectationIndex:t.expectationIndex,expectationText:t.text,judgePassed:t.judgeAPassed,humanPassed:t.humanPassed,reviewerPassed:t.judgeBPassed}))})).upserted,a(`Persisted ${E} reviewer verdict(s) \u2014 disagreements appear on the Review tab.`)}catch(e){s(`Could not persist reviewer verdicts: ${e instanceof Error?e.message:e}`)}return{targetName:v.name,reviewer:n,judgeModels:Y,reviewerModel:_,report:V,persisted:E,alreadyReviewed:c,deferredPartialRuns:x}}p(oe,"runJudgeReviewPass");export{W as a,Z as b,w as c,oe as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./chunk-ZLLER3HP.js";import{spawn as y}from"node:child_process";function O(o){try{let t=JSON.parse(o),s=t.result??t.content??o,u=t.usage?.total_tokens??(t.usage?.input_tokens??0)+(t.usage?.output_tokens??0),r;if(t.modelUsage&&typeof t.modelUsage=="object"){let n=-1;for(let[i,m]of Object.entries(t.modelUsage)){let a=typeof m?.outputTokens=="number"?m.outputTokens:0;a>n&&(n=a,r=i)}}return{output:s,totalTokens:u,model:r}}catch{return{output:o,totalTokens:0}}}c(O,"parseClaudeJsonOutput");function D(o){let{prompt:t,targetContent:s,systemPrompt:u,model:r}=o,n=["-p",t,"--output-format","json","--settings",JSON.stringify({disableAllHooks:!0})],i=s??u;return i&&n.push("--system-prompt",i),r&&n.push("--model",r),n}c(D,"buildClaudeArgs");function v(o,t,s,u){let r=t.trim()||s.trim()||u.trim()||"(no output on stderr or stdout)";return`Exit code ${o}: ${r.slice(0,1e3)}`}c(v,"describeExitFailure");async function h(o){let{prompt:t,targetContent:s,systemPrompt:u,workDir:r=process.cwd(),timeout:n=12e4,model:i}=o,m=D({prompt:t,targetContent:s,systemPrompt:u,model:i}),a=Date.now();return new Promise(g=>{let l={...process.env};delete l.CLAUDECODE,delete l.HTTPS_PROXY;let b=["/opt/homebrew/bin","/usr/local/bin"],f=(l.PATH??"").split(":").filter(Boolean),T=b.filter(e=>!f.includes(e));T.length&&(l.PATH=[...f,...T].join(":"));let p=y("claude",m,{cwd:r,env:l,stdio:["ignore","pipe","pipe"]}),d="",x="";p.stdout.on("data",e=>{d+=e.toString()}),p.stderr.on("data",e=>{x+=e.toString()});let k=setTimeout(()=>{p.kill("SIGTERM"),g({output:d,exitCode:null,durationMs:Date.now()-a,totalTokens:0,error:`Timed out after ${n}ms`})},n);p.on("close",e=>{clearTimeout(k);let P=Date.now()-a,{output:E,totalTokens:C,model:w}=O(d);g({output:E,exitCode:e,durationMs:P,totalTokens:C,model:w,error:e!==0?v(e,x,E,d):void 0})}),p.on("error",e=>{clearTimeout(k),g({output:"",exitCode:null,durationMs:Date.now()-a,totalTokens:0,error:`Failed to spawn claude: ${e.message}`})})})}c(h,"executeEval");export{O as a,D as b,v as c,h as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,d as m}from"./chunk-
|
|
1
|
+
import{a as d,d as m}from"./chunk-QAV4HW7D.js";import{a as c,l as a}from"./chunk-JZ5Z2BRO.js";import{a as o}from"./chunk-ZLLER3HP.js";import{createHash as g,randomUUID as v}from"node:crypto";import{hostname as y,platform as p}from"node:os";import{existsSync as P,mkdirSync as _,readFileSync as h,writeFileSync as R}from"node:fs";import{join as E}from"node:path";var O="device-id";function u(){let e=o(t=>t==="1"||t==="true","off");return e(process.env.RULEMETRIC_NO_TELEMETRY)||e(process.env.DO_NOT_TRACK)}o(u,"telemetryDisabled");function l(){let e=a(),t=E(e,O);try{if(P(t)){let r=h(t,"utf-8").trim();if(r)return r}}catch{}let n=g("sha256").update(`${v()}:${y()}`).digest("hex").slice(0,32);try{_(e,{recursive:!0}),R(t,n,{mode:384})}catch{}return n}o(l,"getDeviceId");async function U(e,t={},n){if(!u())try{await m("/api/telemetry/cli-events",{method:"POST",body:{event:e,deviceId:l(),cliVersion:n,os:p(),props:t},timeoutMs:5e3})}catch{}}o(U,"emitSetupEvent");async function w(e){if(u())return;let n=`${process.env.RULEMETRIC_API_URL??c().apiUrl??d}/api/telemetry/cli-error`,r=process.env.HTTPS_PROXY,s=process.env.HTTP_PROXY,T=r!==void 0||s!==void 0;delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY;let i=new AbortController,f=setTimeout(()=>i.abort(),4e3);try{await globalThis.fetch(n,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`rulemetric-cli/${e.cliVersion??"unknown"}`},body:JSON.stringify({event:e.event??"onboarding_error",deviceId:l(),command:e.command,statusCode:e.statusCode,message:e.message?e.message.slice(0,500):void 0,cliVersion:e.cliVersion,os:p(),nodeVersion:process.version,proxied:T,props:e.props}),signal:i.signal})}catch{}finally{clearTimeout(f),r!==void 0&&(process.env.HTTPS_PROXY=r),s!==void 0&&(process.env.HTTP_PROXY=s)}}o(w,"emitErrorBeacon");export{u as a,l as b,U as c,w as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as n,c as a,d as g}from"./chunk-3AV3GTMP.js";import{e as o}from"./chunk-
|
|
1
|
+
import{a as s,b as n,c as a,d as g}from"./chunk-3AV3GTMP.js";import{e as o}from"./chunk-QAV4HW7D.js";import{a as e}from"./chunk-ZLLER3HP.js";var i=!1;async function c(){if(process.env.RULEMETRIC_ORG_ID)return;let r=s();if(!(r&&!g(r)))try{let t=await o("/api/profile");if(!t.activeOrgId){a();return}if(r&&t.activeOrgId===r.orgId){n({orgId:r.orgId,orgSlug:r.orgSlug,syncedAt:Date.now()});return}let d=(await o("/api/orgs")).find(l=>l.id===t.activeOrgId);n({orgId:t.activeOrgId,orgSlug:d?.slug,syncedAt:Date.now()})}catch{}}e(c,"syncActiveOrgFromServer");async function p(){i||(i=!0,await c())}e(p,"maybeRefreshActiveOrg");async function v(){i=!0,await c()}e(v,"bootstrapActiveOrg");function O(){i=!1}e(O,"_resetRefreshAttempt");export{p as a,v as b,O as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as h,b as
|
|
1
|
+
import{a as h,b as D}from"./chunk-FP6QAPNK.js";import{d as _,e as C}from"./chunk-3PUOJ6F2.js";import{a as o}from"./chunk-ZLLER3HP.js";import*as m from"node:fs/promises";import*as x from"node:path";import{eq as z}from"drizzle-orm";import{randomBytes as H}from"node:crypto";var A="#0d9488",g="#1a1a1a",y="#666666",M="#f5f5f7",k="#ffffff",I="#e5e5e9",O=["Added","Changed","Fixed","Removed","Deprecated","Security"];function U(e){let t=["January","February","March","April","May","June","July","August","September","October","November","December"],[n,r,a]=e.split("-").map(p=>parseInt(p,10));return!n||!r||!a||r<1||r>12?e:`${t[r-1]} ${a}, ${n}`}o(U,"formatIsoDate");function l(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}o(l,"escapeHtml");function P(e){let t=[];for(let n of O){let r=e[n];r&&r.length>0&&t.push({name:n,items:r})}return t}o(P,"orderedSections");function v(e){let{version:t,date:n,sections:r,unsubscribeUrl:a,productUrl:p,recipientName:u}=e,c=U(n),s=`What's new in RuleMetric \u2014 ${c}`,b=u?`Hi ${u},`:"Hi there,",i=P(r),d=new Date().getUTCFullYear(),E=i.map(({name:$,items:R})=>{let w=R.map(S=>` <li style="margin:0 0 6px 0;font-size:15px;line-height:1.5;color:${g};">${l(S)}</li>`).join(`
|
|
2
2
|
`);return` <h3 style="margin:24px 0 8px 0;font-size:16px;line-height:1.3;font-weight:600;color:${g};">${$}</h3>
|
|
3
3
|
<ul style="margin:0 0 8px 0;padding-left:20px;">
|
|
4
4
|
${w}
|
|
@@ -63,4 +63,4 @@ ${E}
|
|
|
63
63
|
</table>
|
|
64
64
|
</body>
|
|
65
65
|
</html>`,f=[`What's new in RuleMetric \u2014 ${c}`,`Release ${t}`,"",b,"","Here's what shipped in the latest RuleMetric release.",""];for(let{name:$,items:R}of i){f.push(`${$}:`);for(let w of R)f.push(` - ${w}`);f.push("")}f.push("--","You're receiving this because you signed up for RuleMetric product updates.",`Unsubscribe: ${a}`,"",`RuleMetric \u2022 ${d}`);let N=f.join(`
|
|
66
|
-
`);return{subject:s,html:T,text:N}}o(v,"renderChangelogAnnouncement");async function L(e){let t=e;for(let n=0;n<50;n++){try{return await m.stat(x.join(t,"pnpm-workspace.yaml")),t}catch{}let r=x.dirname(t);if(r===t)return null;t=r}return null}o(L,"findRepoRoot");async function j(e){if(e)try{return await m.readFile(e,"utf-8")}catch{return null}let t=await L(process.cwd())??process.cwd(),n=x.join(t,"CHANGELOG.md");try{return await m.readFile(n,"utf-8")}catch{return null}}o(j,"readChangelog");var B="https://rulemetric.com";function F(e){let t=e.date??new Date().toISOString().slice(0,10),n=v({version:e.version,date:t,sections:e.sections,unsubscribeUrl:"{{unsubscribe_url}}",recipientName:"{{recipient_name}}",productUrl:B});return{version:e.version,releaseDate:t,subject:n.subject,htmlBody:n.html,textBody:n.text,sections:e.sections}}o(F,"renderRow");async function me(e={}){let t=e.db??
|
|
66
|
+
`);return{subject:s,html:T,text:N}}o(v,"renderChangelogAnnouncement");async function L(e){let t=e;for(let n=0;n<50;n++){try{return await m.stat(x.join(t,"pnpm-workspace.yaml")),t}catch{}let r=x.dirname(t);if(r===t)return null;t=r}return null}o(L,"findRepoRoot");async function j(e){if(e)try{return await m.readFile(e,"utf-8")}catch{return null}let t=await L(process.cwd())??process.cwd(),n=x.join(t,"CHANGELOG.md");try{return await m.readFile(n,"utf-8")}catch{return null}}o(j,"readChangelog");var B="https://rulemetric.com";function F(e){let t=e.date??new Date().toISOString().slice(0,10),n=v({version:e.version,date:t,sections:e.sections,unsubscribeUrl:"{{unsubscribe_url}}",recipientName:"{{recipient_name}}",productUrl:B});return{version:e.version,releaseDate:t,subject:n.subject,htmlBody:n.html,textBody:n.text,sections:e.sections}}o(F,"renderRow");async function me(e={}){let t=e.db??D(),n=e.logger??{info:o(s=>console.log(s),"info"),warn:o(s=>console.warn(s),"warn")},r=await j(e.changelogPath);if(r===null)return n.info("[cron_check_changelog] CHANGELOG.md not found; nothing to do"),{createdCount:0,skippedCount:0};let a=_(r),p=C(a);if(p.length===0)return n.info("[cron_check_changelog] No announceable entries; nothing to do"),{createdCount:0,skippedCount:0};let u=0,c=0;for(let s of p){if((await t.select({id:h.id}).from(h).where(z(h.version,s.version)).limit(1)).length>0){c++;continue}let i=F(s);try{await t.insert(h).values({version:i.version,releaseDate:i.releaseDate,subject:i.subject,htmlBody:i.htmlBody,textBody:i.textBody,sections:i.sections,status:"draft"}),u++,n.info(`[cron_check_changelog] Created draft announcement for ${i.version}`)}catch(d){let E=d instanceof Error?d.message:String(d);if(/duplicate key|unique/i.test(E)){c++;continue}throw d}}return n.info(`[cron_check_changelog] Done: created ${u}, skipped ${c}`),{createdCount:u,skippedCount:c}}o(me,"processChangelog");export{me as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-E2NVNLFD.js";import{h as s}from"./chunk-QAV4HW7D.js";import{a as n}from"./chunk-ZLLER3HP.js";async function l(a,c){let{mirrorId:g,evalTargetId:p,config:r}=a,e=n(o=>c.logger.info(o),"log");await i(r,p,e);let t={type:"conversation",conversationId:r.conversationId};return await s(`/api/eval-jobs/${g}/state`,{result:t}).catch(o=>{e(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),t}n(l,"processConversation");export{l as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as i,e as n,g,h as m}from"./chunk-NJ5UED3H.js";import{
|
|
1
|
+
import{b as f}from"./chunk-ZXF5NE54.js";import{d as i,e as n,g,h as m}from"./chunk-NJ5UED3H.js";import{a as s}from"./chunk-ZLLER3HP.js";import{Box as u,Text as t}from"ink";import{jsx as l,jsxs as e}from"react/jsx-runtime";var y={pending:{glyph:"\u25CC",color:n},queued:{glyph:"\u25CC",color:n},running:{glyph:"\u25CF",color:i},completed:{glyph:"\u2713",color:g},failed:{glyph:"\u2717",color:m},cancelled:{glyph:"\u2298",color:n}};function b(c){let p=Date.now()-new Date(c).getTime(),r=Math.floor(p/6e4);if(r<1)return"now";if(r<60)return`${r}m`;let o=Math.floor(r/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}s(b,"ago");function w({jobs:c,selectedIndex:p,focused:r}){return c.length===0?e(u,{flexDirection:"column",paddingX:1,children:[l(t,{bold:!0,color:i,children:"\u25BC Active jobs"}),l(t,{dimColor:!0,children:" (no jobs yet \u2014 press tab to focus the form below)"})]}):e(u,{flexDirection:"column",paddingX:1,children:[e(t,{bold:!0,color:i,children:["\u25BC Active jobs (last ",c.length,")"]}),c.map((o,h)=>{let d=r&&h===p,a=y[o.status]??{glyph:"?",color:n},x=o.config?.projectPath??"",T=(o.config?.prompt??"").slice(0,30);return e(t,{wrap:"truncate-end",children:[l(t,{color:d?i:n,children:d?"\u25B6 ":" "}),e(t,{color:a.color,children:[a.glyph," "]}),l(t,{dimColor:!0,children:o.status.padEnd(10)}),l(t,{children:f(o.tool).padEnd(14)}),l(t,{dimColor:!0,children:x.padEnd(28)}),e(t,{children:['"',T,'"']}),e(t,{dimColor:!0,children:[" ",b(o.createdAt)]})]},o.id)})]})}s(w,"ActiveJobsList");export{w as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as f}from"./chunk-6QKI756T.js";import{a as l}from"./chunk-5RBLIVBF.js";import{b as g,e as k}from"./chunk-
|
|
1
|
+
import{c as f}from"./chunk-6QKI756T.js";import{a as l}from"./chunk-5RBLIVBF.js";import{b as g,e as k}from"./chunk-QAV4HW7D.js";import{a as m}from"./chunk-ZLLER3HP.js";async function C(w,i={}){let R=i.removeWorktreeFn??f,t=i.log??(e=>process.stderr.write(`[process_run_cleanup] ${e}
|
|
2
2
|
`)),j=i.getRunDetail??(async e=>{try{return await k(`/api/runs/${e}`)}catch(r){if(r instanceof g&&r.statusCode===404)return null;throw r}}),{runId:o}=w,n=await j(o);if(!n)throw new l(`Run ${o} not found`);if(!n.run.projectPath)throw new l(`Run ${o} has no projectPath; cannot resolve a repo root for worktree cleanup`);let a=n.run.projectPath,$=n.sessions.filter(e=>e.endedAt!=null),s=[],u=0,c=0,p=0,d=0,h=new Set;for(let e of $)if(!(!e.projectPath||e.projectPath===a)&&!h.has(e.projectPath)){h.add(e.projectPath);try{let r=await R({repoRoot:a,worktreePath:e.projectPath});r.removed?(u++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"removed"}),t(`removed worktree ${e.projectPath} (session ${e.id})`)):r.reason==="dirty"?(c++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"skipped-dirty"}),t(`skipped dirty worktree ${e.projectPath} (session ${e.id}) \u2014 uncommitted changes`)):(p++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"absent"}),t(`worktree absent ${e.projectPath} (session ${e.id})`))}catch(r){let P=r instanceof Error?r.message:String(r);d++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"error",error:P.slice(0,1e3)}),t(`error removing worktree ${e.projectPath} (session ${e.id}): ${P}`)}}return t(`run ${o} cleanup: removed=${u} skippedDirty=${c} absent=${p} errored=${d}`),{runId:o,repoRoot:a,removed:u,skippedDirty:c,absent:p,errored:d,worktrees:s}}m(C,"processRunCleanup");export{C as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./chunk-CJRYYV76.js";import{b as u}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-CJRYYV76.js";import{b as u}from"./chunk-MO57LGGK.js";import{e as o}from"./chunk-QAV4HW7D.js";import{a as c}from"./chunk-ZLLER3HP.js";async function w(e,g){let i=c(a=>g?.logger?.info?.(a)??console.log(a),"log"),{evalTargetId:n}=e,s=await o(`/api/eval-targets/${n}/judge-calibration`),t=d({powered:s.powerCheck.powered,mde:s.powerCheck.mde??Number.POSITIVE_INFINITY},s.caseDiscrimination??{total:0,discriminating:0,nonDiscriminating:0,unpaired:0},{runsCompleted:0,maxRuns:e.maxRuns??24,batchesRun:0,maxBatches:1});if(t.action==="stop")return i(`[cron_eval_autorun] ${n}: ${t.reason}`),{skipped:t.code,reason:t.reason};let r=await o(`/api/eval-targets/${n}`),l=(await o(`/api/eval-targets/${n}/evals`)).filter(a=>!a.retiredAt);if(l.length===0)return{skipped:"no-live-cases"};let{completed:m,failed:p}=await u({cases:l,targetContent:r.content,concurrency:2,runNumber:1,opts:{targetId:n,targetVersion:r.version??1,iteration:1,timeout:e.timeout??24e4,model:e.model,graderModel:e.graderModel,skipGrading:!1,targetType:r.type,targetName:r.name},onLog:i});return i(`[cron_eval_autorun] ${r.name}: ${m} completed, ${p} failed`),{ranRuns:m,reason:t.reason}}c(w,"cronEvalAutorun");export{w as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as u}from"./chunk-TZA4HAVF.js";import{a as o}from"./chunk-ZLLER3HP.js";var l=`You are a meta-judge evaluating the quality of an eval run \u2014 not the code output, but whether the test cases and grading themselves are rigorous and meaningful.
|
|
2
2
|
|
|
3
3
|
You will receive a summary of eval cases, their expectations, and grading results.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as E,d as R}from"./chunk-
|
|
1
|
+
import{b as E,d as R}from"./chunk-QAV4HW7D.js";import{a as o}from"./chunk-ZLLER3HP.js";import{createHash as C}from"node:crypto";import{existsSync as A,mkdirSync as I,readFileSync as p,renameSync as L,rmdirSync as M,writeFileSync as m}from"node:fs";import{homedir as U,tmpdir as x}from"node:os";import{join as c}from"node:path";var $=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function v(t){return $.test(t)?t:`antigravity-${C("sha256").update(t).digest("hex").slice(0,16)}`}o(v,"hookSessionKey");var _=100,F=new Set(["RUN_COMMAND","VIEW_FILE","LIST_DIRECTORY","CODE_ACTION","GREP_SEARCH","SEARCH_WEB"]),H=new Set(["CONVERSATION_HISTORY","KNOWLEDGE_ARTIFACTS","CHECKPOINT"]);function T(){return process.env.RULEMETRIC_CONFIG_DIR??c(U(),".config","rulemetric")}o(T,"configDir");function O(){return c(T(),"antigravity-state")}o(O,"stateDir");function P(t){return c(O(),`${t}.json`)}o(P,"stateFile");function k(){let t=c(T(),"env");if(A(t))try{let n=p(t,"utf-8");for(let r of n.split(/\r?\n/)){let e=r.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);if(!e)continue;let i=e[1];if(process.env[i]!==void 0)continue;let s=e[2];(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1)),process.env[i]=s}}catch{}}o(k,"loadEnvFile");function b(t){try{let n=p(P(t),"utf-8"),r=JSON.parse(n);if(r&&typeof r=="object"&&"lastStepIdx"in r){let e=r.lastStepIdx;if(typeof e=="number"&&Number.isFinite(e))return{lastStepIdx:e}}}catch{}return null}o(b,"loadState");function g(t,n){I(O(),{recursive:!0});let r=P(t),e=`${r}.tmp`;m(e,JSON.stringify(n),{mode:384});try{L(e,r)}catch{m(r,JSON.stringify(n),{mode:384})}}o(g,"saveState");function N(t){let n=process.env.TMPDIR??x(),r=c(n,"rulemetric"),e=c(r,v(t));try{return p(e,"utf-8").trim()||null}catch{return null}}o(N,"resolveRwSessionId");function W(t){let n=process.env.TMPDIR??x(),r=c(n,"rulemetric"),e=v(t),i=c(r,`${e}.seq`),s=c(r,`${e}.seqlock`),l=Date.now()+5e3;for(;Date.now()<l;)try{I(s);break}catch{}let a=1;try{a=parseInt(p(i,"utf-8").trim(),10)+1,(!Number.isFinite(a)||a<1)&&(a=1)}catch{a=1}try{m(i,String(a))}catch{}try{M(s)}catch{}return a}o(W,"nextSequence");function Y(t,n){let r;try{r=p(t,"utf-8")}catch{return[]}let e=[];for(let i of r.split(/\r?\n/))if(i.trim())try{let s=JSON.parse(i);typeof s.step_index=="number"&&s.step_index>n&&e.push(s)}catch{}return e.sort((i,s)=>i.step_index-s.step_index),e}o(Y,"readNewRecords");function G(t){let n;try{n=p(t,"utf-8")}catch{return-1}let r=-1;for(let e of n.split(/\r?\n/))if(e.trim())try{let i=JSON.parse(e);typeof i.step_index=="number"&&i.step_index>r&&(r=i.step_index)}catch{}return r}o(G,"findMaxStepIndex");function J(t){let n=t.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);return n?n[1].trim():t.trim()}o(J,"extractUserPrompt");function j(t,n){let r=t.created_at??new Date().toISOString(),e={antigravityStepIndex:t.step_index,antigravitySource:t.source,antigravityType:t.type};if(H.has(t.type)||F.has(t.type))return null;if(t.source==="USER_EXPLICIT"&&t.type==="USER_INPUT")return{sequence:n,eventType:"user_message",content:J(t.content??""),timestamp:r,metadata:e};if(t.source==="MODEL"&&t.type==="PLANNER_RESPONSE"){let i=[];return t.thinking&&t.thinking.trim()&&i.push(`[thinking]
|
|
2
2
|
${t.thinking.trim()}`),t.content&&t.content.trim()&&i.push(t.content.trim()),t.tool_calls&&t.tool_calls.length>0&&(e.antigravityToolCalls=t.tool_calls.map(s=>s.name).filter(Boolean)),{sequence:n,eventType:"assistant_response",content:i.join(`
|
|
3
3
|
|
|
4
4
|
`)||null,timestamp:r,metadata:e}}return t.source==="MODEL"&&t.type==="GENERIC"?{sequence:n,eventType:"tool_result",content:t.content??null,timestamp:r,metadata:e}:t.source==="SYSTEM"&&(t.type==="SYSTEM_MESSAGE"||t.type==="ERROR_MESSAGE")?null:{sequence:n,eventType:`antigravity_${t.type.toLowerCase()}`,content:t.content??null,timestamp:r,metadata:e}}o(j,"classifyRecord");function q(t){try{let n=JSON.parse(t);return n&&typeof n=="object"?n:null}catch{return null}}o(q,"parseHookPayload");async function K(t,n,r,e,i={}){let s=i.errorSink??(u=>process.stderr.write(u)),l=0,a=0,d=0,S=0,f=e;for(let u of t){l++,i.onProgress?.({attempted:l,total:t.length,record:u});let w=W(r),y=j(u,w);if(!y)S++;else try{await R(`/api/sessions/${n}/events`,{method:"POST",body:y}),a++}catch(h){d++;let D=h instanceof E?h.statusCode:"unknown";s(`[antigravity-tailer] failed step=${u.step_index} type=${u.type} status=${D}
|
|
@@ -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-YFQ4FOAS.js";import{a as h}from"../../chunk-KHWG7ZG4.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-UUZB4IKU.js";import"../../chunk-EQHKCGSX.js";import"../../chunk-VA5DPQB4.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-QAV4HW7D.js";import"../../chunk-3PUOJ6F2.js";import"../../chunk-JZ5Z2BRO.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-KHWG7ZG4.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-UUZB4IKU.js";import"../../chunk-EQHKCGSX.js";import"../../chunk-VA5DPQB4.js";import"../../chunk-3AV3GTMP.js";import{f as r}from"../../chunk-QAV4HW7D.js";import"../../chunk-3PUOJ6F2.js";import{i as o,l as s}from"../../chunk-JZ5Z2BRO.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-BPP7AEFW.js";import{a as w}from"../../chunk-KHWG7ZG4.js";import"../../chunk-IZTIYR5Q.js";import{c}from"../../chunk-UUZB4IKU.js";import"../../chunk-EQHKCGSX.js";import{b as n}from"../../chunk-VA5DPQB4.js";import"../../chunk-3AV3GTMP.js";import{b as r,d as a}from"../../chunk-QAV4HW7D.js";import"../../chunk-3PUOJ6F2.js";import{b as m,d,h as u,i as g}from"../../chunk-JZ5Z2BRO.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-KHWG7ZG4.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-UUZB4IKU.js";import"../../chunk-EQHKCGSX.js";import"../../chunk-VA5DPQB4.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-QAV4HW7D.js";import"../../chunk-3PUOJ6F2.js";import{f as i,j as r}from"../../chunk-JZ5Z2BRO.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-KHWG7ZG4.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-UUZB4IKU.js";import"../../chunk-EQHKCGSX.js";import"../../chunk-VA5DPQB4.js";import"../../chunk-3AV3GTMP.js";import{e as n,i as c}from"../../chunk-QAV4HW7D.js";import"../../chunk-3PUOJ6F2.js";import"../../chunk-JZ5Z2BRO.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-BPP7AEFW.js";import{a as h}from"../../chunk-KHWG7ZG4.js";import"../../chunk-IZTIYR5Q.js";import{c as d}from"../../chunk-UUZB4IKU.js";import"../../chunk-EQHKCGSX.js";import{b as l}from"../../chunk-VA5DPQB4.js";import"../../chunk-3AV3GTMP.js";import{b as m,d as p}from"../../chunk-QAV4HW7D.js";import"../../chunk-3PUOJ6F2.js";import{d as n,h as c}from"../../chunk-JZ5Z2BRO.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};
|