@rulemetric/cli 0.12.3 → 0.12.5
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-LVAROIKP.js → chunk-22ZDUL6H.js} +1 -1
- package/dist/{chunk-Y6TAPCA5.js → chunk-2DWUGAJ4.js} +1 -1
- package/dist/{chunk-FNMJ6E6F.js → chunk-2KJAM2NG.js} +1 -1
- package/dist/{chunk-D4UDSY7Y.js → chunk-2MD5QLYF.js} +1 -1
- package/dist/{chunk-2MZFB46B.js → chunk-5OX6YKTR.js} +1 -1
- package/dist/{chunk-K6T4ODPZ.js → chunk-5PM4E27L.js} +1 -1
- package/dist/{chunk-IS2AZIG7.js → chunk-7PWPWJXC.js} +1 -1
- package/dist/chunk-7R3WWD7V.js +1 -0
- package/dist/{chunk-VC3DJPUB.js → chunk-A2LHEUNW.js} +1 -1
- package/dist/{chunk-4Y54EMS6.js → chunk-A5P3RCPI.js} +1 -1
- package/dist/{chunk-7BLO7ECB.js → chunk-AGK5AUWT.js} +1 -1
- package/dist/{chunk-YRTG6SX6.js → chunk-AKXGUQ5B.js} +1 -1
- package/dist/chunk-APXQLQZY.js +1 -0
- package/dist/{chunk-J35L3LR3.js → chunk-ARC4Q3GL.js} +1 -1
- package/dist/{chunk-XZY2W3D3.js → chunk-BTQQPQRG.js} +1 -1
- package/dist/{chunk-ASQG7BTP.js → chunk-BXFDEQCX.js} +1 -1
- package/dist/{chunk-QLG6OCYF.js → chunk-CZTTW3MZ.js} +1 -1
- package/dist/{chunk-65TQMBNF.js → chunk-DSJNZWCZ.js} +1 -1
- package/dist/{chunk-ZQJWKIJS.js → chunk-E4RGYYBC.js} +1 -1
- package/dist/{chunk-VTUTSUFW.js → chunk-EZHL527S.js} +1 -1
- package/dist/{chunk-MOY7XDR6.js → chunk-FE2UWAIP.js} +1 -1
- package/dist/{chunk-LW3UE2FY.js → chunk-G3HODHFN.js} +1 -1
- package/dist/{chunk-OCHAV6YZ.js → chunk-GCLTMV7V.js} +1 -1
- package/dist/{chunk-VIFE47RC.js → chunk-GHWBW2IW.js} +1 -1
- package/dist/{chunk-OEZNBFJ2.js → chunk-GOA5Q6TY.js} +1 -1
- package/dist/{chunk-RK2LZIBA.js → chunk-GRPUY2EZ.js} +1 -1
- package/dist/{chunk-E7N5R3HV.js → chunk-HQCPGDQE.js} +1 -1
- package/dist/{chunk-UQSUSB6G.js → chunk-MILLBGCB.js} +1 -1
- package/dist/{chunk-FIPW2SGV.js → chunk-MJ5H7RDK.js} +1 -1
- package/dist/{chunk-2IEYDOFE.js → chunk-NKJTNGXR.js} +1 -1
- package/dist/{chunk-LDQ6FLET.js → chunk-O65AQZYB.js} +1 -1
- package/dist/{chunk-6PUH7HEL.js → chunk-OOFGV7EX.js} +1 -1
- package/dist/{chunk-SD626JBZ.js → chunk-PWTTCSQA.js} +1 -1
- package/dist/{chunk-6LJD6TXN.js → chunk-R6MCQNSH.js} +1 -1
- package/dist/{chunk-5BTNALJL.js → chunk-RUTWW6N6.js} +1 -1
- package/dist/{chunk-4XLMX642.js → chunk-S2SKT5PV.js} +1 -1
- package/dist/chunk-SIGZEQ3K.js +1 -0
- package/dist/{chunk-XUGWUFIQ.js → chunk-TBU5SWA4.js} +1 -1
- package/dist/{chunk-CRPOQMQ2.js → chunk-UA5GEVGW.js} +1 -1
- package/dist/{chunk-2AVGUZ2P.js → chunk-UGACB66X.js} +1 -1
- package/dist/{chunk-PMW35N32.js → chunk-UTAETY5Z.js} +1 -1
- package/dist/chunk-UXB6DRR7.js +3 -0
- package/dist/{chunk-3JSYVZOB.js → chunk-VEFLUZH5.js} +1 -1
- package/dist/{chunk-WRQEHXSN.js → chunk-VYZKKSX4.js} +1 -1
- package/dist/{chunk-T67L2YTW.js → chunk-W23MESHM.js} +1 -1
- package/dist/{chunk-LYP3LNFL.js → chunk-W67DO5PT.js} +1 -1
- package/dist/{chunk-TJYXSMQV.js → chunk-WCIX5KWG.js} +1 -1
- package/dist/{chunk-OOGTQOL3.js → chunk-WMIUFMDI.js} +5 -5
- package/dist/{chunk-SVON2JIS.js → chunk-WTMJSL7R.js} +1 -1
- package/dist/{chunk-SZUH54L4.js → chunk-Y3BYR4M7.js} +1 -1
- package/dist/{chunk-YTPQ7VBO.js → chunk-YSLKV4XC.js} +1 -1
- package/dist/{chunk-PQMWZHEY.js → chunk-YXNAGHHQ.js} +1 -1
- package/dist/{chunk-NMWP3JLW.js → chunk-Z4YVOVMM.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 +1 -1
- package/dist/commands/skills/list.js +1 -1
- package/dist/commands/skills/publish.js +1 -1
- package/dist/commands/skills/search.js +1 -1
- package/dist/commands/skills/update.js +1 -1
- package/dist/commands/suggestions/accept.js +1 -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/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 +7 -7
- package/dist/chunk-2WTCH4RR.js +0 -1
- package/dist/chunk-GY5IJ4RS.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-ZLLER3HP.js";import{existsSync as c,readdirSync as u,statSync as a}from"node:fs";import{homedir as p}from"node:os";import{join as l}from"node:path";var d=i(r=>/^\/(Users|home)\/[^/]+\/?$/.test(r),"isHomeDir"),m=i(r=>/^\/(private\/)?(tmp|var\/folders)/.test(r),"isThrowaway");function y(r,t){return{exists:i(e=>c(e),"exists"),listDirs:i(e=>{try{return u(e,{withFileTypes:!0}).filter(n=>n.isDirectory()).map(n=>n.name)}catch{return[]}},"listDirs"),readTranscriptCwd:t,gitAnchors:r,stat:i(e=>{try{let n=a(e);return{mtimeMs:n.mtimeMs,size:n.size}}catch{return null}},"stat"),home:p()}}i(y,"defaultRecoveryEnv");function f(r,t){let e=l(t.home,".claude","projects");if(!t.exists(e))return null;for(let n of t.listDirs(e)){let o=l(e,n,`${r}.jsonl`);if(t.exists(o))return o}return null}i(f,"findClaudeCodeTranscript");function g(r,t){let e=f(r,t);return e?t.readTranscriptCwd(e):null}i(g,"findClaudeCodeCwd");var h=20*1024*1024;function b(r){if(r.tool!=="claude_code")return{reimport:!1,reason:"not-claude-code"};if(!r.transcript)return{reimport:!1,reason:"no-transcript"};if(r.transcript.size>h)return{reimport:!1,reason:"transcript-too-large"};if(r.pathWasJunk)return{reimport:!0,reason:"junk-path"};if(!r.endedAt)return{reimport:!0,reason:"never-closed"};let t=Date.parse(r.endedAt);return Number.isFinite(t)&&r.transcript.mtimeMs>t+300*1e3?{reimport:!0,reason:"transcript-outgrew-row"}:{reimport:!1,reason:"row-current"}}i(b,"shouldReimportTranscript");function A(r,t){let e=i(s=>s&&!d(s)&&!m(s)?s:null,"usable"),n=e(r.projectPath);if(!n&&r.tool==="claude_code"&&r.externalSessionId&&(n=e(g(r.externalSessionId,t))),!n||!t.exists(n))return null;let o=t.gitAnchors(n);return!o||!o.gitRemote&&!o.gitRootCommit?null:{projectPath:n,...o}}i(A,"recoverAnchors");export{d as a,y as b,f as c,g as d,h as e,b as f,A as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-A2LHEUNW.js";import{a as f}from"./chunk-ZLLER3HP.js";import{useEffect as J,useState as u,useCallback as m,useRef as s}from"react";var y=5e3;function T(a=20){let[d,b]=u([]),[g,l]=u(null),[h,p]=u(!0),r=s(!1),e=s(null),c=s(0),t=m(async()=>{let o=++c.current;try{let n=await i({limit:a});if(r.current||o!==c.current)return;b(n),l(null)}catch(n){if(r.current||o!==c.current)return;l(n instanceof Error?n.message:String(n))}finally{if(r.current||o!==c.current)return;p(!1),e.current=setTimeout(()=>{t()},y)}},[a]),L=m(()=>{e.current&&clearTimeout(e.current),t()},[t]);return J(()=>(r.current=!1,t(),()=>{r.current=!0,e.current&&clearTimeout(e.current)}),[t]),{jobs:d,error:g,loading:h,refetch:L}}f(T,"useLaunchJobs");export{T as a};
|
|
@@ -1,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-UGACB66X.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 +1 @@
|
|
|
1
|
-
import{l as E}from"./chunk-
|
|
1
|
+
import{l as E}from"./chunk-WMIUFMDI.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 +1 @@
|
|
|
1
|
-
import{c as d,d as t}from"./chunk-
|
|
1
|
+
import{c as d,d as t}from"./chunk-MILLBGCB.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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as R,b as S,c as v,f as $,g as A}from"./chunk-SIGZEQ3K.js";import{e as y,f}from"./chunk-UGACB66X.js";import{a as p}from"./chunk-ZLLER3HP.js";import{execFileSync as w}from"node:child_process";import{openSync as x,readSync as P,closeSync as C,readFileSync as j}from"node:fs";function E(c){let t;try{t=x(c,"r");let o=Buffer.alloc(64*1024),s=P(t,o,0,o.length,0),i=o.subarray(0,s).toString("utf-8");for(let r of i.split(`
|
|
2
|
+
`))if(r.startsWith("{"))try{let a=JSON.parse(r).cwd;if(typeof a=="string"&&a.startsWith("/"))return a}catch{}return null}catch{return null}finally{t!==void 0&&C(t)}}p(E,"readTranscriptCwd");function I(c){let t=p(r=>{try{return w("git",["-C",c,...r],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()||null}catch{return null}},"git");if(!t(["rev-parse","--show-toplevel"]))return null;let s=t(["rev-parse","--git-dir"]),i=t(["rev-parse","--git-common-dir"]);return{gitRemote:t(["remote","get-url","origin"]),gitRootCommit:t(["rev-list","--max-parents=0","HEAD"])?.split(`
|
|
3
|
+
`).pop()?.trim()??null,gitBranch:t(["branch","--show-current"]),isWorktree:!!s&&!!i&&s!==i}}p(I,"gitAnchors");async function H(c,t,o=S(I,E)){let s=Math.min(c.limit??200,1e3),i=await y(`/api/sessions/unattributed?limit=${s}`),r=i.sessions??[],a=i.total??r.length;if(r.length===0)return t.logger.info("no unattributed sessions"),{scanned:0,repaired:0,reimported:0,unrepairable:0,remaining:0};let d=0,g=0,l=0;for(let e of r){if(!e.externalSessionId){l++;continue}let n=A(e,o);if(!n){l++;continue}try{await f("/api/sessions",{tool:e.tool,externalSessionId:e.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}}),d++}catch(u){l++,t.logger.info(`reconcile failed for ${e.externalSessionId}: ${u.message}`);continue}let m=e.tool==="claude_code"?v(e.externalSessionId,o):null,b=$({tool:e.tool,pathWasJunk:!!e.projectPath&&R(e.projectPath),endedAt:e.endedAt??null,transcript:m?o.stat(m):null});if(b.reimport&&m)try{let u=j(m,"utf-8");await f(`/api/sessions/${e.id}/reimport`,{content:u,tool:"claude_code"}),g++}catch(u){t.logger.info(`reimport failed for ${e.externalSessionId} (${b.reason}): ${u.message}`)}}let h=a-d;return t.logger.info(`reconciled attribution: scanned=${r.length} repaired=${d} reimported=${g} unrepairable=${l} remaining=${h} (of ${a} total)`),{scanned:r.length,repaired:d,reimported:g,unrepairable:l,remaining:h}}p(H,"cronReconcileAttribution");export{H as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v}from"./chunk-
|
|
1
|
+
import{c as v}from"./chunk-2MD5QLYF.js";import{e as h,f}from"./chunk-UGACB66X.js";import{q as m,r as u}from"./chunk-WMIUFMDI.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{c as l}from"./chunk-
|
|
1
|
+
import{c as l}from"./chunk-UGACB66X.js";import{c as a,l as u}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";var c=120*1e3,t=null;async function k(){if(process.env.RULEMETRIC_API_KEY)return!0;let e=a(u());if(!e.isRefreshable(c))return!0;let r=e.loadToken();return r?.refreshToken?t||(t=f(e,r).finally(()=>{t=null}),t):!0}o(k,"ensureFreshToken");async function f(e,r){let s;try{s=await fetch(`${l()}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:r.refreshToken})})}catch{return!0}if(s.status===401)return e.clearToken(),!1;if(!s.ok)return!0;let n=await s.json().catch(()=>null);if(!n?.accessToken||!n.refreshToken)return!0;let i={accessToken:n.accessToken,refreshToken:n.refreshToken,expiresAt:n.expiresAt??r.expiresAt,email:n.email??r.email};return e.saveToken(i),e.saveEnvFile(i.accessToken),!0}o(f,"doRefresh");export{k as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c}from"./chunk-
|
|
1
|
+
import{c}from"./chunk-PWTTCSQA.js";import{e as p,g as u}from"./chunk-UGACB66X.js";import{a as o}from"./chunk-ZLLER3HP.js";var l="openCandidate";function g(n,i){let t=(n??{})[l];if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.content!="string"||!e.content||typeof e.hash!="string"||!e.hash||typeof e.priorHash!="string"||e.priorHash!==i?null:{content:e.content,hash:e.hash,priorHash:e.priorHash,plannedPairs:typeof e.plannedPairs=="number"?e.plannedPairs:0,updatedAt:typeof e.updatedAt=="string"?e.updatedAt:""}}o(g,"resolveOpenCandidate");function m(n){let{plannedPairs:i,carriedPairs:t,liveCases:e}=n;if(e<=0)return 0;let a=i-t;return a<=0?0:Math.ceil(a/e)}o(m,"owedPasses");var d=100;async function b(n){let{evalTargetId:i,candidateContentHash:t}=n,e=[];for(let a=0;;a+=d){let r=await p(`/api/eval-targets/${i}/runs?candidateContentHash=${encodeURIComponent(t)}&limit=${d}&offset=${a}`);if(!Array.isArray(r)||r.length===0||(e.push(...r),r.length<d))break}return c(e)}o(b,"fetchCarriedPairs");async function P(n){let{evalTargetId:i,meta:t,blob:e,log:a,tag:r}=n;try{let s={...t};e?s[l]=e:delete s[l],await u(`/api/eval-targets/${i}`,{metadata:s}),a(e?`${r}: banked candidate ${e.hash.slice(0,8)} \u2014 the next run resumes instead of restarting`:`${r}: cleared the banked candidate (this cycle reached a decision)`)}catch(s){a(`${r}: could not update the candidate bank (${s instanceof Error?s.message:String(s)})`)}}o(P,"bankOpenCandidate");function C(n){return{content:n.content,hash:n.hash,priorHash:n.priorHash,plannedPairs:n.plannedPairs,updatedAt:n.now.toISOString()}}o(C,"buildOpenCandidate");export{l as a,g as b,m as c,b as d,P as e,C as f};
|
|
@@ -1 +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-UGACB66X.js";import{a as w}from"./chunk-ZLLER3HP.js";async function W(v,f){let{mirrorId:i,evalTargetId:g,config:o}=v,a=w(e=>f.logger.info(e),"log"),s=await k(`/api/eval-targets/${g}`),$=await k(`/api/eval-targets/${g}/evals`);if($.length===0&&o.generateIfEmpty){a("No eval cases on target \u2014 generating from content via local LLM...");let e=await A({content:s.content,name:s.name});if(e===null)throw new Error("Case generation requires an LLM backend (claude CLI on PATH or ANTHROPIC_API_KEY) \u2014 none available on this worker.");let n=[];for(let t of e)n.push(await E(`/api/eval-targets/${g}/evals`,t));$=n,a(`Generated ${n.length} eval case(s)`)}if($.length===0)throw new T("No evals defined for target");let G=o.runsPerEval??1,R=o.timeout??12e4,j=o.iteration??1,y=new Set;if(f.job.attempts>1)for(let n=0;;n+=100){let t=await k(`/api/eval-targets/${g}/runs?jobId=${i}&limit=100&offset=${n}`);for(let r of t)y.add(`${r.evalId}|${r.configuration}|${r.runNumber}|${r.iteration}`);if(t.length<100)break}let _=[{name:"with_target",content:s.content}];o.skipBaseline||_.push({name:"without_target"});let d=[];for(let e of $)for(let n of _)for(let t=1;t<=G;t++)y.has(`${e.id}|${n.name}|${t}|${j}`)||d.push({eval_:e,configuration:n.name,targetContent:n.content,runNumber:t});y.size>0&&a(`Resuming attempt ${f.job.attempts}: ${y.size} run(s) already persisted, ${d.length} remaining`);let l=d.length,u=0,m=Math.min(o.parallel??1,4);await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:0,current:null,message:`Starting ${l} eval runs (concurrency: ${m})...`}});let b=[];async function I(e){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`;a(`[${u+1}/${l}] ${n}`);let t=x({targetType:s.type,targetContent:e.targetContent,targetName:s.name});t.leakedFiles.length&&a(`\u26A0 CONTAMINATED ${n}: ${t.leakedFiles.join(", ")} survived the strip`);try{let r=await M({prompt:e.eval_.prompt,targetContent:t.systemPrompt,workDir:t.workDir,timeout:R,model:o.model}),c={};return!o.skipGrading&&e.eval_.expectations.length>0&&!r.error&&(c=await C({prompt:e.eval_.prompt,output:r.output,expectations:e.eval_.expectations,model:o.graderModel??o.model,timeout:R})),{jobId:i,evalId:e.eval_.id,evalTargetId:s.id,evalTargetVersion:s.version,configuration:e.configuration,runNumber:e.runNumber,iteration:j,status:r.error?"failed":"completed",outputs:{...r.error?{error:r.error}:{transcript:r.output,...r.model?{model:r.model}:{}},methodology:t.methodology,delivery:t.delivery,isolated:t.isWorktree,...t.leakedFiles.length?{leakedFiles:t.leakedFiles}:{}},timing:{duration_ms:r.durationMs,total_tokens:r.totalTokens},grading:c,worktree:t.isWorktree?!0:void 0}}finally{t.cleanup()}}if(w(I,"processItem"),m<=1)for(let e of d){let n=`${e.configuration} \xB7 ${e.eval_.name} \xB7 run#${e.runNumber}`;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Executing ${n}...`}});let t=await I(e);await E("/api/eval-runs",t),b.push(t),u++,await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Completed ${n}`}})}else{a(`Running ${l} evals with concurrency=${m} (worktree isolation)`);for(let e=0;e<d.length;e+=m){let n=d.slice(e,e+m),t=`batch ${Math.floor(e/m)+1}/${Math.ceil(d.length/m)}`;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:t,message:`Executing ${t} (${n.length} parallel)...`}});let r=await Promise.all(n.map(I));for(let c of r)await E("/api/eval-runs",c),b.push(c),u++;await p(`/api/eval-jobs/${i}/progress`,{status:"running",progress:{total:l,completed:u,current:t,message:`Completed ${t}`}})}}let P=J(b),h;if(!o.skipGrading&&b.some(e=>e.grading&&Object.keys(e.grading).length>0))try{a(`Running meta-judge for job ${i}...`);let e=$.map(n=>{let r=b.filter(c=>c.evalId===n.id&&c.configuration==="with_target")[0];return{evalName:n.name,prompt:n.prompt,expectations:n.expectations,grading:r?.grading?r.grading:null,output:r?.outputs?.transcript?.slice(0,500)}});h=await S({targetName:s.name,evalResults:e,model:o.graderModel??o.model,timeout:6e4}),a(`Meta-judge: quality=${h.quality_score}/5, issues=${h.issues.length}`)}catch(e){a(`Meta-judge failed (non-fatal): ${e instanceof Error?e.message:String(e)}`)}let N=h?{...P,meta_judgement:h}:P;return a(`Job ${i} completed: ${u}/${l} runs`),await p(`/api/eval-jobs/${i}/state`,{result:N}).catch(e=>{a(`result persist failed: ${e instanceof Error?e.message:String(e)}`)}),N}w(W,"processEval");function J(v){let f=v.filter(a=>a.status==="completed"),i=v.filter(a=>a.status==="failed"),g=f.filter(a=>{let s=a.grading;return s&&Object.keys(s).length>0}),o=g.length>0?g.reduce((a,s)=>a+(s.grading?.summary?.pass_rate??0),0)/g.length:null;return{total:v.length,completed:f.length,failed:i.length,avgPassRate:o}}w(J,"buildSummary");export{W as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as g,c as w}from"./chunk-UPFH72PF.js";import{g as p,h as m,i as k,j as h,k as y}from"./chunk-
|
|
1
|
+
import{a as g,c as w}from"./chunk-UPFH72PF.js";import{g as p,h as m,i as k,j as h,k as y}from"./chunk-WMIUFMDI.js";import{a as s}from"./chunk-ZLLER3HP.js";import{existsSync as u,readFileSync as f,writeFileSync as v,copyFileSync as R,rmSync as P,statSync as x,readdirSync as $,mkdirSync as j}from"node:fs";import{join as i,dirname as L}from"node:path";import{homedir as c}from"node:os";var I=["/plugins/cache/","/plugins/marketplaces/","/node_modules/","/.git/"];function _(e){return I.some(t=>e.includes(t))}s(_,"isUnownedPath");function K(e,t){let n=i(c(),".config","rulemetric","retraction-backups",t),r=e.replace(/^\/+/,"").replace(/\//g,"__");return i(n,r)}s(K,"backupPathFor");function b(e){return e.split(`
|
|
2
2
|
`).slice(0,40).map(t=>`- ${t}`).join(`
|
|
3
3
|
`)}s(b,"shortDiff");function d(e,t,n){return{kind:e,path:t,ok:!1,refusal:n,preview:"",warnings:[]}}s(d,"refuse");function B(e){let[t,...n]=e.split("::"),r=n.join("::");if(!r)return null;switch(t){case"claude_md":return{kind:"claude_md_section",target:r};case"memory":return{kind:"memory_section",target:r};case"skill":return{kind:"skill_file",target:r};default:return null}}s(B,"pathFromContextIdentity");function D(e,t){let n=e.replace(/^skills--/,""),r=w(e);return[...(r===n?[n]:[r,n]).flatMap(a=>[i(t,...g.split("/"),a,"SKILL.md"),i(t,".claude","skills",a,"SKILL.md"),i(t,".claude","skills",`${a}.md`),i(c(),...g.split("/"),a,"SKILL.md"),i(c(),".claude","skills",a,"SKILL.md"),i(c(),".claude","skills",`${a}.md`)]),...F(n)]}s(D,"candidateSkillPaths");function F(e){let t=i(c(),".claude","plugins","marketplaces");if(!u(t))return[];let n=[];try{for(let r of $(t))n.push(i(t,r,"skills",e,"SKILL.md"),i(t,r,"plugins",e,"SKILL.md"),i(t,r,"skills",`${e}.md`))}catch{}return n}s(F,"pluginSkillPaths");function H(e){switch(e.kind){case"claude_md_section":case"memory_section":case"claude_md_block":return C(e);case"skill_file":return E(e);case"settings_hook":case"mcp_server":return N(e)}}s(H,"planRetraction");function C(e){let t=e.target;if(!u(t))return d(e.kind,t,`File does not exist: ${t}`);if(_(t))return d(e.kind,t,`Refusing to edit a path this tool does not own: ${t}`);let n=f(t,"utf-8"),r=e.body?m(n,e.body):p(n,e.heading??"");if(!r.removed){let l={"not-found":"The content is not present in this file (already removed, or edited since).",ambiguous:"The content appears more than once \u2014 refusing to guess which copy the verdict was about.","would-empty-file":"Removing it would empty the file. Delete the file by hand if that is really the intent."}[r.reason??"not-found"];return d(e.kind,t,l)}let o=[];return S(t,e.cwd)||o.push("This file is not tracked by git in this repo \u2014 the timestamped backup is your only undo."),{kind:e.kind,path:t,ok:!0,preview:b(r.removedText??""),nextContent:r.content,warnings:o}}s(C,"planFileEdit");function E(e){let t=e.target.startsWith("/")?[e.target]:D(e.target,e.cwd),n=t.find(l=>u(l));if(!n)return d("skill_file",t[0]??e.target,`No local skill file found for "${e.target}". Searched:
|
|
4
4
|
${t.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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
|
|
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 L=["org","team","project","personal"],R=p.object({name:p.string().min(1),description:p.string().min(1),type:p.literal("instruction").default("instruction"),scope:p.enum(L),version:p.string().min(1),tags:p.array(p.string()).optional(),compatibility:p.array(p.string()).optional(),slots:p.record(p.string(),p.string()).optional(),metadata:p.record(p.string(),p.unknown()).optional()});import{z as d}from"zod";var N=d.object({name:d.string().min(1),description:d.string().min(1),type:d.literal("prompt"),version:d.string().min(1),tags:d.array(d.string()).optional(),variables:d.array(d.string()).optional(),metadata:d.record(d.string(),d.unknown()).optional()});function v(e,t){let n=t.map(o=>`- ID: ${o.id}
|
|
3
3
|
Name: ${o.name}
|
|
4
4
|
Description: ${o.description}
|
|
5
5
|
Tags: ${o.tags.join(", ")}
|
|
@@ -32,7 +32,7 @@ Return your response as JSON in this exact format:
|
|
|
32
32
|
]
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
Only include instructions with a relevance score >=
|
|
35
|
+
Only include instructions with a relevance score >= ${.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
36
|
Name: ${e.name}
|
|
37
37
|
Description: ${e.description}
|
|
38
38
|
Tags: ${e.tags.join(", ")}
|
|
@@ -43,6 +43,6 @@ Only include instructions with a relevance score >= 0.5. Order by score descendi
|
|
|
43
43
|
|
|
44
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
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>=
|
|
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,
|
|
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 T=["inside","outside"];function y(e){return e.trim().toLowerCase()}i(y,"normalizeDependencyKey");function ge(e){let t=[];if(T.includes(e.boundaryClass)||t.push({field:"boundaryClass",message:`must be one of ${T.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"],b=".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:[b],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 Te(e){let t=[`runs on: ${e.event}${e.matcher?` (tools matching ${e.matcher})`:""}`,`spawns: ${e.command.trim()}`,`writes: ${b} (one entry, tagged with this artifact's id)`],n=k(e.command);return n&&t.push(`needs: ${n} on PATH`),t}i(Te,"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 be(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(be,"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 be(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 w=.3,Oe=15;function O(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>=Oe&&o.push(l)}}return o}i(O,"splitDirectives");function W(e,t,n=w){let o=O(e);if(o.length===0)return{redundant:!1,coverage:0,matches:[],novel:[]};let r=t.flatMap(c=>O(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 we(e,t=w){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(we,"findInternalRedundancy");var G=.5,Ie=/-(?=[0-9a-f]{6}$)[0-9a-f]*[0-9][0-9a-f]*$/;function I(e){return e.trim().toLowerCase().replace(/^skills--/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(Ie,"").replace(/-+$/,"")}i(I,"skillNameStem");function Le(e,t,n=G){let o=I(e.name);for(let s of t)if(o.length>0&&I(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(Le,"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,b as s,F as t,_e as u,Ae as v,Te as w,ke as x,O as y,W as z,we as A,Le as B,Me as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as k}from"./chunk-GN3ZHQ46.js";import{a as f}from"./chunk-KGURGIZ2.js";import{a as $}from"./chunk-BJSVATVJ.js";import{d as v}from"./chunk-TZA4HAVF.js";import{f as p}from"./chunk-
|
|
1
|
+
import{e as k}from"./chunk-GN3ZHQ46.js";import{a as f}from"./chunk-KGURGIZ2.js";import{a as $}from"./chunk-BJSVATVJ.js";import{d as v}from"./chunk-TZA4HAVF.js";import{f as p}from"./chunk-UGACB66X.js";import{a as c}from"./chunk-ZLLER3HP.js";async function x(m,t,s=()=>{}){let{eval_:r,configuration:i,targetContent:g,runNumber:o}=m;s(`[${i}] ${r.name} run#${o} \u2014 executing...`);let a=k({targetType:t.targetType,targetContent:g,targetName:t.targetName}),d={methodology:a.methodology,delivery:a.delivery,isolated:a.isWorktree,...t.candidateContentHash?{candidateContentHash:t.candidateContentHash}:{},...a.leakedFiles.length?{leakedFiles:a.leakedFiles}:{}};a.isWorktree||s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 no git worktree; running without repo context`),a.leakedFiles.length&&s(`[${i}] ${r.name} run#${o} \u2014 \u26A0 CONTAMINATED: ${a.leakedFiles.join(", ")} survived the strip`);try{let n=await v({prompt:r.prompt,targetContent:a.systemPrompt,workDir:a.workDir,timeout:t.timeout,model:t.model});if(n.error){let e=f(n.error);return s(`[${i}] ${r.name} run#${o} \u2014 FAILED (${e.kind}): ${n.error}`),{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"failed",outputs:{error:n.error,failureKind:e.kind,failureClass:e.class,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens},grading:{},failure:e}}s(`[${i}] ${r.name} run#${o} \u2014 completed in ${(n.durationMs/1e3).toFixed(1)}s`);let u={};if(!t.skipGrading&&r.expectations.length>0){s(`[${i}] ${r.name} run#${o} \u2014 grading...`);let e=await $({prompt:r.prompt,output:n.output,expectations:r.expectations,model:t.graderModel??t.model,timeout:t.timeout});u=e,s(`[${i}] ${r.name} run#${o} \u2014 grading done: pass_rate=${e.summary.pass_rate==null?"n/a (all assertions errored)":`${(e.summary.pass_rate*100).toFixed(0)}%`}`)}return{evalId:r.id,evalTargetId:t.targetId,evalTargetVersion:t.targetVersion,configuration:i,runNumber:o,iteration:t.iteration,status:"completed",outputs:{transcript:n.output,...d},timing:{duration_ms:n.durationMs,total_tokens:n.totalTokens,total_duration_seconds:n.durationMs/1e3},grading:u}}finally{a.cleanup()}}c(x,"executeAndGradeCase");async function R(m){let{cases:t,targetContent:s,concurrency:r,runNumber:i,opts:g,skipBaseline:o,onLog:a=c(()=>{},"onLog")}=m,d=o?["with_target"]:["with_target","without_target"],n=[];for(let e of t)for(let l of d)n.push({eval_:e,configuration:l,targetContent:l==="with_target"?s:void 0,runNumber:i});let u=[];for(let e=0;e<n.length;e+=Math.max(1,r)){let l=n.slice(e,e+Math.max(1,r)),h=await Promise.all(l.map(b=>x(b,g,a)));u.push(...h)}for(let e of u)try{await p("/api/eval-runs",e)}catch(l){a(` \u26A0 failed to post a run result: ${l instanceof Error?l.message:String(l)}`)}try{await p(`/api/eval-targets/${g.targetId}/label-state`,{})}catch(e){a(` \u26A0 label-state notification skipped: ${e instanceof Error?e.message:String(e)}`)}return{completed:u.filter(e=>e.status==="completed").length,failed:u.filter(e=>e.status==="failed").length,results:u}}c(R,"runBatchAndPost");export{x as a,R as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as d}from"./chunk-QWCEZEDO.js";import{d as g}from"./chunk-NF2BIEAF.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-3QXRLIGC.js";import{e as _}from"./chunk-
|
|
1
|
+
import{e as d}from"./chunk-QWCEZEDO.js";import{d as g}from"./chunk-NF2BIEAF.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-3QXRLIGC.js";import{e as _}from"./chunk-UGACB66X.js";import{g as m,l as k}from"./chunk-PZNWH4VQ.js";import{a as i}from"./chunk-ZLLER3HP.js";import{execSync as j}from"node:child_process";import{existsSync as p,readFileSync as y}from"node:fs";import{homedir as f}from"node:os";import{join as a}from"node:path";var P=["install","auth","hooks","worker"],O=["judge"],M=[...P,...O];function $(){return{projectPath:process.cwd(),configDir:k()}}i($,"defaultContext");var A=a(f(),".mitmproxy","mitmproxy-ca-cert.pem");function S(e){if(!e)return"";if(e.length<=8)return"*".repeat(e.length);let t=e.slice(0,4),n=e.slice(-4);return`${t}${"*".repeat(Math.max(4,e.length-8))}${n}`}i(S,"maskToken");function te(e,t){let n=e===null?[]:e.replace(/\n$/,"").split(`
|
|
2
2
|
`),o=t===null?[]:t.replace(/\n$/,"").split(`
|
|
3
3
|
`),s=[],u=Math.max(n.length,o.length);for(let c=0;c<u;c++){let l=n[c],r=o[c];l===r?s.push(` ${l}`):(l!==void 0&&s.push(`-${l}`),r!==void 0&&s.push(`+${r}`))}return s.join(`
|
|
4
4
|
`)}i(te,"renderDiff");function x(e,t){let n=a(e,"env");if(!p(n))return null;try{let s=y(n,"utf-8").match(new RegExp(`^${t}=(.+)$`,"m"));return s?s[1]:null}catch{return null}}i(x,"readEnvValue");async function b(){if(!m())return!1;try{return(await Promise.race([_("/api/setup/status"),new Promise((t,n)=>setTimeout(()=>n(new Error("setup/status timeout")),2500))]))?.workerActive===!0}catch{return!1}}i(b,"workerActive");function E(e,t){let n=a(e,".claude",t),o={},s=null;if(p(n))try{s=y(n,"utf-8").replace(/\n$/,""),o=JSON.parse(s)}catch{o={}}return{settings:o,before:s}}i(E,"readProjectSettings");function D(e){let{settings:t,before:n}=E(e,"settings.local.json");return v(t),{before:n,after:JSON.stringify(t,null,2)}}i(D,"projectHooksSettings");function N(e){let{settings:t,before:n}=E(e,"settings.local.json"),o={...t.env??{}};return o.HTTPS_PROXY=`http://localhost:${d}`,o.NO_PROXY=I,o.NODE_EXTRA_CA_CERTS=A,{before:n,after:JSON.stringify({...t,env:o},null,2)}}i(N,"projectProxyEnvSettings");function U(e){let{settings:t,before:n}=E(e,"settings.json");if(n===null)return null;let{removed:o}=C(t,d);return o?{before:n,after:JSON.stringify(t,null,2)}:null}i(U,"projectSharedSettingsMigration");var Y=a(f(),"Library","LaunchAgents","com.rulemetric.worker.plist"),G=a(f(),".config","systemd","user","rulemetric-worker.service");function h(e){j(e,{stdio:"inherit"})}i(h,"runCommand");var L=[{id:"install",title:"Install the CLI",command:"npm install -g @rulemetric/cli",async detect(){return m()||await b()},async plan(){return{id:"install",title:"Install the CLI",command:"npm install -g @rulemetric/cli",artifacts:[{path:"npm install -g @rulemetric/cli",kind:"command",before:null,after:"rulemetric --version # verifies the binary is on PATH"}]}},async apply(){h("npm install -g @rulemetric/cli")}},{id:"auth",title:"Authenticate",command:"rulemetric auth login",async detect(){return m()},async plan(e){let t=a(e.configDir,"env"),n=null;if(p(t))try{n=X(y(t,"utf-8"))}catch{n="(unreadable)"}let o=x(e.configDir,"RULEMETRIC_ACCESS_TOKEN"),u=[`RULEMETRIC_ACCESS_TOKEN=${S(o||"<token-from-login>")}`],c=x(e.configDir,"RULEMETRIC_API_KEY");c&&u.push(`RULEMETRIC_API_KEY=${S(c)}`);let l=process.env.RULEMETRIC_API_URL;l&&u.push(`RULEMETRIC_API_URL=${l}`);let r=u.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as n,c as a,d as g}from"./chunk-3AV3GTMP.js";import{e as o}from"./chunk-
|
|
1
|
+
import{a as s,b as n,c as a,d as g}from"./chunk-3AV3GTMP.js";import{e as o}from"./chunk-UGACB66X.js";import{a as e}from"./chunk-ZLLER3HP.js";var i=!1;async function c(){if(process.env.RULEMETRIC_ORG_ID)return;let r=s();if(!(r&&!g(r)))try{let t=await o("/api/profile");if(!t.activeOrgId){a();return}if(r&&t.activeOrgId===r.orgId){n({orgId:r.orgId,orgSlug:r.orgSlug,syncedAt:Date.now()});return}let d=(await o("/api/orgs")).find(l=>l.id===t.activeOrgId);n({orgId:t.activeOrgId,orgSlug:d?.slug,syncedAt:Date.now()})}catch{}}e(c,"syncActiveOrgFromServer");async function p(){i||(i=!0,await c())}e(p,"maybeRefreshActiveOrg");async function v(){i=!0,await c()}e(v,"bootstrapActiveOrg");function O(){i=!1}e(O,"_resetRefreshAttempt");export{p as a,v as b,O as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as R,b as T}from"./chunk-
|
|
1
|
+
import{a as R,b as T}from"./chunk-GCLTMV7V.js";import{a as p,b as y}from"./chunk-22ZDUL6H.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-UGACB66X.js";import{B as S,C as b,o as k,z as A}from"./chunk-WMIUFMDI.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 +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-
|
|
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-UGACB66X.js";import{c as H,d as U}from"./chunk-WMIUFMDI.js";import{a as u}from"./chunk-ZLLER3HP.js";import{readFileSync as q,realpathSync as V}from"node:fs";import y from"node:path";import A from"node:os";function Q(s){let n=y.resolve(s);if(n===y.resolve(A.homedir()))return!1;let a=y.parse(n).root;if(n===a)return!1;try{let o=V(A.tmpdir());if(V(n)===o)return!1}catch{}return!0}u(Q,"isScorableProjectPath");var Z=5,ee=Number(process.env.RULEMETRIC_MAX_SUGGESTION_PROJECTS??10),te=48,ne=.5,O=400,oe=3,re=.6,se=1;function ae(s){let n=s.bloated??[],a=new Set([...s.harmful.map(o=>o.id),...s.candidates.map(o=>o.id)]);return n.filter(o=>!a.has(o.id)).slice(0,se).map(o=>({instructionId:o.id,estimatedTokens:o.estimatedTokens,topProjectId:o.topProjectId??null,score:.55,reason:`Costs ~${o.estimatedTokens} tokens every session and measures neutral across ${o.exposures} exposed session(s) \u2014 enough data to detect an effect, and none found. Consider shortening "${o.name}" rather than removing it.`+(o.containsSafetyLanguage?" CAUTION: it contains guardrail language (destructive-command or credential rules) \u2014 preserve those lines when shortening.":"")}))}u(ae,"buildTrimProposals");async function ie(s,n,a){let o=[],i=0;for(let d of s)try{await a("/api/instruction-experiments",{instructionId:d.instructionId,projectPath:n,source:"groom"}),i++}catch(g){let m=g instanceof Error?g.message:String(g);o.push({...d,reason:`${d.reason} (not measurable by withholding: ${m})`})}return{nominated:i,unmeasurable:o}}u(ie,"nominateRemovals");function ce(s){let n=[];for(let o of s.harmful){let i=o.verdict.delta;n.push({instructionId:o.id,score:Math.min(.95,.75+Math.abs(i)),topProjectId:o.topProjectId??null,reason:`Measured harmful: sessions using "${o.name}" scored ${(i*100).toFixed(1)}pp worse across ${o.exposures} exposed session(s). Observational \u2014 review before archiving.`})}let a=new Set(s.harmful.map(o=>o.id));for(let o of s.candidates)a.has(o.id)||n.push({instructionId:o.id,score:re,topProjectId:o.topProjectId??null,reason:`Unused: "${o.name}" is ${o.reason} (${o.totalExposures} lifetime exposure(s)) but still costs context budget every session.`});return n.slice(0,oe)}u(ce,"buildRemovalProposals");function le(){let s=y.join(A.homedir(),".config","rulemetric","skills-registry.json");try{let n=q(s,"utf-8"),a=JSON.parse(n),o=new Date(a.generatedAt).getTime();return Number.isNaN(o)?"unknown":Date.now()-o>te*60*60*1e3?"stale":"fresh"}catch{return"unknown"}}u(le,"observeSkillsRegistry");var Re=u(async(s,n)=>{let a=J(),o=a!=="none";o?n.logger.info(`Scoring backend: ${a}`):n.logger.warn("No LLM backend available (claude CLI missing and ANTHROPIC_API_KEY unset); skipping relevance scoring. Removal/trim proposals still run \u2014 they need no LLM.");let i;try{i=(await w("/api/sessions/project-paths?limit="+ee)).projectPaths}catch(e){n.logger.warn(`Failed to fetch project paths: ${e instanceof Error?e.message:String(e)}`);return}if(i.length===0){n.logger.info("No recent project paths; nothing to score");return}let d=new Map;try{let e=await w("/api/projects?limit=200");for(let t of e.projects??[])t.primaryCheckoutPath&&d.set(x(t.primaryCheckoutPath),t.id)}catch(e){n.logger.warn(`Failed to fetch projects for id resolution: ${e instanceof Error?e.message:String(e)}`)}let g=new Map;try{let e=await w(`/api/catalog?limit=200&proposable=1&contentPreview=${O}`);for(let t of e)g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.contentPreview??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch catalog: ${e instanceof Error?e.message:String(e)}`)}try{let e=await w("/api/instructions?limit=100");for(let t of e.instructions??[])g.has(t.id)||g.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,O)})}catch(e){n.logger.warn(`Failed to fetch personal instructions: ${e instanceof Error?e.message:String(e)}`)}let m=[],p=[];try{let e=await w("/api/insights/groom-candidates");if(!e.captureHealthy)n.logger.info(`Grooming paused: ${e.reason??"capture unhealthy"}`);else{m=ce(e),p=ae(e);let t=e.safetyGuarded+e.harmfulSafetyGuarded;n.logger.info(`Removal proposals: ${m.length} (${e.harmful.length} measured-harmful, ${e.candidates.length} never-used, ${t} withheld by the safety allowlist); trim proposals: ${p.length} (${(e.bloated??[]).length} measured-neutral and expensive, ${e.trimSafetyFlagged??0} flagged as containing guardrail language)`)}}catch(e){n.logger.warn(`Failed to fetch groom candidates: ${e instanceof Error?e.message:String(e)}`)}let b=[...g.values()];if(b.length===0&&m.length===0&&p.length===0){n.logger.info("No candidate instructions and nothing to retire; nothing to score");return}n.logger.info(`Scoring ${b.length} candidates across ${i.length} project(s)`);let M=0,l=null,I=new Set;for(let e of i)try{let t=x(e);if(!Q(t)){n.logger.info(`Skipping ${t}: not a project directory (home/root)`);continue}let f=D(t),k=o&&f.length>0;f.length===0&&n.logger.info(`${t}: insufficient language signals; removal/trim only`);let v=X(t),z={name:y.basename(t),description:v.description,languages:f,topics:v.topics,dependencies:v.dependencies},E=k?U(b):[];k&&n.logger.info(`Scoring ${b.length} candidates for ${t} in ${E.length} batch(es)`);let C=[],$=0;for(let r of E)try{let c=await B(H(z,r),"",4096);if(!c){$++;continue}let T=c.recommendations??[];for(let P of T)typeof P.instructionId=="string"&&typeof P.score=="number"&&typeof P.reason=="string"&&C.push({instructionId:P.instructionId,score:P.score,reason:P.reason})}catch(c){$++,n.logger.warn(`Batch failed for ${t}: ${c instanceof Error?c.message:String(c)}`)}$>0&&n.logger.warn(`${$}/${E.length} batch(es) failed for ${t} (backend ${a}); suggestions are partial`),k&&C.length===0&&n.logger.warn(`No usable LLM output for ${t} (backend ${a})`);let K=C.filter(r=>r.score>=ne).sort((r,c)=>c.score-r.score).slice(0,Z),_=d.get(t),W=l===null||l===t;l===null&&(l=t);let N=u(r=>r.topProjectId?r.topProjectId===_:W,"placeHere"),F=m.filter(N),{nominated:L,unmeasurable:G}=await ie(F,t,R);L>0&&n.logger.info(`${t}: ${L} removal candidate(s) nominated for randomised withholding instead of the feed`);let h=[...K.map(r=>({instructionId:r.instructionId,score:r.score,reason:r.reason,kind:"add"})),...G.map(({topProjectId:r,...c})=>({...c,kind:"remove"})),...p.filter(N).map(({estimatedTokens:r,topProjectId:c,...T})=>({...T,kind:"trim"}))];if(h.length===0){n.logger.info(`Nothing to suggest for ${t}`);continue}await R("/api/instruction-suggestions/batch-upsert",{projectPath:t,..._?{projectId:_}:{},suggestions:h}),n.logger.info(`${t}: ${h.filter(r=>r.kind==="add").length} add + ${h.filter(r=>r.kind==="remove").length} remove + ${h.filter(r=>r.kind==="trim").length} trim`);for(let r of h)r.kind!=="add"&&I.add(r.instructionId);let Y=new Set(G.map(r=>r.instructionId));for(let r of F)Y.has(r.instructionId)||I.add(r.instructionId);M++}catch(t){n.logger.warn(`Failed to score ${e}: ${t instanceof Error?t.message:String(t)}`)}let j=[...m.filter(e=>!I.has(e.instructionId)),...p.filter(e=>!I.has(e.instructionId)).map(({estimatedTokens:e,...t})=>t)];if(j.length>0&&l)try{let e=new Set(p.map(t=>t.instructionId));await R("/api/instruction-suggestions/batch-upsert",{projectPath:l,...d.get(l)?{projectId:d.get(l)}:{},suggestions:j.map(({topProjectId:t,...f})=>({...f,kind:e.has(f.instructionId)?"trim":"remove"}))}),n.logger.info(`Orphan sweep: ${j.length} proposal(s) whose project was not scored this run placed on ${l}`)}catch(e){n.logger.warn(`Orphan sweep failed: ${e instanceof Error?e.message:String(e)}`)}let S=le();if(S==="unknown")n.logger.warn("Skills registry unreadable or has no usable generatedAt; leaving suggestion staleness unchanged");else try{await R("/api/instruction-suggestions/mark-stale",{stale:S==="stale"}),S==="stale"?n.logger.warn("Skills registry is stale (>48h); marked catalog-skill suggestions stale"):n.logger.info("Skills registry is fresh; cleared staleness on catalog-skill suggestions")}catch{}n.logger.info(`Done: scored ${M}/${i.length} projects`)},"cronSuggestInstructions");export{Q as a,ae as b,ie as c,ce as d,Re as e};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as v,b as u,e as y,g as d}from"../../chunk-
|
|
1
|
+
import{a as v,b as u,e as y,g as d}from"../../chunk-EZHL527S.js";import{a as h}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import"../../chunk-PZNWH4VQ.js";import{a as p}from"../../chunk-ZLLER3HP.js";import{Args as k,Flags as o}from"@oclif/core";import{existsSync as T}from"node:fs";import{homedir as P}from"node:os";import{join as I}from"node:path";var A=I(P(),".gemini","antigravity-ide","brain"),g=class x extends h{static{p(this,"AntigravityBackfill")}static description="Backfill historical events from an Antigravity conversation transcript into a RuleMetric session. Useful for seeding a conversation that existed before hooks were installed \u2014 the live hook intentionally only captures forward.";static examples=["<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --session 158db9aa-68ee-43fc-961b-f3a180578694","<%= config.bin %> antigravity backfill 26fd215d-f43b-4ea5-b177-dc2c0e696f97 --dry-run"];static args={conversationId:k.string({description:"Antigravity conversationId (UUID) \u2014 the directory name under ~/.gemini/antigravity-ide/brain/",required:!0})};static flags={session:o.string({char:"s",description:"RuleMetric session UUID to POST events into. If omitted, resolved from the hook tmp file ($TMPDIR/rulemetric/<conversationId>) \u2014 fails if neither is present."}),transcript:o.string({description:"Path to the transcript.jsonl file. Defaults to ~/.gemini/antigravity-ide/brain/<conversationId>/.system_generated/logs/transcript.jsonl"}),"after-step":o.integer({description:"Only emit records with step_index > this value. Default: read from existing state file, else -1 (everything)."}),limit:o.integer({description:"Cap on the number of records to process this run."}),"dry-run":o.boolean({default:!1,description:"Classify records without POSTing. Reports counts only."}),"save-state":o.boolean({default:!0,allowNo:!0,description:"After backfill, persist the highest step_index so the live hook resumes from there."})};async run(){let{args:b,flags:e}=await this.parse(x),t=b.conversationId;d.loadEnvFile(),process.env.RULEMETRIC_API_URL||this.error("RULEMETRIC_API_URL is not set. Configure it via env or ~/.config/rulemetric/env.");let l=e.transcript??I(A,t,".system_generated","logs","transcript.jsonl");T(l)||this.error(`Transcript not found: ${l}`);let m=e.session??d.resolveRwSessionId(t);m||this.error(`No RuleMetric session resolved. Pass --session <uuid>, or run the Antigravity hook at least once so $TMPDIR/rulemetric/${t} is populated.`);let n=e["after-step"];n===void 0&&(n=d.load(t)?.lastStepIdx??-1);let i=v(l,n);e.limit!==void 0&&i.length>e.limit&&(i=i.slice(0,e.limit));let R=u(l);if(this.log(`Conversation ${t}: transcript max step = ${R}, after-step = ${n}, records to process = ${i.length}`),i.length===0){this.log("Nothing to backfill.");return}if(e["dry-run"]){let r=0,a=0,c={};for(let S of i){let f=(await import("../../lib/antigravity-transcript.js")).classifyRecord(S,0);f?(r++,c[f.eventType]=(c[f.eventType]??0)+1):a++}this.log(`Dry run: would emit ${r}, skip ${a}. By eventType: ${JSON.stringify(c)}`);return}let w=Date.now(),s=await y(i,m,t,n,{onProgress:p(({attempted:r,total:a})=>{(r%100===0||r===a)&&process.stderr.write(` \u2026${r}/${a}
|
|
2
2
|
`)},"onProgress")}),$=((Date.now()-w)/1e3).toFixed(1);this.log(`Backfill complete in ${$}s. attempted=${s.attempted} emitted=${s.emitted} skipped=${s.skipped} failed=${s.failed} highestStepIdx=${s.highestStepIdx}`),e["save-state"]?(d.save(t,{lastStepIdx:s.highestStepIdx}),this.log(`State saved \u2192 live hook will resume from step_index > ${s.highestStepIdx}.`)):this.log("State NOT saved (--no-save-state). Live hook will re-emit any new records from after-step.")}};export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"../../chunk-
|
|
1
|
+
import{a as n}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import{f as r}from"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import{i as o,l as s}from"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import*as c from"node:path";import{Flags as l}from"@oclif/core";var t=class g extends n{static{a(this,"AuthCreateKey")}static description="Create a long-lived API key for CLI and proxy authentication";static examples=['<%= config.bin %> auth create-key --name "laptop"','<%= config.bin %> auth create-key --name "ci token" --no-save'];static flags={name:l.string({char:"n",description:"Name for this key",required:!0}),save:l.boolean({char:"s",description:"Save key to ~/.config/rulemetric/env for hooks/proxy",default:!0,allowNo:!0})};async run(){let{flags:i}=await this.parse(g),e=await r("/api/auth/api-keys",{name:i.name});this.log(""),this.log("API key created successfully:"),this.log(""),this.log(` Name: ${e.name}`),this.log(` Key: ${e.key}`),this.log(` Prefix: ${e.keyPrefix}`),this.log(""),this.warn("Save this key now \u2014 it will not be shown again."),i.save&&(o(e.key,process.env.RULEMETRIC_API_URL),this.log(""),this.log(`Key saved to ${c.join(s(),"env")} (RULEMETRIC_API_KEY)`),this.log("Hooks and proxy will use this key automatically."))}};export{t as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as f}from"../../chunk-
|
|
1
|
+
import{a as f}from"../../chunk-G3HODHFN.js";import{a as w}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import{c}from"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import{b as n}from"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import{b as r,d as a}from"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import{b as m,d,h as u,i as g}from"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{Flags as p}from"@oclif/core";var h=class y extends w{static{l(this,"AuthLogin")}static description="Log in to RuleMetric";static examples=["<%= config.bin %> auth login","<%= config.bin %> auth login -e user@example.com"];static flags={email:p.string({char:"e",description:"Email address"}),password:p.string({char:"p",description:"Password (for non-interactive use)"}),"api-key":p.string({description:"Authenticate with an API key from https://rulemetric.com/connect (required for Google/GitHub sign-ins, which have no password)",exclusive:["password"]})};async run(){let{flags:s}=await this.parse(y);if(s["api-key"]){await this.loginWithApiKey(s["api-key"]);return}let e=s.email,t=s.password;if(!e||!t){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p, or set RULEMETRIC_API_KEY (create a key at https://rulemetric.com/connect).");let{input:o,password:k}=await import("@inquirer/prompts");this.log("Signed up with Google or GitHub? You have no password \u2014 press Ctrl-C and run:"),this.log(" rulemetric auth login --api-key <key> (create one at https://rulemetric.com/connect)"),this.log(""),e||(e=await o({message:"Email:"})),t||(t=await k({message:"Password:"}))}let i;try{i=await a("/auth/login",{method:"POST",body:{email:e,password:t},timeoutMs:2e4})}catch(o){throw o instanceof r&&o.statusCode===401&&this.error(`Invalid email or password.
|
|
2
2
|
|
|
3
3
|
If you signed up with Google or GitHub, you have no password \u2014 that is why this cannot work. Create an API key at https://rulemetric.com/connect, then run:
|
|
4
4
|
rulemetric auth login --api-key <key>`),o}let v=i.expiresAt??new Date(Date.now()+3600*1e3).toISOString();d({accessToken:i.accessToken,refreshToken:i.refreshToken,expiresAt:v,email:i.email}),u(i.accessToken,process.env.RULEMETRIC_API_URL),await n(),await f(this.log.bind(this),this.warn.bind(this),this.config.version),c("auth_login",{},this.config.version),this.log(`Logged in as ${i.email}`)}async loginWithApiKey(s){let e=s.trim();e||this.error("Empty --api-key. Create one at https://rulemetric.com/connect"),process.env.RULEMETRIC_API_KEY=e;try{await a("/api/setup/status",{timeoutMs:2e4})}catch(t){throw delete process.env.RULEMETRIC_API_KEY,t instanceof r&&(t.statusCode===401||t.statusCode===403)&&this.error("That API key was rejected. Check you copied it whole (it is shown only once at creation) or mint a new one at https://rulemetric.com/connect"),t}g(e,process.env.RULEMETRIC_API_URL),m(),await n(),c("auth_login",{method:"api_key"},this.config.version),this.log(`Authenticated with API key ${e.slice(0,11)}...`),this.log("Verify any time with: rulemetric auth status")}};export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../../chunk-
|
|
1
|
+
import{a as s}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import{f as i,j as r}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";var e=class t extends s{static{o(this,"AuthLogout")}static description="Log out of RuleMetric";static examples=["<%= config.bin %> auth logout"];async run(){await this.parse(t),i(),r(),this.log("Logged out successfully.")}};export{e as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k}from"../../chunk-
|
|
1
|
+
import{a as k}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import{e as n,i as c}from"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import"../../chunk-PZNWH4VQ.js";import{a as s}from"../../chunk-ZLLER3HP.js";import{Args as y}from"@oclif/core";var a=class m extends k{static{s(this,"AuthRevokeKey")}static description="Revoke an API key (run with no argument to list active keys)";static examples=["<%= config.bin %> auth revoke-key","<%= config.bin %> auth revoke-key rm_abc12345",'<%= config.bin %> auth revoke-key "my-laptop (auto)"'];static args={id:y.string({description:"API key ID, prefix (rm_xxxxxxxx), or name"})};async run(){let{args:o}=await this.parse(m),r=(await n("/api/auth/api-keys")).filter(e=>!e.revokedAt);if(!o.id){if(r.length===0){this.log("No active API keys.");return}this.log(`Active API keys \u2014 pass an id, prefix, or name to revoke one:
|
|
2
2
|
`);for(let e of r)this.log(` ${e.id} ${e.keyPrefix}... ${e.name}`);return}let i=o.id,t=r.filter(e=>e.id===i||e.name===i||i.startsWith("rm_")&&i.startsWith(e.keyPrefix));t.length===0&&this.error(`No active API key matches "${i}". Run \`rulemetric auth revoke-key\` with no argument to list keys.`),t.length>1&&this.error(`"${i}" matches ${t.length} keys \u2014 use the exact key ID:
|
|
3
3
|
`+t.map(e=>` ${e.id} ${e.keyPrefix}... ${e.name}`).join(`
|
|
4
4
|
`)),await c(`/api/auth/api-keys/${t[0].id}`),this.log(`API key ${t[0].keyPrefix}... ("${t[0].name}") revoked.`)}};export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g}from"../../chunk-
|
|
1
|
+
import{a as g}from"../../chunk-G3HODHFN.js";import{a as h}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import{c as d}from"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import{b as l}from"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import{b as m,d as p}from"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import{d as n,h as c}from"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as u}from"@oclif/core";var t=class f extends h{static{o(this,"AuthSignup")}static description="Create a RuleMetric account from the CLI";static examples=["<%= config.bin %> auth signup","<%= config.bin %> auth signup -e user@example.com"];static flags={email:u.string({char:"e",description:"Email address"}),password:u.string({char:"p",description:"Password (min 8 chars; for non-interactive use)"})};async run(){let{flags:a}=await this.parse(f),i=a.email,r=a.password;if(!i||!r){process.stdin.isTTY||this.error("Missing credentials in a non-interactive shell. Pass --email/-e and --password/-p.");let{input:s,password:v}=await import("@inquirer/prompts");i||(i=await s({message:"Email:"})),r||(r=await v({message:"Password (min 8 chars):"}))}let e;try{e=await p("/auth/signup",{method:"POST",body:{email:i,password:r},timeoutMs:2e4})}catch(s){throw s instanceof m&&s.statusCode===409&&this.error(`An account with ${i} already exists. Run: rulemetric auth login -e ${i}`),s}if(e.confirmationRequired||!e.accessToken||!e.refreshToken){this.log(`Account created for ${e.email}.`),this.log("Check your email and click the confirmation link, then run:"),this.log(` rulemetric auth login -e ${e.email}`);return}let w=e.expiresAt??new Date(Date.now()+3600*1e3).toISOString();n({accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:w,email:e.email}),c(e.accessToken,process.env.RULEMETRIC_API_URL),await l(),await g(this.log.bind(this),this.warn.bind(this),this.config.version),d("auth_signup",{},this.config.version),this.log(`Signed up and logged in as ${e.email}`)}};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"../../chunk-W2MV25SB.js";import{a as g}from"../../chunk-
|
|
1
|
+
import{a as c}from"../../chunk-W2MV25SB.js";import{a as g}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import{a,e as l,l as t}from"../../chunk-PZNWH4VQ.js";import{a as r}from"../../chunk-ZLLER3HP.js";import*as u from"node:path";var o=class h extends g{static{r(this,"AuthStatus")}static description="Show current authentication status";static examples=["<%= config.bin %> auth status"];async run(){await this.parse(h);let e=l(),i=process.env.RULEMETRIC_API_KEY,s=a().apiKey;if(i||s){let m=i||s,p=i?"RULEMETRIC_API_KEY env var":u.join(t(),"env");this.log(`Authenticated via API key ${m.slice(0,11)}... (${p})`),e&&this.log(`Logged in as: ${e.email}`),this.log(`Config: ${t()}`);return}if(!e){this.log("Not logged in. Run `rulemetric auth login` to authenticate.");return}let n=new Date(e.expiresAt).getTime();if(Number.isNaN(n)||Date.now()>=n){this.log("Session expired. Run `rulemetric auth login` to re-authenticate.");return}this.log(`Logged in as: ${e.email}`),this.log(`Session expires: ${c(e.expiresAt)}`),this.log(`Config: ${t()}`)}};export{o as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as f,b as k,c as S,d as x,e as R,f as n,g as y}from"../../chunk-SHYP27B7.js";import{b as C,c as w,f as v,g as b}from"../../chunk-QXPYGN7I.js";import{a as u}from"../../chunk-
|
|
1
|
+
import{a as f,b as k,c as S,d as x,e as R,f as n,g as y}from"../../chunk-SHYP27B7.js";import{b as C,c as w,f as v,g as b}from"../../chunk-QXPYGN7I.js";import{a as u}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import{l as m}from"../../chunk-PZNWH4VQ.js";import{a as h}from"../../chunk-ZLLER3HP.js";import{existsSync as O}from"node:fs";import{Flags as c}from"@oclif/core";var g=class E extends u{static{h(this,"CaptureScope")}static description="Show or set which projects RuleMetric captures \u2014 the Codex sweep and hook-driven sessions each have their own scope";static examples=["<%= config.bin %> <%= command.id %>","<%= config.bin %> <%= command.id %> --add ~/work/client-a --add ~/work/client-b","<%= config.bin %> <%= command.id %> --tool hooks --add ~/work/client-a","<%= config.bin %> <%= command.id %> --tool hooks --off","<%= config.bin %> <%= command.id %> --remove ~/work/client-a","<%= config.bin %> <%= command.id %> --off","<%= config.bin %> <%= command.id %> --all"];static flags={tool:c.string({description:'Which capture path to edit: "codex" (the worker transcript sweep, the default) or "hooks" (Claude Code / Cursor / Copilot / Antigravity hook sessions).',options:["codex","hooks"],default:"codex"}),add:c.string({description:"Capture sessions under this path (repeatable). Implies an allowlist.",multiple:!0}),remove:c.string({description:"Stop capturing under this path (repeatable).",multiple:!0}),off:c.boolean({description:"Turn this capture path off entirely.",exclusive:["all"]}),all:c.boolean({description:"Capture every project (the default).",exclusive:["off"]}),clear:c.boolean({description:"Remove this scope, restoring the default."})};async run(){let{flags:o}=await this.parse(E),s=m(),d=f(s);if(!((o.add?.length??0)>0||(o.remove?.length??0)>0||o.off||o.all||o.clear)){await this.show(s,d);return}for(let t of[...o.add??[],...o.remove??[]])R(t)||this.error(`Not an absolute path: ${t}
|
|
2
2
|
Use an absolute path or ~/\u2026 \u2014 relative paths cannot be matched against a session's cwd.`);for(let t of o.add??[]){let a=x(t);O(a)||this.warn(`${a} does not exist yet \u2014 added anyway, but nothing will match until it does.`)}let e;try{e=k(s)}catch(t){o.clear||this.error(t instanceof Error?t.message:String(t));let a=y(s);this.warn(`${f(s)} was not valid JSON \u2014 saved it to ${a} and starting fresh.`),e={}}let i=o.tool??"codex",r=void 0,l=!1;if(o.clear&&({config:e}=n(e,{op:"clear"},r,i)),o.off&&({config:e}=n(e,{op:"mode",mode:"off"},r,i)),o.all&&({config:e}=n(e,{op:"mode",mode:"all"},r,i)),o.remove?.length){let t=n(e,{op:"remove",roots:o.remove},r,i);e=t.config,l=t.emptiedToOff}o.add?.length&&({config:e}=n(e,{op:"add",roots:o.add},r,i)),S(s,e),l&&(this.log(`Removed the last root \u2014 ${i==="hooks"?"hook":"Codex"} capture is now OFF rather than silently capturing everything.`),this.log("Use --all to go back to capturing every project.")),await this.show(s,d),this.log(""),this.log(i==="hooks"?"Takes effect on the next hook fire. No restart needed.":"Takes effect on the next sweep (within ~30s). No restart needed.")}async show(o,s){let d=await C({configDir:o}),p=await w({configDir:o}),e=h((i,r,l,t)=>{if(this.log(`${i}: ${l}`),r.roots.length)for(let a of r.roots)this.log(` \u2022 ${a}`);r.error&&(this.log(" This scope is FAILING CLOSED \u2014 nothing is being captured on this path."),this.log(` Fix the file, or run \`rulemetric capture scope ${i==="Hook capture"?"--tool hooks ":""}--clear\` to start over.`)),r.source==="env"&&this.log(` Set by environment variable, which outranks the config file (${t}).`)},"print");e("Codex capture",d,v(d),"RULEMETRIC_CODEX_CAPTURE / RULEMETRIC_CODEX_ROOTS"),e("Hook capture",p,b(p),"RULEMETRIC_HOOKS_CAPTURE / RULEMETRIC_HOOKS_ROOTS"),this.log(`Config: ${s}`)}};export{g as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as g,b as d,c as p}from"../../chunk-W2MV25SB.js";import{a as c}from"../../chunk-
|
|
1
|
+
import{a as g,b as d,c as p}from"../../chunk-W2MV25SB.js";import{a as c}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Flags as i}from"@oclif/core";var o=class m extends c{static{a(this,"Catalog")}static description="Browse the org instruction catalog";static flags={badge:i.string({description:"Filter by badge",options:["recommended","required"]}),scope:i.string({description:"Filter by scope",options:["org","team"]}),search:i.string({description:"Search by name or description"})};async run(){let{flags:e}=await this.parse(m);this.requireAuth();let s=new URLSearchParams;e.badge&&s.set("badge",e.badge),e.scope&&s.set("scope",e.scope),e.search&&s.set("search",e.search);let r=await n(`/api/catalog?${s.toString()}`);if(r.length===0){this.log("No instructions found in catalog.");return}for(let t of r){let l=t.badge?` [${t.badge}]`:"",f=t.tags?.length?` (${t.tags.join(", ")})`:"";this.log(` ${d(t.name,40)} \u2014 ${p(t.scope)}${l} v${t.version}${f} ${g(t.updatedAt)}`)}this.log(`
|
|
2
2
|
${r.length} instruction(s) found.`)}};export{o as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as i}from"../../chunk-
|
|
1
|
+
import{a as i}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import{f as n}from"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import"../../chunk-PZNWH4VQ.js";import{a as t}from"../../chunk-ZLLER3HP.js";import{Args as c}from"@oclif/core";var o=class s extends i{static{t(this,"CatalogRecommend")}static description="Get AI-powered instruction recommendations for a project";static args={projectId:c.string({description:"ID of the project",required:!0})};async run(){let{args:a}=await this.parse(s);this.requireAuth(),this.log(`Analyzing project and generating recommendations...
|
|
2
2
|
`);let r=await n(`/api/projects/${a.projectId}/recommendations`,{});if(r.error&&this.warn(`Note: ${r.error}`),r.recommendations.length===0){this.log("No recommendations found.");return}for(let e of r.recommendations)this.log(` ${(e.score*100).toFixed(0)}% \u2014 ${e.instructionId}`),this.log(` ${e.reason}
|
|
3
3
|
`)}};export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"../../chunk-
|
|
1
|
+
import{a as o}from"../../chunk-APXQLQZY.js";import{a as n}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{printTable as t}from"@oclif/table";var a=class s extends n{static{i(this,"CronsList")}static description="List manually-runnable maintenance tasks";static examples=["<%= config.bin %> crons list"];async run(){await this.parse(s),t({data:o.map(e=>({Name:e.name,"Scheduled by":e.scheduledBy,Description:e.description})),columns:["Name","Scheduled by","Description"]}),this.log(""),this.log("Scheduled crons run in Supabase pg_cron \u2014 audit them with:"),this.log(` psql "$DATABASE_URL" -c 'select jobname, schedule, active from cron.job;'`),this.log("Run any task above on demand with: rulemetric crons run <name>")}};export{a as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"../../chunk-
|
|
1
|
+
import{a as u}from"../../chunk-APXQLQZY.js";import{a as c}from"../../chunk-DSJNZWCZ.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-OOFGV7EX.js";import"../../chunk-VYZKKSX4.js";import"../../chunk-YSLKV4XC.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-UGACB66X.js";import"../../chunk-WMIUFMDI.js";import"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{Args as g,Flags as f}from"@oclif/core";var i=class m extends c{static{l(this,"CronsRun")}static description="Run a maintenance task synchronously, right now";static examples=["<%= config.bin %> crons run cron_check_changelog","<%= config.bin %> crons run cron_suggest_instructions --quiet"];static args={name:g.string({description:"Task name (run `rulemetric crons list` to see all)",required:!0})};static flags={quiet:f.boolean({char:"q",description:"Suppress per-line log output; print summary only"})};async run(){let{args:s,flags:d}=await this.parse(m);this.requireAuth();let n=u.find(e=>e.name===s.name);n||this.error(`Unknown task: ${s.name}
|
|
2
2
|
Run \`rulemetric crons list\` to see available tasks.`);let o;try{({runManualTask:o}=await import("../../lib/manual-tasks.js"))}catch(e){let r=e?.code;throw(r==="ERR_MODULE_NOT_FOUND"||r==="MODULE_NOT_FOUND")&&this.error("`crons run` needs the worker runtime, which isn't available in this install.\nThese maintenance tasks connect to the database directly \u2014 run them from a full RuleMetric checkout with DATABASE_URL and the worker dependencies installed."),e}this.log(`\u25B6 Running ${n.name} \u2026`);let h=Date.now(),t=await o(s.name);if(!d.quiet)for(let e of t.logs){let r=e.level==="error"||e.level==="warn"?`[${e.level}]`:"";this.log(` ${r} ${e.message}`)}let a=((t.durationMs??Date.now()-h)/1e3).toFixed(1);t.ok?this.log(`\u2713 ${n.name} completed in ${a}s (${t.logs.length} log line${t.logs.length===1?"":"s"})`):this.error(`\u2717 ${n.name} failed after ${a}s: ${t.error}`)}};export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"../chunk-
|
|
1
|
+
import{a as o}from"../chunk-DSJNZWCZ.js";import"../chunk-IZTIYR5Q.js";import"../chunk-OOFGV7EX.js";import"../chunk-VYZKKSX4.js";import"../chunk-YSLKV4XC.js";import"../chunk-3AV3GTMP.js";import"../chunk-UGACB66X.js";import"../chunk-WMIUFMDI.js";import"../chunk-PZNWH4VQ.js";import{a as i}from"../chunk-ZLLER3HP.js";import{Flags as r}from"@oclif/core";var a=class s extends o{static{i(this,"Dashboard")}static description="Interactive TUI dashboard showing session analytics, outcomes, friction, and insights";static examples=["<%= config.bin %> dashboard","<%= config.bin %> dashboard --period 30days","<%= config.bin %> dashboard --launcher"];static flags={period:r.string({char:"p",default:"week",options:["today","week","30days","month","all"],description:"Initial time period"}),launcher:r.boolean({char:"l",default:!1,description:"Open the launcher overlay immediately"})};async run(){let{flags:e}=await this.parse(s),{renderDashboard:t}=await import("../dashboard/Dashboard.js");await t(e.period,{openLauncher:e.launcher})}};export{a as default};
|