@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}from"../../../chunk-UK7BR6XM.js";import"../../../chunk-QBNLZJIR.js";import"../../../chunk-N7ODX6PO.js";import"../../../chunk-PJ3WHQ67.js";import"../../../chunk-GP46IPK2.js";import"../../../chunk-DS4P5C4F.js";import"../../../chunk-PZNWH4VQ.js";import"../../../chunk-ZLLER3HP.js";export{a as processSessionGoal};
1
+ import{a}from"../../../chunk-2MZFB46B.js";import"../../../chunk-QBNLZJIR.js";import"../../../chunk-N7ODX6PO.js";import"../../../chunk-PJ3WHQ67.js";import"../../../chunk-2AVGUZ2P.js";import"../../../chunk-OOGTQOL3.js";import"../../../chunk-PZNWH4VQ.js";import"../../../chunk-ZLLER3HP.js";export{a as processSessionGoal};
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-ZSOYH7FX.js";import"../chunk-6UEFCMR2.js";import"../chunk-NF2BIEAF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-TZA4HAVF.js";import"../chunk-GP46IPK2.js";import"../chunk-DS4P5C4F.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{c as JudgeReviewSkip,b as llmExpectationIndexes,a as reviewMatchesReviewer,d as runJudgeReviewPass};
1
+ import{a,b,c,d}from"../chunk-UQSUSB6G.js";import"../chunk-6UEFCMR2.js";import"../chunk-NF2BIEAF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{c as JudgeReviewSkip,b as llmExpectationIndexes,a as reviewMatchesReviewer,d as runJudgeReviewPass};
@@ -1 +1 @@
1
- import{a}from"../chunk-GY5IJ4RS.js";import"../chunk-ZLLER3HP.js";export{a as MANUAL_TASK_META};
1
+ import{a}from"../chunk-APXQLQZY.js";import"../chunk-ZLLER3HP.js";export{a as MANUAL_TASK_META};
@@ -1 +1 @@
1
- import{a as l}from"../chunk-KOQRNWIW.js";import"../chunk-LUCVMLHV.js";import{a as u}from"../chunk-PZS55PW2.js";import{e as g}from"../chunk-YS5UJKK5.js";import"../chunk-HOQPVOMF.js";import"../chunk-GIRPEMTW.js";import"../chunk-MODXEGCU.js";import{a as i}from"../chunk-GY5IJ4RS.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-GP46IPK2.js";import"../chunk-DS4P5C4F.js";import"../chunk-PZNWH4VQ.js";import{a as o}from"../chunk-ZLLER3HP.js";var c={cron_check_changelog:o(async(r,e)=>{let s=await l({logger:{info:o(t=>e.logger.info(t),"info"),warn:o(t=>e.logger.warn(t),"warn")}});e.logger.info(`[cron_check_changelog] result: created=${s.createdCount} skipped=${s.skippedCount}`)},"cron_check_changelog"),cron_suggest_instructions:o((r,e)=>g(r,e),"cron_suggest_instructions"),cron_refresh_skills:o((r,e)=>u(r,e),"cron_refresh_skills")},p=i.map(r=>{let e=c[r.name];if(!e)throw new Error(`manual-tasks: no handler registered for "${r.name}"`);return{...r,handler:e}});async function m(r){let e=p.find(n=>n.name===r);if(!e)return{name:r,durationMs:0,ok:!1,error:`Unknown task: ${r}`,logs:[]};let s=[],t={logger:{info:o(n=>s.push({level:"info",message:n}),"info"),warn:o(n=>s.push({level:"warn",message:n}),"warn"),error:o(n=>s.push({level:"error",message:n}),"error")},job:{attempts:0}},a=Date.now();try{return await e.handler({},t),{name:r,durationMs:Date.now()-a,ok:!0,logs:s}}catch(n){return{name:r,durationMs:Date.now()-a,ok:!1,error:n instanceof Error?n.message:String(n),logs:s}}}o(m,"runManualTask");export{p as MANUAL_TASKS,m as runManualTask};
1
+ import{a as l}from"../chunk-QLG6OCYF.js";import"../chunk-LUCVMLHV.js";import{a as u}from"../chunk-PZS55PW2.js";import{e as c}from"../chunk-NMWP3JLW.js";import"../chunk-HOQPVOMF.js";import{a as g}from"../chunk-2K3RUBKC.js";import"../chunk-GIRPEMTW.js";import"../chunk-QUOH6GWM.js";import"../chunk-MODXEGCU.js";import{a as i}from"../chunk-APXQLQZY.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import{a as o}from"../chunk-ZLLER3HP.js";var f={cron_check_changelog:o(async(r,n)=>{let t=await l({logger:{info:o(s=>n.logger.info(s),"info"),warn:o(s=>n.logger.warn(s),"warn")}});n.logger.info(`[cron_check_changelog] result: created=${t.createdCount} skipped=${t.skippedCount}`)},"cron_check_changelog"),cron_suggest_instructions:o((r,n)=>c(r,n),"cron_suggest_instructions"),cron_reconcile_attribution:o((r,n)=>g(r,n).then(()=>{}),"cron_reconcile_attribution"),cron_refresh_skills:o((r,n)=>u(r,n),"cron_refresh_skills")},p=i.map(r=>{let n=f[r.name];if(!n)throw new Error(`manual-tasks: no handler registered for "${r.name}"`);return{...r,handler:n}});async function w(r){let n=p.find(e=>e.name===r);if(!n)return{name:r,durationMs:0,ok:!1,error:`Unknown task: ${r}`,logs:[]};let t=[],s={logger:{info:o(e=>t.push({level:"info",message:e}),"info"),warn:o(e=>t.push({level:"warn",message:e}),"warn"),error:o(e=>t.push({level:"error",message:e}),"error")},job:{attempts:0}},a=Date.now();try{return await n.handler({},s),{name:r,durationMs:Date.now()-a,ok:!0,logs:t}}catch(e){return{name:r,durationMs:Date.now()-a,ok:!1,error:e instanceof Error?e.message:String(e),logs:t}}}o(w,"runManualTask");export{p as MANUAL_TASKS,w as runManualTask};
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-ATSZBAG5.js";import"../chunk-D3CZJ6CZ.js";import"../chunk-FLSDLFUE.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-CJ4NG6FL.js";import"../chunk-6LYWI22A.js";import"../chunk-ANSK2LTP.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-GP46IPK2.js";import"../chunk-DS4P5C4F.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as MAX_RETIREMENTS_PER_REFINEMENT,c as executeCaseRefinement,b as planCaseRefinement};
1
+ import{a,b,c}from"../chunk-LZJXW3B6.js";import"../chunk-KHCMVYTH.js";import"../chunk-TZUTX4PG.js";import"../chunk-M7QSC64D.js";import"../chunk-DPCAPIQB.js";import"../chunk-T67L2YTW.js";import"../chunk-LB24UKHZ.js";import"../chunk-G7V4ZZZ3.js";import"../chunk-SD626JBZ.js";import"../chunk-SVON2JIS.js";import"../chunk-GN3ZHQ46.js";import"../chunk-U2NT5OSQ.js";import"../chunk-KGURGIZ2.js";import"../chunk-UPFH72PF.js";import"../chunk-BJSVATVJ.js";import"../chunk-CDY7TQFZ.js";import"../chunk-RIVEBBZC.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-VBXL7XO7.js";import"../chunk-TZA4HAVF.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as MAX_RETIREMENTS_PER_REFINEMENT,c as executeCaseRefinement,b as planCaseRefinement};
@@ -1 +1 @@
1
- import{a,b}from"../chunk-IZHJNPER.js";import"../chunk-GP46IPK2.js";import"../chunk-DS4P5C4F.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as postObservation,b as postObservations};
1
+ import{a,b}from"../chunk-OEZNBFJ2.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as postObservation,b as postObservations};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"../chunk-NNOSORNV.js";import"../chunk-UPFH72PF.js";import"../chunk-DS4P5C4F.js";import"../chunk-ZLLER3HP.js";export{e as applyRetraction,a as backupPathFor,c as candidateSkillPaths,b as pathFromContextIdentity,d as planRetraction};
1
+ import{a,b,c,d,e}from"../chunk-TJYXSMQV.js";import"../chunk-UPFH72PF.js";import"../chunk-OOGTQOL3.js";import"../chunk-ZLLER3HP.js";export{e as applyRetraction,a as backupPathFor,c as candidateSkillPaths,b as pathFromContextIdentity,d as planRetraction};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"../chunk-EINQYO2T.js";import"../chunk-QWCEZEDO.js";import"../chunk-KKDHD4XA.js";import"../chunk-SZ62CP55.js";import"../chunk-NF2BIEAF.js";import"../chunk-3QXRLIGC.js";import"../chunk-HFGO5762.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-GP46IPK2.js";import"../chunk-DS4P5C4F.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{c as ALL_STEP_IDS,a as CORE_STEP_IDS,b as OPTIONAL_STEP_IDS,g as STEPS,j as computeStatus,d as defaultContext,h as getStep,i as isStepId,e as maskToken,f as renderDiff};
1
+ import{a,b,c,d,e,f,g,h,i,j}from"../chunk-SZUH54L4.js";import"../chunk-QWCEZEDO.js";import"../chunk-KKDHD4XA.js";import"../chunk-SZ62CP55.js";import"../chunk-NF2BIEAF.js";import"../chunk-3QXRLIGC.js";import"../chunk-HFGO5762.js";import"../chunk-QBNLZJIR.js";import"../chunk-N7ODX6PO.js";import"../chunk-PJ3WHQ67.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{c as ALL_STEP_IDS,a as CORE_STEP_IDS,b as OPTIONAL_STEP_IDS,g as STEPS,j as computeStatus,d as defaultContext,h as getStep,i as isStepId,e as maskToken,f as renderDiff};
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-RDXWQDNZ.js";import"../chunk-GP46IPK2.js";import"../chunk-DS4P5C4F.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{d as emitErrorBeacon,c as emitSetupEvent,b as getDeviceId,a as telemetryDisabled};
1
+ import{a,b,c,d}from"../chunk-6PUH7HEL.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{d as emitErrorBeacon,c as emitSetupEvent,b as getDeviceId,a as telemetryDisabled};
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-BFDXMIXO.js";import"../chunk-N7ODX6PO.js";import"../chunk-GP46IPK2.js";import"../chunk-DS4P5C4F.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as probeAndReport,b as runOneHeartbeatCycle,c as startTerminalTargetHeartbeat};
1
+ import{a,b,c}from"../chunk-FNMJ6E6F.js";import"../chunk-N7ODX6PO.js";import"../chunk-2AVGUZ2P.js";import"../chunk-OOGTQOL3.js";import"../chunk-PZNWH4VQ.js";import"../chunk-ZLLER3HP.js";export{a as probeAndReport,b as runOneHeartbeatCycle,c as startTerminalTargetHeartbeat};
@@ -3593,9 +3593,9 @@
3593
3593
  "type": "option"
