@rulemetric/cli 0.12.2 → 0.12.4

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 (204) hide show
  1. package/dist/base-command.js +1 -1
  2. package/dist/{chunk-GP46IPK2.js → chunk-2AVGUZ2P.js} +1 -1
  3. package/dist/{chunk-ZHYCFUGJ.js → chunk-2IEYDOFE.js} +1 -1
  4. package/dist/chunk-2K3RUBKC.js +3 -0
  5. package/dist/{chunk-UK7BR6XM.js → chunk-2MZFB46B.js} +1 -1
  6. package/dist/{chunk-3RN3LDUC.js → chunk-3JSYVZOB.js} +1 -1
  7. package/dist/{chunk-PHO4W7UH.js → chunk-4XLMX642.js} +1 -1
  8. package/dist/{chunk-GAFMAVFO.js → chunk-5BTNALJL.js} +1 -1
  9. package/dist/{chunk-FI3YELW3.js → chunk-5C3DRKW3.js} +1 -1
  10. package/dist/{chunk-JKXU7FAY.js → chunk-65TQMBNF.js} +1 -1
  11. package/dist/{chunk-RDXWQDNZ.js → chunk-6PUH7HEL.js} +1 -1
  12. package/dist/{chunk-YE5ARPHO.js → chunk-7BLO7ECB.js} +1 -1
  13. package/dist/chunk-APXQLQZY.js +1 -0
  14. package/dist/{chunk-2G4LYY6O.js → chunk-CRPOQMQ2.js} +1 -1
  15. package/dist/{chunk-QEKWPQDQ.js → chunk-D4UDSY7Y.js} +1 -1
  16. package/dist/chunk-D55QB3QI.js +1 -0
  17. package/dist/{chunk-UK5JOTMW.js → chunk-E7N5R3HV.js} +1 -1
  18. package/dist/{chunk-FZ537XIW.js → chunk-FIPW2SGV.js} +1 -1
  19. package/dist/{chunk-BFDXMIXO.js → chunk-FNMJ6E6F.js} +1 -1
  20. package/dist/{chunk-I2CXODLD.js → chunk-J35L3LR3.js} +1 -1
  21. package/dist/{chunk-YYM2TW2D.js → chunk-K6T4ODPZ.js} +1 -1
  22. package/dist/{chunk-D3CZJ6CZ.js → chunk-KHCMVYTH.js} +1 -1
  23. package/dist/{chunk-4XPH2EH4.js → chunk-LDQ6FLET.js} +1 -1
  24. package/dist/{chunk-355GZ7LR.js → chunk-LVAROIKP.js} +1 -1
  25. package/dist/{chunk-4MXLDBLV.js → chunk-LW3UE2FY.js} +1 -1
  26. package/dist/{chunk-N2AIDOYF.js → chunk-LYP3LNFL.js} +1 -1
  27. package/dist/{chunk-ATSZBAG5.js → chunk-LZJXW3B6.js} +1 -1
  28. package/dist/{chunk-L6NQNVK2.js → chunk-MOY7XDR6.js} +1 -1
  29. package/dist/chunk-NMWP3JLW.js +1 -0
  30. package/dist/chunk-OCHAV6YZ.js +1 -0
  31. package/dist/{chunk-IZHJNPER.js → chunk-OEZNBFJ2.js} +1 -1
  32. package/dist/chunk-OOGTQOL3.js +48 -0
  33. package/dist/{chunk-EFLPMXJY.js → chunk-PMW35N32.js} +1 -1
  34. package/dist/{chunk-IS4JRZK2.js → chunk-PQMWZHEY.js} +1 -1
  35. package/dist/{chunk-KOQRNWIW.js → chunk-QLG6OCYF.js} +1 -1
  36. package/dist/chunk-QUOH6GWM.js +1 -0
  37. package/dist/{chunk-FPOPUEA6.js → chunk-RK2LZIBA.js} +1 -1
  38. package/dist/{chunk-6LYWI22A.js → chunk-SD626JBZ.js} +1 -1
  39. package/dist/{chunk-V6IYMQL6.js → chunk-SJKS3PYX.js} +8 -17
  40. package/dist/{chunk-ANSK2LTP.js → chunk-SVON2JIS.js} +1 -1
  41. package/dist/{chunk-EINQYO2T.js → chunk-SZUH54L4.js} +1 -1
  42. package/dist/{chunk-CJ4NG6FL.js → chunk-T67L2YTW.js} +1 -1
  43. package/dist/{chunk-NNOSORNV.js → chunk-TJYXSMQV.js} +1 -1
  44. package/dist/{chunk-FLSDLFUE.js → chunk-TZUTX4PG.js} +1 -1
  45. package/dist/{chunk-ZSOYH7FX.js → chunk-UQSUSB6G.js} +1 -1
  46. package/dist/{chunk-V3CAUY7M.js → chunk-VC3DJPUB.js} +1 -1
  47. package/dist/{chunk-E2QYH6EF.js → chunk-VIFE47RC.js} +1 -1
  48. package/dist/{chunk-HNAVHRGY.js → chunk-VTUTSUFW.js} +1 -1
  49. package/dist/{chunk-Y3T5Q5CD.js → chunk-WRQEHXSN.js} +1 -1
  50. package/dist/{chunk-4NAYH7VA.js → chunk-XUGWUFIQ.js} +1 -1
  51. package/dist/{chunk-76MON4SR.js → chunk-XZY2W3D3.js} +1 -1
  52. package/dist/chunk-Y6TAPCA5.js +13 -0
  53. package/dist/{chunk-3CX6YUEX.js → chunk-YRTG6SX6.js} +1 -1
  54. package/dist/{chunk-OJSWNU56.js → chunk-YTPQ7VBO.js} +1 -1
  55. package/dist/{chunk-NEP5EWHJ.js → chunk-ZQJWKIJS.js} +1 -1
  56. package/dist/commands/antigravity/backfill.js +1 -1
  57. package/dist/commands/auth/create-key.js +1 -1
  58. package/dist/commands/auth/login.js +1 -1
  59. package/dist/commands/auth/logout.js +1 -1
  60. package/dist/commands/auth/revoke-key.js +1 -1
  61. package/dist/commands/auth/signup.js +1 -1
  62. package/dist/commands/auth/status.js +1 -1
  63. package/dist/commands/capture/scope.js +1 -1
  64. package/dist/commands/catalog/index.js +1 -1
  65. package/dist/commands/catalog/recommend.js +1 -1
  66. package/dist/commands/crons/list.js +1 -1
  67. package/dist/commands/crons/run.js +1 -1
  68. package/dist/commands/dashboard.js +1 -1
  69. package/dist/commands/diagnostics.js +1 -1
  70. package/dist/commands/eval-targets/create.js +1 -1
  71. package/dist/commands/eval-targets/list.js +1 -1
  72. package/dist/commands/evals/agent.js +1 -1
  73. package/dist/commands/evals/auto-run.js +1 -1
  74. package/dist/commands/evals/benchmark.js +1 -1
  75. package/dist/commands/evals/compare.js +1 -1
  76. package/dist/commands/evals/create.js +1 -1
  77. package/dist/commands/evals/optimize-description.js +1 -1
  78. package/dist/commands/evals/optimize.js +1 -1
  79. package/dist/commands/evals/refine-cases.js +1 -1
  80. package/dist/commands/evals/run.js +1 -1
  81. package/dist/commands/evals/validate-judge.js +1 -1
  82. package/dist/commands/experiments/list.js +1 -1
  83. package/dist/commands/gateway/ensure.js +1 -1
  84. package/dist/commands/hooks/install.js +1 -1
  85. package/dist/commands/hooks/run.js +1 -1
  86. package/dist/commands/hooks/uninstall.js +1 -1
  87. package/dist/commands/instructions/create.js +1 -1
  88. package/dist/commands/instructions/dedupe.js +1 -1
  89. package/dist/commands/instructions/delete.js +1 -1
  90. package/dist/commands/instructions/fork.js +1 -1
  91. package/dist/commands/instructions/get.js +1 -1
  92. package/dist/commands/instructions/list.js +1 -1
  93. package/dist/commands/instructions/promote.js +1 -1
  94. package/dist/commands/instructions/pull.js +1 -1
  95. package/dist/commands/instructions/restore.js +1 -1
  96. package/dist/commands/instructions/retract.js +1 -1
  97. package/dist/commands/instructions/upstream.js +1 -1
  98. package/dist/commands/instructions/versions.js +1 -1
  99. package/dist/commands/launcher.js +1 -1
  100. package/dist/commands/local/down.js +1 -1
  101. package/dist/commands/local/up.js +1 -1
  102. package/dist/commands/org/current.js +1 -1
  103. package/dist/commands/org/list.js +1 -1
  104. package/dist/commands/org/switch.js +1 -1
  105. package/dist/commands/packs/add-instruction.js +1 -1
  106. package/dist/commands/packs/apply.js +1 -1
  107. package/dist/commands/packs/create.js +1 -1
  108. package/dist/commands/packs/fork.js +1 -1
  109. package/dist/commands/packs/get.js +1 -1
  110. package/dist/commands/packs/list.js +1 -1
  111. package/dist/commands/packs/remove-instruction.js +1 -1
  112. package/dist/commands/proxy/env.js +1 -1
  113. package/dist/commands/proxy/logs.js +1 -1
  114. package/dist/commands/proxy/restart.js +1 -1
  115. package/dist/commands/proxy/setup.js +1 -1
  116. package/dist/commands/proxy/start.js +1 -1
  117. package/dist/commands/proxy/status.js +1 -1
  118. package/dist/commands/proxy/stop.js +1 -1
  119. package/dist/commands/research/backfill.js +1 -1
  120. package/dist/commands/research/tail-transcript.js +1 -1
  121. package/dist/commands/service/install.js +1 -1
  122. package/dist/commands/service/status.js +1 -1
  123. package/dist/commands/service/uninstall.js +1 -1
  124. package/dist/commands/sessions/analyze.js +1 -1
  125. package/dist/commands/sessions/delete.js +1 -1
  126. package/dist/commands/sessions/end.js +1 -1
  127. package/dist/commands/sessions/import.js +1 -1
  128. package/dist/commands/sessions/list.js +1 -1
  129. package/dist/commands/sessions/start.js +1 -1
  130. package/dist/commands/setup.js +1 -1
  131. package/dist/commands/skills/export-approved.js +1 -1
  132. package/dist/commands/skills/install.js +2 -2
  133. package/dist/commands/skills/list.js +1 -1
  134. package/dist/commands/skills/publish.js +1 -1
  135. package/dist/commands/skills/search.js +2 -2
  136. package/dist/commands/skills/update.js +1 -1
  137. package/dist/commands/suggestions/accept.js +1 -1
  138. package/dist/commands/suggestions/auto.js +1 -1
  139. package/dist/commands/suggestions/dismiss.js +1 -1
  140. package/dist/commands/suggestions/list.js +1 -1
  141. package/dist/commands/suggestions/refresh.js +1 -1
  142. package/dist/commands/suggestions/undo.js +1 -1
  143. package/dist/dashboard/Dashboard.js +1 -1
  144. package/dist/dashboard/data.js +1 -1
  145. package/dist/dashboard/launcher/LauncherOverlay.js +1 -1
  146. package/dist/dashboard/launcher/api.js +1 -1
  147. package/dist/dashboard/launcher/useLaunchJobs.js +1 -1
  148. package/dist/lib/active-org-refresh.js +1 -1
  149. package/dist/lib/agent-loop.js +1 -1
  150. package/dist/lib/antigravity-transcript.js +1 -1
  151. package/dist/lib/api-client.js +1 -1
  152. package/dist/lib/attribution-recovery.js +1 -0
  153. package/dist/lib/ensure-api-key.js +1 -1
  154. package/dist/lib/ensure-fresh-token.js +1 -1
  155. package/dist/lib/eval-benchmark.js +1 -1
  156. package/dist/lib/eval-candidate-run.js +1 -1
  157. package/dist/lib/eval-conversation-handler.js +1 -1
  158. package/dist/lib/eval-resume.js +1 -1
  159. package/dist/lib/eval-run-batch.js +1 -1
  160. package/dist/lib/evolution-enrolment.js +1 -1
  161. package/dist/lib/insights/generation/installed-asks.js +1 -1
  162. package/dist/lib/insights/generation/prompts.js +1 -1
  163. package/dist/lib/insights/nomination/nominate.js +1 -1
  164. package/dist/lib/instructions/acceptance/accept-events.js +1 -1
  165. package/dist/lib/instructions/acceptance/accept-hook.js +1 -1
  166. package/dist/lib/instructions/acceptance/hook-install.js +1 -1
  167. package/dist/lib/instructions/acceptance/reverse-applications.js +1 -1
  168. package/dist/lib/instructions/acceptance/suggestion-accept.js +1 -1
  169. package/dist/lib/jobs/handlers/cron-auto-accept-suggestions.js +1 -1
  170. package/dist/lib/jobs/handlers/cron-eval-autorun.js +1 -1
  171. package/dist/lib/jobs/handlers/cron-instruction-evolution.js +1 -1
  172. package/dist/lib/jobs/handlers/cron-instruction-training.js +1 -1
  173. package/dist/lib/jobs/handlers/cron-reconcile-attribution.js +1 -0
  174. package/dist/lib/jobs/handlers/cron-refine-cases.js +1 -1
  175. package/dist/lib/jobs/handlers/cron-refresh-pricing.js +1 -1
  176. package/dist/lib/jobs/handlers/cron-retire-unused-skills.js +1 -1
  177. package/dist/lib/jobs/handlers/cron-suggest-instructions.js +1 -1
  178. package/dist/lib/jobs/handlers/distill-memories.js +1 -1
  179. package/dist/lib/jobs/handlers/process-changelog.js +1 -1
  180. package/dist/lib/jobs/handlers/process-conversation.js +1 -1
  181. package/dist/lib/jobs/handlers/process-eval.js +1 -1
  182. package/dist/lib/jobs/handlers/process-insights.js +1 -1
  183. package/dist/lib/jobs/handlers/process-judge-review.js +1 -1
  184. package/dist/lib/jobs/handlers/process-launch.js +1 -1
  185. package/dist/lib/jobs/handlers/process-memory-ab.js +1 -1
  186. package/dist/lib/jobs/handlers/process-run-cleanup.js +1 -1
  187. package/dist/lib/jobs/handlers/process-session-goal.js +1 -1
  188. package/dist/lib/judge-review-runner.js +1 -1
  189. package/dist/lib/manual-tasks-meta.js +1 -1
  190. package/dist/lib/manual-tasks.js +1 -1
  191. package/dist/lib/refine-cases.js +1 -1
  192. package/dist/lib/research-client.js +1 -1
  193. package/dist/lib/retraction.js +1 -1
  194. package/dist/lib/setup-steps.js +1 -1
  195. package/dist/lib/telemetry.js +1 -1
  196. package/dist/lib/terminal-target-heartbeat.js +1 -1
  197. package/oclif.manifest.json +3 -3
  198. package/package.json +6 -6
  199. package/dist/chunk-7HJJCRYK.js +0 -1
  200. package/dist/chunk-DS4P5C4F.js +0 -48
  201. package/dist/chunk-GY5IJ4RS.js +0 -1
  202. package/dist/chunk-IFLFSHMN.js +0 -13
  203. package/dist/chunk-J7E4BQYZ.js +0 -1
  204. package/dist/chunk-YS5UJKK5.js +0 -1
