@rulemetric/cli 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-command.js +1 -1
- package/dist/{chunk-WLLIFRRE.js → chunk-2EXQM3UF.js} +1 -1
- package/dist/chunk-2RZDFKX4.js +1 -0
- package/dist/{chunk-NSO2EBYE.js → chunk-2WRP6ZJF.js} +1 -1
- package/dist/chunk-35NZJWFC.js +4 -0
- package/dist/{chunk-3ZHBOILE.js → chunk-45CCW25C.js} +1 -1
- package/dist/{chunk-NMCQ7JZZ.js → chunk-52RILE5M.js} +1 -1
- package/dist/{chunk-B45MMFZ4.js → chunk-5O62P6KC.js} +6 -6
- package/dist/chunk-6WX3AXMI.js +1 -0
- package/dist/{chunk-ENW5SUQJ.js → chunk-6XCD343D.js} +1 -1
- package/dist/chunk-6Z4JNHBO.js +1 -0
- package/dist/{chunk-MJLW5KN2.js → chunk-75H3CKWA.js} +1 -1
- package/dist/{chunk-XAGNGQL3.js → chunk-7CQBFCHP.js} +1 -1
- package/dist/{chunk-ZFEDOPRU.js → chunk-AEIKPNLG.js} +1 -1
- package/dist/{chunk-XCN2YPWI.js → chunk-ANPGOUIO.js} +1 -1
- package/dist/chunk-B56GMANB.js +1 -0
- package/dist/{chunk-CXENLSMR.js → chunk-B5FBLLKT.js} +1 -1
- package/dist/{chunk-KIQK7NVF.js → chunk-CLPIN7TY.js} +1 -1
- package/dist/{chunk-4LVSD2XZ.js → chunk-DRX65ZLX.js} +1 -1
- package/dist/{chunk-5VWVQCNR.js → chunk-E5FI5YHO.js} +1 -1
- package/dist/{chunk-7MQZPDDZ.js → chunk-E6O2IFOK.js} +1 -1
- package/dist/{chunk-BOYWPUV2.js → chunk-EA3X4TAE.js} +1 -1
- package/dist/{chunk-AZWY2DOT.js → chunk-EBGVDX3Z.js} +1 -1
- package/dist/{chunk-FGGESTXG.js → chunk-EYRM7BT4.js} +1 -1
- package/dist/chunk-FD272ZXG.js +2 -0
- package/dist/chunk-FKUFJWII.js +1 -0
- package/dist/chunk-G2MRNA45.js +1 -0
- package/dist/{chunk-C3XWDYZJ.js → chunk-G2UGWEMO.js} +1 -1
- package/dist/chunk-GRTEWHXU.js +5 -0
- package/dist/{chunk-RRBFKVCI.js → chunk-HEO56SKT.js} +1 -1
- package/dist/chunk-HRU6WGCG.js +1 -0
- package/dist/{chunk-MHLHLJ5T.js → chunk-I2U5GNNM.js} +2 -2
- package/dist/{chunk-AZRGURHR.js → chunk-ICULHHNZ.js} +1 -1
- package/dist/{chunk-BRYURAUN.js → chunk-ID47WFUP.js} +1 -1
- package/dist/chunk-IQOBKWVY.js +5 -0
- package/dist/chunk-JE2JX7IJ.js +4 -0
- package/dist/chunk-JVTSJFFI.js +1 -0
- package/dist/{chunk-D7L7IMJQ.js → chunk-K2PI3OGV.js} +1 -1
- package/dist/chunk-K4LO27GG.js +1 -0
- package/dist/chunk-KCX2YDC3.js +1 -0
- package/dist/{chunk-5LTJNYCP.js → chunk-KTLRSRHF.js} +1 -1
- package/dist/{chunk-K65DDLTZ.js → chunk-LKOUL3IF.js} +1 -1
- package/dist/{chunk-GWQ24FQP.js → chunk-LQRXWLFJ.js} +1 -1
- package/dist/{chunk-A2JFQUDW.js → chunk-NI6RDOZ5.js} +1 -1
- package/dist/{chunk-JCZOEIL7.js → chunk-NJKPUZNM.js} +1 -1
- package/dist/{chunk-PPQFN62M.js → chunk-NN4M476J.js} +1 -1
- package/dist/chunk-NX3PF3EQ.js +1 -0
- package/dist/{chunk-7J7H7YFQ.js → chunk-O662MWOR.js} +1 -1
- package/dist/{chunk-UROUVE3D.js → chunk-OHMVGDWQ.js} +1 -1
- package/dist/{chunk-RQBN7WNS.js → chunk-OLOECA5V.js} +7 -7
- package/dist/{chunk-IYX65N6T.js → chunk-ONDOPTSL.js} +1 -1
- package/dist/chunk-ONSRPEUQ.js +7 -0
- package/dist/{chunk-UQJNUESP.js → chunk-OT7ZUHJF.js} +1 -1
- package/dist/{chunk-CAQLSYOK.js → chunk-PCSSIYH6.js} +1 -1
- package/dist/chunk-PD4BUQ2X.js +1 -0
- package/dist/{chunk-WSUKOU3X.js → chunk-PRC5N4NB.js} +1 -1
- package/dist/chunk-Q37D6V2G.js +2 -0
- package/dist/chunk-Q42RXJ4R.js +1 -0
- package/dist/{chunk-3EZZGA72.js → chunk-RFLO7L5X.js} +1 -1
- package/dist/{chunk-QRKMRG6W.js → chunk-RR5EE23Q.js} +1 -1
- package/dist/{chunk-5U5SHJJA.js → chunk-RYMQMJ7O.js} +1 -1
- package/dist/chunk-S7ZQTZNB.js +3 -0
- package/dist/{chunk-LELSVLNK.js → chunk-SFZSHNZZ.js} +1 -1
- package/dist/{chunk-7N55TWYQ.js → chunk-T7DAU6DV.js} +1 -1
- package/dist/{chunk-HNPC5U3C.js → chunk-TUSFCQBL.js} +1 -1
- package/dist/chunk-UFRJ75FW.js +1 -0
- package/dist/{chunk-I2FPXRA6.js → chunk-VGBATQZ3.js} +1 -1
- package/dist/{chunk-NAS7FIGM.js → chunk-WLLSWFAJ.js} +1 -1
- package/dist/chunk-WUDHDZOG.js +1 -0
- package/dist/{chunk-A6JUIZ3H.js → chunk-WYDRKFXO.js} +1 -1
- package/dist/{chunk-YLEXR62G.js → chunk-XPVI6H2L.js} +6 -6
- package/dist/{chunk-IPNBW7ZW.js → chunk-XQEI7NOC.js} +1 -1
- package/dist/{chunk-EKTNI6RV.js → chunk-Y6VBAURK.js} +1 -1
- package/dist/chunk-YMIO3CVV.js +2 -0
- package/dist/{chunk-RAMQVEJB.js → chunk-YRGNBYZZ.js} +1 -1
- package/dist/{chunk-TQFHRD5B.js → chunk-Z7LBSVG3.js} +1 -1
- package/dist/{chunk-ANLPPIMS.js → chunk-ZFIGOHQ6.js} +1 -1
- package/dist/chunk-ZVCKDNBT.js +1 -0
- 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 +3 -3
- package/dist/commands/evals/auto-run.js +1 -5
- package/dist/commands/evals/benchmark.js +1 -1
- package/dist/commands/evals/compare.js +1 -31
- package/dist/commands/evals/create.js +1 -1
- package/dist/commands/evals/optimize-description.js +1 -59
- package/dist/commands/evals/optimize.js +1 -5
- package/dist/commands/evals/refine-cases.js +1 -1
- package/dist/commands/evals/run.js +1 -3
- package/dist/commands/evals/validate-judge.js +1 -1
- package/dist/commands/experiments/enroll.js +1 -0
- 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/resume-scoped-outcomes.js +1 -1
- package/dist/commands/research/tail-transcript.js +1 -1
- package/dist/commands/service/install.js +37 -37
- package/dist/commands/service/status.js +1 -1
- package/dist/commands/service/uninstall.js +1 -1
- package/dist/commands/service/updates.js +1 -0
- 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/dashboard/panels/measurement.js +1 -1
- package/dist/dashboard/telemetry.js +1 -1
- package/dist/{dist-ZJY72TUD.js → dist-TNM2RNPT.js} +1 -1
- package/dist/lib/active-org-refresh.js +1 -1
- package/dist/lib/agent-loop.js +1 -1
- package/dist/lib/agent-presence.js +1 -1
- package/dist/lib/antigravity-transcript.js +1 -1
- package/dist/lib/api-client.js +1 -1
- package/dist/lib/case-refinement-policy.js +1 -0
- package/dist/lib/discovery-evidence.js +1 -0
- package/dist/lib/discovery-repository.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-case-generator.js +1 -1
- package/dist/lib/eval-compare.js +1 -1
- package/dist/lib/eval-conversation-handler.js +1 -1
- package/dist/lib/eval-quota-gate.js +1 -1
- package/dist/lib/eval-resume.js +1 -1
- package/dist/lib/eval-run-batch.js +1 -1
- package/dist/lib/eval-trigger-tester.js +8 -1
- package/dist/lib/insights/generation/installed-asks.js +1 -1
- package/dist/lib/insights/generation/project-evidence.js +1 -1
- package/dist/lib/insights/generation/quality-review.js +1 -1
- package/dist/lib/insights/nomination/nominate.js +1 -1
- package/dist/lib/instruction-proposer.js +16 -1
- package/dist/lib/instruction-restoration.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-training.js +1 -1
- package/dist/lib/jobs/handlers/cron-reconcile-attribution.js +1 -1
- 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/finalize-scoped-launch.js +1 -1
- package/dist/lib/jobs/handlers/harbor-ab.js +1 -1
- package/dist/lib/jobs/handlers/prepare-isolated-launch.js +1 -0
- package/dist/lib/jobs/handlers/prepare-suggestion-live.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-run-cleanup.js +1 -1
- package/dist/lib/jobs/handlers/process-session-goal.js +1 -1
- package/dist/lib/jobs/handlers/process-suggestion-adoption.js +1 -1
- package/dist/lib/jobs/handlers/process-suggestion-discovery.js +1 -1
- package/dist/lib/jobs/handlers/process-suggestion-eval.js +1 -1
- package/dist/lib/jobs/handlers/restore-instruction.js +1 -0
- package/dist/lib/jobs/shed-retry.js +1 -1
- package/dist/lib/judge-review-runner.js +1 -1
- package/dist/lib/llm-client.js +1 -1
- package/dist/lib/manual-tasks.js +1 -1
- package/dist/lib/projects/workspace/worktree.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/session-updates.js +1 -1
- package/dist/lib/setup-steps.js +1 -1
- package/dist/lib/study-result-store.js +1 -0
- package/dist/lib/suggestion-discovery.js +1 -1
- package/dist/lib/telemetry.js +1 -1
- package/dist/lib/terminal-target-heartbeat.js +1 -1
- package/dist/lib/transcript-sync.js +1 -1
- package/dist/lib/work-report.js +1 -1
- package/dist/lib/worker-updates.js +1 -0
- package/oclif.manifest.json +322 -199
- package/package.json +7 -7
- package/dist/chunk-2C7CFCMM.js +0 -1
- package/dist/chunk-647M2I2Y.js +0 -1
- package/dist/chunk-7OTOAC6C.js +0 -8
- package/dist/chunk-A6XQSO62.js +0 -4
- package/dist/chunk-AHLVY52I.js +0 -1
- package/dist/chunk-BDWQ6J4V.js +0 -1
- package/dist/chunk-BU3ZGLQG.js +0 -1
- package/dist/chunk-CJ2WSSHD.js +0 -1
- package/dist/chunk-DTTR4EUJ.js +0 -1
- package/dist/chunk-DZRBB34J.js +0 -16
- package/dist/chunk-FLJTAD2R.js +0 -1
- package/dist/chunk-G7V4ZZZ3.js +0 -1
- package/dist/chunk-GHUW7P55.js +0 -2
- package/dist/chunk-GYKYJJNF.js +0 -1
- package/dist/chunk-KFNFLMUR.js +0 -3
- package/dist/chunk-KOIFFSYW.js +0 -2
- package/dist/chunk-KR32Y5Q5.js +0 -1
- package/dist/chunk-L5ILEWHH.js +0 -1
- package/dist/chunk-LZPE6424.js +0 -5
- package/dist/chunk-MRQIYIQE.js +0 -1
- package/dist/chunk-NLUHMHPM.js +0 -1
- package/dist/chunk-NVOYP4HX.js +0 -1
- package/dist/chunk-P577DWWL.js +0 -1
- package/dist/chunk-PMMHMRFS.js +0 -1
- package/dist/chunk-R26SQ3BE.js +0 -5
- package/dist/chunk-RITL4NU3.js +0 -1
- package/dist/chunk-RWQG25JU.js +0 -1
- package/dist/chunk-YZQZD2E6.js +0 -1
- package/dist/chunk-ZJABRHIP.js +0 -1
- package/dist/lib/eval-accumulation.js +0 -1
- package/dist/lib/evolution-cost.js +0 -1
- package/dist/lib/evolution-enrolment.js +0 -1
- package/dist/lib/jobs/handlers/cron-instruction-evolution.js +0 -1
- package/dist/lib/jobs/handlers/process-memory-ab.js +0 -1
- package/dist/lib/optimize-compare.js +0 -1
|
@@ -1,59 +1 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
Generated ${r.length} trigger queries.`),this.log("Review and approve them at:"),this.log(` ${g}`),this.log(" (Triggers tab \u2192 click to review)"),this.log(`
|
|
3
|
-
Waiting for approval...`);let c=Date.now(),d=!1;for(;!d;){Date.now()-c>_&&this.error(`Timed out after ${_/6e4} minutes waiting for approval. Approve the trigger set at ${g} (Triggers tab) and re-run this command.`),await new Promise(h=>setTimeout(h,t["poll-interval"]));let p=(await y(`/api/eval-targets/${i.targetId}/trigger-evals?status=approved`)).find(h=>h.id===a.id);p&&(d=!0,r.length=0,r.push(...p.queries),this.log("Trigger queries approved!"))}let n=r.map((u,p)=>p).sort(()=>Math.random()-.5),s=Math.ceil(n.length*.6),o=n.slice(0,s),I=n.slice(s);await w(`/api/trigger-evals/${a.id}`,{trainIndices:o,testIndices:I});let x=o.map(u=>r[u]),D=I.map(u=>r[u]);this.log(`
|
|
4
|
-
Split: ${x.length} train, ${D.length} test`);let m=e.description,T=m,$=0;for(let u=1;u<=t["max-iterations"];u++){this.log(`
|
|
5
|
-
=== Iteration ${u} ===`),this.log(`Description: "${m}"`),this.log("Testing train set...");let p=await this.testQuerySet(x,e,m,t),h=S(p);this.log(`Train accuracy: ${(h*100).toFixed(1)}%`),this.printTriggerResults(p),this.log("Testing test set...");let O=await this.testQuerySet(D,e,m,t),f=S(O);if(this.log(`Test accuracy: ${(f*100).toFixed(1)}%`),await q("/api/optimization-runs",{evalTargetId:e.id,type:"description",iteration:u,inputVersion:e.version,trainScore:h,testScore:f,analysis:{description:m,trainResults:p.map(l=>({query:l.query,shouldTrigger:l.shouldTrigger,didTrigger:l.didTrigger,correct:l.correct})),testResults:O.map(l=>({query:l.query,shouldTrigger:l.shouldTrigger,didTrigger:l.didTrigger,correct:l.correct}))},status:"completed"}),f>$&&($=f,T=m),h>=1){this.log("Perfect train score. Stopping.");break}this.log("Generating improved description...");let M=p.filter(l=>!l.correct);m=await this.improveDescription(e,m,M,t)}this.log(`
|
|
6
|
-
=== Optimization Complete ===`),this.log(`Best test accuracy: ${($*100).toFixed(1)}%`),this.log(`
|
|
7
|
-
Before: "${e.description}"`),this.log(`After: "${T}"`),T!==e.description?(await w(`/api/eval-targets/${e.id}`,{description:T}),this.log(`
|
|
8
|
-
Description updated.`)):this.log(`
|
|
9
|
-
No improvement found. Description unchanged.`)}async generateTriggerQueries(i,t,e){let r="";try{let s=(await y("/api/sessions?limit=10")).map(o=>o.firstUserPrompt??o.lastMessagePreview??"").filter(o=>o.trim().length>0).slice(0,5);s.length>0&&(r=`
|
|
10
|
-
|
|
11
|
-
Real user prompts from recent sessions (use as inspiration for realistic queries):
|
|
12
|
-
`+s.map(o=>`- ${o}`).join(`
|
|
13
|
-
`))}catch{}let a=Math.ceil(t/2),g=t-a,c=`Generate ${t} trigger eval queries for a skill/instruction.
|
|
14
|
-
|
|
15
|
-
## Skill Name
|
|
16
|
-
${i.name}
|
|
17
|
-
|
|
18
|
-
## Skill Description
|
|
19
|
-
${i.description}
|
|
20
|
-
|
|
21
|
-
## Skill Content (first 1000 chars)
|
|
22
|
-
${i.content.slice(0,1e3)}
|
|
23
|
-
${r}
|
|
24
|
-
|
|
25
|
-
Generate ${a} should-trigger queries and ${g} should-not-trigger queries.
|
|
26
|
-
|
|
27
|
-
Rules:
|
|
28
|
-
- Queries must be realistic \u2014 what a real user would actually type
|
|
29
|
-
- Include concrete details (file paths, project names, specific problems)
|
|
30
|
-
- Vary length and formality
|
|
31
|
-
- Should-not-trigger queries should be near-misses (share keywords but need something different)
|
|
32
|
-
- Do NOT make should-not-trigger queries obviously irrelevant
|
|
33
|
-
|
|
34
|
-
Respond with ONLY a valid JSON array:
|
|
35
|
-
[
|
|
36
|
-
{"query": "realistic user prompt...", "should_trigger": true},
|
|
37
|
-
{"query": "another prompt...", "should_trigger": false}
|
|
38
|
-
]`,d=await b({prompt:c,timeout:e.timeout,model:e.model});try{let n=d.output.trim(),s=n.match(/```(?:json)?\s*([\s\S]*?)```/);s&&(n=s[1].trim());let o=n.match(/\[[\s\S]*\]/);return o&&(n=o[0]),JSON.parse(n)}catch{return[{query:`Help me use ${i.name}`,should_trigger:!0},{query:"Write a hello world program",should_trigger:!1}]}}async testQuerySet(i,t,e,r){let a=[];for(let g of i){let c=[];for(let s=0;s<r["runs-per-query"];s++){let o=await P({query:g.query,shouldTrigger:g.should_trigger,skillName:t.name,skillDescription:e,model:r.model,timeout:r.timeout,variant:s});c.push(o)}let n=c.filter(s=>s.didTrigger).length>r["runs-per-query"]/2;a.push({query:g.query,shouldTrigger:g.should_trigger,didTrigger:n,correct:n===g.should_trigger,confidence:c.reduce((s,o)=>s+o.confidence,0)/c.length,evidence:c[0].evidence})}return a}printTriggerResults(i){for(let t of i){let e=t.correct?"OK":"FAIL",r=t.shouldTrigger?"should trigger":"should NOT trigger",a=t.didTrigger?"triggered":"did NOT trigger";this.log(` [${e}] ${r} / ${a}: "${t.query.slice(0,60)}..."`)}}async improveDescription(i,t,e,r){let a=e.map(d=>`- ${d.shouldTrigger?"SHOULD trigger but DID NOT":"SHOULD NOT trigger but DID"}: "${d.query}"`).join(`
|
|
39
|
-
`),g=`You are optimizing a skill description for better triggering accuracy.
|
|
40
|
-
|
|
41
|
-
## Skill Name
|
|
42
|
-
${i.name}
|
|
43
|
-
|
|
44
|
-
## Current Description
|
|
45
|
-
${t}
|
|
46
|
-
|
|
47
|
-
## Skill Content (first 500 chars)
|
|
48
|
-
${i.content.slice(0,500)}
|
|
49
|
-
|
|
50
|
-
## Failures
|
|
51
|
-
${a}
|
|
52
|
-
|
|
53
|
-
Propose an improved description that:
|
|
54
|
-
- Fixes the trigger failures above
|
|
55
|
-
- Keeps the description concise but comprehensive
|
|
56
|
-
- Uses specific keywords and contexts for when to trigger
|
|
57
|
-
- Includes "Use PROACTIVELY" phrasing for important trigger contexts
|
|
58
|
-
|
|
59
|
-
Respond with ONLY the new description text (no JSON, no explanation, just the description string).`;return(await b({prompt:g,timeout:r.timeout,model:r.model})).output.trim().replace(/^["']|["']$/g,"")}};export{R as default};
|
|
1
|
+
import{a as t}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{Args as o,Flags as e}from"@oclif/core";var r=class extends t{static{i(this,"EvalOptimizeDescriptionCommand")}static description="Retired optimization workflow; use canonical experiments";static examples=["<%= config.bin %> evals run <target-id>"];static args={targetId:o.string({description:"Eval target ID",required:!0})};static flags={"max-iterations":e.integer({description:"Maximum optimization iterations",default:5}),model:e.string({description:"Model for trigger testing and improvement"}),queries:e.integer({description:"Number of trigger queries to generate",default:20}),"runs-per-query":e.integer({description:"Runs per query for reliability",default:3}),"poll-interval":e.integer({description:"Ms between approval polls",default:5e3}),timeout:e.integer({description:"Timeout per eval in ms",default:12e4})};async run(){this.error("This optimization workflow is retired. Use evals run for recorded experiments; review and edit target content explicitly.")}};export{r as default};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
=== Iteration ${l} ===`),this.log("Running train evals...");let b=await this.runEvalsOnTarget(t,u,e),p=this.computePassRate(b);if(this.log(`Train pass rate: ${(p*100).toFixed(1)}%`),p>=h){this.log(`Train score ${(p*100).toFixed(1)}% >= threshold ${(h*100).toFixed(0)}%. Stopping.`);let o=await this.runEvalsOnTarget(t,d,e),z=this.computePassRate(o);this.log(`Final test score: ${(z*100).toFixed(1)}%`),await m("/api/optimization-runs",{evalTargetId:t.id,type:"content",iteration:l,inputVersion:t.version,trainScore:p,testScore:z,analysis:{reason:"threshold_reached"},status:"completed"});break}this.log("Analyzing results...");let M=b.map(o=>({evalName:o.evalName,prompt:o.prompt,expectations:o.expectations,grading:o.grading})),a=await V({content:t.content,evalResults:M,model:e["analyzer-model"]??e.model,timeout:e.timeout});this.log(`
|
|
3
|
-
Assessment: ${a.overallAssessment}`),this.log(`Suggestions: ${a.suggestions.length}`);for(let o of a.suggestions)this.log(` - [${o.section}] ${o.reasoning}`);if(a.proposedContent===t.content){this.log("No changes proposed. Stopping."),await m("/api/optimization-runs",{evalTargetId:t.id,type:"content",iteration:l,inputVersion:t.version,trainScore:p,analysis:{reason:"no_changes"},status:"completed"});break}if(!e.auto&&!await this.confirm(`
|
|
4
|
-
Apply the proposed changes as a new version? [y/N] `)){this.log("Changes not applied. Stopping."),await m("/api/optimization-runs",{evalTargetId:t.id,type:"content",iteration:l,inputVersion:t.version,trainScore:p,analysis:{reason:"user_declined",suggestions:a.suggestions},status:"completed"});break}let r=await S(`/api/eval-targets/${t.id}`,{content:a.proposedContent});this.log(`Created v${r.version}`),this.log(`Running test evals on v${t.version} (baseline) and v${r.version}...`);let E=await this.runEvalsOnTarget(t,d,e),R=await this.runEvalsOnTarget(r,d,e),v=this.computePassRate(R),I=this.computePassRate(E);this.log(`Test pass rate: v${t.version} ${(I*100).toFixed(1)}% \u2192 v${r.version} ${(v*100).toFixed(1)}%`);let y=P(E,R);if(y&&this.log(C(y,t.version,r.version)),await m("/api/optimization-runs",{evalTargetId:t.id,type:"content",iteration:l,inputVersion:t.version,outputVersion:r.version,trainScore:p,testScore:v,analysis:{suggestions:a.suggestions,overallAssessment:a.overallAssessment,priorTestScore:I,verdict:y},status:"completed"}),v>f)f=v,T=r.version,x=0;else if(x++,x>=2){this.log("No improvement for 2 consecutive iterations. Stopping.");break}t=r}this.log(`
|
|
5
|
-
=== Optimization Complete ===`),this.log(`Best version: v${T} (test score: ${(f*100).toFixed(1)}%)`)}async confirm(n){process.stdin.isTTY||this.error("Interactive approval requires a TTY. Re-run with --auto to apply changes without review.");let e=_({input:process.stdin,output:process.stdout});try{let t=await e.question(n);return/^y(es)?$/i.test(t.trim())}finally{e.close()}}async runEvalsOnTarget(n,e,t){let i=[];for(let s of e){let c=await F({prompt:s.prompt,targetContent:n.content,timeout:t.timeout,model:t.model});if(c.error){i.push({evalName:s.name,prompt:s.prompt,expectations:s.expectations,grading:{}});continue}if(s.expectations.length>0){let u=await N({prompt:s.prompt,output:c.output,expectations:s.expectations,model:t.model,timeout:t.timeout});i.push({evalName:s.name,prompt:s.prompt,expectations:s.expectations,grading:u})}else i.push({evalName:s.name,prompt:s.prompt,expectations:s.expectations,grading:{}})}return i}computePassRate(n){let e=n.filter(i=>Object.keys(i.grading).length>0);if(e.length===0)return 0;let t=e.map(i=>i.grading.summary?.pass_rate??0);return t.reduce((i,s)=>i+s,0)/t.length}};export{$ as default};
|
|
1
|
+
import{a as r}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as t}from"../../chunk-ZLLER3HP.js";import{Args as o,Flags as e}from"@oclif/core";var i=class extends r{static{t(this,"EvalOptimizeCommand")}static description="Retired optimization workflow; use canonical experiments";static examples=["<%= config.bin %> evals run <target-id>"];static args={targetId:o.string({description:"Eval target ID",required:!0})};static flags={auto:e.boolean({description:"Skip interactive review, apply suggestions automatically",default:!1}),"max-iterations":e.integer({description:"Maximum optimization iterations",default:5}),threshold:e.string({description:"Stop if pass rate reaches this threshold (0-1)",default:"0.95"}),model:e.string({description:"Model for eval execution"}),"analyzer-model":e.string({description:"Model for analysis/suggestions"}),timeout:e.integer({description:"Timeout per eval in ms",default:12e4})};async run(){this.error("This optimization workflow is retired. Use evals run for recorded experiments; review and edit target content explicitly.")}};export{i as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as w,c as $}from"../../chunk-
|
|
1
|
+
import{b as w,c as $}from"../../chunk-G2MRNA45.js";import{b as v}from"../../chunk-OT7ZUHJF.js";import"../../chunk-FLXWL4F4.js";import"../../chunk-V6L25LFD.js";import"../../chunk-LQRXWLFJ.js";import"../../chunk-PPAHIVG5.js";import"../../chunk-CT7FWSIU.js";import"../../chunk-5MXZJWQS.js";import"../../chunk-K4LO27GG.js";import"../../chunk-FLP6WIJV.js";import"../../chunk-JP6ULOEX.js";import"../../chunk-SVZYRGO5.js";import"../../chunk-WULEBQPI.js";import"../../chunk-N7ODX6PO.js";import"../../chunk-GPBN4ROE.js";import"../../chunk-6XTLP2G7.js";import"../../chunk-PJ3WHQ67.js";import{a as f}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as d,f as p,h}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Args as P,Flags as y}from"@oclif/core";var c=a(s=>s==null?"n/a":`${Math.round(s*100)}%`,"pct"),g=class s extends f{static{a(this,"EvalRefineCases")}static description="Retire non-discriminating eval cases and regenerate discriminating replacements (\xA76e)";static examples=["<%= config.bin %> evals refine-cases <target-id> # preview","<%= config.bin %> evals refine-cases <target-id> --yes # apply: retire + regenerate","<%= config.bin %> evals refine-cases <target-id> --yes --no-generate"];static args={targetId:P.string({description:"Eval target ID",required:!0})};static flags={yes:y.boolean({char:"y",description:"Apply (retire + regenerate). Without this, only previews."}),"no-generate":y.boolean({description:"Retire dead cases but do not regenerate replacements."})};async run(){let{args:b,flags:l}=await this.parse(s);this.requireAuth();let n=b.targetId,o=await d(`/api/eval-targets/${n}`),m=await d(`/api/eval-targets/${n}/judge-calibration`),i=m.caseDiscrimination,t=w(i);if(this.log(`Target "${o.name}" v${o.version} \u2014 judge ${m.judge.currentModel??"(unstamped)"}`),t.refused==="no-discrimination-data"){this.log("No case-discrimination data yet \u2014 run some evals with AND without the target first (`evals run` / the web Run Evals button), then refine.");return}if(this.log(`${i.total} diagnosable case(s): ${i.discriminating} discriminate, ${i.nonDiscriminating} flat/wrong-sign, ${i.unpaired} unpaired.`),t.refused==="all-discriminating"){this.log("Every case discriminates \u2014 nothing to retire. \u{1F389}");return}let C=i.cases.filter(e=>!e.discriminating),u=new Set(t.retire.map(e=>e.evalId));this.log(`
|
|
2
2
|
Would retire ${t.retire.length} non-discriminating case(s):`);for(let e of C)u.has(e.evalId)&&this.log(` \u2717 ${e.name} \u2014 ${c(e.withPassRate)} with vs ${c(e.withoutPassRate)} without (\u0394${(e.separation*100).toFixed(0)}pp) \u2014 ${e.note}`);for(let e of i.unpairedCases)u.has(e.evalId)&&this.log(` \u2717 ${e.name} \u2014 ${c(e.withPassRate)} with vs ${c(e.withoutPassRate)} without \u2014 unpaired`);if(t.replacementsRequired&&this.log(`
|
|
3
3
|
${t.summary}. Replacements are generated and created BEFORE anything is retired \u2014 a target left under the floor drops out of the nightly evolution rotation with no error anywhere.`),!l.yes){this.log(`
|
|
4
4
|
Preview only. Re-run with --yes to retire ${t.retire.length} case(s)${l["no-generate"]?"":" and generate replacements"}.`);return}let r=await $(t,{generate:a(e=>l["no-generate"]?Promise.resolve([]):v({content:o.content,name:o.name,feedback:e}),"generate"),createCase:a(e=>p(`/api/eval-targets/${n}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations}),"createCase"),retireCase:a(async(e,R)=>{await h(`/api/eval-targets/${n}/evals/${e}`,{retire:!0,retiredReason:R})},"retireCase"),log:a(e=>this.log(e),"log")});if(r.skipped==="no-llm-backend"){this.warn(r.summary+" Install the `claude` CLI (or set ANTHROPIC_API_KEY), then run `evals refine-cases` again.");return}if(r.skipped==="no-replacements-generated"){this.warn(r.summary);return}this.log(`
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
${a.name}:`),this.log(` Runs: ${t.length}/${n.length} completed`),d.length>0){let e=d.map(o=>o.grading.summary?.pass_rate??0),s=e.reduce((o,f)=>o+f,0)/e.length;this.log(` Avg pass_rate: ${(s*100).toFixed(1)}%`)}for(let e of n){let s=l.find(x=>x.id===e.evalId)?.name??e.evalId,o=e.grading.summary?.pass_rate,f=o!==void 0?` pass_rate=${(o*100).toFixed(0)}%`:"",w=e.timing.duration_ms?` ${(e.timing.duration_ms/1e3).toFixed(1)}s`:"";this.log(` [${e.status}] ${s} run#${e.runNumber}${f}${w}`)}}if(!r["skip-baseline"]&&u.length>0){let a=u.filter(t=>t.configuration==="with_target"&&Object.keys(t.grading).length>0),n=u.filter(t=>t.configuration==="without_target"&&Object.keys(t.grading).length>0);if(a.length>0&&n.length>0){let t=a.map(s=>s.grading.summary?.pass_rate??0).reduce((s,o)=>s+o,0)/a.length,d=n.map(s=>s.grading.summary?.pass_rate??0).reduce((s,o)=>s+o,0)/n.length,e=t-d;this.log(`
|
|
3
|
-
Delta: ${e>0?"+":""}${(e*100).toFixed(1)}% (with_target vs without_target)`)}}}async executeAndGrade(c,r,i){return k(c,{targetId:r.id,targetVersion:r.version,iteration:i.iteration,timeout:i.timeout,model:i.model,graderModel:i["grader-model"],skipGrading:i["skip-grading"],targetType:r.type,targetName:r.name},l=>this.log(l))}};export{b as default};
|
|
1
|
+
import{a as s}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{f as n}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Args as d,Flags as r}from"@oclif/core";var t=class o extends s{static{a(this,"EvalRunCommand")}static description="Queue an experiment against a target using the configured worker";static examples=["<%= config.bin %> evals run <target-id>","<%= config.bin %> evals run <target-id> --parallel 3 --runs-per-eval 2","<%= config.bin %> evals run <target-id> --skip-baseline --skip-grading"];static args={targetId:d.string({description:"Eval target ID",required:!0})};static flags={parallel:r.integer({description:"Number of parallel eval executions",default:1}),"runs-per-eval":r.integer({description:"Number of runs per eval for variance analysis",default:1}),iteration:r.integer({description:"Iteration number for tracking",default:1}),"skip-baseline":r.boolean({description:"Skip baseline (without_target) runs",default:!1}),"skip-grading":r.boolean({description:"Skip LLM grading step",default:!1}),model:r.string({description:"Model for eval execution (default: user configured)"}),"grader-model":r.string({description:"Model for grading (default: same as execution model)"}),timeout:r.integer({description:"Timeout per eval in ms",default:12e4})};async run(){let{args:l,flags:e}=await this.parse(o);this.requireAuth();let i=await n("/api/experiments",{executor:"replay",targetId:l.targetId,config:{parallel:e.parallel,runsPerEval:e["runs-per-eval"],iteration:e.iteration,skipBaseline:e["skip-baseline"],skipGrading:e["skip-grading"],model:e.model,graderModel:e["grader-model"],timeout:e.timeout}});this.log(`Experiment ${i.id} queued (job ${i.jobId}).`),this.log(i.href),i.noLiveWorker&&this.log("Start rulemetric evals agent to execute this experiment.")}};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c,d as m}from"../../chunk-
|
|
1
|
+
import{c,d as m}from"../../chunk-CLPIN7TY.js";import"../../chunk-6UEFCMR2.js";import"../../chunk-3HJT572X.js";import"../../chunk-CDY7TQFZ.js";import"../../chunk-FLP6WIJV.js";import"../../chunk-JP6ULOEX.js";import"../../chunk-SVZYRGO5.js";import"../../chunk-WULEBQPI.js";import"../../chunk-GPBN4ROE.js";import"../../chunk-6XTLP2G7.js";import"../../chunk-PJ3WHQ67.js";import{a as u}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as r}from"../../chunk-ZLLER3HP.js";import{Args as p,Flags as s}from"@oclif/core";var o=r(n=>n==null?"\u2014":`${(n*100).toFixed(0)}%`,"pct"),g=class n extends u{static{r(this,"EvalValidateJudge")}static description="Score a second model against your human judge-review labels (\xA76g validation pass)";static examples=["<%= config.bin %> evals validate-judge <target-id> # auto-detect installed CLIs","<%= config.bin %> evals validate-judge <target-id> --engine codex --model gpt-5.5","<%= config.bin %> evals validate-judge <target-id> --model claude-sonnet-5 --json","<%= config.bin %> evals validate-judge <target-id> --limit 5 # quick sample"];static args={targetId:p.string({description:"Eval target ID",required:!0})};static flags={model:s.string({description:"Second reviewer model. Default: resolved from your installed tooling (codex: your ~/.codex/config.toml model; claude: a tier that differs from the original judge)."}),engine:s.string({description:"CLI that runs the second reviewer. `auto` prefers your installed codex for a cross-vendor reviewer \u2014 two Claude models share a training lineage, so their agreement overstates independence.",options:["auto","claude","codex"],default:"auto"}),limit:s.integer({description:"Sample only the N most-recently-annotated runs (cost control / smoke)"}),"skip-reviewed":s.boolean({description:"Only re-grade assertions this reviewer model has not ruled on yet",default:!1}),parallel:s.integer({description:"Concurrent re-grades",default:3}),timeout:s.integer({description:"Timeout per re-grade in ms",default:12e4}),json:s.boolean({description:"Emit the full report as JSON"})};async run(){let{args:h,flags:i}=await this.parse(n);this.requireAuth();let a;try{a=await m({targetId:h.targetId,engineFlag:i.engine,modelFlag:i.model,limit:i.limit,parallel:i.parallel,timeoutMs:i.timeout,skipReviewed:i["skip-reviewed"],log:r(t=>this.log(t),"log"),warn:r(t=>this.warn(t),"warn")})}catch(t){throw t instanceof c&&this.error(t.message),t}let{report:e,judgeModels:l,reviewerModel:d}=a;if(l.length===1&&l[0]===d&&this.warn(`Second reviewer resolved to the SAME model as the original judge (${l[0]}) \u2014 this measures self-consistency, not independent review.`),i.json){this.log(JSON.stringify({target:a.targetName,judgeA:l,judgeB:d,persisted:a.persisted,alreadyReviewed:a.alreadyReviewed,...e},null,2));return}if(e.pairs===0&&a.alreadyReviewed>0){this.log(`All ${a.alreadyReviewed} labeled assertion(s) already reviewed by ${d} \u2014 nothing new to grade.`);return}if(this.log(""),this.log(`Second reviewer: ${d} \u2014 scored against ${e.pairs} human-labeled assertion(s)`+(e.skipped?` (${e.skipped} skipped)`:"")),this.log(""),this.log(` reviewer vs HUMAN: ${o(e.bVsHuman.overall.rate)} overall \xB7 ${o(e.bVsHuman.onJudgePass.rate)} where judge passed \xB7 ${o(e.bVsHuman.onJudgeFail.rate)} where judge failed`),this.log(` original judge vs human: ${o(e.aVsHuman.overall.rate)} (your approve rate)`),this.log(` reviewer vs judge: ${o(e.bVsA.overall.rate)} (inter-model, not truth)`),this.log(` Cohen's \u03BA (reviewer vs human): ${e.kappaBvsHuman==null?"undefined (degenerate marginals)":e.kappaBvsHuman.toFixed(2)}`),this.log(""),e.suggestedAnchorWeight!=null&&this.log(` suggested \xA76g anchor weight if used as a passive label source: ${e.suggestedAnchorWeight.toFixed(2)} (misclassification attenuation (2\xB7acc\u22121)\xB2; validated:false either way)`),e.disagreements.length>0){this.log(""),this.log(` ${e.disagreements.length} disagreement(s) with your labels \u2014 flagged on the Review tab:`);for(let t of e.disagreements.slice(0,10))this.log(` run ${t.runId.slice(0,8)} #${t.expectationIndex}: human=${t.humanPassed?"pass":"fail"} reviewer=${t.judgeBPassed?"pass":"fail"} \u2014 ${t.text.slice(0,80)}`);e.disagreements.length>10&&this.log(` \u2026 and ${e.disagreements.length-10} more (use --json for all)`)}}};export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"../../chunk-MODXEGCU.js";import{a as c}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{f as a}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as s}from"../../chunk-ZLLER3HP.js";import{Flags as e}from"@oclif/core";import{readFileSync as f}from"node:fs";function m(o,i,t,r){if(!i.trim())throw new Error("A task family is required.");if(!t.trim()||t.length>32e3)throw new Error("Supply a fresh work request between 1 and 32000 characters.");return{tool:"claude_code",config:{projectPath:p(o),studyTaskFamily:i.trim(),prompt:t.trim(),mode:"headless",...r?{model:r}:{}}}}s(m,"freshTaskLaunch");var n=class o extends c{static{s(this,"ExperimentsEnroll")}static description="Submit a fresh work request to an eligible project experiment";static examples=["<%= config.bin %> experiments enroll --project /repo --family parser-repair --prompt-file task.txt"];static flags={project:e.string({char:"p",description:"Project path (defaults to current directory)"}),family:e.string({required:!0,description:"Task family shown by the waiting experiment"}),"prompt-file":e.string({required:!0,description:"UTF-8 file containing a real, fresh work request"}),model:e.string({description:"Optional model constraint; must match the experiment pin"})};async run(){let{flags:i}=await this.parse(o);this.requireAuth();let t=m(i.project??process.cwd(),i.family,f(i["prompt-file"],"utf8"),i.model),r=await a("/api/launch-jobs",t);this.log(`Queued fresh task: ${r.id}`),r.config.scopedConfirmation&&this.log(`Experiment ${r.config.scopedConfirmation.id}; task ${r.config.scopedConfirmation.taskId}`),r.noLiveWorker&&this.log("Waiting for a compatible worker. See RuleMetric activity for progress."),this.log(`Activity: /loop/jobs/launch-job/${r.id}`)}};export{n as default,m as freshTaskLaunch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as f}from"../../chunk-MODXEGCU.js";import{a as b}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as g}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Flags as S}from"@oclif/core";import{printTable as P}from"@oclif/table";import{z as e}from"zod";var c=e.enum(["fixture","benchmark","replay","repository","historical"]),l=e.enum(["ready","queued","running","completed","failed","cancelled"]),u=e.enum(["improved","worsened","no_useful_difference","inconclusive","unassessed"]),j=e.object({key:e.string().min(1),label:e.string().min(1),unit:e.string().min(1),direction:e.enum(["higher","lower"]),baseline:e.number().finite().nullable(),treatment:e.number().finite().nullable(),finding:u,basis:e.enum(["descriptive","inference","historical"]),explanation:e.string().min(1),interval:e.tuple([e.number().finite(),e.number().finite()]).nullable()}).strict().superRefine((n,r)=>{n.basis==="descriptive"&&!["inconclusive","unassessed"].includes(n.finding)&&r.addIssue({code:"custom",path:["finding"],message:"An observed difference alone is not an inferential finding"}),n.interval&&n.interval[0]>n.interval[1]&&r.addIssue({code:"custom",path:["interval"],message:"Interval bounds must be ordered"})}),m=e.object({version:e.literal(1),primaryMetric:e.string().nullable(),metrics:e.array(j),validity:e.enum(["valid","limited","invalid","unassessed"]),explanation:e.string().min(1),observed:e.number().int().nonnegative(),planned:e.number().int().nonnegative().nullable(),applicationAllowed:e.boolean()}).strict().superRefine((n,r)=>{let s=n.metrics.map(t=>t.key);new Set(s).size!==s.length&&r.addIssue({code:"custom",path:["metrics"],message:"Each metric has one finding"}),n.primaryMetric&&!s.includes(n.primaryMetric)&&r.addIssue({code:"custom",path:["primaryMetric"],message:"Primary metric must be present"}),n.applicationAllowed&&(n.validity!=="valid"||n.metrics.find(t=>t.key===n.primaryMetric)?.finding!=="improved"||n.metrics.some(t=>t.finding==="worsened"))&&r.addIssue({code:"custom",path:["applicationAllowed"],message:"Application requires a valid primary improvement and no worsened safeguards"})}),w=e.object({taskId:e.string().min(1),arm:e.enum(["baseline","treatment"]),repetition:e.number().int().positive(),metrics:e.record(e.number().finite().nullable()),eligible:e.boolean(),exclusion:e.string().nullable(),evidence:e.record(e.unknown())}).strict(),k=w.extend({id:e.string().uuid()}),_=e.object({id:e.string().uuid(),experimentId:e.string().uuid().nullable(),action:e.enum(["file_change","instruction_delivery","instruction_revision"]),status:e.enum(["not_applied","applied","reverted"]),target:e.string(),appliedAt:e.string().nullable(),evidence:e.record(e.unknown())}).strict();function x(n){return n?.metrics.find(r=>r.key===n.primaryMetric)?.finding??"unassessed"}a(x,"primaryFinding");var C=e.object({id:e.string().uuid(),name:e.string(),executor:c,status:l,projectPath:e.string().nullable(),parentExperimentId:e.string().uuid().nullable(),result:m.nullable(),protocol:e.unknown(),analysis:e.unknown(),legacyEvidence:e.unknown(),observations:e.array(k),totalObservations:e.number().int(),nextOffset:e.number().int().nullable(),applications:e.array(_),totalApplications:e.number().int(),nextApplicationOffset:e.number().int().nullable()}),h=e.object({fileChanges:e.number().int().nonnegative(),instructionRevisions:e.number().int().nonnegative(),instructionDeliveries:e.number().int().nonnegative(),restorations:e.number().int().nonnegative()}).strict();function v(n){return[["fileChanges","file change"],["instructionRevisions","instruction revision"],["instructionDeliveries","instruction delivery"],["restorations","restoration"]].filter(([s])=>n[s]>0).map(([s,t])=>`${n[s]} ${n[s]===1?t:t==="instruction delivery"?"instruction deliveries":t+"s"}`).join(", ")||"No recorded actions"}a(v,"describeExperimentActions");import{z as i}from"zod";var p=c,T=p.options,I={positive:"improved",negative:"worsened",not_useful:"no_useful_difference"},y=l,q=i.object({source:p.optional(),outcome:i.preprocess(n=>typeof n=="string"?I[n]??n:n,u.optional()),status:y.optional(),search:i.string().trim().max(200).default(""),project:i.string().max(4096).optional(),offset:i.coerce.number().int().min(0).max(1e6).default(0),limit:i.coerce.number().int().min(1).max(100).default(25)}),O=i.object({id:i.string(),source:p,name:i.string(),projectPath:i.string().nullable(),targetId:i.string().nullable(),createdAt:i.string(),finishedAt:i.string().nullable(),status:y,result:m.nullable(),applicationCounts:h,model:i.string().nullable(),engine:i.string().nullable(),evidenceScope:i.string(),href:i.string()}).strict(),E=i.object({rows:i.array(O),total:i.number(),nextOffset:i.number().nullable(),counts:i.object({all:i.number(),improved:i.number(),running:i.number(),failed:i.number()}).strict()}).strict(),M=i.object({id:i.string(),source:i.enum(["harbor","target"]),name:i.string(),description:i.string(),projectPath:i.string().nullable(),cases:i.number(),plannedCalls:i.number().nullable(),href:i.string(),runnable:i.boolean(),blockedReason:i.string().nullable(),schedule:i.string()}).strict(),B=i.object({suites:i.array(M),total:i.number(),nextOffset:i.number().nullable()}).strict(),$=i.discriminatedUnion("source",[i.object({source:i.literal("harbor"),id:i.string().min(1).max(100)}).strict(),i.object({source:i.literal("target"),id:i.string().uuid()}).strict(),i.object({source:i.literal("study"),id:i.string().uuid()}).strict()]);var d=class n extends b{static{a(this,"ExperimentsList")}static description="List experiments with execution, metric finding, and application separately";static examples=["<%= config.bin %> experiments list","<%= config.bin %> experiments list --all"];static flags={project:S.string({char:"p",description:"Project path (defaults to current directory)"}),all:S.boolean({description:"Every project",default:!1})};async run(){let{flags:r}=await this.parse(n);this.requireAuth();let s=new URLSearchParams({limit:"50"});r.all||s.set("project",f(r.project??process.cwd()));let t=E.parse(await g(`/api/evaluations?${s}`));if(!t.rows.length){this.log("No experiments found.");return}P({data:t.rows.map(o=>({Experiment:o.name,Execution:o.status,Metric:o.result?.metrics.find(A=>A.key===o.result?.primaryMetric)?.label??"Unassessed",Finding:x(o.result??null).replaceAll("_"," "),Actions:v(o.applicationCounts)})),columns:["Experiment","Execution","Metric","Finding","Actions"]}),this.log(`Showing ${t.rows.length} of ${t.total} experiments. Findings describe the named metric; application requires its own receipt.`)}};export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as y,c as h}from"../../chunk-NVABG3AO.js";import{e,i as p,k as m,m as f}from"../../chunk-QWCEZEDO.js";import"../../chunk-KKDHD4XA.js";import{b as d,d as u}from"../../chunk-SZ62CP55.js";import{B as l,E as g}from"../../chunk-OZQNSELV.js";import"../../chunk-HFGO5762.js";import"../../chunk-VS5ROGDP.js";import{a as c}from"../../chunk-
|
|
1
|
+
import{b as y,c as h}from"../../chunk-NVABG3AO.js";import{e,i as p,k as m,m as f}from"../../chunk-QWCEZEDO.js";import"../../chunk-KKDHD4XA.js";import{b as d,d as u}from"../../chunk-SZ62CP55.js";import{B as l,E as g}from"../../chunk-OZQNSELV.js";import"../../chunk-HFGO5762.js";import"../../chunk-VS5ROGDP.js";import{a as c}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{spawn as S}from"node:child_process";import{existsSync as v,readFileSync as R,statSync as C,writeFileSync as M}from"node:fs";import{homedir as T}from"node:os";import{join as o}from"node:path";var s=o(T(),".config","rulemetric"),x=o(s,"proxy-addon.version"),_=o(s,"proxy.pid"),w=o(s,"proxy-drift-restart.at"),E=10*6e4,n=class P extends c{static{a(this,"GatewayEnsure")}static description="Ensure the gateway proxy is running (called by hooks, not for direct use)";static hidden=!0;async run(){await this.parse(P),this.maybeRestartStaleProxy();let t=await p(e);if(t.status==="ours-live"){let r=h(i=>{i==="vscode"?l(e):g(e)});r.length>0&&console.error(`[RuleMetric] Gateway healthy again \u2014 restored ${r.join(", ")} proxy settings.`);return}if(t.status==="foreign"){if(m())return;let r=y(e);console.error(`[RuleMetric] A non-RuleMetric process holds :${e} \u2014 cannot start gateway. `+(r.length>0?`Unpinned ${r.join(", ")} proxy settings so editors are not routed through it. `:"")+"Run `rulemetric diagnostics` if Claude Code HTTPS requests fail.");return}try{f(this.config.version)}catch(r){console.error(`[RuleMetric] Could not start gateway: ${r.message}`)}}maybeRestartStaleProxy(){try{if(!v(x))return;let t=R(x,"utf-8").trim();if(!t||t===this.config.version)return;let r=R(_,"utf-8").trim(),i=Number(r);if(!Number.isFinite(i)||!u(i,d))return;try{if(Date.now()-C(w).mtimeMs<E)return}catch{}M(w,new Date().toISOString()),S(process.execPath,[process.argv[1],"proxy","restart"],{detached:!0,stdio:"ignore"}).unref(),console.error(`[RuleMetric] Capture proxy is running CLI ${t} but ${this.config.version} is installed \u2014 restarting it in the background.`)}catch{}}};export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as mt}from"../../chunk-5INUF4A4.js";import{a as yt}from"../../chunk-6XEC6474.js";import{e as s,i as F,j as V,k as q,m as A,n as W}from"../../chunk-QWCEZEDO.js";import{e as D}from"../../chunk-KKDHD4XA.js";import"../../chunk-SZ62CP55.js";import"../../chunk-N7ODX6PO.js";import{B as ht,E as gt,H as pt,I as ft,e as Z,f as tt,g as et,i as st,j as ot,k as it,n as rt,p as at,q as nt,r as lt,u as ct,v as ut,y as dt}from"../../chunk-OZQNSELV.js";import{a as J,b as z,c as m,d as Q,g as R}from"../../chunk-HFGO5762.js";import"../../chunk-VS5ROGDP.js";import{a as f}from"../../chunk-PJ3WHQ67.js";import{a as X}from"../../chunk-JCZOEIL7.js";import{a as B}from"../../chunk-TQFHRD5B.js";import"../../chunk-IZTIYR5Q.js";import{c as Y}from"../../chunk-5LTJNYCP.js";import"../../chunk-3EZZGA72.js";import{b as M}from"../../chunk-XAGNGQL3.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-5VWVQCNR.js";import"../../chunk-MHLHLJ5T.js";import"../../chunk-XQYAVSUQ.js";import{a as L}from"../../chunk-PZNWH4VQ.js";import{a as w}from"../../chunk-ZLLER3HP.js";import{Flags as y}from"@oclif/core";import{execFileSync as Ct,spawnSync as l}from"node:child_process";import{existsSync as u}from"node:fs";import{homedir as kt}from"node:os";import{join as _,dirname as wt}from"node:path";function xt(){try{let h=Ct("/bin/sh",["-c","command -v rulemetric"],{encoding:"utf-8"}).trim();if(h&&u(h))return wt(h)}catch{}}w(xt,"resolveHookBinDir");function Pt(){try{return Ct("launchctl",["list","com.rulemetric.gateway"],{stdio:["ignore","pipe","pipe"]}),!0}catch{return!1}}w(Pt,"isGatewayLaunchdManaged");var o=_(kt(),".mitmproxy","mitmproxy-ca-cert.pem"),K=class h extends B{static{w(this,"HooksInstall")}static description="Install session tracking hooks and context capture proxy for Claude Code";static examples=["<%= config.bin %> hooks install","<%= config.bin %> hooks install --global","<%= config.bin %> hooks install --no-proxy"];static flags={"no-proxy":y.boolean({default:!1,description:"Skip proxy/gateway configuration (hooks only)"}),"project-dir":y.string({description:"Project directory to install hooks in (defaults to cwd)"}),"user-hooks":y.boolean({description:"Write user-level Cursor/Antigravity hooks (~/.cursor, ~/.gemini). Required for Cursor capture \u2014 its traffic bypasses the proxy.",default:!0,allowNo:!0}),global:y.boolean({char:"g",default:!1,description:"Install hooks globally (~/.claude/settings.json) so all projects are tracked"}),"statusline-usage":y.boolean({default:!1,description:"Install the statusline shim so Claude Code pushes live rate_limits on every refresh (makes /usage rings update in real time without needing the proxy)"})};async run(){let{flags:i}=await this.parse(h),r=i.global,a=r?kt():i["project-dir"]??process.cwd(),x=_(a,".claude"),C=it(x,r),$=r?"settings.json":"settings.local.json",P=i["no-proxy"],b=!1,g=P?"no_proxy_flag":void 0,p=!1,S=[];r&&this.log(`Installing hooks globally \u2192 ${C}`);let{settings:n,recoveredBackup:I}=Z(C);if(I&&this.log(`[!!] ${C} was not valid JSON \u2014 backed it up to ${I} and continued with a fresh file.`),!r){let e=rt(_(x,"settings.json"),s);e.migrated&&(this.log("[OK] Moved RuleMetric machine-local state out of the shared .claude/settings.json (it now lives in .claude/settings.local.json)"),e.backupPath&&this.log(` Previous shared settings backed up \u2192 ${e.backupPath}`),e.removedStatusline&&u(J)&&!R(n)&&(n.statusLine=m))}let E=L();(E.accessToken||process.env.RULEMETRIC_ACCESS_TOKEN)&&!E.apiKey&&!process.env.RULEMETRIC_API_KEY&&await X(this.log.bind(this),this.warn.bind(this),this.config.version);let vt=st(n),k=xt();if(et(n,k),this.log(vt?`[OK] Refreshed RuleMetric Claude Code session hooks \u2192 .claude/${$}`:`[OK] Installed RuleMetric Claude Code session hooks \u2192 .claude/${$}`),!P){let e=!!f("mitmdump");if(e||(this.log(""),this.log("[!!] mitmproxy not found \u2014 installing..."),S=["brew","pipx","uv"].filter(t=>!!f(t)),e=this.installMitmproxy(),e||(this.log("[!!] Could not install mitmproxy. Skipping proxy config."),this.log(" Install manually: pipx install mitmproxy"),this.log(" Then re-run: rulemetric hooks install"))),u(o))this.log("[OK] CA certificate found");else{this.log("[..] Generating CA certificate...");let t=f("mitmdump");t&&(l(t,["--set","listen_port=0","-q"],{timeout:5e3,stdio:"ignore"}),u(o)?this.log(`[OK] CA certificate generated at ${o}`):this.log("[!!] Could not generate CA cert"))}let c=u(o);c&&!this.isCACertTrusted()?(this.log("[..] Installing CA certificate into system trust store (requires admin)..."),p=this.trustCACert(),p?this.log("[OK] CA certificate trusted by system"):(this.log("[!!] Could not install CA cert automatically."),process.platform==="darwin"?this.log(` Run manually: sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${o}`):process.platform==="linux"&&this.log(` Run manually: sudo cp ${o} /usr/local/share/ca-certificates/mitmproxy-ca.crt && sudo update-ca-certificates`))):c&&(this.log("[OK] CA certificate already trusted"),p=!0);let d=Pt(),O=await F(s);if(d)this.log("[OK] Gateway managed by launchd (com.rulemetric.gateway)");else if(O.status==="ours-live")this.log("[OK] Gateway already running");else if(O.status==="foreign"&&q()){this.log("[..] Restarting gateway (running build predates the identity handshake)..."),W(),await new Promise(t=>setTimeout(t,500));try{let t=A(this.config.version);this.log(`[OK] Gateway restarted (PID ${t})`)}catch(t){this.log(`[!!] Could not restart gateway: ${t.message}`)}}else if(O.status!=="foreign")try{let t=A(this.config.version);this.log(`[OK] Gateway started (PID ${t})`)}catch(t){this.log(`[!!] Could not start gateway: ${t.message}`)}let G=await V(s,{timeoutMs:4e3});if(!c)g=e?"ca_not_generated":S.length===0?"no_package_manager":"mitmproxy_install_failed",this.log("[!!] No CA certificate \u2014 NOT setting HTTPS_PROXY (capture stays hooks-only)."),this.log(" Install mitmproxy, then re-run: rulemetric hooks install");else if(G.status==="foreign"&&!d){g="gateway_port_foreign";let t=D(s);this.log(`[!!] Port :${s} is held by a process that is NOT the RuleMetric gateway \u2014 NOT setting HTTPS_PROXY.`),this.log(t?` Holding the port: ${t}`:` Could not identify the holder (try: lsof -nP -iTCP:${s} -sTCP:LISTEN)`),this.log(" Capture still works via hooks. Free the port, then re-run: rulemetric hooks install")}else if(G.status==="dead")g="gateway_not_live",this.log(`[!!] Gateway is not answering on :${s} \u2014 NOT setting HTTPS_PROXY.`),this.log(" Capture still works via hooks. To enable deep (proxy) capture later:"),this.log(" rulemetric proxy start && rulemetric hooks install");else{let t=n.env??{};t.HTTPS_PROXY=`http://localhost:${s}`,t.NO_PROXY=ot,u(o)&&(t.NODE_EXTRA_CA_CERTS=o),n.env=t,b=!0,this.log(`[OK] HTTPS_PROXY set to gateway on :${s} (verified live)`),ct(a,s,o)&&this.log("[OK] Cursor proxy configured \u2192 .cursor/settings.json"),ut(a,s,o)&&this.log("[OK] VS Code workspace proxy configured \u2192 .vscode/settings.json"),ht(s)&&this.log("[OK] VS Code user proxy configured \u2192 ~/Library/Application Support/Code/User/settings.json"),gt(s)&&this.log("[OK] Cursor user proxy configured \u2192 ~/Library/Application Support/Cursor/User/settings.json"),p?dt(s,o)&&this.log("[OK] HTTPS_PROXY set for GUI apps (launchctl + LaunchAgent)"):(g="ca_untrusted",this.log("[!!] CA not trusted \u2014 skipping machine-wide GUI proxy (would break native-app TLS)."),this.log(" Claude Code capture is unaffected. Trust the CA + re-run to enable cross-app capture."))}}let v=[];if(!r){let e=at(a,k);e&&(this.log(`[OK] Cursor hooks configured \u2192 ${e}`),v.push(e));let c=lt(a,k);c&&(this.log(`[OK] Copilot Agent hooks configured \u2192 ${c}`),v.push(c));let d=pt(a);d&&(this.log(`[OK] Antigravity workspace hooks configured \u2192 ${d}`),v.push(d))}let H=i["user-hooks"]?ft():null;H&&this.log(`[OK] Antigravity user hooks configured \u2192 ${H}`);let U=i["user-hooks"]?nt(k):null;if(U&&this.log(`[OK] Cursor user hooks configured \u2192 ${U}`),i["user-hooks"]||(this.log("[--] Skipped user-level Cursor/Antigravity hooks (--no-user-hooks)."),this.log(" Cursor capture will not work: its chat traffic bypasses the proxy,"),this.log(" so hooks are the only path. Claude Code capture is unaffected.")),i["statusline-usage"])if(R(n))this.log("[OK] Statusline shim already installed");else{let e=Q(n);z(e),n.statusLine=m,e?this.log(`[OK] Statusline shim installed \u2192 ${m.command} (chains to: ${e})`):this.log(`[OK] Statusline shim installed \u2192 ${m.command}`),this.log(" Rate-limit rings will now update on Claude Code's statusline refresh cadence")}let{backupPath:N}=tt(C,n);N&&this.log(`[OK] Backed up previous settings \u2192 ${N}`),this.log(""),this.log("Setup complete! Next steps:"),r?(this.log(" 1. Install always-on API: rulemetric service install"),this.log(" 2. Start Claude Code in any project \u2014 all sessions tracked automatically"),this.log(""),this.log("The API service starts on login and restarts on crash.")):P?(this.log(" 1. Start Claude Code \u2014 sessions are captured by the hooks just installed"),this.log(""),this.log("No proxy means no mitmproxy / CA cert needed. The hooks capture full"),this.log("sessions on their own; re-run without --no-proxy to also capture system"),this.log("prompts for instruction-effectiveness linking.")):(this.log(" 1. Start Claude Code \u2014 sessions are captured by hooks immediately"),b?this.log(" 2. Full-depth capture is ON \u2014 the proxy is live on :"+s+"."):this.log(" 2. Enable full depth (proxy not yet live): rulemetric proxy start"),this.log(""),this.log("Hooks capture every session (lifecycle + transcript). The proxy adds the"),this.log("rendered system prompt (instruction-effectiveness linking) + cross-tool capture."),this.log(""),this.log("To capture traffic from other clients (Python, curl, etc.):"),this.log(' eval "$(rulemetric proxy env --all)"'));let j=mt(a,v);j&&this.log(j),await M(),Y("hooks_installed",{proxy:b,caTrusted:p,reason:g,installers:S,global:r},this.config.version);let T=await yt();this.log(""),T.available?this.log(`[OK] tmux found${T.version?` (v${T.version})`:""} \u2014 live send enabled`):this.log("[!!] tmux not found \u2014 live send will fall back to opening Terminal. Install with: brew install tmux")}installMitmproxy(){for(let[i,r]of[["pipx",["install","mitmproxy"]],["uv",["tool","install","mitmproxy"]],["brew",["install","mitmproxy"]]]){let a=f(i);if(a&&(this.log(` Installing via ${i}...`),l(a,[...r],{stdio:"inherit"}).status===0))return!0}return!1}isCACertTrusted(){return process.platform==="darwin"?l("security",["verify-cert","-c",o],{stdio:"pipe"}).status===0:process.platform==="linux"?u("/usr/local/share/ca-certificates/mitmproxy-ca.crt"):process.platform==="win32"?l("certutil",["-verify",o],{stdio:"pipe"}).status===0:!1}trustCACert(){return process.platform==="darwin"?l("sudo",["security","add-trusted-cert","-d","-r","trustRoot","-k","/Library/Keychains/System.keychain",o],{stdio:"inherit"}).status===0:process.platform==="linux"?l("sudo",["cp",o,"/usr/local/share/ca-certificates/mitmproxy-ca.crt"],{stdio:"inherit"}).status!==0?!1:l("sudo",["update-ca-certificates"],{stdio:"inherit"}).status===0:process.platform==="win32"?l("certutil",["-addstore","-f","Root",o],{stdio:"inherit"}).status===0:!1}};export{K as default};
|
|
1
|
+
import{b as mt}from"../../chunk-5INUF4A4.js";import{a as yt}from"../../chunk-6XEC6474.js";import"../../chunk-N7ODX6PO.js";import{e as s,i as F,j as V,k as q,m as A,n as W}from"../../chunk-QWCEZEDO.js";import{e as D}from"../../chunk-KKDHD4XA.js";import"../../chunk-SZ62CP55.js";import{a as f}from"../../chunk-PJ3WHQ67.js";import{B as ht,E as gt,H as pt,I as ft,e as Z,f as tt,g as et,i as st,j as ot,k as it,n as rt,p as at,q as nt,r as lt,u as ct,v as ut,y as dt}from"../../chunk-OZQNSELV.js";import{a as J,b as z,c as m,d as Q,g as R}from"../../chunk-HFGO5762.js";import"../../chunk-VS5ROGDP.js";import{a as X}from"../../chunk-NJKPUZNM.js";import{a as B}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import{c as Y}from"../../chunk-KTLRSRHF.js";import{b as M}from"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import{a as L}from"../../chunk-PZNWH4VQ.js";import{a as w}from"../../chunk-ZLLER3HP.js";import{Flags as y}from"@oclif/core";import{execFileSync as Ct,spawnSync as l}from"node:child_process";import{existsSync as u}from"node:fs";import{homedir as kt}from"node:os";import{join as _,dirname as wt}from"node:path";function xt(){try{let h=Ct("/bin/sh",["-c","command -v rulemetric"],{encoding:"utf-8"}).trim();if(h&&u(h))return wt(h)}catch{}}w(xt,"resolveHookBinDir");function Pt(){try{return Ct("launchctl",["list","com.rulemetric.gateway"],{stdio:["ignore","pipe","pipe"]}),!0}catch{return!1}}w(Pt,"isGatewayLaunchdManaged");var o=_(kt(),".mitmproxy","mitmproxy-ca-cert.pem"),K=class h extends B{static{w(this,"HooksInstall")}static description="Install session tracking hooks and context capture proxy for Claude Code";static examples=["<%= config.bin %> hooks install","<%= config.bin %> hooks install --global","<%= config.bin %> hooks install --no-proxy"];static flags={"no-proxy":y.boolean({default:!1,description:"Skip proxy/gateway configuration (hooks only)"}),"project-dir":y.string({description:"Project directory to install hooks in (defaults to cwd)"}),"user-hooks":y.boolean({description:"Write user-level Cursor/Antigravity hooks (~/.cursor, ~/.gemini). Required for Cursor capture \u2014 its traffic bypasses the proxy.",default:!0,allowNo:!0}),global:y.boolean({char:"g",default:!1,description:"Install hooks globally (~/.claude/settings.json) so all projects are tracked"}),"statusline-usage":y.boolean({default:!1,description:"Install the statusline shim so Claude Code pushes live rate_limits on every refresh (makes /usage rings update in real time without needing the proxy)"})};async run(){let{flags:i}=await this.parse(h),r=i.global,a=r?kt():i["project-dir"]??process.cwd(),x=_(a,".claude"),C=it(x,r),$=r?"settings.json":"settings.local.json",P=i["no-proxy"],b=!1,g=P?"no_proxy_flag":void 0,p=!1,S=[];r&&this.log(`Installing hooks globally \u2192 ${C}`);let{settings:n,recoveredBackup:I}=Z(C);if(I&&this.log(`[!!] ${C} was not valid JSON \u2014 backed it up to ${I} and continued with a fresh file.`),!r){let e=rt(_(x,"settings.json"),s);e.migrated&&(this.log("[OK] Moved RuleMetric machine-local state out of the shared .claude/settings.json (it now lives in .claude/settings.local.json)"),e.backupPath&&this.log(` Previous shared settings backed up \u2192 ${e.backupPath}`),e.removedStatusline&&u(J)&&!R(n)&&(n.statusLine=m))}let E=L();(E.accessToken||process.env.RULEMETRIC_ACCESS_TOKEN)&&!E.apiKey&&!process.env.RULEMETRIC_API_KEY&&await X(this.log.bind(this),this.warn.bind(this),this.config.version);let vt=st(n),k=xt();if(et(n,k),this.log(vt?`[OK] Refreshed RuleMetric Claude Code session hooks \u2192 .claude/${$}`:`[OK] Installed RuleMetric Claude Code session hooks \u2192 .claude/${$}`),!P){let e=!!f("mitmdump");if(e||(this.log(""),this.log("[!!] mitmproxy not found \u2014 installing..."),S=["brew","pipx","uv"].filter(t=>!!f(t)),e=this.installMitmproxy(),e||(this.log("[!!] Could not install mitmproxy. Skipping proxy config."),this.log(" Install manually: pipx install mitmproxy"),this.log(" Then re-run: rulemetric hooks install"))),u(o))this.log("[OK] CA certificate found");else{this.log("[..] Generating CA certificate...");let t=f("mitmdump");t&&(l(t,["--set","listen_port=0","-q"],{timeout:5e3,stdio:"ignore"}),u(o)?this.log(`[OK] CA certificate generated at ${o}`):this.log("[!!] Could not generate CA cert"))}let c=u(o);c&&!this.isCACertTrusted()?(this.log("[..] Installing CA certificate into system trust store (requires admin)..."),p=this.trustCACert(),p?this.log("[OK] CA certificate trusted by system"):(this.log("[!!] Could not install CA cert automatically."),process.platform==="darwin"?this.log(` Run manually: sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${o}`):process.platform==="linux"&&this.log(` Run manually: sudo cp ${o} /usr/local/share/ca-certificates/mitmproxy-ca.crt && sudo update-ca-certificates`))):c&&(this.log("[OK] CA certificate already trusted"),p=!0);let d=Pt(),O=await F(s);if(d)this.log("[OK] Gateway managed by launchd (com.rulemetric.gateway)");else if(O.status==="ours-live")this.log("[OK] Gateway already running");else if(O.status==="foreign"&&q()){this.log("[..] Restarting gateway (running build predates the identity handshake)..."),W(),await new Promise(t=>setTimeout(t,500));try{let t=A(this.config.version);this.log(`[OK] Gateway restarted (PID ${t})`)}catch(t){this.log(`[!!] Could not restart gateway: ${t.message}`)}}else if(O.status!=="foreign")try{let t=A(this.config.version);this.log(`[OK] Gateway started (PID ${t})`)}catch(t){this.log(`[!!] Could not start gateway: ${t.message}`)}let G=await V(s,{timeoutMs:4e3});if(!c)g=e?"ca_not_generated":S.length===0?"no_package_manager":"mitmproxy_install_failed",this.log("[!!] No CA certificate \u2014 NOT setting HTTPS_PROXY (capture stays hooks-only)."),this.log(" Install mitmproxy, then re-run: rulemetric hooks install");else if(G.status==="foreign"&&!d){g="gateway_port_foreign";let t=D(s);this.log(`[!!] Port :${s} is held by a process that is NOT the RuleMetric gateway \u2014 NOT setting HTTPS_PROXY.`),this.log(t?` Holding the port: ${t}`:` Could not identify the holder (try: lsof -nP -iTCP:${s} -sTCP:LISTEN)`),this.log(" Capture still works via hooks. Free the port, then re-run: rulemetric hooks install")}else if(G.status==="dead")g="gateway_not_live",this.log(`[!!] Gateway is not answering on :${s} \u2014 NOT setting HTTPS_PROXY.`),this.log(" Capture still works via hooks. To enable deep (proxy) capture later:"),this.log(" rulemetric proxy start && rulemetric hooks install");else{let t=n.env??{};t.HTTPS_PROXY=`http://localhost:${s}`,t.NO_PROXY=ot,u(o)&&(t.NODE_EXTRA_CA_CERTS=o),n.env=t,b=!0,this.log(`[OK] HTTPS_PROXY set to gateway on :${s} (verified live)`),ct(a,s,o)&&this.log("[OK] Cursor proxy configured \u2192 .cursor/settings.json"),ut(a,s,o)&&this.log("[OK] VS Code workspace proxy configured \u2192 .vscode/settings.json"),ht(s)&&this.log("[OK] VS Code user proxy configured \u2192 ~/Library/Application Support/Code/User/settings.json"),gt(s)&&this.log("[OK] Cursor user proxy configured \u2192 ~/Library/Application Support/Cursor/User/settings.json"),p?dt(s,o)&&this.log("[OK] HTTPS_PROXY set for GUI apps (launchctl + LaunchAgent)"):(g="ca_untrusted",this.log("[!!] CA not trusted \u2014 skipping machine-wide GUI proxy (would break native-app TLS)."),this.log(" Claude Code capture is unaffected. Trust the CA + re-run to enable cross-app capture."))}}let v=[];if(!r){let e=at(a,k);e&&(this.log(`[OK] Cursor hooks configured \u2192 ${e}`),v.push(e));let c=lt(a,k);c&&(this.log(`[OK] Copilot Agent hooks configured \u2192 ${c}`),v.push(c));let d=pt(a);d&&(this.log(`[OK] Antigravity workspace hooks configured \u2192 ${d}`),v.push(d))}let H=i["user-hooks"]?ft():null;H&&this.log(`[OK] Antigravity user hooks configured \u2192 ${H}`);let U=i["user-hooks"]?nt(k):null;if(U&&this.log(`[OK] Cursor user hooks configured \u2192 ${U}`),i["user-hooks"]||(this.log("[--] Skipped user-level Cursor/Antigravity hooks (--no-user-hooks)."),this.log(" Cursor capture will not work: its chat traffic bypasses the proxy,"),this.log(" so hooks are the only path. Claude Code capture is unaffected.")),i["statusline-usage"])if(R(n))this.log("[OK] Statusline shim already installed");else{let e=Q(n);z(e),n.statusLine=m,e?this.log(`[OK] Statusline shim installed \u2192 ${m.command} (chains to: ${e})`):this.log(`[OK] Statusline shim installed \u2192 ${m.command}`),this.log(" Rate-limit rings will now update on Claude Code's statusline refresh cadence")}let{backupPath:N}=tt(C,n);N&&this.log(`[OK] Backed up previous settings \u2192 ${N}`),this.log(""),this.log("Setup complete! Next steps:"),r?(this.log(" 1. Install always-on API: rulemetric service install"),this.log(" 2. Start Claude Code in any project \u2014 all sessions tracked automatically"),this.log(""),this.log("The API service starts on login and restarts on crash.")):P?(this.log(" 1. Start Claude Code \u2014 sessions are captured by the hooks just installed"),this.log(""),this.log("No proxy means no mitmproxy / CA cert needed. The hooks capture full"),this.log("sessions on their own; re-run without --no-proxy to also capture system"),this.log("prompts for instruction-effectiveness linking.")):(this.log(" 1. Start Claude Code \u2014 sessions are captured by hooks immediately"),b?this.log(" 2. Full-depth capture is ON \u2014 the proxy is live on :"+s+"."):this.log(" 2. Enable full depth (proxy not yet live): rulemetric proxy start"),this.log(""),this.log("Hooks capture every session (lifecycle + transcript). The proxy adds the"),this.log("rendered system prompt (instruction-effectiveness linking) + cross-tool capture."),this.log(""),this.log("To capture traffic from other clients (Python, curl, etc.):"),this.log(' eval "$(rulemetric proxy env --all)"'));let j=mt(a,v);j&&this.log(j),await M(),Y("hooks_installed",{proxy:b,caTrusted:p,reason:g,installers:S,global:r},this.config.version);let T=await yt();this.log(""),T.available?this.log(`[OK] tmux found${T.version?` (v${T.version})`:""} \u2014 live send enabled`):this.log("[!!] tmux not found \u2014 live send will fall back to opening Terminal. Install with: brew install tmux")}installMitmproxy(){for(let[i,r]of[["pipx",["install","mitmproxy"]],["uv",["tool","install","mitmproxy"]],["brew",["install","mitmproxy"]]]){let a=f(i);if(a&&(this.log(` Installing via ${i}...`),l(a,[...r],{stdio:"inherit"}).status===0))return!0}return!1}isCACertTrusted(){return process.platform==="darwin"?l("security",["verify-cert","-c",o],{stdio:"pipe"}).status===0:process.platform==="linux"?u("/usr/local/share/ca-certificates/mitmproxy-ca.crt"):process.platform==="win32"?l("certutil",["-verify",o],{stdio:"pipe"}).status===0:!1}trustCACert(){return process.platform==="darwin"?l("sudo",["security","add-trusted-cert","-d","-r","trustRoot","-k","/Library/Keychains/System.keychain",o],{stdio:"inherit"}).status===0:process.platform==="linux"?l("sudo",["cp",o,"/usr/local/share/ca-certificates/mitmproxy-ca.crt"],{stdio:"inherit"}).status!==0?!1:l("sudo",["update-ca-certificates"],{stdio:"inherit"}).status===0:process.platform==="win32"?l("certutil",["-addstore","-f","Root",o],{stdio:"inherit"}).status===0:!1}};export{K as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as m,b as f,d as g}from"../../chunk-
|
|
1
|
+
import{a as m,b as f,d as g}from"../../chunk-AEIKPNLG.js";import{a as d}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as u}from"../../chunk-ZLLER3HP.js";import{Args as v}from"@oclif/core";import{execFileSync as S}from"node:child_process";import{existsSync as y}from"node:fs";import{join as k,delimiter as E}from"node:path";var O=["session-start","session-end","user-prompt","post-tool-use","assistant-response"],p=class h extends d{static{u(this,"HooksRun")}static description="Execute a hook script (called by AI tool hooks, not for direct use)";static hidden=!0;static args={hook:v.string({description:"Hook name to run",required:!0,options:[...O]})};async run(){let{args:o}=await this.parse(h),s=o.hook,{scriptsDir:r}=await import("@rulemetric/hooks/scripts-dir"),n=k(r,`${s}.sh`);y(n)||this.error(`Hook script not found: ${n}`);try{let e=await this.readStdin();try{let{evaluateHookCaptureGate:t}=await import("../../lib/hooks-capture-gate.js"),{getDefaultConfigDir:w}=await import("../../lib/auth.js");if(!(await t({stdin:e,configDir:w()})).allowed)return}catch{}let a=`${process.env.PATH??""}${E}${r}`,l=s==="session-end"?3e4:1e4,i=s==="session-start"?m(e):null,c="";try{c=S("bash",[n],{input:e,stdio:["pipe",i?"pipe":"inherit","inherit"],timeout:l,env:{...process.env,PATH:a}})?.toString()??""}catch(t){if(!i)throw t;c=t.stdout?.toString()??""}if(i){let t=await g(i.cwd);process.stdout.write(f(c,t?.message??null)),t?.emitted()}if(process.env.RULEMETRIC_HOOK_TOOL==="antigravity"&&s==="post-tool-use")try{let{tailAntigravityTranscript:t}=await import("../../lib/antigravity-transcript.js");await t(e)}catch(t){process.stderr.write(`[antigravity-tailer] ${t.message}
|
|
2
2
|
`)}}catch(e){let a=e.status;process.env.RULEMETRIC_HOOK_DEBUG&&process.stderr.write(`[rulemetric hooks run ${s}] non-fatal exit ${a??"?"}: ${e.message??""}
|
|
3
3
|
`)}}readStdin(){return new Promise(o=>{let s=[];process.stdin.on("data",r=>s.push(r)),process.stdin.on("end",()=>o(Buffer.concat(s).toString("utf-8"))),process.stdin.readableEnded&&o(Buffer.concat(s).toString("utf-8"))})}};export{p as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as v,n as y}from"../../chunk-QWCEZEDO.js";import"../../chunk-KKDHD4XA.js";import"../../chunk-SZ62CP55.js";import{C as j,F as b,J as A,K as w,o as R,s as k,t as x,w as C,x as S,z as P}from"../../chunk-OZQNSELV.js";import"../../chunk-HFGO5762.js";import"../../chunk-VS5ROGDP.js";import{a as p}from"../../chunk-
|
|
1
|
+
import{e as v,n as y}from"../../chunk-QWCEZEDO.js";import"../../chunk-KKDHD4XA.js";import"../../chunk-SZ62CP55.js";import{C as j,F as b,J as A,K as w,o as R,s as k,t as x,w as C,x as S,z as P}from"../../chunk-OZQNSELV.js";import"../../chunk-HFGO5762.js";import"../../chunk-VS5ROGDP.js";import{a as p}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as l}from"../../chunk-ZLLER3HP.js";import{existsSync as c,readFileSync as N,writeFileSync as T}from"node:fs";import{spawnSync as s}from"node:child_process";import{homedir as O}from"node:os";import{join as u}from"node:path";import{Flags as a}from"@oclif/core";var i=u(O(),".mitmproxy","mitmproxy-ca-cert.pem");function E(){return c(i)?process.platform==="darwin"?s("sudo",["security","remove-trusted-cert","-d",i],{stdio:"inherit"}).status===0:process.platform==="linux"?s("sudo",["rm","-f","/usr/local/share/ca-certificates/mitmproxy-ca.crt"],{stdio:"inherit"}).status!==0?!1:s("sudo",["update-ca-certificates","--fresh"],{stdio:"inherit"}).status===0:process.platform==="win32"?s("certutil",["-delstore","Root","mitmproxy"],{stdio:"inherit"}).status===0:!1:!1}l(E,"untrustCACert");var m=class f extends p{static{l(this,"HooksUninstall")}static flags={global:a.boolean({description:"Remove the GLOBAL install (~/.claude) rather than this project",default:!1}),"project-dir":a.string({description:"Project directory to clean (defaults to cwd)"}),"user-hooks":a.boolean({description:"Also strip user-level Cursor/Antigravity hooks (~/.cursor, ~/.gemini)",default:!0,allowNo:!0})};static description="Remove session tracking hooks from a project (or the global install)";static examples=["<%= config.bin %> hooks uninstall","<%= config.bin %> hooks uninstall --global","<%= config.bin %> hooks uninstall --project-dir ~/work/repo-a","<%= config.bin %> hooks uninstall --no-user-hooks"];async run(){let{flags:r}=await this.parse(f),t=r.global?O():r["project-dir"]??process.cwd(),d=u(t,".claude");r.global&&this.log(`Removing the GLOBAL install \u2192 ${d}`);let h=R(d,v);if(h.length===0){this.log("No .claude/settings.json or .claude/settings.local.json found \u2014 nothing to uninstall.");return}let e=!1,g=!1;for(let o of h)o.recoveredBackup&&this.log(`[!!] ${o.configPath} was not valid JSON \u2014 backed up to ${o.recoveredBackup}; continuing.`),o.removedHooks&&this.log(`Removed RuleMetric hooks from .claude/${o.fileName}`),o.removedProxyEnv&&(this.log(`Removed HTTPS_PROXY, NO_PROXY and NODE_EXTRA_CA_CERTS from .claude/${o.fileName}`),g=!0),o.removedStatusline&&this.log(`Removed RuleMetric statusline shim from .claude/${o.fileName}`),e=e||o.changed;e||this.log("No hooks or proxy config found \u2014 nothing to uninstall."),k(t)&&(this.log("Removed RuleMetric hooks from .cursor/hooks.json"),e=!0),r["user-hooks"]&&x()&&(this.log("Removed RuleMetric hooks from ~/.cursor/hooks.json"),e=!0);let n=u(t,".cursor","settings.json");if(c(n))try{let o=JSON.parse(N(n,"utf-8"));o["http.proxy"]?.includes("localhost")&&(delete o["http.proxy"],delete o["http.proxyStrictSSL"],T(n,JSON.stringify(o,null,2)+`
|
|
2
2
|
`),this.log("Removed proxy config from .cursor/settings.json"),e=!0)}catch{}S(t)&&(this.log("Removed RuleMetric hooks from .github/hooks/"),e=!0),A(t)&&(this.log("Removed RuleMetric block from .agents/hooks.json"),e=!0),r["user-hooks"]&&w()&&(this.log("Removed RuleMetric block from ~/.gemini/config/hooks.json"),e=!0),C(t)&&(this.log("Removed proxy config from .vscode/settings.json"),e=!0),j()&&(this.log("Removed proxy config from VS Code user settings"),e=!0),b()&&(this.log("Removed proxy config from Cursor user settings"),e=!0),P()&&(this.log("Removed HTTPS_PROXY LaunchAgent"),e=!0),g&&c(i)&&(this.log("Removing the mitmproxy CA from the system trust store (requires sudo)..."),E()?this.log("[OK] mitmproxy CA untrusted."):(this.log("[!!] Could not untrust the CA automatically. Remove it manually:"),process.platform==="darwin"?this.log(` sudo security remove-trusted-cert -d ${i}`):process.platform==="linux"&&this.log(" sudo rm -f /usr/local/share/ca-certificates/mitmproxy-ca.crt && sudo update-ca-certificates --fresh"))),y()&&this.log("Gateway stopped.")}};export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"../../chunk-
|
|
1
|
+
import{a as p}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{f}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as d}from"../../chunk-ZLLER3HP.js";import*as s from"node:fs";import{Args as m,Flags as t}from"@oclif/core";var c=class u extends p{static{d(this,"InstructionsCreate")}static description="Create a new instruction";static examples=['<%= config.bin %> instructions create ./my-instruction.md --name "My Rules" --description "Team coding rules"','<%= config.bin %> instructions create ./rules.md -n "Rules" -d "Project rules" -s project'];static args={file:m.string({description:"Path to markdown file"})};static flags={name:t.string({char:"n",description:"Instruction name",required:!0}),description:t.string({char:"d",description:"Instruction description",required:!0}),scope:t.string({char:"s",description:"Instruction scope",options:["org","team","project","personal"],default:"personal"}),"scope-ref":t.string({description:"Scope reference UUID"}),tags:t.string({char:"t",description:"Comma-separated tags"})};async run(){let{args:i,flags:e}=await this.parse(u);this.requireAuth();let n;if(i.file)s.existsSync(i.file)||this.error(`File not found: ${i.file}`),n=s.readFileSync(i.file,"utf-8");else{this.log("No file provided. Paste content (Ctrl+D to finish):");let r=[];for await(let l of process.stdin)r.push(l);n=Buffer.concat(r).toString("utf-8")}let o={name:e.name,description:e.description,scope:e.scope,content:n};e["scope-ref"]&&(o.scopeRef=e["scope-ref"]),e.tags&&(o.tags=e.tags.split(",").map(r=>r.trim()));let a=await f("/api/instructions",o);this.log(`Created instruction: ${a.name} (${a.id})`)}};export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as p}from"../../chunk-LJRE3LZ2.js";import{a as m}from"../../chunk-
|
|
1
|
+
import{e as p}from"../../chunk-LJRE3LZ2.js";import{a as m}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import{E as f}from"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a}from"../../chunk-ZLLER3HP.js";import{Flags as $}from"@oclif/core";var l=class n extends m{static{a(this,"InstructionsDedupe")}static description="Report instructions in this project that repeat each other in different words";static examples=["<%= config.bin %> instructions dedupe","<%= config.bin %> instructions dedupe --dir apps/cli"];static flags={dir:$.string({description:"Directory whose CLAUDE.md to check (ancestors are included)",default:"."}),threshold:$.string({description:"Similarity floor 0-1 for calling two asks the same (default 0.3)"})};async run(){let{flags:i}=await this.parse(n),o=i.threshold===void 0?void 0:Number(i.threshold);o!==void 0&&(!Number.isFinite(o)||o<=0||o>1)&&this.error("--threshold must be a number greater than 0 and at most 1");let s=p(i.dir);if(s.length===0){this.log(`No CLAUDE.md found at or above ${i.dir}.`);return}let h=[...new Set(s.map(t=>t.source).filter(Boolean))];this.log(`Checked ${s.length} instruction(s) across ${h.length} file(s):`);for(let t of h)this.log(` ${t}`);this.log("");let d=f(s,o);if(d.length===0){this.log("No repeated instructions found.");return}let u=[...d].sort((t,e)=>Number(e.verdict.redundant)-Number(t.verdict.redundant));for(let{instruction:t,verdict:e}of u){let v=e.redundant?"FULLY COVERED \u2014 says nothing the earlier rules do not":`PARTLY COVERED \u2014 ${e.matches.length} of ${e.matches.length+e.novel.length} asks are repeats`;this.log(`${t.source??""} \xB7 ${t.id}`),this.log(` ${v}`);for(let r of e.matches)this.log(` "${c(r.directive)}"`),this.log(` \u21B3 ${(r.similarity*100).toFixed(0)}% match with ${r.matchedSource??r.matchedId}: "${c(r.matchedDirective)}"`);for(let r of e.novel)this.log(` KEEPS: "${c(r)}"`);e.redundant&&!t.id.includes("#handwritten")&&this.log(` Remove it: rulemetric suggestions undo ${t.id}`),this.log("")}let g=u.filter(t=>t.verdict.redundant).length;this.log(`${d.length} instruction(s) repeat earlier ones; ${g} ${g===1?"adds":"add"} nothing new. Nothing was changed \u2014 review each before removing it.`)}};function c(n,i=96){return n.length<=i?n:`${n.slice(0,i-1)}\u2026`}a(c,"clip");export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"../../chunk-WLVQJH4E.js";import{a}from"../../chunk-
|
|
1
|
+
import{a as c}from"../../chunk-WLVQJH4E.js";import{a}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as n,i as s}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as r}from"../../chunk-ZLLER3HP.js";import{Args as f,Flags as u}from"@oclif/core";var o=class d extends a{static{r(this,"InstructionsDelete")}static description="Delete (archive) an instruction";static examples=["<%= config.bin %> instructions delete <id>","<%= config.bin %> instructions delete <id> --force"];static args={id:f.string({description:"Instruction ID",required:!0})};static flags={force:u.boolean({char:"f",description:"Skip confirmation prompt",default:!1})};async run(){let{args:i,flags:l}=await this.parse(d);this.requireAuth(),c(i.id,"instruction ID");let t=await n(`/api/instructions/${encodeURIComponent(i.id)}`);if(!l.force){let{confirm:m}=await import("@inquirer/prompts");if(!await m({message:`Are you sure you want to delete "${t.name}"?`,default:!1})){this.log("Cancelled.");return}}await s(`/api/instructions/${encodeURIComponent(i.id)}`),this.log(`Archived instruction: ${t.name}`);let e=t.contextIdentity;e&&!e.startsWith("public_skill::")&&(this.log(""),this.log("NOTE: this archived the database row only \u2014 nothing was removed from disk."),this.log(` Still present: ${e.split("::").slice(1).join("::")}`),this.log(` To remove it from the file: rulemetric instructions retract ${i.id}`))}};export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../../chunk-
|
|
1
|
+
import{a as s}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{f as o}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as t}from"../../chunk-ZLLER3HP.js";import{Args as a}from"@oclif/core";var i=class e extends s{static{t(this,"InstructionsFork")}static description="Fork an instruction to your personal scope";static examples=["<%= config.bin %> instructions fork <instruction-id>"];static args={id:a.string({description:"ID of the instruction to fork",required:!0})};async run(){let{args:n}=await this.parse(e);this.requireAuth();let r=await o(`/api/instructions/${n.id}/fork`,{});this.log(`Forked instruction: ${r.name} (${r.id})`)}};export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l}from"../../chunk-WLVQJH4E.js";import{a as i,c}from"../../chunk-W2MV25SB.js";import{a}from"../../chunk-
|
|
1
|
+
import{a as l}from"../../chunk-WLVQJH4E.js";import{a as i,c}from"../../chunk-W2MV25SB.js";import{a}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as e}from"../../chunk-ZLLER3HP.js";import{Args as g,Flags as m}from"@oclif/core";var o=class d extends a{static{e(this,"InstructionsGet")}static description="Get an instruction by ID";static examples=["<%= config.bin %> instructions get <id>","<%= config.bin %> instructions get <id> --format raw"];static enableJsonFlag=!0;static args={id:g.string({description:"Instruction ID",required:!0})};static flags={format:m.string({char:"f",description:"Output format",options:["yaml","json","raw"],default:"yaml"})};async run(){let{args:r,flags:s}=await this.parse(d);this.requireAuth(),l(r.id,"instruction ID");let t=await n(`/api/instructions/${encodeURIComponent(r.id)}`);return s.format==="json"?this.log(JSON.stringify(t,null,2)):s.format==="raw"?this.log(t.content):(this.log(`Name: ${t.name}`),this.log(`Description: ${t.description}`),this.log(`Scope: ${c(t.scope)}`),this.log(`Version: ${t.version}`),this.log(`Tags: ${(t.tags??[]).join(", ")||"(none)"}`),this.log(`Created: ${i(t.createdAt)}`),this.log(`Updated: ${i(t.updatedAt)}`),this.log(""),this.log("--- Content ---"),this.log(t.content)),t}};export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as n,c as m}from"../../chunk-W2MV25SB.js";import{a as s}from"../../chunk-
|
|
1
|
+
import{a,b as n,c as m}from"../../chunk-W2MV25SB.js";import{a as s}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as i}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Flags as p}from"@oclif/core";import{printTable as l}from"@oclif/table";var e=class c extends s{static{o(this,"InstructionSummarysList")}static description="List your instructions";static examples=["<%= config.bin %> instructions list","<%= config.bin %> instructions list --json"];static enableJsonFlag=!0;static flags={format:p.string({char:"f",description:"Output format",options:["table","json"],default:"table"})};async run(){let{flags:u}=await this.parse(c);this.requireAuth();let t=await i("/api/instructions");return t.length===0?(this.log("No instructions found. Create one with `rulemetric instructions create`."),t):(u.format==="json"?this.log(JSON.stringify(t,null,2)):l({data:t.map(r=>({Name:n(r.name,40),Scope:m(r.scope),Version:r.version,Tags:(r.tags??[]).join(", "),Updated:a(r.updatedAt)})),columns:["Name","Scope","Version","Tags","Updated"]}),t)}};export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../../chunk-
|
|
1
|
+
import{a as s}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{f as i}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as t}from"../../chunk-ZLLER3HP.js";import{Args as p,Flags as a}from"@oclif/core";var e=class n extends s{static{t(this,"InstructionsPromote")}static description="Promote an instruction to a higher scope (personal \u2192 team \u2192 org)";static examples=["<%= config.bin %> instructions promote <id> --scope team --ref <team-id>","<%= config.bin %> instructions promote <id> --scope org --ref <org-id>"];static args={id:p.string({description:"ID of the instruction to promote",required:!0})};static flags={scope:a.string({description:"Target scope",required:!0,options:["team","org"]}),ref:a.string({description:"Target scope ref (team or org ID)",required:!0})};async run(){let{args:c,flags:r}=await this.parse(n);this.requireAuth();let o=await i(`/api/instructions/${c.id}/promote`,{scope:r.scope,scopeRef:r.ref});this.log(`Promoted "${o.name}" to ${o.scope} scope`)}};export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"../../chunk-
|
|
1
|
+
import{a as r}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{f as s}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{Args as a}from"@oclif/core";var e=class o extends r{static{i(this,"InstructionsPull")}static description="Pull upstream changes into a forked instruction";static args={id:a.string({description:"ID of the forked instruction",required:!0})};async run(){let{args:n}=await this.parse(o);this.requireAuth();let t=await s(`/api/instructions/${n.id}/pull-upstream`,{});t.hasConflicts?(this.log("Merge conflicts detected. Resolve in the web UI:"),this.log(t.merged??"")):this.log(`Successfully pulled upstream changes into "${t.instruction?.name}"`)}};export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../../chunk-WLVQJH4E.js";import{a as o}from"../../chunk-
|
|
1
|
+
import{a as s}from"../../chunk-WLVQJH4E.js";import{a as o}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{f as e}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as r}from"../../chunk-ZLLER3HP.js";import{Args as d}from"@oclif/core";var t=class n extends o{static{r(this,"InstructionsRestore")}static description="Restore an archived instruction";static examples=["<%= config.bin %> instructions restore <id>"];static args={id:d.string({description:"Instruction ID",required:!0})};async run(){let{args:i}=await this.parse(n);this.requireAuth(),s(i.id,"instruction ID");let a=await e(`/api/instructions/${encodeURIComponent(i.id)}/restore`,{});this.log(`Restored: ${a.name} is active again.`),this.log("If it was removed from CLAUDE.md, re-add it with: rulemetric instructions get "+i.id)}};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as f,d as l,e as p}from"../../chunk-
|
|
1
|
+
import{b as f,d as l,e as p}from"../../chunk-EBGVDX3Z.js";import"../../chunk-UPFH72PF.js";import{a as m}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as c}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as u}from"../../chunk-ZLLER3HP.js";import{Args as v,Flags as r}from"@oclif/core";var g=class k extends m{static{u(this,"InstructionsRetract")}static description="Remove an instruction, skill, hook or MCP server from disk (dry-run by default)";static examples=["<%= config.bin %> instructions retract <instruction-id>","<%= config.bin %> instructions retract <instruction-id> --apply","<%= config.bin %> instructions retract --kind skill --target agent-browser","<%= config.bin %> instructions retract --kind mcp --target supabase --apply",'<%= config.bin %> instructions retract --kind hook --target "doomed-tool" --apply'];static args={id:v.string({description:"Instruction ID (omit when using --kind/--target)",required:!1})};static flags={apply:r.boolean({description:"Actually write. Without this, nothing is modified.",default:!1}),force:r.boolean({description:"Proceed without a randomised verdict (observational evidence only)",default:!1}),kind:r.string({description:"Retract something that is not an instruction row",options:["claude-md","memory","skill","hook","mcp"]}),target:r.string({description:"File path, skill name, MCP server name, or hook command substring"}),heading:r.string({description:"Markdown heading to remove (defaults to the instruction name)"})};async run(){let{args:n,flags:i}=await this.parse(k);!n.id&&!(i.kind&&i.target)&&this.error("Provide an instruction ID, or both --kind and --target.");let h=process.cwd(),e,a;if(n.id){this.requireAuth();let t=await c(`/api/instructions/${n.id}`);a=t.name;let o=await this.fetchVerdict(n.id);if(!o&&!i.force){this.log(""),this.log(`No randomised verdict exists for "${t.name}".`),this.log(""),this.log('Every removal signal available today \u2014 including "measured harmful" \u2014 comes from the'),this.log("OBSERVATIONAL path, which is confounded (docs/architecture/effectiveness.md \xA712)."),this.log("Deleting a file on that evidence is the exact conflation \xA713 forbids."),this.log(""),this.log("Re-run with --force if you want to act on observational evidence anyway.");return}o?this.log(`Randomised verdict: ${o.decision} (\u0394 ${o.delta}, n=${o.nTreated}/${o.nControl})`):this.log("\u26A0 Proceeding on OBSERVATIONAL evidence (--force). This signal is confounded.");let s=t.contextIdentity?f(t.contextIdentity):null;if(!s){this.log(""),this.log(`"${t.name}" has no local file behind it (context identity: ${t.contextIdentity??"none"}).`),this.log("Catalog rows live only in the database \u2014 there is nothing on disk to retract.");return}e=l({kind:s.kind,target:s.target,heading:i.heading??t.name,body:s.kind==="claude_md_section"?t.content:void 0,cwd:h})}else{let t={"claude-md":"claude_md_section",memory:"memory_section",skill:"skill_file",hook:"settings_hook",mcp:"mcp_server"};a=i.target,e=l({kind:t[i.kind],target:i.target,heading:i.heading,cwd:h})}if(this.log(""),!e.ok){this.log(`Cannot retract "${a}":`),this.log(""),this.log(e.refusal??"unknown reason"),this.log(""),this.log("Nothing was modified.");return}this.log(`${e.deletesFile?"DELETE":"EDIT"} ${e.path}`),this.log(""),this.log(e.preview),this.log("");for(let t of e.warnings)this.log(`\u26A0 ${t}`);if(!i.apply){this.log(""),this.log("Dry run \u2014 nothing was modified. Re-run with --apply to write.");return}let y=new Date().toISOString().replace(/[:.]/g,"-"),d=p(e,y);d.applied||this.error(`Retraction failed: ${d.error}. Nothing was modified.`),this.log(""),this.log(`\u2713 Retracted from ${e.path}`),this.log(` Backup: ${d.backupPath}`),this.log(" Undo: restore that file, or `git checkout -- <path>` if it is tracked.")}async fetchVerdict(n){try{return(await c(`/api/instruction-verdicts?instructionId=${n}`)).verdicts?.[0]??null}catch{return null}}};export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as s}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{Args as n}from"@oclif/core";var e=class o extends a{static{i(this,"InstructionsUpstream")}static description="Check if a forked instruction has upstream updates";static args={id:n.string({description:"ID of the forked instruction",required:!0})};async run(){let{args:r}=await this.parse(o);this.requireAuth();let t=await s(`/api/instructions/${r.id}/upstream`);t.hasUpdate?(this.log(`Upstream update available: ${t.parentName} is at ${t.upstreamVersion} (you have ${t.currentVersion})`),this.log(`Run: rulemetric instructions pull ${r.id}`)):this.log("Up to date with upstream.")}};export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as m}from"../../chunk-WLVQJH4E.js";import{a}from"../../chunk-W2MV25SB.js";import{a as s}from"../../chunk-
|
|
1
|
+
import{a as m}from"../../chunk-WLVQJH4E.js";import{a}from"../../chunk-W2MV25SB.js";import{a as s}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{e as n}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as o}from"../../chunk-ZLLER3HP.js";import{Args as c}from"@oclif/core";import{printTable as d}from"@oclif/table";var i=class u extends s{static{o(this,"InstructionsVersions")}static description="List version history for an instruction";static examples=["<%= config.bin %> instructions versions <id>"];static enableJsonFlag=!0;static args={id:c.string({description:"Instruction ID",required:!0})};async run(){let{args:e}=await this.parse(u);this.requireAuth(),m(e.id,"instruction ID");let r=await n(`/api/instructions/${encodeURIComponent(e.id)}/versions`);return r.length===0?(this.log("No versions found."),r):(d({data:r.map(t=>({Version:String(t.versionNumber),"Change Summary":t.changeSummary??"(none)","Created At":a(t.createdAt)})),columns:["Version","Change Summary","Created At"]}),r)}};export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"../chunk-
|
|
1
|
+
import{a as r}from"../chunk-Z7LBSVG3.js";import"../chunk-IZTIYR5Q.js";import"../chunk-RFLO7L5X.js";import"../chunk-KTLRSRHF.js";import"../chunk-7CQBFCHP.js";import"../chunk-3AV3GTMP.js";import"../chunk-E5FI5YHO.js";import"../chunk-I2U5GNNM.js";import"../chunk-XQYAVSUQ.js";import"../chunk-PZNWH4VQ.js";import{a as i}from"../chunk-ZLLER3HP.js";var e=class extends r{static{i(this,"Launcher")}static hidden=!0;static description="Manual session launching is currently unavailable";async run(){this.error("Manual session launching has been shelved. Start your coding tool directly, or use `rulemetric dashboard` to view activity.")}};export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t,d as c}from"../../chunk-HRXACKAH.js";import{a as l}from"../../chunk-
|
|
1
|
+
import{c as t,d as c}from"../../chunk-HRXACKAH.js";import{a as l}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import"../../chunk-KTLRSRHF.js";import"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import"../../chunk-PZNWH4VQ.js";import{a as i}from"../../chunk-ZLLER3HP.js";import{Flags as u}from"@oclif/core";import{execFileSync as m,execSync as f,spawnSync as h}from"node:child_process";import{existsSync as d,rmSync as g}from"node:fs";import{homedir as b}from"node:os";import{join as n}from"node:path";var a=n(b(),"Library","LaunchAgents",`${c}.plist`),s=class p extends l{static{i(this,"LocalDown")}static description="Stop the local RuleMetric server and database stack. Data is preserved (restart with `rulemetric local up`); use --delete-data to also wipe the local database.";static flags={"delete-data":u.boolean({default:!1,description:"Also delete the local database volumes (irreversible)"})};async run(){let{flags:o}=await this.parse(p);if(process.platform==="darwin"&&d(a)){let e=f("id -u",{encoding:"utf-8"}).trim();try{m("launchctl",["bootout",`gui/${e}`,a],{stdio:["ignore","pipe","pipe"]}),this.log("[OK] Stopped the local server")}catch{}g(a,{force:!0})}if(d(n(t,"supabase","config.toml"))){let e=o["delete-data"]?["stop","--no-backup"]:["stop"],r=h("supabase",e,{cwd:t,stdio:"inherit"});r.status!==0?this.warn(`\`supabase ${e.join(" ")}\` exited ${r.status} \u2014 the stack may not have been running.`):this.log(o["delete-data"]?"[OK] Database stack stopped and data deleted":"[OK] Database stack stopped (data preserved)")}else this.log("No local stack configured (nothing to stop). Run: rulemetric local up")}};export{s as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as o,b as O,c as x,d as U}from"../../chunk-XB4OMOSE.js";import{a as E,c as p,d as h,h as m,i as f,j as D,l as C,m as I,n as _}from"../../chunk-HRXACKAH.js";import{a as $}from"../../chunk-
|
|
1
|
+
import{a as o,b as O,c as x,d as U}from"../../chunk-XB4OMOSE.js";import{a as E,c as p,d as h,h as m,i as f,j as D,l as C,m as I,n as _}from"../../chunk-HRXACKAH.js";import{a as $}from"../../chunk-NJKPUZNM.js";import{a as A}from"../../chunk-Z7LBSVG3.js";import"../../chunk-IZTIYR5Q.js";import"../../chunk-RFLO7L5X.js";import{c as T}from"../../chunk-KTLRSRHF.js";import{b as R}from"../../chunk-7CQBFCHP.js";import"../../chunk-3AV3GTMP.js";import{b as S,d}from"../../chunk-E5FI5YHO.js";import"../../chunk-I2U5GNNM.js";import"../../chunk-XQYAVSUQ.js";import{d as L,h as P}from"../../chunk-PZNWH4VQ.js";import{a as w}from"../../chunk-ZLLER3HP.js";import{Flags as l}from"@oclif/core";import{execSync as H,spawnSync as a}from"node:child_process";import{mkdirSync as M}from"node:fs";import{homedir as b}from"node:os";import{dirname as G,join as n}from"node:path";var K=n(b(),"Library","LaunchAgents",`${h}.plist`),g=n(b(),".config","rulemetric","logs"),v=class B extends A{static{w(this,"LocalUp")}static description="Run RuleMetric fully locally: start a local Supabase stack (Docker), apply migrations, and serve the API + dashboard from the @rulemetric/local runtime \u2014 all data on this machine, zero cloud contact. Downloads the runtime package on first run.";static examples=["<%= config.bin %> local up --email you@example.com --password <pw>","<%= config.bin %> local up --port 3000","<%= config.bin %> local up --foreground"];static flags={port:l.integer({char:"p",default:3e3,description:"Local API + dashboard port"}),email:l.string({char:"e",description:"Create the first user with this email (with --password)"}),password:l.string({description:"Password for the first user (min 8 chars)"}),foreground:l.boolean({default:!1,description:"Run the server in this terminal instead of installing a launchd service (works on any OS; skips user provisioning)"}),yes:l.boolean({char:"y",default:!1,description:"Skip the runtime-download confirmation"})};async run(){let{flags:s}=await this.parse(B),t=s.port;!s.foreground&&process.platform!=="darwin"&&this.error(`The managed local service is macOS-only (launchd) for now. On this OS, run the server in the foreground instead:
|
|
2
2
|
rulemetric local up --foreground`),a("docker",["info"],{stdio:"ignore"}).status!==0&&this.error(`Docker is not running (or not installed). The local database runs in Docker.
|
|
3
3
|
Install/start Docker Desktop (or colima), then re-run: rulemetric local up`),a("supabase",["--version"],{stdio:"ignore"}).status!==0&&this.error(`The Supabase CLI is required to manage the local database stack.
|
|
4
4
|
Install it: brew install supabase/tap/supabase (or see supabase.com/docs/guides/cli)
|