@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.
- package/dist/base-command.js +1 -1
- package/dist/{chunk-GP46IPK2.js → chunk-2AVGUZ2P.js} +1 -1
- package/dist/{chunk-ZHYCFUGJ.js → chunk-2IEYDOFE.js} +1 -1
- package/dist/chunk-2K3RUBKC.js +3 -0
- package/dist/{chunk-UK7BR6XM.js → chunk-2MZFB46B.js} +1 -1
- package/dist/{chunk-3RN3LDUC.js → chunk-3JSYVZOB.js} +1 -1
- package/dist/{chunk-PHO4W7UH.js → chunk-4XLMX642.js} +1 -1
- package/dist/{chunk-GAFMAVFO.js → chunk-5BTNALJL.js} +1 -1
- package/dist/{chunk-FI3YELW3.js → chunk-5C3DRKW3.js} +1 -1
- package/dist/{chunk-JKXU7FAY.js → chunk-65TQMBNF.js} +1 -1
- package/dist/{chunk-RDXWQDNZ.js → chunk-6PUH7HEL.js} +1 -1
- package/dist/{chunk-YE5ARPHO.js → chunk-7BLO7ECB.js} +1 -1
- package/dist/chunk-APXQLQZY.js +1 -0
- package/dist/{chunk-2G4LYY6O.js → chunk-CRPOQMQ2.js} +1 -1
- package/dist/{chunk-QEKWPQDQ.js → chunk-D4UDSY7Y.js} +1 -1
- package/dist/chunk-D55QB3QI.js +1 -0
- package/dist/{chunk-UK5JOTMW.js → chunk-E7N5R3HV.js} +1 -1
- package/dist/{chunk-FZ537XIW.js → chunk-FIPW2SGV.js} +1 -1
- package/dist/{chunk-BFDXMIXO.js → chunk-FNMJ6E6F.js} +1 -1
- package/dist/{chunk-I2CXODLD.js → chunk-J35L3LR3.js} +1 -1
- package/dist/{chunk-YYM2TW2D.js → chunk-K6T4ODPZ.js} +1 -1
- package/dist/{chunk-D3CZJ6CZ.js → chunk-KHCMVYTH.js} +1 -1
- package/dist/{chunk-4XPH2EH4.js → chunk-LDQ6FLET.js} +1 -1
- package/dist/{chunk-355GZ7LR.js → chunk-LVAROIKP.js} +1 -1
- package/dist/{chunk-4MXLDBLV.js → chunk-LW3UE2FY.js} +1 -1
- package/dist/{chunk-N2AIDOYF.js → chunk-LYP3LNFL.js} +1 -1
- package/dist/{chunk-ATSZBAG5.js → chunk-LZJXW3B6.js} +1 -1
- package/dist/{chunk-L6NQNVK2.js → chunk-MOY7XDR6.js} +1 -1
- package/dist/chunk-NMWP3JLW.js +1 -0
- package/dist/chunk-OCHAV6YZ.js +1 -0
- package/dist/{chunk-IZHJNPER.js → chunk-OEZNBFJ2.js} +1 -1
- package/dist/chunk-OOGTQOL3.js +48 -0
- package/dist/{chunk-EFLPMXJY.js → chunk-PMW35N32.js} +1 -1
- package/dist/{chunk-IS4JRZK2.js → chunk-PQMWZHEY.js} +1 -1
- package/dist/{chunk-KOQRNWIW.js → chunk-QLG6OCYF.js} +1 -1
- package/dist/chunk-QUOH6GWM.js +1 -0
- package/dist/{chunk-FPOPUEA6.js → chunk-RK2LZIBA.js} +1 -1
- package/dist/{chunk-6LYWI22A.js → chunk-SD626JBZ.js} +1 -1
- package/dist/{chunk-V6IYMQL6.js → chunk-SJKS3PYX.js} +8 -17
- package/dist/{chunk-ANSK2LTP.js → chunk-SVON2JIS.js} +1 -1
- package/dist/{chunk-EINQYO2T.js → chunk-SZUH54L4.js} +1 -1
- package/dist/{chunk-CJ4NG6FL.js → chunk-T67L2YTW.js} +1 -1
- package/dist/{chunk-NNOSORNV.js → chunk-TJYXSMQV.js} +1 -1
- package/dist/{chunk-FLSDLFUE.js → chunk-TZUTX4PG.js} +1 -1
- package/dist/{chunk-ZSOYH7FX.js → chunk-UQSUSB6G.js} +1 -1
- package/dist/{chunk-V3CAUY7M.js → chunk-VC3DJPUB.js} +1 -1
- package/dist/{chunk-E2QYH6EF.js → chunk-VIFE47RC.js} +1 -1
- package/dist/{chunk-HNAVHRGY.js → chunk-VTUTSUFW.js} +1 -1
- package/dist/{chunk-Y3T5Q5CD.js → chunk-WRQEHXSN.js} +1 -1
- package/dist/{chunk-4NAYH7VA.js → chunk-XUGWUFIQ.js} +1 -1
- package/dist/{chunk-76MON4SR.js → chunk-XZY2W3D3.js} +1 -1
- package/dist/chunk-Y6TAPCA5.js +13 -0
- package/dist/{chunk-3CX6YUEX.js → chunk-YRTG6SX6.js} +1 -1
- package/dist/{chunk-OJSWNU56.js → chunk-YTPQ7VBO.js} +1 -1
- package/dist/{chunk-NEP5EWHJ.js → chunk-ZQJWKIJS.js} +1 -1
- package/dist/commands/antigravity/backfill.js +1 -1
- package/dist/commands/auth/create-key.js +1 -1
- package/dist/commands/auth/login.js +1 -1
- package/dist/commands/auth/logout.js +1 -1
- package/dist/commands/auth/revoke-key.js +1 -1
- package/dist/commands/auth/signup.js +1 -1
- package/dist/commands/auth/status.js +1 -1
- package/dist/commands/capture/scope.js +1 -1
- package/dist/commands/catalog/index.js +1 -1
- package/dist/commands/catalog/recommend.js +1 -1
- package/dist/commands/crons/list.js +1 -1
- package/dist/commands/crons/run.js +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/diagnostics.js +1 -1
- package/dist/commands/eval-targets/create.js +1 -1
- package/dist/commands/eval-targets/list.js +1 -1
- package/dist/commands/evals/agent.js +1 -1
- package/dist/commands/evals/auto-run.js +1 -1
- package/dist/commands/evals/benchmark.js +1 -1
- package/dist/commands/evals/compare.js +1 -1
- package/dist/commands/evals/create.js +1 -1
- package/dist/commands/evals/optimize-description.js +1 -1
- package/dist/commands/evals/optimize.js +1 -1
- package/dist/commands/evals/refine-cases.js +1 -1
- package/dist/commands/evals/run.js +1 -1
- package/dist/commands/evals/validate-judge.js +1 -1
- package/dist/commands/experiments/list.js +1 -1
- package/dist/commands/gateway/ensure.js +1 -1
- package/dist/commands/hooks/install.js +1 -1
- package/dist/commands/hooks/run.js +1 -1
- package/dist/commands/hooks/uninstall.js +1 -1
- package/dist/commands/instructions/create.js +1 -1
- package/dist/commands/instructions/dedupe.js +1 -1
- package/dist/commands/instructions/delete.js +1 -1
- package/dist/commands/instructions/fork.js +1 -1
- package/dist/commands/instructions/get.js +1 -1
- package/dist/commands/instructions/list.js +1 -1
- package/dist/commands/instructions/promote.js +1 -1
- package/dist/commands/instructions/pull.js +1 -1
- package/dist/commands/instructions/restore.js +1 -1
- package/dist/commands/instructions/retract.js +1 -1
- package/dist/commands/instructions/upstream.js +1 -1
- package/dist/commands/instructions/versions.js +1 -1
- package/dist/commands/launcher.js +1 -1
- package/dist/commands/local/down.js +1 -1
- package/dist/commands/local/up.js +1 -1
- package/dist/commands/org/current.js +1 -1
- package/dist/commands/org/list.js +1 -1
- package/dist/commands/org/switch.js +1 -1
- package/dist/commands/packs/add-instruction.js +1 -1
- package/dist/commands/packs/apply.js +1 -1
- package/dist/commands/packs/create.js +1 -1
- package/dist/commands/packs/fork.js +1 -1
- package/dist/commands/packs/get.js +1 -1
- package/dist/commands/packs/list.js +1 -1
- package/dist/commands/packs/remove-instruction.js +1 -1
- package/dist/commands/proxy/env.js +1 -1
- package/dist/commands/proxy/logs.js +1 -1
- package/dist/commands/proxy/restart.js +1 -1
- package/dist/commands/proxy/setup.js +1 -1
- package/dist/commands/proxy/start.js +1 -1
- package/dist/commands/proxy/status.js +1 -1
- package/dist/commands/proxy/stop.js +1 -1
- package/dist/commands/research/backfill.js +1 -1
- package/dist/commands/research/tail-transcript.js +1 -1
- package/dist/commands/service/install.js +1 -1
- package/dist/commands/service/status.js +1 -1
- package/dist/commands/service/uninstall.js +1 -1
- package/dist/commands/sessions/analyze.js +1 -1
- package/dist/commands/sessions/delete.js +1 -1
- package/dist/commands/sessions/end.js +1 -1
- package/dist/commands/sessions/import.js +1 -1
- package/dist/commands/sessions/list.js +1 -1
- package/dist/commands/sessions/start.js +1 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/skills/export-approved.js +1 -1
- package/dist/commands/skills/install.js +2 -2
- package/dist/commands/skills/list.js +1 -1
- package/dist/commands/skills/publish.js +1 -1
- package/dist/commands/skills/search.js +2 -2
- package/dist/commands/skills/update.js +1 -1
- package/dist/commands/suggestions/accept.js +1 -1
- package/dist/commands/suggestions/auto.js +1 -1
- package/dist/commands/suggestions/dismiss.js +1 -1
- package/dist/commands/suggestions/list.js +1 -1
- package/dist/commands/suggestions/refresh.js +1 -1
- package/dist/commands/suggestions/undo.js +1 -1
- package/dist/dashboard/Dashboard.js +1 -1
- package/dist/dashboard/data.js +1 -1
- package/dist/dashboard/launcher/LauncherOverlay.js +1 -1
- package/dist/dashboard/launcher/api.js +1 -1
- package/dist/dashboard/launcher/useLaunchJobs.js +1 -1
- package/dist/lib/active-org-refresh.js +1 -1
- package/dist/lib/agent-loop.js +1 -1
- package/dist/lib/antigravity-transcript.js +1 -1
- package/dist/lib/api-client.js +1 -1
- package/dist/lib/attribution-recovery.js +1 -0
- package/dist/lib/ensure-api-key.js +1 -1
- package/dist/lib/ensure-fresh-token.js +1 -1
- package/dist/lib/eval-benchmark.js +1 -1
- package/dist/lib/eval-candidate-run.js +1 -1
- package/dist/lib/eval-conversation-handler.js +1 -1
- package/dist/lib/eval-resume.js +1 -1
- package/dist/lib/eval-run-batch.js +1 -1
- package/dist/lib/evolution-enrolment.js +1 -1
- package/dist/lib/insights/generation/installed-asks.js +1 -1
- package/dist/lib/insights/generation/prompts.js +1 -1
- package/dist/lib/insights/nomination/nominate.js +1 -1
- package/dist/lib/instructions/acceptance/accept-events.js +1 -1
- package/dist/lib/instructions/acceptance/accept-hook.js +1 -1
- package/dist/lib/instructions/acceptance/hook-install.js +1 -1
- package/dist/lib/instructions/acceptance/reverse-applications.js +1 -1
- package/dist/lib/instructions/acceptance/suggestion-accept.js +1 -1
- package/dist/lib/jobs/handlers/cron-auto-accept-suggestions.js +1 -1
- package/dist/lib/jobs/handlers/cron-eval-autorun.js +1 -1
- package/dist/lib/jobs/handlers/cron-instruction-evolution.js +1 -1
- package/dist/lib/jobs/handlers/cron-instruction-training.js +1 -1
- package/dist/lib/jobs/handlers/cron-reconcile-attribution.js +1 -0
- package/dist/lib/jobs/handlers/cron-refine-cases.js +1 -1
- package/dist/lib/jobs/handlers/cron-refresh-pricing.js +1 -1
- package/dist/lib/jobs/handlers/cron-retire-unused-skills.js +1 -1
- package/dist/lib/jobs/handlers/cron-suggest-instructions.js +1 -1
- package/dist/lib/jobs/handlers/distill-memories.js +1 -1
- package/dist/lib/jobs/handlers/process-changelog.js +1 -1
- package/dist/lib/jobs/handlers/process-conversation.js +1 -1
- package/dist/lib/jobs/handlers/process-eval.js +1 -1
- package/dist/lib/jobs/handlers/process-insights.js +1 -1
- package/dist/lib/jobs/handlers/process-judge-review.js +1 -1
- package/dist/lib/jobs/handlers/process-launch.js +1 -1
- package/dist/lib/jobs/handlers/process-memory-ab.js +1 -1
- package/dist/lib/jobs/handlers/process-run-cleanup.js +1 -1
- package/dist/lib/jobs/handlers/process-session-goal.js +1 -1
- package/dist/lib/judge-review-runner.js +1 -1
- package/dist/lib/manual-tasks-meta.js +1 -1
- package/dist/lib/manual-tasks.js +1 -1
- package/dist/lib/refine-cases.js +1 -1
- package/dist/lib/research-client.js +1 -1
- package/dist/lib/retraction.js +1 -1
- package/dist/lib/setup-steps.js +1 -1
- package/dist/lib/telemetry.js +1 -1
- package/dist/lib/terminal-target-heartbeat.js +1 -1
- package/oclif.manifest.json +3 -3
- package/package.json +6 -6
- package/dist/chunk-7HJJCRYK.js +0 -1
- package/dist/chunk-DS4P5C4F.js +0 -48
- package/dist/chunk-GY5IJ4RS.js +0 -1
- package/dist/chunk-IFLFSHMN.js +0 -13
- package/dist/chunk-J7E4BQYZ.js +0 -1
- package/dist/chunk-YS5UJKK5.js +0 -1
package/dist/base-command.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}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"./chunk-ZLLER3HP.js";export{a as BaseCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{l as E}from"./chunk-OOGTQOL3.js";import{a as p,e as w}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";import{fileURLToPath as v}from"node:url";import{existsSync as A,readFileSync as b}from"node:fs";import{dirname as L,join as x}from"node:path";function C(){let t=L(v(import.meta.url));for(let e=0;e<8;e++){let s=x(t,"package.json");if(A(s))try{let i=JSON.parse(b(s,"utf8"));if(i.name==="@rulemetric/cli"&&i.version)return i.version}catch{}let n=L(t);if(n===t)break;t=n}return"0.0.0"}o(C,"readCliVersion");var O=C(),I="https://rulemetric.com",l=class extends Error{constructor(s,n){super(n);this.statusCode=s;this.name="ApiError"}static{o(this,"ApiError")}};function S(){let t=p(),e=process.env.RULEMETRIC_API_URL??t.apiUrl;if(!e){if(process.env.RULEMETRIC_STRICT_LOCAL==="1"||t.strictLocal==="1")throw new Error("RULEMETRIC_STRICT_LOCAL is set but no RULEMETRIC_API_URL is configured \u2014 refusing the cloud default. Set RULEMETRIC_API_URL in the environment or ~/.config/rulemetric/env.");e=I}let s=new URL(e);if(s.protocol==="http:"&&s.hostname!=="localhost"&&s.hostname!=="127.0.0.1")throw new Error(`API URL must use HTTPS for non-localhost hosts: ${e}`);return e}o(S,"getBaseUrl");async function a(t,e={}){let n=`${S()}${t}`,i={"Content-Type":"application/json","User-Agent":`rulemetric-cli/${O}`,...e.headers},m=p(),d=process.env.RULEMETRIC_API_KEY||m.apiKey||w()?.accessToken||m.accessToken;d&&(i.Authorization=`Bearer ${d}`);let h=new URL(n),f=h.hostname==="localhost"||h.hostname==="127.0.0.1",P=process.env.HTTPS_PROXY,R=process.env.HTTP_PROXY;f&&(delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY);let u=e.timeoutMs?new AbortController:void 0,g=!1,y=u?setTimeout(()=>{g=!0,u.abort()},e.timeoutMs):void 0,r;try{r=await fetch(n,{method:e.method??"GET",headers:i,body:e.body?JSON.stringify(e.body):void 0,signal:u?.signal})}catch(T){if(g){let U=new URL(n).host,_=Math.round(e.timeoutMs/1e3);throw new l(408,`Request to ${U} timed out after ${_}s. This is usually transient or a local proxy/gateway issue \u2014 retry, and if it persists check HTTPS_PROXY / the RuleMetric gateway (:8787).`)}throw T}finally{y&&clearTimeout(y),f&&(P!==void 0&&(process.env.HTTPS_PROXY=P),R!==void 0&&(process.env.HTTP_PROXY=R))}let c;if(r.headers.get("content-type")?.includes("application/json")?c=await r.json():c=await r.text(),!r.ok){let{message:T}=E(r.status,c);throw new l(r.status,T)}return c}o(a,"api");var j=o(t=>a(t),"apiGet"),F=o((t,e)=>a(t,{method:"POST",body:e}),"apiPost"),B=o((t,e)=>a(t,{method:"PUT",body:e}),"apiPut"),D=o((t,e)=>a(t,{method:"PATCH",body:e}),"apiPatch"),G=o(t=>a(t,{method:"DELETE"}),"apiDelete");export{I as a,l as b,S as c,a as d,j as e,F as f,B as g,D as h,G as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as E}from"./chunk-QBNLZJIR.js";import{b,e as y,f as k,h as M}from"./chunk-
|
|
1
|
+
import{f as E}from"./chunk-QBNLZJIR.js";import{b,e as y,f as k,h as M}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";var v=50,I=24e3,P=3,R=3,C=40,N=4e3,x=new Set(["fact","decision","correction","convention"]),L=`You are distilling DURABLE, PROJECT-SPECIFIC knowledge from an AI coding session so a future agent working on the SAME project starts smarter.
|
|
2
2
|
|
|
3
3
|
Extract ONLY facts / decisions / corrections / conventions that will STILL be true and useful in FUTURE sessions \u2014 architecture facts, deliberate design decisions, corrections of a wrong approach, or project conventions.
|
|
4
4
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as f,c as h}from"./chunk-QUOH6GWM.js";import{e as g,f as d}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";import{execFileSync as y}from"node:child_process";import{openSync as R,readSync as v,closeSync as S}from"node:fs";function w(a){let t;try{t=R(a,"r");let i=Buffer.alloc(64*1024),o=v(t,i,0,i.length,0),r=i.subarray(0,o).toString("utf-8");for(let e of r.split(`
|
|
2
|
+
`))if(e.startsWith("{"))try{let s=JSON.parse(e).cwd;if(typeof s=="string"&&s.startsWith("/"))return s}catch{}return null}catch{return null}finally{t!==void 0&&S(t)}}u(w,"readTranscriptCwd");function A(a){let t=u(e=>{try{return y("git",["-C",a,...e],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()||null}catch{return null}},"git");if(!t(["rev-parse","--show-toplevel"]))return null;let o=t(["rev-parse","--git-dir"]),r=t(["rev-parse","--git-common-dir"]);return{gitRemote:t(["remote","get-url","origin"]),gitRootCommit:t(["rev-list","--max-parents=0","HEAD"])?.split(`
|
|
3
|
+
`).pop()?.trim()??null,gitBranch:t(["branch","--show-current"]),isWorktree:!!o&&!!r&&o!==r}}u(A,"gitAnchors");async function j(a,t,i=f(A,w)){let o=Math.min(a.limit??200,1e3),r=await g(`/api/sessions/unattributed?limit=${o}`),e=r.sessions??[],s=r.total??e.length;if(e.length===0)return t.logger.info("no unattributed sessions"),{scanned:0,repaired:0,unrepairable:0,remaining:0};let m=0,c=0;for(let l of e){if(!l.externalSessionId){c++;continue}let n=h(l,i);if(!n){c++;continue}try{await d("/api/sessions",{tool:l.tool,externalSessionId:l.externalSessionId,projectPath:n.projectPath,...n.gitBranch?{gitBranch:n.gitBranch}:{},metadata:{...n.gitRemote?{gitRemote:n.gitRemote}:{},...n.gitRootCommit?{gitRootCommit:n.gitRootCommit}:{},isWorktree:n.isWorktree,reconciledAttribution:!0}}),m++}catch(b){c++,t.logger.info(`reconcile failed for ${l.externalSessionId}: ${b.message}`)}}let p=s-m;return t.logger.info(`reconciled attribution: scanned=${e.length} repaired=${m} unrepairable=${c} remaining=${p} (of ${s} total)`),{scanned:e.length,repaired:m,unrepairable:c,remaining:p}}u(j,"cronReconcileAttribution");export{j as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f}from"./chunk-QBNLZJIR.js";import{b as S,e as a,h as y}from"./chunk-
|
|
1
|
+
import{f}from"./chunk-QBNLZJIR.js";import{b as S,e as a,h as y}from"./chunk-2AVGUZ2P.js";import{a as p}from"./chunk-ZLLER3HP.js";var _=1800*1e3,G=300*1e3,T=10,h=`Given these messages from an AI coding session, write a 1-2 sentence summary of what the user is trying to accomplish. Focus on the goal, not the steps. No preamble.
|
|
2
2
|
|
|
3
3
|
Return strict JSON in the form: {"goalSummary": "..."}`;async function k(n,e={}){let d=e.llm??f,o=e.now??Date.now,w=e.getSession??(async s=>{try{return await a(`/api/sessions/${s}`)}catch(t){if(t instanceof S&&t.statusCode===404)return null;throw t}}),m=e.getEvents??((s,t)=>a(`/api/sessions/${s}/events?limit=${t.limit}&sort=${t.sort}`)),v=e.saveGoal??(async(s,t)=>{await y(`/api/sessions/${s}/enrich`,{analysis:t})}),i=await w(n.sessionId);if(!i)return{skipped:"not_found"};let[P]=await m(n.sessionId,{limit:1,sort:"desc"}),A=new Date(P?.timestamp??i.startedAt).getTime();if(o()-A>_)return{skipped:"stale"};let l=i.analysis??{},c=l.goalSummaryAt?new Date(l.goalSummaryAt).getTime():0;if(c&&o()-c<G)return{skipped:"recent"};let g=(await m(n.sessionId,{limit:T*2,sort:"asc"})).filter(s=>s.content&&(s.eventType==="user_message"||s.eventType==="assistant_response")).map(s=>`${s.eventType==="user_message"?"USER":"ASSISTANT"}: ${s.content}`).join(`
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v}from"./chunk-
|
|
1
|
+
import{c as v}from"./chunk-D4UDSY7Y.js";import{e as h,f}from"./chunk-2AVGUZ2P.js";import{q as m,r as u}from"./chunk-OOGTQOL3.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as i from"node:fs";import*as d from"node:path";var g=new Set(m);async function $(t){let{applications:l}=await h(`/api/recommendation-applications?instructionId=${encodeURIComponent(t.instructionId)}&projectPath=${encodeURIComponent(t.projectPath)}&limit=200`),r=l.filter(e=>g.has(e.status)&&e.inverse),s=[];for(let e of u(r.map(n=>({...n,appliedAt:n.appliedAt})))){let n=e.inverse;if(n.kind==="delete-paths"){let p=y(t.dir,n.paths);s.push({applicationId:e.id,target:e.targetPath,reversed:p.removed,drifted:!1,reason:p.reason}),(p.removed||p.alreadyGone)&&await f(`/api/recommendation-applications/${encodeURIComponent(e.id)}/transition`,{status:"reverted"});continue}if(n.kind!=="remove-hook-entry"){s.push({applicationId:e.id,target:e.targetPath,reversed:!1,drifted:!1,reason:`no reverser for inverse kind '${n.kind}' \u2014 recorded, not reversed`});continue}let o=v({dir:t.dir,inverse:n});s.push({applicationId:e.id,target:e.targetPath,reversed:o.removed,drifted:o.drifted,reason:o.reason}),(o.removed||o.code==="not-present")&&await f(`/api/recommendation-applications/${encodeURIComponent(e.id)}/transition`,{status:"reverted"})}return s}c($,"reverseApplications");function y(t,l){let r=d.resolve(t),s=!1,e=0;for(let n of l){let o=d.resolve(r,n);if(o===r||!o.startsWith(r+d.sep))return{removed:!1,alreadyGone:!1,reason:`refused: ${n} does not resolve to a path inside the project`};if(!i.existsSync(o)&&!I(o)){e+=1;continue}try{i.rmSync(o,{recursive:!0,force:!0}),s=!0;let a=d.dirname(o);a.startsWith(r+d.sep)&&i.readdirSync(a).length===0&&i.rmdirSync(a)}catch(a){return{removed:!1,alreadyGone:!1,reason:`could not remove ${n}: ${a instanceof Error?a.message:String(a)}`}}}return!s&&e===l.length?{removed:!1,alreadyGone:!0,reason:"already removed"}:{removed:s,alreadyGone:!1}}c(y,"deletePaths");function I(t){try{return i.lstatSync(t).isSymbolicLink()}catch{return!1}}c(I,"isSymlink");function b(t){let l=t.name??t.instructionId,r=[],s=t.reversals.filter(e=>e.reversed);if(t.stripped)r.push(`Removed ${l} from CLAUDE.md.`);else if(s.length>0)for(let e of s)r.push(`Removed ${l} from ${e.target}.`),e.drifted&&r.push(" (that file had changed since it was installed; only the recorded entry was removed)");else r.push(`CLAUDE.md was not modified \u2014 no rulemetric-managed block for ${t.instructionId} was found in this directory.`);for(let e of t.reversals.filter(n=>!n.reversed))r.push(`Still installed in ${e.target}: ${e.reason??"the recorded inverse did not apply"}`);return t.dismissalError?(r.push(`Could not record the dismissal: ${t.dismissalError}`),r.push(s.length>0?' What was removed above stays removed \u2014 only the "stop proposing this" record failed.':" Nothing was removed, and the dismissal was not recorded either."),r.push(" This proposal may be suggested again. Re-run this command to retry."),r):(r.push("It will not be proposed again for 30 days."),r.push("Turn auto-adoption off entirely: rulemetric suggestions auto --off"),r)}c(b,"describeUndo");export{$ as a,y as b,b as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v}from"./chunk-RBSEE2Z6.js";import{a as R}from"./chunk-M7QSC64D.js";import{b}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-RBSEE2Z6.js";import{a as R}from"./chunk-M7QSC64D.js";import{b}from"./chunk-SVON2JIS.js";import{e as u}from"./chunk-2AVGUZ2P.js";import{a as d}from"./chunk-ZLLER3HP.js";var k=6e5;async function T(a,w){let i=d(e=>w?.logger?.info?.(e)??console.log(e),"log"),{evalTargetId:n}=a,l=await u(`/api/eval-targets/${n}/judge-calibration`),o=v({powered:l.powerCheck.powered,mde:l.powerCheck.mde??Number.POSITIVE_INFINITY},l.caseDiscrimination??{total:0,discriminating:0,nonDiscriminating:0,unpaired:0},{runsCompleted:0,maxRuns:a.maxRuns??24,batchesRun:0,maxBatches:1});if(o.action==="stop")return i(`[cron_eval_autorun] ${n}: ${o.reason}`),{skipped:o.code,reason:o.reason};let r=await u(`/api/eval-targets/${n}`),c=R(r);if(c)return i(`[cron_eval_autorun] ${n}: ${c.reason}`),c;let p=(await u(`/api/eval-targets/${n}/evals`)).filter(e=>!e.retiredAt);if(p.length===0)return{skipped:"no-live-cases"};let{completed:g,failed:f,results:$}=await b({cases:p,targetContent:r.content,concurrency:2,runNumber:1,opts:{targetId:n,targetVersion:r.version??1,iteration:1,timeout:a.timeout??k,model:a.model,graderModel:a.graderModel,skipGrading:!1,targetType:r.type,targetName:r.name},onLog:i}),m={};for(let e of $){if(e.status!=="failed")continue;let t=e.failure?.kind??"unknown";m[t]=(m[t]??0)+1}let s=Object.entries(m).sort(([,e],[,t])=>t-e).map(([e,t])=>`${e}x${t}`).join(", ");return i(`[cron_eval_autorun] ${r.name}: ${g} completed, ${f} failed`+(s===""?"":` (${s})`)),{ranRuns:g,failedRuns:f,...s===""?{}:{failures:s},reason:o.reason}}d(T,"cronEvalAutorun");export{T as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as $}from"./chunk-
|
|
1
|
+
import{d as $}from"./chunk-PQMWZHEY.js";import{e as b}from"./chunk-2AVGUZ2P.js";import{a as g}from"./chunk-ZLLER3HP.js";import{existsSync as k,statSync as A}from"node:fs";async function v(y,h){let s=g(n=>h?.logger?.info?.(n)??console.log(n),"log"),{projectPath:o}=y,r=`[cron_auto_accept_suggestions] ${o}`;if(!o)return{skipped:"no-project-path"};if(!k(o)||!A(o).isDirectory())return s(`${r}: project directory no longer exists on this machine \u2014 skipping`),{skipped:"project-path-missing"};let e=await b(`/api/instruction-suggestions/auto-acceptable?projectPath=${encodeURIComponent(o)}`);if(!e.consent.allowed)return s(`${r}: ${e.consent.reason??"no consent"} (${e.consent.source})`),{skipped:"no-consent",reason:e.consent.reason};for(let n of e.refused)s(`${r}: refused "${n.name}" \u2014 ${n.reason}`);if(e.eligible.length===0)return s(`${r}: nothing to adopt`+(e.budget?` (rules ${e.budget.used}/${e.budget.max}`+(e.budget.skillsUsed!==void 0?`, skills ${e.budget.skillsUsed}`+(e.budget.skillsMax==null?" (uncapped)":`/${e.budget.skillsMax}`):"")+` used in ${e.budget.windowDays}d)`:"")),{skipped:"nothing-eligible",refused:e.refused.length,adopted:0};let i=0,f=0,a=0,l=0,d=0,u=0,c=0,m=[];for(let n of e.eligible)try{let t=await $({suggestionId:n.id,dir:o,projectPath:o,actor:"auto"});if(t.action==="added")i+=1,m.push(t.name),n.type==="skill"&&(f+=1),s(`${r}: adopted ${n.type==="skill"?"skill":"rule"} "${t.name}" (score ${n.score.toFixed(2)})`);else if(t.action==="redundant"){t.partialOverlap?d+=1:l+=1;for(let p of t.messages)s(`${r}: ${p}`)}else if(t.action==="unresolvable-reference"){u+=1;for(let p of t.messages)s(`${r}: ${p}`)}else a+=1,s(`${r}: "${t.name}" was already in CLAUDE.md`)}catch(t){c+=1,s(`${r}: failed to adopt "${n.name}" \u2014 ${t instanceof Error?t.message:String(t)}`)}return s(`${r}: ${i} adopted, ${a} already present, ${l} already covered in other words, ${d} refused for partial overlap, ${u} refused for naming files this project does not have, ${c} failed, ${e.refused.length} refused upstream. Undo any of them with \`rulemetric suggestions undo <instruction-id>\`.`),{adopted:i,skills:f,alreadyPresent:a,redundant:l,partialOverlaps:d,unresolvableReferences:u,failed:c,refused:e.refused.length,names:m}}g(v,"cronAutoAcceptSuggestions");export{v as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as u,c as d}from"./chunk-
|
|
1
|
+
import{b as u,c as d}from"./chunk-LZJXW3B6.js";import{b as g}from"./chunk-KJRMGTAO.js";import{e as m,f as p,h as l}from"./chunk-2AVGUZ2P.js";import{a as s}from"./chunk-ZLLER3HP.js";async function x(f,R){let r=s(e=>R?.logger?.info?.(e)??console.log(e),"log"),{evalTargetId:n}=f,i=`[cron_refine_cases] ${n}`,t=await m(`/api/eval-targets/${n}`);if(!(t.metadata?.autoRefineCases===!0))return r(`${i} not opted in (metadata.autoRefineCases)`),{skipped:"not-opted-in",reason:`"${t.name}" has not opted into automatic case refinement. Set metadata.autoRefineCases=true to let the loop cull cases that carry no treatment signal, or run \`rulemetric evals refine-cases ${n}\` by hand.`,targetName:t.name};let C=await m(`/api/eval-targets/${n}/judge-calibration`),a=u(C.caseDiscrimination);if(a.refused)return r(`${i} ${a.refused}: ${a.summary}`),{skipped:a.refused,reason:a.summary,targetName:t.name};r(`${i} ${a.summary}`);let o=await d(a,{generate:s(e=>g({content:t.content,name:t.name,feedback:e}),"generate"),createCase:s(e=>p(`/api/eval-targets/${n}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations}),"createCase"),retireCase:s(async(e,y)=>{await l(`/api/eval-targets/${n}/evals/${e}`,{retire:!0,retiredReason:y})},"retireCase"),log:r});r(`${i} ${o.summary}`);let{skipped:c,...$}=o;return{...$,targetName:t.name,...c?{skipped:c,reason:o.summary}:{}}}s(x,"cronRefineCases");export{x as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as c,c as d}from"./chunk-IZTIYR5Q.js";import{d as u}from"./chunk-
|
|
1
|
+
import{a as c,c as d}from"./chunk-IZTIYR5Q.js";import{d as u}from"./chunk-6PUH7HEL.js";import{a}from"./chunk-WRQEHXSN.js";import{a as n}from"./chunk-YTPQ7VBO.js";import{b as i}from"./chunk-2AVGUZ2P.js";import{g as r}from"./chunk-PZNWH4VQ.js";import{a as s}from"./chunk-ZLLER3HP.js";import{Command as f,Flags as h}from"@oclif/core";function p(t){return t instanceof i?t.statusCode>=500||t.statusCode===408||t.statusCode===0:/fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|bad gateway|timed out/i.test(t.message??"")}s(p,"isAvailabilityError");var m=class extends f{static{s(this,"BaseCommand")}static baseFlags={"api-url":h.string({description:"Override API base URL",env:"RULEMETRIC_API_URL",hidden:!0})};async init(){await super.init();let{flags:e}=await this.parse(this.constructor);e["api-url"]&&(process.env.RULEMETRIC_API_URL=e["api-url"]);let o=d(this.config.version);o&&!this.argv.includes("--quiet")&&!process.env.RULEMETRIC_QUIET&&process.stderr.write(`
|
|
2
2
|
${o}
|
|
3
3
|
|
|
4
4
|
`),c();try{await a()}catch{}}requireAuth(){r()||this.error("Not logged in. Run `rulemetric auth login` to authenticate."),n()}async catch(e){throw p(e)&&await u({command:this.id,statusCode:e instanceof i?e.statusCode:void 0,message:e.message,cliVersion:this.config.version}),e instanceof i&&(e.statusCode===401&&this.error("Session expired. Run `rulemetric auth login` to re-authenticate."),this.error(e.message)),(e.message?.includes("fetch failed")||e.message?.includes("ECONNREFUSED"))&&this.error("Could not connect to the API server. Is it running?"),e}};export{m as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,d as m}from"./chunk-
|
|
1
|
+
import{a as d,d as m}from"./chunk-2AVGUZ2P.js";import{a as c,l as a}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";import{createHash as g,randomUUID as v}from"node:crypto";import{hostname as y,platform as p}from"node:os";import{existsSync as P,mkdirSync as _,readFileSync as h,writeFileSync as R}from"node:fs";import{join as E}from"node:path";var O="device-id";function u(){let e=o(t=>t==="1"||t==="true","off");return e(process.env.RULEMETRIC_NO_TELEMETRY)||e(process.env.DO_NOT_TRACK)}o(u,"telemetryDisabled");function l(){let e=a(),t=E(e,O);try{if(P(t)){let r=h(t,"utf-8").trim();if(r)return r}}catch{}let n=g("sha256").update(`${v()}:${y()}`).digest("hex").slice(0,32);try{_(e,{recursive:!0}),R(t,n,{mode:384})}catch{}return n}o(l,"getDeviceId");async function U(e,t={},n){if(!u())try{await m("/api/telemetry/cli-events",{method:"POST",body:{event:e,deviceId:l(),cliVersion:n,os:p(),props:t},timeoutMs:5e3})}catch{}}o(U,"emitSetupEvent");async function w(e){if(u())return;let n=`${process.env.RULEMETRIC_API_URL??c().apiUrl??d}/api/telemetry/cli-error`,r=process.env.HTTPS_PROXY,s=process.env.HTTP_PROXY,T=r!==void 0||s!==void 0;delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY;let i=new AbortController,f=setTimeout(()=>i.abort(),4e3);try{await globalThis.fetch(n,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`rulemetric-cli/${e.cliVersion??"unknown"}`},body:JSON.stringify({event:e.event??"onboarding_error",deviceId:l(),command:e.command,statusCode:e.statusCode,message:e.message?e.message.slice(0,500):void 0,cliVersion:e.cliVersion,os:p(),nodeVersion:process.version,proxied:T,props:e.props}),signal:i.signal})}catch{}finally{clearTimeout(f),r!==void 0&&(process.env.HTTPS_PROXY=r),s!==void 0&&(process.env.HTTP_PROXY=s)}}o(w,"emitErrorBeacon");export{u as a,l as b,U as c,w as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as E,m}from"./chunk-E7XOYGL5.js";import{a as d}from"./chunk-
|
|
1
|
+
import{c as E,m}from"./chunk-E7XOYGL5.js";import{a as d}from"./chunk-2AVGUZ2P.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as p from"node:fs";import*as u from"node:path";import*as _ from"node:os";function T(){if(process.env.RULEMETRIC_API_KEY||process.env.RULEMETRIC_ACCESS_TOKEN)return;let s=u.join(_.homedir(),".config","rulemetric","env");C(s)||C(u.join(process.cwd(),".env.local"))}c(T,"ensureEnv");function C(s){try{let t=p.readFileSync(s,"utf-8");for(let n of t.split(`
|
|
2
2
|
`)){let e=n.trim();if(!e||e.startsWith("#"))continue;let o=e.indexOf("=");if(o<0)continue;let r=e.slice(0,o).trim(),i=e.slice(o+1).trim();process.env[r]||(process.env[r]=i)}return!!(process.env.RULEMETRIC_API_KEY||process.env.RULEMETRIC_ACCESS_TOKEN)}catch{return!1}}c(C,"loadEnvFile");T();async function I(s){let t={totalSessions:0,totalCalls:0,totalInputTokens:0,totalOutputTokens:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,totalCostUSD:0,providers:{}},n=await m(s);t.providers={};for(let a of n)t.providers[a.provider]=(t.providers[a.provider]||0)+1;let e=new E,o=n.filter(a=>a.provider==="claude");for(let a of o)try{let h=p.readdirSync(a.path).filter(f=>f.endsWith(".jsonl"));t.totalSessions+=h.length;for(let f of h){let v=p.readFileSync(u.join(a.path,f),"utf-8"),R=e.parse(v);for(let l of R.events)l.tokenUsage&&(t.totalCalls++,t.totalInputTokens+=l.tokenUsage.input,t.totalOutputTokens+=l.tokenUsage.output,t.totalCacheReadTokens+=l.tokenUsage.cacheRead??0,t.totalCacheWriteTokens+=l.tokenUsage.cacheWrite??0)}}catch{}let r=15,i=75;return t.totalCostUSD=Math.round((t.totalInputTokens/1e6*r+t.totalOutputTokens/1e6*i+t.totalCacheReadTokens/1e6*(r*.1)+t.totalCacheWriteTokens/1e6*(r*1.25))*100)/100,t}c(I,"loadLocalStats");async function U(s){let t=process.env.RULEMETRIC_API_URL??d,n=process.env.RULEMETRIC_API_KEY,e=process.env.RULEMETRIC_ACCESS_TOKEN,o=n??e;if(!o)return null;let r=new URLSearchParams;s&&r.set("projectPath",s);try{let i=await fetch(`${t}/api/insights/compute?${r}`,{headers:{Authorization:`Bearer ${o}`},signal:AbortSignal.timeout(5e3)});return i.ok?await i.json():null}catch{return null}}c(U,"loadApiInsights");async function g(s){let t=process.env.RULEMETRIC_API_URL??d,n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)return null;let e=new URLSearchParams;s&&e.set("projectPath",s);try{let o=await fetch(`${t}/api/insights/linked-instructions?${e}`,{headers:{Authorization:`Bearer ${n}`},signal:AbortSignal.timeout(5e3)});return o.ok?await o.json():null}catch{return null}}c(g,"loadLinkedInstructions");export{I as a,U as b,g as c};
|
|
@@ -0,0 +1 @@
|
|
|
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_reconcile_attribution",description:"Re-attribute captured sessions that never resolved to a project (project_id NULL), using git anchors read from the checkouts on this machine.",scheduledBy:"Supabase pg_cron hourly :20 \u2192 agent_jobs \u2192 agent loop (migration 00206)"},{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,4 +1,4 @@
|
|
|
1
|
-
import{d as b,f as y}from"./chunk-QBNLZJIR.js";import{e as M,f as w}from"./chunk-
|
|
1
|
+
import{d as b,f as y}from"./chunk-QBNLZJIR.js";import{e as M,f as w}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";var $={anthropic:["https://platform.claude.com/docs/en/about-claude/pricing.md"],openai:["https://platform.openai.com/docs/pricing"]},R=.7,v=16e3,x=["You extract LLM API pricing from a provider pricing page.","You will be given the page text in <data> tags and, in this system prompt,","a list of model ids to find. For EACH requested model id, return its","published USD price per 1,000,000 tokens.","","Rules:","- Only report a model if you can find its rate ON THE PAGE. If it is not on"," the page, set found=false and omit the numbers \u2014 never guess from memory.","- inputPerM and outputPerM are the standard (non-batch, non-priority) rates.","- cacheReadPerM: the cached/discounted-input rate if published, else omit.","- For Anthropic models ONLY, if cache-write rates are not explicitly listed,"," compute them as cacheWrite5mPerM = inputPerM * 1.25 and"," cacheWrite1hPerM = inputPerM * 2.0. For all other providers, omit them.","- confidence is 0..1: how sure you are the numbers are correct for THIS id.","- contextWindow in tokens if stated, else omit.","","Respond with ONLY a JSON object of the form:",'{"rates":[{"modelId":"...","found":true,"confidence":0.9,"inputPerM":5,"outputPerM":25,"cacheReadPerM":0.5,"contextWindow":1000000}]}'].join(`
|
|
2
2
|
`);async function C(f){try{let n=await fetch(f,{headers:{accept:"text/plain, text/markdown, text/html"}});if(!n.ok)return null;let i=await n.text();return i.length>v?i.slice(0,v):i}catch{return null}}u(C,"fetchPage");var L=u(async(f,n)=>{let i=await M("/api/pricing/coverage"),I=[...i.unpriced,...i.stale],m=new Map;for(let r of I)m.set(`${r.provider}::${r.modelId}`,r);let a=[...m.values()];if(a.length===0)return n.logger.info("[cron-refresh-pricing] coverage clean \u2014 nothing unpriced or stale"),{status:"clean",checked:i.unpriced.length+i.stale.length};if(b()==="none")return n.logger.warn(`[cron-refresh-pricing] ${a.length} model(s) need pricing but no LLM backend (install the claude CLI or set ANTHROPIC_API_KEY) \u2014 skipping`),{status:"no-llm",pending:a.length};let d=new Map;for(let r of a){let o=d.get(r.provider)??[];o.push(r.modelId),d.set(r.provider,o)}let t={written:0,unchanged:0,flagged:0,rejected:0,skipped:0},c=[];for(let[r,o]of d){let h=$[r];if(!h){n.logger.warn(`[cron-refresh-pricing] no pricing source configured for provider '${r}' (${o.length} model(s)) \u2014 skipping`),t.skipped+=o.length;continue}let p="",l="";for(let e of h){let s=await C(e);s&&(p+=`
|
|
3
3
|
|
|
4
4
|
=== ${e} ===
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as k,k as b}from"./chunk-3QXRLIGC.js";import{
|
|
1
|
+
import{f as k,k as b}from"./chunk-3QXRLIGC.js";import{m as v,s as f,u as y}from"./chunk-OOGTQOL3.js";import{a as o}from"./chunk-ZLLER3HP.js";import{createHash as D}from"node:crypto";import{existsSync as d,readFileSync as H,writeFileSync as O,mkdirSync as I}from"node:fs";import{delimiter as R,dirname as j,join as m,resolve as w}from"node:path";function P(e){return b(m(e,".claude"),!1)}o(P,"adoptedHookSettingsPath");function B(e){return D("sha256").update(e).digest("hex")}o(B,"sha256");function h(e){return B(d(e)?H(e,"utf-8"):"")}o(h,"fileHash");function x(e){if(!d(e))return{settings:{}};let t=H(e,"utf-8");try{let n=JSON.parse(t);return!n||typeof n!="object"||Array.isArray(n)?{unreadable:!0}:{settings:n}}catch{return{unreadable:!0}}}o(x,"readSettings");function p(e,t){let n=e.hooks;if(!n||typeof n!="object")return[];let r=n[t];return Array.isArray(r)?r:[]}o(p,"hookBlocks");function A(e,t){return p(e,t).flatMap(n=>(n?.hooks??[]).map(r=>r?.command).filter(r=>typeof r=="string"))}o(A,"commandsFor");function W(e){let t=P(e.dir);if(!t.endsWith("settings.local.json"))return{status:"refused",reason:`refusing to write ${t}: adopted hooks are machine-local and only ever land in settings.local.json`};let n=x(t);if("unreadable"in n)return{status:"refused",reason:`${t} exists but is not readable as JSON. Nothing was written \u2014 installing would mean replacing a settings file this command could not read.`};let r=n.settings,s=y(e.spec.command,e.instructionId),a=h(t),l=o((g,S)=>({kind:"remove-hook-entry",file:f,event:e.spec.event,command:s,backupPath:S,hashAtWrite:g}),"inverseFor");if(A(r,e.spec.event).includes(s))return{status:"already-present",target:f,command:s,inverse:l(a,`${t}.bak`),beforeHash:a};let c={...e.spec.matcher?{matcher:e.spec.matcher}:{},hooks:[{type:"command",command:s}]},u=r.hooks&&typeof r.hooks=="object"?r.hooks:{};u[e.spec.event]=[...p(r,e.spec.event),c],r.hooks=u;let{backupPath:i}=k(t,r);return i||(i=`${t}.bak`,I(j(i),{recursive:!0}),O(i,`{}
|
|
2
2
|
`)),{status:"installed",target:f,command:s,inverse:l(h(t),i),beforeHash:a}}o(W,"installHook");function _(e){let t=w(e.dir,e.inverse.file);if(!d(t))return{removed:!1,drifted:!0,code:"file-missing",reason:`${e.inverse.file} no longer exists`};let n=x(t);if("unreadable"in n)return{removed:!1,drifted:!0,code:"unreadable",reason:`${e.inverse.file} is not readable as JSON; refusing to rewrite it`};let r=n.settings,s=h(t)!==e.inverse.hashAtWrite,a=A(r,e.inverse.event).filter(i=>i===e.inverse.command);if(a.length===0)return{removed:!1,drifted:s,code:"not-present",reason:"the recorded entry is no longer present \u2014 nothing to remove"};if(a.length>1)return{removed:!1,drifted:s,code:"ambiguous",reason:`${a.length} entries carry this exact command; refusing to guess which one this artifact installed`};let l=p(r,e.inverse.event).map(i=>({...i,hooks:(i?.hooks??[]).filter(g=>g?.command!==e.inverse.command)})).filter(i=>(i.hooks??[]).length>0),c=r.hooks;l.length===0?delete c[e.inverse.event]:c[e.inverse.event]=l,Object.keys(c).length===0&&delete r.hooks;let{backupPath:u}=k(t,r);return{removed:!0,drifted:s,backupPath:u}}o(_,"uninstallHook");function K(e){return(process.env.PATH??"").split(R).filter(Boolean).some(n=>d(m(n,e)))}o(K,"commandOnPath");function $(e,t){return d(m(e,".agents","skills",t))||d(m(e,".claude","skills",t))}o($,"skillInstalled");function z(e,t){let n={satisfied:[],missing:[],unverifiable:[]};for(let r of t){let s=v(r);if(!s)continue;let[a,...l]=s.split(":"),c=l.join(":").trim();if(!c){n.unverifiable.push(s);continue}a==="cmd"?(K(c)?n.satisfied:n.missing).push(s):a==="skill"?($(e,c)?n.satisfied:n.missing).push(s):a==="file"?(d(w(e,c))?n.satisfied:n.missing).push(s):n.unverifiable.push(s)}return n}o(z,"checkDependencies");export{P as a,W as b,_ as c,z as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as G}from"./chunk-FNMJ6E6F.js";import{b as q}from"./chunk-IEQDLURA.js";import{a as M}from"./chunk-LYP3LNFL.js";import{a as L}from"./chunk-Y6TAPCA5.js";import{a as B}from"./chunk-PMW35N32.js";import{b as N}from"./chunk-ZQJWKIJS.js";import{a as V}from"./chunk-LDQ6FLET.js";import{a as W}from"./chunk-J35L3LR3.js";import{a as x}from"./chunk-ZYGBABMZ.js";import{b as T}from"./chunk-5RBLIVBF.js";import{a as C}from"./chunk-2MZFB46B.js";import{a as U}from"./chunk-5C3DRKW3.js";import{a as O}from"./chunk-CRPOQMQ2.js";import{a as A}from"./chunk-PZS55PW2.js";import{a as K}from"./chunk-YRTG6SX6.js";import{e as S}from"./chunk-NMWP3JLW.js";import{b as D}from"./chunk-2IEYDOFE.js";import{a as P}from"./chunk-FIPW2SGV.js";import{a as F}from"./chunk-5BTNALJL.js";import{a as $}from"./chunk-4XLMX642.js";import{a as J}from"./chunk-RK2LZIBA.js";import{a as y}from"./chunk-2K3RUBKC.js";import{l as R}from"./chunk-TZUTX4PG.js";import{d as H}from"./chunk-NF2BIEAF.js";import{b as E,e as I,f as _}from"./chunk-2AVGUZ2P.js";import{a}from"./chunk-ZLLER3HP.js";var j={process_eval:M,process_insights:L,process_launch:N,process_send_message:x,process_conversation:P,process_session_goal:C,distill_memories:D,memory_ab:V,process_run_cleanup:W,cron_refine_cases:U,cron_retire_unused_skills:K,cron_reconcile_attribution:y,cron_suggest_instructions:S,cron_refresh_skills:A,cron_refresh_pricing:O,cron_eval_autorun:$,cron_auto_accept_suggestions:F,cron_instruction_training:J,cron_instruction_evolution:R,process_judge_review:B},Q=Object.keys(j),ne=new Set([]);function re(e=process.env){return e.DATABASE_URL?Q:Q.filter(n=>!ne.has(n))}a(re,"availableCapabilities");var te=3e4,oe=3e4,se=3e4,X=500,Y=1e4,ae=`thin-agent-${process.pid}`,b=null;function ie(e,n,r,c){let i;try{let u=H();i={claude:u.claudeBin!=null,codex:u.codexBin!=null,codexModel:u.codexConfiguredModel}}catch{}let m=a(u=>{_("/api/workers/heartbeat",{workerType:"cli-worker",clientName:ae,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"),se);n.addEventListener("abort",()=>{clearInterval(o),m("shutting_down")},{once:!0})}a(ie,"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 z(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(z,"abortableSleep");async function le(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(le,"pollForWork");function ce(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(ce,"makeHelpers");async function de(e,n,r){let c=j[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=ce(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=T(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(de,"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 Ve(e){let n=e.log??(()=>{}),r=e.pollWaitMs??te,c=e.heartbeatIntervalMs??oe,i=e.capabilities??re();s(n,{event:"agent_start",capabilities:i,pollWaitMs:r,heartbeatIntervalMs:c});try{let t=q();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)})}ie(i,e.signal,n,e.version),G({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=X;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 le([...f],r)}catch(p){let ee=p instanceof E?p.statusCode:void 0;if(s(n,{event:"poll_error",lane:t,status:ee,error:p instanceof Error?p.message:String(p)}),!await z(g,l))break;g=Math.min(g*2,Y);continue}if(!h){if(s(n,{event:"poll_204",lane:t}),!await z(g,l))break;g=Math.min(g*2,Y);continue}g=X,await de(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(Ve,"runAgentLoop");export{j as a,Q as b,re as c,le as d,Ve as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as u}from"./chunk-
|
|
1
|
+
import{f as u}from"./chunk-2AVGUZ2P.js";import{a as m}from"./chunk-ZLLER3HP.js";async function p(n,a,s){if(a)try{let t=Array.isArray(n.recommendation_candidates)?n.recommendation_candidates.filter(e=>typeof e.title=="string"&&typeof e.artifact=="string"&&typeof e.canonicalBody=="string"&&e.canonicalBody.trim().length>=12).map(e=>({title:String(e.title).trim(),artifact:String(e.artifact),canonicalBody:String(e.canonicalBody).trim(),rationale:String(e.rationale??""),evidence:Array.isArray(e.evidence)?e.evidence:[],outcomeMetric:String(e.outcomeMetric??"session_outcome"),renderings:Array.isArray(e.renderings)?e.renderings:[]})):[],i=n.suggestions,l=Array.isArray(i?.claude_md_additions)?i.claude_md_additions.filter(e=>typeof e?.addition=="string"&&e.addition.trim().length>=12).map(e=>({addition:String(e.addition).trim(),why:String(e.why??"")})):[],d=Array.isArray(n.recommended_skills)?n.recommended_skills.filter(e=>typeof e?.skillId=="string"&&e.skillId.length>0).map(e=>({skillId:String(e.skillId),reason:String(e.reason??"")})):[],g=Array.isArray(i?.features_to_try)?i.features_to_try.filter(e=>typeof e?.feature=="string"&&e.feature.trim().length>=2).map(e=>({feature:String(e.feature).trim(),one_liner:String(e.one_liner??""),why_for_you:String(e.why_for_you??""),example_code:String(e.example_code??"")})):[],c=[...Array.isArray(i?.usage_patterns)?i.usage_patterns.map(e=>({title:String(e.title??"").trim(),lead:String(e.suggestion??""),detail:String(e.detail??""),copyable_prompt:String(e.copyable_prompt??""),origin:"usage_pattern"})):[],...Array.isArray(n.on_the_horizon?.opportunities)?n.on_the_horizon.opportunities.map(e=>({title:String(e.title??"").trim(),lead:String(e.whats_possible??""),detail:String(e.how_to_try??""),copyable_prompt:String(e.copyable_prompt??""),origin:"opportunity"})):[]].filter(e=>e.title.length>=2);if(t.length===0&&l.length===0&&d.length===0&&g.length===0&&c.length===0)return;let r=await u("/api/insights/recommendations/nominate",{projectPath:a,candidates:t.slice(0,40),additions:l.slice(0,20),skills:d.slice(0,20),features:g.slice(0,20),advice:c.slice(0,40)}),o=r.additionsRejected??[];s(` ${r.nominated} recommendation(s) nominated into the suggestion feed (${r.additionsCreated} new instruction(s)`+((r.featuresCreated??0)>0?`, ${r.featuresCreated} feature proposal(s)`:"")+((r.adviceCreated??0)>0?`, ${r.adviceCreated} pattern/opportunity`:"")+(r.skillsUnresolved>0?`, ${r.skillsUnresolved} skill slug(s) unresolved`:"")+(o.length>0?`, ${o.length} rejected as unfilled templates`:"")+")");for(let e of o)s(` rejected "${e.name}" \u2014 unfilled placeholder(s): ${e.placeholders.join(", ")}`);for(let e of r.itemsFailed??[])s(` failed "${e.name}" \u2014 ${e.error}`)}catch(t){s(` nomination skipped (whole batch): ${t instanceof Error?t.message:String(t)}`)}}m(p,"nominateRecommendations");export{p as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-K6T4ODPZ.js";import{h as s}from"./chunk-2AVGUZ2P.js";import{a as n}from"./chunk-ZLLER3HP.js";async function l(a,c){let{mirrorId:g,evalTargetId:p,config:r}=a,e=n(o=>c.logger.info(o),"log");await i(r,p,e);let t={type:"conversation",conversationId:r.conversationId};return await s(`/api/eval-jobs/${g}/state`,{result:t}).catch(o=>{e(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),t}n(l,"processConversation");export{l as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as g,c as m}from"./chunk-N7ODX6PO.js";import{e as s,h as c}from"./chunk-
|
|
1
|
+
import{b as g,c as m}from"./chunk-N7ODX6PO.js";import{e as s,h as c}from"./chunk-2AVGUZ2P.js";import{a as i}from"./chunk-ZLLER3HP.js";var u=6e4;function o(t,e){try{t(JSON.stringify({ts:new Date().toISOString(),...e}))}catch{t(`[tt-heartbeat] log_error event=${e.event}`)}}i(o,"structuredLog");function d(t,e){return e.aborted?Promise.resolve(!1):t<=0?Promise.resolve(!0):new Promise(r=>{let a=setTimeout(()=>{e.removeEventListener("abort",n),r(!0)},t),n=i(()=>{clearTimeout(a),e.removeEventListener("abort",n),r(!1)},"onAbort");e.addEventListener("abort",n,{once:!0})})}i(d,"abortableSleep");async function l(t,e){if(t.kind!=="tmux")return;let a=(await g(m(t.target))).code===0?"active":"missing";try{await c(`/api/terminal-targets/${t.id}/status`,{status:a,lastSeenAt:new Date().toISOString()}),o(e,{event:"tt_heartbeat",targetId:t.id,target:t.target,status:a})}catch(n){o(e,{event:"tt_heartbeat_error",targetId:t.id,target:t.target,error:n instanceof Error?n.message:String(n)})}}i(l,"probeAndReport");async function b(t){let e;try{e=await s("/api/terminal-targets?status=active")}catch(r){o(t,{event:"tt_heartbeat_list_error",error:r instanceof Error?r.message:String(r)});return}for(let r of e.targets??[])try{await l(r,t)}catch(a){o(t,{event:"tt_heartbeat_probe_error",targetId:r.id,error:a instanceof Error?a.message:String(a)})}}i(b,"runOneHeartbeatCycle");async function p(t){let e=t.log??(()=>{}),r=t.intervalMs??u;for(o(e,{event:"tt_heartbeat_start",intervalMs:r});!t.signal.aborted&&(await b(e),!!await d(r,t.signal)););o(e,{event:"tt_heartbeat_stop"})}i(p,"startTerminalTargetHeartbeat");export{l as a,b,p as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as f}from"./chunk-RFISMWRW.js";import{a as l}from"./chunk-5RBLIVBF.js";import{b as g,e as k}from"./chunk-
|
|
1
|
+
import{c as f}from"./chunk-RFISMWRW.js";import{a as l}from"./chunk-5RBLIVBF.js";import{b as g,e as k}from"./chunk-2AVGUZ2P.js";import{a as m}from"./chunk-ZLLER3HP.js";async function C(w,i={}){let R=i.removeWorktreeFn??f,t=i.log??(e=>process.stderr.write(`[process_run_cleanup] ${e}
|
|
2
2
|
`)),j=i.getRunDetail??(async e=>{try{return await k(`/api/runs/${e}`)}catch(r){if(r instanceof g&&r.statusCode===404)return null;throw r}}),{runId:o}=w,n=await j(o);if(!n)throw new l(`Run ${o} not found`);if(!n.run.projectPath)throw new l(`Run ${o} has no projectPath; cannot resolve a repo root for worktree cleanup`);let a=n.run.projectPath,$=n.sessions.filter(e=>e.endedAt!=null),s=[],u=0,c=0,p=0,d=0,h=new Set;for(let e of $)if(!(!e.projectPath||e.projectPath===a)&&!h.has(e.projectPath)){h.add(e.projectPath);try{let r=await R({repoRoot:a,worktreePath:e.projectPath});r.removed?(u++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"removed"}),t(`removed worktree ${e.projectPath} (session ${e.id})`)):r.reason==="dirty"?(c++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"skipped-dirty"}),t(`skipped dirty worktree ${e.projectPath} (session ${e.id}) \u2014 uncommitted changes`)):(p++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"absent"}),t(`worktree absent ${e.projectPath} (session ${e.id})`))}catch(r){let P=r instanceof Error?r.message:String(r);d++,s.push({sessionId:e.id,worktreePath:e.projectPath,status:"error",error:P.slice(0,1e3)}),t(`error removing worktree ${e.projectPath} (session ${e.id}): ${P}`)}}return t(`run ${o} cleanup: removed=${u} skippedDirty=${c} absent=${p} errored=${d}`),{runId:o,repoRoot:a,removed:u,skippedDirty:c,absent:p,errored:d,worktrees:s}}m(C,"processRunCleanup");export{C as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as $}from"./chunk-KJRMGTAO.js";import{a as C}from"./chunk-AFYZYXQ3.js";import{a as y}from"./chunk-BJSVATVJ.js";import{d as f}from"./chunk-TZA4HAVF.js";import{e as h,f as w}from"./chunk-
|
|
1
|
+
import{b as $}from"./chunk-KJRMGTAO.js";import{a as C}from"./chunk-AFYZYXQ3.js";import{a as y}from"./chunk-BJSVATVJ.js";import{d as f}from"./chunk-TZA4HAVF.js";import{e as h,f as w}from"./chunk-2AVGUZ2P.js";import{a as v}from"./chunk-ZLLER3HP.js";async function N(n,i,p){let{conversationId:a,messageId:g,messageContent:r}=n,o=await h(`/api/eval-targets/${i}`),c=await h(`/api/eval-targets/${i}/evals`),e=await h(`/api/eval-conversations/${a}/messages`),t=e.findIndex(l=>l.id===g);if(t>=0&&e.slice(t+1).some(u=>u.role==="assistant"&&(u.type==="results"||u.type==="proposal"||u.type==="generated"||u.type==="text"))){p(`Message ${g} already processed \u2014 skipping (idempotency guard)`);return}let s=v(async(l,u,m)=>{await w(`/api/eval-conversations/${a}/messages/assistant`,{content:l,type:u,data:m})},"postMessage"),d=await _(o,c,e,r,p);p(`Action: ${d.action}`);try{switch(d.action){case"run_evals":await x(o,c,a,s,p);break;case"generate_cases":await k(o,i,a,s,p);break;case"analyze_results":case"propose_changes":await E(o,c,e,r,a,s,p);break;case"respond":await s(d.response,"text");break}}catch(l){let u=l instanceof Error?l.message:String(l);throw await s(`Something went wrong: ${u}`,"text").catch(()=>{}),l}}v(N,"processConversationJob");async function _(n,i,p,a,g){let r=p.slice(-10).map(e=>`${e.role}: ${e.content.slice(0,200)}`).join(`
|
|
2
2
|
`),o=`You are an eval assistant. Decide what action to take based on the user's message.
|
|
3
3
|
|
|
4
4
|
## Current State
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t,e as E}from"./chunk-
|
|
1
|
+
import{b as t,e as E}from"./chunk-TZUTX4PG.js";import{a as r}from"./chunk-ZLLER3HP.js";function s(o=10,_=t){for(let e=1;e<=o;e++)if(E(e,o,_).feasible)return e;return o}r(s,"minFeasibleLiveCases");var S=s(),A=3;export{s as a,S as b,A as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as h}from"./chunk-BJSVATVJ.js";import{b as E}from"./chunk-VBXL7XO7.js";import{d as P}from"./chunk-TZA4HAVF.js";import{b as d,e as p,h as w}from"./chunk-
|
|
1
|
+
import{a as h}from"./chunk-BJSVATVJ.js";import{b as E}from"./chunk-VBXL7XO7.js";import{d as P}from"./chunk-TZA4HAVF.js";import{b as d,e as p,h as w}from"./chunk-2AVGUZ2P.js";import{a as u}from"./chunk-ZLLER3HP.js";var b=u(n=>(n.summary.pass_rate??0)>=1?1:0,"fullPassScore");async function G(n,i={}){let c=i.executeEval??P,g=i.grade??h,v=i.getExperiment??(async r=>{try{return await p(`/api/memory-experiments/${r}`)}catch(t){if(t instanceof d&&t.statusCode===404)return null;throw t}}),M=i.getMemoryBody??(async r=>{try{return(await p(`/api/memories/${r}`)).body}catch(t){if(t instanceof d&&t.statusCode===404)return null;throw t}}),s=i.updateExperiment??(async(r,t)=>{await w(`/api/memory-experiments/${r}`,t)}),e=await v(n.experimentId);if(!e)return{skipped:"not_found"};if(e.status==="completed"||e.status==="failed")return{skipped:"already_terminal",status:e.status};let y=await M(e.memoryId);if(y==null)return await s(e.id,{status:"failed",error:"memory no longer exists"}),{skipped:"memory_gone",status:"failed"};await s(e.id,{status:"running"});let f=e.expectations??[],o=e.model??void 0,a=[],x=0;try{for(let t=0;t<e.trials;t++){let l=await c({prompt:e.taskPrompt,targetContent:y,model:o}),m=await c({prompt:e.taskPrompt,model:o});if(l.error||m.error){x++;continue}let[k,R]=await Promise.all([g({prompt:e.taskPrompt,output:l.output,expectations:f,model:o}),g({prompt:e.taskPrompt,output:m.output,expectations:f,model:o})]);a.push({withScore:b(k),withoutScore:b(R),withLatency:l.durationMs/1e3,withoutLatency:m.durationMs/1e3})}if(a.length===0){let t=`no trials completed (${x}/${e.trials} runs errored \u2014 is the claude CLI available?)`;return await s(e.id,{status:"failed",error:t}),{status:"failed",requestedTrials:e.trials,completedTrials:0}}let r=E(a);return await s(e.id,{status:"completed",result:{verdict:r,pairs:a,completedTrials:a.length,model:o??null}}),{status:"completed",requestedTrials:e.trials,completedTrials:a.length,significant:r.significant,delta:r.delta}}catch(r){let t=r instanceof Error?r.message:String(r);return await s(e.id,{status:"failed",error:t.slice(0,500)}).catch(()=>{}),{status:"failed",requestedTrials:e.trials,completedTrials:a.length}}}u(G,"processMemoryAb");export{G as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as r}from"./chunk-
|
|
1
|
+
import{f as r}from"./chunk-2AVGUZ2P.js";import{a as i}from"./chunk-ZLLER3HP.js";async function p(e,t,n,o){await r(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:"accepted",projectPath:t,instructionId:n,actor:o})}i(p,"logAccepted");async function a(e,t,n,o,s="redundant"){await r(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:s,projectPath:t,instructionId:n,actor:o})}i(a,"logRefused");export{p as a,a as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u}from"./chunk-
|
|
1
|
+
import{c as u}from"./chunk-6PUH7HEL.js";import{b as c,e as y,f as m}from"./chunk-2AVGUZ2P.js";import{a as n,b as t,i as s,k as p}from"./chunk-PZNWH4VQ.js";import{a}from"./chunk-ZLLER3HP.js";import{hostname as l}from"node:os";async function R(f,r,h){t();let o=process.env.RULEMETRIC_API_KEY,d=n().apiKey;if(o||d)try{await y("/api/profile");return}catch(e){if(!(e instanceof c)||e.statusCode!==401)return;if(o){r('Your exported RULEMETRIC_API_KEY was rejected (revoked?). Unset it or replace it with a fresh key (`rulemetric auth create-key --name "my-laptop"`).');return}p(),t(),r("Stored API key was rejected (revoked?) \u2014 replacing it with a fresh one.")}let i=`${l()} (auto)`;try{let e=await m("/api/auth/api-keys",{name:i});s(e.key,process.env.RULEMETRIC_API_URL),t(),f(`Created API key "${i}" for hooks + proxy auth (saved to your config).`),u("key_created",{},h)}catch(e){let k=e instanceof Error?e.message:String(e);r(`Could not auto-create an API key (${k}). Hooks/proxy will work via your session token for ABOUT AN HOUR \u2014 the token expires, and capture then stops until a key exists. Run \`rulemetric auth create-key --name "my-laptop"\` (or \`rulemetric auth login\` again) to fix this permanently.`)}}a(R,"ensureDeviceApiKey");export{R as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T}from"./chunk-5RBLIVBF.js";import{a as S}from"./chunk-XFAFMYIP.js";import{b as A}from"./chunk-KJRMGTAO.js";import{e as x}from"./chunk-GN3ZHQ46.js";import{a as C}from"./chunk-BJSVATVJ.js";import{d as M}from"./chunk-TZA4HAVF.js";import{e as k,f as E,h as p}from"./chunk-
|
|
1
|
+
import{a as T}from"./chunk-5RBLIVBF.js";import{a as S}from"./chunk-XFAFMYIP.js";import{b as A}from"./chunk-KJRMGTAO.js";import{e as x}from"./chunk-GN3ZHQ46.js";import{a as C}from"./chunk-BJSVATVJ.js";import{d as M}from"./chunk-TZA4HAVF.js";import{e as k,f as E,h as p}from"./chunk-2AVGUZ2P.js";import{a as w}from"./chunk-ZLLER3HP.js";async function W(v,f){let{mirrorId:i,evalTargetId:g,config:o}=v,a=w(e=>f.logger.info(e),"log"),s=await k(`/api/eval-targets/${g}`),$=await k(`/api/eval-targets/${g}/evals`);if($.length===0&&o.generateIfEmpty){a("No eval cases on target \u2014 generating from content via local LLM...");let e=await A({content:s.content,name:s.name});if(e===null)throw new Error("Case generation requires an LLM backend (claude CLI on PATH or ANTHROPIC_API_KEY) \u2014 none available on this worker.");let n=[];for(let t of e)n.push(await E(`/api/eval-targets/${g}/evals`,t));$=n,a(`Generated ${n.length} eval case(s)`)}if($.length===0)throw new T("No evals defined for target");let G=o.runsPerEval??1,R=o.timeout??12e4,j=o.iteration??1,y=new Set;if(f.job.attempts>1)for(let n=0;;n+=100){let t=await k(`/api/eval-targets/${g}/runs?jobId=${i}&limit=100&offset=${n}`);for(let r of t)y.add(`${r.evalId}|${r.configuration}|${r.runNumber}|${r.iteration}`);if(t.length<100)break}let _=[{name:"with_target",content:s.content}];o.skipBaseline||_.push({name:"without_target"});let d=[];for(let e of $)for(let n of _)for(let t=1;t<=G;t++)y.has(`${e.id}|${n.name}|${t}|${j}`)||d.push({eval_:e,configuration:n.name,targetContent:n.content,runNumber:t});y.size>0&&a(`Resuming attempt ${f.job.attempts}: ${y.size} run(s) already persisted, ${d.length} remaining`);let l=d.length,u=0,m=Math.min(o.parallel??1,4);await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:0,current:null,message:`Starting ${l} eval runs (concurrency: ${m})...`}});let b=[];async function I(e){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`;a(`[${u+1}/${l}] ${n}`);let t=x({targetType:s.type,targetContent:e.targetContent,targetName:s.name});t.leakedFiles.length&&a(`\u26A0 CONTAMINATED ${n}: ${t.leakedFiles.join(", ")} survived the strip`);try{let r=await M({prompt:e.eval_.prompt,targetContent:t.systemPrompt,workDir:t.workDir,timeout:R,model:o.model}),c={};return!o.skipGrading&&e.eval_.expectations.length>0&&!r.error&&(c=await C({prompt:e.eval_.prompt,output:r.output,expectations:e.eval_.expectations,model:o.graderModel??o.model,timeout:R})),{jobId:i,evalId:e.eval_.id,evalTargetId:s.id,evalTargetVersion:s.version,configuration:e.configuration,runNumber:e.runNumber,iteration:j,status:r.error?"failed":"completed",outputs:{...r.error?{error:r.error}:{transcript:r.output,...r.model?{model:r.model}:{}},methodology:t.methodology,delivery:t.delivery,isolated:t.isWorktree,...t.leakedFiles.length?{leakedFiles:t.leakedFiles}:{}},timing:{duration_ms:r.durationMs,total_tokens:r.totalTokens},grading:c,worktree:t.isWorktree?!0:void 0}}finally{t.cleanup()}}if(w(I,"processItem"),m<=1)for(let e of d){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Executing ${n}...`}});let t=await I(e);await E("/api/eval-runs",t),b.push(t),u++,await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Completed ${n}`}})}else{a(`Running ${l} evals with concurrency=${m} (worktree isolation)`);for(let e=0;e<d.length;e+=m){let n=d.slice(e,e+m),t=`batch ${Math.floor(e/m)+1}/${Math.ceil(d.length/m)}`;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:t,message:`Executing ${t} (${n.length} parallel)...`}});let r=await Promise.all(n.map(I));for(let c of r)await E("/api/eval-runs",c),b.push(c),u++;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:t,message:`Completed ${t}`}})}}let P=J(b),h;if(!o.skipGrading&&b.some(e=>e.grading&&Object.keys(e.grading).length>0))try{a(`Running meta-judge for job ${i}...`);let e=$.map(n=>{let r=b.filter(c=>c.evalId===n.id&&c.configuration==="with_target")[0];return{evalName:n.name,prompt:n.prompt,expectations:n.expectations,grading:r?.grading?r.grading:null,output:r?.outputs?.transcript?.slice(0,500)}});h=await S({targetName:s.name,evalResults:e,model:o.graderModel??o.model,timeout:6e4}),a(`Meta-judge: quality=${h.quality_score}/5, issues=${h.issues.length}`)}catch(e){a(`Meta-judge failed (non-fatal): ${e instanceof Error?e.message:String(e)}`)}let N=h?{...P,meta_judgement:h}:P;return a(`Job ${i} completed: ${u}/${l} runs`),await p(`/api/eval-jobs/${i}/state`,{result:N}).catch(e=>{a(`result persist failed: ${e instanceof Error?e.message:String(e)}`)}),N}w(W,"processEval");function J(v){let f=v.filter(a=>a.status==="completed"),i=v.filter(a=>a.status==="failed"),g=f.filter(a=>{let s=a.grading;return s&&Object.keys(s).length>0}),o=g.length>0?g.reduce((a,s)=>a+(s.grading?.summary?.pass_rate??0),0)/g.length:null;return{total:v.length,completed:f.length,failed:i.length,avgPassRate:o}}w(J,"buildSummary");export{W as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as m}from"./chunk-
|
|
1
|
+
import{b as m}from"./chunk-KHCMVYTH.js";import{a as g}from"./chunk-ZLLER3HP.js";var p=5;function b(t){let r=g((e,f)=>({retire:[],survivingCases:0,replacementsRequired:!1,refused:e,summary:f}),"none");if(!t||t.cases.length===0&&t.unpairedCases.length===0)return r("no-discrimination-data","No case-discrimination data yet \u2014 the target needs runs in BOTH cohorts before any case can be judged dead.");let c=[...t.cases.filter(e=>!e.discriminating).map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate,withoutPassRate:e.withoutPassRate,reason:e.note}})),...t.unpairedCases.map(e=>({evalId:e.evalId,name:e.name,feedback:{name:e.name,withPassRate:e.withPassRate??0,withoutPassRate:e.withoutPassRate,reason:"runs in only one cohort (no with-vs-without comparison possible)"}}))];if(c.length===0)return r("all-discriminating","Every case discriminates \u2014 nothing to retire.");let s=new Map(t.cases.map(e=>[e.evalId,e.separation])),o=[...c].sort((e,f)=>(s.get(e.evalId)??-1)-(s.get(f.evalId)??-1)).slice(0,p),u=c.length-o.length,d=t.total+t.unpaired,l=d-o.length,i=l<m,n=`${o.length} of ${d} live case(s) carry no treatment signal`+(u>0?` (${u} more over the ${p}-per-run cap)`:"")+(i?`; retiring them leaves ${l}, below the ${m}-case evolution floor, so replacements must be generated first`:"");return{retire:o,survivingCases:l,replacementsRequired:i,refused:null,summary:n}}g(b,"planCaseRefinement");async function v(t,r){let h=r.log??(()=>{}),c=g((n,e)=>({retired:0,generated:0,skipped:n,summary:e,retiredNames:[],generatedNames:[]}),"empty");if(t.refused)return c(t.refused,t.summary);let s=await r.generate(t.retire.map(n=>n.feedback)),a=[];for(let n of s??[]){let e=await r.createCase(n);a.push(e.name),h(` + ${e.name} (${e.id})`)}let o=t.survivingCases+t.retire.length+a.length,u=Math.max(0,o-m),d=t.retire.slice(0,Math.min(t.retire.length,u)),l=t.retire.length-d.length;if(d.length===0)return{retired:0,generated:a.length,skipped:s===null?"no-llm-backend":"no-replacements-generated",summary:`${t.summary}. `+(s===null?"No local LLM backend available, so nothing was retired":`The generator produced ${a.length} usable replacement(s), not enough to retire anything`)+` \u2014 dropping below the ${m}-case floor would silently disenrol the target from the nightly loop.`,retiredNames:[],generatedNames:a};let i=[];for(let n of d)await r.retireCase(n.evalId,n.feedback.reason),i.push(n.name),h(` retired ${n.name}`);return{retired:i.length,generated:a.length,skipped:null,summary:`Retired ${i.length} non-discriminating case(s), added ${a.length} replacement(s)`+(l>0?`; held ${l} back to stay at the ${m}-case floor (they remain condemned and will be retired once replacements exist)`:"")+". The replacements have no runs yet \u2014 the next autorun batch builds their depth.",retiredNames:i,generatedNames:a}}g(v,"executeCaseRefinement");export{p as a,b,v as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e as p}from"./chunk-LJRE3LZ2.js";import{
|
|
1
|
+
import{e as p}from"./chunk-LJRE3LZ2.js";import{y as f}from"./chunk-OOGTQOL3.js";import{a as r}from"./chunk-ZLLER3HP.js";var g=80,h=/\b(must|never|always|do not|don'?t|avoid|prefer|require[sd]?|before|after|only|instead of|use|run|add|keep|stop|refuse|check|verify|ask|write|read)\b/i,m=200,k=r(()=>({asks:[],omitted:0}),"empty");function A(s){return s.replace(/\s+/g," ").trim().toLowerCase()}r(A,"key");function I(s){let t=[];for(let o of s.split(`
|
|
2
2
|
`)){let e=o.trim(),n=t.length>0?t[t.length-1]:"",i=e===""||/^(?:[-*+]|\d+[.)]|#|```|>|\||!)/.test(e);if(n!==""&&!/[.!?:;]$/.test(n)&&!/^(?:#|```)/.test(n)&&!i){t[t.length-1]=`${n} ${e}`;continue}t.push(e)}return t.join(`
|
|
3
3
|
`)}r(I,"unwrap");function y(s,t=p){if(!s)return k();try{let o=new Set,e=[],n=[];for(let l of t(s))for(let d of f(I(l.content))){let c=A(d);if(c===""||o.has(c))continue;o.add(c);let a=d.replace(/\s+/g," ").trim(),u=a.length>m?`${a.slice(0,m)}\u2026`:a;(h.test(u)?e:n).push(u)}let i=[...e,...n];return{asks:i.slice(0,g),omitted:Math.max(0,i.length-g)}}catch{return k()}}r(y,"readInstalledAsks");export{g as a,m as b,y as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as X}from"./chunk-HOQPVOMF.js";import{b as D}from"./chunk-GIRPEMTW.js";import{a as x}from"./chunk-MODXEGCU.js";import{d as J,f as B}from"./chunk-QBNLZJIR.js";import{e as w,f as R}from"./chunk-2AVGUZ2P.js";import{c as H,d as U}from"./chunk-OOGTQOL3.js";import{a as u}from"./chunk-ZLLER3HP.js";import{readFileSync as q,realpathSync as V}from"node:fs";import y from"node:path";import A from"node:os";function Q(s){let n=y.resolve(s);if(n===y.resolve(A.homedir()))return!1;let a=y.parse(n).root;if(n===a)return!1;try{let o=V(A.tmpdir());if(V(n)===o)return!1}catch{}return!0}u(Q,"isScorableProjectPath");var Z=5,ee=Number(process.env.RULEMETRIC_MAX_SUGGESTION_PROJECTS??10),te=48,ne=.5,O=400,oe=3,re=.6,se=1;function ae(s){let n=s.bloated??[],a=new Set([...s.harmful.map(o=>o.id),...s.candidates.map(o=>o.id)]);return n.filter(o=>!a.has(o.id)).slice(0,se).map(o=>({instructionId:o.id,estimatedTokens:o.estimatedTokens,topProjectId:o.topProjectId??null,score:.55,reason:`Costs ~${o.estimatedTokens} tokens every session and measures neutral across ${o.exposures} exposed session(s) \u2014 enough data to detect an effect, and none found. Consider shortening "${o.name}" rather than removing it.`+(o.containsSafetyLanguage?" CAUTION: it contains guardrail language (destructive-command or credential rules) \u2014 preserve those lines when shortening.":"")}))}u(ae,"buildTrimProposals");async function ie(s,n,a){let o=[],i=0;for(let d of s)try{await a("/api/instruction-experiments",{instructionId:d.instructionId,projectPath:n,source:"groom"}),i++}catch(g){let m=g instanceof Error?g.message:String(g);o.push({...d,reason:`${d.reason} (not measurable by withholding: ${m})`})}return{nominated:i,unmeasurable:o}}u(ie,"nominateRemovals");function ce(s){let n=[];for(let o of s.harmful){let i=o.verdict.delta;n.push({instructionId:o.id,score:Math.min(.95,.75+Math.abs(i)),topProjectId:o.topProjectId??null,reason:`Measured harmful: sessions using "${o.name}" scored ${(i*100).toFixed(1)}pp worse across ${o.exposures} exposed session(s). Observational \u2014 review before archiving.`})}let a=new Set(s.harmful.map(o=>o.id));for(let o of s.candidates)a.has(o.id)||n.push({instructionId:o.id,score:re,topProjectId:o.topProjectId??null,reason:`Unused: "${o.name}" is ${o.reason} (${o.totalExposures} lifetime exposure(s)) but still costs context budget every session.`});return n.slice(0,oe)}u(ce,"buildRemovalProposals");function le(){let s=y.join(A.homedir(),".config","rulemetric","skills-registry.json");try{let n=q(s,"utf-8"),a=JSON.parse(n),o=new Date(a.generatedAt).getTime();return Number.isNaN(o)?"unknown":Date.now()-o>te*60*60*1e3?"stale":"fresh"}catch{return"unknown"}}u(le,"observeSkillsRegistry");var Re=u(async(s,n)=>{let a=J(),o=a!=="none";o?n.logger.info(`Scoring backend: ${a}`):n.logger.warn("No LLM backend available (claude CLI missing and ANTHROPIC_API_KEY unset); skipping relevance scoring. Removal/trim proposals still run \u2014 they need no LLM.");let i;try{i=(await w("/api/sessions/project-paths?limit="+ee)).projectPaths}catch(e){n.logger.warn(`Failed to fetch project paths: ${e instanceof Error?e.message:String(e)}`);return}if(i.length===0){n.logger.info("No recent project paths; nothing to score");return}let d=new Map;try{let e=await w("/api/projects?limit=200");for(let t of e.projects??[])t.primaryCheckoutPath&&d.set(x(t.primaryCheckoutPath),t.id)}catch(e){n.logger.warn(`Failed to fetch projects for id resolution: ${e instanceof Error?e.message:String(e)}`)}let g=new Map;try{let e=await w(`/api/catalog?limit=200&proposable=1&contentPreview=${O}`);for(let t of e)g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.contentPreview??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch catalog: ${e instanceof Error?e.message:String(e)}`)}try{let e=await w("/api/instructions?limit=100");for(let t of e.instructions??[])g.has(t.id)||g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch personal instructions: ${e instanceof Error?e.message:String(e)}`)}let m=[],p=[];try{let e=await w("/api/insights/groom-candidates");if(!e.captureHealthy)n.logger.info(`Grooming paused: ${e.reason??"capture unhealthy"}`);else{m=ce(e),p=ae(e);let t=e.safetyGuarded+e.harmfulSafetyGuarded;n.logger.info(`Removal proposals: ${m.length} (${e.harmful.length} measured-harmful, ${e.candidates.length} never-used, ${t} withheld by the safety allowlist); trim proposals: ${p.length} (${(e.bloated??[]).length} measured-neutral and expensive, ${e.trimSafetyFlagged??0} flagged as containing guardrail language)`)}}catch(e){n.logger.warn(`Failed to fetch groom candidates: ${e instanceof Error?e.message:String(e)}`)}let b=[...g.values()];if(b.length===0&&m.length===0&&p.length===0){n.logger.info("No candidate instructions and nothing to retire; nothing to score");return}n.logger.info(`Scoring ${b.length} candidates across ${i.length} project(s)`);let M=0,l=null,I=new Set;for(let e of i)try{let t=x(e);if(!Q(t)){n.logger.info(`Skipping ${t}: not a project directory (home/root)`);continue}let f=D(t),k=o&&f.length>0;f.length===0&&n.logger.info(`${t}: insufficient language signals; removal/trim only`);let v=X(t),z={name:y.basename(t),description:v.description,languages:f,topics:v.topics,dependencies:v.dependencies},E=k?U(b):[];k&&n.logger.info(`Scoring ${b.length} candidates for ${t} in ${E.length} batch(es)`);let C=[],$=0;for(let r of E)try{let c=await B(H(z,r),"",4096);if(!c){$++;continue}let T=c.recommendations??[];for(let P of T)typeof P.instructionId=="string"&&typeof P.score=="number"&&typeof P.reason=="string"&&C.push({instructionId:P.instructionId,score:P.score,reason:P.reason})}catch(c){$++,n.logger.warn(`Batch failed for ${t}: ${c instanceof Error?c.message:String(c)}`)}$>0&&n.logger.warn(`${$}/${E.length} batch(es) failed for ${t} (backend ${a}); suggestions are partial`),k&&C.length===0&&n.logger.warn(`No usable LLM output for ${t} (backend ${a})`);let K=C.filter(r=>r.score>=ne).sort((r,c)=>c.score-r.score).slice(0,Z),_=d.get(t),W=l===null||l===t;l===null&&(l=t);let N=u(r=>r.topProjectId?r.topProjectId===_:W,"placeHere"),F=m.filter(N),{nominated:L,unmeasurable:G}=await ie(F,t,R);L>0&&n.logger.info(`${t}: ${L} removal candidate(s) nominated for randomised withholding instead of the feed`);let h=[...K.map(r=>({instructionId:r.instructionId,score:r.score,reason:r.reason,kind:"add"})),...G.map(({topProjectId:r,...c})=>({...c,kind:"remove"})),...p.filter(N).map(({estimatedTokens:r,topProjectId:c,...T})=>({...T,kind:"trim"}))];if(h.length===0){n.logger.info(`Nothing to suggest for ${t}`);continue}await R("/api/instruction-suggestions/batch-upsert",{projectPath:t,..._?{projectId:_}:{},suggestions:h}),n.logger.info(`${t}: ${h.filter(r=>r.kind==="add").length} add + ${h.filter(r=>r.kind==="remove").length} remove + ${h.filter(r=>r.kind==="trim").length} trim`);for(let r of h)r.kind!=="add"&&I.add(r.instructionId);let Y=new Set(G.map(r=>r.instructionId));for(let r of F)Y.has(r.instructionId)||I.add(r.instructionId);M++}catch(t){n.logger.warn(`Failed to score ${e}: ${t instanceof Error?t.message:String(t)}`)}let j=[...m.filter(e=>!I.has(e.instructionId)),...p.filter(e=>!I.has(e.instructionId)).map(({estimatedTokens:e,...t})=>t)];if(j.length>0&&l)try{let e=new Set(p.map(t=>t.instructionId));await R("/api/instruction-suggestions/batch-upsert",{projectPath:l,...d.get(l)?{projectId:d.get(l)}:{},suggestions:j.map(({topProjectId:t,...f})=>({...f,kind:e.has(f.instructionId)?"trim":"remove"}))}),n.logger.info(`Orphan sweep: ${j.length} proposal(s) whose project was not scored this run placed on ${l}`)}catch(e){n.logger.warn(`Orphan sweep failed: ${e instanceof Error?e.message:String(e)}`)}let S=le();if(S==="unknown")n.logger.warn("Skills registry unreadable or has no usable generatedAt; leaving suggestion staleness unchanged");else try{await R("/api/instruction-suggestions/mark-stale",{stale:S==="stale"}),S==="stale"?n.logger.warn("Skills registry is stale (>48h); marked catalog-skill suggestions stale"):n.logger.info("Skills registry is fresh; cleared staleness on catalog-skill suggestions")}catch{}n.logger.info(`Done: scored ${M}/${i.length} projects`)},"cronSuggestInstructions");export{Q as a,ae as b,ie as c,ce as d,Re as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as I}from"./chunk-LVAROIKP.js";import{b as A,c as l,d as b}from"./chunk-D4UDSY7Y.js";import{f as k}from"./chunk-2AVGUZ2P.js";import{n as f,o as g,p as u,v,w as $,x as y}from"./chunk-OOGTQOL3.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 +1 @@
|
|
|
1
|
-
import{b as o,f as a}from"./chunk-
|
|
1
|
+
import{b as o,f as a}from"./chunk-2AVGUZ2P.js";import{a as n}from"./chunk-ZLLER3HP.js";function c(e){return e==null?e??null:e instanceof Date?e.toISOString():e}n(c,"serializeDate");async function d(e){let r={provider:e.provider,plan:e.plan,limitType:e.limitType,value:e.value,unit:e.unit,comparator:e.comparator,resetsAt:c(e.resetsAt),sourceType:e.sourceType,sourceUrl:e.sourceUrl,sourceEvidence:e.sourceEvidence,confidence:e.confidence,observedAt:c(e.observedAt)};return a("/api/internal/research/observe",r)}n(d,"postObservation");async function f(e){let r=0,i=0,s=[];for(let u of e)try{await d(u),r++}catch(t){i++;let p=t instanceof o?`HTTP ${t.statusCode}: ${t.message}`:String(t);s.length<5&&s.push(p)}return{posted:r,failed:i,errors:s}}n(f,"postObservations");export{d as a,f as b};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{a as i}from"./chunk-ZLLER3HP.js";function X(e){return(e.trim().split(`
|
|
2
|
+
`)[0]?.replace(/^#+\s*/,"").trim()||"Suggested instruction").slice(0,120)}i(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 s=r;if(typeof s.addition!="string"||s.addition.trim()==="")return[];let a=s.addition.trim();return[{title:X(a),artifact:"instruction",canonicalBody:a,rationale:typeof s.why=="string"?s.why:"",evidence:[],outcomeMetric:"session_outcome",renderings:[{harness:"claude_code",target:"CLAUDE.md",body:a},{harness:"codex",target:"AGENTS.md",body:a}]}]})),e}i(J,"normalizeRecommendationCandidates");var Z=new Set(["instruction"]);function Q(e){if(!e||typeof e!="object")return e;let t=e,n=t.recommendation_candidates;if(!Array.isArray(n)||n.length===0)return e;let o=n.filter(s=>!!s&&typeof s=="object"&&typeof s.canonicalBody=="string"&&s.canonicalBody.trim().length>0);for(let s of o){if(Array.isArray(s.renderings)&&s.renderings.length>0)continue;let a=s.canonicalBody.trim(),c=Z.has(String(s.artifact));s.renderings=c?[{harness:"claude_code",target:"CLAUDE.md",body:a},{harness:"codex",target:"AGENTS.md",body:a}]:[{harness:"claude_code",target:"manual",body:a},{harness:"codex",target:"manual",body:a}]}let r=t.suggestions&&typeof t.suggestions=="object"?t.suggestions:{};return(!Array.isArray(r.claude_md_additions)||r.claude_md_additions.length===0)&&(r.claude_md_additions=o.filter(s=>s.artifact==="instruction").map(s=>({addition:s.canonicalBody.trim(),why:typeof s.rationale=="string"?s.rationale:"",prompt_scaffold:"Add to CLAUDE.md (and AGENTS.md for Codex)."}))),(!Array.isArray(r.features_to_try)||r.features_to_try.length===0)&&(r.features_to_try=o.filter(s=>s.artifact!=="instruction").map(s=>({feature:typeof s.title=="string"?s.title:"Proposed change",one_liner:typeof s.rationale=="string"?s.rationale:"",why_for_you:typeof s.outcomeMetric=="string"?`Aimed at ${s.outcomeMetric}.`:"",example_code:s.canonicalBody.trim()}))),Array.isArray(r.usage_patterns)||(r.usage_patterns=[]),t.suggestions=r,e}i(Q,"deriveLegacyPresentation");function ee(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 te(e),J(e),e}i(ee,"normalizeRecommendations");function te(e){if(!e||typeof e!="object")return;let t=e;if(Array.isArray(t.recommendation_candidates)&&t.recommendation_candidates.length>0)return;let n=t.suggestions;if(!n||typeof n!="object")return;let o=n.recommendation_candidates;!Array.isArray(o)||o.length===0||(t.recommendation_candidates=o)}i(te,"liftNestedCandidates");import{z as p}from"zod";var I=["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(I),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.`}i(v,"buildRecommendationPrompt");var P=32e3,ne={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(ne,[]).length,r=[],s=[],a=0;for(let c of e){let l=oe(c);s.length>0&&o+a+l>n&&(r.push(s),s=[],a=0),s.push(c),a+=l}return s.length>0&&r.push(s),r}i(D,"batchCandidatesForPrompt");function oe(e){return`- ID: ${e.id}
|
|
36
|
+
Name: ${e.name}
|
|
37
|
+
Description: ${e.description}
|
|
38
|
+
Tags: ${e.tags.join(", ")}
|
|
39
|
+
Preview: ${e.contentPreview}`.length+2}i(oe,"renderedSize");var j=["Added","Changed","Fixed","Removed","Deprecated","Security"],re=/^##\s+\[([^\]]+)\](?:\s*[-–]\s*(\d{4}-\d{2}-\d{2}))?\s*$/,se=/^###\s+(.+?)\s*$/,ie=/^[-*]\s+(.*\S)\s*$/,ae=/^ {2,}(\S.*)$/;function ce(e){let t=e.split(/\r?\n/),n=[],o=null,r=null,s=null;for(let a of t){let c=a.match(re);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,s=null;continue}if(!o)continue;let l=a.match(se);if(l){let m=l[1].trim();j.includes(m)?(r=m,o.sections[r]||(o.sections[r]=[]),s=o.sections[r]):(r=null,s=null);continue}if(!r||!s)continue;let u=a.match(ie);if(u){s.push(u[1]);continue}let f=a.match(ae);if(f&&s.length>0){s[s.length-1]+=" "+f[1].trim();continue}}return o&&n.push(o),{entries:n}}i(ce,"parseChangelog");function le(e){return e.entries.filter(t=>t.unreleased?!1:Object.values(t.sections).some(n=>n&&n.length>0))}i(le,"announceableEntries");function _(e){let t=/^(#{1,6})\s+/.exec(e);return t?t[1].length:0}i(_,"headingLevel");function $(e){return e.replace(/^#{1,6}\s+/,"").replace(/[`*_~]/g,"").trim().toLowerCase()}i($,"normaliseHeading");function ue(e,t){let n=$(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)_(o[m])>0&&$(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 s=r[0],a=_(o[s]),c=o.length;for(let m=s+1;m<o.length;m+=1){let S=_(o[m]);if(S>0&&S<=a){c=m;break}}let l=o.slice(s,c).join(`
|
|
41
|
+
`),u=[...o.slice(0,s),...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}}i(ue,"removeMarkdownSection");function me(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}}i(me,"removeExactBlock");var M=["HTTPS_PROXY","HTTP_PROXY","NODE_EXTRA_CA_CERTS"];function pe(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,s]of Object.entries(n.hooks)){if(!Array.isArray(s))continue;let a=s.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"}:{}}}i(pe,"removeHookByCommand");function de(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}`]})}i(de,"removeMcpServer");function E(e){if(!e||typeof e!="object")return[];let t=e.env;return t?M.filter(n=>n in t):[]}i(E,"protectedEnvKeysPresent");function fe(e,t){let n=E(e),o=new Set(E(t));return n.filter(r=>!o.has(r))}i(fe,"lostProtectedEnvKeys");function he(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,s=typeof o.code=="string"&&o.code?o.code:void 0;return s?{message:r,code:s}:{message:r}}i(he,"parseApiError");var b=["inside","outside"];function y(e){return e.trim().toLowerCase()}i(y,"normalizeDependencyKey");function ge(e){let t=[];if(b.includes(e.boundaryClass)||t.push({field:"boundaryClass",message:`must be one of ${b.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}i(ge,"validateArtifactSpec");function ye(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(s=>!o.has(s));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}i(ye,"validateArtifactInverse");var U="artifact";function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}i(A,"stringArray");function xe(e){if(!e||typeof e!="object")return null;let t=e[U];if(!t||typeof t!="object")return null;let n=t;return{boundaryClass:n.boundaryClass,targets:A(n.targets),requires:A(n.requires),provides:A(n.provides)}}i(xe,"parseArtifactSpec");var ve=["applied","measuring","improved","inconclusive","harmful","rollback_ready"];function H(e){return e.appliedAt?e.appliedAt instanceof Date?e.appliedAt.getTime():new Date(e.appliedAt).getTime():0}i(H,"appliedAtMs");function Se(e){return[...e].sort((t,n)=>{let o=H(n)-H(t);return o!==0?o:(n.applySeq??0)-(t.applySeq??0)})}i(Se,"orderForReversal");var z=["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PostToolUse","PreCompact","Notification","Stop","SubagentStop"],T=".claude/settings.local.json";function F(e){return`# rm-artifact:${e}`}i(F,"hookTag");function _e(e,t){return`${e.trim()} ${F(t)}`}i(_e,"taggedHookCommand");var Ee=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)||Ee.has(t)?null:y(`cmd:${t}`)}i(k,"inferredCommandRequirement");function Ae(e,t){let n=new Set((t?.requires??[]).map(y).filter(Boolean)),o=k(e.command);return o&&n.add(o),{boundaryClass:"outside",targets:[T],requires:[...n],provides:(t?.provides??[]).map(y).filter(Boolean)}}i(Ae,"hookArtifactSpec");function x(e){let t=[];z.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}i(x,"validateHookSpec");function be(e){let t=[`runs on: ${e.event}${e.matcher?` (tools matching ${e.matcher})`:""}`,`spawns: ${e.command.trim()}`,`writes: ${T} (one entry, tagged with this artifact's id)`],n=k(e.command);return n&&t.push(`needs: ${n} on PATH`),t}i(be,"describeHookCapability");var Y="hook";function h(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}i(h,"asRecord");function K(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}}i(K,"readBareSpec");function B(e){let t=h(e.hooks)??e,n=[];for(let[o,r]of Object.entries(t))if(Array.isArray(r))for(let s of r){let a=h(s);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:[]}}i(B,"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}i(Te,"fencedBlocks");function ke(e){let t=h(h(e.frontmatter)?.artifact),n=t?h(t[Y]):null;if(n){let o=K(n);if(o)return{spec:o,problems:x(o),source:"envelope"};let r=B(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 s=h(r);if(!s)continue;let a=K(s);if(a)return{spec:a,problems:x(a),source:"content-fragment"};let c=B(s);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"}}i(ke,"parseHookSpec");var Ce=/[\p{L}\p{N}]+/gu;function C(e){let t=new Set;for(let n of e.toLowerCase().matchAll(Ce)){let o=` ${n[0]} `;for(let r=0;r+3<=o.length;r+=1)t.add(o.slice(r,r+3))}return t}i(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,[s,a]=n.size<=o.size?[n,o]:[o,n];for(let l of s)a.has(l)&&(r+=1);let c=n.size+o.size-r;return c===0?0:r/c}i(g,"trigramSimilarity");var L=.3,we=15;function w(e){let n=e.replace(/<!--[\s\S]*?-->/g," ").replace(/```[\s\S]*?```/g," "),o=[];for(let r of n.split(`
|
|
47
|
+
`)){let s=r.trim();if(s.length===0||s.startsWith("#"))continue;let a=s.replace(/^(?:[-*+]|\d+[.)])\s+/,"").trim();if(a.length!==0)for(let c of a.split(/(?<=[.!?])\s+(?=[A-Z(`"'*])/)){let l=c.trim();l.length>=we&&o.push(l)}}return o}i(w,"splitDirectives");function W(e,t,n=L){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}))),s=[],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?s.push(l):a.push(c)}return{redundant:a.length===0,coverage:s.length/o.length,matches:s,novel:a}}i(W,"assessRedundancy");function Le(e,t=L){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}i(Le,"findInternalRedundancy");var G=.5,Oe=/-(?=[0-9a-f]{6}$)[0-9a-f]*[0-9][0-9a-f]*$/;function O(e){return e.trim().toLowerCase().replace(/^skills--/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(Oe,"").replace(/-+$/,"")}i(O,"skillNameStem");function Ie(e,t,n=G){let o=O(e.name);for(let s of t)if(o.length>0&&O(s.name)===o)return{name:s.name,similarity:g(e.content,s.content),reason:"name-stem"};let r=null;for(let s of t){let a=g(e.content,s.content);a<n||(r===null||a>r.similarity)&&(r={name:s.name,similarity:a,reason:"body"})}return r}i(Ie,"assessSkillDuplication");var Re=new Set(["sh","bash","zsh","fish"]),Ne=new Set(["mjs","cjs","js","ts","py","rb","pl"]),Pe=/(?:^|[\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+)*$/,De=/(?:\.\/)?(?:[\w.@-]+\/)+[\w.@-]+\.\w+/g;function je(e){return e.replace(/```[\w-]*\n?/g," ").replace(/`/g," ")}i(je,"stripCodeMarkers");function $e(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}i($e,"normalise");function q(e){let t=je(e),n=new Set,o=[];for(let r of t.matchAll(De)){let s=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=$e(s);if(!l)continue;let u=l.slice(l.lastIndexOf(".")+1).toLowerCase();(Re.has(u)||Ne.has(u)&&(s.startsWith("./")||Pe.test(t.slice(t.lastIndexOf(`
|
|
48
|
+
`,Math.max(0,a-1))+1,a))))&&(n.has(l)||(n.add(l),o.push({reference:s,path:l})))}return o}i(q,"extractCommandReferences");function Me(e,t){return q(e).filter(n=>!t(n.path))}i(Me,"findUnresolvableReferences");import Nt from"gray-matter";import{z as V}from"zod";var $t=V.object({type:V.enum(["instruction","prompt"])});export{Q as a,ee as b,v as c,D as d,ce as e,le as f,ue as g,me as h,pe as i,de as j,fe as k,he as l,y as m,ge as n,ye as o,xe as p,ve as q,Se as r,T as s,F as t,_e as u,Ae as v,be as w,ke as x,w as y,W as z,Le as A,Ie as B,Me as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as d,d as t}from"./chunk-
|
|
1
|
+
import{c as d,d as t}from"./chunk-UQSUSB6G.js";import{a as r}from"./chunk-ZLLER3HP.js";async function g(o,i){let{evalTargetId:s}=o;try{let e=await t({targetId:s,engineFlag:"auto",skipReviewed:!0,log:r(a=>i.logger.info(`[judge-review] ${a}`),"log"),warn:r(a=>i.logger.warn(`[judge-review] ${a}`),"warn")});return{evalTargetId:s,reviewerModel:e.reviewerModel,comparedPairs:e.report.pairs,disagreements:e.report.disagreements.length,persisted:e.persisted,alreadyReviewed:e.alreadyReviewed,deferredPartialRuns:e.deferredPartialRuns}}catch(e){if(e instanceof d)return i.logger.info(`[judge-review] skipped (${e.reason}): ${e.message}`),{evalTargetId:s,skipped:e.reason};throw e}}r(g,"processJudgeReview");export{g as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as R,b as T}from"./chunk-
|
|
1
|
+
import{a as R,b as T}from"./chunk-OCHAV6YZ.js";import{a as p,b as y}from"./chunk-LVAROIKP.js";import{a as $,b as w,e as U}from"./chunk-LJRE3LZ2.js";import{g as j,i as D,j as x}from"./chunk-UPFH72PF.js";import{e as I,f as P,i as C}from"./chunk-2AVGUZ2P.js";import{B as S,C as b,o as k,z as A}from"./chunk-OOGTQOL3.js";import{a as u}from"./chunk-ZLLER3HP.js";import*as l from"node:fs";import*as m from"node:path";var O=new Set(["mcp","subagent","feature"]);function L(e,t,i){let a=m.join(e,"CLAUDE.md"),s=$(t),o=w(t),r=l.existsSync(a)?l.readFileSync(a,"utf8"):"";if(r.includes(s))return!1;let d=`${r.length>0&&!r.endsWith(`
|
|
2
2
|
`)?`
|
|
3
3
|
|
|
4
4
|
`:r.length>0?`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as h,b as D}from"./chunk-LUCVMLHV.js";import{
|
|
1
|
+
import{a as h,b as D}from"./chunk-LUCVMLHV.js";import{e as _,f as C}from"./chunk-OOGTQOL3.js";import{a as o}from"./chunk-ZLLER3HP.js";import*as m from"node:fs/promises";import*as x from"node:path";import{eq as z}from"drizzle-orm";import{randomBytes as H}from"node:crypto";var A="#0d9488",g="#1a1a1a",y="#666666",M="#f5f5f7",k="#ffffff",I="#e5e5e9",O=["Added","Changed","Fixed","Removed","Deprecated","Security"];function U(e){let t=["January","February","March","April","May","June","July","August","September","October","November","December"],[n,r,a]=e.split("-").map(p=>parseInt(p,10));return!n||!r||!a||r<1||r>12?e:`${t[r-1]} ${a}, ${n}`}o(U,"formatIsoDate");function l(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}o(l,"escapeHtml");function P(e){let t=[];for(let n of O){let r=e[n];r&&r.length>0&&t.push({name:n,items:r})}return t}o(P,"orderedSections");function v(e){let{version:t,date:n,sections:r,unsubscribeUrl:a,productUrl:p,recipientName:u}=e,c=U(n),s=`What's new in RuleMetric \u2014 ${c}`,b=u?`Hi ${u},`:"Hi there,",i=P(r),d=new Date().getUTCFullYear(),E=i.map(({name:$,items:R})=>{let w=R.map(S=>` <li style="margin:0 0 6px 0;font-size:15px;line-height:1.5;color:${g};">${l(S)}</li>`).join(`
|
|
2
2
|
`);return` <h3 style="margin:24px 0 8px 0;font-size:16px;line-height:1.3;font-weight:600;color:${g};">${$}</h3>
|
|
3
3
|
<ul style="margin:0 0 8px 0;padding-left:20px;">
|
|
4
4
|
${w}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-ZLLER3HP.js";import{existsSync as c,readdirSync as a}from"node:fs";import{homedir as u}from"node:os";import{join as l}from"node:path";var d=o(r=>/^\/(Users|home)\/[^/]+\/?$/.test(r),"isHomeDir"),g=o(r=>/^\/(private\/)?(tmp|var\/folders)/.test(r),"isThrowaway");function x(r,e){return{exists:o(n=>c(n),"exists"),listDirs:o(n=>{try{return a(n,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name)}catch{return[]}},"listDirs"),readTranscriptCwd:e,gitAnchors:r,home:u()}}o(x,"defaultRecoveryEnv");function p(r,e){let n=l(e.home,".claude","projects");if(!e.exists(n))return null;for(let t of e.listDirs(n)){let i=l(n,t,`${r}.jsonl`);if(!e.exists(i))continue;let s=e.readTranscriptCwd(i);return s||null}return null}o(p,"findClaudeCodeCwd");function v(r,e){let n=o(s=>s&&!d(s)&&!g(s)?s:null,"usable"),t=n(r.projectPath);if(!t&&r.tool==="claude_code"&&r.externalSessionId&&(t=n(p(r.externalSessionId,e))),!t||!e.exists(t))return null;let i=e.gitAnchors(t);return!i||!i.gitRemote&&!i.gitRootCommit?null:{projectPath:t,...i}}o(v,"recoverAnchors");export{x as a,p as b,v as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as c,f as d}from"./chunk-
|
|
1
|
+
import{e as c,f as d}from"./chunk-2AVGUZ2P.js";import{a as m}from"./chunk-ZLLER3HP.js";async function f(g,p){let r=m(e=>p?.logger?.info?.(e)??console.log(e),"log"),{projectPath:s}=g,i=`[cron_instruction_training] ${s}`;if(!s)return{skipped:"no-project-path"};let n=await d("/api/instruction-experiments/settle",{projectPath:s}),o=n.settled.map(e=>e.outcome),a=o.filter(e=>e==="graduated").length;for(let e of n.settled)r(`${i}: experiment ${e.experimentId} \u2192 ${e.outcome}`);n.examined>0&&r(`${i}: examined ${n.examined} running experiment(s) \u2014 ${n.settled.length} settled (${a} graduated), ${n.stillRunning} still gathering`);let t=await c(`/api/instruction-suggestions/trialable?projectPath=${encodeURIComponent(s)}`);for(let e of t.refused)r(`${i}: not trialling "${e.name}" \u2014 ${e.reason}`);if(t.candidates.length===0)return r(`${i}: no new trial started (${t.running}/${t.limits.maxConcurrent} running, ${t.slots} slot(s) free)`),{examined:n.examined,settled:n.settled.length,graduated:a,nominated:0,running:t.running,outcomes:o};let u=0;for(let e of t.candidates)try{await d("/api/instruction-experiments",{instructionId:e.instructionId,projectPath:s,source:"trial"}),u+=1,r(`${i}: now measuring "${e.name}" (score ${e.score.toFixed(2)})`)}catch(l){r(`${i}: could not measure "${e.name}" \u2014 ${l instanceof Error?l.message:String(l)}`)}return{examined:n.examined,settled:n.settled.length,graduated:a,nominated:u,running:t.running+u,outcomes:o}}m(f,"cronInstructionTraining");export{f as a};
|