@@ -1 +1 @@
1
- import{a as E}from"./chunk-ANSK2LTP.js";import{b as R,c as x}from"./chunk-KGURGIZ2.js";import{f as F}from"./chunk-GP46IPK2.js";import{a as s}from"./chunk-ZLLER3HP.js";var A="with_candidate",$="with_prior_version";function k(n){let t=n.filter(e=>e.configuration===A),r=[];for(let e of t){let u=n.find(o=>o.configuration===$&&o.evalId===e.evalId&&o.runNumber===e.runNumber);if(!u)continue;let l=h(e),f=h(u);l==null||f==null||r.push({withScore:l,withoutScore:f})}return r}s(k,"pairCandidateRuns");function h(n){return n.status!=="completed"?null:n.grading?.summary?.pass_rate??null}s(h,"evidenceOf");function P(n){let t=[],r=0;for(let e of n){if(e.status==="failed"){t.push(e.failure??{kind:"unknown",class:"infrastructure"});continue}h(e)==null&&(r+=1)}return{infrastructureFailed:t.length,ungradeable:r,summary:R(t)}}s(P,"accountForFailures");function Q(n){let{pairs:t,minPairs:r,accounting:e}=n;return t>=r?{kind:"proceed"}:e.infrastructureFailed<=0?{kind:"proceed"}:{kind:"infrastructure-incomplete",reason:`${t}/${r} pair(s) \u2014 ${e.infrastructureFailed} run(s) never executed (${e.summary.describe()}). Retry when the environment recovers; this is not a statement about the target.`}}s(Q,"attributeShortfall");function w(n,t,r,e){let u=[];for(let l of n)u.push({eval_:l,configuration:A,targetContent:t,runNumber:e}),u.push({eval_:l,configuration:$,targetContent:r,runNumber:e});return u}s(w,"buildCandidateQueue");async function N(n){let{cases:t,candidateContent:r,priorVersionContent:e,concurrency:u,runNumber:l,opts:f,onLog:o=s(()=>{},"onLog")}=n,p=w(t,r,e,l),i=[],b=Math.max(1,u),g=null;for(let a=0;a<p.length;a+=b){let d=p.slice(a,a+b);i.push(...await Promise.all(d.map(c=>E(c,f,o))));let y=i.find(c=>c.failure&&x(c.failure.kind));if(y?.failure){g=y.failure.kind;let c=p.length-i.length;o(` \u26D4 aborting batch \u2014 ${g}: the account is out of quota. Skipped ${c} remaining run(s) that would certainly have failed.`);break}}for(let a of i)try{await F("/api/eval-runs",a)}catch(d){o(` \u26A0 failed to post a run result: ${d instanceof Error?d.message:String(d)}`)}let C=k(i),m=P(i),v=t.length-C.length;if(v>0){let a=m.infrastructureFailed?` \u2014 ${m.infrastructureFailed} run(s) never executed (${m.summary.describe()})`:"";o(` \u26A0 ${v}/${t.length} case(s) produced no usable pair (failed or ungradeable arm)${a}`)}return{completed:i.filter(a=>a.status==="completed").length,failed:i.filter(a=>a.status==="failed").length,results:i,pairs:C,accounting:m,abortedForQuota:g}}s(N,"runCandidateBatchAndPost");export{A as a,$ as b,k as c,P as d,Q as e,w as f,N as g};
1
+ import{a as E}from"./chunk-SVON2JIS.js";import{b as R,c as x}from"./chunk-KGURGIZ2.js";import{f as F}from"./chunk-2AVGUZ2P.js";import{a as s}from"./chunk-ZLLER3HP.js";var A="with_candidate",$="with_prior_version";function k(n){let t=n.filter(e=>e.configuration===A),r=[];for(let e of t){let u=n.find(o=>o.configuration===$&&o.evalId===e.evalId&&o.runNumber===e.runNumber);if(!u)continue;let l=h(e),f=h(u);l==null||f==null||r.push({withScore:l,withoutScore:f})}return r}s(k,"pairCandidateRuns");function h(n){return n.status!=="completed"?null:n.grading?.summary?.pass_rate??null}s(h,"evidenceOf");function P(n){let t=[],r=0;for(let e of n){if(e.status==="failed"){t.push(e.failure??{kind:"unknown",class:"infrastructure"});continue}h(e)==null&&(r+=1)}return{infrastructureFailed:t.length,ungradeable:r,summary:R(t)}}s(P,"accountForFailures");function Q(n){let{pairs:t,minPairs:r,accounting:e}=n;return t>=r?{kind:"proceed"}:e.infrastructureFailed<=0?{kind:"proceed"}:{kind:"infrastructure-incomplete",reason:`${t}/${r} pair(s) \u2014 ${e.infrastructureFailed} run(s) never executed (${e.summary.describe()}). Retry when the environment recovers; this is not a statement about the target.`}}s(Q,"attributeShortfall");function w(n,t,r,e){let u=[];for(let l of n)u.push({eval_:l,configuration:A,targetContent:t,runNumber:e}),u.push({eval_:l,configuration:$,targetContent:r,runNumber:e});return u}s(w,"buildCandidateQueue");async function N(n){let{cases:t,candidateContent:r,priorVersionContent:e,concurrency:u,runNumber:l,opts:f,onLog:o=s(()=>{},"onLog")}=n,p=w(t,r,e,l),i=[],b=Math.max(1,u),g=null;for(let a=0;a<p.length;a+=b){let d=p.slice(a,a+b);i.push(...await Promise.all(d.map(c=>E(c,f,o))));let y=i.find(c=>c.failure&&x(c.failure.kind));if(y?.failure){g=y.failure.kind;let c=p.length-i.length;o(` \u26D4 aborting batch \u2014 ${g}: the account is out of quota. Skipped ${c} remaining run(s) that would certainly have failed.`);break}}for(let a of i)try{await F("/api/eval-runs",a)}catch(d){o(` \u26A0 failed to post a run result: ${d instanceof Error?d.message:String(d)}`)}let C=k(i),m=P(i),v=t.length-C.length;if(v>0){let a=m.infrastructureFailed?` \u2014 ${m.infrastructureFailed} run(s) never executed (${m.summary.describe()})`:"";o(` \u26A0 ${v}/${t.length} case(s) produced no usable pair (failed or ungradeable arm)${a}`)}return{completed:i.filter(a=>a.status==="completed").length,failed:i.filter(a=>a.status==="failed").length,results:i,pairs:C,accounting:m,abortedForQuota:g}}s(N,"runCandidateBatchAndPost");export{A as a,$ as b,k as c,P as d,Q as e,w as f,N as g};
@@ -1,5 +1,5 @@
1
- import{a as i}from"./chunk-ZLLER3HP.js";function r(n){let o=n.dismissed.filter(e=>e.label.trim()!==""),s=n.repeated.filter(e=>e.label.trim()!==""),a=(n.installed??[]).filter(e=>e.trim()!=="");if(o.length===0&&s.length===0&&a.length===0)return"";let t=[];return(o.length>0||s.length>0)&&t.push("","## ADVICE YOU HAVE ALREADY GIVEN THIS USER","This is your own prior output for this project. Use it to say something NEW."),o.length>0&&t.push("","DISMISSED by the user \u2014 do NOT propose these again, and do not propose a","reworded version of them. A paraphrase of a dismissed suggestion is still","the dismissed suggestion:",...o.map(e=>`- [${e.category}] ${e.label}`)),s.length>0&&t.push("","ALREADY GENERATED, sometimes repeatedly. Repeat one ONLY if it is still","the single most important finding in the data \u2014 otherwise prefer a new","observation over restating these:",...s.map(e=>`- [${e.category}] ${e.label} (generated ${e.timesGenerated}x)`)),a.length>0&&(t.push("","## ALREADY INSTALLED IN THIS PROJECT'S INSTRUCTION FILES","The agent reads these on every session in this project. They are the","user's own rules, not your suggestions. Do not propose them, and do not","propose a reworded version of one.","","If an idea is PARTLY here, propose only the part that is not \u2014 a block","mixing new asks with restatements is refused whole and its new asks are","lost with it. One ask per proposal is always safe.","",...a.map(e=>`- ${e}`)),(n.installedOmitted??0)>0&&t.push(`- (+${n.installedOmitted} more not shown \u2014 this project has more rules than fit here,`," so treat the list as a sample rather than the full set.)")),t.join(`
2
- `)}i(r,"renderGeneratorMemory");var d=[{name:"project_areas",usesGeneratorMemory:!0,prompt:`Analyze this Claude Code usage data and identify project areas.
1
+ import{a}from"./chunk-ZLLER3HP.js";function r(o){let s=o.dismissed.filter(e=>e.label.trim()!==""),n=o.repeated.filter(e=>e.label.trim()!==""),i=(o.installed??[]).filter(e=>e.trim()!=="");if(s.length===0&&n.length===0&&i.length===0)return"";let t=[];return(s.length>0||n.length>0)&&t.push("","## ADVICE YOU HAVE ALREADY GIVEN THIS USER","This is your own prior output for this project. Use it to say something NEW."),s.length>0&&t.push("","DISMISSED by the user \u2014 do NOT propose these again, and do not propose a","reworded version of them. A paraphrase of a dismissed suggestion is still","the dismissed suggestion:",...s.map(e=>`- [${e.category}] ${e.label}`)),n.length>0&&t.push("","ALREADY GENERATED, sometimes repeatedly. Repeat one ONLY if it is still","the single most important finding in the data \u2014 otherwise prefer a new","observation over restating these:",...n.map(e=>`- [${e.category}] ${e.label} (generated ${e.timesGenerated}x)`)),i.length>0&&(t.push("","## ALREADY INSTALLED IN THIS PROJECT'S INSTRUCTION FILES","The agent reads these on every session in this project. They are the","user's own rules, not your suggestions. Do not propose them, and do not","propose a reworded version of one.","","If an idea is PARTLY here, propose only the part that is not \u2014 a block","mixing new asks with restatements is refused whole and its new asks are","lost with it. One ask per proposal is always safe.","",...i.map(e=>`- ${e}`)),(o.installedOmitted??0)>0&&t.push(`- (+${o.installedOmitted} more not shown \u2014 this project has more rules than fit here,`," so treat the list as a sample rather than the full set.)")),t.join(`
2
+ `)}a(r,"renderGeneratorMemory");var d=[{name:"project_areas",usesGeneratorMemory:!0,prompt:`Analyze this Claude Code usage data and identify project areas.
3
3
  RESPOND WITH ONLY A VALID JSON OBJECT:
4
4
  {
5
5
  "areas": [
@@ -30,7 +30,7 @@ RESPOND WITH ONLY A VALID JSON OBJECT:
30
30
  Include 3 friction categories with 2 examples each.`,maxTokens:8192},{name:"suggestions",usesGeneratorMemory:!0,timeoutMs:42e4,prompt:`Analyze this cross-harness coding-agent usage data and suggest the smallest changes that address the evidence.
31
31
 
32
32
  Choose the artifact honestly:
33
- - "instruction": durable behavioral guidance; render for "claude_code" in CLAUDE.md and "codex" in AGENTS.md when applicable.
33
+ - "instruction": durable behavioral guidance for CLAUDE.md / AGENTS.md.
34
34
  - "skill": a reusable, user-invoked markdown workflow.
35
35
  - "hook": lifecycle enforcement that runs a command.
36
36
  - "script": a repeated command chain worth making deterministic.
@@ -39,34 +39,25 @@ Choose the artifact honestly:
39
39
  - "routine": periodic work or a scheduled check.
40
40
  - "feature": human-facing advice that does not fit the types above.
41
41
 
42
- Executable artifacts (hook, script, mcp, subagent, routine) are proposals for human review, never silent installs. Do not translate Codex evidence into Claude-only commands. Use a "manual" target when a harness-safe rendering is unavailable.
42
+ Executable artifacts (hook, script, mcp, subagent, routine) are proposals for human review, never silent installs. Do not translate Codex evidence into Claude-only commands.
43
+ Write each proposal ONCE, as one candidate. Do not repeat a proposal in another form.
43
44
  RESPOND WITH ONLY A VALID JSON OBJECT:
44
45
  {
45
46
  "recommendation_candidates": [
46
47
  {
47
48
  "title": "Short stable title",
48
49
  "artifact": "instruction|skill|hook|script|mcp|subagent|routine|feature",
49
- "canonicalBody": "Harness-neutral meaning or complete proposed artifact",
50
+ "canonicalBody": "Harness-neutral meaning, or the complete proposed artifact",
50
51
  "rationale": "Why the evidence supports this change",
51
52
  "evidence": [{"sessionId": "optional session id", "finding": "Observed behavior"}],
52
- "outcomeMetric": "The outcome or recurrence metric this change should improve",
53
- "renderings": [
54
- {"harness": "claude_code", "target": "CLAUDE.md", "body": "Claude Code rendering"},
55
- {"harness": "codex", "target": "AGENTS.md", "body": "Codex rendering"}
56
- ]
53
+ "outcomeMetric": "The outcome or recurrence metric this change should improve"
57
54
  }
58
55
  ],
59
- "claude_md_additions": [
60
- {"addition": "Legacy presentation copy of each Claude instruction rendering", "why": "1 sentence explaining why", "prompt_scaffold": "Instructions for where to add this"}
61
- ],
62
- "features_to_try": [
63
- {"feature": "Human-facing non-instruction proposal", "one_liner": "What it does", "why_for_you": "Why this would help YOU", "example_code": "Complete example to review"}
64
- ],
65
56
  "usage_patterns": [
66
57
  {"title": "Short title", "suggestion": "1-2 sentence summary", "detail": "3-4 sentences explaining how this applies", "copyable_prompt": "A specific prompt to copy and try"}
67
58
  ]
68
59
  }
69
- Include 3-6 canonical candidates. Keep the legacy arrays aligned with those candidates for older clients; do not invent additional legacy-only recommendations.`,maxTokens:8192},{name:"on_the_horizon",usesGeneratorMemory:!0,timeoutMs:24e4,prompt:`Analyze this Claude Code usage data and identify future opportunities.
60
+ Include 3-6 candidates. Per-harness renderings are derived from canonicalBody \u2014 do not write them.`,maxTokens:8192},{name:"on_the_horizon",usesGeneratorMemory:!0,timeoutMs:24e4,prompt:`Analyze this Claude Code usage data and identify future opportunities.
70
61
  RESPOND WITH ONLY A VALID JSON OBJECT:
71
62
  {
72
63
  "intro": "1 sentence about evolving AI-assisted development",
@@ -1 +1 @@
1
- import{e as k}from"./chunk-GN3ZHQ46.js";import{a as f}from"./chunk-KGURGIZ2.js";import{a as $}from"./chunk-BJSVATVJ.js";import{d as v}from"./chunk-TZA4HAVF.js";import{f as p}from"./chunk-GP46IPK2.js";import{a as c}from"./chunk-ZLLER3HP.js";async function x(m,t,s=()=>{}){let{eval_:r,configuration:i,targetContent:g,runNumber:o}=m;s(`[${i}] ${r.name} run#${o} \u2014 executing...`);let a=k({targetType:t.targetType,targetContent:g,targetName:t.targetName}),d={methodology:a.methodology,delivery:a.delivery,isolated:a.isWorktree,...t.candidateContentHash?{candidateContentHash:t.candidateContentHash}:{},...a.leakedFiles.length?{leakedFiles:a.leakedFiles}:{}};a.isWorktree||s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 no git worktree; running without repo context`),a.leakedFiles.length&&s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 CONTAMINATED: ${a.leakedFiles.join(", ")} survived the strip`);try{let n=await v({prompt:r.prompt,targetContent:a.systemPrompt,workDir:a.workDir,timeout:t.timeout,model:t.model});if(n.error){let e=f(n.error);return s(`[${i}] ${r.name} run#${o} \u2014 FAILED (${e.kind}): ${n.error}`),{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"failed",outputs:{error:n.error,failureKind:e.kind,failureClass:e.class,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens},grading:{},failure:e}}s(`[${i}] ${r.name} run#${o} \u2014 completed in ${(n.durationMs/1e3).toFixed(1)}s`);let u={};if(!t.skipGrading&&r.expectations.length>0){s(`[${i}] ${r.name} run#${o} \u2014 grading...`);let e=await $({prompt:r.prompt,output:n.output,expectations:r.expectations,model:t.graderModel??t.model,timeout:t.timeout});u=e,s(`[${i}] ${r.name} run#${o} \u2014 grading done: pass_rate=${e.summary.pass_rate==null?"n/a (all assertions errored)":`${(e.summary.pass_rate*100).toFixed(0)}%`}`)}return{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"completed",outputs:{transcript:n.output,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens,total_duration_seconds:n.durationMs/1e3},grading:u}}finally{a.cleanup()}}c(x,"executeAndGradeCase");async function R(m){let{cases:t,targetContent:s,concurrency:r,runNumber:i,opts:g,skipBaseline:o,onLog:a=c(()=>{},"onLog")}=m,d=o?["with_target"]:["with_target","without_target"],n=[];for(let e of t)for(let l of d)n.push({eval_:e,configuration:l,targetContent:l==="with_target"?s:void 0,runNumber:i});let u=[];for(let e=0;e<n.length;e+=Math.max(1,r)){let l=n.slice(e,e+Math.max(1,r)),h=await Promise.all(l.map(b=>x(b,g,a)));u.push(...h)}for(let e of u)try{await p("/api/eval-runs",e)}catch(l){a(` \u26A0 failed to post a run result: ${l instanceof Error?l.message:String(l)}`)}try{await p(`/api/eval-targets/${g.targetId}/label-state`,{})}catch(e){a(` \u26A0 label-state notification skipped: ${e instanceof Error?e.message:String(e)}`)}return{completed:u.filter(e=>e.status==="completed").length,failed:u.filter(e=>e.status==="failed").length,results:u}}c(R,"runBatchAndPost");export{x as a,R as b};
1
+ import{e as k}from"./chunk-GN3ZHQ46.js";import{a as f}from"./chunk-KGURGIZ2.js";import{a as $}from"./chunk-BJSVATVJ.js";import{d as v}from"./chunk-TZA4HAVF.js";import{f as p}from"./chunk-2AVGUZ2P.js";import{a as c}from"./chunk-ZLLER3HP.js";async function x(m,t,s=()=>{}){let{eval_:r,configuration:i,targetContent:g,runNumber:o}=m;s(`[${i}] ${r.name} run#${o} \u2014 executing...`);let a=k({targetType:t.targetType,targetContent:g,targetName:t.targetName}),d={methodology:a.methodology,delivery:a.delivery,isolated:a.isWorktree,...t.candidateContentHash?{candidateContentHash:t.candidateContentHash}:{},...a.leakedFiles.length?{leakedFiles:a.leakedFiles}:{}};a.isWorktree||s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 no git worktree; running without repo context`),a.leakedFiles.length&&s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 CONTAMINATED: ${a.leakedFiles.join(", ")} survived the strip`);try{let n=await v({prompt:r.prompt,targetContent:a.systemPrompt,workDir:a.workDir,timeout:t.timeout,model:t.model});if(n.error){let e=f(n.error);return s(`[${i}] ${r.name} run#${o} \u2014 FAILED (${e.kind}): ${n.error}`),{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"failed",outputs:{error:n.error,failureKind:e.kind,failureClass:e.class,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens},grading:{},failure:e}}s(`[${i}] ${r.name} run#${o} \u2014 completed in ${(n.durationMs/1e3).toFixed(1)}s`);let u={};if(!t.skipGrading&&r.expectations.length>0){s(`[${i}] ${r.name} run#${o} \u2014 grading...`);let e=await $({prompt:r.prompt,output:n.output,expectations:r.expectations,model:t.graderModel??t.model,timeout:t.timeout});u=e,s(`[${i}] ${r.name} run#${o} \u2014 grading done: pass_rate=${e.summary.pass_rate==null?"n/a (all assertions errored)":`${(e.summary.pass_rate*100).toFixed(0)}%`}`)}return{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"completed",outputs:{transcript:n.output,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens,total_duration_seconds:n.durationMs/1e3},grading:u}}finally{a.cleanup()}}c(x,"executeAndGradeCase");async function R(m){let{cases:t,targetContent:s,concurrency:r,runNumber:i,opts:g,skipBaseline:o,onLog:a=c(()=>{},"onLog")}=m,d=o?["with_target"]:["with_target","without_target"],n=[];for(let e of t)for(let l of d)n.push({eval_:e,configuration:l,targetContent:l==="with_target"?s:void 0,runNumber:i});let u=[];for(let e=0;e<n.length;e+=Math.max(1,r)){let l=n.slice(e,e+Math.max(1,r)),h=await Promise.all(l.map(b=>x(b,g,a)));u.push(...h)}for(let e of u)try{await p("/api/eval-runs",e)}catch(l){a(` \u26A0 failed to post a run result: ${l instanceof Error?l.message:String(l)}`)}try{await p(`/api/eval-targets/${g.targetId}/label-state`,{})}catch(e){a(` \u26A0 label-state notification skipped: ${e instanceof Error?e.message:String(e)}`)}return{completed:u.filter(e=>e.status==="completed").length,failed:u.filter(e=>e.status==="failed").length,results:u}}c(R,"runBatchAndPost");export{x as a,R as b};
@@ -1,4 +1,4 @@
1
- import{e as d}from"./chunk-QWCEZEDO.js";import{d as g}from"./chunk-NF2BIEAF.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-3QXRLIGC.js";import{e as _}from"./chunk-GP46IPK2.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{d as g}from"./chunk-NF2BIEAF.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-3QXRLIGC.js";import{e as _}from"./chunk-2AVGUZ2P.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 +1 @@
1
- import{c}from"./chunk-6LYWI22A.js";import{e as p,g as u}from"./chunk-GP46IPK2.js";import{a as o}from"./chunk-ZLLER3HP.js";var l="openCandidate";function g(n,i){let t=(n??{})[l];if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.content!="string"||!e.content||typeof e.hash!="string"||!e.hash||typeof e.priorHash!="string"||e.priorHash!==i?null:{content:e.content,hash:e.hash,priorHash:e.priorHash,plannedPairs:typeof e.plannedPairs=="number"?e.plannedPairs:0,updatedAt:typeof e.updatedAt=="string"?e.updatedAt:""}}o(g,"resolveOpenCandidate");function m(n){let{plannedPairs:i,carriedPairs:t,liveCases:e}=n;if(e<=0)return 0;let a=i-t;return a<=0?0:Math.ceil(a/e)}o(m,"owedPasses");var d=100;async function b(n){let{evalTargetId:i,candidateContentHash:t}=n,e=[];for(let a=0;;a+=d){let r=await p(`/api/eval-targets/${i}/runs?candidateContentHash=${encodeURIComponent(t)}&limit=${d}&offset=${a}`);if(!Array.isArray(r)||r.length===0||(e.push(...r),r.length<d))break}return c(e)}o(b,"fetchCarriedPairs");async function P(n){let{evalTargetId:i,meta:t,blob:e,log:a,tag:r}=n;try{let s={...t};e?s[l]=e:delete s[l],await u(`/api/eval-targets/${i}`,{metadata:s}),a(e?`${r}: banked candidate ${e.hash.slice(0,8)} \u2014 the next run resumes instead of restarting`:`${r}: cleared the banked candidate (this cycle reached a decision)`)}catch(s){a(`${r}: could not update the candidate bank (${s instanceof Error?s.message:String(s)})`)}}o(P,"bankOpenCandidate");function C(n){return{content:n.content,hash:n.hash,priorHash:n.priorHash,plannedPairs:n.plannedPairs,updatedAt:n.now.toISOString()}}o(C,"buildOpenCandidate");export{l as a,g as b,m as c,b as d,P as e,C as f};
1
+ import{c}from"./chunk-SD626JBZ.js";import{e as p,g as u}from"./chunk-2AVGUZ2P.js";import{a as o}from"./chunk-ZLLER3HP.js";var l="openCandidate";function g(n,i){let t=(n??{})[l];if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.content!="string"||!e.content||typeof e.hash!="string"||!e.hash||typeof e.priorHash!="string"||e.priorHash!==i?null:{content:e.content,hash:e.hash,priorHash:e.priorHash,plannedPairs:typeof e.plannedPairs=="number"?e.plannedPairs:0,updatedAt:typeof e.updatedAt=="string"?e.updatedAt:""}}o(g,"resolveOpenCandidate");function m(n){let{plannedPairs:i,carriedPairs:t,liveCases:e}=n;if(e<=0)return 0;let a=i-t;return a<=0?0:Math.ceil(a/e)}o(m,"owedPasses");var d=100;async function b(n){let{evalTargetId:i,candidateContentHash:t}=n,e=[];for(let a=0;;a+=d){let r=await p(`/api/eval-targets/${i}/runs?candidateContentHash=${encodeURIComponent(t)}&limit=${d}&offset=${a}`);if(!Array.isArray(r)||r.length===0||(e.push(...r),r.length<d))break}return c(e)}o(b,"fetchCarriedPairs");async function P(n){let{evalTargetId:i,meta:t,blob:e,log:a,tag:r}=n;try{let s={...t};e?s[l]=e:delete s[l],await u(`/api/eval-targets/${i}`,{metadata:s}),a(e?`${r}: banked candidate ${e.hash.slice(0,8)} \u2014 the next run resumes instead of restarting`:`${r}: cleared the banked candidate (this cycle reached a decision)`)}catch(s){a(`${r}: could not update the candidate bank (${s instanceof Error?s.message:String(s)})`)}}o(P,"bankOpenCandidate");function C(n){return{content:n.content,hash:n.hash,priorHash:n.priorHash,plannedPairs:n.plannedPairs,updatedAt:n.now.toISOString()}}o(C,"buildOpenCandidate");export{l as a,g as b,m as c,b as d,P as e,C as f};
@@ -1,4 +1,4 @@
1
- import{a as g,c as w}from"./chunk-UPFH72PF.js";import{f as p,g as m,h as k,i as h,j as y}from"./chunk-DS4P5C4F.js";import{a as s}from"./chunk-ZLLER3HP.js";import{existsSync as u,readFileSync as f,writeFileSync as v,copyFileSync as R,rmSync as P,statSync as x,readdirSync as $,mkdirSync as j}from"node:fs";import{join as i,dirname as L}from"node:path";import{homedir as c}from"node:os";var I=["/plugins/cache/","/plugins/marketplaces/","/node_modules/","/.git/"];function _(e){return I.some(t=>e.includes(t))}s(_,"isUnownedPath");function K(e,t){let n=i(c(),".config","rulemetric","retraction-backups",t),r=e.replace(/^\/+/,"").replace(/\//g,"__");return i(n,r)}s(K,"backupPathFor");function b(e){return e.split(`
1
+ import{a as g,c as w}from"./chunk-UPFH72PF.js";import{g as p,h as m,i as k,j as h,k as y}from"./chunk-OOGTQOL3.js";import{a as s}from"./chunk-ZLLER3HP.js";import{existsSync as u,readFileSync as f,writeFileSync as v,copyFileSync as R,rmSync as P,statSync as x,readdirSync as $,mkdirSync as j}from"node:fs";import{join as i,dirname as L}from"node:path";import{homedir as c}from"node:os";var I=["/plugins/cache/","/plugins/marketplaces/","/node_modules/","/.git/"];function _(e){return I.some(t=>e.includes(t))}s(_,"isUnownedPath");function K(e,t){let n=i(c(),".config","rulemetric","retraction-backups",t),r=e.replace(/^\/+/,"").replace(/\//g,"__");return i(n,r)}s(K,"backupPathFor");function b(e){return e.split(`
2
2
  `).slice(0,40).map(t=>`- ${t}`).join(`
3
3
  `)}s(b,"shortDiff");function d(e,t,n){return{kind:e,path:t,ok:!1,refusal:n,preview:"",warnings:[]}}s(d,"refuse");function B(e){let[t,...n]=e.split("::"),r=n.join("::");if(!r)return null;switch(t){case"claude_md":return{kind:"claude_md_section",target:r};case"memory":return{kind:"memory_section",target:r};case"skill":return{kind:"skill_file",target:r};default:return null}}s(B,"pathFromContextIdentity");function D(e,t){let n=e.replace(/^skills--/,""),r=w(e);return[...(r===n?[n]:[r,n]).flatMap(a=>[i(t,...g.split("/"),a,"SKILL.md"),i(t,".claude","skills",a,"SKILL.md"),i(t,".claude","skills",`${a}.md`),i(c(),...g.split("/"),a,"SKILL.md"),i(c(),".claude","skills",a,"SKILL.md"),i(c(),".claude","skills",`${a}.md`)]),...F(n)]}s(D,"candidateSkillPaths");function F(e){let t=i(c(),".claude","plugins","marketplaces");if(!u(t))return[];let n=[];try{for(let r of $(t))n.push(i(t,r,"skills",e,"SKILL.md"),i(t,r,"plugins",e,"SKILL.md"),i(t,r,"skills",`${e}.md`))}catch{}return n}s(F,"pluginSkillPaths");function H(e){switch(e.kind){case"claude_md_section":case"memory_section":case"claude_md_block":return C(e);case"skill_file":return E(e);case"settings_hook":case"mcp_server":return N(e)}}s(H,"planRetraction");function C(e){let t=e.target;if(!u(t))return d(e.kind,t,`File does not exist: ${t}`);if(_(t))return d(e.kind,t,`Refusing to edit a path this tool does not own: ${t}`);let n=f(t,"utf-8"),r=e.body?m(n,e.body):p(n,e.heading??"");if(!r.removed){let l={"not-found":"The content is not present in this file (already removed, or edited since).",ambiguous:"The content appears more than once \u2014 refusing to guess which copy the verdict was about.","would-empty-file":"Removing it would empty the file. Delete the file by hand if that is really the intent."}[r.reason??"not-found"];return d(e.kind,t,l)}let o=[];return S(t,e.cwd)||o.push("This file is not tracked by git in this repo \u2014 the timestamped backup is your only undo."),{kind:e.kind,path:t,ok:!0,preview:b(r.removedText??""),nextContent:r.content,warnings:o}}s(C,"planFileEdit");function E(e){let t=e.target.startsWith("/")?[e.target]:D(e.target,e.cwd),n=t.find(l=>u(l));if(!n)return d("skill_file",t[0]??e.target,`No local skill file found for "${e.target}". Searched:
4
4
  ${t.join(`
@@ -1 +1 @@
1
- import{a as Re}from"./chunk-M7QSC64D.js";import{i as Ae}from"./chunk-DPCAPIQB.js";import{b as ce,i as ue,j as pe,k as de,l as ge,m as me,n as fe}from"./chunk-LB24UKHZ.js";import{c as we}from"./chunk-G7V4ZZZ3.js";import{a as Pe,b as ye,c as ve,d as ke,e as ee,f as Ce}from"./chunk-CJ4NG6FL.js";import{d as he,e as be,g as $e}from"./chunk-6LYWI22A.js";import{d as se,e as Z,f as le}from"./chunk-VBXL7XO7.js";import{e as P,f as K}from"./chunk-GP46IPK2.js";import{a as u}from"./chunk-ZLLER3HP.js";import{createHash as We}from"node:crypto";import{existsSync as Ee,readFileSync as Se,writeFileSync as Ne}from"node:fs";var W=u(a=>We("sha256").update(a).digest("hex"),"sha256"),Ie=1.3,te=4,Le=20;function Fe(a,i){if(!a.configured||i<=0)return te;let t=Math.ceil(a.minPairs*Ie/i);return Math.min(Le,Math.max(te,t))}u(Fe,"passCapFor");function je(a,i=10,t=te){if(a<=0)return{passes:0,expectedPairs:0,feasible:!1,reason:"no live cases"};let l=Math.ceil(i*Ie),e=Math.min(t,Math.ceil(l/a)),r=e*a;return r<i?{passes:e,expectedPairs:r,feasible:!1,reason:`${a} live case(s) x ${t} passes = ${a*t} pairs at best, below the ${i} a controlled verdict requires \u2014 add cases rather than replaying these`}:{passes:e,expectedPairs:r,feasible:!0}}u(je,"planPasses");var Ue=60,qe=u(a=>typeof a=="object"&&a!==null&&typeof a.withScore=="number"&&typeof a.withoutScore=="number","isPair");function Ge(a,i,t){let l=[...a].sort((e,r)=>Date.parse(r.createdAt)-Date.parse(e.createdAt));for(let e of l){if(e.applied)continue;let r=e.gates?.accumulation;if(!r||typeof r!="object"||r.priorContentHash!==i||r.targetPairs!==t||typeof r.candidateContentHash!="string"||!Array.isArray(r.pairs))continue;let o=r.pairs.filter(qe);if(o.length===r.pairs.length&&!(o.length>=t))return{promotionId:e.id,candidateContentHash:r.candidateContentHash,pairs:o,runs:typeof r.runs=="number"?r.runs:1}}return null}u(Ge,"findOpenAccumulation");var Be=5,xe=u(a=>Array.isArray(a)?a.filter(i=>typeof i=="string"):[],"stringList"),j=u(a=>typeof a=="number"&&Number.isFinite(a)?a:null,"finite");function Xe(a,i,t=Be){let l=[...a].filter(o=>o.fromContentHash===i).sort((o,g)=>Date.parse(g.createdAt)-Date.parse(o.createdAt)),e=[],r=new Set;for(let o of l){let g=o.toContentHash??o.id;if(r.has(g))continue;r.add(g);let y=o.verdict??null,S=j(y?.delta),x=j(y?.ci?.lower),H=j(y?.ci?.upper),C=j(y?.nWith),ne=y?.sufficient===!0&&S!=null&&x!=null&&H!=null&&C!=null?{delta:S,ciLower:x,ciUpper:H,nPairs:C}:null;if(e.push({decision:typeof o.decision=="string"?o.decision:"unknown",applied:o.applied===!0,at:typeof o.createdAt=="string"?o.createdAt:"",rationale:typeof o.proposalRationale=="string"?o.proposalRationale:"",touched:xe(o.touchedSections),refusals:xe(o.refusals),measured:ne}),e.length>=t)break}return e}u(Xe,"summarisePriorDecisions");function ze(a,i){let t=i.accumulate??(a.autoEvolveAccumulate===!0||a.autoEvolveAccumulate==="true"),l=i.accumulateTargetPairs??a.autoEvolveAccumulateTarget,e=typeof l=="string"?Number.parseInt(l,10):l,r=typeof e=="number"&&Number.isInteger(e)&&e>0?e:Ue;return{enabled:t,targetPairs:r}}u(ze,"readAccumulateConfig");function Qe(a){let i=a.accumulateEnabled&&a.pairCount<a.targetPairs;return{apply:a.consented&&!i,peeking:i}}u(Qe,"resolveApply");async function it(a,i){let t=u(n=>i?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:l}=a,e=`[cron_instruction_evolution] ${l}`,r=await P(`/api/eval-targets/${l}`),o=r.metadata??{},g=null,y=!1;if(r.name.startsWith("/")&&Ee(r.name))try{if(g=Se(r.name,"utf8"),g!==r.content){let n=await K(`/api/eval-targets/${l}/sync-content`,{content:g});y=n.synced,t(`${e}: target content drifted from disk by ${Math.abs(g.length-r.content.length)} chars \u2014 synced to disk truth (v${n.version}). Prior verdicts against the old text dissolve via content-hash keying.`),r={...r,content:g,version:n.version}}}catch(n){t(`${e}: disk sync failed (${n instanceof Error?n.message:String(n)}) \u2014 measuring the stored snapshot`)}let S=!1;try{S=(await P("/api/settings/evolution-account")).paused}catch(n){t(`${e}: could not read the account switch (${n instanceof Error?n.message:String(n)}) \u2014 pausing to be safe`),S=!0}if(S)return t(`${e}: PAUSED for the whole account (profiles.evolution_paused) \u2014 no model budget spent.`),{skipped:"paused-account"};if(pe(o))return t(`${e}: PAUSED (metadata.autoEvolvePaused) \u2014 no model budget spent. Opt-in is intact.`),{skipped:"paused"};let x=Re(r);if(x)return t(`${e}: ${x.reason}`),x;let H=a.apply??(o.autoEvolveApply===!0||o.autoEvolveApply==="true"),C=Ve(o);if(C==null){if(H)return t(`${e}: refusing \u2014 metadata.immutableSections is unset. Set it (use [] to explicitly protect nothing) before letting the loop edit this target unattended.`),{skipped:"immutable-sections-unset"};t(`${e}: metadata.immutableSections unset \u2014 measure-only cycle proceeds with [] (nothing protected). Writing still requires setting it explicitly.`),C=[]}let $=(await P(`/api/eval-targets/${l}/evals`)).filter(n=>!n.retiredAt);if($.length===0)return{skipped:"no-live-cases"};let N=ue(o);N.note&&t(`${e}: ${N.note}`);let v=je($.length,N.minPairs,Fe(N,$.length));if(!v.feasible)return t(`${e}: cannot reach a sufficient verdict \u2014 ${v.reason}`),{skipped:"cannot-reach-min-n",reason:v.reason};let He=de({liveCases:$.length,passes:v.passes});t(`${e}: budget for this run \u2014 ${fe(He)}`);let U=await P(`/api/eval-targets/${l}/judge-calibration`);if(!U.powerCheck.adequate){let n=(U.powerCheck.reasons??[]).join("; ");return t(`${e}: not adequately powered, skipping before spending budget \u2014 ${n}`),{skipped:"not-adequate",reason:n}}let re=le,_e=Date.now()-re*24*60*60*1e3,q=await P(`/api/eval-targets/${l}/promotions?limit=200`),ae=q.promotions.filter(n=>n.applied&&Date.parse(n.createdAt)>=_e).length;if(ae>=Z)return t(`${e}: change budget looks exhausted (${ae}/${Z} applied in ${re}d), skipping before spending budget`),{skipped:"budget-exhausted"};try{let n=await P("/api/usage/current-limits"),c=we({limits:n,now:new Date});if(!c.ok)return t(`${e}: deferring before spending budget \u2014 ${c.reason}`),{skipped:"quota-exhausted",reason:c.reason}}catch(n){t(`${e}: quota unknown (${n instanceof Error?n.message:String(n)}) \u2014 proceeding`)}let L=se();if(!L.green)return t(`${e}: A/A canary is RED \u2014 halting. ${L.failures.join(" | ")}`),{skipped:"canary-red",reason:L.failures.join(" | ")};let G=r.content,D=W(G),p=ze(o,a),k=p.enabled?Ge(q.promotions,D,p.targetPairs):null,m,F,w=[],_=0,B=ce,f=k?null:ye(o,D);if(f){m=f.content,F="",B=0;try{w=await ke({evalTargetId:l,candidateContentHash:f.hash})}catch(n){return t(`${e}: could not rebuild banked pairs (${n instanceof Error?n.message:String(n)})`),{skipped:"resume-read-failed",reason:f.hash}}t(`${e}: resuming interrupted cycle \u2014 ${w.length}/${f.plannedPairs} pair(s) rebuilt from eval_runs, no proposal call spent`)}else if(k){let n=await P(`/api/promotions/${k.promotionId}`);if(W(n.toContent)!==k.candidateContentHash)return t(`${e}: stored candidate does not match its recorded hash \u2014 refusing to continue`),{skipped:"accumulation-hash-mismatch",reason:k.promotionId};m=n.toContent,F=n.proposalRationale??"",w=k.pairs,_=k.runs,B=0,t(`${e}: continuing accumulation ${k.promotionId} \u2014 ${w.length}/${p.targetPairs} pair(s) carried from ${_} prior run(s)`)}else{let n=U.caseDiscrimination?.cases??[],c=[];if(r.name.startsWith("/")){let s=r.name.slice(0,r.name.lastIndexOf("/"));try{let b=await P(`/api/insights/evidence?projectPath=${encodeURIComponent(s)}`);b.analyzedAt&&(c=[...b.friction.map(Y=>`Real-session friction (insights, ${b.analyzedAt.slice(0,10)}): ${Y}`),...b.whatWorks.map(Y=>`Working well in real sessions \u2014 do not break: ${Y}`)],c.length>0&&t(`${e}: proposer sees ${b.friction.length} friction + ${b.whatWorks.length} what-works item(s) from insights`))}catch(b){t(`${e}: insights evidence unavailable (${b instanceof Error?b.message:String(b)}) \u2014 proposing without it`)}}let T=[];try{T=Xe(q.promotions,D)}catch(s){t(`${e}: could not summarise prior decisions (${s instanceof Error?s.message:String(s)}) \u2014 proposing without them`)}T.length>0&&t(`${e}: proposer sees ${T.length} prior decision(s) against this exact body (${T.map(s=>`${s.decision}${s.measured?"/measured":""}`).join(", ")})`);let M=await Ae({currentContent:r.content,targetType:r.type,targetName:r.name,immutableSections:C,evidence:{nonDiscriminating:n.filter(s=>!s.discriminating).map(s=>`${s.name??s.assertion??"unnamed"} \u2014 ${s.note}`),weakest:n.filter(s=>s.discriminating&&s.withPassRate<s.withoutPassRate).map(s=>({name:s.name??s.assertion??"unnamed",withPassRate:s.withPassRate,withoutPassRate:s.withoutPassRate})),priorDecisions:T,notes:c}});if(!M.ok)return t(`${e}: no usable proposal \u2014 ${M.reason}`),{skipped:"no-proposal",reason:M.reason};m=M.proposal.candidateContent,F=M.proposal.rationale}let I=f?ve({plannedPairs:f.plannedPairs||v.expectedPairs,carriedPairs:w.length,liveCases:$.length}):v.passes;t(`${e}: measuring ${$.length} case(s) x ${I} pass(es) = up to ${$.length*I} pairs, candidate vs prior version`+(f?` (resumed; ${w.length} pair(s) already banked)`:""));let A=[],X=[],Oe=Date.now(),oe=0,z=0;for(let n=1;n<=I;n++){let c=await $e({cases:$,candidateContent:m,priorVersionContent:G,concurrency:a.concurrency??2,runNumber:n,opts:{targetId:l,targetVersion:r.version??1,iteration:1,timeout:a.timeout??24e4,model:a.model,graderModel:a.graderModel,skipGrading:!1,targetType:r.type,targetName:r.name,candidateContentHash:W(m)},onLog:t});if(A.push(...c.pairs),X.push(...c.results),oe+=c.completed,z+=c.failed,t(`${e}: pass ${n}/${I} \u2014 ${c.pairs.length} pair(s), running total ${A.length}`),c.abortedForQuota){t(`${e}: stopping after pass ${n}/${I} \u2014 ${c.abortedForQuota}. Remaining passes would spend against an exhausted account.`);break}}let R=[...w,...A],O=he(X),Q=A.length>0,d=ge({runs:X,plannedPairs:v.expectedPairs,usablePairs:A.length,verdictPairs:Q?R.length:A.length,proposalCalls:B,passes:I,liveCases:$.length,wallMs:Date.now()-Oe});if(t(`${e}: ${oe} completed, ${z} failed, ${A.length} usable pair(s) \u2014 spent ~${d.modelCalls} model calls (${d.proposalCalls} proposal + ${d.executorCalls} executor + >=${d.graderCalls} grader) in ${(d.wallMs/6e4).toFixed(1)} min`+(Q?`; the ${d.verdictPairs} pair(s) behind this verdict resolve +/-${me(d.mde)} at 80% power`:"")),!Q)return{skipped:O.infrastructureFailed?"infrastructure-failure":"no-pairs",reason:O.infrastructureFailed?`${O.infrastructureFailed} run(s) never executed (${O.summary.describe()}) \u2014 the environment failed, not the target`:`${z} run(s) failed or were ungradeable`,cost:d};let V=be({pairs:R.length,minPairs:10,accounting:O});if(V.kind==="infrastructure-incomplete")return t(`${e}: not posting a verdict \u2014 ${V.reason}`),await ee({evalTargetId:l,meta:o,blob:Ce({content:m,hash:W(m),priorHash:D,plannedPairs:f?.plannedPairs||v.expectedPairs,now:new Date}),log:t,tag:e}),{skipped:"infrastructure-incomplete",reason:V.reason,cost:d};p.enabled&&t(`${e}: accumulated ${R.length}/${p.targetPairs} pair(s) over ${_+1} run(s) on one candidate`);let ie=H,{apply:Te,peeking:Me}=Qe({consented:ie,accumulateEnabled:p.enabled,pairCount:R.length,targetPairs:p.targetPairs});ie&&Me&&t(`${e}: interim readout at ${R.length}/${p.targetPairs} pairs \u2014 recording the decision but not acting until the target is reached`);let h=await K(`/api/eval-targets/${l}/promotions`,{candidateContent:m,proposalSource:"llm",proposalRationale:F,pairs:R,canaryGreen:L.green,measuredAgainstContentHash:D,immutableSections:C,apply:Te,measurementCost:d,...p.enabled?{accumulation:{candidateContentHash:W(m),priorContentHash:D,targetPairs:p.targetPairs,carriedPairs:w.length,runs:_+1}}:{}});t(`${e}: ${h.decision}${h.applied?" (APPLIED)":""} \u2014 ${h.rationale}`+(h.refusals.length>0?` | refusals: ${h.refusals.join("; ")}`:"")),(f||o[Pe])&&await ee({evalTargetId:l,meta:o,blob:null,log:t,tag:e});let J=!1,E;if(h.applied&&r.name.startsWith("/"))try{Ee(r.name)?Se(r.name,"utf8")!==G?E="file changed since measurement started \u2014 refusing to clobber; next cycle re-syncs":(Ne(r.name,m,"utf8"),J=!0):E="file no longer exists on disk",t(J?`${e}: measured improvement written to ${r.name} (undo: git checkout -- ${r.name})`:`${e}: NOT written to disk \u2014 ${E}`)}catch(n){E=n instanceof Error?n.message:String(n),t(`${e}: disk write-back failed \u2014 ${E}. The eval target is updated; the file is not.`)}return{decision:h.decision,applied:h.applied,nPairs:R.length,promotionId:h.id,cost:d,diskSynced:y,...h.applied?{fileWritten:J,...E?{fileWriteSkipped:E}:{}}:{},...p.enabled?{carriedPairs:w.length,accumulationRuns:_+1}:{}}}u(it,"cronInstructionEvolution");function Ve(a){let i=a.immutableSections;return i==null||!Array.isArray(i)?null:i.filter(t=>typeof t=="string")}u(Ve,"readImmutableSections");export{Ie as a,te as b,Le as c,Fe as d,je as e,Ue as f,Ge as g,Be as h,Xe as i,ze as j,Qe as k,it as l,Ve as m};
1
+ import{a as Re}from"./chunk-M7QSC64D.js";import{i as Ae}from"./chunk-DPCAPIQB.js";import{a as Pe,b as ye,c as ve,d as ke,e as ee,f as Ce}from"./chunk-T67L2YTW.js";import{b as ce,i as ue,j as pe,k as de,l as ge,m as me,n as fe}from"./chunk-LB24UKHZ.js";import{c as we}from"./chunk-G7V4ZZZ3.js";import{d as he,e as be,g as $e}from"./chunk-SD626JBZ.js";import{d as se,e as Z,f as le}from"./chunk-VBXL7XO7.js";import{e as P,f as K}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";import{createHash as We}from"node:crypto";import{existsSync as Ee,readFileSync as Se,writeFileSync as Ne}from"node:fs";var W=u(a=>We("sha256").update(a).digest("hex"),"sha256"),Ie=1.3,te=4,Le=20;function Fe(a,i){if(!a.configured||i<=0)return te;let t=Math.ceil(a.minPairs*Ie/i);return Math.min(Le,Math.max(te,t))}u(Fe,"passCapFor");function je(a,i=10,t=te){if(a<=0)return{passes:0,expectedPairs:0,feasible:!1,reason:"no live cases"};let l=Math.ceil(i*Ie),e=Math.min(t,Math.ceil(l/a)),r=e*a;return r<i?{passes:e,expectedPairs:r,feasible:!1,reason:`${a} live case(s) x ${t} passes = ${a*t} pairs at best, below the ${i} a controlled verdict requires \u2014 add cases rather than replaying these`}:{passes:e,expectedPairs:r,feasible:!0}}u(je,"planPasses");var Ue=60,qe=u(a=>typeof a=="object"&&a!==null&&typeof a.withScore=="number"&&typeof a.withoutScore=="number","isPair");function Ge(a,i,t){let l=[...a].sort((e,r)=>Date.parse(r.createdAt)-Date.parse(e.createdAt));for(let e of l){if(e.applied)continue;let r=e.gates?.accumulation;if(!r||typeof r!="object"||r.priorContentHash!==i||r.targetPairs!==t||typeof r.candidateContentHash!="string"||!Array.isArray(r.pairs))continue;let o=r.pairs.filter(qe);if(o.length===r.pairs.length&&!(o.length>=t))return{promotionId:e.id,candidateContentHash:r.candidateContentHash,pairs:o,runs:typeof r.runs=="number"?r.runs:1}}return null}u(Ge,"findOpenAccumulation");var Be=5,xe=u(a=>Array.isArray(a)?a.filter(i=>typeof i=="string"):[],"stringList"),j=u(a=>typeof a=="number"&&Number.isFinite(a)?a:null,"finite");function Xe(a,i,t=Be){let l=[...a].filter(o=>o.fromContentHash===i).sort((o,g)=>Date.parse(g.createdAt)-Date.parse(o.createdAt)),e=[],r=new Set;for(let o of l){let g=o.toContentHash??o.id;if(r.has(g))continue;r.add(g);let y=o.verdict??null,S=j(y?.delta),x=j(y?.ci?.lower),H=j(y?.ci?.upper),C=j(y?.nWith),ne=y?.sufficient===!0&&S!=null&&x!=null&&H!=null&&C!=null?{delta:S,ciLower:x,ciUpper:H,nPairs:C}:null;if(e.push({decision:typeof o.decision=="string"?o.decision:"unknown",applied:o.applied===!0,at:typeof o.createdAt=="string"?o.createdAt:"",rationale:typeof o.proposalRationale=="string"?o.proposalRationale:"",touched:xe(o.touchedSections),refusals:xe(o.refusals),measured:ne}),e.length>=t)break}return e}u(Xe,"summarisePriorDecisions");function ze(a,i){let t=i.accumulate??(a.autoEvolveAccumulate===!0||a.autoEvolveAccumulate==="true"),l=i.accumulateTargetPairs??a.autoEvolveAccumulateTarget,e=typeof l=="string"?Number.parseInt(l,10):l,r=typeof e=="number"&&Number.isInteger(e)&&e>0?e:Ue;return{enabled:t,targetPairs:r}}u(ze,"readAccumulateConfig");function Qe(a){let i=a.accumulateEnabled&&a.pairCount<a.targetPairs;return{apply:a.consented&&!i,peeking:i}}u(Qe,"resolveApply");async function it(a,i){let t=u(n=>i?.logger?.info?.(n)??console.log(n),"log"),{evalTargetId:l}=a,e=`[cron_instruction_evolution] ${l}`,r=await P(`/api/eval-targets/${l}`),o=r.metadata??{},g=null,y=!1;if(r.name.startsWith("/")&&Ee(r.name))try{if(g=Se(r.name,"utf8"),g!==r.content){let n=await K(`/api/eval-targets/${l}/sync-content`,{content:g});y=n.synced,t(`${e}: target content drifted from disk by ${Math.abs(g.length-r.content.length)} chars \u2014 synced to disk truth (v${n.version}). Prior verdicts against the old text dissolve via content-hash keying.`),r={...r,content:g,version:n.version}}}catch(n){t(`${e}: disk sync failed (${n instanceof Error?n.message:String(n)}) \u2014 measuring the stored snapshot`)}let S=!1;try{S=(await P("/api/settings/evolution-account")).paused}catch(n){t(`${e}: could not read the account switch (${n instanceof Error?n.message:String(n)}) \u2014 pausing to be safe`),S=!0}if(S)return t(`${e}: PAUSED for the whole account (profiles.evolution_paused) \u2014 no model budget spent.`),{skipped:"paused-account"};if(pe(o))return t(`${e}: PAUSED (metadata.autoEvolvePaused) \u2014 no model budget spent. Opt-in is intact.`),{skipped:"paused"};let x=Re(r);if(x)return t(`${e}: ${x.reason}`),x;let H=a.apply??(o.autoEvolveApply===!0||o.autoEvolveApply==="true"),C=Ve(o);if(C==null){if(H)return t(`${e}: refusing \u2014 metadata.immutableSections is unset. Set it (use [] to explicitly protect nothing) before letting the loop edit this target unattended.`),{skipped:"immutable-sections-unset"};t(`${e}: metadata.immutableSections unset \u2014 measure-only cycle proceeds with [] (nothing protected). Writing still requires setting it explicitly.`),C=[]}let $=(await P(`/api/eval-targets/${l}/evals`)).filter(n=>!n.retiredAt);if($.length===0)return{skipped:"no-live-cases"};let N=ue(o);N.note&&t(`${e}: ${N.note}`);let v=je($.length,N.minPairs,Fe(N,$.length));if(!v.feasible)return t(`${e}: cannot reach a sufficient verdict \u2014 ${v.reason}`),{skipped:"cannot-reach-min-n",reason:v.reason};let He=de({liveCases:$.length,passes:v.passes});t(`${e}: budget for this run \u2014 ${fe(He)}`);let U=await P(`/api/eval-targets/${l}/judge-calibration`);if(!U.powerCheck.adequate){let n=(U.powerCheck.reasons??[]).join("; ");return t(`${e}: not adequately powered, skipping before spending budget \u2014 ${n}`),{skipped:"not-adequate",reason:n}}let re=le,_e=Date.now()-re*24*60*60*1e3,q=await P(`/api/eval-targets/${l}/promotions?limit=200`),ae=q.promotions.filter(n=>n.applied&&Date.parse(n.createdAt)>=_e).length;if(ae>=Z)return t(`${e}: change budget looks exhausted (${ae}/${Z} applied in ${re}d), skipping before spending budget`),{skipped:"budget-exhausted"};try{let n=await P("/api/usage/current-limits"),c=we({limits:n,now:new Date});if(!c.ok)return t(`${e}: deferring before spending budget \u2014 ${c.reason}`),{skipped:"quota-exhausted",reason:c.reason}}catch(n){t(`${e}: quota unknown (${n instanceof Error?n.message:String(n)}) \u2014 proceeding`)}let L=se();if(!L.green)return t(`${e}: A/A canary is RED \u2014 halting. ${L.failures.join(" | ")}`),{skipped:"canary-red",reason:L.failures.join(" | ")};let G=r.content,D=W(G),p=ze(o,a),k=p.enabled?Ge(q.promotions,D,p.targetPairs):null,m,F,w=[],_=0,B=ce,f=k?null:ye(o,D);if(f){m=f.content,F="",B=0;try{w=await ke({evalTargetId:l,candidateContentHash:f.hash})}catch(n){return t(`${e}: could not rebuild banked pairs (${n instanceof Error?n.message:String(n)})`),{skipped:"resume-read-failed",reason:f.hash}}t(`${e}: resuming interrupted cycle \u2014 ${w.length}/${f.plannedPairs} pair(s) rebuilt from eval_runs, no proposal call spent`)}else if(k){let n=await P(`/api/promotions/${k.promotionId}`);if(W(n.toContent)!==k.candidateContentHash)return t(`${e}: stored candidate does not match its recorded hash \u2014 refusing to continue`),{skipped:"accumulation-hash-mismatch",reason:k.promotionId};m=n.toContent,F=n.proposalRationale??"",w=k.pairs,_=k.runs,B=0,t(`${e}: continuing accumulation ${k.promotionId} \u2014 ${w.length}/${p.targetPairs} pair(s) carried from ${_} prior run(s)`)}else{let n=U.caseDiscrimination?.cases??[],c=[];if(r.name.startsWith("/")){let s=r.name.slice(0,r.name.lastIndexOf("/"));try{let b=await P(`/api/insights/evidence?projectPath=${encodeURIComponent(s)}`);b.analyzedAt&&(c=[...b.friction.map(Y=>`Real-session friction (insights, ${b.analyzedAt.slice(0,10)}): ${Y}`),...b.whatWorks.map(Y=>`Working well in real sessions \u2014 do not break: ${Y}`)],c.length>0&&t(`${e}: proposer sees ${b.friction.length} friction + ${b.whatWorks.length} what-works item(s) from insights`))}catch(b){t(`${e}: insights evidence unavailable (${b instanceof Error?b.message:String(b)}) \u2014 proposing without it`)}}let T=[];try{T=Xe(q.promotions,D)}catch(s){t(`${e}: could not summarise prior decisions (${s instanceof Error?s.message:String(s)}) \u2014 proposing without them`)}T.length>0&&t(`${e}: proposer sees ${T.length} prior decision(s) against this exact body (${T.map(s=>`${s.decision}${s.measured?"/measured":""}`).join(", ")})`);let M=await Ae({currentContent:r.content,targetType:r.type,targetName:r.name,immutableSections:C,evidence:{nonDiscriminating:n.filter(s=>!s.discriminating).map(s=>`${s.name??s.assertion??"unnamed"} \u2014 ${s.note}`),weakest:n.filter(s=>s.discriminating&&s.withPassRate<s.withoutPassRate).map(s=>({name:s.name??s.assertion??"unnamed",withPassRate:s.withPassRate,withoutPassRate:s.withoutPassRate})),priorDecisions:T,notes:c}});if(!M.ok)return t(`${e}: no usable proposal \u2014 ${M.reason}`),{skipped:"no-proposal",reason:M.reason};m=M.proposal.candidateContent,F=M.proposal.rationale}let I=f?ve({plannedPairs:f.plannedPairs||v.expectedPairs,carriedPairs:w.length,liveCases:$.length}):v.passes;t(`${e}: measuring ${$.length} case(s) x ${I} pass(es) = up to ${$.length*I} pairs, candidate vs prior version`+(f?` (resumed; ${w.length} pair(s) already banked)`:""));let A=[],X=[],Oe=Date.now(),oe=0,z=0;for(let n=1;n<=I;n++){let c=await $e({cases:$,candidateContent:m,priorVersionContent:G,concurrency:a.concurrency??2,runNumber:n,opts:{targetId:l,targetVersion:r.version??1,iteration:1,timeout:a.timeout??24e4,model:a.model,graderModel:a.graderModel,skipGrading:!1,targetType:r.type,targetName:r.name,candidateContentHash:W(m)},onLog:t});if(A.push(...c.pairs),X.push(...c.results),oe+=c.completed,z+=c.failed,t(`${e}: pass ${n}/${I} \u2014 ${c.pairs.length} pair(s), running total ${A.length}`),c.abortedForQuota){t(`${e}: stopping after pass ${n}/${I} \u2014 ${c.abortedForQuota}. Remaining passes would spend against an exhausted account.`);break}}let R=[...w,...A],O=he(X),Q=A.length>0,d=ge({runs:X,plannedPairs:v.expectedPairs,usablePairs:A.length,verdictPairs:Q?R.length:A.length,proposalCalls:B,passes:I,liveCases:$.length,wallMs:Date.now()-Oe});if(t(`${e}: ${oe} completed, ${z} failed, ${A.length} usable pair(s) \u2014 spent ~${d.modelCalls} model calls (${d.proposalCalls} proposal + ${d.executorCalls} executor + >=${d.graderCalls} grader) in ${(d.wallMs/6e4).toFixed(1)} min`+(Q?`; the ${d.verdictPairs} pair(s) behind this verdict resolve +/-${me(d.mde)} at 80% power`:"")),!Q)return{skipped:O.infrastructureFailed?"infrastructure-failure":"no-pairs",reason:O.infrastructureFailed?`${O.infrastructureFailed} run(s) never executed (${O.summary.describe()}) \u2014 the environment failed, not the target`:`${z} run(s) failed or were ungradeable`,cost:d};let V=be({pairs:R.length,minPairs:10,accounting:O});if(V.kind==="infrastructure-incomplete")return t(`${e}: not posting a verdict \u2014 ${V.reason}`),await ee({evalTargetId:l,meta:o,blob:Ce({content:m,hash:W(m),priorHash:D,plannedPairs:f?.plannedPairs||v.expectedPairs,now:new Date}),log:t,tag:e}),{skipped:"infrastructure-incomplete",reason:V.reason,cost:d};p.enabled&&t(`${e}: accumulated ${R.length}/${p.targetPairs} pair(s) over ${_+1} run(s) on one candidate`);let ie=H,{apply:Te,peeking:Me}=Qe({consented:ie,accumulateEnabled:p.enabled,pairCount:R.length,targetPairs:p.targetPairs});ie&&Me&&t(`${e}: interim readout at ${R.length}/${p.targetPairs} pairs \u2014 recording the decision but not acting until the target is reached`);let h=await K(`/api/eval-targets/${l}/promotions`,{candidateContent:m,proposalSource:"llm",proposalRationale:F,pairs:R,canaryGreen:L.green,measuredAgainstContentHash:D,immutableSections:C,apply:Te,measurementCost:d,...p.enabled?{accumulation:{candidateContentHash:W(m),priorContentHash:D,targetPairs:p.targetPairs,carriedPairs:w.length,runs:_+1}}:{}});t(`${e}: ${h.decision}${h.applied?" (APPLIED)":""} \u2014 ${h.rationale}`+(h.refusals.length>0?` | refusals: ${h.refusals.join("; ")}`:"")),(f||o[Pe])&&await ee({evalTargetId:l,meta:o,blob:null,log:t,tag:e});let J=!1,E;if(h.applied&&r.name.startsWith("/"))try{Ee(r.name)?Se(r.name,"utf8")!==G?E="file changed since measurement started \u2014 refusing to clobber; next cycle re-syncs":(Ne(r.name,m,"utf8"),J=!0):E="file no longer exists on disk",t(J?`${e}: measured improvement written to ${r.name} (undo: git checkout -- ${r.name})`:`${e}: NOT written to disk \u2014 ${E}`)}catch(n){E=n instanceof Error?n.message:String(n),t(`${e}: disk write-back failed \u2014 ${E}. The eval target is updated; the file is not.`)}return{decision:h.decision,applied:h.applied,nPairs:R.length,promotionId:h.id,cost:d,diskSynced:y,...h.applied?{fileWritten:J,...E?{fileWriteSkipped:E}:{}}:{},...p.enabled?{carriedPairs:w.length,accumulationRuns:_+1}:{}}}u(it,"cronInstructionEvolution");function Ve(a){let i=a.immutableSections;return i==null||!Array.isArray(i)?null:i.filter(t=>typeof t=="string")}u(Ve,"readImmutableSections");export{Ie as a,te as b,Le as c,Fe as d,je as e,Ue as f,Ge as g,Be as h,Xe as i,ze as j,Qe as k,it as l,Ve as m};
@@ -1 +1 @@
1
- import{b as D,c as j}from"./chunk-6UEFCMR2.js";import{b as B,c as R,d as N,e as z}from"./chunk-NF2BIEAF.js";import{a as G}from"./chunk-BJSVATVJ.js";import{c as J}from"./chunk-RIVEBBZC.js";import{e as f,g as T}from"./chunk-GP46IPK2.js";import{a as p}from"./chunk-ZLLER3HP.js";function W(r,a,s){return s?r.reviewerModel===s||r.reviewerModel===`${a}:${s}`:r.reviewerEngine===a}p(W,"reviewMatchesReviewer");var C=100;function Z(r){let a=new Set;return r.forEach((s,d)=>{s.method!=="deterministic"&&a.add(d)}),a}p(Z,"llmExpectationIndexes");var w=class extends Error{constructor(s,d){super(d);this.reason=s}static{p(this,"JudgeReviewSkip")}};async function oe(r){let a=r.log??(()=>{}),s=r.warn??a,d=r.targetId,K=r.parallel??3,U=r.timeoutMs??12e4,v=await f(`/api/eval-targets/${d}`),u=(await f(`/api/eval-targets/${d}/annotations?limit=500`)).filter(e=>e.judgeMethod==="llm");if(u.length===0)throw new w("no-labels",`No human labels on "${v.name}" yet \u2014 label some runs in the Review tab first.`);let n;try{n=z({engineFlag:r.engineFlag??"auto",modelFlag:r.modelFlag,availability:N(),judgeModels:[...new Set(u.map(e=>e.judgeModel).filter(e=>e!=null))]})}catch(e){throw new w("no-engine",e instanceof Error?e.message:String(e))}a(`Reviewer: ${n.rationale}`);let c=0,b=u;if(r.skipReviewed){let e=await f(`/api/eval-targets/${d}/judge-reviews`),t=new Set(e.filter(i=>W(i,n.engine,r.modelFlag)).map(i=>`${i.evalRunId}:${i.expectationIndex}`));if(b=u.filter(i=>!t.has(`${i.evalRunId}:${i.expectationIndex}`)),c=u.length-b.length,b.length===0)return{targetName:v.name,reviewer:n,judgeModels:[],reviewerModel:n.model??`${n.engine} (CLI default)`,report:j([],0),persisted:0,alreadyReviewed:c,deferredPartialRuns:0}}let y=new Map;for(let e=0;;e+=C){let t=await f(`/api/eval-targets/${d}/runs?limit=${C}&offset=${e}`);for(let i of t)y.set(i.id,i);if(t.length<C)break}let q=await f(`/api/eval-targets/${d}/evals`),X=new Map(q.map(e=>[e.id,e.prompt])),o=new Map;for(let e of b){let t=o.get(e.evalRunId)??[];t.push(e),o.set(e.evalRunId,t)}let P=new Map;for(let e of u){let t=P.get(e.evalRunId)??new Set;t.add(e.expectationIndex),P.set(e.evalRunId,t)}let x=0;for(let[e]of[...o]){let t=y.get(e)?.grading?.expectations;if(!t)continue;let i=Z(t),g=P.get(e)??new Set;[...i].every(h=>g.has(h))||(o.delete(e),x+=1)}if(x>0&&a(`${x} partially-labeled run(s) deferred \u2014 a run is re-graded once, after all its assertions are labeled.`),o.size===0)return{targetName:v.name,reviewer:n,judgeModels:[],reviewerModel:n.model??`${n.engine} (CLI default)`,report:j([],0),persisted:0,alreadyReviewed:c,deferredPartialRuns:x};if(n.engine==="codex"&&n.model){let e=await J({prompt:"Reply with exactly: OK",model:n.model,timeout:6e4});if(e.error&&B(e.error)){if(n.model===R)throw new w("preflight-failed",`Codex fallback model ${R} is also unrunnable: ${e.error}`);s(`Your codex model "${n.model}" can't run on the installed CLI/account \u2014 falling back to ${R}.`),n={...n,model:R}}else if(e.error)throw new w("preflight-failed",`Codex preflight failed: ${e.error}`)}let S=[...o.values()].flat(),Y=[...new Set(S.map(e=>e.judgeModel).filter(e=>e!=null))];a(`Re-grading ${o.size} annotated run(s) / ${S.length} assertion(s) on "${v.name}"`+(c?` (${c} already reviewed \u2014 skipped)`:"")+".");let $=[],I=0,k=new Set,m=r.limit!=null?[...o.entries()].slice(0,Math.max(1,r.limit)):[...o.entries()];m.length<o.size&&a(`Sampling ${m.length} of ${o.size} annotated runs (limit).`);let H=0,Q=p(async()=>{for(;;){let e=H++;if(e>=m.length)return;let[t,i]=m[e],g=y.get(t),h=g?.grading?.expectations,O=g?.outputs?.transcript,F=g?X.get(g.evalId):void 0;if(!g||!h?.length||!O||!F){I+=i.length,s(`run ${t.slice(0,8)}: missing output/expectations/prompt \u2014 skipped`);continue}let M=await G({prompt:F,output:O,expectations:h.map(l=>l.text),model:n.model??void 0,timeout:U,engine:n.engine});M.judge_model&&k.add(M.judge_model);for(let l of i){let L=h[l.expectationIndex],A=M.expectations[l.expectationIndex];if(!L||!A||L.text!==l.expectationText){I+=1;continue}if(M.judge_model==null&&A.method==="llm"){I+=1;continue}$.push({runId:t,expectationIndex:l.expectationIndex,text:l.expectationText,humanPassed:D(l.verdict,l.judgePassed),judgeAPassed:l.judgePassed,judgeBPassed:A.passed})}a(` ${e+1}/${m.length} re-graded`)}},"workerFn");await Promise.all(Array.from({length:Math.max(1,Math.min(K,m.length))},Q));let V=j($,I),_=[...k][0]??n.model??`${n.engine} (CLI default)`,E=0;if($.length>0)try{E=(await T(`/api/eval-targets/${d}/judge-reviews`,{reviewerEngine:n.engine,reviewerModel:_,verdicts:$.map(t=>({evalRunId:t.runId,expectationIndex:t.expectationIndex,expectationText:t.text,judgePassed:t.judgeAPassed,humanPassed:t.humanPassed,reviewerPassed:t.judgeBPassed}))})).upserted,a(`Persisted ${E} reviewer verdict(s) \u2014 disagreements appear on the Review tab.`)}catch(e){s(`Could not persist reviewer verdicts: ${e instanceof Error?e.message:e}`)}return{targetName:v.name,reviewer:n,judgeModels:Y,reviewerModel:_,report:V,persisted:E,alreadyReviewed:c,deferredPartialRuns:x}}p(oe,"runJudgeReviewPass");export{W as a,Z as b,w as c,oe as d};
1
+ import{b as D,c as j}from"./chunk-6UEFCMR2.js";import{b as B,c as R,d as N,e as z}from"./chunk-NF2BIEAF.js";import{a as G}from"./chunk-BJSVATVJ.js";import{c as J}from"./chunk-RIVEBBZC.js";import{e as f,g as T}from"./chunk-2AVGUZ2P.js";import{a as p}from"./chunk-ZLLER3HP.js";function W(r,a,s){return s?r.reviewerModel===s||r.reviewerModel===`${a}:${s}`:r.reviewerEngine===a}p(W,"reviewMatchesReviewer");var C=100;function Z(r){let a=new Set;return r.forEach((s,d)=>{s.method!=="deterministic"&&a.add(d)}),a}p(Z,"llmExpectationIndexes");var w=class extends Error{constructor(s,d){super(d);this.reason=s}static{p(this,"JudgeReviewSkip")}};async function oe(r){let a=r.log??(()=>{}),s=r.warn??a,d=r.targetId,K=r.parallel??3,U=r.timeoutMs??12e4,v=await f(`/api/eval-targets/${d}`),u=(await f(`/api/eval-targets/${d}/annotations?limit=500`)).filter(e=>e.judgeMethod==="llm");if(u.length===0)throw new w("no-labels",`No human labels on "${v.name}" yet \u2014 label some runs in the Review tab first.`);let n;try{n=z({engineFlag:r.engineFlag??"auto",modelFlag:r.modelFlag,availability:N(),judgeModels:[...new Set(u.map(e=>e.judgeModel).filter(e=>e!=null))]})}catch(e){throw new w("no-engine",e instanceof Error?e.message:String(e))}a(`Reviewer: ${n.rationale}`);let c=0,b=u;if(r.skipReviewed){let e=await f(`/api/eval-targets/${d}/judge-reviews`),t=new Set(e.filter(i=>W(i,n.engine,r.modelFlag)).map(i=>`${i.evalRunId}:${i.expectationIndex}`));if(b=u.filter(i=>!t.has(`${i.evalRunId}:${i.expectationIndex}`)),c=u.length-b.length,b.length===0)return{targetName:v.name,reviewer:n,judgeModels:[],reviewerModel:n.model??`${n.engine} (CLI default)`,report:j([],0),persisted:0,alreadyReviewed:c,deferredPartialRuns:0}}let y=new Map;for(let e=0;;e+=C){let t=await f(`/api/eval-targets/${d}/runs?limit=${C}&offset=${e}`);for(let i of t)y.set(i.id,i);if(t.length<C)break}let q=await f(`/api/eval-targets/${d}/evals`),X=new Map(q.map(e=>[e.id,e.prompt])),o=new Map;for(let e of b){let t=o.get(e.evalRunId)??[];t.push(e),o.set(e.evalRunId,t)}let P=new Map;for(let e of u){let t=P.get(e.evalRunId)??new Set;t.add(e.expectationIndex),P.set(e.evalRunId,t)}let x=0;for(let[e]of[...o]){let t=y.get(e)?.grading?.expectations;if(!t)continue;let i=Z(t),g=P.get(e)??new Set;[...i].every(h=>g.has(h))||(o.delete(e),x+=1)}if(x>0&&a(`${x} partially-labeled run(s) deferred \u2014 a run is re-graded once, after all its assertions are labeled.`),o.size===0)return{targetName:v.name,reviewer:n,judgeModels:[],reviewerModel:n.model??`${n.engine} (CLI default)`,report:j([],0),persisted:0,alreadyReviewed:c,deferredPartialRuns:x};if(n.engine==="codex"&&n.model){let e=await J({prompt:"Reply with exactly: OK",model:n.model,timeout:6e4});if(e.error&&B(e.error)){if(n.model===R)throw new w("preflight-failed",`Codex fallback model ${R} is also unrunnable: ${e.error}`);s(`Your codex model "${n.model}" can't run on the installed CLI/account \u2014 falling back to ${R}.`),n={...n,model:R}}else if(e.error)throw new w("preflight-failed",`Codex preflight failed: ${e.error}`)}let S=[...o.values()].flat(),Y=[...new Set(S.map(e=>e.judgeModel).filter(e=>e!=null))];a(`Re-grading ${o.size} annotated run(s) / ${S.length} assertion(s) on "${v.name}"`+(c?` (${c} already reviewed \u2014 skipped)`:"")+".");let $=[],I=0,k=new Set,m=r.limit!=null?[...o.entries()].slice(0,Math.max(1,r.limit)):[...o.entries()];m.length<o.size&&a(`Sampling ${m.length} of ${o.size} annotated runs (limit).`);let H=0,Q=p(async()=>{for(;;){let e=H++;if(e>=m.length)return;let[t,i]=m[e],g=y.get(t),h=g?.grading?.expectations,O=g?.outputs?.transcript,F=g?X.get(g.evalId):void 0;if(!g||!h?.length||!O||!F){I+=i.length,s(`run ${t.slice(0,8)}: missing output/expectations/prompt \u2014 skipped`);continue}let M=await G({prompt:F,output:O,expectations:h.map(l=>l.text),model:n.model??void 0,timeout:U,engine:n.engine});M.judge_model&&k.add(M.judge_model);for(let l of i){let L=h[l.expectationIndex],A=M.expectations[l.expectationIndex];if(!L||!A||L.text!==l.expectationText){I+=1;continue}if(M.judge_model==null&&A.method==="llm"){I+=1;continue}$.push({runId:t,expectationIndex:l.expectationIndex,text:l.expectationText,humanPassed:D(l.verdict,l.judgePassed),judgeAPassed:l.judgePassed,judgeBPassed:A.passed})}a(` ${e+1}/${m.length} re-graded`)}},"workerFn");await Promise.all(Array.from({length:Math.max(1,Math.min(K,m.length))},Q));let V=j($,I),_=[...k][0]??n.model??`${n.engine} (CLI default)`,E=0;if($.length>0)try{E=(await T(`/api/eval-targets/${d}/judge-reviews`,{reviewerEngine:n.engine,reviewerModel:_,verdicts:$.map(t=>({evalRunId:t.runId,expectationIndex:t.expectationIndex,expectationText:t.text,judgePassed:t.judgeAPassed,humanPassed:t.humanPassed,reviewerPassed:t.judgeBPassed}))})).upserted,a(`Persisted ${E} reviewer verdict(s) \u2014 disagreements appear on the Review tab.`)}catch(e){s(`Could not persist reviewer verdicts: ${e instanceof Error?e.message:e}`)}return{targetName:v.name,reviewer:n,judgeModels:Y,reviewerModel:_,report:V,persisted:E,alreadyReviewed:c,deferredPartialRuns:x}}p(oe,"runJudgeReviewPass");export{W as a,Z as b,w as c,oe as d};
@@ -1 +1 @@
1
- import{a}from"./chunk-GP46IPK2.js";import{a as e}from"./chunk-ZLLER3HP.js";function i(){return process.env.RULEMETRIC_API_URL??a}e(i,"apiUrl");function u(){let n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)throw new Error("not signed in \u2014 run `rulemetric auth login`");return n}e(u,"authToken");async function t(n,o){let r=await fetch(`${i()}${n}`,{...o,headers:{Authorization:`Bearer ${u()}`,"Content-Type":"application/json",...o?.headers??{}},signal:AbortSignal.timeout(1e4)});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return await r.json()}e(t,"request");function c({limit:n}){return t(`/api/launch-jobs?limit=${n}`)}e(c,"fetchLaunchJobs");function h(n){return t("/api/launch-jobs",{method:"POST",body:JSON.stringify(n)})}e(h,"createLaunchJob");function l(n){return t(`/api/launch-jobs/${n}/cancel`,{method:"POST"})}e(l,"cancelLaunchJob");function p(){return t("/api/launchers")}e(p,"listLaunchers");export{c as a,h as b,l as c,p as d};
1
+ import{a}from"./chunk-2AVGUZ2P.js";import{a as e}from"./chunk-ZLLER3HP.js";function i(){return process.env.RULEMETRIC_API_URL??a}e(i,"apiUrl");function u(){let n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)throw new Error("not signed in \u2014 run `rulemetric auth login`");return n}e(u,"authToken");async function t(n,o){let r=await fetch(`${i()}${n}`,{...o,headers:{Authorization:`Bearer ${u()}`,"Content-Type":"application/json",...o?.headers??{}},signal:AbortSignal.timeout(1e4)});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return await r.json()}e(t,"request");function c({limit:n}){return t(`/api/launch-jobs?limit=${n}`)}e(c,"fetchLaunchJobs");function h(n){return t("/api/launch-jobs",{method:"POST",body:JSON.stringify(n)})}e(h,"createLaunchJob");function l(n){return t(`/api/launch-jobs/${n}/cancel`,{method:"POST"})}e(l,"cancelLaunchJob");function p(){return t("/api/launchers")}e(p,"listLaunchers");export{c as a,h as b,l as c,p as d};
@@ -1 +1 @@
1
- import{a as j}from"./chunk-4NAYH7VA.js";import{a as E}from"./chunk-NBTC5FNV.js";import{a as J}from"./chunk-TU2AR6XO.js";import{d as T}from"./chunk-NJ5UED3H.js";import{b as I,c as P,d as v}from"./chunk-V3CAUY7M.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-XUGWUFIQ.js";import{a as E}from"./chunk-NBTC5FNV.js";import{a as J}from"./chunk-TU2AR6XO.js";import{d as T}from"./chunk-NJ5UED3H.js";import{b as I,c as P,d as v}from"./chunk-VC3DJPUB.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,4 +1,4 @@
1
- import{b as E,d as R}from"./chunk-GP46IPK2.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-2AVGUZ2P.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{c as l}from"./chunk-GP46IPK2.js";import{c as a,l as u}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";var c=120*1e3,t=null;async function k(){if(process.env.RULEMETRIC_API_KEY)return!0;let e=a(u());if(!e.isRefreshable(c))return!0;let r=e.loadToken();return r?.refreshToken?t||(t=f(e,r).finally(()=>{t=null}),t):!0}o(k,"ensureFreshToken");async function f(e,r){let s;try{s=await fetch(`${l()}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:r.refreshToken})})}catch{return!0}if(s.status===401)return e.clearToken(),!1;if(!s.ok)return!0;let n=await s.json().catch(()=>null);if(!n?.accessToken||!n.refreshToken)return!0;let i={accessToken:n.accessToken,refreshToken:n.refreshToken,expiresAt:n.expiresAt??r.expiresAt,email:n.email??r.email};return e.saveToken(i),e.saveEnvFile(i.accessToken),!0}o(f,"doRefresh");export{k as a};
1
+ import{c as l}from"./chunk-2AVGUZ2P.js";import{c as a,l as u}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";var c=120*1e3,t=null;async function k(){if(process.env.RULEMETRIC_API_KEY)return!0;let e=a(u());if(!e.isRefreshable(c))return!0;let r=e.loadToken();return r?.refreshToken?t||(t=f(e,r).finally(()=>{t=null}),t):!0}o(k,"ensureFreshToken");async function f(e,r){let s;try{s=await fetch(`${l()}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:r.refreshToken})})}catch{return!0}if(s.status===401)return e.clearToken(),!1;if(!s.ok)return!0;let n=await s.json().catch(()=>null);if(!n?.accessToken||!n.refreshToken)return!0;let i={accessToken:n.accessToken,refreshToken:n.refreshToken,expiresAt:n.expiresAt??r.expiresAt,email:n.email??r.email};return e.saveToken(i),e.saveEnvFile(i.accessToken),!0}o(f,"doRefresh");export{k as a};
@@ -1 +1 @@
1
- import{a as i}from"./chunk-V3CAUY7M.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-VC3DJPUB.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{b as $}from"./chunk-VBXL7XO7.js";import{e as w,f as k}from"./chunk-GP46IPK2.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-VBXL7XO7.js";import{e as w,f as k}from"./chunk-2AVGUZ2P.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};
@@ -0,0 +1,13 @@
1
+ import{a as I}from"./chunk-5RBLIVBF.js";import{a as j,d as O}from"./chunk-3UKZJAFS.js";import{c as U}from"./chunk-MOY7XDR6.js";import{a as T,b as P,c as H,d as A}from"./chunk-SJKS3PYX.js";import{a as W}from"./chunk-E7N5R3HV.js";import{c as x,d as L,f as S}from"./chunk-QBNLZJIR.js";import{e as _,f as J,h as d}from"./chunk-2AVGUZ2P.js";import{a as z,b as F}from"./chunk-OOGTQOL3.js";import{a as f}from"./chunk-ZLLER3HP.js";var B=f((l,{limit:a,sort:n,eventTypes:s})=>_(`/api/sessions/${l}/events?limit=${a}&sort=${n}&eventType=${encodeURIComponent(s.join(","))}&hasContent=true`),"fetchTranscriptTurns");async function is(l,a){let{mirrorId:n,projectPath:s,projectId:r,config:g}=l,t=f(e=>a.logger.info(e),"log");if(g?.sessionId)return Y({mirrorId:n,sessionId:g.sessionId},t);t(`Processing insights job ${n}...`),await d(`/api/insights-jobs/${n}/progress`,{status:"running",progress:{step:"reading_data"}});try{let{repaired:e}=await J("/api/sessions/repair-analyzed-at",{});e>0&&t(` Repaired analyzed_at on ${e} orphan session(s).`)}catch(e){t(` Warning: analyzed_at repair failed: ${e instanceof Error?e.message:String(e)}`)}let p=20,w=200,v=15*6e4,D=3,C=Date.now()+v;if(L()!=="none"){let e=0,o=0;try{for(;e<w&&Date.now()<C;){let c=await _(`/api/sessions?needsFacets=true&graderVersion=${2}&limit=${p}&offset=${o}`);if(c.length===0)break;t(` Generating facets for ${c.length} un-analyzed sessions (drained ${e} so far)...`);for(let $=0;$<c.length&&!(e>=w||Date.now()>=C);$+=D){let R=c.slice($,$+D);await Promise.all(R.map(async m=>{if(!(e>=w||Date.now()>=C))try{let u=await O(q=>B(m.id,q));if(u.turnCount<2){e++,o++;return}let k=await S(A,u.text,4096);k&&typeof k.outcome=="string"?(await d(`/api/sessions/${m.id}/enrich`,{analysis:{source:"generated_facets",...k,graderVersion:2},...m.eventCount!=null?{analyzedEventCount:m.eventCount}:{},analyzedTurnCount:u.turnCount}),t(` Generated facets for session ${m.id} (${m.tool}, ${u.turnCount} turns)`)):o++,e++}catch(u){t(` Failed to generate facets for session ${m.id}: ${u instanceof Error?u.message:String(u)}`),e++,o++}}))}if(c.length<p)break}}catch(c){t(` Warning: facet generation failed after ${e} sessions: ${c instanceof Error?c.message:String(c)}`)}if(e>0){let c=Date.now()>=C?`time budget (${Math.round(v/6e4)}m)`:e>=w?`hard cap (${w})`:"queue empty";t(` Facet drain stopped on ${c} after ${e} session(s); the rest resume next run.`)}}let b=await K(s,r);if(!b)throw new I("No session data found \u2014 ensure sessions are captured and enriched.");t(` Found ${b.stats.sessions} sessions, generating recommendations...`);let E=await Z(s,t);E&&t(` Generator memory: ${E.split(`
2
+ `).length} lines of prior-advice context`);let i={},y=[],h=P.length+1;for(let e=0;e<P.length;e++){let o=P[e];t(` [${e+1}/${h}] Generating ${o.name}...`);try{await d(`/api/insights-jobs/${n}/progress`,{status:"running",progress:{step:o.name,current:e+1,total:h,partial:{...i}}})}catch(u){t(` Warning: progress update failed for ${o.name}: ${u instanceof Error?u.message:String(u)}`)}t(` Running LLM prompt for ${o.name}...`);let c=o.usesGeneratorMemory&&E?`${b.summary}
3
+ ${E}`:b.summary,$=Date.now(),R=await S(o.prompt,c,o.maxTokens,{timeoutMs:o.timeoutMs}),m=Date.now()-$;R?(i[o.name]=R,t(` Got result for ${o.name} (${Math.round(m/1e3)}s)`)):(y.push(o.name),t(` No result for ${o.name} after ${Math.round(m/1e3)}s (budget ${Math.round((o.timeoutMs??12e4)/1e3)}s) \u2014 section DROPPED`))}t(` [${h}/${h}] Generating at_a_glance...`),await d(`/api/insights-jobs/${n}/progress`,{status:"running",progress:{step:"at_a_glance",current:h,total:h,partial:{...i}}});let V=[b.summary,i.what_works?`
4
+ ## What Works
5
+ ${JSON.stringify(i.what_works)}`:"",i.friction_analysis?`
6
+ ## Friction
7
+ ${JSON.stringify(i.friction_analysis)}`:"",i.suggestions?`
8
+ ## Suggestions
9
+ ${JSON.stringify(i.suggestions)}`:"",i.on_the_horizon?`
10
+ ## On the Horizon
11
+ ${JSON.stringify(i.on_the_horizon)}`:""].join(`
12
+ `),G=await S(H,V,8192);G&&(i.at_a_glance=G),t(" Uploading results..."),t(` Done! Recommendations generated for job ${n}`),F(i),z(i);let N={recommendations:i,...y.length>0?{sectionsFailed:y}:{}};return y.length>0&&t(` \u26A0 ${y.length} section(s) produced nothing: ${y.join(", ")}`),await d(`/api/insights-jobs/${n}/state`,{result:N}).catch(e=>{t(`result persist failed: ${e instanceof Error?e.message:String(e)}`)}),await W(i,s,t),N}f(is,"processInsights");async function Y(l,a){let{mirrorId:n,sessionId:s}=l;a(`Analyzing session ${s} via tool CLI...`),await d(`/api/insights-jobs/${n}/progress`,{status:"running",progress:{step:"fetching_session"}});let r=await _(`/api/sessions/${s}`);if(r.analysis&&r.analysis.source==="session_analysis")return a(` Session ${s} already analyzed \u2014 skipping (idempotency guard)`),{sessionId:s,skipped:!0,reason:"already_analyzed"};let g=await O(p=>B(s,p));if(g.turnCount<2)throw new I("Session has too few conversation turns to analyze");await d(`/api/insights-jobs/${n}/progress`,{status:"running",progress:{step:"running_analysis",tool:r.tool}});let t=await x(r.tool,A,g.text);if(!t)throw new Error(`Analysis failed \u2014 ${r.tool} CLI returned no result`);return await d(`/api/sessions/${s}/enrich`,{analysis:{source:"session_analysis",tool:r.tool,...t,graderVersion:2},...r.eventCount!=null?{analyzedEventCount:r.eventCount}:{},analyzedTurnCount:g.turnCount}),a(` Session ${s} analyzed via ${r.tool}`),{sessionId:s,tool:r.tool,facets:t}}f(Y,"processSessionAnalysisInline");async function Z(l,a,n=_,s=U){let{asks:r,omitted:g}=s(l);try{let t=await n(`/api/insights/recommendations/history?projectPath=${encodeURIComponent(l??"")}`);return!t||!Array.isArray(t.dismissed)||!Array.isArray(t.repeated)?T({dismissed:[],repeated:[],installed:r,installedOmitted:g}):T({...t,installed:r,installedOmitted:g})}catch(t){return a(` Warning: generator memory unavailable (${t instanceof Error?t.message:String(t)}) \u2014 generating without it`),T({dismissed:[],repeated:[],installed:r,installedOmitted:g})}}f(Z,"fetchGeneratorMemory");async function K(l,a){try{let n=new URLSearchParams;a?n.set("projectId",a):l&&n.set("projectPath",l);let s=await _(`/api/insights/compute?${n}`);if(!s||s.total_sessions===0)return null;let r=Object.entries(s.tool_counts??{}).sort((t,p)=>p[1]-t[1]).slice(0,10).map(([t,p])=>`${t}: ${p}`).join(", ");return{summary:[`Sessions: ${s.total_sessions}, Messages: ${s.total_messages}, Session-hours: ${Math.round(s.total_duration_hours)} (sum of per-session spans across ${s.sessions_with_meta} measured sessions; concurrent sessions counted separately, so this exceeds elapsed time)`,`Top tools: ${r}`,s.goal_categories&&Object.keys(s.goal_categories).length>0?`Goals: ${JSON.stringify(s.goal_categories)}`:"",s.friction&&Object.keys(s.friction).length>0?`Friction: ${JSON.stringify(s.friction)}`:"",s.outcomes&&Object.keys(s.outcomes).length>0?`Outcomes: ${JSON.stringify(s.outcomes)}`:"",s.projects&&Object.keys(s.projects).length>0?`Projects: ${JSON.stringify(s.projects)}`:""].filter(Boolean).join(`
13
+ `),stats:{sessions:s.total_sessions,totalMessages:s.total_messages,totalSessionHours:s.total_duration_hours,measuredSessions:s.sessions_with_meta,toolCounts:s.tool_counts,goalCounts:s.goal_categories,frictionCounts:s.friction}}}catch(n){throw new M(n instanceof Error?n.message:String(n))}}f(K,"buildDataSummaryFromApi");var M=class extends Error{static{f(this,"InsightsSummaryUnavailableError")}constructor(a){super(`Could not read session summary (retryable): ${a}`),this.name="InsightsSummaryUnavailableError"}};export{is as a,Z as b};
@@ -1 +1 @@
1
- import{b as g}from"./chunk-3ZHVP3KE.js";import{d as k,e as h}from"./chunk-NNOSORNV.js";import{e as m,i as f}from"./chunk-GP46IPK2.js";import{a as c}from"./chunk-ZLLER3HP.js";import{existsSync as b}from"node:fs";async function w($,y){let r=c(t=>y?.logger?.info?.(t)??console.log(t),"log"),{projectPath:s}=$,n=`[cron_retire_unused_skills] ${s}`;if(!s||!b(s))return{skipped:"project-missing",reason:`${s} does not exist on this machine \u2014 refusing to delete files for a project that is not here.`};let o=await m("/api/insights/groom-candidates"),e=g({captureHealthy:o.skillCaptureHealthy===!0,captureReason:o.skillCaptureHealthy===void 0?"API did not report skill capture health (older deployment)":o.skillCaptureReason,candidates:o.unusedSkills??[]});if(e.refused)return r(`${n} ${e.refused}: ${e.summary}`),{skipped:e.refused,reason:e.summary,held:e.held.length};r(`${n} ${e.summary}`);let a=[],d=[],l=0;for(let t of e.retire){let u=k({kind:"skill_file",target:t.name,cwd:s});if(!u.ok){l+=1,r(`${n} could not plan removal of ${t.name}: ${u.refusal??"unresolved"}`);continue}let R=new Date().toISOString().replace(/[:.]/g,"-"),i=h(u,R);if(!i.applied){l+=1,r(`${n} failed to remove ${t.name}: ${i.error??"unknown error"}`);continue}a.push(t.name),i.backupPath&&d.push(i.backupPath),r(`${n} retired ${t.name} (backup: ${i.backupPath??"none"})`);try{await f(`/api/instructions/${t.instructionId}`)}catch(p){r(`${n} removed ${t.name} but could not archive its instruction row: ${p instanceof Error?p.message:String(p)}`)}}return{retired:a.length,failed:l,held:e.held.length,names:a,backups:d,reason:e.summary}}c(w,"cronRetireUnusedSkills");export{w as a};
1
+ import{b as g}from"./chunk-3ZHVP3KE.js";import{d as k,e as h}from"./chunk-TJYXSMQV.js";import{e as m,i as f}from"./chunk-2AVGUZ2P.js";import{a as c}from"./chunk-ZLLER3HP.js";import{existsSync as b}from"node:fs";async function w($,y){let r=c(t=>y?.logger?.info?.(t)??console.log(t),"log"),{projectPath:s}=$,n=`[cron_retire_unused_skills] ${s}`;if(!s||!b(s))return{skipped:"project-missing",reason:`${s} does not exist on this machine \u2014 refusing to delete files for a project that is not here.`};let o=await m("/api/insights/groom-candidates"),e=g({captureHealthy:o.skillCaptureHealthy===!0,captureReason:o.skillCaptureHealthy===void 0?"API did not report skill capture health (older deployment)":o.skillCaptureReason,candidates:o.unusedSkills??[]});if(e.refused)return r(`${n} ${e.refused}: ${e.summary}`),{skipped:e.refused,reason:e.summary,held:e.held.length};r(`${n} ${e.summary}`);let a=[],d=[],l=0;for(let t of e.retire){let u=k({kind:"skill_file",target:t.name,cwd:s});if(!u.ok){l+=1,r(`${n} could not plan removal of ${t.name}: ${u.refusal??"unresolved"}`);continue}let R=new Date().toISOString().replace(/[:.]/g,"-"),i=h(u,R);if(!i.applied){l+=1,r(`${n} failed to remove ${t.name}: ${i.error??"unknown error"}`);continue}a.push(t.name),i.backupPath&&d.push(i.backupPath),r(`${n} retired ${t.name} (backup: ${i.backupPath??"none"})`);try{await f(`/api/instructions/${t.instructionId}`)}catch(p){r(`${n} removed ${t.name} but could not archive its instruction row: ${p instanceof Error?p.message:String(p)}`)}}return{retired:a.length,failed:l,held:e.held.length,names:a,backups:d,reason:e.summary}}c(w,"cronRetireUnusedSkills");export{w as a};
@@ -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-GP46IPK2.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-2AVGUZ2P.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{b as l}from"./chunk-RFISMWRW.js";import{a as p}from"./chunk-5RBLIVBF.js";import{h}from"./chunk-GP46IPK2.js";import{a as c}from"./chunk-ZLLER3HP.js";async function g(t){if(!t.worktree?.create)return t;let{branch:e,baseRef:s}=t.worktree,n=await l({repoRoot:t.projectPath,branch:e,baseRef:s});return{...t,projectPath:n.path,gitBranch:n.branch}}c(g,"resolveWorktreeForLaunch");async function L(t,e){let{mirrorId:s,tool:n}=t,{config:r}=t,a=c(o=>e.logger.info(o),"log");if(e.job.attempts>1)throw new p(`process_launch is not safe to retry (attempt ${e.job.attempts}). Re-launch manually.`);r=await g(r),r.worktree?.create&&a(`Worktree resolved: ${r.projectPath} (branch ${r.gitBranch})`),a(`Launching ${n}...`);let{getLauncher:f}=await import("./dist-XEWF3R3N.js"),i=await f(n).launch(r);a(`Launch completed: sessionId=${i.sessionId}`);let u={...i,worktreePath:r.worktree?.create?r.projectPath:void 0,runId:r.runId};return await h(`/api/launch-jobs/${s}/state`,{result:u}).catch(o=>{a(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),u}c(L,"processLaunch");export{g as a,L as b};
1
+ import{b as l}from"./chunk-RFISMWRW.js";import{a as p}from"./chunk-5RBLIVBF.js";import{h}from"./chunk-2AVGUZ2P.js";import{a as c}from"./chunk-ZLLER3HP.js";async function g(t){if(!t.worktree?.create)return t;let{branch:e,baseRef:s}=t.worktree,n=await l({repoRoot:t.projectPath,branch:e,baseRef:s});return{...t,projectPath:n.path,gitBranch:n.branch}}c(g,"resolveWorktreeForLaunch");async function L(t,e){let{mirrorId:s,tool:n}=t,{config:r}=t,a=c(o=>e.logger.info(o),"log");if(e.job.attempts>1)throw new p(`process_launch is not safe to retry (attempt ${e.job.attempts}). Re-launch manually.`);r=await g(r),r.worktree?.create&&a(`Worktree resolved: ${r.projectPath} (branch ${r.gitBranch})`),a(`Launching ${n}...`);let{getLauncher:f}=await import("./dist-XEWF3R3N.js"),i=await f(n).launch(r);a(`Launch completed: sessionId=${i.sessionId}`);let u={...i,worktreePath:r.worktree?.create?r.projectPath:void 0,runId:r.runId};return await h(`/api/launch-jobs/${s}/state`,{result:u}).catch(o=>{a(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),u}c(L,"processLaunch");export{g as a,L as b};
@@ -1,2 +1,2 @@
1
- import{a as v,b as u,e as y,g as d}from"../../chunk-HNAVHRGY.js";import{a as h}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import"../../chunk-PZNWH4VQ.js";import{a as p}from"../../chunk-ZLLER3HP.js";import{Args as k,Flags as o}from"@oclif/core";import{existsSync as T}from"node:fs";import{homedir as P}from"node:os";import{join as I}from"node:path";var A=I(P(),".gemini","antigravity-ide","brain"),g=class x extends h{static{p(this,"AntigravityBackfill")}static description="Backfill historical events from an Antigravity conversation transcript into a RuleMetric session. Useful for seeding a conversation that existed before hooks were installed \u2014 the live hook intentionally only captures forward.";static examples=["<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --session 158db9aa-68ee-43fc-961b-f3a180578694","<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --dry-run"];static args={conversationId:k.string({description:"Antigravity conversationId (UUID) \u2014 the directory name under ~/.gemini/antigravity-ide/brain/",required:!0})};static flags={session:o.string({char:"s",description:"RuleMetric session UUID to POST events into. If omitted, resolved from the hook tmp file ($TMPDIR/rulemetric/<conversationId>) \u2014 fails if neither is present."}),transcript:o.string({description:"Path to the transcript.jsonl file. Defaults to ~/.gemini/antigravity-ide/brain/<conversationId>/.system_generated/logs/transcript.jsonl"}),"after-step":o.integer({description:"Only emit records with step_index > this value. Default: read from existing state file, else -1 (everything)."}),limit:o.integer({description:"Cap on the number of records to process this run."}),"dry-run":o.boolean({default:!1,description:"Classify records without POSTing. Reports counts only."}),"save-state":o.boolean({default:!0,allowNo:!0,description:"After backfill, persist the highest step_index so the live hook resumes from there."})};async run(){let{args:b,flags:e}=await this.parse(x),t=b.conversationId;d.loadEnvFile(),process.env.RULEMETRIC_API_URL||this.error("RULEMETRIC_API_URL is not set. Configure it via env or ~/.config/rulemetric/env.");let l=e.transcript??I(A,t,".system_generated","logs","transcript.jsonl");T(l)||this.error(`Transcript not found: ${l}`);let m=e.session??d.resolveRwSessionId(t);m||this.error(`No RuleMetric session resolved. Pass --session <uuid>, or run the Antigravity hook at least once so $TMPDIR/rulemetric/${t} is populated.`);let n=e["after-step"];n===void 0&&(n=d.load(t)?.lastStepIdx??-1);let i=v(l,n);e.limit!==void 0&&i.length>e.limit&&(i=i.slice(0,e.limit));let R=u(l);if(this.log(`Conversation ${t}: transcript max step = ${R}, after-step = ${n}, records to process = ${i.length}`),i.length===0){this.log("Nothing to backfill.");return}if(e["dry-run"]){let r=0,a=0,c={};for(let S of i){let f=(await import("../../lib/antigravity-transcript.js")).classifyRecord(S,0);f?(r++,c[f.eventType]=(c[f.eventType]??0)+1):a++}this.log(`Dry run: would emit ${r}, skip ${a}. By eventType: ${JSON.stringify(c)}`);return}let w=Date.now(),s=await y(i,m,t,n,{onProgress:p(({attempted:r,total:a})=>{(r%100===0||r===a)&&process.stderr.write(` \u2026${r}/${a}
1
+ import{a as v,b as u,e as y,g as d}from"../../chunk-VTUTSUFW.js";import{a as h}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as p}from"../../chunk-ZLLER3HP.js";import{Args as k,Flags as o}from"@oclif/core";import{existsSync as T}from"node:fs";import{homedir as P}from"node:os";import{join as I}from"node:path";var A=I(P(),".gemini","antigravity-ide","brain"),g=class x extends h{static{p(this,"AntigravityBackfill")}static description="Backfill historical events from an Antigravity conversation transcript into a RuleMetric session. Useful for seeding a conversation that existed before hooks were installed \u2014 the live hook intentionally only captures forward.";static examples=["<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --session 158db9aa-68ee-43fc-961b-f3a180578694","<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --dry-run"];static args={conversationId:k.string({description:"Antigravity conversationId (UUID) \u2014 the directory name under ~/.gemini/antigravity-ide/brain/",required:!0})};static flags={session:o.string({char:"s",description:"RuleMetric session UUID to POST events into. If omitted, resolved from the hook tmp file ($TMPDIR/rulemetric/<conversationId>) \u2014 fails if neither is present."}),transcript:o.string({description:"Path to the transcript.jsonl file. Defaults to ~/.gemini/antigravity-ide/brain/<conversationId>/.system_generated/logs/transcript.jsonl"}),"after-step":o.integer({description:"Only emit records with step_index > this value. Default: read from existing state file, else -1 (everything)."}),limit:o.integer({description:"Cap on the number of records to process this run."}),"dry-run":o.boolean({default:!1,description:"Classify records without POSTing. Reports counts only."}),"save-state":o.boolean({default:!0,allowNo:!0,description:"After backfill, persist the highest step_index so the live hook resumes from there."})};async run(){let{args:b,flags:e}=await this.parse(x),t=b.conversationId;d.loadEnvFile(),process.env.RULEMETRIC_API_URL||this.error("RULEMETRIC_API_URL is not set. Configure it via env or ~/.config/rulemetric/env.");let l=e.transcript??I(A,t,".system_generated","logs","transcript.jsonl");T(l)||this.error(`Transcript not found: ${l}`);let m=e.session??d.resolveRwSessionId(t);m||this.error(`No RuleMetric session resolved. Pass --session <uuid>, or run the Antigravity hook at least once so $TMPDIR/rulemetric/${t} is populated.`);let n=e["after-step"];n===void 0&&(n=d.load(t)?.lastStepIdx??-1);let i=v(l,n);e.limit!==void 0&&i.length>e.limit&&(i=i.slice(0,e.limit));let R=u(l);if(this.log(`Conversation ${t}: transcript max step = ${R}, after-step = ${n}, records to process = ${i.length}`),i.length===0){this.log("Nothing to backfill.");return}if(e["dry-run"]){let r=0,a=0,c={};for(let S of i){let f=(await import("../../lib/antigravity-transcript.js")).classifyRecord(S,0);f?(r++,c[f.eventType]=(c[f.eventType]??0)+1):a++}this.log(`Dry run: would emit ${r}, skip ${a}. By eventType: ${JSON.stringify(c)}`);return}let w=Date.now(),s=await y(i,m,t,n,{onProgress:p(({attempted:r,total:a})=>{(r%100===0||r===a)&&process.stderr.write(` \u2026${r}/${a}
2
2
  `)},"onProgress")}),$=((Date.now()-w)/1e3).toFixed(1);this.log(`Backfill complete in ${$}s. attempted=${s.attempted} emitted=${s.emitted} skipped=${s.skipped} failed=${s.failed} highestStepIdx=${s.highestStepIdx}`),e["save-state"]?(d.save(t,{lastStepIdx:s.highestStepIdx}),this.log(`State saved \u2192 live hook will resume from step_index > ${s.highestStepIdx}.`)):this.log("State NOT saved (--no-save-state). Live hook will re-emit any new records from after-step.")}};export{g as default};
@@ -1 +1 @@
1
- import{a as n}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import{f as r}from"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import{i as o,l as s}from"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import*as c from"node:path";import{Flags as l}from"@oclif/core";var t=class g extends n{static{a(this,"AuthCreateKey")}static description="Create a long-lived API key for CLI and proxy authentication";static examples=['<%= config.bin %> auth create-key --name "laptop"','<%= config.bin %> auth create-key --name "ci token" --no-save'];static flags={name:l.string({char:"n",description:"Name for this key",required:!0}),save:l.boolean({char:"s",description:"Save key to ~/.config/rulemetric/env for hooks/proxy",default:!0,allowNo:!0})};async run(){let{flags:i}=await this.parse(g),e=await r("/api/auth/api-keys",{name:i.name});this.log(""),this.log("API key created successfully:"),this.log(""),this.log(` Name: ${e.name}`),this.log(` Key: ${e.key}`),this.log(` Prefix: ${e.keyPrefix}`),this.log(""),this.warn("Save this key now \u2014 it will not be shown again."),i.save&&(o(e.key,process.env.RULEMETRIC_API_URL),this.log(""),this.log(`Key saved to ${c.join(s(),"env")} (RULEMETRIC_API_KEY)`),this.log("Hooks and proxy will use this key automatically."))}};export{t as default};
1
+ import{a as n}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{f as r}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{i as o,l as s}from"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import*as c from"node:path";import{Flags as l}from"@oclif/core";var t=class g extends n{static{a(this,"AuthCreateKey")}static description="Create a long-lived API key for CLI and proxy authentication";static examples=['<%= config.bin %> auth create-key --name "laptop"','<%= config.bin %> auth create-key --name "ci token" --no-save'];static flags={name:l.string({char:"n",description:"Name for this key",required:!0}),save:l.boolean({char:"s",description:"Save key to ~/.config/rulemetric/env for hooks/proxy",default:!0,allowNo:!0})};async run(){let{flags:i}=await this.parse(g),e=await r("/api/auth/api-keys",{name:i.name});this.log(""),this.log("API key created successfully:"),this.log(""),this.log(` Name: ${e.name}`),this.log(` Key: ${e.key}`),this.log(` Prefix: ${e.keyPrefix}`),this.log(""),this.warn("Save this key now \u2014 it will not be shown again."),i.save&&(o(e.key,process.env.RULEMETRIC_API_URL),this.log(""),this.log(`Key saved to ${c.join(s(),"env")} (RULEMETRIC_API_KEY)`),this.log("Hooks and proxy will use this key automatically."))}};export{t as default};
@@ -1,4 +1,4 @@
1
- import{a as f}from"../../chunk-4MXLDBLV.js";import{a as w}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import{c}from"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import{b as n}from"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import{b as r,d as a}from"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import{b as m,d,h as u,i as g}from"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{Flags as p}from"@oclif/core";var h=class y extends w{static{l(this,"AuthLogin")}static description="Log in to RuleMetric";static examples=["<%= config.bin %> auth login","<%= config.bin %> auth login -e user@example.com"];static flags={email:p.string({char:"e",description:"Email address"}),password:p.string({char:"p",description:"Password (for non-interactive use)"}),"api-key":p.string({description:"Authenticate with an API key from https://rulemetric.com/connect (required for Google/GitHub sign-ins, which have no password)",exclusive:["password"]})};async run(){let{flags:s}=await this.parse(y);if(s["api-key"]){await this.loginWithApiKey(s["api-key"]);return}let e=s.email,t=s.password;if(!e||!t){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p, or set RULEMETRIC_API_KEY (create a key at https://rulemetric.com/connect).");let{input:o,password:k}=await import("@inquirer/prompts");this.log("Signed up with Google or GitHub? You have no password \u2014 press Ctrl-C and run:"),this.log(" rulemetric auth login --api-key <key> (create one at https://rulemetric.com/connect)"),this.log(""),e||(e=await o({message:"Email:"})),t||(t=await k({message:"Password:"}))}let i;try{i=await a("/auth/login",{method:"POST",body:{email:e,password:t},timeoutMs:2e4})}catch(o){throw o instanceof r&&o.statusCode===401&&this.error(`Invalid email or password.
1
+ import{a as f}from"../../chunk-LW3UE2FY.js";import{a as w}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import{c}from"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import{b as n}from"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{b as r,d as a}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{b as m,d,h as u,i as g}from"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{Flags as p}from"@oclif/core";var h=class y extends w{static{l(this,"AuthLogin")}static description="Log in to RuleMetric";static examples=["<%= config.bin %> auth login","<%= config.bin %> auth login -e user@example.com"];static flags={email:p.string({char:"e",description:"Email address"}),password:p.string({char:"p",description:"Password (for non-interactive use)"}),"api-key":p.string({description:"Authenticate with an API key from https://rulemetric.com/connect (required for Google/GitHub sign-ins, which have no password)",exclusive:["password"]})};async run(){let{flags:s}=await this.parse(y);if(s["api-key"]){await this.loginWithApiKey(s["api-key"]);return}let e=s.email,t=s.password;if(!e||!t){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p, or set RULEMETRIC_API_KEY (create a key at https://rulemetric.com/connect).");let{input:o,password:k}=await import("@inquirer/prompts");this.log("Signed up with Google or GitHub? You have no password \u2014 press Ctrl-C and run:"),this.log(" rulemetric auth login --api-key <key> (create one at https://rulemetric.com/connect)"),this.log(""),e||(e=await o({message:"Email:"})),t||(t=await k({message:"Password:"}))}let i;try{i=await a("/auth/login",{method:"POST",body:{email:e,password:t},timeoutMs:2e4})}catch(o){throw o instanceof r&&o.statusCode===401&&this.error(`Invalid email or password.
2
2
 
3
3
  If you signed up with Google or GitHub, you have no password \u2014 that is why this cannot work. Create an API key at https://rulemetric.com/connect, then run:
4
4
  rulemetric auth login --api-key <key>`),o}let v=i.expiresAt??new Date(Date.now()+3600*1e3).toISOString();d({accessToken:i.accessToken,refreshToken:i.refreshToken,expiresAt:v,email:i.email}),u(i.accessToken,process.env.RULEMETRIC_API_URL),await n(),await f(this.log.bind(this),this.warn.bind(this),this.config.version),c("auth_login",{},this.config.version),this.log(`Logged in as ${i.email}`)}async loginWithApiKey(s){let e=s.trim();e||this.error("Empty --api-key. Create one at https://rulemetric.com/connect"),process.env.RULEMETRIC_API_KEY=e;try{await a("/api/setup/status",{timeoutMs:2e4})}catch(t){throw delete process.env.RULEMETRIC_API_KEY,t instanceof r&&(t.statusCode===401||t.statusCode===403)&&this.error("That API key was rejected. Check you copied it whole (it is shown only once at creation) or mint a new one at https://rulemetric.com/connect"),t}g(e,process.env.RULEMETRIC_API_URL),m(),await n(),c("auth_login",{method:"api_key"},this.config.version),this.log(`Authenticated with API key ${e.slice(0,11)}...`),this.log("Verify any time with: rulemetric auth status")}};export{h as default};
@@ -1 +1 @@
1
- import{a as s}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import{f as i,j as r}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";var e=class t extends s{static{o(this,"AuthLogout")}static description="Log out of RuleMetric";static examples=["<%= config.bin %> auth logout"];async run(){await this.parse(t),i(),r(),this.log("Logged out successfully.")}};export{e as default};
1
+ import{a as s}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{f as i,j as r}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";var e=class t extends s{static{o(this,"AuthLogout")}static description="Log out of RuleMetric";static examples=["<%= config.bin %> auth logout"];async run(){await this.parse(t),i(),r(),this.log("Logged out successfully.")}};export{e as default};
@@ -1,4 +1,4 @@
1
- import{a as k}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import{e as n,i as c}from"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import"../../chunk-PZNWH4VQ.js";import{a as s}from"../../chunk-ZLLER3HP.js";import{Args as y}from"@oclif/core";var a=class m extends k{static{s(this,"AuthRevokeKey")}static description="Revoke an API key (run with no argument to list active keys)";static examples=["<%= config.bin %> auth revoke-key","<%= config.bin %> auth revoke-key rm_abc12345",'<%= config.bin %> auth revoke-key "my-laptop (auto)"'];static args={id:y.string({description:"API key ID, prefix (rm_xxxxxxxx), or name"})};async run(){let{args:o}=await this.parse(m),r=(await n("/api/auth/api-keys")).filter(e=>!e.revokedAt);if(!o.id){if(r.length===0){this.log("No active API keys.");return}this.log(`Active API keys \u2014 pass an id, prefix, or name to revoke one:
1
+ import{a as k}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{e as n,i as c}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as s}from"../../chunk-ZLLER3HP.js";import{Args as y}from"@oclif/core";var a=class m extends k{static{s(this,"AuthRevokeKey")}static description="Revoke an API key (run with no argument to list active keys)";static examples=["<%= config.bin %> auth revoke-key","<%= config.bin %> auth revoke-key rm_abc12345",'<%= config.bin %> auth revoke-key "my-laptop (auto)"'];static args={id:y.string({description:"API key ID, prefix (rm_xxxxxxxx), or name"})};async run(){let{args:o}=await this.parse(m),r=(await n("/api/auth/api-keys")).filter(e=>!e.revokedAt);if(!o.id){if(r.length===0){this.log("No active API keys.");return}this.log(`Active API keys \u2014 pass an id, prefix, or name to revoke one:
2
2
  `);for(let e of r)this.log(` ${e.id} ${e.keyPrefix}... ${e.name}`);return}let i=o.id,t=r.filter(e=>e.id===i||e.name===i||i.startsWith("rm_")&&i.startsWith(e.keyPrefix));t.length===0&&this.error(`No active API key matches "${i}". Run \`rulemetric auth revoke-key\` with no argument to list keys.`),t.length>1&&this.error(`"${i}" matches ${t.length} keys \u2014 use the exact key ID:
3
3
  `+t.map(e=>` ${e.id} ${e.keyPrefix}... ${e.name}`).join(`
4
4
  `)),await c(`/api/auth/api-keys/${t[0].id}`),this.log(`API key ${t[0].keyPrefix}... ("${t[0].name}") revoked.`)}};export{a as default};
@@ -1 +1 @@
1
- import{a as g}from"../../chunk-4MXLDBLV.js";import{a as h}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import{c as d}from"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import{b as l}from"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import{b as m,d as p}from"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import{d as n,h as c}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as u}from"@oclif/core";var t=class f extends h{static{o(this,"AuthSignup")}static description="Create a RuleMetric account from the CLI";static examples=["<%= config.bin %> auth signup","<%= config.bin %> auth signup -e user@example.com"];static flags={email:u.string({char:"e",description:"Email address"}),password:u.string({char:"p",description:"Password (min 8 chars; for non-interactive use)"})};async run(){let{flags:a}=await this.parse(f),i=a.email,r=a.password;if(!i||!r){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p.");let{input:s,password:v}=await import("@inquirer/prompts");i||(i=await s({message:"Email:"})),r||(r=await v({message:"Password (min 8 chars):"}))}let e;try{e=await p("/auth/signup",{method:"POST",body:{email:i,password:r},timeoutMs:2e4})}catch(s){throw s instanceof m&&s.statusCode===409&&this.error(`An account with ${i} already exists. Run: rulemetric auth login -e ${i}`),s}if(e.confirmationRequired||!e.accessToken||!e.refreshToken){this.log(`Account created for ${e.email}.`),this.log("Check your email and click the confirmation link, then run:"),this.log(` rulemetric auth login -e ${e.email}`);return}let w=e.expiresAt??new Date(Date.now()+3600*1e3).toISOString();n({accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:w,email:e.email}),c(e.accessToken,process.env.RULEMETRIC_API_URL),await l(),await g(this.log.bind(this),this.warn.bind(this),this.config.version),d("auth_signup",{},this.config.version),this.log(`Signed up and logged in as ${e.email}`)}};export{t as default};
1
+ import{a as g}from"../../chunk-LW3UE2FY.js";import{a as h}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import{c as d}from"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import{b as l}from"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{b as m,d as p}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{d as n,h as c}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as u}from"@oclif/core";var t=class f extends h{static{o(this,"AuthSignup")}static description="Create a RuleMetric account from the CLI";static examples=["<%= config.bin %> auth signup","<%= config.bin %> auth signup -e user@example.com"];static flags={email:u.string({char:"e",description:"Email address"}),password:u.string({char:"p",description:"Password (min 8 chars; for non-interactive use)"})};async run(){let{flags:a}=await this.parse(f),i=a.email,r=a.password;if(!i||!r){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p.");let{input:s,password:v}=await import("@inquirer/prompts");i||(i=await s({message:"Email:"})),r||(r=await v({message:"Password (min 8 chars):"}))}let e;try{e=await p("/auth/signup",{method:"POST",body:{email:i,password:r},timeoutMs:2e4})}catch(s){throw s instanceof m&&s.statusCode===409&&this.error(`An account with ${i} already exists. Run: rulemetric auth login -e ${i}`),s}if(e.confirmationRequired||!e.accessToken||!e.refreshToken){this.log(`Account created for ${e.email}.`),this.log("Check your email and click the confirmation link, then run:"),this.log(` rulemetric auth login -e ${e.email}`);return}let w=e.expiresAt??new Date(Date.now()+3600*1e3).toISOString();n({accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:w,email:e.email}),c(e.accessToken,process.env.RULEMETRIC_API_URL),await l(),await g(this.log.bind(this),this.warn.bind(this),this.config.version),d("auth_signup",{},this.config.version),this.log(`Signed up and logged in as ${e.email}`)}};export{t as default};
@@ -1 +1 @@
1
- import{a as c}from"../../chunk-W2MV25SB.js";import{a as g}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import{a,e as l,l as t}from"../../chunk-PZNWH4VQ.js";import{a as r}from"../../chunk-ZLLER3HP.js";import*as u from"node:path";var o=class h extends g{static{r(this,"AuthStatus")}static description="Show current authentication status";static examples=["<%= config.bin %> auth status"];async run(){await this.parse(h);let e=l(),i=process.env.RULEMETRIC_API_KEY,s=a().apiKey;if(i||s){let m=i||s,p=i?"RULEMETRIC_API_KEY env var":u.join(t(),"env");this.log(`Authenticated via API key ${m.slice(0,11)}... (${p})`),e&&this.log(`Logged in as: ${e.email}`),this.log(`Config: ${t()}`);return}if(!e){this.log("Not logged in. Run `rulemetric auth login` to authenticate.");return}let n=new Date(e.expiresAt).getTime();if(Number.isNaN(n)||Date.now()>=n){this.log("Session expired. Run `rulemetric auth login` to re-authenticate.");return}this.log(`Logged in as: ${e.email}`),this.log(`Session expires: ${c(e.expiresAt)}`),this.log(`Config: ${t()}`)}};export{o as default};
1
+ import{a as c}from"../../chunk-W2MV25SB.js";import{a as g}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{a,e as l,l as t}from"../../chunk-PZNWH4VQ.js";import{a as r}from"../../chunk-ZLLER3HP.js";import*as u from"node:path";var o=class h extends g{static{r(this,"AuthStatus")}static description="Show current authentication status";static examples=["<%= config.bin %> auth status"];async run(){await this.parse(h);let e=l(),i=process.env.RULEMETRIC_API_KEY,s=a().apiKey;if(i||s){let m=i||s,p=i?"RULEMETRIC_API_KEY env var":u.join(t(),"env");this.log(`Authenticated via API key ${m.slice(0,11)}... (${p})`),e&&this.log(`Logged in as: ${e.email}`),this.log(`Config: ${t()}`);return}if(!e){this.log("Not logged in. Run `rulemetric auth login` to authenticate.");return}let n=new Date(e.expiresAt).getTime();if(Number.isNaN(n)||Date.now()>=n){this.log("Session expired. Run `rulemetric auth login` to re-authenticate.");return}this.log(`Logged in as: ${e.email}`),this.log(`Session expires: ${c(e.expiresAt)}`),this.log(`Config: ${t()}`)}};export{o as default};
@@ -1,2 +1,2 @@
1
- import{a as f,b as k,c as S,d as x,e as R,f as n,g as y}from"../../chunk-SHYP27B7.js";import{b as C,c as w,f as v,g as b}from"../../chunk-QXPYGN7I.js";import{a as u}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import{l as m}from"../../chunk-PZNWH4VQ.js";import{a as h}from"../../chunk-ZLLER3HP.js";import{existsSync as O}from"node:fs";import{Flags as c}from"@oclif/core";var g=class E extends u{static{h(this,"CaptureScope")}static description="Show or set which projects RuleMetric captures \u2014 the Codex sweep and hook-driven sessions each have their own scope";static examples=["<%= config.bin %> <%= command.id %>","<%= config.bin %> <%= command.id %> --add ~/work/client-a --add ~/work/client-b","<%= config.bin %> <%= command.id %> --tool hooks --add ~/work/client-a","<%= config.bin %> <%= command.id %> --tool hooks --off","<%= config.bin %> <%= command.id %> --remove ~/work/client-a","<%= config.bin %> <%= command.id %> --off","<%= config.bin %> <%= command.id %> --all"];static flags={tool:c.string({description:'Which capture path to edit: "codex" (the worker transcript sweep, the default) or "hooks" (Claude Code / Cursor / Copilot / Antigravity hook sessions).',options:["codex","hooks"],default:"codex"}),add:c.string({description:"Capture sessions under this path (repeatable). Implies an allowlist.",multiple:!0}),remove:c.string({description:"Stop capturing under this path (repeatable).",multiple:!0}),off:c.boolean({description:"Turn this capture path off entirely.",exclusive:["all"]}),all:c.boolean({description:"Capture every project (the default).",exclusive:["off"]}),clear:c.boolean({description:"Remove this scope, restoring the default."})};async run(){let{flags:o}=await this.parse(E),s=m(),d=f(s);if(!((o.add?.length??0)>0||(o.remove?.length??0)>0||o.off||o.all||o.clear)){await this.show(s,d);return}for(let t of[...o.add??[],...o.remove??[]])R(t)||this.error(`Not an absolute path: ${t}
1
+ import{a as f,b as k,c as S,d as x,e as R,f as n,g as y}from"../../chunk-SHYP27B7.js";import{b as C,c as w,f as v,g as b}from"../../chunk-QXPYGN7I.js";import{a as u}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import{l as m}from"../../chunk-PZNWH4VQ.js";import{a as h}from"../../chunk-ZLLER3HP.js";import{existsSync as O}from"node:fs";import{Flags as c}from"@oclif/core";var g=class E extends u{static{h(this,"CaptureScope")}static description="Show or set which projects RuleMetric captures \u2014 the Codex sweep and hook-driven sessions each have their own scope";static examples=["<%= config.bin %> <%= command.id %>","<%= config.bin %> <%= command.id %> --add ~/work/client-a --add ~/work/client-b","<%= config.bin %> <%= command.id %> --tool hooks --add ~/work/client-a","<%= config.bin %> <%= command.id %> --tool hooks --off","<%= config.bin %> <%= command.id %> --remove ~/work/client-a","<%= config.bin %> <%= command.id %> --off","<%= config.bin %> <%= command.id %> --all"];static flags={tool:c.string({description:'Which capture path to edit: "codex" (the worker transcript sweep, the default) or "hooks" (Claude Code / Cursor / Copilot / Antigravity hook sessions).',options:["codex","hooks"],default:"codex"}),add:c.string({description:"Capture sessions under this path (repeatable). Implies an allowlist.",multiple:!0}),remove:c.string({description:"Stop capturing under this path (repeatable).",multiple:!0}),off:c.boolean({description:"Turn this capture path off entirely.",exclusive:["all"]}),all:c.boolean({description:"Capture every project (the default).",exclusive:["off"]}),clear:c.boolean({description:"Remove this scope, restoring the default."})};async run(){let{flags:o}=await this.parse(E),s=m(),d=f(s);if(!((o.add?.length??0)>0||(o.remove?.length??0)>0||o.off||o.all||o.clear)){await this.show(s,d);return}for(let t of[...o.add??[],...o.remove??[]])R(t)||this.error(`Not an absolute path: ${t}
2
2
  Use an absolute path or ~/\u2026 \u2014 relative paths cannot be matched against a session's cwd.`);for(let t of o.add??[]){let a=x(t);O(a)||this.warn(`${a} does not exist yet \u2014 added anyway, but nothing will match until it does.`)}let e;try{e=k(s)}catch(t){o.clear||this.error(t instanceof Error?t.message:String(t));let a=y(s);this.warn(`${f(s)} was not valid JSON \u2014 saved it to ${a} and starting fresh.`),e={}}let i=o.tool??"codex",r=void 0,l=!1;if(o.clear&&({config:e}=n(e,{op:"clear"},r,i)),o.off&&({config:e}=n(e,{op:"mode",mode:"off"},r,i)),o.all&&({config:e}=n(e,{op:"mode",mode:"all"},r,i)),o.remove?.length){let t=n(e,{op:"remove",roots:o.remove},r,i);e=t.config,l=t.emptiedToOff}o.add?.length&&({config:e}=n(e,{op:"add",roots:o.add},r,i)),S(s,e),l&&(this.log(`Removed the last root \u2014 ${i==="hooks"?"hook":"Codex"} capture is now OFF rather than silently capturing everything.`),this.log("Use --all to go back to capturing every project.")),await this.show(s,d),this.log(""),this.log(i==="hooks"?"Takes effect on the next hook fire. No restart needed.":"Takes effect on the next sweep (within ~30s). No restart needed.")}async show(o,s){let d=await C({configDir:o}),p=await w({configDir:o}),e=h((i,r,l,t)=>{if(this.log(`${i}: ${l}`),r.roots.length)for(let a of r.roots)this.log(` \u2022 ${a}`);r.error&&(this.log(" This scope is FAILING CLOSED \u2014 nothing is being captured on this path."),this.log(` Fix the file, or run \`rulemetric capture scope ${i==="Hook capture"?"--tool hooks ":""}--clear\` to start over.`)),r.source==="env"&&this.log(` Set by environment variable, which outranks the config file (${t}).`)},"print");e("Codex capture",d,v(d),"RULEMETRIC_CODEX_CAPTURE / RULEMETRIC_CODEX_ROOTS"),e("Hook capture",p,b(p),"RULEMETRIC_HOOKS_CAPTURE / RULEMETRIC_HOOKS_ROOTS"),this.log(`Config: ${s}`)}};export{g as default};
@@ -1,2 +1,2 @@
1
- import{a as g,b as d,c as p}from"../../chunk-W2MV25SB.js";import{a as c}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Flags as i}from"@oclif/core";var o=class m extends c{static{a(this,"Catalog")}static description="Browse the org instruction catalog";static flags={badge:i.string({description:"Filter by badge",options:["recommended","required"]}),scope:i.string({description:"Filter by scope",options:["org","team"]}),search:i.string({description:"Search by name or description"})};async run(){let{flags:e}=await this.parse(m);this.requireAuth();let s=new URLSearchParams;e.badge&&s.set("badge",e.badge),e.scope&&s.set("scope",e.scope),e.search&&s.set("search",e.search);let r=await n(`/api/catalog?${s.toString()}`);if(r.length===0){this.log("No instructions found in catalog.");return}for(let t of r){let l=t.badge?` [${t.badge}]`:"",f=t.tags?.length?` (${t.tags.join(", ")})`:"";this.log(` ${d(t.name,40)} \u2014 ${p(t.scope)}${l} v${t.version}${f} ${g(t.updatedAt)}`)}this.log(`
1
+ import{a as g,b as d,c as p}from"../../chunk-W2MV25SB.js";import{a as c}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Flags as i}from"@oclif/core";var o=class m extends c{static{a(this,"Catalog")}static description="Browse the org instruction catalog";static flags={badge:i.string({description:"Filter by badge",options:["recommended","required"]}),scope:i.string({description:"Filter by scope",options:["org","team"]}),search:i.string({description:"Search by name or description"})};async run(){let{flags:e}=await this.parse(m);this.requireAuth();let s=new URLSearchParams;e.badge&&s.set("badge",e.badge),e.scope&&s.set("scope",e.scope),e.search&&s.set("search",e.search);let r=await n(`/api/catalog?${s.toString()}`);if(r.length===0){this.log("No instructions found in catalog.");return}for(let t of r){let l=t.badge?` [${t.badge}]`:"",f=t.tags?.length?` (${t.tags.join(", ")})`:"";this.log(` ${d(t.name,40)} \u2014 ${p(t.scope)}${l} v${t.version}${f} ${g(t.updatedAt)}`)}this.log(`
2
2
  ${r.length} instruction(s) found.`)}};export{o as default};
@@ -1,3 +1,3 @@
1
- import{a as i}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import{f as n}from"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import"../../chunk-PZNWH4VQ.js";import{a as t}from"../../chunk-ZLLER3HP.js";import{Args as c}from"@oclif/core";var o=class s extends i{static{t(this,"CatalogRecommend")}static description="Get AI-powered instruction recommendations for a project";static args={projectId:c.string({description:"ID of the project",required:!0})};async run(){let{args:a}=await this.parse(s);this.requireAuth(),this.log(`Analyzing project and generating recommendations...
1
+ import{a as i}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import{f as n}from"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as t}from"../../chunk-ZLLER3HP.js";import{Args as c}from"@oclif/core";var o=class s extends i{static{t(this,"CatalogRecommend")}static description="Get AI-powered instruction recommendations for a project";static args={projectId:c.string({description:"ID of the project",required:!0})};async run(){let{args:a}=await this.parse(s);this.requireAuth(),this.log(`Analyzing project and generating recommendations...
2
2
  `);let r=await n(`/api/projects/${a.projectId}/recommendations`,{});if(r.error&&this.warn(`Note: ${r.error}`),r.recommendations.length===0){this.log("No recommendations found.");return}for(let e of r.recommendations)this.log(` ${(e.score*100).toFixed(0)}% \u2014 ${e.instructionId}`),this.log(` ${e.reason}
3
3
  `)}};export{o as default};
@@ -1 +1 @@
1
- import{a as o}from"../../chunk-GY5IJ4RS.js";import{a as n}from"../../chunk-JKXU7FAY.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RDXWQDNZ.js";import"../../chunk-Y3T5Q5CD.js";import"../../chunk-OJSWNU56.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-GP46IPK2.js";import"../../chunk-DS4P5C4F.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{printTable as t}from"@oclif/table";var a=class s extends n{static{i(this,"CronsList")}static description="List manually-runnable maintenance tasks";static examples=["<%= config.bin %> crons list"];async run(){await this.parse(s),t({data:o.map(e=>({Name:e.name,"Scheduled by":e.scheduledBy,Description:e.description})),columns:["Name","Scheduled by","Description"]}),this.log(""),this.log("Scheduled crons run in Supabase pg_cron \u2014 audit them with:"),this.log(` psql "$DATABASE_URL" -c 'select jobname, schedule, active from cron.job;'`),this.log("Run any task above on demand with: rulemetric crons run <name>")}};export{a as default};
1
+ import{a as o}from"../../chunk-APXQLQZY.js";import{a as n}from"../../chunk-65TQMBNF.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-6PUH7HEL.js";import"../../chunk-WRQEHXSN.js";import"../../chunk-YTPQ7VBO.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-2AVGUZ2P.js";import"../../chunk-OOGTQOL3.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{printTable as t}from"@oclif/table";var a=class s extends n{static{i(this,"CronsList")}static description="List manually-runnable maintenance tasks";static examples=["<%= config.bin %> crons list"];async run(){await this.parse(s),t({data:o.map(e=>({Name:e.name,"Scheduled by":e.scheduledBy,Description:e.description})),columns:["Name","Scheduled by","Description"]}),this.log(""),this.log("Scheduled crons run in Supabase pg_cron \u2014 audit them with:"),this.log(` psql "$DATABASE_URL" -c 'select jobname, schedule, active from cron.job;'`),this.log("Run any task above on demand with: rulemetric crons run <name>")}};export{a as default};