@rulemetric/cli 0.17.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/dist/base-command.js +1 -1
  2. package/dist/{chunk-DHIEGG4T.js → chunk-26XE3JCL.js} +1 -1
  3. package/dist/chunk-2IQBXE6F.js +1 -0
  4. package/dist/{chunk-QXPGTEMO.js → chunk-2K4TF5RM.js} +1 -1
  5. package/dist/chunk-3IAZMJA4.js +1 -0
  6. package/dist/{chunk-F5GSKVF2.js → chunk-3WNQ52TW.js} +1 -1
  7. package/dist/{chunk-KEVDLLHT.js → chunk-433HK3QQ.js} +1 -1
  8. package/dist/{chunk-KR36ZDGN.js → chunk-4GM4OEQY.js} +1 -1
  9. package/dist/{chunk-5A6TMSRO.js → chunk-4XRPSKIJ.js} +1 -1
  10. package/dist/{chunk-65LFPUDB.js → chunk-52OHAULM.js} +1 -1
  11. package/dist/{chunk-T7HZZ4DJ.js → chunk-55HFAX5Y.js} +1 -1
  12. package/dist/{chunk-QPAOX7P2.js → chunk-57YXM7AI.js} +1 -1
  13. package/dist/{chunk-SFZPFNC6.js → chunk-6YSTU453.js} +1 -1
  14. package/dist/{chunk-3H44B6PB.js → chunk-7V6LLVAY.js} +1 -1
  15. package/dist/{chunk-USKRCVX3.js → chunk-ACJ2DBOE.js} +1 -1
  16. package/dist/{chunk-LJE5J3EW.js → chunk-ANHFE6US.js} +1 -1
  17. package/dist/{chunk-FADINV4H.js → chunk-AXTEV56C.js} +1 -1
  18. package/dist/{chunk-HBDKOU2N.js → chunk-AZB34RT6.js} +7 -6
  19. package/dist/{chunk-RDQXK5LG.js → chunk-AZK4Y5DB.js} +1 -1
  20. package/dist/{chunk-GIQ2HK3W.js → chunk-BLGICIV4.js} +1 -1
  21. package/dist/{chunk-6QMIDH6X.js → chunk-BV3JMD3A.js} +1 -1
  22. package/dist/{chunk-ZKPURXUS.js → chunk-CEM7JMUW.js} +1 -1
  23. package/dist/{chunk-NWV66NMA.js → chunk-CWVXTLXZ.js} +1 -1
  24. package/dist/{chunk-IMN4BWAR.js → chunk-CXSDZ473.js} +1 -1
  25. package/dist/{chunk-4ZDE63UG.js → chunk-DB4ZM5N3.js} +1 -1
  26. package/dist/{chunk-QPVUGTDP.js → chunk-EOTSCWFS.js} +1 -1
  27. package/dist/chunk-FLXWL4F4.js +8 -0
  28. package/dist/{chunk-7YZURVZD.js → chunk-FPEC6DJV.js} +1 -1
  29. package/dist/chunk-G2226CG6.js +1 -0
  30. package/dist/{chunk-KOORMTZO.js → chunk-GLZBTGN5.js} +1 -1
  31. package/dist/{chunk-5TM7AOH2.js → chunk-GPWLS64K.js} +1 -1
  32. package/dist/{chunk-STUNT4N3.js → chunk-HB4RUEEE.js} +1 -1
  33. package/dist/{chunk-UVCVJKEN.js → chunk-JEZ5ZTKR.js} +1 -1
  34. package/dist/{chunk-ISYU5BMU.js → chunk-JQ2ZCUEC.js} +1 -1
  35. package/dist/{chunk-FHRBW4AQ.js → chunk-KSKC5SEQ.js} +1 -1
  36. package/dist/{chunk-ISEUEYSC.js → chunk-L3AXNCWC.js} +1 -1
  37. package/dist/chunk-LARY6ZFT.js +1 -0
  38. package/dist/{chunk-E4CIJ67Z.js → chunk-LEUXIXIS.js} +1 -1
  39. package/dist/{chunk-GGUXEZC3.js → chunk-LMNUO32P.js} +1 -1
  40. package/dist/{chunk-ZBTJ5R7C.js → chunk-LMQDS47I.js} +1 -1
  41. package/dist/{chunk-VUNJGZPP.js → chunk-M2CPTQZL.js} +1 -1
  42. package/dist/{chunk-WUCACPGC.js → chunk-MOQTSJNZ.js} +1 -1
  43. package/dist/chunk-N7P3HUPD.js +3 -0
  44. package/dist/{chunk-7LE2W3WP.js → chunk-PHBPHZSZ.js} +1 -1
  45. package/dist/{chunk-TSLBCZ5P.js → chunk-QH7JB4UQ.js} +1 -1
  46. package/dist/{chunk-CVPAKEEZ.js → chunk-R7URROQD.js} +1 -1
  47. package/dist/{chunk-EFEPD4AZ.js → chunk-RAIXY6YA.js} +1 -1
  48. package/dist/{chunk-KUW6AVSI.js → chunk-RCJTCLZO.js} +1 -1
  49. package/dist/chunk-SVZYRGO5.js +4 -0
  50. package/dist/{chunk-WL5ZWQAS.js → chunk-TDDJOSFQ.js} +1 -1
  51. package/dist/{chunk-EMZFZCS4.js → chunk-TDRUVE4J.js} +1 -1
  52. package/dist/chunk-TFJAT263.js +2 -0
  53. package/dist/{chunk-PDXHRF4E.js → chunk-TL57YUJV.js} +1 -1
  54. package/dist/{chunk-QNSIBPWG.js → chunk-TZC4CYPD.js} +1 -1
  55. package/dist/{chunk-FG343JM3.js → chunk-U6AASXY3.js} +1 -1
  56. package/dist/{chunk-BDQTVYYF.js → chunk-UDNEOJWY.js} +1 -1
  57. package/dist/{chunk-PJ4RIUI3.js → chunk-UPJVMMDK.js} +1 -1
  58. package/dist/{chunk-Q7IDLOSP.js → chunk-V2G6E53W.js} +1 -1
  59. package/dist/{chunk-MYGVN6X4.js → chunk-VF54EOLZ.js} +1 -1
  60. package/dist/{chunk-KE5K3F7J.js → chunk-VFWQ2W4B.js} +1 -1
  61. package/dist/chunk-VZYNZS5U.js +1 -0
  62. package/dist/{chunk-DX6IPDED.js → chunk-WDLAPZPN.js} +1 -1
  63. package/dist/{chunk-AKCCNLHL.js → chunk-WM437XV6.js} +1 -1
  64. package/dist/chunk-WULEBQPI.js +1 -0
  65. package/dist/{chunk-CPDW7WW2.js → chunk-WWL4HNXM.js} +17 -17
  66. package/dist/{chunk-KGU2IW54.js → chunk-YSY25OGG.js} +1 -1
  67. package/dist/{chunk-WL34G6IR.js → chunk-YVEI7XR6.js} +1 -1
  68. package/dist/{chunk-YXMAGC53.js → chunk-YX2IGS72.js} +1 -1
  69. package/dist/chunk-Z7UN4R7T.js +1 -0
  70. package/dist/{chunk-TQM7MF5C.js → chunk-ZZZ7ECPT.js} +1 -1
  71. package/dist/commands/antigravity/backfill.js +1 -1
  72. package/dist/commands/auth/create-key.js +1 -1
  73. package/dist/commands/auth/login.js +1 -1
  74. package/dist/commands/auth/logout.js +1 -1
  75. package/dist/commands/auth/revoke-key.js +1 -1
  76. package/dist/commands/auth/signup.js +1 -1
  77. package/dist/commands/auth/status.js +1 -1
  78. package/dist/commands/capture/scope.js +1 -1
  79. package/dist/commands/catalog/index.js +1 -1
  80. package/dist/commands/catalog/recommend.js +1 -1
  81. package/dist/commands/crons/list.js +1 -1
  82. package/dist/commands/crons/run.js +1 -1
  83. package/dist/commands/dashboard.js +1 -1
  84. package/dist/commands/diagnostics.js +1 -1
  85. package/dist/commands/eval-targets/create.js +1 -1
  86. package/dist/commands/eval-targets/list.js +1 -1
  87. package/dist/commands/evals/agent.js +1 -1
  88. package/dist/commands/evals/auto-run.js +1 -1
  89. package/dist/commands/evals/benchmark.js +1 -1
  90. package/dist/commands/evals/compare.js +1 -1
  91. package/dist/commands/evals/create.js +1 -1
  92. package/dist/commands/evals/optimize-description.js +1 -1
  93. package/dist/commands/evals/optimize.js +1 -1
  94. package/dist/commands/evals/refine-cases.js +1 -1
  95. package/dist/commands/evals/run.js +1 -1
  96. package/dist/commands/evals/validate-judge.js +1 -1
  97. package/dist/commands/experiments/list.js +1 -1
  98. package/dist/commands/gateway/ensure.js +1 -1
  99. package/dist/commands/hooks/install.js +1 -1
  100. package/dist/commands/hooks/run.js +1 -1
  101. package/dist/commands/hooks/uninstall.js +1 -1
  102. package/dist/commands/instructions/create.js +1 -1
  103. package/dist/commands/instructions/dedupe.js +1 -1
  104. package/dist/commands/instructions/delete.js +1 -1
  105. package/dist/commands/instructions/fork.js +1 -1
  106. package/dist/commands/instructions/get.js +1 -1
  107. package/dist/commands/instructions/list.js +1 -1
  108. package/dist/commands/instructions/promote.js +1 -1
  109. package/dist/commands/instructions/pull.js +1 -1
  110. package/dist/commands/instructions/restore.js +1 -1
  111. package/dist/commands/instructions/retract.js +1 -1
  112. package/dist/commands/instructions/upstream.js +1 -1
  113. package/dist/commands/instructions/versions.js +1 -1
  114. package/dist/commands/launcher.js +1 -1
  115. package/dist/commands/local/down.js +1 -1
  116. package/dist/commands/local/up.js +1 -1
  117. package/dist/commands/org/current.js +1 -1
  118. package/dist/commands/org/list.js +1 -1
  119. package/dist/commands/org/switch.js +1 -1
  120. package/dist/commands/packs/add-instruction.js +1 -1
  121. package/dist/commands/packs/apply.js +1 -1
  122. package/dist/commands/packs/create.js +1 -1
  123. package/dist/commands/packs/fork.js +1 -1
  124. package/dist/commands/packs/get.js +1 -1
  125. package/dist/commands/packs/list.js +1 -1
  126. package/dist/commands/packs/remove-instruction.js +1 -1
  127. package/dist/commands/proxy/env.js +1 -1
  128. package/dist/commands/proxy/logs.js +1 -1
  129. package/dist/commands/proxy/restart.js +1 -1
  130. package/dist/commands/proxy/setup.js +1 -1
  131. package/dist/commands/proxy/start.js +1 -1
  132. package/dist/commands/proxy/status.js +1 -1
  133. package/dist/commands/proxy/stop.js +1 -1
  134. package/dist/commands/research/backfill.js +1 -1
  135. package/dist/commands/research/resume-scoped-outcomes.js +1 -1
  136. package/dist/commands/research/tail-transcript.js +1 -1
  137. package/dist/commands/service/install.js +1 -1
  138. package/dist/commands/service/status.js +1 -1
  139. package/dist/commands/service/uninstall.js +1 -1
  140. package/dist/commands/sessions/analyze.js +1 -1
  141. package/dist/commands/sessions/delete.js +1 -1
  142. package/dist/commands/sessions/end.js +1 -1
  143. package/dist/commands/sessions/import.js +1 -1
  144. package/dist/commands/sessions/list.js +1 -1
  145. package/dist/commands/sessions/start.js +1 -1
  146. package/dist/commands/setup.js +1 -1
  147. package/dist/commands/skills/export-approved.js +1 -1
  148. package/dist/commands/skills/install.js +1 -1
  149. package/dist/commands/skills/list.js +1 -1
  150. package/dist/commands/skills/publish.js +1 -1
  151. package/dist/commands/skills/search.js +1 -1
  152. package/dist/commands/skills/update.js +1 -1
  153. package/dist/commands/suggestions/accept.js +1 -1
  154. package/dist/commands/suggestions/auto.js +1 -1
  155. package/dist/commands/suggestions/dismiss.js +1 -1
  156. package/dist/commands/suggestions/list.js +1 -1
  157. package/dist/commands/suggestions/refresh.js +1 -1
  158. package/dist/commands/suggestions/undo.js +1 -1
  159. package/dist/dashboard/Dashboard.js +1 -1
  160. package/dist/dashboard/data.js +1 -1
  161. package/dist/dashboard/launcher/LauncherOverlay.js +1 -1
  162. package/dist/dashboard/launcher/api.js +1 -1
  163. package/dist/dashboard/launcher/useLaunchJobs.js +1 -1
  164. package/dist/dashboard/panels/measurement.js +1 -1
  165. package/dist/{dist-5647V2E7.js → dist-WGZCHQTC.js} +1 -1
  166. package/dist/lib/active-org-refresh.js +1 -1
  167. package/dist/lib/actor-env.js +1 -0
  168. package/dist/lib/agent-loop.js +1 -1
  169. package/dist/lib/agent-presence.js +1 -1
  170. package/dist/lib/antigravity-transcript.js +1 -1
  171. package/dist/lib/api-client.js +1 -1
  172. package/dist/lib/codex-exec.js +1 -1
  173. package/dist/lib/ensure-api-key.js +1 -1
  174. package/dist/lib/ensure-fresh-token.js +1 -1
  175. package/dist/lib/eval-analyzer.js +1 -1
  176. package/dist/lib/eval-benchmark.js +1 -1
  177. package/dist/lib/eval-candidate-run.js +1 -1
  178. package/dist/lib/eval-case-generator.js +1 -1
  179. package/dist/lib/eval-conversation-handler.js +1 -1
  180. package/dist/lib/eval-executor.js +1 -1
  181. package/dist/lib/eval-grader.js +1 -1
  182. package/dist/lib/eval-meta-judge.js +1 -1
  183. package/dist/lib/eval-resume.js +1 -1
  184. package/dist/lib/eval-run-batch.js +1 -1
  185. package/dist/lib/eval-trigger-tester.js +1 -1
  186. package/dist/lib/evolution-enrolment.js +1 -1
  187. package/dist/lib/insights/nomination/nominate.js +1 -1
  188. package/dist/lib/instruction-proposer.js +1 -1
  189. package/dist/lib/instruction-restoration.js +1 -1
  190. package/dist/lib/instructions/acceptance/accept-events.js +1 -1
  191. package/dist/lib/instructions/acceptance/accept-hook.js +1 -1
  192. package/dist/lib/instructions/acceptance/reverse-applications.js +1 -1
  193. package/dist/lib/instructions/acceptance/suggestion-accept.js +1 -1
  194. package/dist/lib/jobs/handlers/cron-auto-accept-suggestions.js +1 -1
  195. package/dist/lib/jobs/handlers/cron-eval-autorun.js +1 -1
  196. package/dist/lib/jobs/handlers/cron-instruction-evolution.js +1 -1
  197. package/dist/lib/jobs/handlers/cron-instruction-training.js +1 -1
  198. package/dist/lib/jobs/handlers/cron-reconcile-attribution.js +1 -1
  199. package/dist/lib/jobs/handlers/cron-refine-cases.js +1 -1
  200. package/dist/lib/jobs/handlers/cron-refresh-pricing.js +1 -1
  201. package/dist/lib/jobs/handlers/cron-retire-unused-skills.js +1 -1
  202. package/dist/lib/jobs/handlers/cron-suggest-instructions.js +1 -1
  203. package/dist/lib/jobs/handlers/distill-memories.js +1 -1
  204. package/dist/lib/jobs/handlers/finalize-scoped-launch.js +1 -1
  205. package/dist/lib/jobs/handlers/prepare-suggestion-live.js +1 -1
  206. package/dist/lib/jobs/handlers/process-conversation.js +1 -1
  207. package/dist/lib/jobs/handlers/process-eval.js +1 -1
  208. package/dist/lib/jobs/handlers/process-insights.js +1 -1
  209. package/dist/lib/jobs/handlers/process-judge-review.js +1 -1
  210. package/dist/lib/jobs/handlers/process-launch.js +1 -1
  211. package/dist/lib/jobs/handlers/process-memory-ab.js +1 -1
  212. package/dist/lib/jobs/handlers/process-run-cleanup.js +1 -1
  213. package/dist/lib/jobs/handlers/process-session-goal.js +1 -1
  214. package/dist/lib/jobs/handlers/process-suggestion-eval.js +1 -1
  215. package/dist/lib/jobs/shed-retry.js +1 -1
  216. package/dist/lib/judge-review-runner.js +1 -1
  217. package/dist/lib/llm-client.js +1 -1
  218. package/dist/lib/manual-tasks.js +1 -1
  219. package/dist/lib/measurement-llm.js +1 -1
  220. package/dist/lib/projects/workspace/eval-workspace.js +1 -1
  221. package/dist/lib/projects/workspace/worktree.js +1 -1
  222. package/dist/lib/refine-cases.js +1 -1
  223. package/dist/lib/repository-capabilities.js +1 -0
  224. package/dist/lib/research-client.js +1 -1
  225. package/dist/lib/setup-steps.js +1 -1
  226. package/dist/lib/telemetry.js +1 -1
  227. package/dist/lib/terminal-target-heartbeat.js +1 -1
  228. package/dist/lib/work-report.js +1 -1
  229. package/oclif.manifest.json +1 -1
  230. package/package.json +6 -6
  231. package/dist/chunk-2PO5I3XR.js +0 -1
  232. package/dist/chunk-3MYCWZ63.js +0 -1
  233. package/dist/chunk-4GOXEEXZ.js +0 -1
  234. package/dist/chunk-CDSSOOIG.js +0 -1
  235. package/dist/chunk-FCALFMZV.js +0 -1
  236. package/dist/chunk-GIXHG5FK.js +0 -1
  237. package/dist/chunk-JNLDISBA.js +0 -4
  238. package/dist/chunk-SWSOEYC7.js +0 -1
  239. package/dist/chunk-ZLBYYLJZ.js +0 -3