3594
3594
  },
3595
3595
  "claude-dir": {
3596
- "description": "Override the Claude Code projects directory",
3596
+ "description": "Override the Claude Code projects directory (defaults to ~/.claude)",
3597
3597
  "name": "claude-dir",
3598
- "default": "/home/runner/.claude",
3598
+ "noCacheDefault": true,
3599
3599
  "hasDynamicHelp": false,
3600
3600
  "multiple": false,
3601
3601
  "type": "option"
@@ -4787,5 +4787,5 @@
4787
4787
  ]
4788
4788
  }
4789
4789
  },
4790
- "version": "0.12.2"
4790
+ "version": "0.12.4"
4791
4791
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulemetric/cli",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -80,9 +80,9 @@
80
80
  "postgres": "^3.4.0",
81
81
  "react": "^19.0.0",
82
82
  "zod": "^3.24.0",
83
- "@rulemetric/proxy": "0.12.2",
84
- "@rulemetric/skills-registry": "0.12.2",
85
- "@rulemetric/hooks": "0.12.2"
83
+ "@rulemetric/hooks": "0.12.4",
84
+ "@rulemetric/proxy": "0.12.4",
85
+ "@rulemetric/skills-registry": "0.12.4"
86
86
  },
87
87
  "//deps": "Worker (`evals agent`) runtime deps: the @opentelemetry/* set, @sentry/node, and postgres are STATIC top-level imports loaded at worker startup (via bundled @rulemetric/{telemetry,db}) — they MUST be runtime deps or a clean `npm i -g` crashes with ModuleLoadError. `better-sqlite3` is optionalDependencies (below): it's a native module, lazy `require()`'d inside a try/catch (packages/session providers cursor/opencode) so a missing binary degrades gracefully — making it a hard dep would break `npm i -g` on platforms without prebuilt binaries. `resend` stays a devDep: lazy `await import('resend')` guarded by RESEND_API_KEY, which end-user workers never set (provider falls back to noop). Classification verified via import-graph scan of dist/commands/evals/agent.js + per-importer static/lazy check.",
88
88
  "optionalDependencies": {
@@ -108,8 +108,8 @@
108
108
  "@rulemetric/effectiveness": "0.0.1",
109
109
  "@rulemetric/email": "0.0.1",
110
110
  "@rulemetric/session": "0.2.1",
111
- "@rulemetric/telemetry": "0.0.1",
112
- "@rulemetric/typescript-config": "0.0.0"
111
+ "@rulemetric/typescript-config": "0.0.0",
112
+ "@rulemetric/telemetry": "0.0.1"
113
113
  },