@@ -1 +1 @@
1
- import{a as E}from"./chunk-DQYYHX6K.js";import{a as I}from"./chunk-RBSEE2Z6.js";import{a as w}from"./chunk-M7QSC64D.js";import{c as v,e as h}from"./chunk-FADINV4H.js";import{b as R}from"./chunk-SWSOEYC7.js";import{e as m}from"./chunk-GIXHG5FK.js";import{a as d}from"./chunk-ZLLER3HP.js";var T=6e5;async function P(e,$){let i=d(n=>$?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:r}=e,k=e.measurement?v(e):{},o=await m(`/api/eval-targets/${r}/judge-calibration`),l=!e.measurement||o.methodology?.measurement?.engine===e.measurement.engine&&o.methodology.measurement.model===e.measurement.model&&o.methodology.current===R(e.measurement.engine),a=I({powered:l&&o.powerCheck.powered,mde:l?o.powerCheck.mde??Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY},(l?o.caseDiscrimination:void 0)??{total:0,discriminating:0,nonDiscriminating:0,unpaired:0},{runsCompleted:0,maxRuns:e.maxRuns??24,batchesRun:0,maxBatches:1});if(a.action==="stop")return i(`[cron_eval_autorun] ${r}: ${a.reason}`),{skipped:a.code,reason:a.reason};let t=await m(`/api/eval-targets/${r}`);if(t.metadata?.autoRunEnabled===!1)return{skipped:"paused",reason:"Nightly measurement is off for this target."};let c=w(t);if(c)return i(`[cron_eval_autorun] ${r}: ${c.reason}`),c;let p=(await m(`/api/eval-targets/${r}/evals`)).filter(n=>!n.retiredAt);if(p.length===0)return{skipped:"no-live-cases"};let{completed:f,failed:b,results:N}=await h({cases:E(p,e.maxRuns??12),targetContent:t.content,concurrency:2,runNumber:Math.floor(Date.now()/1e3),opts:{targetId:r,targetVersion:t.version??1,iteration:1,timeout:e.timeout??T,model:e.model,graderModel:e.graderModel,graderEngine:e.graderEngine,...k,skipGrading:!1,targetType:t.type,targetName:t.name},onLog:i}),g={};for(let n of N){if(n.status!=="failed")continue;let s=n.failure?.kind??"unknown";g[s]=(g[s]??0)+1}let u=Object.entries(g).sort(([,n],[,s])=>s-n).map(([n,s])=>`${n}x${s}`).join(", ");return i(`[cron_eval_autorun] ${t.name}: ${f} completed, ${b} failed`+(u===""?"":` (${u})`)),{ranRuns:f,failedRuns:b,...u===""?{}:{failures:u},reason:a.reason}}d(P,"cronEvalAutorun");export{P as a};
1
+ import{a as E}from"./chunk-DQYYHX6K.js";import{a as I}from"./chunk-RBSEE2Z6.js";import{a as w}from"./chunk-M7QSC64D.js";import{c as v,e as h}from"./chunk-AXTEV56C.js";import{b as R}from"./chunk-VZYNZS5U.js";import{e as m}from"./chunk-Z7UN4R7T.js";import{a as d}from"./chunk-ZLLER3HP.js";var T=6e5;async function P(e,$){let i=d(n=>$?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:r}=e,k=e.measurement?v(e):{},o=await m(`/api/eval-targets/${r}/judge-calibration`),l=!e.measurement||o.methodology?.measurement?.engine===e.measurement.engine&&o.methodology.measurement.model===e.measurement.model&&o.methodology.current===R(e.measurement.engine),a=I({powered:l&&o.powerCheck.powered,mde:l?o.powerCheck.mde??Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY},(l?o.caseDiscrimination:void 0)??{total:0,discriminating:0,nonDiscriminating:0,unpaired:0},{runsCompleted:0,maxRuns:e.maxRuns??24,batchesRun:0,maxBatches:1});if(a.action==="stop")return i(`[cron_eval_autorun] ${r}: ${a.reason}`),{skipped:a.code,reason:a.reason};let t=await m(`/api/eval-targets/${r}`);if(t.metadata?.autoRunEnabled===!1)return{skipped:"paused",reason:"Nightly measurement is off for this target."};let c=w(t);if(c)return i(`[cron_eval_autorun] ${r}: ${c.reason}`),c;let p=(await m(`/api/eval-targets/${r}/evals`)).filter(n=>!n.retiredAt);if(p.length===0)return{skipped:"no-live-cases"};let{completed:f,failed:b,results:N}=await h({cases:E(p,e.maxRuns??12),targetContent:t.content,concurrency:2,runNumber:Math.floor(Date.now()/1e3),opts:{targetId:r,targetVersion:t.version??1,iteration:1,timeout:e.timeout??T,model:e.model,graderModel:e.graderModel,graderEngine:e.graderEngine,...k,skipGrading:!1,targetType:t.type,targetName:t.name},onLog:i}),g={};for(let n of N){if(n.status!=="failed")continue;let s=n.failure?.kind??"unknown";g[s]=(g[s]??0)+1}let u=Object.entries(g).sort(([,n],[,s])=>s-n).map(([n,s])=>`${n}x${s}`).join(", ");return i(`[cron_eval_autorun] ${t.name}: ${f} completed, ${b} failed`+(u===""?"":` (${u})`)),{ranRuns:f,failedRuns:b,...u===""?{}:{failures:u},reason:a.reason}}d(P,"cronEvalAutorun");export{P as a};
@@ -1,4 +1,4 @@
1
- import{a as c,c as d}from"./chunk-IZTIYR5Q.js";import{d as u}from"./chunk-WL5ZWQAS.js";import{a}from"./chunk-KEVDLLHT.js";import{a as n}from"./chunk-DX6IPDED.js";import{b as i}from"./chunk-GIXHG5FK.js";import{g as r}from"./chunk-PZNWH4VQ.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(`
1
+ import{a as c,c as d}from"./chunk-IZTIYR5Q.js";import{d as u}from"./chunk-TDDJOSFQ.js";import{a}from"./chunk-433HK3QQ.js";import{a as n}from"./chunk-WDLAPZPN.js";import{b as i}from"./chunk-Z7UN4R7T.js";import{g as r}from"./chunk-PZNWH4VQ.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};
@@ -0,0 +1,3 @@
1
+ import{h as R}from"./chunk-R7URROQD.js";import{h as _}from"./chunk-3IAZMJA4.js";import{a as $,b as E,c as v,f as w,g as P}from"./chunk-SIGZEQ3K.js";import{e as y,f}from"./chunk-Z7UN4R7T.js";import{a as c}from"./chunk-ZLLER3HP.js";import{execFileSync as A}from"node:child_process";import{openSync as x,readSync as C,closeSync as M,readFileSync as O}from"node:fs";var T=12e4,j=3e4;function B(l){let t;try{t=x(l,"r");let o=Buffer.alloc(64*1024),a=C(t,o,0,o.length,0),i=o.subarray(0,a).toString("utf-8");for(let s of i.split(`
2
+ `))if(s.startsWith("{"))try{let n=JSON.parse(s).cwd;if(typeof n=="string"&&n.startsWith("/"))return n}catch{}return null}catch{return null}finally{t!==void 0&&M(t)}}c(B,"readTranscriptCwd");function D(l){let t=c(s=>{try{return A("git",["-C",l,...s],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()||null}catch{return null}},"git");if(!t(["rev-parse","--show-toplevel"]))return null;let a=t(["rev-parse","--git-dir"]),i=t(["rev-parse","--git-common-dir"]);return{gitRemote:t(["remote","get-url","origin"]),gitRootCommit:t(["rev-list","--max-parents=0","HEAD"])?.split(`
3
+ `).pop()?.trim()??null,gitBranch:t(["branch","--show-current"]),isWorktree:!!a&&!!i&&a!==i}}c(D,"gitAnchors");async function L(l,t,o=E(D,B)){let a=Math.min(l.limit??200,1e3),i=!1;try{let e=await _(r=>t.logger.info(r),{signal:t.leaseSignal,sweepBudgetMs:T,requestTimeoutMs:j});e.scanned>0&&t.logger.info(`scoped outcomes: scanned=${e.scanned} delivered=${e.delivered} failed=${e.failed} unmeasured=${e.unmeasured} pending=${e.pending} deferred=${e.deferred} stop=${e.stopReason}`),i=e.stopReason==="lease_lost"}catch(e){t.logger.info(`scoped outcome resume sweep failed: ${e.message}`),i=!!t.leaseSignal?.aborted}if(i)return t.logger.warn("lease lost during scoped outcome resume; attribution repair skipped for this claim"),{scanned:0,repaired:0,reimported:0,unrepairable:0,remaining:0};let s=await R(()=>y(`/api/sessions/unattributed?limit=${a}`),{log:c(e=>t.logger.info(e),"log"),label:"sessions/unattributed",idempotent:!0}),n=s.sessions??[],b=s.total??n.length;if(n.length===0)return t.logger.info("no unattributed sessions"),{scanned:0,repaired:0,reimported:0,unrepairable:0,remaining:0};let m=0,g=0,d=0;for(let e of n){if(!e.externalSessionId){d++;continue}let r=P(e,o);if(!r){d++;continue}try{await f("/api/sessions",{tool:e.tool,externalSessionId:e.externalSessionId,projectPath:r.projectPath,...r.gitBranch?{gitBranch:r.gitBranch}:{},metadata:{...r.gitRemote?{gitRemote:r.gitRemote}:{},...r.gitRootCommit?{gitRootCommit:r.gitRootCommit}:{},isWorktree:r.isWorktree,reconciledAttribution:!0}}),m++}catch(u){d++,t.logger.info(`reconcile failed for ${e.externalSessionId}: ${u.message}`);continue}let p=e.tool==="claude_code"?v(e.externalSessionId,o):null,S=w({tool:e.tool,pathWasJunk:!!e.projectPath&&$(e.projectPath),endedAt:e.endedAt??null,transcript:p?o.stat(p):null});if(S.reimport&&p)try{let u=O(p,"utf-8");await f(`/api/sessions/${e.id}/reimport`,{content:u,tool:"claude_code"}),g++}catch(u){t.logger.info(`reimport failed for ${e.externalSessionId} (${S.reason}): ${u.message}`)}}let h=b-m;return t.logger.info(`reconciled attribution: scanned=${n.length} repaired=${m} reimported=${g} unrepairable=${d} remaining=${h} (of ${b} total)`),{scanned:n.length,repaired:m,reimported:g,unrepairable:d,remaining:h}}c(L,"cronReconcileAttribution");export{L as a};
@@ -1 +1 @@
1
- import{b as $}from"./chunk-KFNFLMUR.js";import{e as w,f as k}from"./chunk-GIXHG5FK.js";import{a as u}from"./chunk-ZLLER3HP.js";function h(e){if(e.length===0)return{mean:0,stddev:0,min:0,max:0};let n=e.reduce((s,a)=>s+a,0)/e.length,o=e.reduce((s,a)=>s+(a-n)**2,0)/e.length;return{mean:Math.round(n*1e3)/1e3,stddev:Math.round(Math.sqrt(o)*1e3)/1e3,min:Math.min(...e),max:Math.max(...e)}}u(h,"computeStats");var x="with_target",E="without_target";function _(e){let n=e.grading.summary?.pass_rate;return typeof n=="number"&&n>=1}u(_,"fullPass");function b(e){return e.grading.summary?.pass_rate!=null}u(b,"hasGrading");function R(e){let n=e.timing.total_tokens;return typeof n=="number"&&n>0?n:void 0}u(R,"tokensOf");function v(e){let n=e.timing.duration_ms;return typeof n=="number"&&!isNaN(n)?n/1e3:void 0}u(v,"secondsOf");function y(e,n){let o={};for(let s of e)(o[n(s)]??=[]).push(s);return o}u(y,"groupBy");function C(e,n){let o=y(e.filter(b),i=>i.evalId),s=y(n.filter(b),i=>i.evalId),a=u((i,l)=>i.runNumber-l.runNumber,"byRun"),t=[];for(let i of Object.keys(o)){let l=o[i].sort(a),d=(s[i]??[]).sort(a);for(let r=0;r<Math.min(l.length,d.length);r++){let c={withScore:_(l[r])?1:0,withoutScore:_(d[r])?1:0},f=R(l[r]),g=R(d[r]);f!=null&&g!=null&&(c.withCost=f,c.withoutCost=g);let p=v(l[r]),m=v(d[r]);p!=null&&m!=null&&(c.withLatency=p,c.withoutLatency=m),t.push(c)}}return t}u(C,"pairRunsByEval");function T(e){let n=e.filter(r=>r.status==="completed");if(n.length===0)return{runSummary:{},verdict:null,notes:["No completed runs found"],totalRuns:0};let o=y(n,r=>r.configuration),s={},a=[];for(let[r,c]of Object.entries(o)){let f=c.filter(b).map(m=>m.grading.summary.pass_rate),g=c.map(v).filter(m=>m!=null),p=c.map(R).filter(m=>m!=null);s[r]={},f.length>0&&(s[r].pass_rate=h(f)),g.length>0&&(s[r].time_seconds=h(g)),p.length>0&&(s[r].tokens=h(p))}let t=null,i=o[x]??[],l=o[E]??[],d=C(i,l);if(d.length>0){if(t=$(d),!t.sufficient)a.push(t.insufficientReason??"Insufficient data for a significance verdict.");else if(t.significant){let r=t.delta>=0?"improves":"reduces",c=t.pValue!=null?`, McNemar p=${t.pValue.toFixed(4)}`:"";a.push(`Target ${r} the pass rate by ${Math.abs(t.delta*100).toFixed(0)}% (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}${c}).`)}else a.push(`No significant effect on pass rate (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}).`);t.costDelta!=null&&Math.round(t.costDelta)!==0&&a.push(`Token cost delta: ${t.costDelta>=0?"+":""}${Math.round(t.costDelta)} tokens/task.`),t.latencyDelta!=null&&Math.abs(t.latencyDelta)>1&&a.push(`Target ${t.latencyDelta>0?"adds":"saves"} ${Math.abs(t.latencyDelta).toFixed(1)}s/task.`)}for(let r of Object.values(s))if(r.pass_rate&&r.pass_rate.stddev>.2){a.push(`High pass-rate variance (stddev=${r.pass_rate.stddev.toFixed(2)}) \u2014 results may be unreliable.`);break}return{runSummary:s,verdict:t,notes:a,totalRuns:n.length}}u(T,"summarizeRuns");async function S(e,n){let o=n?`&iteration=${n}`:"",s=100,a=[];for(let t=0;t<1e5;t+=s){let i=await w(`/api/eval-targets/${e}/runs?limit=${s}&offset=${t}&activeCasesOnly=1${o}`);if(a.push(...i),i.length<s)break}return T(a)}u(S,"aggregateBenchmark");async function B(e,n,o){return k(`/api/eval-targets/${e}/benchmarks`,{iteration:n,runSummary:o.runSummary,notes:o.notes})}u(B,"postBenchmark");export{T as a,S as b,B as c};
1
+ import{b as $}from"./chunk-KFNFLMUR.js";import{e as w,f as k}from"./chunk-Z7UN4R7T.js";import{a as u}from"./chunk-ZLLER3HP.js";function h(e){if(e.length===0)return{mean:0,stddev:0,min:0,max:0};let n=e.reduce((s,a)=>s+a,0)/e.length,o=e.reduce((s,a)=>s+(a-n)**2,0)/e.length;return{mean:Math.round(n*1e3)/1e3,stddev:Math.round(Math.sqrt(o)*1e3)/1e3,min:Math.min(...e),max:Math.max(...e)}}u(h,"computeStats");var x="with_target",E="without_target";function _(e){let n=e.grading.summary?.pass_rate;return typeof n=="number"&&n>=1}u(_,"fullPass");function b(e){return e.grading.summary?.pass_rate!=null}u(b,"hasGrading");function R(e){let n=e.timing.total_tokens;return typeof n=="number"&&n>0?n:void 0}u(R,"tokensOf");function v(e){let n=e.timing.duration_ms;return typeof n=="number"&&!isNaN(n)?n/1e3:void 0}u(v,"secondsOf");function y(e,n){let o={};for(let s of e)(o[n(s)]??=[]).push(s);return o}u(y,"groupBy");function C(e,n){let o=y(e.filter(b),i=>i.evalId),s=y(n.filter(b),i=>i.evalId),a=u((i,l)=>i.runNumber-l.runNumber,"byRun"),t=[];for(let i of Object.keys(o)){let l=o[i].sort(a),d=(s[i]??[]).sort(a);for(let r=0;r<Math.min(l.length,d.length);r++){let c={withScore:_(l[r])?1:0,withoutScore:_(d[r])?1:0},f=R(l[r]),g=R(d[r]);f!=null&&g!=null&&(c.withCost=f,c.withoutCost=g);let p=v(l[r]),m=v(d[r]);p!=null&&m!=null&&(c.withLatency=p,c.withoutLatency=m),t.push(c)}}return t}u(C,"pairRunsByEval");function T(e){let n=e.filter(r=>r.status==="completed");if(n.length===0)return{runSummary:{},verdict:null,notes:["No completed runs found"],totalRuns:0};let o=y(n,r=>r.configuration),s={},a=[];for(let[r,c]of Object.entries(o)){let f=c.filter(b).map(m=>m.grading.summary.pass_rate),g=c.map(v).filter(m=>m!=null),p=c.map(R).filter(m=>m!=null);s[r]={},f.length>0&&(s[r].pass_rate=h(f)),g.length>0&&(s[r].time_seconds=h(g)),p.length>0&&(s[r].tokens=h(p))}let t=null,i=o[x]??[],l=o[E]??[],d=C(i,l);if(d.length>0){if(t=$(d),!t.sufficient)a.push(t.insufficientReason??"Insufficient data for a significance verdict.");else if(t.significant){let r=t.delta>=0?"improves":"reduces",c=t.pValue!=null?`, McNemar p=${t.pValue.toFixed(4)}`:"";a.push(`Target ${r} the pass rate by ${Math.abs(t.delta*100).toFixed(0)}% (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}${c}).`)}else a.push(`No significant effect on pass rate (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}).`);t.costDelta!=null&&Math.round(t.costDelta)!==0&&a.push(`Token cost delta: ${t.costDelta>=0?"+":""}${Math.round(t.costDelta)} tokens/task.`),t.latencyDelta!=null&&Math.abs(t.latencyDelta)>1&&a.push(`Target ${t.latencyDelta>0?"adds":"saves"} ${Math.abs(t.latencyDelta).toFixed(1)}s/task.`)}for(let r of Object.values(s))if(r.pass_rate&&r.pass_rate.stddev>.2){a.push(`High pass-rate variance (stddev=${r.pass_rate.stddev.toFixed(2)}) \u2014 results may be unreliable.`);break}return{runSummary:s,verdict:t,notes:a,totalRuns:n.length}}u(T,"summarizeRuns");async function S(e,n){let o=n?`&iteration=${n}`:"",s=100,a=[];for(let t=0;t<1e5;t+=s){let i=await w(`/api/eval-targets/${e}/runs?limit=${s}&offset=${t}&activeCasesOnly=1${o}`);if(a.push(...i),i.length<s)break}return T(a)}u(S,"aggregateBenchmark");async function B(e,n,o){return k(`/api/eval-targets/${e}/benchmarks`,{iteration:n,runSummary:o.runSummary,notes:o.notes})}u(B,"postBenchmark");export{T as a,S as b,B as c};
@@ -1 +1 @@
1
- import{b as m}from"./chunk-65LFPUDB.js";import{a as g}from"./chunk-ZLLER3HP.js";var p=5;function b(t){let r=g((e,f)=>({retire:[],survivingCases:0,replacementsRequired:!1,refused:e,summary:f}),"none");if(!t||t.cases.length===0&&t.unpairedCases.length===0)return r("no-discrimination-data","No case-discrimination data yet \u2014 the target needs runs in BOTH cohorts before any case can be judged dead.");let c=[...t.cases.filter(e=>!e.discriminating).map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate,withoutPassRate:e.withoutPassRate,reason:e.note}})),...t.unpairedCases.map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate??0,withoutPassRate:e.withoutPassRate,reason:"runs in only one cohort (no with-vs-without comparison possible)"}}))];if(c.length===0)return r("all-discriminating","Every case discriminates \u2014 nothing to retire.");let s=new Map(t.cases.map(e=>[e.evalId,e.separation])),o=[...c].sort((e,f)=>(s.get(e.evalId)??-1)-(s.get(f.evalId)??-1)).slice(0,p),u=c.length-o.length,d=t.total+t.unpaired,l=d-o.length,i=l<m,n=`${o.length} of ${d} live case(s) carry no treatment signal`+(u>0?` (${u} more over the ${p}-per-run cap)`:"")+(i?`; retiring them leaves ${l}, below the ${m}-case evolution floor, so replacements must be generated first`:"");return{retire:o,survivingCases:l,replacementsRequired:i,refused:null,summary:n}}g(b,"planCaseRefinement");async function v(t,r){let h=r.log??(()=>{}),c=g((n,e)=>({retired:0,generated:0,skipped:n,summary:e,retiredNames:[],generatedNames:[]}),"empty");if(t.refused)return c(t.refused,t.summary);let s=await r.generate(t.retire.map(n=>n.feedback)),a=[];for(let n of s??[]){let e=await r.createCase(n);a.push(e.name),h(` + ${e.name} (${e.id})`)}let o=t.survivingCases+t.retire.length+a.length,u=Math.max(0,o-m),d=t.retire.slice(0,Math.min(t.retire.length,u)),l=t.retire.length-d.length;if(d.length===0)return{retired:0,generated:a.length,skipped:s===null?"no-llm-backend":"no-replacements-generated",summary:`${t.summary}. `+(s===null?"No local LLM backend available, so nothing was retired":`The generator produced ${a.length} usable replacement(s), not enough to retire anything`)+` \u2014 dropping below the ${m}-case floor would silently disenrol the target from the nightly loop.`,retiredNames:[],generatedNames:a};let i=[];for(let n of d)await r.retireCase(n.evalId,n.feedback.reason),i.push(n.name),h(` retired ${n.name}`);return{retired:i.length,generated:a.length,skipped:null,summary:`Retired ${i.length} non-discriminating case(s), added ${a.length} replacement(s)`+(l>0?`; held ${l} back to stay at the ${m}-case floor (they remain condemned and will be retired once replacements exist)`:"")+". The replacements have no runs yet \u2014 the next autorun batch builds their depth.",retiredNames:i,generatedNames:a}}g(v,"executeCaseRefinement");export{p as a,b,v as c};
1
+ import{b as m}from"./chunk-52OHAULM.js";import{a as g}from"./chunk-ZLLER3HP.js";var p=5;function b(t){let r=g((e,f)=>({retire:[],survivingCases:0,replacementsRequired:!1,refused:e,summary:f}),"none");if(!t||t.cases.length===0&&t.unpairedCases.length===0)return r("no-discrimination-data","No case-discrimination data yet \u2014 the target needs runs in BOTH cohorts before any case can be judged dead.");let c=[...t.cases.filter(e=>!e.discriminating).map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate,withoutPassRate:e.withoutPassRate,reason:e.note}})),...t.unpairedCases.map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate??0,withoutPassRate:e.withoutPassRate,reason:"runs in only one cohort (no with-vs-without comparison possible)"}}))];if(c.length===0)return r("all-discriminating","Every case discriminates \u2014 nothing to retire.");let s=new Map(t.cases.map(e=>[e.evalId,e.separation])),o=[...c].sort((e,f)=>(s.get(e.evalId)??-1)-(s.get(f.evalId)??-1)).slice(0,p),u=c.length-o.length,d=t.total+t.unpaired,l=d-o.length,i=l<m,n=`${o.length} of ${d} live case(s) carry no treatment signal`+(u>0?` (${u} more over the ${p}-per-run cap)`:"")+(i?`; retiring them leaves ${l}, below the ${m}-case evolution floor, so replacements must be generated first`:"");return{retire:o,survivingCases:l,replacementsRequired:i,refused:null,summary:n}}g(b,"planCaseRefinement");async function v(t,r){let h=r.log??(()=>{}),c=g((n,e)=>({retired:0,generated:0,skipped:n,summary:e,retiredNames:[],generatedNames:[]}),"empty");if(t.refused)return c(t.refused,t.summary);let s=await r.generate(t.retire.map(n=>n.feedback)),a=[];for(let n of s??[]){let e=await r.createCase(n);a.push(e.name),h(` + ${e.name} (${e.id})`)}let o=t.survivingCases+t.retire.length+a.length,u=Math.max(0,o-m),d=t.retire.slice(0,Math.min(t.retire.length,u)),l=t.retire.length-d.length;if(d.length===0)return{retired:0,generated:a.length,skipped:s===null?"no-llm-backend":"no-replacements-generated",summary:`${t.summary}. `+(s===null?"No local LLM backend available, so nothing was retired":`The generator produced ${a.length} usable replacement(s), not enough to retire anything`)+` \u2014 dropping below the ${m}-case floor would silently disenrol the target from the nightly loop.`,retiredNames:[],generatedNames:a};let i=[];for(let n of d)await r.retireCase(n.evalId,n.feedback.reason),i.push(n.name),h(` retired ${n.name}`);return{retired:i.length,generated:a.length,skipped:null,summary:`Retired ${i.length} non-discriminating case(s), added ${a.length} replacement(s)`+(l>0?`; held ${l} back to stay at the ${m}-case floor (they remain condemned and will be retired once replacements exist)`:"")+". The replacements have no runs yet \u2014 the next autorun batch builds their depth.",retiredNames:i,generatedNames:a}}g(v,"executeCaseRefinement");export{p as a,b,v as c};
@@ -1 +1 @@
1
- import{b as i}from"./chunk-GIXHG5FK.js";import{a as n}from"./chunk-ZLLER3HP.js";var d=new Set([408,429,502,503,504]),R=new Set([500]),l=6e4,_=1e3,h=8e3;function T(e){return e instanceof i&&d.has(e.statusCode)}n(T,"isShedError");function w(e){return e instanceof i&&R.has(e.statusCode)}n(w,"isRetryableServerError");async function g(e,r={}){let m=r.budgetMs??l,u=r.sleep??(o=>new Promise(t=>setTimeout(t,o))),S=Date.now()+m,s=_;for(let o=1;;o++)try{return await e()}catch(t){let a=S-Date.now(),E=r.idempotent===!0&&w(t);if(!T(t)&&!E||a<=0)throw t;let p=t.statusCode,c=Math.min(s,a);r.log?.(`[shed-retry] ${r.label??"api call"} ${E?"hit a server error":"shed"} with ${p} (${t.message}) \u2014 attempt ${o}, retrying in ${c}ms`),await u(c),s=Math.min(s*2,h)}}n(g,"withShedRetry");export{d as a,R as b,l as c,_ as d,h as e,T as f,w as g,g as h};
1
+ import{b as i}from"./chunk-Z7UN4R7T.js";import{a as n}from"./chunk-ZLLER3HP.js";var d=new Set([408,429,502,503,504]),R=new Set([500]),l=6e4,_=1e3,h=8e3;function T(e){return e instanceof i&&d.has(e.statusCode)}n(T,"isShedError");function w(e){return e instanceof i&&R.has(e.statusCode)}n(w,"isRetryableServerError");async function g(e,r={}){let m=r.budgetMs??l,u=r.sleep??(o=>new Promise(t=>setTimeout(t,o))),S=Date.now()+m,s=_;for(let o=1;;o++)try{return await e()}catch(t){let a=S-Date.now(),E=r.idempotent===!0&&w(t);if(!T(t)&&!E||a<=0)throw t;let p=t.statusCode,c=Math.min(s,a);r.log?.(`[shed-retry] ${r.label??"api call"} ${E?"hit a server error":"shed"} with ${p} (${t.message}) \u2014 attempt ${o}, retrying in ${c}ms`),await u(c),s=Math.min(s*2,h)}}n(g,"withShedRetry");export{d as a,R as b,l as c,_ as d,h as e,T as f,w as g,g as h};
@@ -1 +1 @@
1
- import{c as X}from"./chunk-HOQPVOMF.js";import{b as D}from"./chunk-GIRPEMTW.js";import{a as x}from"./chunk-MODXEGCU.js";import{e as J,g as B}from"./chunk-DHIEGG4T.js";import{e as w,f as R}from"./chunk-GIXHG5FK.js";import{c as H,d as U}from"./chunk-X6CF5KTW.js";import{a as u}from"./chunk-ZLLER3HP.js";import{readFileSync as q,realpathSync as V}from"node:fs";import y from"node:path";import A from"node:os";function Q(s){let n=y.resolve(s);if(n===y.resolve(A.homedir()))return!1;let a=y.parse(n).root;if(n===a)return!1;try{let o=V(A.tmpdir());if(V(n)===o)return!1}catch{}return!0}u(Q,"isScorableProjectPath");var Z=5,ee=Number(process.env.RULEMETRIC_MAX_SUGGESTION_PROJECTS??10),te=48,ne=.5,O=400,oe=3,re=.6,se=1;function ae(s){let n=s.bloated??[],a=new Set([...s.harmful.map(o=>o.id),...s.candidates.map(o=>o.id)]);return n.filter(o=>!a.has(o.id)).slice(0,se).map(o=>({instructionId:o.id,estimatedTokens:o.estimatedTokens,topProjectId:o.topProjectId??null,score:.55,reason:`Costs ~${o.estimatedTokens} tokens every session and measures neutral across ${o.exposures} exposed session(s) \u2014 enough data to detect an effect, and none found. Consider shortening "${o.name}" rather than removing it.`+(o.containsSafetyLanguage?" CAUTION: it contains guardrail language (destructive-command or credential rules) \u2014 preserve those lines when shortening.":"")}))}u(ae,"buildTrimProposals");async function ie(s,n,a){let o=[],i=0;for(let d of s)try{await a("/api/instruction-experiments",{instructionId:d.instructionId,projectPath:n,source:"groom"}),i++}catch(g){let m=g instanceof Error?g.message:String(g);o.push({...d,reason:`${d.reason} (not measurable by withholding: ${m})`})}return{nominated:i,unmeasurable:o}}u(ie,"nominateRemovals");function ce(s){let n=[];for(let o of s.harmful){let i=o.verdict.delta;n.push({instructionId:o.id,score:Math.min(.95,.75+Math.abs(i)),topProjectId:o.topProjectId??null,reason:`Measured harmful: sessions using "${o.name}" scored ${(i*100).toFixed(1)}pp worse across ${o.exposures} exposed session(s). Observational \u2014 review before archiving.`})}let a=new Set(s.harmful.map(o=>o.id));for(let o of s.candidates)a.has(o.id)||n.push({instructionId:o.id,score:re,topProjectId:o.topProjectId??null,reason:`Unused: "${o.name}" is ${o.reason} (${o.totalExposures} lifetime exposure(s)) but still costs context budget every session.`});return n.slice(0,oe)}u(ce,"buildRemovalProposals");function le(){let s=y.join(A.homedir(),".config","rulemetric","skills-registry.json");try{let n=q(s,"utf-8"),a=JSON.parse(n),o=new Date(a.generatedAt).getTime();return Number.isNaN(o)?"unknown":Date.now()-o>te*60*60*1e3?"stale":"fresh"}catch{return"unknown"}}u(le,"observeSkillsRegistry");var Re=u(async(s,n)=>{let a=J(),o=a!=="none";o?n.logger.info(`Scoring backend: ${a}`):n.logger.warn("No LLM backend available (claude CLI missing and ANTHROPIC_API_KEY unset); skipping relevance scoring. Removal/trim proposals still run \u2014 they need no LLM.");let i;try{i=(await w("/api/sessions/project-paths?limit="+ee)).projectPaths}catch(e){n.logger.warn(`Failed to fetch project paths: ${e instanceof Error?e.message:String(e)}`);return}if(i.length===0){n.logger.info("No recent project paths; nothing to score");return}let d=new Map;try{let e=await w("/api/projects?limit=200");for(let t of e.projects??[])t.primaryCheckoutPath&&d.set(x(t.primaryCheckoutPath),t.id)}catch(e){n.logger.warn(`Failed to fetch projects for id resolution: ${e instanceof Error?e.message:String(e)}`)}let g=new Map;try{let e=await w(`/api/catalog?limit=200&proposable=1&contentPreview=${O}`);for(let t of e)g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.contentPreview??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch catalog: ${e instanceof Error?e.message:String(e)}`)}try{let e=await w("/api/instructions?limit=100");for(let t of e.instructions??[])g.has(t.id)||g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch personal instructions: ${e instanceof Error?e.message:String(e)}`)}let m=[],p=[];try{let e=await w("/api/insights/groom-candidates");if(!e.captureHealthy)n.logger.info(`Grooming paused: ${e.reason??"capture unhealthy"}`);else{m=ce(e),p=ae(e);let t=e.safetyGuarded+e.harmfulSafetyGuarded;n.logger.info(`Removal proposals: ${m.length} (${e.harmful.length} measured-harmful, ${e.candidates.length} never-used, ${t} withheld by the safety allowlist); trim proposals: ${p.length} (${(e.bloated??[]).length} measured-neutral and expensive, ${e.trimSafetyFlagged??0} flagged as containing guardrail language)`)}}catch(e){n.logger.warn(`Failed to fetch groom candidates: ${e instanceof Error?e.message:String(e)}`)}let b=[...g.values()];if(b.length===0&&m.length===0&&p.length===0){n.logger.info("No candidate instructions and nothing to retire; nothing to score");return}n.logger.info(`Scoring ${b.length} candidates across ${i.length} project(s)`);let M=0,l=null,I=new Set;for(let e of i)try{let t=x(e);if(!Q(t)){n.logger.info(`Skipping ${t}: not a project directory (home/root)`);continue}let f=D(t),k=o&&f.length>0;f.length===0&&n.logger.info(`${t}: insufficient language signals; removal/trim only`);let v=X(t),z={name:y.basename(t),description:v.description,languages:f,topics:v.topics,dependencies:v.dependencies},E=k?U(b):[];k&&n.logger.info(`Scoring ${b.length} candidates for ${t} in ${E.length} batch(es)`);let C=[],$=0;for(let r of E)try{let c=await B(H(z,r),"",4096);if(!c){$++;continue}let T=c.recommendations??[];for(let P of T)typeof P.instructionId=="string"&&typeof P.score=="number"&&typeof P.reason=="string"&&C.push({instructionId:P.instructionId,score:P.score,reason:P.reason})}catch(c){$++,n.logger.warn(`Batch failed for ${t}: ${c instanceof Error?c.message:String(c)}`)}$>0&&n.logger.warn(`${$}/${E.length} batch(es) failed for ${t} (backend ${a}); suggestions are partial`),k&&C.length===0&&n.logger.warn(`No usable LLM output for ${t} (backend ${a})`);let K=C.filter(r=>r.score>=ne).sort((r,c)=>c.score-r.score).slice(0,Z),_=d.get(t),W=l===null||l===t;l===null&&(l=t);let N=u(r=>r.topProjectId?r.topProjectId===_:W,"placeHere"),F=m.filter(N),{nominated:L,unmeasurable:G}=await ie(F,t,R);L>0&&n.logger.info(`${t}: ${L} removal candidate(s) nominated for randomised withholding instead of the feed`);let h=[...K.map(r=>({instructionId:r.instructionId,score:r.score,reason:r.reason,kind:"add"})),...G.map(({topProjectId:r,...c})=>({...c,kind:"remove"})),...p.filter(N).map(({estimatedTokens:r,topProjectId:c,...T})=>({...T,kind:"trim"}))];if(h.length===0){n.logger.info(`Nothing to suggest for ${t}`);continue}await R("/api/instruction-suggestions/batch-upsert",{projectPath:t,..._?{projectId:_}:{},suggestions:h}),n.logger.info(`${t}: ${h.filter(r=>r.kind==="add").length} add + ${h.filter(r=>r.kind==="remove").length} remove + ${h.filter(r=>r.kind==="trim").length} trim`);for(let r of h)r.kind!=="add"&&I.add(r.instructionId);let Y=new Set(G.map(r=>r.instructionId));for(let r of F)Y.has(r.instructionId)||I.add(r.instructionId);M++}catch(t){n.logger.warn(`Failed to score ${e}: ${t instanceof Error?t.message:String(t)}`)}let j=[...m.filter(e=>!I.has(e.instructionId)),...p.filter(e=>!I.has(e.instructionId)).map(({estimatedTokens:e,...t})=>t)];if(j.length>0&&l)try{let e=new Set(p.map(t=>t.instructionId));await R("/api/instruction-suggestions/batch-upsert",{projectPath:l,...d.get(l)?{projectId:d.get(l)}:{},suggestions:j.map(({topProjectId:t,...f})=>({...f,kind:e.has(f.instructionId)?"trim":"remove"}))}),n.logger.info(`Orphan sweep: ${j.length} proposal(s) whose project was not scored this run placed on ${l}`)}catch(e){n.logger.warn(`Orphan sweep failed: ${e instanceof Error?e.message:String(e)}`)}let S=le();if(S==="unknown")n.logger.warn("Skills registry unreadable or has no usable generatedAt; leaving suggestion staleness unchanged");else try{await R("/api/instruction-suggestions/mark-stale",{stale:S==="stale"}),S==="stale"?n.logger.warn("Skills registry is stale (>48h); marked catalog-skill suggestions stale"):n.logger.info("Skills registry is fresh; cleared staleness on catalog-skill suggestions")}catch{}n.logger.info(`Done: scored ${M}/${i.length} projects`)},"cronSuggestInstructions");export{Q as a,ae as b,ie as c,ce as d,Re as e};
1
+ import{c as X}from"./chunk-HOQPVOMF.js";import{b as D}from"./chunk-GIRPEMTW.js";import{a as x}from"./chunk-MODXEGCU.js";import{e as J,g as B}from"./chunk-26XE3JCL.js";import{e as w,f as R}from"./chunk-Z7UN4R7T.js";import{c as H,d as U}from"./chunk-X6CF5KTW.js";import{a as u}from"./chunk-ZLLER3HP.js";import{readFileSync as q,realpathSync as V}from"node:fs";import y from"node:path";import A from"node:os";function Q(s){let n=y.resolve(s);if(n===y.resolve(A.homedir()))return!1;let a=y.parse(n).root;if(n===a)return!1;try{let o=V(A.tmpdir());if(V(n)===o)return!1}catch{}return!0}u(Q,"isScorableProjectPath");var Z=5,ee=Number(process.env.RULEMETRIC_MAX_SUGGESTION_PROJECTS??10),te=48,ne=.5,O=400,oe=3,re=.6,se=1;function ae(s){let n=s.bloated??[],a=new Set([...s.harmful.map(o=>o.id),...s.candidates.map(o=>o.id)]);return n.filter(o=>!a.has(o.id)).slice(0,se).map(o=>({instructionId:o.id,estimatedTokens:o.estimatedTokens,topProjectId:o.topProjectId??null,score:.55,reason:`Costs ~${o.estimatedTokens} tokens every session and measures neutral across ${o.exposures} exposed session(s) \u2014 enough data to detect an effect, and none found. Consider shortening "${o.name}" rather than removing it.`+(o.containsSafetyLanguage?" CAUTION: it contains guardrail language (destructive-command or credential rules) \u2014 preserve those lines when shortening.":"")}))}u(ae,"buildTrimProposals");async function ie(s,n,a){let o=[],i=0;for(let d of s)try{await a("/api/instruction-experiments",{instructionId:d.instructionId,projectPath:n,source:"groom"}),i++}catch(g){let m=g instanceof Error?g.message:String(g);o.push({...d,reason:`${d.reason} (not measurable by withholding: ${m})`})}return{nominated:i,unmeasurable:o}}u(ie,"nominateRemovals");function ce(s){let n=[];for(let o of s.harmful){let i=o.verdict.delta;n.push({instructionId:o.id,score:Math.min(.95,.75+Math.abs(i)),topProjectId:o.topProjectId??null,reason:`Measured harmful: sessions using "${o.name}" scored ${(i*100).toFixed(1)}pp worse across ${o.exposures} exposed session(s). Observational \u2014 review before archiving.`})}let a=new Set(s.harmful.map(o=>o.id));for(let o of s.candidates)a.has(o.id)||n.push({instructionId:o.id,score:re,topProjectId:o.topProjectId??null,reason:`Unused: "${o.name}" is ${o.reason} (${o.totalExposures} lifetime exposure(s)) but still costs context budget every session.`});return n.slice(0,oe)}u(ce,"buildRemovalProposals");function le(){let s=y.join(A.homedir(),".config","rulemetric","skills-registry.json");try{let n=q(s,"utf-8"),a=JSON.parse(n),o=new Date(a.generatedAt).getTime();return Number.isNaN(o)?"unknown":Date.now()-o>te*60*60*1e3?"stale":"fresh"}catch{return"unknown"}}u(le,"observeSkillsRegistry");var Re=u(async(s,n)=>{let a=J(),o=a!=="none";o?n.logger.info(`Scoring backend: ${a}`):n.logger.warn("No LLM backend available (claude CLI missing and ANTHROPIC_API_KEY unset); skipping relevance scoring. Removal/trim proposals still run \u2014 they need no LLM.");let i;try{i=(await w("/api/sessions/project-paths?limit="+ee)).projectPaths}catch(e){n.logger.warn(`Failed to fetch project paths: ${e instanceof Error?e.message:String(e)}`);return}if(i.length===0){n.logger.info("No recent project paths; nothing to score");return}let d=new Map;try{let e=await w("/api/projects?limit=200");for(let t of e.projects??[])t.primaryCheckoutPath&&d.set(x(t.primaryCheckoutPath),t.id)}catch(e){n.logger.warn(`Failed to fetch projects for id resolution: ${e instanceof Error?e.message:String(e)}`)}let g=new Map;try{let e=await w(`/api/catalog?limit=200&proposable=1&contentPreview=${O}`);for(let t of e)g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.contentPreview??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch catalog: ${e instanceof Error?e.message:String(e)}`)}try{let e=await w("/api/instructions?limit=100");for(let t of e.instructions??[])g.has(t.id)||g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch personal instructions: ${e instanceof Error?e.message:String(e)}`)}let m=[],p=[];try{let e=await w("/api/insights/groom-candidates");if(!e.captureHealthy)n.logger.info(`Grooming paused: ${e.reason??"capture unhealthy"}`);else{m=ce(e),p=ae(e);let t=e.safetyGuarded+e.harmfulSafetyGuarded;n.logger.info(`Removal proposals: ${m.length} (${e.harmful.length} measured-harmful, ${e.candidates.length} never-used, ${t} withheld by the safety allowlist); trim proposals: ${p.length} (${(e.bloated??[]).length} measured-neutral and expensive, ${e.trimSafetyFlagged??0} flagged as containing guardrail language)`)}}catch(e){n.logger.warn(`Failed to fetch groom candidates: ${e instanceof Error?e.message:String(e)}`)}let b=[...g.values()];if(b.length===0&&m.length===0&&p.length===0){n.logger.info("No candidate instructions and nothing to retire; nothing to score");return}n.logger.info(`Scoring ${b.length} candidates across ${i.length} project(s)`);let M=0,l=null,I=new Set;for(let e of i)try{let t=x(e);if(!Q(t)){n.logger.info(`Skipping ${t}: not a project directory (home/root)`);continue}let f=D(t),k=o&&f.length>0;f.length===0&&n.logger.info(`${t}: insufficient language signals; removal/trim only`);let v=X(t),z={name:y.basename(t),description:v.description,languages:f,topics:v.topics,dependencies:v.dependencies},E=k?U(b):[];k&&n.logger.info(`Scoring ${b.length} candidates for ${t} in ${E.length} batch(es)`);let C=[],$=0;for(let r of E)try{let c=await B(H(z,r),"",4096);if(!c){$++;continue}let T=c.recommendations??[];for(let P of T)typeof P.instructionId=="string"&&typeof P.score=="number"&&typeof P.reason=="string"&&C.push({instructionId:P.instructionId,score:P.score,reason:P.reason})}catch(c){$++,n.logger.warn(`Batch failed for ${t}: ${c instanceof Error?c.message:String(c)}`)}$>0&&n.logger.warn(`${$}/${E.length} batch(es) failed for ${t} (backend ${a}); suggestions are partial`),k&&C.length===0&&n.logger.warn(`No usable LLM output for ${t} (backend ${a})`);let K=C.filter(r=>r.score>=ne).sort((r,c)=>c.score-r.score).slice(0,Z),_=d.get(t),W=l===null||l===t;l===null&&(l=t);let N=u(r=>r.topProjectId?r.topProjectId===_:W,"placeHere"),F=m.filter(N),{nominated:L,unmeasurable:G}=await ie(F,t,R);L>0&&n.logger.info(`${t}: ${L} removal candidate(s) nominated for randomised withholding instead of the feed`);let h=[...K.map(r=>({instructionId:r.instructionId,score:r.score,reason:r.reason,kind:"add"})),...G.map(({topProjectId:r,...c})=>({...c,kind:"remove"})),...p.filter(N).map(({estimatedTokens:r,topProjectId:c,...T})=>({...T,kind:"trim"}))];if(h.length===0){n.logger.info(`Nothing to suggest for ${t}`);continue}await R("/api/instruction-suggestions/batch-upsert",{projectPath:t,..._?{projectId:_}:{},suggestions:h}),n.logger.info(`${t}: ${h.filter(r=>r.kind==="add").length} add + ${h.filter(r=>r.kind==="remove").length} remove + ${h.filter(r=>r.kind==="trim").length} trim`);for(let r of h)r.kind!=="add"&&I.add(r.instructionId);let Y=new Set(G.map(r=>r.instructionId));for(let r of F)Y.has(r.instructionId)||I.add(r.instructionId);M++}catch(t){n.logger.warn(`Failed to score ${e}: ${t instanceof Error?t.message:String(t)}`)}let j=[...m.filter(e=>!I.has(e.instructionId)),...p.filter(e=>!I.has(e.instructionId)).map(({estimatedTokens:e,...t})=>t)];if(j.length>0&&l)try{let e=new Set(p.map(t=>t.instructionId));await R("/api/instruction-suggestions/batch-upsert",{projectPath:l,...d.get(l)?{projectId:d.get(l)}:{},suggestions:j.map(({topProjectId:t,...f})=>({...f,kind:e.has(f.instructionId)?"trim":"remove"}))}),n.logger.info(`Orphan sweep: ${j.length} proposal(s) whose project was not scored this run placed on ${l}`)}catch(e){n.logger.warn(`Orphan sweep failed: ${e instanceof Error?e.message:String(e)}`)}let S=le();if(S==="unknown")n.logger.warn("Skills registry unreadable or has no usable generatedAt; leaving suggestion staleness unchanged");else try{await R("/api/instruction-suggestions/mark-stale",{stale:S==="stale"}),S==="stale"?n.logger.warn("Skills registry is stale (>48h); marked catalog-skill suggestions stale"):n.logger.info("Skills registry is fresh; cleared staleness on catalog-skill suggestions")}catch{}n.logger.info(`Done: scored ${M}/${i.length} projects`)},"cronSuggestInstructions");export{Q as a,ae as b,ie as c,ce as d,Re as e};
@@ -1 +1 @@
1
- import{b as T,d as H}from"./chunk-VBGHPAUT.js";import{b as A,e as c,f as m}from"./chunk-GIXHG5FK.js";import{a as u}from"./chunk-ZLLER3HP.js";import{createHash as M,randomUUID as D}from"node:crypto";import{readFileSync as h,existsSync as g}from"node:fs";import{join as i}from"node:path";import{pathToFileURL as L}from"node:url";import{execFileSync as O}from"node:child_process";import{scriptsDir as J}from"@rulemetric/hooks/scripts-dir";var f=u(t=>M("sha256").update(t).digest("hex"),"hash");async function Q(t){let k=await c(`/api/instruction-suggestions/${t.suggestionId}/test`);if(k.liveStudies?.length)return{status:"existing",studyId:k.liveStudies[0].id};let o=await c(`/api/eval-targets/${t.evalTargetId}`);if(!o.projectPath||!o.instructionId)return{status:"blocked",reason:"The suggestion has no project and instruction link."};let s=o.projectPath;if(!g(i(s,"package.json")))return{status:"blocked",reason:"Automatic repository checks currently require a package.json type-check or typecheck script."};let d=JSON.parse(h(i(s,"package.json"),"utf8")),y=["type-check","typecheck"].find(e=>typeof d.scripts?.[e]=="string");if(!y)return{status:"blocked",reason:"Add a type-check or typecheck script to prepare independently checked code tasks."};let v=t.research?[]:await c(`/api/eval-targets/${t.evalTargetId}/runs?jobId=${t.evalJobId}&limit=100`),b=v.flatMap(e=>e.outputs?.engine==="claude"&&e.outputs.model?[e.outputs.model]:[]),x=[...new Set(b)],l=t.requestedModel?.trim()||(x.length===1?x[0]:void 0);if(!l)return{status:"blocked",reason:"Choose an exact Claude model for the separately budgeted live study. Missing comparison model metadata does not determine live eligibility."};let p=await import(L(i(J,"scoped-live.mjs")).href);if(typeof p.runRepositoryCheck!="function")return{status:"blocked",reason:"Upgrade the installed hooks to support repository checks."};let r=p.observeEnvironment(s);for(let e of Object.keys(r.contextHashes))if(r.contextHashes[e]&&/(?:CLAUDE(?:\.local)?|AGENTS)\.md$/.test(e)&&h(e,"utf8").includes(t.content.trim()))return{status:"blocked",reason:"The candidate already exists in background instructions; it cannot be withheld from baseline tasks."};let P=O("git",["ls-files","-z"],{cwd:s,encoding:"utf8",timeout:5e3}).split("\0"),I=[...new Set(["package.json",...P.filter(e=>!e.split("/").some(q=>q.startsWith("."))&&/(^|\/)(package\.json|tsconfig[^/]*\.json|turbo\.json|pnpm-workspace\.yaml|pnpm-lock\.yaml|package-lock\.json|yarn\.lock)$/.test(e))])];if(I.length>300)return{status:"blocked",reason:"Repository verifier configuration exceeds the 300-file preparation bound."};let $=Object.fromEntries(I.sort().map(e=>[e,f(h(i(s,e),"utf8"))])),w={name:"Repository type checking passes",path:"package.json",kind:"command_exit",expected:"0",primary:!0,command:[d.packageManager?.startsWith("pnpm@")||g(i(s,"pnpm-lock.yaml"))?"pnpm":d.packageManager?.startsWith("yarn@")||g(i(s,"yarn.lock"))?"yarn":"npm","run",y],timeoutMs:12e4,fileHashes:$},n=p.runRepositoryCheck(s,w);if(n.error||n.exitCode===null)return{status:"blocked",reason:`The verifier could not execute: ${n.error??"no exit status"}`};let a=t.research?.taskLimit??20,j=Array.from({length:a+1},()=>`work-${D()}`),S=H.parse({version:1,mode:"exploration",research:{question:t.research?.question??`Does ${o.name} increase the fraction of fresh launched tasks leaving repository type checks passing?`,rationale:t.research?T(t.research):o.description||"Test the exact suggested instruction on prospective project work.",eligibility:"Fresh work requests supplied before launch in this project, using the pinned Claude model. One request per task; resumed and repeated work excluded.",riskReview:`${a} task assignments, one baseline follow-up, seven-day expiry. Frozen repository checks; changes to checker configuration invalidate outcomes. Shared-checkout carryover is recorded; final causal interpretation remains inconclusive. No automatic adoption.`,enrollment:"prospective-launches",suggestionId:t.suggestionId,evalTargetId:t.evalTargetId,preparationJobId:t.preparationJobId,carryoverPolicy:"fresh-session-per-task",adoptionPolicy:"no-adoption"},projectPath:s,taskFamily:"fresh-project-work",harness:"claude_code",model:l,configurationHash:f(JSON.stringify({harnessVersion:r.harnessVersion,repositoryRevision:r.repositoryRevision,contextHashes:r.contextHashes})),baselineDeliveryHash:f(""),treatmentDeliveryHash:t.contentHash,primaryOutcome:"Repository type checking passes after the task; this is not a claim of full task correctness.",outcomeRule:{source:"session_analysis",completedValues:["achieved"],failedValues:["failed"]},eligibleTaskIds:j,maxAssignments:a,decisionRule:{minCompletedPerArm:2,minimumAbsoluteEffect:.1},expiresAt:new Date(Date.now()+7*864e5).toISOString(),verification:{version:1,kind:"artifact-checks",environment:r,tasks:j.map(e=>({taskId:e,checks:[w]}))}}),C=await m("/api/instruction-experiments",{instructionId:o.instructionId,projectPath:s,source:"trial",mode:"scoped"}),R;try{R=await m(`/api/instruction-experiments/${C.experimentId}/scoped-live-confirmations`,{protocol:S})}catch(e){if(e instanceof A&&e.statusCode===409&&e.message==="Preparation was cancelled before the live study opened")return{status:"cancelled",reason:e.message};throw e}return{status:"waiting_for_work",studyId:R.confirmation.id,verifierReadiness:n,taskLimit:a,comparisonRunsWithUnknownModel:v.length-b.length,modelSelection:t.requestedModel?"explicit_request":"comparison_observation",outcome:S.primaryOutcome,model:l}}u(Q,"prepareSuggestionLive");export{Q as a};
1
+ import{b as T,d as H}from"./chunk-VBGHPAUT.js";import{b as A,e as c,f as m}from"./chunk-Z7UN4R7T.js";import{a as u}from"./chunk-ZLLER3HP.js";import{createHash as M,randomUUID as D}from"node:crypto";import{readFileSync as h,existsSync as g}from"node:fs";import{join as i}from"node:path";import{pathToFileURL as L}from"node:url";import{execFileSync as O}from"node:child_process";import{scriptsDir as J}from"@rulemetric/hooks/scripts-dir";var f=u(t=>M("sha256").update(t).digest("hex"),"hash");async function Q(t){let k=await c(`/api/instruction-suggestions/${t.suggestionId}/test`);if(k.liveStudies?.length)return{status:"existing",studyId:k.liveStudies[0].id};let o=await c(`/api/eval-targets/${t.evalTargetId}`);if(!o.projectPath||!o.instructionId)return{status:"blocked",reason:"The suggestion has no project and instruction link."};let s=o.projectPath;if(!g(i(s,"package.json")))return{status:"blocked",reason:"Automatic repository checks currently require a package.json type-check or typecheck script."};let d=JSON.parse(h(i(s,"package.json"),"utf8")),y=["type-check","typecheck"].find(e=>typeof d.scripts?.[e]=="string");if(!y)return{status:"blocked",reason:"Add a type-check or typecheck script to prepare independently checked code tasks."};let v=t.research?[]:await c(`/api/eval-targets/${t.evalTargetId}/runs?jobId=${t.evalJobId}&limit=100`),b=v.flatMap(e=>e.outputs?.engine==="claude"&&e.outputs.model?[e.outputs.model]:[]),x=[...new Set(b)],l=t.requestedModel?.trim()||(x.length===1?x[0]:void 0);if(!l)return{status:"blocked",reason:"Choose an exact Claude model for the separately budgeted live study. Missing comparison model metadata does not determine live eligibility."};let p=await import(L(i(J,"scoped-live.mjs")).href);if(typeof p.runRepositoryCheck!="function")return{status:"blocked",reason:"Upgrade the installed hooks to support repository checks."};let r=p.observeEnvironment(s);for(let e of Object.keys(r.contextHashes))if(r.contextHashes[e]&&/(?:CLAUDE(?:\.local)?|AGENTS)\.md$/.test(e)&&h(e,"utf8").includes(t.content.trim()))return{status:"blocked",reason:"The candidate already exists in background instructions; it cannot be withheld from baseline tasks."};let P=O("git",["ls-files","-z"],{cwd:s,encoding:"utf8",timeout:5e3}).split("\0"),I=[...new Set(["package.json",...P.filter(e=>!e.split("/").some(q=>q.startsWith("."))&&/(^|\/)(package\.json|tsconfig[^/]*\.json|turbo\.json|pnpm-workspace\.yaml|pnpm-lock\.yaml|package-lock\.json|yarn\.lock)$/.test(e))])];if(I.length>300)return{status:"blocked",reason:"Repository verifier configuration exceeds the 300-file preparation bound."};let $=Object.fromEntries(I.sort().map(e=>[e,f(h(i(s,e),"utf8"))])),w={name:"Repository type checking passes",path:"package.json",kind:"command_exit",expected:"0",primary:!0,command:[d.packageManager?.startsWith("pnpm@")||g(i(s,"pnpm-lock.yaml"))?"pnpm":d.packageManager?.startsWith("yarn@")||g(i(s,"yarn.lock"))?"yarn":"npm","run",y],timeoutMs:12e4,fileHashes:$},n=p.runRepositoryCheck(s,w);if(n.error||n.exitCode===null)return{status:"blocked",reason:`The verifier could not execute: ${n.error??"no exit status"}`};let a=t.research?.taskLimit??20,j=Array.from({length:a+1},()=>`work-${D()}`),S=H.parse({version:1,mode:"exploration",research:{question:t.research?.question??`Does ${o.name} increase the fraction of fresh launched tasks leaving repository type checks passing?`,rationale:t.research?T(t.research):o.description||"Test the exact suggested instruction on prospective project work.",eligibility:"Fresh work requests supplied before launch in this project, using the pinned Claude model. One request per task; resumed and repeated work excluded.",riskReview:`${a} task assignments, one baseline follow-up, seven-day expiry. Frozen repository checks; changes to checker configuration invalidate outcomes. Shared-checkout carryover is recorded; final causal interpretation remains inconclusive. No automatic adoption.`,enrollment:"prospective-launches",suggestionId:t.suggestionId,evalTargetId:t.evalTargetId,preparationJobId:t.preparationJobId,carryoverPolicy:"fresh-session-per-task",adoptionPolicy:"no-adoption"},projectPath:s,taskFamily:"fresh-project-work",harness:"claude_code",model:l,configurationHash:f(JSON.stringify({harnessVersion:r.harnessVersion,repositoryRevision:r.repositoryRevision,contextHashes:r.contextHashes})),baselineDeliveryHash:f(""),treatmentDeliveryHash:t.contentHash,primaryOutcome:"Repository type checking passes after the task; this is not a claim of full task correctness.",outcomeRule:{source:"session_analysis",completedValues:["achieved"],failedValues:["failed"]},eligibleTaskIds:j,maxAssignments:a,decisionRule:{minCompletedPerArm:2,minimumAbsoluteEffect:.1},expiresAt:new Date(Date.now()+7*864e5).toISOString(),verification:{version:1,kind:"artifact-checks",environment:r,tasks:j.map(e=>({taskId:e,checks:[w]}))}}),C=await m("/api/instruction-experiments",{instructionId:o.instructionId,projectPath:s,source:"trial",mode:"scoped"}),R;try{R=await m(`/api/instruction-experiments/${C.experimentId}/scoped-live-confirmations`,{protocol:S})}catch(e){if(e instanceof A&&e.statusCode===409&&e.message==="Preparation was cancelled before the live study opened")return{status:"cancelled",reason:e.message};throw e}return{status:"waiting_for_work",studyId:R.confirmation.id,verifierReadiness:n,taskLimit:a,comparisonRunsWithUnknownModel:v.length-b.length,modelSelection:t.requestedModel?"explicit_request":"comparison_observation",outcome:S.primaryOutcome,model:l}}u(Q,"prepareSuggestionLive");export{Q as a};
@@ -0,0 +1,4 @@
1
+ import{b as h}from"./chunk-WULEBQPI.js";import{a as w}from"./chunk-6XTLP2G7.js";import{a as s}from"./chunk-ZLLER3HP.js";import{spawn as v}from"node:child_process";import{mkdtempSync as P,readFileSync as S,rmSync as I}from"node:fs";import{tmpdir as M}from"node:os";import{join as y}from"node:path";var O=s(t=>`codex:${t.replace(/^codex:/,"")}`,"codexModelId");function $(t,o,i=!1){return["exec","--json","--sandbox",i?"workspace-write":"read-only","--skip-git-repo-check","--ephemeral","--model",t.replace(/^codex:/,""),"--output-last-message",o,"-"]}s($,"buildCodexArgs");function R(t){let o;for(let i of t.split(`
2
+ `)){let c=i.trim();if(!c.startsWith("{"))continue;let n;try{n=JSON.parse(c)}catch{continue}if(typeof n!="object"||n===null)continue;let d=n.usage;if(typeof d!="object"||d===null)continue;let u=s(x=>{let p=d[x];return typeof p=="number"&&Number.isFinite(p)?p:0},"num"),a=u("input_tokens"),l=u("output_tokens");o={inputTokens:a,cachedInputTokens:u("cached_input_tokens"),outputTokens:l,reasoningOutputTokens:u("reasoning_output_tokens"),totalTokens:a+l}}return o}s(R,"parseCodexUsage");async function L(t){let{prompt:o,systemPrompt:i,model:c,timeout:n=12e4,workDir:d=process.cwd()}=t,u=i?`${i}
3
+
4
+ ${o}`:o,a=w("codex");if(!a)return{output:"",exitCode:null,durationMs:0,error:"Codex CLI not found on PATH, well-known install dirs, or the node bin dir \u2014 is it installed?"};let l=P(y(M(),"rulemetric-codex-")),x=y(l,"last-message.txt"),p=Date.now();return new Promise(E=>{let _=h(),r=v(a,$(c,x,t.writableFixture),{cwd:d,env:_,stdio:["pipe","pipe","pipe"]}),k="",m="",C=256*1024;r.stdout.on("data",e=>{m+=e.toString(),m.length>C&&(m=m.slice(-C))}),r.stderr.on("data",e=>{k+=e.toString()});let f=s(e=>{I(l,{recursive:!0,force:!0}),E({...e,durationMs:Date.now()-p})},"finish"),b=setTimeout(()=>{r.kill("SIGTERM"),f({output:"",exitCode:null,error:`codex exec timed out after ${n}ms`})},n);r.on("error",e=>{clearTimeout(b),f({output:"",exitCode:null,error:`failed to spawn codex: ${e.message} (is the Codex CLI installed?)`})}),r.on("close",e=>{clearTimeout(b);let g="";try{g=S(x,"utf8").trim()}catch{}let T=R(m);if(e!==0||g===""){f({output:g,exitCode:e,usage:T,error:`codex exec failed (exit ${e}): ${k.trim().slice(-500)||"no last message produced"}`});return}f({output:g,exitCode:e,model:O(c),usage:T})}),r.stdin.write(u),r.stdin.end()})}s(L,"executeCodexEval");export{O as a,$ as b,R as c,L as d};
@@ -1 +1 @@
1
- import{a as d,d as m}from"./chunk-GIXHG5FK.js";import{a as c,l as a}from"./chunk-PZNWH4VQ.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
+ import{a as d,d as m}from"./chunk-Z7UN4R7T.js";import{a as c,l as a}from"./chunk-PZNWH4VQ.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 j}from"./chunk-PJ4RIUI3.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{b as I,c as P,d as v}from"./chunk-NWV66NMA.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};
1
+ import{a as j}from"./chunk-UPJVMMDK.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{b as I,c as P,d as v}from"./chunk-CWVXTLXZ.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,2 @@
1
+ import{a as X,b as M,c as P,d as Y,e as Z}from"./chunk-JU5ZNXPK.js";import{a as d}from"./chunk-5RBLIVBF.js";import{c as K}from"./chunk-VBGHPAUT.js";import{a as ee}from"./chunk-4GM4OEQY.js";import{b as re}from"./chunk-AZB34RT6.js";import{b as te,e as ne}from"./chunk-FLXWL4F4.js";import{a as N,c as W}from"./chunk-AXTEV56C.js";import{f as C}from"./chunk-VZYNZS5U.js";import{a as V}from"./chunk-U6AASXY3.js";import{b as B,g as Q}from"./chunk-LARY6ZFT.js";import{e as _,f as I,h as $}from"./chunk-Z7UN4R7T.js";import{a as x}from"./chunk-ZLLER3HP.js";import{execFileSync as se}from"node:child_process";import{tmpdir as oe}from"node:os";import{existsSync as ie}from"node:fs";async function Ee(s,b){let{mirrorId:u,evalTargetId:f}=s,o=s.measurement?{...s.config,...W({...s.config,measurement:s.measurement})}:s.config,l=x(e=>b.logger.info(e),"log"),t=s.study?K.parse(s.study):null;if(t&&t.protocol.scope.engine!=="claude")throw new d("Frozen study isolation is currently verified only for Claude");if(t&&X(t.protocol)!==t.protocolHash)throw new d("Study snapshot hash mismatch");let D=await _(`/api/eval-targets/${f}`),p=s.candidateSnapshot?{...D,...s.candidateSnapshot}:D,c=await _(`/api/eval-targets/${f}/evals`);if(t&&(c=t.protocol.tasks.filter(e=>e.split===(t.protocol.analysis.role==="frozen_validation"?"validation":"exploration")).map(e=>({id:e.evalId,name:e.taskId,prompt:e.prompt,expectedOutput:"",expectations:[]}))),o.repositoryRoot&&!ie(o.repositoryRoot))throw new d(`Frozen test checkout no longer exists: ${o.repositoryRoot}`);let k=o.repositoryRoot?te(o.repositoryRoot):null;if(c.length===0&&o.generateIfEmpty){l("No eval cases on target \u2014 generating from content via local LLM...");let e=await re({content:p.content,name:p.name,...k?{repository:k}:{},...s.measurement?{measurement:s.measurement}:{}});if(e===null)throw new Error("Case generation requires a local LLM backend (Claude or Codex CLI) \u2014 none available on this worker.");let n=[];for(let r of e)n.push(await I(`/api/eval-targets/${f}/evals`,r));c=n,l(`Generated ${n.length} eval case(s)`)}if(k){let e=c.filter(n=>ne(`${n.name}
2
+ ${n.prompt}`,k).length>0);if(e.length>0)throw new d(`Invalid eval case(s) for this repository (runtimes present: ${k.runtimes.join(", ")||"none"}): ${e.map(n=>n.name).join(", ")}`)}if(s.candidateSnapshot&&(c=c.slice(0,5)),c.length===0)throw new d("No evals defined for target");let j=null;if(t&&(j=se(t.protocol.scope.engine,["--version"],{encoding:"utf8",timeout:1e4}).trim(),j!==t.protocol.scope.harnessVersion))throw new d("Observed harness version differs from frozen protocol");if(t){if(o.engine!==t.protocol.scope.engine||o.model!==t.protocol.scope.model||o.runsPerEval!==t.protocol.analysis.repetitions||o.timeout!==t.protocol.analysis.maxSecondsPerCall*1e3||o.skipBaseline||new Date(t.protocol.scope.expiresAt)<=new Date)throw new d("Study execution configuration differs from frozen protocol or scope expired");for(let e of t.protocol.tasks.filter(n=>c.some(r=>r.id===n.evalId))){let n=C({baseDir:oe(),engine:t.protocol.scope.engine});try{M(n.workDir,[...e.files,...e.oracleFiles]);let r=P(n.workDir,e);if(!r.primaryPassed||!r.safeguardsPassed)throw new d(`Oracle failed for ${e.taskId}; no actor calls started`)}finally{n.cleanup()}}}let ae=o.runsPerEval??1,F=o.timeout??12e4,H=t?1:o.iteration??1,S=new Set;if(b.job.attempts>1)for(let n=0;;n+=100){let r=await _(`/api/eval-targets/${f}/runs?jobId=${u}&limit=100&offset=${n}`);for(let i of r)S.add(`${i.evalId}|${i.configuration}|${i.runNumber}|${i.iteration}`);if(r.length<100)break}let T=[{name:"with_target",content:t?.protocol.treatment.content??p.content}];o.skipBaseline||T.push({name:"without_target",...t?{content:t.protocol.baseline.content}:{}});let v=[];for(let e of c)for(let n of T)for(let r=1;r<=ae;r++)S.has(`${e.id}|${n.name}|${r}|${H}`)||v.push({eval_:e,configuration:n.name,targetContent:n.content,runNumber:r});t&&v.sort((e,n)=>e.eval_.id.localeCompare(n.eval_.id)||e.runNumber-n.runNumber||((c.findIndex(r=>r.id===e.eval_.id)+e.runNumber)%2?e.configuration.localeCompare(n.configuration):n.configuration.localeCompare(e.configuration))),S.size>0&&l(`Resuming attempt ${b.job.attempts}: ${S.size} run(s) already persisted, ${v.length} remaining`);let m=v.length,h=0,w=B(o.engine),y=Math.min(o.parallel??1,4);await $(`/api/eval-jobs/${u}/progress`,{status:"running",progress:{total:m,completed:0,current:null,message:`Starting ${m} eval runs (concurrency: ${y})...`}});let E=[];async function z(e){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`;l(`[${h+1}/${m}] ${n}`);let r=C({...t?{baseDir:oe()}:o.repositoryRoot?{baseDir:o.repositoryRoot}:{},targetType:t?"instruction":p.type,targetContent:e.targetContent,targetName:p.name,engine:w});r.leakedFiles.length&&l(`\u26A0 CONTAMINATED ${n}: ${r.leakedFiles.join(", ")} survived the strip`);try{let i=t?.protocol.tasks.find(q=>q.evalId===e.eval_.id),g=e.configuration==="with_target"?"treatment":"baseline";t&&i&&M(r.workDir,[...i.files,...t.protocol[g].files]);let G=t&&i?Z(r.workDir,i,t.protocol[g],w):null;t&&i&&await I(`/api/studies/${t.id}/calls`,{jobId:u,taskId:i.taskId,arm:g,repetition:e.runNumber});let a=await Q({prompt:e.eval_.prompt,targetContent:t?e.targetContent:r.systemPrompt,...t?{appendTarget:!0}:{},workDir:r.workDir,timeout:F,model:o.model,engine:w,...t?{writableFixture:!0}:{}}),A={};!o.skipGrading&&e.eval_.expectations.length>0&&!a.error&&(A=await V({...N({engine:w,model:o.model},{engine:o.graderEngine,model:o.graderModel}),prompt:e.eval_.prompt,output:a.output,expectations:e.eval_.expectations,timeout:F}));let L=t?Y(t.protocol,a):null,U=t&&i?{studyId:t.id,protocolHash:t.protocolHash,taskId:i.taskId,arm:g,repetition:e.runNumber,eligible:L===null,exclusion:L,...P(r.workDir,i),deliveryHash:G.deliveryHash,fixtureHash:G.fixtureHash,harnessVersion:j,engine:a.engine??null,model:a.model??null,provider:a.engine==="claude"?"anthropic":a.provider??null,durationMs:a.durationMs,tokens:a.totalTokens||null,costUsd:a.costUsd??null}:null;return{jobId:u,evalId:e.eval_.id,evalTargetId:p.id,evalTargetVersion:p.version,configuration:e.configuration,runNumber:e.runNumber,iteration:H,status:a.error?"failed":"completed",outputs:{...U?{study:U}:{},...s.candidateSnapshot?{candidateHash:s.candidateSnapshot.contentHash,suggestionId:s.candidateSnapshot.suggestionId,evidenceKind:"constructed_evaluation"}:{},...a.usage?{usage:a.usage}:{},...a.error?{error:a.error}:{transcript:a.output,...a.model?{model:a.model}:{}},methodology:r.methodology,delivery:r.delivery,isolated:r.isWorktree,engine:a.engine??w,model:a.model??null,deliveryRegime:`${p.type}:${w}:${r.methodology}`,...s.measurement?{measurement:s.measurement}:{},...a.provider?{provider:a.provider}:{},...a.costUsd!=null?{costUsd:a.costUsd}:{},...r.leakedFiles.length?{leakedFiles:r.leakedFiles}:{}},timing:{duration_ms:a.durationMs,total_tokens:a.totalTokens},grading:A,worktree:r.isWorktree?!0:void 0}}finally{r.cleanup()}}if(x(z,"processItem"),y<=1)for(let e of v){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`,r=await $(`/api/eval-jobs/${u}/progress`,{status:"running",progress:{total:m,completed:h,current:n,message:`Executing ${n}...`}});if(s.candidateSnapshot&&r?.status==="cancelled")throw new d("Suggestion testing cancelled; no further actor calls");let i=await z(e);await I("/api/eval-runs",i),E.push(i),h++,await $(`/api/eval-jobs/${u}/progress`,{status:"running",progress:{total:m,completed:h,current:n,message:`Completed ${n}`}})}else{l(`Running ${m} evals with concurrency=${y} (worktree isolation)`);for(let e=0;e<v.length;e+=y){let n=v.slice(e,e+y),r=`batch ${Math.floor(e/y)+1}/${Math.ceil(v.length/y)}`;await $(`/api/eval-jobs/${u}/progress`,{status:"running",progress:{total:m,completed:h,current:r,message:`Executing ${r} (${n.length} parallel)...`}});let i=await Promise.all(n.map(z));for(let g of i)await I("/api/eval-runs",g),E.push(g),h++;await $(`/api/eval-jobs/${u}/progress`,{status:"running",progress:{total:m,completed:h,current:r,message:`Completed ${r}`}})}}let J=le(E),R;if(!o.skipGrading&&E.some(e=>e.grading&&Object.keys(e.grading).length>0))try{l(`Running meta-judge for job ${u}...`);let e=c.map(n=>{let i=E.filter(g=>g.evalId===n.id&&g.configuration==="with_target")[0];return{evalName:n.name,prompt:n.prompt,expectations:n.expectations,grading:i?.grading?i.grading:null,output:i?.outputs?.transcript?.slice(0,500)}});R=await ee({...N({engine:w,model:o.model},{engine:o.graderEngine,model:o.graderModel}),targetName:p.name,evalResults:e,timeout:6e4}),l(`Meta-judge: quality=${R.quality_score}/5, issues=${R.issues.length}`)}catch(e){l(`Meta-judge failed (non-fatal): ${e instanceof Error?e.message:String(e)}`)}let O=R?{...J,meta_judgement:R}:J;return l(`Job ${u} completed: ${h}/${m} runs`),await $(`/api/eval-jobs/${u}/state`,{result:O}).catch(e=>{l(`result persist failed: ${e instanceof Error?e.message:String(e)}`)}),O}x(Ee,"processEval");function le(s){let b=s.filter(l=>l.status==="completed"),u=s.filter(l=>l.status==="failed"),f=b.filter(l=>{let t=l.grading;return t&&Object.keys(t).length>0}),o=f.length>0?f.reduce((l,t)=>l+(t.grading?.summary?.pass_rate??0),0)/f.length:null;return{total:s.length,completed:b.length,failed:u.length,avgPassRate:o}}x(le,"buildSummary");export{Ee as a};
@@ -1,4 +1,4 @@
1
- import{f as p}from"./chunk-4GOXEEXZ.js";import{a as c}from"./chunk-ZLLER3HP.js";var y=`You are an expert at improving AI coding instructions, skills, and prompts. You receive eval results showing how well the current content performs, and your job is to propose specific improvements.
1
+ import{g as p}from"./chunk-LARY6ZFT.js";import{a as c}from"./chunk-ZLLER3HP.js";var y=`You are an expert at improving AI coding instructions, skills, and prompts. You receive eval results showing how well the current content performs, and your job is to propose specific improvements.
2
2
 
3
3
  You will receive:
4
4
  1. The current content of the eval target
@@ -1,4 +1,4 @@
1
- import{e as d}from"./chunk-QWCEZEDO.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-OZQNSELV.js";import{d as g}from"./chunk-GPBN4ROE.js";import{e as _}from"./chunk-GIXHG5FK.js";import{g as m,l as k}from"./chunk-PZNWH4VQ.js";import{a as i}from"./chunk-ZLLER3HP.js";import{execSync as j}from"node:child_process";import{existsSync as p,readFileSync as y}from"node:fs";import{homedir as f}from"node:os";import{join as a}from"node:path";var P=["install","auth","hooks","worker"],O=["judge"],M=[...P,...O];function $(){return{projectPath:process.cwd(),configDir:k()}}i($,"defaultContext");var A=a(f(),".mitmproxy","mitmproxy-ca-cert.pem");function S(e){if(!e)return"";if(e.length<=8)return"*".repeat(e.length);let t=e.slice(0,4),n=e.slice(-4);return`${t}${"*".repeat(Math.max(4,e.length-8))}${n}`}i(S,"maskToken");function te(e,t){let n=e===null?[]:e.replace(/\n$/,"").split(`
1
+ import{e as d}from"./chunk-QWCEZEDO.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-OZQNSELV.js";import{d as g}from"./chunk-GPBN4ROE.js";import{e as _}from"./chunk-Z7UN4R7T.js";import{g as m,l as k}from"./chunk-PZNWH4VQ.js";import{a as i}from"./chunk-ZLLER3HP.js";import{execSync as j}from"node:child_process";import{existsSync as p,readFileSync as y}from"node:fs";import{homedir as f}from"node:os";import{join as a}from"node:path";var P=["install","auth","hooks","worker"],O=["judge"],M=[...P,...O];function $(){return{projectPath:process.cwd(),configDir:k()}}i($,"defaultContext");var A=a(f(),".mitmproxy","mitmproxy-ca-cert.pem");function S(e){if(!e)return"";if(e.length<=8)return"*".repeat(e.length);let t=e.slice(0,4),n=e.slice(-4);return`${t}${"*".repeat(Math.max(4,e.length-8))}${n}`}i(S,"maskToken");function te(e,t){let n=e===null?[]:e.replace(/\n$/,"").split(`
2
2
  `),o=t===null?[]:t.replace(/\n$/,"").split(`
3
3
  `),s=[],u=Math.max(n.length,o.length);for(let c=0;c<u;c++){let l=n[c],r=o[c];l===r?s.push(` ${l}`):(l!==void 0&&s.push(`-${l}`),r!==void 0&&s.push(`+${r}`))}return s.join(`
4
4
  `)}i(te,"renderDiff");function x(e,t){let n=a(e,"env");if(!p(n))return null;try{let s=y(n,"utf-8").match(new RegExp(`^${t}=(.+)$`,"m"));return s?s[1]:null}catch{return null}}i(x,"readEnvValue");async function b(){if(!m())return!1;try{return(await Promise.race([_("/api/setup/status"),new Promise((t,n)=>setTimeout(()=>n(new Error("setup/status timeout")),2500))]))?.workerActive===!0}catch{return!1}}i(b,"workerActive");function E(e,t){let n=a(e,".claude",t),o={},s=null;if(p(n))try{s=y(n,"utf-8").replace(/\n$/,""),o=JSON.parse(s)}catch{o={}}return{settings:o,before:s}}i(E,"readProjectSettings");function D(e){let{settings:t,before:n}=E(e,"settings.local.json");return v(t),{before:n,after:JSON.stringify(t,null,2)}}i(D,"projectHooksSettings");function N(e){let{settings:t,before:n}=E(e,"settings.local.json"),o={...t.env??{}};return o.HTTPS_PROXY=`http://localhost:${d}`,o.NO_PROXY=I,o.NODE_EXTRA_CA_CERTS=A,{before:n,after:JSON.stringify({...t,env:o},null,2)}}i(N,"projectProxyEnvSettings");function U(e){let{settings:t,before:n}=E(e,"settings.json");if(n===null)return null;let{removed:o}=C(t,d);return o?{before:n,after:JSON.stringify(t,null,2)}:null}i(U,"projectSharedSettingsMigration");var Y=a(f(),"Library","LaunchAgents","com.rulemetric.worker.plist"),G=a(f(),".config","systemd","user","rulemetric-worker.service");function h(e){j(e,{stdio:"inherit"})}i(h,"runCommand");var L=[{id:"install",title:"Install the CLI",command:"npm install -g @rulemetric/cli",async detect(){return m()||await b()},async plan(){return{id:"install",title:"Install the CLI",command:"npm install -g @rulemetric/cli",artifacts:[{path:"npm install -g @rulemetric/cli",kind:"command",before:null,after:"rulemetric --version # verifies the binary is on PATH"}]}},async apply(){h("npm install -g @rulemetric/cli")}},{id:"auth",title:"Authenticate",command:"rulemetric auth login",async detect(){return m()},async plan(e){let t=a(e.configDir,"env"),n=null;if(p(t))try{n=X(y(t,"utf-8"))}catch{n="(unreadable)"}let o=x(e.configDir,"RULEMETRIC_ACCESS_TOKEN"),u=[`RULEMETRIC_ACCESS_TOKEN=${S(o||"<token-from-login>")}`],c=x(e.configDir,"RULEMETRIC_API_KEY");c&&u.push(`RULEMETRIC_API_KEY=${S(c)}`);let l=process.env.RULEMETRIC_API_URL;l&&u.push(`RULEMETRIC_API_URL=${l}`);let r=u.join(`
@@ -1,4 +1,4 @@
1
- import{a as w,b as S}from"./chunk-CDY7TQFZ.js";import{f as A}from"./chunk-4GOXEEXZ.js";import{d as G}from"./chunk-JNLDISBA.js";import{a as p}from"./chunk-ZLLER3HP.js";var j=`You are a rigorous eval grader. Your job is to evaluate whether an AI assistant's output meets a set of expectations.
1
+ import{a as w,b as S}from"./chunk-CDY7TQFZ.js";import{g as A}from"./chunk-LARY6ZFT.js";import{d as G}from"./chunk-SVZYRGO5.js";import{a as p}from"./chunk-ZLLER3HP.js";var j=`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
@@ -1,4 +1,4 @@
1
- import{b as E,d as R}from"./chunk-GIXHG5FK.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]
1
+ import{b as E,d as R}from"./chunk-Z7UN4R7T.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 +1 @@
1
- import{a as i}from"./chunk-NWV66NMA.js";import{a as f}from"./chunk-ZLLER3HP.js";import{useEffect as J,useState as u,useCallback as m,useRef as s}from"react";var y=5e3;function T(a=20){let[d,b]=u([]),[g,l]=u(null),[h,p]=u(!0),r=s(!1),e=s(null),c=s(0),t=m(async()=>{let o=++c.current;try{let n=await i({limit:a});if(r.current||o!==c.current)return;b(n),l(null)}catch(n){if(r.current||o!==c.current)return;l(n instanceof Error?n.message:String(n))}finally{if(r.current||o!==c.current)return;p(!1),e.current=setTimeout(()=>{t()},y)}},[a]),L=m(()=>{e.current&&clearTimeout(e.current),t()},[t]);return J(()=>(r.current=!1,t(),()=>{r.current=!0,e.current&&clearTimeout(e.current)}),[t]),{jobs:d,error:g,loading:h,refetch:L}}f(T,"useLaunchJobs");export{T as a};
1
+ import{a as i}from"./chunk-CWVXTLXZ.js";import{a as f}from"./chunk-ZLLER3HP.js";import{useEffect as J,useState as u,useCallback as m,useRef as s}from"react";var y=5e3;function T(a=20){let[d,b]=u([]),[g,l]=u(null),[h,p]=u(!0),r=s(!1),e=s(null),c=s(0),t=m(async()=>{let o=++c.current;try{let n=await i({limit:a});if(r.current||o!==c.current)return;b(n),l(null)}catch(n){if(r.current||o!==c.current)return;l(n instanceof Error?n.message:String(n))}finally{if(r.current||o!==c.current)return;p(!1),e.current=setTimeout(()=>{t()},y)}},[a]),L=m(()=>{e.current&&clearTimeout(e.current),t()},[t]);return J(()=>(r.current=!1,t(),()=>{r.current=!0,e.current&&clearTimeout(e.current)}),[t]),{jobs:d,error:g,loading:h,refetch:L}}f(T,"useLaunchJobs");export{T as a};
@@ -1 +1 @@
1
- import{c as d,d as t}from"./chunk-3H44B6PB.js";import{a as r}from"./chunk-ZLLER3HP.js";async function g(o,i){let{evalTargetId:s}=o;try{let e=await t({targetId:s,engineFlag:"auto",skipReviewed:!0,log:r(a=>i.logger.info(`[judge-review] ${a}`),"log"),warn:r(a=>i.logger.warn(`[judge-review] ${a}`),"warn")});return{evalTargetId:s,reviewerModel:e.reviewerModel,comparedPairs:e.report.pairs,disagreements:e.report.disagreements.length,persisted:e.persisted,alreadyReviewed:e.alreadyReviewed,deferredPartialRuns:e.deferredPartialRuns}}catch(e){if(e instanceof d)return i.logger.info(`[judge-review] skipped (${e.reason}): ${e.message}`),{evalTargetId:s,skipped:e.reason};throw e}}r(g,"processJudgeReview");export{g as a};
1
+ import{c as d,d as t}from"./chunk-7V6LLVAY.js";import{a as r}from"./chunk-ZLLER3HP.js";async function g(o,i){let{evalTargetId:s}=o;try{let e=await t({targetId:s,engineFlag:"auto",skipReviewed:!0,log:r(a=>i.logger.info(`[judge-review] ${a}`),"log"),warn:r(a=>i.logger.warn(`[judge-review] ${a}`),"warn")});return{evalTargetId:s,reviewerModel:e.reviewerModel,comparedPairs:e.report.pairs,disagreements:e.report.disagreements.length,persisted:e.persisted,alreadyReviewed:e.alreadyReviewed,deferredPartialRuns:e.deferredPartialRuns}}catch(e){if(e instanceof d)return i.logger.info(`[judge-review] skipped (${e.reason}): ${e.message}`),{evalTargetId:s,skipped:e.reason};throw e}}r(g,"processJudgeReview");export{g as a};
@@ -1 +1 @@
1
- import{d as w}from"./chunk-NJ5UED3H.js";import{c as $,d as p}from"./chunk-GIXHG5FK.js";import{a as H,b as k,c as U,d as L,e as O}from"./chunk-XQYAVSUQ.js";import{a as g}from"./chunk-ZLLER3HP.js";import{useCallback as D,useEffect as G,useRef as y,useState as u}from"react";import{Box as q,Text as r,useInput as N}from"ink";import W from"ink-select-input";import X from"ink-text-input";import{spawn as z}from"node:child_process";import{Fragment as T,jsx as s,jsxs as i}from"react/jsx-runtime";function se({width:_,onClose:S}){let[M,j]=u([]),[c,m]=u("status"),[b,A]=u(null),[R,C]=u(""),[E,o]=u(""),[d,P]=u(!1),h=y(!1),v=y(!1),f=y(!0),l=D(async()=>{if(h.current){v.current=!0;return}h.current=!0;try{let t=await Promise.allSettled([p("/api/settings/measurement",{timeoutMs:5e3}).then(e=>L(k.parse(e))),p("/api/settings/harbor",{timeoutMs:5e3}).then(e=>O(U.parse(e)))]);f.current&&j(t.flatMap((e,n)=>e.status==="fulfilled"?e.value:[{id:`error-${n}`,label:n===0?"Measurement unavailable":"Harbor unavailable",detail:e.reason instanceof Error?e.reason.message:String(e.reason)}]))}finally{h.current=!1,v.current&&f.current&&(v.current=!1,l())}},[]);G(()=>{f.current=!0,l();let t=setInterval(()=>void l(),3e4);return()=>{f.current=!1,clearInterval(t)}},[l]);async function I(t,e){let n=H.safeParse({engine:t,model:e.trim()||null});if(!n.success){o(n.error.issues.map(a=>a.message).join("; "));return}P(!0);try{await p("/api/settings/measurement",{method:"PATCH",body:n.data,timeoutMs:5e3}),o("Saved for future opted-in jobs. Schedules and file permissions are unchanged."),m("status"),await l()}catch(a){o(a instanceof Error?a.message:String(a))}finally{P(!1)}}g(I,"save");function x(t){try{let e=new URL(t,process.env.RULEMETRIC_WEB_URL??$()).toString(),n=process.platform==="darwin"?"open":process.platform==="win32"?"rundll32":"xdg-open",a=process.platform==="win32"?["url.dll,FileProtocolHandler",e]:[e],B=z(n,a,{stdio:"ignore"});B.on("error",()=>o(`Open in your browser: ${e}`)),B.on("exit",F=>{F&&o(`Open in your browser: ${e}`)}),o(`Opening ${e}`)}catch(e){o(e instanceof Error?e.message:String(e))}}return g(x,"openPage"),N((t,e)=>{if(!d){if(e.escape){c==="status"?S():(m("status"),o(""));return}c==="status"&&((t==="q"||t==="m")&&S(),t==="r"&&l(),t==="c"&&(o(""),m("engine")),t==="e"&&x("/eval-targets"),t==="t"&&x("/memories"),t==="h"&&x("/settings"))}}),i(q,{width:_,flexDirection:"column",borderStyle:"round",borderColor:w,paddingX:1,children:[s(r,{bold:!0,color:w,children:"Measurement \xB7 account settings"}),c==="status"&&i(T,{children:[M.length===0?s(r,{children:"Loading measurement status\u2026"}):M.map(t=>i(r,{children:[i(r,{bold:!0,children:[t.label,": "]}),t.detail]},t.id)),s(r,{dimColor:!0,children:"Trials compare with/without an instruction or memory within a fixed harness/model. Inspect exclusions and uncertainty before claiming a gain."}),s(r,{children:"c engine/model \xB7 e nightly trials & eval evidence \xB7 t memory trials"}),s(r,{children:"h Harbor/settings \xB7 r refresh \xB7 Esc back (e/t/h open dashboard)"})]}),c==="engine"&&i(T,{children:[s(r,{children:"Choose actor for future opted-in jobs. This does not enable schedules or file rewrites."}),s(W,{items:[{label:"Claude Code",value:"claude"},{label:"Codex",value:"codex"},{label:"Pi",value:"pi"},{label:"Unset \u2014 existing worker defaults",value:"unset"}],onSelect:t=>{if(!d){if(t.value==="unset"){I(null,"");return}A(t.value),C(""),m("model")}}})]}),c==="model"&&i(T,{children:[s(r,{children:b==="pi"?"Required provider/model (Harbor unsupported)":b==="codex"?"Required supported Codex model":"Claude model (blank uses defaults)"}),i(q,{children:[s(r,{children:"Model: "}),s(X,{value:R,onChange:C,focus:!d,onSubmit:()=>{d||I(b,R)}})]}),s(r,{dimColor:!0,children:"Enter saves \xB7 Esc cancels"})]}),d&&s(r,{children:"Saving\u2026"}),E&&s(r,{children:E})]})}g(se,"MeasurementPanel");export{se as a};
1
+ import{d as w}from"./chunk-NJ5UED3H.js";import{c as $,d as p}from"./chunk-Z7UN4R7T.js";import{a as H,b as k,c as U,d as L,e as O}from"./chunk-XQYAVSUQ.js";import{a as g}from"./chunk-ZLLER3HP.js";import{useCallback as D,useEffect as G,useRef as y,useState as u}from"react";import{Box as q,Text as r,useInput as N}from"ink";import W from"ink-select-input";import X from"ink-text-input";import{spawn as z}from"node:child_process";import{Fragment as T,jsx as s,jsxs as i}from"react/jsx-runtime";function se({width:_,onClose:S}){let[M,j]=u([]),[c,m]=u("status"),[b,A]=u(null),[R,C]=u(""),[E,o]=u(""),[d,P]=u(!1),h=y(!1),v=y(!1),f=y(!0),l=D(async()=>{if(h.current){v.current=!0;return}h.current=!0;try{let t=await Promise.allSettled([p("/api/settings/measurement",{timeoutMs:5e3}).then(e=>L(k.parse(e))),p("/api/settings/harbor",{timeoutMs:5e3}).then(e=>O(U.parse(e)))]);f.current&&j(t.flatMap((e,n)=>e.status==="fulfilled"?e.value:[{id:`error-${n}`,label:n===0?"Measurement unavailable":"Harbor unavailable",detail:e.reason instanceof Error?e.reason.message:String(e.reason)}]))}finally{h.current=!1,v.current&&f.current&&(v.current=!1,l())}},[]);G(()=>{f.current=!0,l();let t=setInterval(()=>void l(),3e4);return()=>{f.current=!1,clearInterval(t)}},[l]);async function I(t,e){let n=H.safeParse({engine:t,model:e.trim()||null});if(!n.success){o(n.error.issues.map(a=>a.message).join("; "));return}P(!0);try{await p("/api/settings/measurement",{method:"PATCH",body:n.data,timeoutMs:5e3}),o("Saved for future opted-in jobs. Schedules and file permissions are unchanged."),m("status"),await l()}catch(a){o(a instanceof Error?a.message:String(a))}finally{P(!1)}}g(I,"save");function x(t){try{let e=new URL(t,process.env.RULEMETRIC_WEB_URL??$()).toString(),n=process.platform==="darwin"?"open":process.platform==="win32"?"rundll32":"xdg-open",a=process.platform==="win32"?["url.dll,FileProtocolHandler",e]:[e],B=z(n,a,{stdio:"ignore"});B.on("error",()=>o(`Open in your browser: ${e}`)),B.on("exit",F=>{F&&o(`Open in your browser: ${e}`)}),o(`Opening ${e}`)}catch(e){o(e instanceof Error?e.message:String(e))}}return g(x,"openPage"),N((t,e)=>{if(!d){if(e.escape){c==="status"?S():(m("status"),o(""));return}c==="status"&&((t==="q"||t==="m")&&S(),t==="r"&&l(),t==="c"&&(o(""),m("engine")),t==="e"&&x("/eval-targets"),t==="t"&&x("/memories"),t==="h"&&x("/settings"))}}),i(q,{width:_,flexDirection:"column",borderStyle:"round",borderColor:w,paddingX:1,children:[s(r,{bold:!0,color:w,children:"Measurement \xB7 account settings"}),c==="status"&&i(T,{children:[M.length===0?s(r,{children:"Loading measurement status\u2026"}):M.map(t=>i(r,{children:[i(r,{bold:!0,children:[t.label,": "]}),t.detail]},t.id)),s(r,{dimColor:!0,children:"Trials compare with/without an instruction or memory within a fixed harness/model. Inspect exclusions and uncertainty before claiming a gain."}),s(r,{children:"c engine/model \xB7 e nightly trials & eval evidence \xB7 t memory trials"}),s(r,{children:"h Harbor/settings \xB7 r refresh \xB7 Esc back (e/t/h open dashboard)"})]}),c==="engine"&&i(T,{children:[s(r,{children:"Choose actor for future opted-in jobs. This does not enable schedules or file rewrites."}),s(W,{items:[{label:"Claude Code",value:"claude"},{label:"Codex",value:"codex"},{label:"Pi",value:"pi"},{label:"Unset \u2014 existing worker defaults",value:"unset"}],onSelect:t=>{if(!d){if(t.value==="unset"){I(null,"");return}A(t.value),C(""),m("model")}}})]}),c==="model"&&i(T,{children:[s(r,{children:b==="pi"?"Required provider/model (Harbor unsupported)":b==="codex"?"Required supported Codex model":"Claude model (blank uses defaults)"}),i(q,{children:[s(r,{children:"Model: "}),s(X,{value:R,onChange:C,focus:!d,onSubmit:()=>{d||I(b,R)}})]}),s(r,{dimColor:!0,children:"Enter saves \xB7 Esc cancels"})]}),d&&s(r,{children:"Saving\u2026"}),E&&s(r,{children:E})]})}g(se,"MeasurementPanel");export{se as a};
@@ -1 +1 @@
1
- import{f as u}from"./chunk-GIXHG5FK.js";import{a as m}from"./chunk-ZLLER3HP.js";async function p(n,a,s){if(a)try{let t=Array.isArray(n.recommendation_candidates)?n.recommendation_candidates.filter(e=>typeof e.title=="string"&&typeof e.artifact=="string"&&typeof e.canonicalBody=="string"&&e.canonicalBody.trim().length>=12).map(e=>({title:String(e.title).trim(),artifact:String(e.artifact),canonicalBody:String(e.canonicalBody).trim(),rationale:String(e.rationale??""),evidence:Array.isArray(e.evidence)?e.evidence:[],outcomeMetric:String(e.outcomeMetric??"session_outcome"),renderings:Array.isArray(e.renderings)?e.renderings:[]})):[],i=n.suggestions,l=Array.isArray(i?.claude_md_additions)?i.claude_md_additions.filter(e=>typeof e?.addition=="string"&&e.addition.trim().length>=12).map(e=>({addition:String(e.addition).trim(),why:String(e.why??"")})):[],d=Array.isArray(n.recommended_skills)?n.recommended_skills.filter(e=>typeof e?.skillId=="string"&&e.skillId.length>0).map(e=>({skillId:String(e.skillId),reason:String(e.reason??"")})):[],g=Array.isArray(i?.features_to_try)?i.features_to_try.filter(e=>typeof e?.feature=="string"&&e.feature.trim().length>=2).map(e=>({feature:String(e.feature).trim(),one_liner:String(e.one_liner??""),why_for_you:String(e.why_for_you??""),example_code:String(e.example_code??"")})):[],c=[...Array.isArray(i?.usage_patterns)?i.usage_patterns.map(e=>({title:String(e.title??"").trim(),lead:String(e.suggestion??""),detail:String(e.detail??""),copyable_prompt:String(e.copyable_prompt??""),origin:"usage_pattern"})):[],...Array.isArray(n.on_the_horizon?.opportunities)?n.on_the_horizon.opportunities.map(e=>({title:String(e.title??"").trim(),lead:String(e.whats_possible??""),detail:String(e.how_to_try??""),copyable_prompt:String(e.copyable_prompt??""),origin:"opportunity"})):[]].filter(e=>e.title.length>=2);if(t.length===0&&l.length===0&&d.length===0&&g.length===0&&c.length===0)return;let r=await u("/api/insights/recommendations/nominate",{projectPath:a,candidates:t.slice(0,40),additions:l.slice(0,20),skills:d.slice(0,20),features:g.slice(0,20),advice:c.slice(0,40)}),o=r.additionsRejected??[];s(` ${r.nominated} recommendation(s) nominated into the suggestion feed (${r.additionsCreated} new instruction(s)`+((r.featuresCreated??0)>0?`, ${r.featuresCreated} feature proposal(s)`:"")+((r.adviceCreated??0)>0?`, ${r.adviceCreated} pattern/opportunity`:"")+(r.skillsUnresolved>0?`, ${r.skillsUnresolved} skill slug(s) unresolved`:"")+(o.length>0?`, ${o.length} rejected as unfilled templates`:"")+")");for(let e of o)s(` rejected "${e.name}" \u2014 unfilled placeholder(s): ${e.placeholders.join(", ")}`);for(let e of r.itemsFailed??[])s(` failed "${e.name}" \u2014 ${e.error}`)}catch(t){s(` nomination skipped (whole batch): ${t instanceof Error?t.message:String(t)}`)}}m(p,"nominateRecommendations");export{p as a};
1
+ import{f as u}from"./chunk-Z7UN4R7T.js";import{a as m}from"./chunk-ZLLER3HP.js";async function p(n,a,s){if(a)try{let t=Array.isArray(n.recommendation_candidates)?n.recommendation_candidates.filter(e=>typeof e.title=="string"&&typeof e.artifact=="string"&&typeof e.canonicalBody=="string"&&e.canonicalBody.trim().length>=12).map(e=>({title:String(e.title).trim(),artifact:String(e.artifact),canonicalBody:String(e.canonicalBody).trim(),rationale:String(e.rationale??""),evidence:Array.isArray(e.evidence)?e.evidence:[],outcomeMetric:String(e.outcomeMetric??"session_outcome"),renderings:Array.isArray(e.renderings)?e.renderings:[]})):[],i=n.suggestions,l=Array.isArray(i?.claude_md_additions)?i.claude_md_additions.filter(e=>typeof e?.addition=="string"&&e.addition.trim().length>=12).map(e=>({addition:String(e.addition).trim(),why:String(e.why??"")})):[],d=Array.isArray(n.recommended_skills)?n.recommended_skills.filter(e=>typeof e?.skillId=="string"&&e.skillId.length>0).map(e=>({skillId:String(e.skillId),reason:String(e.reason??"")})):[],g=Array.isArray(i?.features_to_try)?i.features_to_try.filter(e=>typeof e?.feature=="string"&&e.feature.trim().length>=2).map(e=>({feature:String(e.feature).trim(),one_liner:String(e.one_liner??""),why_for_you:String(e.why_for_you??""),example_code:String(e.example_code??"")})):[],c=[...Array.isArray(i?.usage_patterns)?i.usage_patterns.map(e=>({title:String(e.title??"").trim(),lead:String(e.suggestion??""),detail:String(e.detail??""),copyable_prompt:String(e.copyable_prompt??""),origin:"usage_pattern"})):[],...Array.isArray(n.on_the_horizon?.opportunities)?n.on_the_horizon.opportunities.map(e=>({title:String(e.title??"").trim(),lead:String(e.whats_possible??""),detail:String(e.how_to_try??""),copyable_prompt:String(e.copyable_prompt??""),origin:"opportunity"})):[]].filter(e=>e.title.length>=2);if(t.length===0&&l.length===0&&d.length===0&&g.length===0&&c.length===0)return;let r=await u("/api/insights/recommendations/nominate",{projectPath:a,candidates:t.slice(0,40),additions:l.slice(0,20),skills:d.slice(0,20),features:g.slice(0,20),advice:c.slice(0,40)}),o=r.additionsRejected??[];s(` ${r.nominated} recommendation(s) nominated into the suggestion feed (${r.additionsCreated} new instruction(s)`+((r.featuresCreated??0)>0?`, ${r.featuresCreated} feature proposal(s)`:"")+((r.adviceCreated??0)>0?`, ${r.adviceCreated} pattern/opportunity`:"")+(r.skillsUnresolved>0?`, ${r.skillsUnresolved} skill slug(s) unresolved`:"")+(o.length>0?`, ${o.length} rejected as unfilled templates`:"")+")");for(let e of o)s(` rejected "${e.name}" \u2014 unfilled placeholder(s): ${e.placeholders.join(", ")}`);for(let e of r.itemsFailed??[])s(` failed "${e.name}" \u2014 ${e.error}`)}catch(t){s(` nomination skipped (whole batch): ${t instanceof Error?t.message:String(t)}`)}}m(p,"nominateRecommendations");export{p as a};
@@ -0,0 +1 @@
1
+ import{a as v}from"./chunk-U2NT5OSQ.js";import{a as u}from"./chunk-GYNZ3OZF.js";import{c as k,e as E}from"./chunk-UPFH72PF.js";import{a}from"./chunk-ZLLER3HP.js";import{mkdirSync as N,readdirSync as h,rmSync as I,writeFileSync as S}from"node:fs";import{join as p,relative as y,sep as _}from"node:path";var b="v4-claude-neutral-restricted-actor";function C(e){return e==="codex"?"v4-codex-project-neutral-actor-env":e==="pi"?"v2-neutral-workspace":b}a(C,"evalMethodology");var T=["CLAUDE.md","CLAUDE.local.md","AGENTS.md"],A=new Set(["node_modules",".git","dist","build",".next","coverage"]),W={claude:{file:u.claude_code,delivery:"claude_md"},codex:{file:u.codex,delivery:"agents_md"},pi:{file:u.codex,delivery:"agents_md"}};function x(e,s="claude"){let i=[],t=new Set(T);s==="codex"&&t.add("AGENTS.override.md");let d=a(n=>{let r;try{r=h(n,{withFileTypes:!0})}catch{return}for(let o of r){let l=p(n,o.name);if(s==="codex"&&[".codex",".agents"].includes(o.name)){i.push(y(e,l));continue}if(o.isDirectory()){if(A.has(o.name)||o.name.startsWith(".")&&o.name!==".claude")continue;d(l)}else t.has(o.name)&&i.push(y(e,l))}},"walk");return d(e),i}a(x,"findAmbientInstructionFiles");function F(e,s){let i=[];for(let t of x(e,s))try{I(p(e,t),{force:!0,recursive:!0}),i.push(t)}catch{}return i}a(F,"stripAmbientInstructions");function O(e){return/[a-z0-9]/i.test(e??"")?k(e??""):"eval-target-skill"}a(O,"skillSlug");function j(e={}){let{baseDir:s,targetType:i,targetContent:t,targetName:d,engine:n="claude"}=e,r=v(s),o=F(r.workDir,n),l="none",m,f=[];if(t)switch(i){case"prompt":m=t,l="system_prompt";break;case"skill":{if(n!=="claude")throw r.cleanup(),new Error(`createEvalWorkspace: a skill target cannot be measured on ${n} \u2014 .claude/skills is read by Claude Code only, so both arms would run without it.`);let c=O(d),g=E({dirName:c,content:t});D(r.workDir,p(".claude","skills",c,"SKILL.md"),g.text),l="skill";break}default:{let{file:c,delivery:g}=W[n];D(r.workDir,c,t),f.push(c),l=g;break}}let w=x(r.workDir,n).filter(c=>!f.includes(c));return{workDir:r.workDir,systemPrompt:m,delivery:l,methodology:C(n),isWorktree:r.isWorktree,strippedFiles:o,leakedFiles:w,cleanup:r.cleanup}}a(j,"createEvalWorkspace");function D(e,s,i){let t=p(e,s),d=t.slice(0,t.lastIndexOf(_));N(d,{recursive:!0}),S(t,i,"utf8")}a(D,"writeFileInWorkspace");export{b as a,C as b,T as c,x as d,O as e,j as f};
@@ -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-GIXHG5FK.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
+ import{a as s,b as n,c as a,d as g}from"./chunk-3AV3GTMP.js";import{e as o}from"./chunk-Z7UN4R7T.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 +1 @@
1
- import{h as $}from"./chunk-CVPAKEEZ.js";import{h}from"./chunk-FHRBW4AQ.js";import{e as b}from"./chunk-GIXHG5FK.js";import{a as g}from"./chunk-ZLLER3HP.js";import{existsSync as A,statSync as w}from"node:fs";async function R(y,k){let n=g(s=>k?.logger?.info?.(s)??console.log(s),"log"),{projectPath:o}=y,r=`[cron_auto_accept_suggestions] ${o}`;if(!o)return{skipped:"no-project-path"};if(!A(o)||!w(o).isDirectory())return n(`${r}: project directory no longer exists on this machine \u2014 skipping`),{skipped:"project-path-missing"};let e=await $(()=>b(`/api/instruction-suggestions/auto-acceptable?projectPath=${encodeURIComponent(o)}`),{log:n,label:"auto-acceptable",idempotent:!0});if(!e.consent.allowed)return n(`${r}: ${e.consent.reason??"no consent"} (${e.consent.source})`),{skipped:"no-consent",reason:e.consent.reason};for(let s of e.refused)n(`${r}: refused "${s.name}" \u2014 ${s.reason}`);if(e.eligible.length===0)return n(`${r}: nothing to adopt`+(e.budget?` (rules ${e.budget.used}/${e.budget.max}`+(e.budget.skillsUsed!==void 0?`, skills ${e.budget.skillsUsed}`+(e.budget.skillsMax==null?" (uncapped)":`/${e.budget.skillsMax}`):"")+` used in ${e.budget.windowDays}d)`:"")),{skipped:"nothing-eligible",refused:e.refused.length,adopted:0};let i=0,f=0,a=0,l=0,d=0,u=0,c=0,m=[];for(let s of e.eligible)try{let t=await h({suggestionId:s.id,dir:o,projectPath:o,actor:"auto"});if(t.action==="added")i+=1,m.push(t.name),s.type==="skill"&&(f+=1),n(`${r}: adopted ${s.type==="skill"?"skill":"rule"} "${t.name}" (score ${s.score.toFixed(2)})`);else if(t.action==="redundant"){t.partialOverlap?d+=1:l+=1;for(let p of t.messages)n(`${r}: ${p}`)}else if(t.action==="unresolvable-reference"){u+=1;for(let p of t.messages)n(`${r}: ${p}`)}else a+=1,n(`${r}: "${t.name}" was already in CLAUDE.md`)}catch(t){c+=1,n(`${r}: failed to adopt "${s.name}" \u2014 ${t instanceof Error?t.message:String(t)}`)}return n(`${r}: ${i} adopted, ${a} already present, ${l} already covered in other words, ${d} refused for partial overlap, ${u} refused for naming files this project does not have, ${c} failed, ${e.refused.length} refused upstream. Undo any of them with \`rulemetric suggestions undo <instruction-id>\`.`),{adopted:i,skills:f,alreadyPresent:a,redundant:l,partialOverlaps:d,unresolvableReferences:u,failed:c,refused:e.refused.length,names:m}}g(R,"cronAutoAcceptSuggestions");export{R as a};
1
+ import{h as $}from"./chunk-R7URROQD.js";import{h}from"./chunk-KSKC5SEQ.js";import{e as b}from"./chunk-Z7UN4R7T.js";import{a as g}from"./chunk-ZLLER3HP.js";import{existsSync as A,statSync as w}from"node:fs";async function R(y,k){let n=g(s=>k?.logger?.info?.(s)??console.log(s),"log"),{projectPath:o}=y,r=`[cron_auto_accept_suggestions] ${o}`;if(!o)return{skipped:"no-project-path"};if(!A(o)||!w(o).isDirectory())return n(`${r}: project directory no longer exists on this machine \u2014 skipping`),{skipped:"project-path-missing"};let e=await $(()=>b(`/api/instruction-suggestions/auto-acceptable?projectPath=${encodeURIComponent(o)}`),{log:n,label:"auto-acceptable",idempotent:!0});if(!e.consent.allowed)return n(`${r}: ${e.consent.reason??"no consent"} (${e.consent.source})`),{skipped:"no-consent",reason:e.consent.reason};for(let s of e.refused)n(`${r}: refused "${s.name}" \u2014 ${s.reason}`);if(e.eligible.length===0)return n(`${r}: nothing to adopt`+(e.budget?` (rules ${e.budget.used}/${e.budget.max}`+(e.budget.skillsUsed!==void 0?`, skills ${e.budget.skillsUsed}`+(e.budget.skillsMax==null?" (uncapped)":`/${e.budget.skillsMax}`):"")+` used in ${e.budget.windowDays}d)`:"")),{skipped:"nothing-eligible",refused:e.refused.length,adopted:0};let i=0,f=0,a=0,l=0,d=0,u=0,c=0,m=[];for(let s of e.eligible)try{let t=await h({suggestionId:s.id,dir:o,projectPath:o,actor:"auto"});if(t.action==="added")i+=1,m.push(t.name),s.type==="skill"&&(f+=1),n(`${r}: adopted ${s.type==="skill"?"skill":"rule"} "${t.name}" (score ${s.score.toFixed(2)})`);else if(t.action==="redundant"){t.partialOverlap?d+=1:l+=1;for(let p of t.messages)n(`${r}: ${p}`)}else if(t.action==="unresolvable-reference"){u+=1;for(let p of t.messages)n(`${r}: ${p}`)}else a+=1,n(`${r}: "${t.name}" was already in CLAUDE.md`)}catch(t){c+=1,n(`${r}: failed to adopt "${s.name}" \u2014 ${t instanceof Error?t.message:String(t)}`)}return n(`${r}: ${i} adopted, ${a} already present, ${l} already covered in other words, ${d} refused for partial overlap, ${u} refused for naming files this project does not have, ${c} failed, ${e.refused.length} refused upstream. Undo any of them with \`rulemetric suggestions undo <instruction-id>\`.`),{adopted:i,skills:f,alreadyPresent:a,redundant:l,partialOverlaps:d,unresolvableReferences:u,failed:c,refused:e.refused.length,names:m}}g(R,"cronAutoAcceptSuggestions");export{R as a};
@@ -0,0 +1 @@
1
+ import{a as A}from"./chunk-ZLLER3HP.js";var s=["HOME","PATH","USER","LOGNAME","SHELL","TMPDIR","TMP","TEMP","LANG","LC_ALL","TZ","SSL_CERT_FILE","NODE_EXTRA_CA_CERTS","ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN","ANTHROPIC_BASE_URL","CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CONFIG_DIR","OPENAI_API_KEY","OPENAI_BASE_URL","CODEX_HOME"],T=["CLAUDECODE","HTTPS_PROXY","HTTP_PROXY","ALL_PROXY"],t=["/opt/homebrew/bin","/usr/local/bin"];function O(n=process.env){let o={};for(let E of s)n[E]!==void 0&&(o[E]=n[E]);for(let E of T)delete o[E];let _=(o.PATH??"").split(":").filter(Boolean),e=t.filter(E=>!_.includes(E));return e.length&&(o.PATH=[..._,...e].join(":")),o}A(O,"buildActorEnv");export{s as a,O as b};