114
114
  "scripts": {
115
115
  "build": "node scripts/build.mjs",
@@ -1 +0,0 @@
1
- import{a as I}from"./chunk-355GZ7LR.js";import{b as A,c as l,d as b}from"./chunk-QEKWPQDQ.js";import{f as k}from"./chunk-GP46IPK2.js";import{m as f,n as g,o as u,u as v,v as $,w as y}from"./chunk-DS4P5C4F.js";import{a as c}from"./chunk-ZLLER3HP.js";import{randomUUID as P}from"node:crypto";async function H(s){let{applyMode:e="human",...r}=s;await k("/api/recommendation-applications",{...r,harness:"claude_code",applyMode:e,status:"applied",applyBatchId:P(),applySeq:0})}c(H,"recordApplication");async function M(s,e){let r=c(t=>({action:"manual-required",instructionId:e.id,name:e.name,fileModified:!1,messages:t}),"refuse");if(s.actor!=="human")return r([`Not installed: ${e.name} is a hook, and a hook is a command this machine runs unattended.`,"Installing one is always a human decision \u2014 the same refusal the API makes server-side.",` Review it: rulemetric suggestions accept ${s.suggestionId}`]);let n=y(e);if(!n.spec)return r([`Not installed: ${e.name} does not contain an installable hook spec.`,...n.problems.map(t=>` ${t.field}: ${t.message}`)]);if(n.problems.length>0)return r([`Not installed: ${e.name}'s hook spec is not fit to act on.`,...n.problems.map(t=>` ${t.field}: ${t.message}`)]);let w=u(e.frontmatter),i=v(n.spec,w??void 0),p=f(i);if(p.length>0)return r([`Not installed: ${e.name}'s artifact spec is not fit to act on.`,...p.map(t=>` ${t.field}: ${t.message}`)]);let o=b(s.dir,i.requires);if(o.missing.length>0)return r([`Not installed: ${e.name} needs ${o.missing.join(", ")}, which is not present here.`,"It is left unapplied rather than installed and broken \u2014 a hook whose command is missing still runs, and fails, on every matching event.","Accept it again once the dependency exists."]);let a=A({dir:s.dir,instructionId:e.id,spec:n.spec});if(a.status==="refused")return r([`Not installed: ${e.name}.`,` ${a.reason}`]);let m=g(i,a.inverse);if(m.length>0)return l({dir:s.dir,inverse:a.inverse}),r([`Not installed: ${e.name} was written and then rolled back \u2014 the actuator could not produce a valid inverse.`,...m.map(t=>` ${t.field}: ${t.message}`)]);try{await H({instructionId:e.id,projectPath:s.projectPath,targetPath:a.target,beforeHash:a.beforeHash,appliedHash:a.inverse.hashAtWrite,boundaryClass:i.boundaryClass,targets:i.targets,inverse:a.inverse,requires:i.requires,provides:i.provides})}catch(t){let h=l({dir:s.dir,inverse:a.inverse});return r([`Not installed: ${e.name} \u2014 the effect could not be recorded, so it was undone.`,` ${t instanceof Error?t.message:String(t)}`,h.removed?" The hook was removed; your settings are as they were.":` WARNING: the rollback did not complete (${h.reason??"unknown reason"}). Check ${a.target} for the entry tagged with ${e.id}.`])}await I(s.suggestionId,s.projectPath,e.id,s.actor);let d=a.status==="installed"?[`Accepted: installed a ${n.spec.event} hook into ${a.target}.`]:[`Already present: this hook is already installed in ${a.target}.`];for(let t of $(n.spec))d.push(` ${t}`);return o.unverifiable.length>0&&d.push(` unchecked: ${o.unverifiable.join(", ")} \u2014 this command cannot verify that namespace.`),d.push(`Undo with: rulemetric suggestions undo ${e.id}`),{action:a.status==="installed"?"added":"already-present",instructionId:e.id,name:e.name,fileModified:a.status==="installed",messages:d}}c(M,"acceptHook");export{H as a,M as b};
@@ -1,48 +0,0 @@
1
- import{a as s}from"./chunk-ZLLER3HP.js";function X(e){return(e.trim().split(`
2
- `)[0]?.replace(/^#+\s*/,"").trim()||"Suggested instruction").slice(0,120)}s(X,"recommendationTitle");function J(e){if(!e||typeof e!="object")return e;let t=e;if(Array.isArray(t.recommendation_candidates))return e;let n=t.suggestions;if(!n||typeof n!="object")return e;let o=n.claude_md_additions;return Array.isArray(o)&&(t.recommendation_candidates=o.flatMap(r=>{if(!r||typeof r!="object")return[];let i=r;if(typeof i.addition!="string"||i.addition.trim()==="")return[];let a=i.addition.trim();return[{title:X(a),artifact:"instruction",canonicalBody:a,rationale:typeof i.why=="string"?i.why:"",evidence:[],outcomeMetric:"session_outcome",renderings:[{harness:"claude_code",target:"CLAUDE.md",body:a},{harness:"codex",target:"AGENTS.md",body:a}]}]})),e}s(J,"normalizeRecommendationCandidates");function Z(e){if(!e||typeof e!="object")return e;let t=e,n=t.project_areas;if(n!==void 0&&!Array.isArray(n)){let o=n&&typeof n=="object"?n.areas:void 0;t.project_areas=Array.isArray(o)?o:void 0}return J(e),e}s(Z,"normalizeRecommendations");import{z as p}from"zod";var L=["org","team","project","personal"],R=p.object({name:p.string().min(1),description:p.string().min(1),type:p.literal("instruction").default("instruction"),scope:p.enum(L),version:p.string().min(1),tags:p.array(p.string()).optional(),compatibility:p.array(p.string()).optional(),slots:p.record(p.string(),p.string()).optional(),metadata:p.record(p.string(),p.unknown()).optional()});import{z as d}from"zod";var N=d.object({name:d.string().min(1),description:d.string().min(1),type:d.literal("prompt"),version:d.string().min(1),tags:d.array(d.string()).optional(),variables:d.array(d.string()).optional(),metadata:d.record(d.string(),d.unknown()).optional()});function v(e,t){let n=t.map(o=>`- ID: ${o.id}
3
- Name: ${o.name}
4
- Description: ${o.description}
5
- Tags: ${o.tags.join(", ")}
6
- Preview: ${o.contentPreview}`).join(`
7
-
8
- `);return`You are an expert at matching AI coding instructions to software projects.
9
-
10
- ## Project
11
- - Name: ${e.name}
12
- - Description: ${e.description??"No description"}
13
- - Languages: ${e.languages.join(", ")||"Unknown"}
14
- - Topics: ${e.topics.join(", ")||"None"}
15
- - Dependencies: ${e.dependencies.join(", ")||"None"}
16
-
17
- ## Available Instructions
18
-
19
- ${n}
20
-
21
- ## Task
22
-
23
- Analyze the project and recommend which instructions would be most useful. Consider:
24
- 1. Language and framework alignment
25
- 2. Project purpose and what standards/practices would help
26
- 3. Security, testing, and quality needs based on the project type
27
-
28
- Return your response as JSON in this exact format:
29
- {
30
- "recommendations": [
31
- { "instructionId": "<id>", "score": <0.0-1.0>, "reason": "<one sentence explanation>" }
32
- ]
33
- }
34
-
35
- Only include instructions with a relevance score >= 0.5. Order by score descending. Return valid JSON only, no markdown fences.`}s(v,"buildRecommendationPrompt");var P=32e3,Q={name:"x".repeat(64),description:"x".repeat(256),languages:["TypeScript","Python","Go"],topics:["x".repeat(32)],dependencies:["x".repeat(32)]};function D(e,t={}){if(e.length===0)return[];let n=t.charBudget??P,o=v(Q,[]).length,r=[],i=[],a=0;for(let c of e){let l=ee(c);i.length>0&&o+a+l>n&&(r.push(i),i=[],a=0),i.push(c),a+=l}return i.length>0&&r.push(i),r}s(D,"batchCandidatesForPrompt");function ee(e){return`- ID: ${e.id}
36
- Name: ${e.name}
37
- Description: ${e.description}
38
- Tags: ${e.tags.join(", ")}
39
- Preview: ${e.contentPreview}`.length+2}s(ee,"renderedSize");var $=["Added","Changed","Fixed","Removed","Deprecated","Security"],te=/^##\s+\[([^\]]+)\](?:\s*[-–]\s*(\d{4}-\d{2}-\d{2}))?\s*$/,ne=/^###\s+(.+?)\s*$/,oe=/^[-*]\s+(.*\S)\s*$/,re=/^ {2,}(\S.*)$/;function se(e){let t=e.split(/\r?\n/),n=[],o=null,r=null,i=null;for(let a of t){let c=a.match(te);if(c){o&&n.push(o);let m=c[1].trim();o={version:m,date:c[2]??null,unreleased:m.toLowerCase()==="unreleased",sections:{}},r=null,i=null;continue}if(!o)continue;let l=a.match(ne);if(l){let m=l[1].trim();$.includes(m)?(r=m,o.sections[r]||(o.sections[r]=[]),i=o.sections[r]):(r=null,i=null);continue}if(!r||!i)continue;let u=a.match(oe);if(u){i.push(u[1]);continue}let f=a.match(re);if(f&&i.length>0){i[i.length-1]+=" "+f[1].trim();continue}}return o&&n.push(o),{entries:n}}s(se,"parseChangelog");function ie(e){return e.entries.filter(t=>t.unreleased?!1:Object.values(t.sections).some(n=>n&&n.length>0))}s(ie,"announceableEntries");function E(e){let t=/^(#{1,6})\s+/.exec(e);return t?t[1].length:0}s(E,"headingLevel");function j(e){return e.replace(/^#{1,6}\s+/,"").replace(/[`*_~]/g,"").trim().toLowerCase()}s(j,"normaliseHeading");function ae(e,t){let n=j(t);if(n.length===0)return{content:e,removed:!1,removedText:null,reason:"not-found"};let o=e.split(`
40
- `),r=[];for(let m=0;m<o.length;m+=1)E(o[m])>0&&j(o[m])===n&&r.push(m);if(r.length===0)return{content:e,removed:!1,removedText:null,reason:"not-found"};if(r.length>1)return{content:e,removed:!1,removedText:null,reason:"ambiguous"};let i=r[0],a=E(o[i]),c=o.length;for(let m=i+1;m<o.length;m+=1){let S=E(o[m]);if(S>0&&S<=a){c=m;break}}let l=o.slice(i,c).join(`
41
- `),u=[...o.slice(0,i),...o.slice(c)];return u.join("").trim().length===0?{content:e,removed:!1,removedText:null,reason:"would-empty-file"}:{content:u.join(`
42
- `).replace(/\n{3,}/g,`
43
-
44
- `),removed:!0,removedText:l}}s(ae,"removeMarkdownSection");function ce(e,t){let n=t.trim();if(n.length===0)return{content:e,removed:!1,removedText:null,reason:"not-found"};let o=e.indexOf(n);if(o===-1)return{content:e,removed:!1,removedText:null,reason:"not-found"};if(e.indexOf(n,o+1)!==-1)return{content:e,removed:!1,removedText:null,reason:"ambiguous"};let r=(e.slice(0,o)+e.slice(o+n.length)).replace(/\n{3,}/g,`
45
-
46
- `);return r.trim().length===0?{content:e,removed:!1,removedText:null,reason:"would-empty-file"}:{content:r,removed:!0,removedText:n}}s(ce,"removeExactBlock");var H=["HTTPS_PROXY","HTTP_PROXY","NODE_EXTRA_CA_CERTS"];function le(e,t){if(!e||typeof e!="object")return{value:e,removed:!1,removedDescriptions:[],reason:"not-found"};let n=structuredClone(e);if(!n.hooks)return{value:n,removed:!1,removedDescriptions:[],reason:"not-found"};let o=[];for(let[r,i]of Object.entries(n.hooks)){if(!Array.isArray(i))continue;let a=i.filter(c=>{let l=(c.hooks??[]).some(u=>typeof u.command=="string"&&u.command.includes(t));return l&&o.push(`${r}: ${c.matcher??"*"} \u2192 ${(c.hooks??[]).map(u=>u.command).join(", ")}`),!l});a.length===0?delete n.hooks[r]:n.hooks[r]=a}return Object.keys(n.hooks).length===0&&delete n.hooks,{value:n,removed:o.length>0,removedDescriptions:o,...o.length===0?{reason:"not-found"}:{}}}s(le,"removeHookByCommand");function ue(e,t){if(!e||typeof e!="object")return{value:e,removed:!1,removedDescriptions:[],reason:"not-found"};let n=structuredClone(e);return!n.mcpServers||!(t in n.mcpServers)?{value:n,removed:!1,removedDescriptions:[],reason:"not-found"}:(delete n.mcpServers[t],Object.keys(n.mcpServers).length===0&&delete n.mcpServers,{value:n,removed:!0,removedDescriptions:[`mcpServers.${t}`]})}s(ue,"removeMcpServer");function T(e){if(!e||typeof e!="object")return[];let t=e.env;return t?H.filter(n=>n in t):[]}s(T,"protectedEnvKeysPresent");function me(e,t){let n=T(e),o=new Set(T(t));return n.filter(r=>!o.has(r))}s(me,"lostProtectedEnvKeys");function pe(e,t){let n=`HTTP ${e}`;if(!t||typeof t!="object")return{message:n};let o=t,r=typeof o.error=="string"&&o.error?o.error:o.error?JSON.stringify(o.error):n,i=typeof o.code=="string"&&o.code?o.code:void 0;return i?{message:r,code:i}:{message:r}}s(pe,"parseApiError");var _=["inside","outside"];function y(e){return e.trim().toLowerCase()}s(y,"normalizeDependencyKey");function de(e){let t=[];if(_.includes(e.boundaryClass)||t.push({field:"boundaryClass",message:`must be one of ${_.join(" | ")}`}),!Array.isArray(e.targets)||e.targets.length===0)t.push({field:"targets",message:"a proposal that cannot name the paths it writes cannot be applied"});else{for(let r of e.targets)if(typeof r!="string"||r.trim().length===0){t.push({field:"targets",message:"target paths must be non-empty"});break}let n=e.targets.filter(r=>typeof r=="string"&&(r.startsWith("/")||/^[A-Za-z]:[\\/]/.test(r)));n.length>0&&t.push({field:"targets",message:`targets must be project-relative (absolute: ${n.join(", ")})`});let o=e.targets.filter(r=>typeof r=="string"&&r.split(/[\\/]/).includes(".."));o.length>0&&t.push({field:"targets",message:`targets must not traverse outside the project (${o.join(", ")})`})}for(let n of["requires","provides"]){let o=e[n];if(!Array.isArray(o)){t.push({field:n,message:"must be an array of dependency keys"});continue}o.some(r=>typeof r!="string"||r.trim().length===0)&&t.push({field:n,message:"dependency keys must be non-empty strings"})}return t}s(de,"validateArtifactSpec");function fe(e,t){let n=[],o=new Set(e.targets??[]);if(t.kind==="delete-paths"){e.boundaryClass!=="inside"&&n.push({field:"inverse",message:"deleting paths is only an inverse for `inside` artifacts; an `outside` path may hold text we did not write"}),t.paths.length===0&&n.push({field:"inverse.paths",message:"nothing to delete \u2014 this is not an inverse"});let r=t.paths.filter(i=>!o.has(i));return r.length>0&&n.push({field:"inverse.paths",message:`would delete paths the spec never declared: ${r.join(", ")}`}),n}return e.boundaryClass!=="outside"&&n.push({field:"inverse",message:"a compensation is only an inverse for `outside` artifacts; an `inside` path owes an exact undo"}),(!t.backupPath||t.backupPath.trim().length===0)&&n.push({field:"inverse.backupPath",message:"an `outside` write owes a backup"}),(!t.hashAtWrite||t.hashAtWrite.trim().length===0)&&n.push({field:"inverse.hashAtWrite",message:"without the post-write hash the undo cannot tell a drifted file from an untouched one"}),o.has(t.file)||n.push({field:"inverse.file",message:`wrote ${t.file}, which the spec did not declare as a target`}),t.kind==="remove-marked-region"?(!t.startMarker||!t.endMarker)&&n.push({field:"inverse",message:"an `outside` region needs both markers, or the undo cannot tell where our text ends"}):t.command.trim().length===0&&n.push({field:"inverse.command",message:"the exact command written is the identity of the entry; without it the undo is a search"}),n}s(fe,"validateArtifactInverse");var K="artifact";function b(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}s(b,"stringArray");function he(e){if(!e||typeof e!="object")return null;let t=e[K];if(!t||typeof t!="object")return null;let n=t;return{boundaryClass:n.boundaryClass,targets:b(n.targets),requires:b(n.requires),provides:b(n.provides)}}s(he,"parseArtifactSpec");var ge=["applied","measuring","improved","inconclusive","harmful","rollback_ready"];function M(e){return e.appliedAt?e.appliedAt instanceof Date?e.appliedAt.getTime():new Date(e.appliedAt).getTime():0}s(M,"appliedAtMs");function ye(e){return[...e].sort((t,n)=>{let o=M(n)-M(t);return o!==0?o:(n.applySeq??0)-(t.applySeq??0)})}s(ye,"orderForReversal");var B=["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PostToolUse","PreCompact","Notification","Stop","SubagentStop"],A=".claude/settings.local.json";function F(e){return`# rm-artifact:${e}`}s(F,"hookTag");function xe(e,t){return`${e.trim()} ${F(t)}`}s(xe,"taggedHookCommand");var ve=new Set(["if","then","else","elif","fi","for","while","until","do","done","case","esac","function","return","exit","cd","echo","test","true","false"]);function k(e){let t=e.trim().split(/\s+/)[0]??"";return!/^[a-z][a-z0-9_-]*$/.test(t)||ve.has(t)?null:y(`cmd:${t}`)}s(k,"inferredCommandRequirement");function Se(e,t){let n=new Set((t?.requires??[]).map(y).filter(Boolean)),o=k(e.command);return o&&n.add(o),{boundaryClass:"outside",targets:[A],requires:[...n],provides:(t?.provides??[]).map(y).filter(Boolean)}}s(Se,"hookArtifactSpec");function x(e){let t=[];B.includes(e.event)||t.push({field:"event",message:`unknown hook event ${JSON.stringify(e.event)} \u2014 a hook on an event that never fires is indistinguishable from one that was never installed`});let n=(e.command??"").trim();return n.length===0?t.push({field:"command",message:"a hook with no command installs nothing"}):(/[\r\n]/.test(n)&&t.push({field:"command",message:"multi-line commands are refused: the identity tag is a trailing shell comment, which would silence only the final line, and a human reviewing an install should read one line"}),n.includes("\0")&&t.push({field:"command",message:"command contains a NUL byte"}),n.includes("rulemetric")&&t.push({field:"command",message:'refused: `rulemetric hooks uninstall` deletes every hook whose command contains "rulemetric", so installing one here would make this hook collateral damage of an unrelated command'}),n.includes("rm-artifact:")&&t.push({field:"command",message:"command already carries an artifact tag \u2014 installing it would produce two identities for one entry"})),e.matcher!==void 0&&(typeof e.matcher!="string"||e.matcher.trim().length===0)&&t.push({field:"matcher",message:"matcher must be a non-empty string when present"}),t}s(x,"validateHookSpec");function Ee(e){let t=[`runs on: ${e.event}${e.matcher?` (tools matching ${e.matcher})`:""}`,`spawns: ${e.command.trim()}`,`writes: ${A} (one entry, tagged with this artifact's id)`],n=k(e.command);return n&&t.push(`needs: ${n} on PATH`),t}s(Ee,"describeHookCapability");var Y="hook";function h(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}s(h,"asRecord");function U(e){let t=e.event,n=e.command;if(typeof t!="string"||typeof n!="string")return null;let o=typeof e.matcher=="string"?e.matcher:void 0;return{event:t,matcher:o,command:n}}s(U,"readBareSpec");function z(e){let t=h(e.hooks)??e,n=[];for(let[o,r]of Object.entries(t))if(Array.isArray(r))for(let i of r){let a=h(i);if(!a)continue;let c=typeof a.matcher=="string"&&a.matcher.length>0?a.matcher:void 0,l=Array.isArray(a.hooks)?a.hooks:[];for(let u of l){let f=h(u)?.command;typeof f=="string"&&n.push({event:o,matcher:c,command:f})}}return n.length===0?{spec:null,problems:[]}:n.length>1?{spec:null,problems:[{field:"hook",message:`proposal describes ${n.length} hook entries; one proposal installs exactly one hook, so its inverse stays exact and its review stays readable`}]}:{spec:n[0],problems:[]}}s(z,"readSettingsFragment");function Te(e){let t=[],n=/```[a-zA-Z]*\n([\s\S]*?)```/g,o;for(;(o=n.exec(e))!==null;)t.push(o[1]);return t}s(Te,"fencedBlocks");function be(e){let t=h(h(e.frontmatter)?.artifact),n=t?h(t[Y]):null;if(n){let o=U(n);if(o)return{spec:o,problems:x(o),source:"envelope"};let r=z(n);if(r.spec)return{spec:r.spec,problems:x(r.spec),source:"envelope"};if(r.problems.length>0)return{spec:null,problems:r.problems,source:"envelope"}}for(let o of Te(e.content??"")){let r;try{r=JSON.parse(o)}catch{continue}let i=h(r);if(!i)continue;let a=U(i);if(a)return{spec:a,problems:x(a),source:"content-fragment"};let c=z(i);if(c.spec)return{spec:c.spec,problems:x(c.spec),source:"content-fragment"};if(c.problems.length>0)return{spec:null,problems:c.problems,source:"content-fragment"}}return{spec:null,problems:[{field:"hook",message:"no hook spec found \u2014 a hook proposal must carry {event, command} in its artifact envelope or a JSON settings fragment in its body"}],source:"none"}}s(be,"parseHookSpec");var _e=/[\p{L}\p{N}]+/gu;function C(e){let t=new Set;for(let n of e.toLowerCase().matchAll(_e)){let o=` ${n[0]} `;for(let r=0;r+3<=o.length;r+=1)t.add(o.slice(r,r+3))}return t}s(C,"trigrams");function g(e,t){let n=C(e),o=C(t);if(n.size===0||o.size===0)return 0;let r=0,[i,a]=n.size<=o.size?[n,o]:[o,n];for(let l of i)a.has(l)&&(r+=1);let c=n.size+o.size-r;return c===0?0:r/c}s(g,"trigramSimilarity");var O=.3,Ae=15;function w(e){let n=e.replace(/<!--[\s\S]*?-->/g," ").replace(/```[\s\S]*?```/g," "),o=[];for(let r of n.split(`
47
- `)){let i=r.trim();if(i.length===0||i.startsWith("#"))continue;let a=i.replace(/^(?:[-*+]|\d+[.)])\s+/,"").trim();if(a.length!==0)for(let c of a.split(/(?<=[.!?])\s+(?=[A-Z(`"'*])/)){let l=c.trim();l.length>=Ae&&o.push(l)}}return o}s(w,"splitDirectives");function W(e,t,n=O){let o=w(e);if(o.length===0)return{redundant:!1,coverage:0,matches:[],novel:[]};let r=t.flatMap(c=>w(c.content).map(l=>({text:l,id:c.id,source:c.source}))),i=[],a=[];for(let c of o){let l=null;for(let u of r){let f=g(c,u.text);f<n||(l===null||f>l.similarity)&&(l={directive:c,matchedDirective:u.text,matchedId:u.id,matchedSource:u.source,similarity:f})}l?i.push(l):a.push(c)}return{redundant:a.length===0,coverage:i.length/o.length,matches:i,novel:a}}s(W,"assessRedundancy");function ke(e,t=O){let n=[];for(let o=0;o<e.length;o+=1){let r=W(e[o].content,e.slice(0,o),t);r.matches.length>0&&n.push({instruction:e[o],verdict:r})}return n}s(ke,"findInternalRedundancy");var G=.5,Ce=/-(?=[0-9a-f]{6}$)[0-9a-f]*[0-9][0-9a-f]*$/;function I(e){return e.trim().toLowerCase().replace(/^skills--/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(Ce,"").replace(/-+$/,"")}s(I,"skillNameStem");function we(e,t,n=G){let o=I(e.name);for(let i of t)if(o.length>0&&I(i.name)===o)return{name:i.name,similarity:g(e.content,i.content),reason:"name-stem"};let r=null;for(let i of t){let a=g(e.content,i.content);a<n||(r===null||a>r.similarity)&&(r={name:i.name,similarity:a,reason:"body"})}return r}s(we,"assessSkillDuplication");var Oe=new Set(["sh","bash","zsh","fish"]),Ie=new Set(["mjs","cjs","js","ts","py","rb","pl"]),Le=/(?:^|[\s(`'"])(?:sudo\s+)?(?:node|npx|pnpm|npm|yarn|bun|deno|tsx|ts-node|vitest|jest|python3?|python|ruby|perl|bash|sh|zsh|exec|run|dlx)\s+(?:[-\w=@./]+\s+)*$/,Re=/(?:\.\/)?(?:[\w.@-]+\/)+[\w.@-]+\.\w+/g;function Ne(e){return e.replace(/```[\w-]*\n?/g," ").replace(/`/g," ")}s(Ne,"stripCodeMarkers");function Pe(e){let t=e.trim();return t=t.replace(/[.,;:)\]]+$/,""),t.startsWith("./")&&(t=t.slice(2)),t.length===0||t.startsWith("/")||t.startsWith("~")||t.startsWith("..")||/[<>{}*?]/.test(t)?null:t}s(Pe,"normalise");function q(e){let t=Ne(e),n=new Set,o=[];for(let r of t.matchAll(Re)){let i=r[0],a=r.index??0,c=t.slice(Math.max(0,a-1),a);if(c.length>0&&!/[\s(['"=]/.test(c))continue;let l=Pe(i);if(!l)continue;let u=l.slice(l.lastIndexOf(".")+1).toLowerCase();(Oe.has(u)||Ie.has(u)&&(i.startsWith("./")||Le.test(t.slice(t.lastIndexOf(`
48
- `,Math.max(0,a-1))+1,a))))&&(n.has(l)||(n.add(l),o.push({reference:i,path:l})))}return o}s(q,"extractCommandReferences");function De(e,t){return q(e).filter(n=>!t(n.path))}s(De,"findUnresolvableReferences");import It from"gray-matter";import{z as V}from"zod";var Pt=V.object({type:V.enum(["instruction","prompt"])});export{Z as a,v as b,D as c,se as d,ie as e,ae as f,ce as g,le as h,ue as i,me as j,pe as k,y as l,de as m,fe as n,he as o,ge as p,ye as q,A as r,F as s,xe as t,Se as u,Ee as v,be as w,w as x,W as y,ke as z,we as A,De as B};
@@ -1 +0,0 @@
1
- var e=[{name:"cron_check_changelog",description:"Parse CHANGELOG.md and create draft announcement rows for new versions.",scheduledBy:"manual only \u2014 announcement drafts are reminder-driven, never scheduled"},{name:"cron_suggest_instructions",description:"Precompute per-project instruction suggestions for the SessionStart hook.",scheduledBy:"Supabase pg_cron daily 04:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00083)"},{name:"cron_refresh_skills",description:"Refresh the skills registry from GitHub sources (disk JSON + public instructions sync). Requires GITHUB_TOKEN.",scheduledBy:"Supabase pg_cron daily 03:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00086)"}];export{e as a};
@@ -1,13 +0,0 @@
1
- import{a as I}from"./chunk-5RBLIVBF.js";import{a as j,d as O}from"./chunk-3UKZJAFS.js";import{c as H}from"./chunk-L6NQNVK2.js";import{a as T,b as P,c as L,d as A}from"./chunk-V6IYMQL6.js";import{a as U}from"./chunk-UK5JOTMW.js";import{c as J,d as x,f as S}from"./chunk-QBNLZJIR.js";import{e as _,f as F,h as d}from"./chunk-GP46IPK2.js";import{a as z}from"./chunk-DS4P5C4F.js";import{a as f}from"./chunk-ZLLER3HP.js";var W=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 os(l,a){let{mirrorId:n,projectPath:s,projectId:r,config:g}=l,t=f(e=>a.logger.info(e),"log");if(g?.sessionId)return q({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 F("/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(x()!=="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(V=>W(m.id,V));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 Z(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 Y(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 B=[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(L,B,8192);G&&(i.at_a_glance=G),t(" Uploading results..."),t(` Done! Recommendations generated for job ${n}`),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 U(i,s,t),N}f(os,"processInsights");async function q(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=>W(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 J(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(q,"processSessionAnalysisInline");async function Y(l,a,n=_,s=H){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(Y,"fetchGeneratorMemory");async function Z(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(Z,"buildDataSummaryFromApi");var M=class extends Error{static{f(this,"InsightsSummaryUnavailableError")}constructor(a){super(`Could not read session summary (retryable): ${a}`),this.name="InsightsSummaryUnavailableError"}};export{os as a,Y as b};
@@ -1 +0,0 @@
1
- import{c as K}from"./chunk-BFDXMIXO.js";import{b as G}from"./chunk-IEQDLURA.js";import{a as W}from"./chunk-EFLPMXJY.js";import{b as L}from"./chunk-NEP5EWHJ.js";import{a as D}from"./chunk-4XPH2EH4.js";import{a as V}from"./chunk-I2CXODLD.js";import{a as P}from"./chunk-ZYGBABMZ.js";import{a as x}from"./chunk-UK7BR6XM.js";import{a as y}from"./chunk-PZS55PW2.js";import{a as U}from"./chunk-3CX6YUEX.js";import{e as S}from"./chunk-YS5UJKK5.js";import{b as C}from"./chunk-ZHYCFUGJ.js";import{a as N}from"./chunk-FZ537XIW.js";import{a as T}from"./chunk-N2AIDOYF.js";import{a as M}from"./chunk-IFLFSHMN.js";import{b as R}from"./chunk-5RBLIVBF.js";import{a as $}from"./chunk-GAFMAVFO.js";import{a as O}from"./chunk-PHO4W7UH.js";import{a as F}from"./chunk-FPOPUEA6.js";import{a as J}from"./chunk-FI3YELW3.js";import{a as B}from"./chunk-2G4LYY6O.js";import{l as H}from"./chunk-FLSDLFUE.js";import{d as A}from"./chunk-NF2BIEAF.js";import{b as E,e as I,f as _}from"./chunk-GP46IPK2.js";import{a}from"./chunk-ZLLER3HP.js";var Z={process_eval:T,process_insights:M,process_launch:L,process_send_message:P,process_conversation:N,process_session_goal:x,distill_memories:C,memory_ab:D,process_run_cleanup:V,cron_refine_cases:J,cron_retire_unused_skills:U,cron_suggest_instructions:S,cron_refresh_skills:y,cron_refresh_pricing:B,cron_eval_autorun:O,cron_auto_accept_suggestions:$,cron_instruction_training:F,cron_instruction_evolution:H,process_judge_review:W},q=Object.keys(Z),ee=new Set([]);function ne(e=process.env){return e.DATABASE_URL?q:q.filter(n=>!ee.has(n))}a(ne,"availableCapabilities");var re=3e4,te=3e4,oe=3e4,Q=500,X=1e4,se=`thin-agent-${process.pid}`,b=null;function ae(e,n,r,c){let i;try{let u=A();i={claude:u.claudeBin!=null,codex:u.codexBin!=null,codexModel:u.codexConfiguredModel}}catch{}let m=a(u=>{_("/api/workers/heartbeat",{workerType:"cli-worker",clientName:se,clientVersion:c,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:u,metadata:{capabilities:e,mode:"thin-agent",llmEngines:i}}).then(d=>{let l=d?.advisory;l&&l.message!==b?(b=l.message,s(r,{event:"worker_advisory",code:l.code,message:l.message})):l||(b=null)}).catch(d=>{s(r,{event:"presence_heartbeat_error",error:d instanceof Error?d.message:String(d)})})},"send");m("alive");let o=setInterval(()=>m("alive"),oe);n.addEventListener("abort",()=>{clearInterval(o),m("shutting_down")},{once:!0})}a(ae,"startPresenceHeartbeat");function s(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}a(s,"structuredLog");function Y(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let c=setTimeout(()=>{n.removeEventListener("abort",i),r(!0)},e),i=a(()=>{clearTimeout(c),n.removeEventListener("abort",i),r(!1)},"onAbort");n.addEventListener("abort",i,{once:!0})})}a(Y,"abortableSleep");async function ie(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,c=await I(`/api/work/next?${r}`);return c==null||typeof c=="string"?null:c}a(ie,"pollForWork");function le(e,n){return{logger:{info:a(r=>n(r),"info"),warn:a(r=>n(r),"warn"),error:a(r=>n(r),"error")},job:{attempts:e}}}a(le,"makeHelpers");async function ce(e,n,r){let c=Z[e.kind],i=Date.now();if(s(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!c){let o=`unknown kind: ${e.kind}`;s(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:o}),await _(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:o,terminal:!0}).catch(()=>{});return}let m=setInterval(()=>{s(r,{event:"heartbeat",jobId:e.id}),_(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(o=>{s(r,{event:"heartbeat_error",jobId:e.id,error:o instanceof Error?o.message:String(o)})})},n);try{let o=le(e.attempts,r),u=await c(e.payload,o)??{};clearInterval(m),s(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-i}),await _(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:u})}catch(o){clearInterval(m);let u=R(o),d=o instanceof Error?o.message:String(o);s(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-i,terminal:u,error:d}),await _(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:d,terminal:u}).catch(l=>{s(r,{event:"fail_post_error",jobId:e.id,error:l instanceof Error?l.message:String(l)})})}}a(ce,"runOne");var z=new Set(["process_eval","process_conversation","process_insights","process_session_goal","distill_memories","memory_ab","cron_suggest_instructions","cron_eval_autorun","cron_instruction_evolution","process_judge_review"]);async function Ce(e){let n=e.log??(()=>{}),r=e.pollWaitMs??re,c=e.heartbeatIntervalMs??te,i=e.capabilities??ne();s(n,{event:"agent_start",capabilities:i,pollWaitMs:r,heartbeatIntervalMs:c});try{let t=G();t.removed.length>0&&s(n,{event:"eval_worktrees_swept",removed:t.removed.length})}catch(t){s(n,{event:"eval_worktree_sweep_failed",error:t instanceof Error?t.message:String(t)})}ae(i,e.signal,n,e.version),K({signal:e.signal,log:n}).catch(t=>{s(n,{event:"tt_heartbeat_fatal",error:t instanceof Error?t.message:String(t)})});let m=5*6e4,o=0,u=a(()=>{if(!e.readInstalledVersion||!e.version)return!1;let t=Date.now();if(t-o<m)return!1;o=t;let f=e.readInstalledVersion();return!!(f&&f!==e.version)},"versionDrifted"),d=new AbortController,l=d.signal;e.signal.aborted?d.abort():e.signal.addEventListener("abort",()=>d.abort(),{once:!0});let v=a(async(t,f)=>{let g=Q;for(;!l.aborted;){if(u()){s(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),d.abort(),e.onVersionDrift?.();break}let h=null;try{h=await ie([...f],r)}catch(p){let j=p instanceof E?p.statusCode:void 0;if(s(n,{event:"poll_error",lane:t,status:j,error:p instanceof Error?p.message:String(p)}),!await Y(g,l))break;g=Math.min(g*2,X);continue}if(!h){if(s(n,{event:"poll_204",lane:t}),!await Y(g,l))break;g=Math.min(g*2,X);continue}g=Q,await ce(h,c,n)}},"runLane"),k=i.filter(t=>z.has(t)),w=i.filter(t=>!z.has(t));k.length>0&&w.length>0?(s(n,{event:"agent_lanes",heavy:k.length,fast:w.length}),await Promise.all([v("heavy",k),v("fast",w)])):await v("single",i),s(n,{event:"agent_stop"})}a(Ce,"runAgentLoop");export{Z as a,q as b,ne as c,ie as d,Ce as e};
@@ -1 +0,0 @@
1
- import{c as X}from"./chunk-HOQPVOMF.js";import{b as D}from"./chunk-GIRPEMTW.js";import{a as x}from"./chunk-MODXEGCU.js";import{d as J,f as B}from"./chunk-QBNLZJIR.js";import{e as w,f as R}from"./chunk-GP46IPK2.js";import{b as H,c as U}from"./chunk-DS4P5C4F.js";import{a as u}from"./chunk-ZLLER3HP.js";import{readFileSync as q,realpathSync as V}from"node:fs";import y from"node:path";import A from"node:os";function Q(s){let n=y.resolve(s);if(n===y.resolve(A.homedir()))return!1;let a=y.parse(n).root;if(n===a)return!1;try{let o=V(A.tmpdir());if(V(n)===o)return!1}catch{}return!0}u(Q,"isScorableProjectPath");var Z=5,ee=Number(process.env.RULEMETRIC_MAX_SUGGESTION_PROJECTS??10),te=48,ne=.5,O=400,oe=3,re=.6,se=1;function ae(s){let n=s.bloated??[],a=new Set([...s.harmful.map(o=>o.id),...s.candidates.map(o=>o.id)]);return n.filter(o=>!a.has(o.id)).slice(0,se).map(o=>({instructionId:o.id,estimatedTokens:o.estimatedTokens,topProjectId:o.topProjectId??null,score:.55,reason:`Costs ~${o.estimatedTokens} tokens every session and measures neutral across ${o.exposures} exposed session(s) \u2014 enough data to detect an effect, and none found. Consider shortening "${o.name}" rather than removing it.`+(o.containsSafetyLanguage?" CAUTION: it contains guardrail language (destructive-command or credential rules) \u2014 preserve those lines when shortening.":"")}))}u(ae,"buildTrimProposals");async function ie(s,n,a){let o=[],i=0;for(let d of s)try{await a("/api/instruction-experiments",{instructionId:d.instructionId,projectPath:n,source:"groom"}),i++}catch(g){let m=g instanceof Error?g.message:String(g);o.push({...d,reason:`${d.reason} (not measurable by withholding: ${m})`})}return{nominated:i,unmeasurable:o}}u(ie,"nominateRemovals");function ce(s){let n=[];for(let o of s.harmful){let i=o.verdict.delta;n.push({instructionId:o.id,score:Math.min(.95,.75+Math.abs(i)),topProjectId:o.topProjectId??null,reason:`Measured harmful: sessions using "${o.name}" scored ${(i*100).toFixed(1)}pp worse across ${o.exposures} exposed session(s). Observational \u2014 review before archiving.`})}let a=new Set(s.harmful.map(o=>o.id));for(let o of s.candidates)a.has(o.id)||n.push({instructionId:o.id,score:re,topProjectId:o.topProjectId??null,reason:`Unused: "${o.name}" is ${o.reason} (${o.totalExposures} lifetime exposure(s)) but still costs context budget every session.`});return n.slice(0,oe)}u(ce,"buildRemovalProposals");function le(){let s=y.join(A.homedir(),".config","rulemetric","skills-registry.json");try{let n=q(s,"utf-8"),a=JSON.parse(n),o=new Date(a.generatedAt).getTime();return Number.isNaN(o)?"unknown":Date.now()-o>te*60*60*1e3?"stale":"fresh"}catch{return"unknown"}}u(le,"observeSkillsRegistry");var Re=u(async(s,n)=>{let a=J(),o=a!=="none";o?n.logger.info(`Scoring backend: ${a}`):n.logger.warn("No LLM backend available (claude CLI missing and ANTHROPIC_API_KEY unset); skipping relevance scoring. Removal/trim proposals still run \u2014 they need no LLM.");let i;try{i=(await w("/api/sessions/project-paths?limit="+ee)).projectPaths}catch(e){n.logger.warn(`Failed to fetch project paths: ${e instanceof Error?e.message:String(e)}`);return}if(i.length===0){n.logger.info("No recent project paths; nothing to score");return}let d=new Map;try{let e=await w("/api/projects?limit=200");for(let t of e.projects??[])t.primaryCheckoutPath&&d.set(x(t.primaryCheckoutPath),t.id)}catch(e){n.logger.warn(`Failed to fetch projects for id resolution: ${e instanceof Error?e.message:String(e)}`)}let g=new Map;try{let e=await w(`/api/catalog?limit=200&contentPreview=${O}`);for(let t of e)g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.contentPreview??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch catalog: ${e instanceof Error?e.message:String(e)}`)}try{let e=await w("/api/instructions?limit=100");for(let t of e.instructions??[])g.has(t.id)||g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch personal instructions: ${e instanceof Error?e.message:String(e)}`)}let m=[],p=[];try{let e=await w("/api/insights/groom-candidates");if(!e.captureHealthy)n.logger.info(`Grooming paused: ${e.reason??"capture unhealthy"}`);else{m=ce(e),p=ae(e);let t=e.safetyGuarded+e.harmfulSafetyGuarded;n.logger.info(`Removal proposals: ${m.length} (${e.harmful.length} measured-harmful, ${e.candidates.length} never-used, ${t} withheld by the safety allowlist); trim proposals: ${p.length} (${(e.bloated??[]).length} measured-neutral and expensive, ${e.trimSafetyFlagged??0} flagged as containing guardrail language)`)}}catch(e){n.logger.warn(`Failed to fetch groom candidates: ${e instanceof Error?e.message:String(e)}`)}let b=[...g.values()];if(b.length===0&&m.length===0&&p.length===0){n.logger.info("No candidate instructions and nothing to retire; nothing to score");return}n.logger.info(`Scoring ${b.length} candidates across ${i.length} project(s)`);let M=0,l=null,I=new Set;for(let e of i)try{let t=x(e);if(!Q(t)){n.logger.info(`Skipping ${t}: not a project directory (home/root)`);continue}let f=D(t),k=o&&f.length>0;f.length===0&&n.logger.info(`${t}: insufficient language signals; removal/trim only`);let v=X(t),z={name:y.basename(t),description:v.description,languages:f,topics:v.topics,dependencies:v.dependencies},E=k?U(b):[];k&&n.logger.info(`Scoring ${b.length} candidates for ${t} in ${E.length} batch(es)`);let C=[],$=0;for(let r of E)try{let c=await B(H(z,r),"",4096);if(!c){$++;continue}let T=c.recommendations??[];for(let P of T)typeof P.instructionId=="string"&&typeof P.score=="number"&&typeof P.reason=="string"&&C.push({instructionId:P.instructionId,score:P.score,reason:P.reason})}catch(c){$++,n.logger.warn(`Batch failed for ${t}: ${c instanceof Error?c.message:String(c)}`)}$>0&&n.logger.warn(`${$}/${E.length} batch(es) failed for ${t} (backend ${a}); suggestions are partial`),k&&C.length===0&&n.logger.warn(`No usable LLM output for ${t} (backend ${a})`);let K=C.filter(r=>r.score>=ne).sort((r,c)=>c.score-r.score).slice(0,Z),_=d.get(t),W=l===null||l===t;l===null&&(l=t);let N=u(r=>r.topProjectId?r.topProjectId===_:W,"placeHere"),F=m.filter(N),{nominated:L,unmeasurable:G}=await ie(F,t,R);L>0&&n.logger.info(`${t}: ${L} removal candidate(s) nominated for randomised withholding instead of the feed`);let h=[...K.map(r=>({instructionId:r.instructionId,score:r.score,reason:r.reason,kind:"add"})),...G.map(({topProjectId:r,...c})=>({...c,kind:"remove"})),...p.filter(N).map(({estimatedTokens:r,topProjectId:c,...T})=>({...T,kind:"trim"}))];if(h.length===0){n.logger.info(`Nothing to suggest for ${t}`);continue}await R("/api/instruction-suggestions/batch-upsert",{projectPath:t,..._?{projectId:_}:{},suggestions:h}),n.logger.info(`${t}: ${h.filter(r=>r.kind==="add").length} add + ${h.filter(r=>r.kind==="remove").length} remove + ${h.filter(r=>r.kind==="trim").length} trim`);for(let r of h)r.kind!=="add"&&I.add(r.instructionId);let Y=new Set(G.map(r=>r.instructionId));for(let r of F)Y.has(r.instructionId)||I.add(r.instructionId);M++}catch(t){n.logger.warn(`Failed to score ${e}: ${t instanceof Error?t.message:String(t)}`)}let j=[...m.filter(e=>!I.has(e.instructionId)),...p.filter(e=>!I.has(e.instructionId)).map(({estimatedTokens:e,...t})=>t)];if(j.length>0&&l)try{let e=new Set(p.map(t=>t.instructionId));await R("/api/instruction-suggestions/batch-upsert",{projectPath:l,...d.get(l)?{projectId:d.get(l)}:{},suggestions:j.map(({topProjectId:t,...f})=>({...f,kind:e.has(f.instructionId)?"trim":"remove"}))}),n.logger.info(`Orphan sweep: ${j.length} proposal(s) whose project was not scored this run placed on ${l}`)}catch(e){n.logger.warn(`Orphan sweep failed: ${e instanceof Error?e.message:String(e)}`)}let S=le();if(S==="unknown")n.logger.warn("Skills registry unreadable or has no usable generatedAt; leaving suggestion staleness unchanged");else try{await R("/api/instruction-suggestions/mark-stale",{stale:S==="stale"}),S==="stale"?n.logger.warn("Skills registry is stale (>48h); marked catalog-skill suggestions stale"):n.logger.info("Skills registry is fresh; cleared staleness on catalog-skill suggestions")}catch{}n.logger.info(`Done: scored ${M}/${i.length} projects`)},"cronSuggestInstructions");export{Q as a,ae as b,ie as c,ce as d,Re as e};