@rulemetric/cli 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/dist/base-command.js +1 -14
- package/dist/chunk-2JRDG4LJ.js +31 -0
- package/dist/chunk-2TC6WCUT.js +34 -0
- package/dist/chunk-2WLVDSAP.js +2 -0
- package/dist/chunk-32EEBARV.js +1 -0
- package/dist/chunk-3AV3GTMP.js +1 -0
- package/dist/chunk-43YBXX7R.js +1 -0
- package/dist/chunk-4Z5ECCJE.js +1 -0
- package/dist/chunk-5RBLIVBF.js +1 -0
- package/dist/chunk-67QCYUJU.js +1 -0
- package/dist/chunk-6QKI756T.js +2 -0
- package/dist/chunk-6V4WM73L.js +1 -0
- package/dist/chunk-6XEC6474.js +1 -0
- package/dist/chunk-7DFNBRLY.js +61 -0
- package/dist/chunk-ARNZQBMX.js +1 -0
- package/dist/chunk-AYUJY37O.js +5 -0
- package/dist/chunk-CADKBP3D.js +58 -0
- package/dist/chunk-CDI5CCHU.js +1 -0
- package/dist/chunk-CNQ5DTNC.js +1 -0
- package/dist/chunk-DCLWFGEA.js +1 -0
- package/dist/chunk-DNF4HDI6.js +14 -0
- package/dist/chunk-DPFNJZUO.js +1 -0
- package/dist/chunk-DSO2U4Y6.js +56 -0
- package/dist/chunk-DVN7GFJG.js +1 -0
- package/dist/chunk-G63KMH6U.js +1 -0
- package/dist/chunk-G6XGDHGC.js +2 -0
- package/dist/chunk-GBMF3TP6.js +1 -0
- package/dist/chunk-GY5IJ4RS.js +1 -0
- package/dist/chunk-H2ORWIEY.js +1 -0
- package/dist/chunk-H4SV7FN4.js +1 -0
- package/dist/chunk-HS7X43XE.js +24 -0
- package/dist/{chunk-OQBBVTDG.js → chunk-I2DZGJRR.js} +6 -71
- package/dist/chunk-IZTIYR5Q.js +2 -0
- package/dist/chunk-JAPCCEKF.js +3 -0
- package/dist/chunk-JQTGQXUX.js +1 -0
- package/dist/chunk-KAF3CYRW.js +9 -0
- package/dist/chunk-KKDHD4XA.js +2 -0
- package/dist/chunk-KV325CXF.js +33 -0
- package/dist/chunk-MGHFDHHM.js +1 -0
- package/dist/chunk-MODXEGCU.js +1 -0
- package/dist/chunk-MVM6OGAF.js +4 -0
- package/dist/chunk-N7ODX6PO.js +1 -0
- package/dist/chunk-N7TGRFVZ.js +70 -0
- package/dist/chunk-NBTC5FNV.js +1 -0
- package/dist/chunk-NEACEHQD.js +1 -0
- package/dist/chunk-NJ5UED3H.js +1 -0
- package/dist/chunk-NVKX36YN.js +3 -0
- package/dist/chunk-O2SDD2WW.js +1 -0
- package/dist/chunk-O6C2UGBY.js +7 -0
- package/dist/chunk-OMXUK4M6.js +1 -0
- package/dist/chunk-PPKPCXJD.js +4 -0
- package/dist/{chunk-XZXS2W24.js → chunk-QFVGUZDO.js} +11 -57
- package/dist/chunk-RDET7CKR.js +1 -0
- package/dist/chunk-RQ424GI6.js +5 -0
- package/dist/chunk-RSKQRVPJ.js +1 -0
- package/dist/chunk-RTWRHIKY.js +7 -0
- package/dist/chunk-SZ62CP55.js +1 -0
- package/dist/chunk-TDD7IOV2.js +1 -0
- package/dist/chunk-TIOKY2IA.js +1 -0
- package/dist/chunk-TQMG647B.js +15 -0
- package/dist/chunk-TU2AR6XO.js +1 -0
- package/dist/chunk-U6ABMRT3.js +9 -0
- package/dist/chunk-U6XEU573.js +1 -0
- package/dist/chunk-UF6US7VU.js +1 -0
- package/dist/chunk-V44SRRYR.js +1 -0
- package/dist/chunk-V5U3E4BZ.js +1 -0
- package/dist/chunk-VAXRCSSH.js +2 -0
- package/dist/chunk-VLOX6KOM.js +1 -0
- package/dist/chunk-VUGRXM7R.js +1 -0
- package/dist/chunk-W2MOTOQE.js +1 -0
- package/dist/chunk-W2MV25SB.js +1 -0
- package/dist/chunk-WLVQJH4E.js +1 -0
- package/dist/chunk-WSCK4WNK.js +1 -0
- package/dist/chunk-XICLXXRH.js +1 -0
- package/dist/chunk-XXDZJ6YI.js +1 -0
- package/dist/chunk-ZL4MZMUK.js +34 -0
- package/dist/chunk-ZLLER3HP.js +1 -0
- package/dist/chunk-ZR3MUNLS.js +1 -0
- package/dist/chunk-ZXF5NE54.js +1 -0
- package/dist/commands/antigravity/backfill.js +2 -136
- package/dist/commands/auth/create-key.js +1 -52
- package/dist/commands/auth/login.js +1 -85
- package/dist/commands/auth/logout.js +1 -29
- package/dist/commands/auth/revoke-key.js +4 -33
- package/dist/commands/auth/signup.js +1 -89
- package/dist/commands/auth/status.js +1 -42
- package/dist/commands/catalog/index.js +2 -52
- package/dist/commands/catalog/recommend.js +3 -43
- package/dist/commands/convert.js +1 -75
- package/dist/commands/converters.js +1 -54
- package/dist/commands/crons/list.js +1 -41
- package/dist/commands/crons/run.js +2 -76
- package/dist/commands/dashboard.js +1 -46
- package/dist/commands/diagnostics.js +1 -117
- package/dist/commands/eval-targets/create.js +1 -53
- package/dist/commands/eval-targets/list.js +1 -54
- package/dist/commands/evals/agent.js +3 -310
- package/dist/commands/evals/benchmark.js +6 -73
- package/dist/commands/evals/compare.js +13 -96
- package/dist/commands/evals/create.js +1 -67
- package/dist/commands/evals/optimize-description.js +25 -239
- package/dist/commands/evals/optimize.js +5 -211
- package/dist/commands/evals/run.js +3 -183
- package/dist/commands/gateway/ensure.js +1 -104
- package/dist/commands/hooks/emit-instructions.js +1 -25
- package/dist/commands/hooks/install.js +1 -442
- package/dist/commands/hooks/run.js +3 -81
- package/dist/commands/hooks/uninstall.js +2 -156
- package/dist/commands/import.js +1 -66
- package/dist/commands/instructions/create.js +1 -74
- package/dist/commands/instructions/delete.js +1 -55
- package/dist/commands/instructions/fork.js +1 -34
- package/dist/commands/instructions/get.js +1 -68
- package/dist/commands/instructions/list.js +1 -65
- package/dist/commands/instructions/promote.js +1 -42
- package/dist/commands/instructions/pull.js +1 -39
- package/dist/commands/instructions/upstream.js +1 -38
- package/dist/commands/instructions/versions.js +1 -53
- package/dist/commands/launcher.js +1 -40
- package/dist/commands/org/current.js +1 -77
- package/dist/commands/org/list.js +1 -52
- package/dist/commands/org/switch.js +1 -71
- package/dist/commands/packs/add-instruction.js +1 -37
- package/dist/commands/packs/apply.js +1 -39
- package/dist/commands/packs/create.js +1 -50
- package/dist/commands/packs/fork.js +1 -34
- package/dist/commands/packs/get.js +3 -56
- package/dist/commands/packs/list.js +1 -66
- package/dist/commands/packs/remove-instruction.js +1 -35
- package/dist/commands/proxy/env.js +3 -131
- package/dist/commands/proxy/logs.js +3 -85
- package/dist/commands/proxy/restart.js +1 -35
- package/dist/commands/proxy/setup.js +17 -454
- package/dist/commands/proxy/start.js +10 -333
- package/dist/commands/proxy/status.js +1 -78
- package/dist/commands/proxy/stop.js +1 -94
- package/dist/commands/research/backfill.js +1 -59
- package/dist/commands/research/tail-transcript.js +1 -70
- package/dist/commands/service/install.js +57 -796
- package/dist/commands/service/status.js +1 -180
- package/dist/commands/service/uninstall.js +1 -119
- package/dist/commands/sessions/analyze.js +1 -48
- package/dist/commands/sessions/end.js +2 -85
- package/dist/commands/sessions/import.js +1 -46
- package/dist/commands/sessions/list.js +1 -48
- package/dist/commands/sessions/start.js +3 -90
- package/dist/commands/setup.js +3 -150
- package/dist/commands/skills/export-approved.js +1 -46
- package/dist/commands/skills/install.js +4 -107
- package/dist/commands/skills/list.js +4 -65
- package/dist/commands/skills/publish.js +2 -98
- package/dist/commands/skills/search.js +3 -72
- package/dist/commands/skills/update.js +3 -55
- package/dist/commands/suggestions/accept.js +8 -84
- package/dist/commands/suggestions/dismiss.js +1 -45
- package/dist/commands/suggestions/list.js +2 -61
- package/dist/commands/suggestions/refresh.js +1 -27
- package/dist/cursor-T7AMCMKS.js +13 -0
- package/dist/dashboard/Dashboard.js +1 -243
- package/dist/dashboard/data.js +1 -15
- package/dist/dashboard/launcher/ActiveJobsList.js +1 -10
- package/dist/dashboard/launcher/LauncherOverlay.js +1 -16
- package/dist/dashboard/launcher/NewLaunchForm.js +1 -10
- package/dist/dashboard/launcher/api.js +1 -16
- package/dist/dashboard/launcher/tool-labels.js +1 -10
- package/dist/dashboard/launcher/types.js +0 -1
- package/dist/dashboard/launcher/useLaunchJobs.js +1 -11
- package/dist/dashboard/panels/friction.js +1 -10
- package/dist/dashboard/panels/insights.js +1 -10
- package/dist/dashboard/panels/instructions.js +1 -10
- package/dist/dashboard/panels/outcomes.js +1 -10
- package/dist/dashboard/panels/overview.js +1 -10
- package/dist/dashboard/panels/shared.js +1 -19
- package/dist/dashboard/types.js +1 -24
- package/dist/dist-FAVALJ5C.js +1 -0
- package/dist/index.js +1 -8
- package/dist/lib/active-org-refresh.js +1 -15
- package/dist/lib/active-org.js +1 -16
- package/dist/lib/agent-loop.js +1 -47
- package/dist/lib/antigravity-transcript.js +1 -22
- package/dist/lib/api-client.js +1 -23
- package/dist/lib/auth.js +1 -30
- package/dist/lib/capture-hosts.js +1 -8
- package/dist/lib/detect-languages.js +1 -8
- package/dist/lib/detect-tmux.js +1 -9
- package/dist/lib/diagnostics.js +1 -12
- package/dist/lib/editor-proxy-pins.js +1 -14
- package/dist/lib/ensure-api-key.js +1 -11
- package/dist/lib/ensure-fresh-token.js +1 -0
- package/dist/lib/eval-analyzer.js +1 -9
- package/dist/lib/eval-benchmark.js +1 -12
- package/dist/lib/eval-conversation-handler.js +1 -13
- package/dist/lib/eval-executor.js +1 -8
- package/dist/lib/eval-grader.js +1 -9
- package/dist/lib/eval-meta-judge.js +1 -9
- package/dist/lib/eval-trigger-tester.js +1 -11
- package/dist/lib/eval-worktree.js +1 -8
- package/dist/lib/gateway-entry.js +1 -61
- package/dist/lib/gateway-identity.js +1 -16
- package/dist/lib/gateway-lifecycle.js +1 -32
- package/dist/lib/gateway.js +1 -14
- package/dist/lib/handlers/cron-refresh-pricing.js +1 -0
- package/dist/lib/handlers/cron-refresh-skills.js +1 -8
- package/dist/lib/handlers/cron-suggest-instructions.js +1 -16
- package/dist/lib/handlers/process-announcement.js +1 -11
- package/dist/lib/handlers/process-changelog.js +1 -11
- package/dist/lib/handlers/process-conversation.js +1 -14
- package/dist/lib/handlers/process-eval.js +1 -15
- package/dist/lib/handlers/process-insights.js +1 -15
- package/dist/lib/handlers/process-launch.js +1 -16
- package/dist/lib/handlers/process-run-cleanup.js +1 -13
- package/dist/lib/handlers/process-send-message.js +1 -10
- package/dist/lib/handlers/process-session-goal.js +1 -12
- package/dist/lib/hooks-config.js +1 -81
- package/dist/lib/insights-prompts.js +1 -12
- package/dist/lib/instruction-snapshot.js +1 -8
- package/dist/lib/job-helpers.js +0 -1
- package/dist/lib/llm-client.js +1 -20
- package/dist/lib/manual-tasks-meta.js +1 -8
- package/dist/lib/manual-tasks.js +1 -80
- package/dist/lib/output.js +1 -12
- package/dist/lib/permanent-job-error.js +1 -10
- package/dist/lib/pid-identity.js +1 -14
- package/dist/lib/proxy-respawn.js +1 -12
- package/dist/lib/research-client.js +1 -12
- package/dist/lib/setup-steps.js +1 -33
- package/dist/lib/skills-loader.js +1 -8
- package/dist/lib/statusline-shim.js +1 -20
- package/dist/lib/telemetry.js +1 -16
- package/dist/lib/terminal-target-heartbeat.js +1 -15
- package/dist/lib/tmux.js +1 -16
- package/dist/lib/transcript-rate-limit-watcher.js +1 -22
- package/dist/lib/types.js +1 -8
- package/dist/lib/version-check.js +1 -12
- package/dist/lib/which.js +1 -8
- package/dist/lib/worktree.js +1 -17
- package/dist/opencode-QRJ3BH23.js +1 -0
- package/oclif.manifest.json +12 -34
- package/package.json +9 -8
- package/dist/base-command.js.map +0 -7
- package/dist/chunk-2HK7RGZB.js +0 -82
- package/dist/chunk-2HK7RGZB.js.map +0 -7
- package/dist/chunk-2ORJWTNZ.js +0 -307
- package/dist/chunk-2ORJWTNZ.js.map +0 -7
- package/dist/chunk-37LN5O7M.js +0 -59
- package/dist/chunk-37LN5O7M.js.map +0 -7
- package/dist/chunk-3S7223UR.js +0 -81
- package/dist/chunk-3S7223UR.js.map +0 -7
- package/dist/chunk-3TIMQ3O6.js +0 -96
- package/dist/chunk-3TIMQ3O6.js.map +0 -7
- package/dist/chunk-42GFSAJP.js +0 -32
- package/dist/chunk-42GFSAJP.js.map +0 -7
- package/dist/chunk-4BHDHHKL.js +0 -48
- package/dist/chunk-4BHDHHKL.js.map +0 -7
- package/dist/chunk-4D537GXE.js +0 -99
- package/dist/chunk-4D537GXE.js.map +0 -7
- package/dist/chunk-4LYCDS2N.js +0 -139
- package/dist/chunk-4LYCDS2N.js.map +0 -7
- package/dist/chunk-4SCZK7AL.js +0 -129
- package/dist/chunk-4SCZK7AL.js.map +0 -7
- package/dist/chunk-4XAWK6S2.js +0 -161
- package/dist/chunk-4XAWK6S2.js.map +0 -7
- package/dist/chunk-52WIYRZH.js +0 -73
- package/dist/chunk-52WIYRZH.js.map +0 -7
- package/dist/chunk-5BAOGNUH.js +0 -79
- package/dist/chunk-5BAOGNUH.js.map +0 -7
- package/dist/chunk-5EDMGK3W.js +0 -39
- package/dist/chunk-5EDMGK3W.js.map +0 -7
- package/dist/chunk-6NBS5XFS.js +0 -99
- package/dist/chunk-6NBS5XFS.js.map +0 -7
- package/dist/chunk-7LVVKQMZ.js +0 -98
- package/dist/chunk-7LVVKQMZ.js.map +0 -7
- package/dist/chunk-7NNFYWKK.js +0 -243
- package/dist/chunk-7NNFYWKK.js.map +0 -7
- package/dist/chunk-7NYKWN7U.js +0 -12
- package/dist/chunk-7NYKWN7U.js.map +0 -7
- package/dist/chunk-BO76WKJR.js +0 -42
- package/dist/chunk-BO76WKJR.js.map +0 -7
- package/dist/chunk-BRD5RUGM.js +0 -53
- package/dist/chunk-BRD5RUGM.js.map +0 -7
- package/dist/chunk-BT6Z6545.js +0 -43
- package/dist/chunk-BT6Z6545.js.map +0 -7
- package/dist/chunk-BZDKEQKU.js +0 -39
- package/dist/chunk-BZDKEQKU.js.map +0 -7
- package/dist/chunk-DGHWRQXL.js +0 -17
- package/dist/chunk-DGHWRQXL.js.map +0 -7
- package/dist/chunk-DIQUV5FR.js +0 -257
- package/dist/chunk-DIQUV5FR.js.map +0 -7
- package/dist/chunk-DMX5YOTM.js +0 -167
- package/dist/chunk-DMX5YOTM.js.map +0 -7
- package/dist/chunk-DNKSVWMD.js +0 -108
- package/dist/chunk-DNKSVWMD.js.map +0 -7
- package/dist/chunk-DQ3KELXD.js +0 -74
- package/dist/chunk-DQ3KELXD.js.map +0 -7
- package/dist/chunk-DUJSRBLP.js +0 -122
- package/dist/chunk-DUJSRBLP.js.map +0 -7
- package/dist/chunk-E3BIT53W.js +0 -154
- package/dist/chunk-E3BIT53W.js.map +0 -7
- package/dist/chunk-EARWG4EV.js +0 -22
- package/dist/chunk-EARWG4EV.js.map +0 -7
- package/dist/chunk-EI5BHWXA.js +0 -1662
- package/dist/chunk-EI5BHWXA.js.map +0 -7
- package/dist/chunk-EJ3YAFDP.js +0 -37
- package/dist/chunk-EJ3YAFDP.js.map +0 -7
- package/dist/chunk-EKJ2CABV.js +0 -76
- package/dist/chunk-EKJ2CABV.js.map +0 -7
- package/dist/chunk-EKP32DLN.js +0 -16
- package/dist/chunk-EKP32DLN.js.map +0 -7
- package/dist/chunk-EYPAAGN5.js +0 -51
- package/dist/chunk-EYPAAGN5.js.map +0 -7
- package/dist/chunk-F5N6CLJJ.js +0 -1995
- package/dist/chunk-F5N6CLJJ.js.map +0 -7
- package/dist/chunk-GIUBARWS.js +0 -99
- package/dist/chunk-GIUBARWS.js.map +0 -7
- package/dist/chunk-GQNJO2P2.js +0 -102
- package/dist/chunk-GQNJO2P2.js.map +0 -7
- package/dist/chunk-IJGF2ETG.js +0 -68
- package/dist/chunk-IJGF2ETG.js.map +0 -7
- package/dist/chunk-ILYDELUE.js +0 -46
- package/dist/chunk-ILYDELUE.js.map +0 -7
- package/dist/chunk-J6QFW4LD.js +0 -55
- package/dist/chunk-J6QFW4LD.js.map +0 -7
- package/dist/chunk-J7N3DLH6.js +0 -117
- package/dist/chunk-J7N3DLH6.js.map +0 -7
- package/dist/chunk-JFDWKLQC.js +0 -23
- package/dist/chunk-JFDWKLQC.js.map +0 -7
- package/dist/chunk-JULOLTZS.js +0 -61
- package/dist/chunk-JULOLTZS.js.map +0 -7
- package/dist/chunk-KJKBDQ4D.js +0 -220
- package/dist/chunk-KJKBDQ4D.js.map +0 -7
- package/dist/chunk-KRBQLMOP.js +0 -41
- package/dist/chunk-KRBQLMOP.js.map +0 -7
- package/dist/chunk-LXKPNATC.js +0 -624
- package/dist/chunk-LXKPNATC.js.map +0 -7
- package/dist/chunk-NSBPE2FW.js +0 -17
- package/dist/chunk-NSBPE2FW.js.map +0 -7
- package/dist/chunk-OCKHW72U.js +0 -55
- package/dist/chunk-OCKHW72U.js.map +0 -7
- package/dist/chunk-OKWCKCPE.js +0 -414
- package/dist/chunk-OKWCKCPE.js.map +0 -7
- package/dist/chunk-OO7JDFS4.js +0 -157
- package/dist/chunk-OO7JDFS4.js.map +0 -7
- package/dist/chunk-OQBBVTDG.js.map +0 -7
- package/dist/chunk-OQSQC7VB.js +0 -77
- package/dist/chunk-OQSQC7VB.js.map +0 -7
- package/dist/chunk-PED7L5GX.js +0 -92
- package/dist/chunk-PED7L5GX.js.map +0 -7
- package/dist/chunk-QJQS6TUN.js +0 -44
- package/dist/chunk-QJQS6TUN.js.map +0 -7
- package/dist/chunk-QN34TGD3.js +0 -83
- package/dist/chunk-QN34TGD3.js.map +0 -7
- package/dist/chunk-QSN77T7C.js +0 -250
- package/dist/chunk-QSN77T7C.js.map +0 -7
- package/dist/chunk-R56PH7YE.js +0 -78
- package/dist/chunk-R56PH7YE.js.map +0 -7
- package/dist/chunk-RAXRZYOB.js +0 -299
- package/dist/chunk-RAXRZYOB.js.map +0 -7
- package/dist/chunk-RH7NHVSK.js +0 -16
- package/dist/chunk-RH7NHVSK.js.map +0 -7
- package/dist/chunk-RMTT4KDY.js +0 -191
- package/dist/chunk-RMTT4KDY.js.map +0 -7
- package/dist/chunk-RQ2TMLKG.js +0 -142
- package/dist/chunk-RQ2TMLKG.js.map +0 -7
- package/dist/chunk-SO3T35U7.js +0 -80
- package/dist/chunk-SO3T35U7.js.map +0 -7
- package/dist/chunk-UKMLICWS.js +0 -51
- package/dist/chunk-UKMLICWS.js.map +0 -7
- package/dist/chunk-VA5FFOS7.js +0 -243
- package/dist/chunk-VA5FFOS7.js.map +0 -7
- package/dist/chunk-W2YERO7E.js +0 -170
- package/dist/chunk-W2YERO7E.js.map +0 -7
- package/dist/chunk-W53GKIZQ.js +0 -50
- package/dist/chunk-W53GKIZQ.js.map +0 -7
- package/dist/chunk-WA4MWYRW.js +0 -254
- package/dist/chunk-WA4MWYRW.js.map +0 -7
- package/dist/chunk-XC6M4CSW.js +0 -44
- package/dist/chunk-XC6M4CSW.js.map +0 -7
- package/dist/chunk-XK42ZBDE.js +0 -23
- package/dist/chunk-XK42ZBDE.js.map +0 -7
- package/dist/chunk-XUV6DDBF.js +0 -124
- package/dist/chunk-XUV6DDBF.js.map +0 -7
- package/dist/chunk-XZXS2W24.js.map +0 -7
- package/dist/chunk-Y3WD5CSW.js +0 -49
- package/dist/chunk-Y3WD5CSW.js.map +0 -7
- package/dist/chunk-Y4BJXXYV.js +0 -148
- package/dist/chunk-Y4BJXXYV.js.map +0 -7
- package/dist/chunk-YNIH3KMU.js +0 -121
- package/dist/chunk-YNIH3KMU.js.map +0 -7
- package/dist/chunk-ZUJBM6HE.js +0 -125
- package/dist/chunk-ZUJBM6HE.js.map +0 -7
- package/dist/commands/antigravity/backfill.js.map +0 -7
- package/dist/commands/auth/create-key.js.map +0 -7
- package/dist/commands/auth/login.js.map +0 -7
- package/dist/commands/auth/logout.js.map +0 -7
- package/dist/commands/auth/revoke-key.js.map +0 -7
- package/dist/commands/auth/signup.js.map +0 -7
- package/dist/commands/auth/status.js.map +0 -7
- package/dist/commands/catalog/index.js.map +0 -7
- package/dist/commands/catalog/recommend.js.map +0 -7
- package/dist/commands/convert.js.map +0 -7
- package/dist/commands/converters.js.map +0 -7
- package/dist/commands/crons/list.js.map +0 -7
- package/dist/commands/crons/run.js.map +0 -7
- package/dist/commands/dashboard.js.map +0 -7
- package/dist/commands/diagnostics.js.map +0 -7
- package/dist/commands/eval-targets/create.js.map +0 -7
- package/dist/commands/eval-targets/list.js.map +0 -7
- package/dist/commands/evals/agent.js.map +0 -7
- package/dist/commands/evals/benchmark.js.map +0 -7
- package/dist/commands/evals/compare.js.map +0 -7
- package/dist/commands/evals/create.js.map +0 -7
- package/dist/commands/evals/optimize-description.js.map +0 -7
- package/dist/commands/evals/optimize.js.map +0 -7
- package/dist/commands/evals/run.js.map +0 -7
- package/dist/commands/gateway/ensure.js.map +0 -7
- package/dist/commands/hooks/emit-instructions.js.map +0 -7
- package/dist/commands/hooks/install.js.map +0 -7
- package/dist/commands/hooks/run.js.map +0 -7
- package/dist/commands/hooks/uninstall.js.map +0 -7
- package/dist/commands/import.js.map +0 -7
- package/dist/commands/instructions/create.js.map +0 -7
- package/dist/commands/instructions/delete.js.map +0 -7
- package/dist/commands/instructions/fork.js.map +0 -7
- package/dist/commands/instructions/get.js.map +0 -7
- package/dist/commands/instructions/list.js.map +0 -7
- package/dist/commands/instructions/promote.js.map +0 -7
- package/dist/commands/instructions/pull.js.map +0 -7
- package/dist/commands/instructions/upstream.js.map +0 -7
- package/dist/commands/instructions/versions.js.map +0 -7
- package/dist/commands/launcher.js.map +0 -7
- package/dist/commands/org/current.js.map +0 -7
- package/dist/commands/org/list.js.map +0 -7
- package/dist/commands/org/switch.js.map +0 -7
- package/dist/commands/packs/add-instruction.js.map +0 -7
- package/dist/commands/packs/apply.js.map +0 -7
- package/dist/commands/packs/create.js.map +0 -7
- package/dist/commands/packs/fork.js.map +0 -7
- package/dist/commands/packs/get.js.map +0 -7
- package/dist/commands/packs/list.js.map +0 -7
- package/dist/commands/packs/remove-instruction.js.map +0 -7
- package/dist/commands/proxy/env.js.map +0 -7
- package/dist/commands/proxy/logs.js.map +0 -7
- package/dist/commands/proxy/restart.js.map +0 -7
- package/dist/commands/proxy/setup.js.map +0 -7
- package/dist/commands/proxy/start.js.map +0 -7
- package/dist/commands/proxy/status.js.map +0 -7
- package/dist/commands/proxy/stop.js.map +0 -7
- package/dist/commands/research/backfill.js.map +0 -7
- package/dist/commands/research/tail-transcript.js.map +0 -7
- package/dist/commands/service/install.js.map +0 -7
- package/dist/commands/service/status.js.map +0 -7
- package/dist/commands/service/uninstall.js.map +0 -7
- package/dist/commands/sessions/analyze.js.map +0 -7
- package/dist/commands/sessions/end.js.map +0 -7
- package/dist/commands/sessions/import.js.map +0 -7
- package/dist/commands/sessions/list.js.map +0 -7
- package/dist/commands/sessions/start.js.map +0 -7
- package/dist/commands/setup.js.map +0 -7
- package/dist/commands/skills/export-approved.js.map +0 -7
- package/dist/commands/skills/install.js.map +0 -7
- package/dist/commands/skills/list.js.map +0 -7
- package/dist/commands/skills/publish.js.map +0 -7
- package/dist/commands/skills/search.js.map +0 -7
- package/dist/commands/skills/update.js.map +0 -7
- package/dist/commands/suggestions/accept.js.map +0 -7
- package/dist/commands/suggestions/dismiss.js.map +0 -7
- package/dist/commands/suggestions/list.js.map +0 -7
- package/dist/commands/suggestions/refresh.js.map +0 -7
- package/dist/cursor-BGQJ4CWI.js +0 -134
- package/dist/cursor-BGQJ4CWI.js.map +0 -7
- package/dist/dashboard/Dashboard.js.map +0 -7
- package/dist/dashboard/data.js.map +0 -7
- package/dist/dashboard/launcher/ActiveJobsList.js.map +0 -7
- package/dist/dashboard/launcher/LauncherOverlay.js.map +0 -7
- package/dist/dashboard/launcher/NewLaunchForm.js.map +0 -7
- package/dist/dashboard/launcher/api.js.map +0 -7
- package/dist/dashboard/launcher/tool-labels.js.map +0 -7
- package/dist/dashboard/launcher/types.js.map +0 -7
- package/dist/dashboard/launcher/useLaunchJobs.js.map +0 -7
- package/dist/dashboard/panels/friction.js.map +0 -7
- package/dist/dashboard/panels/insights.js.map +0 -7
- package/dist/dashboard/panels/instructions.js.map +0 -7
- package/dist/dashboard/panels/outcomes.js.map +0 -7
- package/dist/dashboard/panels/overview.js.map +0 -7
- package/dist/dashboard/panels/shared.js.map +0 -7
- package/dist/dashboard/types.js.map +0 -7
- package/dist/dist-UNYP5PJR.js +0 -56
- package/dist/dist-UNYP5PJR.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/lib/active-org-refresh.js.map +0 -7
- package/dist/lib/active-org.js.map +0 -7
- package/dist/lib/agent-loop.js.map +0 -7
- package/dist/lib/antigravity-transcript.js.map +0 -7
- package/dist/lib/api-client.js.map +0 -7
- package/dist/lib/auth.js.map +0 -7
- package/dist/lib/capture-hosts.js.map +0 -7
- package/dist/lib/detect-languages.js.map +0 -7
- package/dist/lib/detect-tmux.js.map +0 -7
- package/dist/lib/diagnostics.js.map +0 -7
- package/dist/lib/editor-proxy-pins.js.map +0 -7
- package/dist/lib/ensure-api-key.js.map +0 -7
- package/dist/lib/eval-analyzer.js.map +0 -7
- package/dist/lib/eval-benchmark.js.map +0 -7
- package/dist/lib/eval-conversation-handler.js.map +0 -7
- package/dist/lib/eval-executor.js.map +0 -7
- package/dist/lib/eval-grader.js.map +0 -7
- package/dist/lib/eval-meta-judge.js.map +0 -7
- package/dist/lib/eval-trigger-tester.js.map +0 -7
- package/dist/lib/eval-worktree.js.map +0 -7
- package/dist/lib/gateway-entry.js.map +0 -7
- package/dist/lib/gateway-identity.js.map +0 -7
- package/dist/lib/gateway-lifecycle.js.map +0 -7
- package/dist/lib/gateway.js.map +0 -7
- package/dist/lib/handlers/cron-refresh-skills.js.map +0 -7
- package/dist/lib/handlers/cron-suggest-instructions.js.map +0 -7
- package/dist/lib/handlers/process-announcement.js.map +0 -7
- package/dist/lib/handlers/process-changelog.js.map +0 -7
- package/dist/lib/handlers/process-conversation.js.map +0 -7
- package/dist/lib/handlers/process-eval.js.map +0 -7
- package/dist/lib/handlers/process-insights.js.map +0 -7
- package/dist/lib/handlers/process-launch.js.map +0 -7
- package/dist/lib/handlers/process-run-cleanup.js.map +0 -7
- package/dist/lib/handlers/process-send-message.js.map +0 -7
- package/dist/lib/handlers/process-session-goal.js.map +0 -7
- package/dist/lib/hooks-config.js.map +0 -7
- package/dist/lib/insights-prompts.js.map +0 -7
- package/dist/lib/instruction-snapshot.js.map +0 -7
- package/dist/lib/job-helpers.js.map +0 -7
- package/dist/lib/llm-client.js.map +0 -7
- package/dist/lib/manual-tasks-meta.js.map +0 -7
- package/dist/lib/manual-tasks.js.map +0 -7
- package/dist/lib/output.js.map +0 -7
- package/dist/lib/permanent-job-error.js.map +0 -7
- package/dist/lib/pid-identity.js.map +0 -7
- package/dist/lib/proxy-respawn.js.map +0 -7
- package/dist/lib/research-client.js.map +0 -7
- package/dist/lib/setup-steps.js.map +0 -7
- package/dist/lib/skills-loader.js.map +0 -7
- package/dist/lib/statusline-shim.js.map +0 -7
- package/dist/lib/telemetry.js.map +0 -7
- package/dist/lib/terminal-target-heartbeat.js.map +0 -7
- package/dist/lib/tmux.js.map +0 -7
- package/dist/lib/transcript-rate-limit-watcher.js.map +0 -7
- package/dist/lib/types.js.map +0 -7
- package/dist/lib/version-check.js.map +0 -7
- package/dist/lib/which.js.map +0 -7
- package/dist/lib/worktree.js.map +0 -7
- package/dist/opencode-IQ7X5YMJ.js +0 -190
- package/dist/opencode-IQ7X5YMJ.js.map +0 -7
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ user-management release) organizations.
|
|
|
8
8
|
```bash
|
|
9
9
|
rulemetric auth login # interactive — writes ~/.config/rulemetric/env
|
|
10
10
|
rulemetric auth create-key # generate a long-lived API key
|
|
11
|
-
rulemetric auth
|
|
11
|
+
rulemetric auth status # show the current auth state (email / API key)
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Credentials are read from (first match wins):
|
|
@@ -25,14 +25,14 @@ active org is set will stamp `sessions.org_id` to that org.
|
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
rulemetric org list # list orgs you belong to; star marks the active one
|
|
28
|
-
rulemetric org current # print the active org's slug
|
|
28
|
+
rulemetric org current # print the active org's slug and id
|
|
29
29
|
rulemetric org switch <slug> # set the active org (cached locally)
|
|
30
30
|
rulemetric org switch --clear # clear the active org (back to personal mode)
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
**Active-org resolution order:**
|
|
34
34
|
1. `RULEMETRIC_ORG_ID` environment variable (process-scoped override)
|
|
35
|
-
2. Local cache at `~/.config/rulemetric/active-org
|
|
35
|
+
2. Local cache at `~/.config/rulemetric/active-org` (written by
|
|
36
36
|
`rulemetric org switch`)
|
|
37
37
|
3. None (sessions captured without an org_id)
|
|
38
38
|
|
|
@@ -45,15 +45,17 @@ the active org in the web UI, which the CLI cache picks up).
|
|
|
45
45
|
|
|
46
46
|
## Other top-level commands
|
|
47
47
|
|
|
48
|
-
- `rulemetric instructions ...` — list, get, create,
|
|
48
|
+
- `rulemetric instructions ...` — list, get, create, delete, fork, promote, pull, upstream, versions
|
|
49
49
|
- `rulemetric convert ...` — format conversion (25+ formats)
|
|
50
50
|
- `rulemetric import ...` — bulk import from a project tree
|
|
51
|
-
- `rulemetric sessions ...` — list
|
|
52
|
-
- `rulemetric evals ...` — eval target/case/run/optimize commands
|
|
53
|
-
- `rulemetric insights sync|generate` — push local session-meta + facets up
|
|
51
|
+
- `rulemetric sessions ...` — list, start, end, import, analyze
|
|
52
|
+
- `rulemetric evals ...` — eval target/case/run/optimize commands + `agent` (background worker)
|
|
54
53
|
- `rulemetric hooks install|uninstall|run <name>` — manage tool hook scripts
|
|
55
54
|
- `rulemetric proxy ...` — start/stop the mitmproxy capture layer
|
|
56
|
-
- `rulemetric service install|uninstall` —
|
|
55
|
+
- `rulemetric service install|status|uninstall` — background services (`--worker-only` installs just the worker)
|
|
56
|
+
|
|
57
|
+
Session insights are enriched automatically (hooks + the background worker) —
|
|
58
|
+
there is no manual `insights` command.
|
|
57
59
|
|
|
58
60
|
## Tests
|
|
59
61
|
|
package/dist/base-command.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
BaseCommand
|
|
3
|
-
} from "./chunk-2HK7RGZB.js";
|
|
4
|
-
import "./chunk-R56PH7YE.js";
|
|
5
|
-
import "./chunk-GQNJO2P2.js";
|
|
6
|
-
import "./chunk-37LN5O7M.js";
|
|
7
|
-
import "./chunk-EKJ2CABV.js";
|
|
8
|
-
import "./chunk-ZUJBM6HE.js";
|
|
9
|
-
import "./chunk-W2YERO7E.js";
|
|
10
|
-
import "./chunk-NSBPE2FW.js";
|
|
11
|
-
export {
|
|
12
|
-
BaseCommand
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=base-command.js.map
|
|
1
|
+
import{a}from"./chunk-PPKPCXJD.js";import"./chunk-IZTIYR5Q.js";import"./chunk-V44SRRYR.js";import"./chunk-U6XEU573.js";import"./chunk-VLOX6KOM.js";import"./chunk-3AV3GTMP.js";import"./chunk-H2ORWIEY.js";import"./chunk-O6C2UGBY.js";import"./chunk-ZLLER3HP.js";export{a as BaseCommand};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{f as x}from"./chunk-I2DZGJRR.js";import{a as r}from"./chunk-ZLLER3HP.js";import{execSync as h}from"node:child_process";import{existsSync as c,mkdirSync as y,readFileSync as p,writeFileSync as a,unlinkSync as S,copyFileSync as $}from"node:fs";import{homedir as d}from"node:os";import{join as i,dirname as N}from"node:path";function q(e){let t=["claude_code"];return c(i(e,".cursor"))&&t.push("cursor"),c(i(e,".github"))&&t.push("copilot_agent"),c(i(e,".agents"))&&t.push("antigravity"),t}r(q,"detectInstalledTools");function U(e){let t=e?`PATH="${e}:$PATH" `:"",o=r(n=>({command:`${t}rulemetric hooks run ${n}`}),"cmd");return{version:1,hooks:{sessionStart:[o("session-start")],beforeSubmitPrompt:[o("user-prompt")],afterFileEdit:[o("post-tool-use")],beforeShellExecution:[o("post-tool-use")],afterShellExecution:[o("post-tool-use")],beforeMCPExecution:[o("post-tool-use")],afterMCPExecution:[o("post-tool-use")],afterAgentResponse:[o("assistant-response")],stop:[o("post-tool-use")],sessionEnd:[o("session-end")]}}}r(U,"generateCursorHooksConfig");function L(e){let t=e?`PATH="${e}:$PATH" `:"",o=r(n=>({type:"command",bash:`${t}rulemetric hooks run ${n}`}),"cmd");return{version:1,hooks:{sessionStart:[o("session-start")],userPromptSubmitted:[o("user-prompt")],postToolUse:[o("post-tool-use")],sessionEnd:[o("session-end")]}}}r(L,"generateCopilotHooksConfig");function B(e){let t=e?`PATH="${e}:$PATH" `:"",o=r(n=>({type:"command",command:`${t}rulemetric hooks run ${n}`}),"mk");return{SessionStart:[{hooks:[o("session-start")]}],UserPromptSubmit:[{hooks:[o("user-prompt")]}],PostToolUse:[{matcher:".*",hooks:[o("post-tool-use")]}],SessionEnd:[{hooks:[o("session-end")]}]}}r(B,"generateClaudeCodeHooksConfig");function J(e){if(!c(e))return{settings:{},recoveredBackup:null};let t=p(e,"utf-8");try{return{settings:JSON.parse(t),recoveredBackup:null}}catch{let o=`${e}.corrupt.bak`;return a(o,t),{settings:{},recoveredBackup:o}}}r(J,"readClaudeSettings");function b(e,t){y(N(e),{recursive:!0});let o=null;return c(e)&&(o=`${e}.bak`,$(e,o)),a(e,JSON.stringify(t,null,2)+`
|
|
2
|
+
`),{backupPath:o}}r(b,"writeClaudeSettingsWithBackup");function k(e){if(!c(e))return{};let t=p(e,"utf-8");try{return JSON.parse(t)}catch{try{a(`${e}.corrupt.bak`,t)}catch{}return null}}r(k,"readMergeableJson");function Q(e,t){let o=B(t),n=e.hooks??{};for(let[s,u]of Object.entries(o)){let l=n[s]??[];l.some(m=>m?.hooks?.some(f=>typeof f?.command=="string"&&f.command.includes("rulemetric")))||(n[s]=[...l,...u])}e.hooks=n}r(Q,"mergeClaudeCodeHooks");function Z(e){if(!e.hooks||typeof e.hooks!="object")return!1;let t=e.hooks;return Object.values(t).some(o=>Array.isArray(o)&&o.some(n=>n?.hooks?.some(s=>typeof s?.command=="string"&&s.command.includes("rulemetric"))))}r(Z,"hasRulemetricClaudeHooks");function D(e){if(!e.hooks||typeof e.hooks!="object")return!1;let t=e.hooks,o=0;for(let n of Object.keys(t)){let s=t[n];if(!Array.isArray(s))continue;let u=s.filter(l=>{let g=l?.hooks?.some(m=>typeof m?.command=="string"&&m.command.includes("rulemetric"));return g&&(o+=1),!g});u.length===0?delete t[n]:t[n]=u}return Object.keys(t).length===0&&delete e.hooks,o>0}r(D,"removeClaudeCodeHooks");var X="localhost,127.0.0.1,*.supabase.co,*.supabase.in";function tt(e,t){return i(e,t?"settings.json":"settings.local.json")}r(tt,"claudeSettingsInstallPath");function M(e,t){let o=e.env;if(!o||typeof o!="object")return!1;let n=!1,s=o.HTTPS_PROXY;(s===`http://localhost:${t}`||s===`http://127.0.0.1:${t}`)&&(delete o.HTTPS_PROXY,n=!0),o.NO_PROXY===X&&(delete o.NO_PROXY,n=!0);let u=o.NODE_EXTRA_CA_CERTS;return typeof u=="string"&&u.includes(".mitmproxy")&&u.endsWith("mitmproxy-ca-cert.pem")&&(delete o.NODE_EXTRA_CA_CERTS,n=!0),n&&Object.keys(o).length===0&&delete e.env,n}r(M,"removeRulemetricProxyEnv");function C(e,t){let o=D(e),n=M(e,t),s=x(e);return{removedHooks:o,removedProxyEnv:n,removedStatusline:s,removed:o||n||s}}r(C,"removeRulemetricMachineState");function et(e,t){let o={migrated:!1,backupPath:null,removedHooks:!1,removedProxyEnv:!1,removedStatusline:!1,removed:!1};if(!c(e))return o;let n;try{n=JSON.parse(p(e,"utf-8"))}catch{return o}let s=C(n,t);if(!s.removed)return o;let{backupPath:u}=b(e,n);return{...s,migrated:!0,backupPath:u}}r(et,"migrateSharedClaudeSettings");function ot(e,t){let o=[];for(let n of["settings.json","settings.local.json"]){let s=i(e,n);if(!c(s))continue;let{settings:u,recoveredBackup:l}=J(s),g=C(u,t);g.removed&&b(s,u),o.push({...g,configPath:s,fileName:n,recoveredBackup:l,changed:g.removed})}return o}r(ot,"cleanClaudeSettingsFiles");function R(e,t){if(!c(e))return null;let o=i(e,"hooks.json"),n=U(t),s=k(o);if(s===null)return null;let u=s,l={...u.hooks??{}},g=r(f=>typeof f=="object"&&f!==null&&"command"in f&&typeof f.command=="string"&&f.command.includes("rulemetric"),"isRulemetricHook");for(let[f,w]of Object.entries(n.hooks)){let j=(l[f]??[]).filter(_=>!g(_));l[f]=[...j,...w]}let m={version:u.version??n.version,hooks:l};return a(o,JSON.stringify(m,null,2)+`
|
|
3
|
+
`),o}r(R,"writeCursorHooksToDir");function nt(e,t){return R(i(e,".cursor"),t)}r(nt,"writeCursorHooks");function rt(e,t=d()){let o=i(t,".cursor");return c(o)?R(o,e):null}r(rt,"writeCursorUserHooks");function st(e,t){let o=i(e,".github");if(!c(o))return null;let n=i(o,"hooks");y(n,{recursive:!0});let s=i(n,"rulemetric.json"),u=L(t);return a(s,JSON.stringify(u,null,2)+`
|
|
4
|
+
`),s}r(st,"writeCopilotHooks");function A(e){if(!c(e))return!1;let t;try{t=JSON.parse(p(e,"utf-8"))}catch{return!1}if(!t.hooks)return!1;let o=!1;for(let[n,s]of Object.entries(t.hooks)){let u=s.filter(l=>{if(typeof l!="object"||l===null||!("command"in l))return!0;let g=l.command;return typeof g=="string"&&g.includes("rulemetric")?(o=!0,!1):!0});u.length===0?delete t.hooks[n]:t.hooks[n]=u}return o&&a(e,JSON.stringify(t,null,2)+`
|
|
5
|
+
`),o}r(A,"removeCursorHooksFromFile");function it(e){return A(i(e,".cursor","hooks.json"))}r(it,"removeCursorHooks");function ut(){return A(i(d(),".cursor","hooks.json"))}r(ut,"removeCursorUserHooks");function ct(e,t,o){let n=i(e,".cursor");if(!c(n))return!1;let s=i(n,"settings.json"),u=k(s);return u===null?!1:(u["http.proxy"]=`http://localhost:${t}`,u["http.proxyStrictSSL"]=c(o),a(s,JSON.stringify(u,null,2)+`
|
|
6
|
+
`),!0)}r(ct,"writeCursorProxyConfig");function lt(e,t,o){let n=i(e,".vscode");if(!c(n))return!1;let s=i(n,"settings.json"),u=k(s);if(u===null)return!1;u["http.proxy"]=`http://localhost:${t}`,u["http.proxyStrictSSL"]=c(o);let l=u["github.copilot.advanced"]??{};return l["debug.overrideProxyUrl"]=`http://localhost:${t}`,u["github.copilot.advanced"]=l,a(s,JSON.stringify(u,null,2)+`
|
|
7
|
+
`),!0}r(lt,"writeVSCodeProxyConfig");function at(e){let t=i(e,".vscode","settings.json");if(!c(t))return!1;let o;try{o=JSON.parse(p(t,"utf-8"))}catch{return!1}let n=!1;o["http.proxy"]&&(delete o["http.proxy"],delete o["http.proxyStrictSSL"],n=!0);let s=o["github.copilot.advanced"];return s?.["debug.overrideProxyUrl"]&&(delete s["debug.overrideProxyUrl"],Object.keys(s).length===0&&delete o["github.copilot.advanced"],n=!0),n&&a(t,JSON.stringify(o,null,2)+`
|
|
8
|
+
`),n}r(at,"removeVSCodeProxyConfig");function gt(e){let t=i(e,".github","hooks","rulemetric.json");return c(t)?(S(t),!0):!1}r(gt,"removeCopilotHooks");var H="com.rulemetric.env";function P(){return i(d(),"Library","LaunchAgents",`${H}.plist`)}r(P,"getLaunchAgentPath");function ft(e,t){if(process.platform!=="darwin")return!1;let o=`http://localhost:${e}`;try{h(`launchctl setenv HTTPS_PROXY ${o}`,{stdio:"pipe"}),c(t)&&h(`launchctl setenv NODE_EXTRA_CA_CERTS ${t}`,{stdio:"pipe"})}catch{return!1}let n=P(),s=i(d(),"Library","LaunchAgents");y(s,{recursive:!0});let u=c(t)?`launchctl setenv NODE_EXTRA_CA_CERTS ${t};`:"",l=`if nc -z -w 1 127.0.0.1 ${e} 2>/dev/null; then launchctl setenv HTTPS_PROXY ${o};${u} else launchctl unsetenv HTTPS_PROXY; launchctl unsetenv NODE_EXTRA_CA_CERTS; fi`,g=`<?xml version="1.0" encoding="UTF-8"?>
|
|
9
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
|
10
|
+
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
11
|
+
<plist version="1.0">
|
|
12
|
+
<dict>
|
|
13
|
+
<key>Label</key>
|
|
14
|
+
<string>${H}</string>
|
|
15
|
+
<key>ProgramArguments</key>
|
|
16
|
+
<array>
|
|
17
|
+
<string>/bin/sh</string>
|
|
18
|
+
<string>-c</string>
|
|
19
|
+
<string>${l}</string>
|
|
20
|
+
</array>
|
|
21
|
+
<key>RunAtLoad</key>
|
|
22
|
+
<true/>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
|
25
|
+
`;return a(n,g),!0}r(ft,"installMacOSProxyEnv");function dt(){if(process.platform!=="darwin")return!1;let e=!1;try{h("launchctl unsetenv HTTPS_PROXY",{stdio:"pipe"}),h("launchctl unsetenv NODE_EXTRA_CA_CERTS",{stdio:"pipe"})}catch{}let t=P();return c(t)&&(S(t),e=!0),e}r(dt,"uninstallMacOSProxyEnv");function O(){return process.platform==="darwin"?i(d(),"Library","Application Support","Code","User","settings.json"):process.platform==="win32"?i(process.env.APPDATA??"","Code","User","settings.json"):i(d(),".config","Code","User","settings.json")}r(O,"getVSCodeUserSettingsPath");function pt(e){let t=O();if(!c(i(t,"..")))return!1;let o=k(t);return o===null||o["http.proxy"]&&!o["http.proxy"].includes("localhost")?!1:(o["http.proxy"]=`http://localhost:${e}`,o["http.proxyStrictSSL"]=!1,a(t,JSON.stringify(o,null,2)+`
|
|
26
|
+
`),!0)}r(pt,"writeVSCodeUserProxyConfig");function mt(){let e=O();if(!c(e))return!1;let t;try{t=JSON.parse(p(e,"utf-8"))}catch{return!1}return t["http.proxy"]?.includes("localhost")?(delete t["http.proxy"],delete t["http.proxyStrictSSL"],a(e,JSON.stringify(t,null,2)+`
|
|
27
|
+
`),!0):!1}r(mt,"removeVSCodeUserProxyConfig");function T(){return process.platform==="darwin"?i(d(),"Library","Application Support","Cursor","User","settings.json"):process.platform==="win32"?i(process.env.APPDATA??"","Cursor","User","settings.json"):i(d(),".config","Cursor","User","settings.json")}r(T,"getCursorUserSettingsPath");function kt(e){let t=T();if(!c(i(t,"..")))return!1;let o=k(t);return o===null||o["http.proxy"]&&!o["http.proxy"].includes("localhost")?!1:(o["http.proxy"]=`http://localhost:${e}`,o["http.proxyStrictSSL"]=!1,a(t,JSON.stringify(o,null,2)+`
|
|
28
|
+
`),!0)}r(kt,"writeCursorUserProxyConfig");function ht(){let e=T();if(!c(e))return!1;let t;try{t=JSON.parse(p(e,"utf-8"))}catch{return!1}return t["http.proxy"]?.includes("localhost")?(delete t["http.proxy"],delete t["http.proxyStrictSSL"],a(e,JSON.stringify(t,null,2)+`
|
|
29
|
+
`),!0):!1}r(ht,"removeCursorUserProxyConfig");function F(){let e=process.execPath,t=process.argv[1];return t&&t.endsWith("run.js")?`${e} ${t}`:"rulemetric"}r(F,"getRulemetricCommand");function Y(){let e=F(),t=r(o=>({type:"command",command:`RULEMETRIC_HOOK_TOOL=antigravity ${e} hooks run ${o}`,timeout:30}),"mk");return{rulemetric:{enabled:!0,SessionStart:[{hooks:[t("session-start")]}],PostToolUse:[{matcher:".*",hooks:[t("post-tool-use")]}],SessionEnd:[{hooks:[t("session-end")]}]}}}r(Y,"generateAntigravityHooksConfig");function E(e){let t=i(e,"hooks.json"),o=k(t);if(o===null)return null;let n=Y(),s={...o,rulemetric:n.rulemetric};return y(e,{recursive:!0}),a(t,JSON.stringify(s,null,2)+`
|
|
30
|
+
`),t}r(E,"writeAntigravityHooksToDir");function yt(e){return E(i(e,".agents"))}r(yt,"writeAntigravityHooks");function vt(e=d()){let t=i(e,".gemini");return c(t)?E(i(t,"config")):null}r(vt,"writeAntigravityUserHooks");function v(e){if(!c(e))return!1;let t;try{t=JSON.parse(p(e,"utf-8"))}catch{return!1}if(!("rulemetric"in t))return!1;if(delete t.rulemetric,Object.keys(t).length===0)try{S(e)}catch{}else a(e,JSON.stringify(t,null,2)+`
|
|
31
|
+
`);return!0}r(v,"removeAntigravityHooksFromFile");function St(e){return v(i(e,".agents","hooks.json"))}r(St,"removeAntigravityHooks");function xt(){let e=v(i(d(),".gemini","config","hooks.json")),t=v(i(d(),".gemini","hooks.json"));return e||t}r(xt,"removeAntigravityUserHooks");export{q as a,U as b,L as c,B as d,J as e,b as f,Q as g,Z as h,D as i,X as j,tt as k,M as l,C as m,et as n,ot as o,nt as p,rt as q,st as r,it as s,ut as t,ct as u,lt as v,at as w,gt as x,ft as y,dt as z,O as A,pt as B,mt as C,T as D,kt as E,ht as F,Y as G,yt as H,vt as I,St as J,xt as K};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import{a as u}from"./chunk-MGHFDHHM.js";import{a as o}from"./chunk-ZLLER3HP.js";var l=`You are a meta-judge evaluating the quality of an eval run \u2014 not the code output, but whether the test cases and grading themselves are rigorous and meaningful.
|
|
2
|
+
|
|
3
|
+
You will receive a summary of eval cases, their expectations, and grading results.
|
|
4
|
+
|
|
5
|
+
Analyze for these quality issues:
|
|
6
|
+
|
|
7
|
+
1. **Weak expectations** \u2014 Expectations that are vague ("should follow conventions") or trivially satisfiable. Good expectations are specific and falsifiable.
|
|
8
|
+
|
|
9
|
+
2. **Inconsistent grading** \u2014 Cases where similar expectations get different pass/fail results, or where evidence doesn't match the verdict.
|
|
10
|
+
|
|
11
|
+
3. **Trivial tests** \u2014 Cases where the prompt doesn't actually challenge the rule. E.g., testing "NEVER use mocks" with a prompt that doesn't involve testing at all.
|
|
12
|
+
|
|
13
|
+
4. **Untestable expectations** \u2014 Expectations that can't be verified from the output alone (e.g., "the developer should feel confident").
|
|
14
|
+
|
|
15
|
+
5. **Suspicious 100% pass** \u2014 If every expectation passes, consider whether the tests were actually challenging enough.
|
|
16
|
+
|
|
17
|
+
Respond in JSON:
|
|
18
|
+
{
|
|
19
|
+
"quality_score": <1-5>,
|
|
20
|
+
"issues": [
|
|
21
|
+
{
|
|
22
|
+
"type": "weak_expectation | inconsistent_grading | trivial_test | untestable_expectation | all_pass_suspicious",
|
|
23
|
+
"severity": "low | medium | high",
|
|
24
|
+
"description": "<specific issue>",
|
|
25
|
+
"affected_eval": "<eval name if applicable>"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"recommendations": ["<specific improvement suggestion>", ...],
|
|
29
|
+
"summary": "<1-2 sentence overall assessment>"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Be constructive but honest. A quality_score of 3 means acceptable, 4 means good, 5 means rigorous. Most real-world eval runs score 2-4.`;async function p(t){let i=t.evalResults.map(e=>{let r=e.grading?{pass_rate:e.grading.summary.pass_rate,expectations:e.grading.expectations.map(s=>({text:s.text,passed:s.passed,evidence:s.evidence.slice(0,200)})),feedback:e.grading.eval_feedback?.overall??""}:null;return{eval_name:e.evalName,prompt:e.prompt.slice(0,500),expectations:e.expectations,grading:r,output_preview:e.output?.slice(0,300)??"(not available)"}}),c=`Evaluate the quality of this eval run for target "${t.targetName}":
|
|
33
|
+
|
|
34
|
+
${JSON.stringify(i,null,2)}`,n=await u({prompt:c,systemPrompt:l,timeout:t.timeout??6e4,model:t.model});if(n.error||!n.output)return{quality_score:0,issues:[{type:"inconsistent_grading",severity:"high",description:`Meta-judge failed: ${n.error??"no output"}`}],recommendations:["Meta-judge could not complete \u2014 check model availability"],summary:"Meta-judge execution failed."};try{let e=m(n.output),r=Array.isArray(e.issues)?e.issues:[],s=Array.isArray(e.recommendations)?e.recommendations:[];return{quality_score:Math.max(1,Math.min(5,Number(e.quality_score)||3)),issues:r.map(a=>({type:a.type??"weak_expectation",severity:a.severity??"medium",description:String(a.description??""),affected_eval:a.affected_eval?String(a.affected_eval):void 0})),recommendations:s,summary:String(e.summary??"No summary provided.")}}catch{return{quality_score:3,issues:[],recommendations:[],summary:"Meta-judge returned unparseable output \u2014 defaulting to neutral score."}}}o(p,"judgeEvalQuality");function m(t){try{return JSON.parse(t)}catch{let i=t.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);if(i)return JSON.parse(i[1]);throw new Error("No JSON found in output")}}o(m,"parseJsonFromOutput");export{p as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as B}from"./chunk-N7TGRFVZ.js";import{a as v,e as d,f as n,g as m,h as U}from"./chunk-H4SV7FN4.js";import{a as R}from"./chunk-5RBLIVBF.js";import{a as $}from"./chunk-ZLLER3HP.js";import{and as L,asc as j,eq as l,gt as q,isNotNull as F,sql as O}from"drizzle-orm";var _=100,C=10;async function G(I,s={}){let t=s.db??U(),D=s.sendEmail??B,p=s.log??(o=>process.stderr.write(`[process_announcement] ${o}
|
|
2
|
+
`)),b=s.webBaseUrl??process.env.RULEMETRIC_WEB_URL??process.env.WEB_URL??"https://rulemetric.com",{announcementId:r}=I,[i]=await t.select().from(d).where(l(d.id,r)).limit(1);if(!i)throw new R(`Announcement ${r} not found`);if(i.status!=="queued"&&i.status!=="sending")throw new R(`Announcement ${r} is in status='${i.status}'; expected 'queued' or 'sending'.`);await t.update(d).set({status:"sending",updatedAt:new Date}).where(l(d.id,r)),p(`Sending announcement ${r} (${i.subject??""})`);let w=0,f=0,h=0,y=0,k=null;try{for(;;){let c=await t.select({userId:m.userId,email:v.email,displayName:v.displayName,unsubscribeToken:m.unsubscribeToken}).from(m).innerJoin(v,l(v.id,m.userId)).where(L(l(m.productAnnouncements,!0),F(v.email),k?q(m.userId,k):void 0)).orderBy(j(m.userId)).limit(_);if(c.length===0)break;k=c[c.length-1].userId;for(let A=0;A<c.length;A+=C){let P=c.slice(A,A+C),S=await Promise.allSettled(P.map(g=>W({recipient:g,announcement:i,webBaseUrl:b,sendEmail:D,db:t})));for(let g=0;g<S.length;g++){let u=S[g];if(u.status==="fulfilled")u.value.ok==="sent"?w++:u.value.ok==="skipped"?h++:(f++,u.value.provider==="noop"&&y++,p(` recipient ${P[g].userId}: send failed \u2014 ${u.value.error}`));else{f++;let T=u.reason instanceof Error?u.reason.message:String(u.reason);p(` recipient ${P[g].userId}: send failed \u2014 ${T}`)}}}if(c.length<_)break}y>0&&p(`WARNING: ${y} recipient(s) hit the noop email provider and were recorded as FAILED \u2014 no email provider is configured on this worker (set RESEND_API_KEY in ~/.config/rulemetric/env and reinstall the service)`);let o=await t.select({status:n.status,count:O`count(*)::int`}).from(n).where(l(n.announcementId,r)).groupBy(n.status),e={};for(let c of o)e[c.status]=c.count;let a=e.sent??0,E=e.failed??0,N=a===0&&E>0?"failed":"sent",x=E>0?`${E} of ${a+E} recipient(s) failed; see announcement_deliveries`:null;return await t.update(d).set({status:N,recipientCount:a,...N==="sent"?{sentAt:new Date}:{},error:x,updatedAt:new Date}).where(l(d.id,r)),p(`Done: status=${N} sent=${a} failed=${E} (this attempt: sent=${w} failed=${f} skipped=${h})`),{sent:w,failed:f,skipped:h}}catch(o){let e=o instanceof Error?o.message:String(o);throw await t.update(d).set({status:"failed",error:e.slice(0,1e3),updatedAt:new Date}).where(l(d.id,r)).catch(()=>{}),o}}$(G,"processAnnouncement");function K(I){return I.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}$(K,"escapeHtml");async function W(I){let{recipient:s,announcement:t,webBaseUrl:D,sendEmail:p,db:b}=I;if(!s.email)return{ok:"skipped",reason:"no-email"};let r=await b.insert(n).values({announcementId:t.id,userId:s.userId,email:s.email,status:"pending"}).onConflictDoNothing({target:[n.announcementId,n.userId]}).returning({id:n.id});if(r.length===0)return{ok:"skipped",reason:"already-claimed"};let i=r[0].id,w=D.replace(/\/$/,""),f=encodeURIComponent(s.unsubscribeToken),h=`${w}/unsubscribe/${f}`,y=s.displayName?.trim().split(/\s+/)[0]||"there",k=t.htmlBody.replaceAll("{{unsubscribe_url}}",h).replaceAll("{{recipient_name}}",K(y)),o=t.textBody.replaceAll("{{unsubscribe_url}}",h).replaceAll("{{recipient_name}}",y);try{let e=await p({to:s.email,subject:t.subject,html:k,text:o,fromName:"RuleMetric",idempotencyKey:i,headers:{"List-Unsubscribe":`<${w}/api/unsubscribe/${f}>`,"List-Unsubscribe-Post":"List-Unsubscribe=One-Click"}});if(e.provider==="noop"){let a="no email provider configured (RESEND_API_KEY unset on the worker)";return await b.update(n).set({status:"failed",error:a}).where(l(n.id,i)),{ok:"failed",error:a,provider:e.provider}}return await b.update(n).set({status:"sent",providerId:e.id,sentAt:new Date}).where(l(n.id,i)),{ok:"sent",providerId:e.id,provider:e.provider}}catch(e){let a=e instanceof Error?e.message:String(e);return await b.update(n).set({status:"failed",error:a.slice(0,1e3)}).where(l(n.id,i)).catch(()=>{}),{ok:"failed",error:a}}}$(W,"sendOne");export{G as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as R}from"./chunk-5RBLIVBF.js";import{a as N}from"./chunk-2TC6WCUT.js";import{a as C}from"./chunk-6V4WM73L.js";import{a as I}from"./chunk-CADKBP3D.js";import{a as M}from"./chunk-MGHFDHHM.js";import{e as k,f as y,h as p}from"./chunk-H2ORWIEY.js";import{a as h}from"./chunk-ZLLER3HP.js";async function H(v,m){let{mirrorId:s,evalTargetId:d,config:a}=v,r=h(t=>m.logger.info(t),"log");if(m.job.attempts>1)throw new R(`process_eval is not safe to retry (attempt ${m.job.attempts}). Re-trigger the eval run from the UI.`);let i=await k(`/api/eval-targets/${d}`),$=await k(`/api/eval-targets/${d}/evals`);if($.length===0)throw new R("No evals defined for target");let J=a.runsPerEval??1,E=a.timeout??12e4,T=a.iteration??1,_=[{name:"with_target",content:i.content}];a.skipBaseline||_.push({name:"without_target"});let f=[];for(let t of $)for(let e of _)for(let n=1;n<=J;n++)f.push({eval_:t,configuration:e.name,targetContent:e.content,runNumber:n});let l=f.length,u=0,g=Math.min(a.parallel??1,4);await p(`/api/eval-jobs/${s}/progress`,{status:"running",progress:{total:l,completed:0,current:null,message:`Starting ${l} eval runs (concurrency: ${g})...`}});let w=[];async function j(t){let e=`${t.configuration} \xB7 ${t.eval_.name} \xB7 run#${t.runNumber}`;r(`[${u+1}/${l}] ${e}`);let n=g>1?C():null;try{let o=await M({prompt:t.eval_.prompt,targetContent:t.targetContent,workDir:n?.workDir,timeout:E,model:a.model}),c={};return!a.skipGrading&&t.eval_.expectations.length>0&&!o.error&&(c=await I({prompt:t.eval_.prompt,output:o.output,expectations:t.eval_.expectations,model:a.graderModel??a.model,timeout:E})),{evalId:t.eval_.id,evalTargetId:i.id,evalTargetVersion:i.version,configuration:t.configuration,runNumber:t.runNumber,iteration:T,status:o.error?"failed":"completed",outputs:o.error?{error:o.error}:{transcript:o.output},timing:{duration_ms:o.durationMs,total_tokens:o.totalTokens},grading:c,worktree:n?.isWorktree?!0:void 0}}finally{n?.cleanup()}}if(h(j,"processItem"),g<=1)for(let t of f){let e=`${t.configuration} \xB7 ${t.eval_.name} \xB7 run#${t.runNumber}`;await p(`/api/eval-jobs/${s}/progress`,{status:"running",progress:{total:l,completed:u,current:e,message:`Executing ${e}...`}});let n=await j(t);await y("/api/eval-runs",n),w.push(n),u++,await p(`/api/eval-jobs/${s}/progress`,{status:"running",progress:{total:l,completed:u,current:e,message:`Completed ${e}`}})}else{r(`Running ${l} evals with concurrency=${g} (worktree isolation)`);for(let t=0;t<f.length;t+=g){let e=f.slice(t,t+g),n=`batch ${Math.floor(t/g)+1}/${Math.ceil(f.length/g)}`;await p(`/api/eval-jobs/${s}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Executing ${n} (${e.length} parallel)...`}});let o=await Promise.all(e.map(j));for(let c of o)await y("/api/eval-runs",c),w.push(c),u++;await p(`/api/eval-jobs/${s}/progress`,{status:"running",progress:{total:l,completed:u,current:n,message:`Completed ${n}`}})}}let x=G(w),b;if(!a.skipGrading&&w.some(t=>t.grading&&Object.keys(t.grading).length>0))try{r(`Running meta-judge for job ${s}...`);let t=$.map(e=>{let o=w.filter(c=>c.evalId===e.id&&c.configuration==="with_target")[0];return{evalName:e.name,prompt:e.prompt,expectations:e.expectations,grading:o?.grading?o.grading:null,output:o?.outputs?.transcript?.slice(0,500)}});b=await N({targetName:i.name,evalResults:t,model:a.graderModel??a.model,timeout:6e4}),r(`Meta-judge: quality=${b.quality_score}/5, issues=${b.issues.length}`)}catch(t){r(`Meta-judge failed (non-fatal): ${t instanceof Error?t.message:String(t)}`)}let P=b?{...x,meta_judgement:b}:x;return r(`Job ${s} completed: ${u}/${l} runs`),await p(`/api/eval-jobs/${s}/state`,{result:P}).catch(t=>{r(`result persist failed: ${t instanceof Error?t.message:String(t)}`)}),P}h(H,"processEval");function G(v){let m=v.filter(r=>r.status==="completed"),s=v.filter(r=>r.status==="failed"),d=m.filter(r=>{let i=r.grading;return i&&Object.keys(i).length>0}),a=d.length>0?d.reduce((r,i)=>r+(i.grading?.summary?.pass_rate??0),0)/d.length:null;return{total:v.length,completed:m.length,failed:s.length,avgPassRate:a}}h(G,"buildSummary");export{H as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-ZLLER3HP.js";import*as r from"node:fs";import*as l from"node:os";import*as u from"node:path";var d=300*1e3;function f(){return process.env.RULEMETRIC_CONFIG_DIR||u.join(l.homedir(),".config","rulemetric")}e(f,"getConfigDir");function s(){return u.join(f(),"active-org")}e(s,"getActiveOrgFile");function a(){let n=process.env.RULEMETRIC_ORG_ID;if(n&&n.trim())return{orgId:n.trim()};let o=s(),i;try{i=r.readFileSync(o,"utf-8")}catch{return null}let t;try{t=JSON.parse(i)}catch{return null}if(!t||typeof t!="object"||!("orgId"in t)||typeof t.orgId!="string")return null;let c=t,g={orgId:c.orgId};return typeof c.orgSlug=="string"&&(g.orgSlug=c.orgSlug),typeof c.syncedAt=="number"&&(g.syncedAt=c.syncedAt),g}e(a,"readActiveOrg");function p(n){let o=f();r.mkdirSync(o,{recursive:!0,mode:448});let i=s(),t=`${i}.tmp`;r.writeFileSync(t,JSON.stringify(n,null,2),{encoding:"utf-8",mode:384}),r.renameSync(t,i)}e(p,"writeActiveOrg");function y(){try{r.unlinkSync(s())}catch{}}e(y,"clearActiveOrg");function m(n,o=d){return typeof n.syncedAt!="number"?!1:Date.now()-n.syncedAt>o}e(m,"isStale");var v={getActiveOrgFile:s,getConfigDir:f};export{a,p as b,y as c,m as d,v as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as H}from"./chunk-TIOKY2IA.js";import{a as b}from"./chunk-TQMG647B.js";import{b as I}from"./chunk-W2MOTOQE.js";import{a as T}from"./chunk-VAXRCSSH.js";import{a as S}from"./chunk-RSKQRVPJ.js";import{a as A}from"./chunk-AYUJY37O.js";import{a as y}from"./chunk-KAF3CYRW.js";import{a as k}from"./chunk-UF6US7VU.js";import{a as _}from"./chunk-DPFNJZUO.js";import{a as R}from"./chunk-2WLVDSAP.js";import{a as E}from"./chunk-NEACEHQD.js";import{a as h}from"./chunk-32EEBARV.js";import{b as w}from"./chunk-5RBLIVBF.js";import{b as f,e as v,f as p}from"./chunk-H2ORWIEY.js";import{a as s}from"./chunk-ZLLER3HP.js";var D={process_eval:h,process_insights:b,process_launch:I,process_send_message:S,process_conversation:E,process_session_goal:A,process_announcement:R,process_run_cleanup:T,cron_suggest_instructions:_,cron_refresh_skills:k,cron_refresh_pricing:y},M=Object.keys(D),V=new Set(["process_session_goal","process_announcement","process_run_cleanup"]);function x(e=process.env){return e.DATABASE_URL?M:M.filter(n=>!V.has(n))}s(x,"availableCapabilities");var O=3e4,W=3e4,$=3e4,L=250,N=5e3,B=`thin-agent-${process.pid}`,g=null;function F(e,n,r,l){let a=s(t=>{p("/api/workers/heartbeat",{workerType:"cli-worker",clientName:B,clientVersion:l,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:t,metadata:{capabilities:e,mode:"thin-agent"}}).then(c=>{let u=c?.advisory;u&&u.message!==g?(g=u.message,o(r,{event:"worker_advisory",code:u.code,message:u.message})):u||(g=null)}).catch(c=>{o(r,{event:"presence_heartbeat_error",error:c instanceof Error?c.message:String(c)})})},"send");a("alive");let d=setInterval(()=>a("alive"),$);n.addEventListener("abort",()=>{clearInterval(d),a("shutting_down")},{once:!0})}s(F,"startPresenceHeartbeat");function o(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}s(o,"structuredLog");function P(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let l=setTimeout(()=>{n.removeEventListener("abort",a),r(!0)},e),a=s(()=>{clearTimeout(l),n.removeEventListener("abort",a),r(!1)},"onAbort");n.addEventListener("abort",a,{once:!0})})}s(P,"abortableSleep");async function J(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,l=await v(`/api/work/next?${r}`);return l==null||typeof l=="string"?null:l}s(J,"pollForWork");function U(e,n){return{logger:{info:s(r=>n(r),"info"),warn:s(r=>n(r),"warn"),error:s(r=>n(r),"error")},job:{attempts:e}}}s(U,"makeHelpers");async function K(e,n,r){let l=D[e.kind],a=Date.now();if(o(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!l){let t=`unknown kind: ${e.kind}`;o(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:t}),await p(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:t,terminal:!0}).catch(()=>{});return}let d=setInterval(()=>{o(r,{event:"heartbeat",jobId:e.id}),p(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(t=>{o(r,{event:"heartbeat_error",jobId:e.id,error:t instanceof Error?t.message:String(t)})})},n);try{let t=U(e.attempts,r),c=await l(e.payload,t)??{};clearInterval(d),o(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-a}),await p(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:c})}catch(t){clearInterval(d);let c=w(t),u=t instanceof Error?t.message:String(t);o(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-a,terminal:c,error:u}),await p(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:u,terminal:c}).catch(i=>{o(r,{event:"fail_post_error",jobId:e.id,error:i instanceof Error?i.message:String(i)})})}}s(K,"runOne");async function ie(e){let n=e.log??(()=>{}),r=e.pollWaitMs??O,l=e.heartbeatIntervalMs??W,a=e.capabilities??x(),d=L;o(n,{event:"agent_start",capabilities:a,pollWaitMs:r,heartbeatIntervalMs:l}),F(a,e.signal,n,e.version),H({signal:e.signal,log:n}).catch(i=>{o(n,{event:"tt_heartbeat_fatal",error:i instanceof Error?i.message:String(i)})});let t=5*6e4,c=0,u=s(()=>{if(!e.readInstalledVersion||!e.version)return!1;let i=Date.now();if(i-c<t)return!1;c=i;let m=e.readInstalledVersion();return!!(m&&m!==e.version)},"versionDrifted");for(;!e.signal.aborted;){if(u()){o(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),e.onVersionDrift?.();break}let i=null;try{i=await J(a,r)}catch(m){let C=m instanceof f?m.statusCode:void 0;if(o(n,{event:"poll_error",status:C,error:m instanceof Error?m.message:String(m)}),!await P(d,e.signal))break;d=Math.min(d*2,N);continue}if(!i){if(o(n,{event:"poll_204"}),!await P(d,e.signal))break;d=Math.min(d*2,N);continue}d=L,await K(i,l,n)}o(n,{event:"agent_stop"})}s(ie,"runAgentLoop");export{D as a,M as b,x as c,J as d,ie as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as c,e as h}from"./chunk-ARNZQBMX.js";import{d as i,f as _}from"./chunk-NJ5UED3H.js";import{a as x}from"./chunk-ZLLER3HP.js";import{Box as w,Text as t}from"ink";import{Fragment as S,jsx as e,jsxs as s}from"react/jsx-runtime";function v({local:n,api:o,label:p,width:C}){let f=o?.total_sessions??n.totalSessions,a=o?.total_messages??0,l=o?.total_input_tokens??n.totalInputTokens,k=o?.total_output_tokens??n.totalOutputTokens,r=o?.total_cache_read_tokens??n.totalCacheReadTokens,d=o?.total_cache_write_tokens??n.totalCacheWriteTokens,g=o?.estimated_cost_usd??n.totalCostUSD,m=o?.days_active??0,T=o?.git_commits??0,u=l+r+d,b=u>0?r/u*100:0;return s(w,{flexDirection:"column",borderStyle:"round",borderColor:i,paddingX:1,width:C,children:[s(t,{wrap:"truncate-end",children:[e(t,{bold:!0,color:i,children:"RuleMetric"}),s(t,{dimColor:!0,children:[" ",p]}),o&&e(t,{color:"#5BF58C",children:" \u25CF API connected"}),!o&&e(t,{color:"#F55B5B",children:" \u25CB API offline"})]}),s(t,{wrap:"truncate-end",children:[e(t,{bold:!0,color:_,children:h(g)}),e(t,{dimColor:!0,children:" cost "}),e(t,{bold:!0,children:String(f)}),e(t,{dimColor:!0,children:" sessions "}),a>0&&s(S,{children:[e(t,{bold:!0,children:a.toLocaleString()}),e(t,{dimColor:!0,children:" messages "})]}),s(t,{bold:!0,children:[b.toFixed(1),"%"]}),e(t,{dimColor:!0,children:" cache hit"})]}),s(t,{dimColor:!0,wrap:"truncate-end",children:[c(l)," in ",c(k)," out ",c(r)," cached ",c(d)," written",m>0?` ${m} days active`:"",T>0?` ${T} commits`:""]})]})}x(v,"Overview");export{v as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-ZLLER3HP.js";var e=class extends Error{static{n(this,"PermanentJobError")}__isPermanentJobError=!0;constructor(o){super(o),this.name="PermanentJobError"}};function t(r){return r instanceof Error&&r.__isPermanentJobError===!0}n(t,"isPermanentJobError");export{e as a,t as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-ZLLER3HP.js";import{existsSync as p}from"node:fs";import{homedir as u}from"node:os";import{join as o,delimiter as d}from"node:path";function b(r,n){return r==="darwin"?["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin",o(n,".local/bin")]:r==="linux"?["/usr/local/bin","/usr/bin",o(n,".local/bin")]:[]}i(b,"wellKnownBinDirs");function g(r,n={}){let t=n.platform??process.platform,s=n.home??u(),l=(n.pathEnv??process.env.PATH??"").split(d).filter(Boolean),a=[...new Set([...l,...b(t,s)])],f=t==="win32"?["",...(process.env.PATHEXT||".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean)]:[""];for(let c of a)for(let m of f){let e=o(c,r+m);if(p(e))return e}return null}i(g,"findBinary");export{g as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{y as w}from"./chunk-7DFNBRLY.js";import{a as m}from"./chunk-N7ODX6PO.js";import{a as s}from"./chunk-ZLLER3HP.js";import{spawn as g}from"node:child_process";import d from"node:fs";import b from"node:path";function c(e,t){return new Promise((r,n)=>{let o=g("git",e,{cwd:t,stdio:["ignore","pipe","pipe"],env:m()}),i="",f="";o.stdout.on("data",a=>{i+=a.toString()}),o.stderr.on("data",a=>{f+=a.toString()}),o.on("error",a=>n(new Error(`git ${e.join(" ")} failed to spawn: ${a.message}`))),o.on("close",a=>{a===0?r({code:a,stdout:i,stderr:f}):n(new Error(`git ${e.join(" ")} exited ${a}: ${f.trim()||i.trim()}`))})})}s(c,"runGit");async function k(e,t){if(!t||!t.trim())throw new Error('invalid branch name "": branch must be a non-empty git refname');if(t.startsWith("-"))throw new Error(`invalid branch name "${t}": must not start with "-" (git would parse it as an option)`);if(/\s/.test(t))throw new Error(`invalid branch name "${t}": must not contain whitespace`);try{await c(["check-ref-format","--branch",t],e)}catch{throw new Error(`invalid branch name "${t}": not a valid git refname`)}}s(k,"assertValidBranch");function h(e){let t=b.resolve(e);try{return d.realpathSync(t)}catch{return t}}s(h,"canonical");function y(e){let t=[],r=null;for(let n of e.split(`
|
|
2
|
+
`))n.startsWith("worktree ")?(r&&t.push(r),r={path:n.slice(9).trim()}):n.startsWith("branch ")&&r&&(r.branch=n.slice(7).trim().replace(/^refs\/heads\//,""));return r&&t.push(r),t}s(y,"parseWorktreeList");async function v(e,t){try{return await c(["show-ref","--verify","--quiet",`refs/heads/${t}`],e),!0}catch{return!1}}s(v,"branchExists");async function B(e){let{repoRoot:t,branch:r,baseRef:n,allowExistingBranch:o=!1}=e;await k(t,r);let i=w({repoRoot:t,branch:r,basePath:e.basePath}),f=await c(["worktree","list","--porcelain"],t),a=y(f.stdout),p=a.find(u=>u.branch===r);if(p)return{path:h(p.path),branch:r,created:!1};let l=a.find(u=>h(u.path)===i);if(l)return{path:h(l.path),branch:l.branch??r,created:!1};if(await v(t,r)){if(!o)throw new Error(`branch "${r}" already exists with no worktree; refusing to clobber (pass allowExistingBranch:true to attach a worktree onto it)`);return await c(["worktree","add",i,r],t),{path:h(i),branch:r,created:!0}}return await c(["worktree","add",i,"-b",r,n],t),{path:h(i),branch:r,created:!0}}s(B,"ensureWorktree");async function S(e){let{repoRoot:t,worktreePath:r}=e;if(!d.existsSync(r))return{removed:!1,reason:"absent"};let n=!1;try{n=(await c(["status","--porcelain"],r)).stdout.trim().length>0}catch{n=!1}if(n)return{removed:!1,reason:"dirty"};try{return await c(["worktree","remove",r],t),{removed:!0}}catch(o){let i=o instanceof Error?o.message:String(o);if(/not a working tree|No such file or directory|not a valid path|is not a working tree/i.test(i))return{removed:!1,reason:"absent"};throw o}}s(S,"removeWorktree");export{c as a,B as b,S as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-ZLLER3HP.js";import{execSync as o}from"node:child_process";import{mkdtempSync as n,rmSync as m,existsSync as u}from"node:fs";import{join as k}from"node:path";import{tmpdir as f}from"node:os";function y(c){let t=c??process.cwd(),s=k(f(),"rulemetric-eval-");try{o("git rev-parse --git-dir",{cwd:t,stdio:"pipe"})}catch{let r=n(s);return{workDir:r,cleanup:e(()=>p(r),"cleanup"),isWorktree:!1}}let a;try{a=o("git rev-parse HEAD",{cwd:t,stdio:"pipe"}).toString().trim()}catch{let r=n(s);return{workDir:r,cleanup:e(()=>p(r),"cleanup"),isWorktree:!1}}let i=n(s);m(i,{recursive:!0});try{o(`git worktree add --detach "${i}" ${a}`,{cwd:t,stdio:"pipe"})}catch{let r=n(s);return{workDir:r,cleanup:e(()=>p(r),"cleanup"),isWorktree:!1}}return{workDir:i,cleanup:e(()=>{try{o(`git worktree remove --force "${i}"`,{cwd:t,stdio:"pipe"})}catch{p(i);try{o("git worktree prune",{cwd:t,stdio:"pipe"})}catch{}}},"cleanup"),isWorktree:!0}}e(y,"createEvalWorktree");function p(c){try{u(c)&&m(c,{recursive:!0,force:!0})}catch{}}e(p,"safeRm");export{y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-N7ODX6PO.js";import{a as i}from"./chunk-ZLLER3HP.js";import{spawn as u}from"node:child_process";function s(){return new Promise(e=>{let t;try{t=u("tmux",["-V"],{stdio:["ignore","pipe","pipe"],env:o()})}catch{e({available:!1});return}let n="";t.stdout?.on("data",a=>{n+=a.toString()}),t.stderr?.on("data",()=>{}),t.on("error",()=>{e({available:!1})}),t.on("close",a=>{if(a!==0){e({available:!1});return}let r=n.trim().match(/^tmux\s+(\S+)/);e({available:!0,version:r?r[1]:void 0})})})}i(s,"detectTmux");export{s as a};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{a as i,b as Ce}from"./chunk-ZLLER3HP.js";var Rt=["claude_code","cursor","vscode_copilot","copilot_agent","rulemetric_mcp","codex","pi","opencode","antigravity"],Mt=["user_message","assistant_message","tool_call","tool_result","thinking","error"];var O=class{static{i(this,"ClaudeCodeAdapter")}tool="claude_code";parse(e){let t=e.split(`
|
|
2
|
+
`).filter(c=>c.trim()),s=[];for(let c of t)try{s.push(JSON.parse(c))}catch{}let o=s.filter(c=>c.type==="user"||c.type==="assistant"),r=null,l=null,p={},a=s.find(c=>c.type==="user");a&&(r=a.cwd??null,l=a.gitBranch??null,a.version&&(p.claudeCodeVersion=a.version),a.sessionId&&(p.sessionId=a.sessionId));let u=s.find(c=>c.type==="assistant");u?.message?.model&&(p.model=u.message.model);let m=[],f=0;for(let c of o){let g=c.timestamp??new Date().toISOString();if(c.type==="user"){let _=c.message?.content;if(typeof _=="string")m.push({sequence:f++,eventType:"user_message",content:_,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:g,metadata:{}});else if(Array.isArray(_))for(let h of _)h.type==="tool_result"&&m.push({sequence:f++,eventType:"tool_result",content:typeof h.content=="string"?h.content:JSON.stringify(h.content),toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:g,metadata:{toolUseId:h.tool_use_id}})}else if(c.type==="assistant"){let _=Array.isArray(c.message?.content)?c.message.content:[],h=c.message?.usage,x=h?{input:h.input_tokens??0,output:h.output_tokens??0,cacheRead:h.cache_read_input_tokens??0,cacheWrite:h.cache_creation_input_tokens??0}:null,S={};c.message?.model&&(S.model=c.message.model),c.message?.stop_reason&&(S.stopReason=c.message.stop_reason),c.requestId&&(S.requestId=c.requestId),h?.service_tier&&(S.serviceTier=h.service_tier),h?.speed&&(S.speed=h.speed),h?.cache_creation&&(S.cacheCreationDetail=h.cache_creation),h?.server_tool_use&&(S.serverToolUse=h.server_tool_use);for(let w of _)w.type==="text"?m.push({sequence:f++,eventType:"assistant_message",content:w.text??"",toolName:null,toolInput:null,toolOutput:null,tokenUsage:x,timestamp:g,metadata:S}):w.type==="thinking"?m.push({sequence:f++,eventType:"thinking",content:w.thinking??"",toolName:null,toolInput:null,toolOutput:null,tokenUsage:x,timestamp:g,metadata:S}):w.type==="tool_use"&&m.push({sequence:f++,eventType:"tool_call",content:null,toolName:w.name??"unknown",toolInput:w.input??null,toolOutput:null,tokenUsage:x,timestamp:g,metadata:{...S,toolUseId:w.id}})}}let d=m.map(c=>c.timestamp).sort(),y=new Date().toISOString();return{tool:"claude_code",projectPath:r,gitBranch:l,startedAt:d[0]??y,endedAt:d[d.length-1]??null,events:m,metadata:p}}};var N=class{static{i(this,"CursorAdapter")}tool="cursor";parse(e){let t=Ce("better-sqlite3"),s=new t(e,{readonly:!0});try{let o=s.prepare("SELECT value FROM ItemTable WHERE key = 'composer.composerData'").get();return o?this.parseComposerJson(o.value):this.emptySession()}finally{s.close()}}parseComposerJson(e){let t;try{t=JSON.parse(e)}catch{return this.emptySession()}let s=Object.values(t.allComposers??{});if(s.length===0)return this.emptySession();let o=s.sort((u,m)=>{let f=u.createdAt?new Date(u.createdAt).getTime():0;return(m.createdAt?new Date(m.createdAt).getTime():0)-f})[0],r=o.conversation??[],l=[];for(let u=0;u<r.length;u++){let m=r[u],f=m.createdAt??new Date().toISOString();l.push({sequence:u,eventType:m.type===1?"user_message":"assistant_message",content:m.text,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:f,metadata:{}})}let p=l.map(u=>u.timestamp).sort(),a=new Date().toISOString();return{tool:"cursor",projectPath:null,gitBranch:null,startedAt:p[0]??a,endedAt:p[p.length-1]??null,events:l,metadata:{composerId:o.composerId}}}emptySession(){return{tool:"cursor",projectPath:null,gitBranch:null,startedAt:new Date().toISOString(),endedAt:null,events:[],metadata:{}}}};var P=class{static{i(this,"VSCodeCopilotAdapter")}tool="vscode_copilot";parse(e){let t;try{t=JSON.parse(e)}catch{return this.emptySession()}let s=t.requests??[],o=[],r=0;for(let a of s){let u=a.timestamp?new Date(a.timestamp).toISOString():new Date().toISOString();if(o.push({sequence:r++,eventType:"user_message",content:a.message,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:u,metadata:{}}),a.response){let m=a.response.timestamp?new Date(a.response.timestamp).toISOString():u;o.push({sequence:r++,eventType:"assistant_message",content:a.response.message,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:m,metadata:{}})}}let l=o.map(a=>a.timestamp).sort(),p=new Date().toISOString();return{tool:"vscode_copilot",projectPath:null,gitBranch:null,startedAt:l[0]??p,endedAt:l[l.length-1]??null,events:o,metadata:{...t.requesterUsername&&{username:t.requesterUsername},...t.customTitle&&{title:t.customTitle}}}}emptySession(){return{tool:"vscode_copilot",projectPath:null,gitBranch:null,startedAt:new Date().toISOString(),endedAt:null,events:[],metadata:{}}}};var b=class{static{i(this,"CopilotAgentAdapter")}tool="copilot_agent";parse(e){let t;try{t=JSON.parse(e)}catch{return this.emptySession()}let s=t.requests??[],o=[],r=0;for(let a of s){let u=a.timestamp?new Date(a.timestamp).toISOString():new Date().toISOString();if(o.push({sequence:r++,eventType:"user_message",content:a.message,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:u,metadata:{}}),a.toolCalls)for(let m of a.toolCalls){let f=m.timestamp?new Date(m.timestamp).toISOString():u;o.push({sequence:r++,eventType:"tool_call",content:null,toolName:m.name??"unknown",toolInput:m.input??null,toolOutput:m.output??null,tokenUsage:null,timestamp:f,metadata:{}})}if(a.response){let m=a.response.timestamp?new Date(a.response.timestamp).toISOString():u;o.push({sequence:r++,eventType:"assistant_message",content:a.response.message,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:m,metadata:{}})}}let l=o.map(a=>a.timestamp).sort(),p=new Date().toISOString();return{tool:"copilot_agent",projectPath:null,gitBranch:null,startedAt:l[0]??p,endedAt:l[l.length-1]??null,events:o,metadata:{...t.requesterUsername&&{username:t.requesterUsername},...t.customTitle&&{title:t.customTitle},...t.agentMode!=null&&{agentMode:t.agentMode}}}}emptySession(){return{tool:"copilot_agent",projectPath:null,gitBranch:null,startedAt:new Date().toISOString(),endedAt:null,events:[],metadata:{}}}};var D=class{static{i(this,"RuleMetricMcpAdapter")}tool="rulemetric_mcp";parse(e){let t;try{t=JSON.parse(e)}catch{return this.emptySession()}let o=(t.events??[]).map((l,p)=>({sequence:l.sequence??p,eventType:this.normalizeEventType(l.eventType),content:l.content??null,toolName:l.toolName??null,toolInput:l.toolInput??null,toolOutput:l.toolOutput??null,tokenUsage:l.tokenUsage??null,timestamp:l.timestamp??new Date().toISOString(),metadata:l.metadata??{}})),r=new Date().toISOString();return{tool:"rulemetric_mcp",projectPath:t.projectPath??null,gitBranch:t.gitBranch??null,startedAt:t.startedAt??o[0]?.timestamp??r,endedAt:t.endedAt??o[o.length-1]?.timestamp??null,events:o,metadata:t.metadata??{}}}normalizeEventType(e){return e&&["user_message","assistant_message","tool_call","tool_result","thinking","error"].includes(e)?e:"assistant_message"}emptySession(){return{tool:"rulemetric_mcp",projectPath:null,gitBranch:null,startedAt:new Date().toISOString(),endedAt:null,events:[],metadata:{}}}};function $e(n){try{return JSON.parse(n)}catch{return n}}i($e,"safeJsonParse");function X(n,e){return Array.isArray(n)?n.filter(t=>t.type&&e.includes(t.type)).map(t=>t.text??"").filter(Boolean).join(`
|
|
3
|
+
|
|
4
|
+
`):""}i(X,"textFromBlocks");function je(n){if(!n)return null;let e=n.cached_input_tokens??0,t=Math.max(0,(n.input_tokens??0)-e),s=(n.output_tokens??0)+(n.reasoning_output_tokens??0);return t===0&&s===0&&e===0?null:{input:t,output:s,cacheRead:e,cacheWrite:0}}i(je,"tokenUsageFromCodex");function Ue(n){if(!n)return new Date().toISOString();let e=new Date(n);return Number.isFinite(e.getTime())?e.toISOString():new Date().toISOString()}i(Ue,"normalizeTimestamp");function Z(){return{sequence:0,model:null,prevCumulativeTotal:0,callNames:{}}}i(Z,"freshCodexState");var C=class{static{i(this,"CodexAdapter")}tool="codex";parse(e){let t=Z(),{events:s,projectPath:o,gitBranch:r,metadata:l}=this.parseLines(e,t),p=s.map(u=>u.timestamp).sort(),a=new Date().toISOString();return{tool:"codex",projectPath:o,gitBranch:r,startedAt:p[0]??a,endedAt:p[p.length-1]??null,events:s,metadata:l}}parseAppend(e,t){let s={...t,callNames:{...t.callNames}},{events:o}=this.parseLines(e,s);return{events:o,state:s}}parseLines(e,t){let s=e.split(`
|
|
5
|
+
`).filter(m=>m.trim()),o=[],r={},l=t.callNames,p=null,a=null,u=null;for(let m of s){let f;try{f=JSON.parse(m)}catch{continue}let d=f.payload;if(!d)continue;let y=Ue(f.timestamp);if(f.type==="session_meta"){u=d.session_id??d.id??u,p=d.cwd??p,d.git_branch&&(a=d.git_branch),d.model&&(t.model=d.model),r.sessionId=u,r.codexSessionId=u,r.originator=d.originator,r.source=d.source,r.modelProvider=d.model_provider,r.codexCliVersion=d.cli_version;continue}if(f.type==="turn_context"){p=d.cwd??p,d.model&&(t.model=d.model,r.model=d.model);continue}if(f.type==="response_item"&&d.type==="message"){if(d.role==="user"){let c=X(d.content,["input_text"]);if(!c)continue;o.push({sequence:t.sequence++,eventType:"user_message",content:c,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,timestamp:y,metadata:{}})}else if(d.role==="assistant"){let c=X(d.content,["output_text"]);if(!c)continue;o.push({sequence:t.sequence++,eventType:"assistant_message",content:c,toolName:null,toolInput:null,toolOutput:null,tokenUsage:null,model:t.model,timestamp:y,metadata:t.model?{model:t.model}:{}})}continue}if(f.type==="response_item"&&d.type==="function_call"){let c=d.name??"unknown";d.call_id&&(l[d.call_id]=c);let g=typeof d.arguments=="string"?$e(d.arguments):{};o.push({sequence:t.sequence++,eventType:"tool_call",content:null,toolName:c,toolInput:g&&typeof g=="object"&&!Array.isArray(g)?g:{arguments:g},toolOutput:null,tokenUsage:null,model:t.model,timestamp:y,metadata:{callId:d.call_id}});continue}if(f.type==="response_item"&&d.type==="function_call_output"){let c=d.call_id?l[d.call_id]??null:null;o.push({sequence:t.sequence++,eventType:"tool_result",content:d.output??null,toolName:c,toolInput:null,toolOutput:d.output==null?null:{output:d.output},tokenUsage:null,model:t.model,timestamp:y,metadata:{callId:d.call_id}});continue}if(f.type==="event_msg"&&d.type==="token_count"){let c=d.info,g=c?.total_token_usage?.total_tokens??0;if(g>0&&g===t.prevCumulativeTotal)continue;g>0&&(t.prevCumulativeTotal=g);let _=je(c?.last_token_usage??c?.total_token_usage);if(!_)continue;let h=c?.model??c?.model_name??t.model;o.push({sequence:t.sequence++,eventType:"assistant_message",content:null,toolName:null,toolInput:null,toolOutput:null,tokenUsage:_,model:h??null,timestamp:y,metadata:{codexEventType:"token_count",...h?{model:h}:{},reasoningOutputTokens:c?.last_token_usage?.reasoning_output_tokens??0}})}}return{events:o,projectPath:p,gitBranch:a,sessionId:u,metadata:r}}};var qe={claude_code:i(()=>new O,"claude_code"),cursor:i(()=>new N,"cursor"),vscode_copilot:i(()=>new P,"vscode_copilot"),copilot_agent:i(()=>new b,"copilot_agent"),rulemetric_mcp:i(()=>new D,"rulemetric_mcp"),codex:i(()=>new C,"codex")};function Ee(n){let e=qe[n];if(!e)throw new Error(`Unknown session tool: ${n}`);return e()}i(Ee,"getAdapter");function Re(n){let e=n.trim();if(e.startsWith("{")){let t=e.split(`
|
|
6
|
+
`)[0],s=null;try{s=JSON.parse(t)}catch{try{s=JSON.parse(e)}catch{}}if(s){if(s.type==="user"||s.type==="assistant")return"claude_code";if(Array.isArray(s.events)&&!s.requests&&!s.allComposers)return"rulemetric_mcp";if(Array.isArray(s.requests))return s.requests.some(r=>Array.isArray(r.toolCalls))||s.agentMode?"copilot_agent":"vscode_copilot";if(s.allComposers)return"cursor"}if(!s)try{let o=e.split(`
|
|
7
|
+
`).filter(r=>r.trim());if(o.length>1){let r=JSON.parse(o[0]);if(r.type==="user"||r.type==="assistant")return"claude_code"}}catch{}}return null}i(Re,"detectTool");function Me(n,e){let t=e.length>0?e.map(o=>`### ${o.name} (ID: ${o.id})
|
|
8
|
+
|
|
9
|
+
${o.content}`).join(`
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
`):"No instructions were linked to this session.",s=n.map(o=>{let r=`[${o.sequence}] ${o.eventType}`;if(o.eventType==="tool_call")return`${r}: ${o.toolName}(${JSON.stringify(o.toolInput)})`;if(o.eventType==="tool_result"){let p=o.content?.slice(0,200)??"";return`${r}: ${p}${o.content&&o.content.length>200?"...":""}`}let l=o.content?.slice(0,300)??"";return`${r}: ${l}${o.content&&o.content.length>300?"...":""}`}).join(`
|
|
14
|
+
`);return`You are analyzing an AI coding session to evaluate how well the agent followed its instructions and to suggest improvements.
|
|
15
|
+
|
|
16
|
+
## Active Instructions
|
|
17
|
+
|
|
18
|
+
${t}
|
|
19
|
+
|
|
20
|
+
## Session Transcript
|
|
21
|
+
|
|
22
|
+
${s}
|
|
23
|
+
|
|
24
|
+
## Analysis Tasks
|
|
25
|
+
|
|
26
|
+
1. **Adherence Score** (0-100): Rate how well the agent followed each active instruction. 100 = perfect adherence.
|
|
27
|
+
2. **Deviations**: List specific events where the agent deviated from instructions. Each deviation needs:
|
|
28
|
+
- eventSequence: the event number
|
|
29
|
+
- instructionId: which instruction was violated
|
|
30
|
+
- description: what went wrong
|
|
31
|
+
- severity: "low", "medium", or "high"
|
|
32
|
+
3. **Suggestions**: For each gap or deviation, propose a specific edit to the instruction. Each suggestion needs:
|
|
33
|
+
- instructionId: which instruction to improve
|
|
34
|
+
- currentContent: the relevant excerpt from the instruction
|
|
35
|
+
- suggestedContent: your proposed replacement text
|
|
36
|
+
- rationale: why this change would help
|
|
37
|
+
- confidence: 0-100 how confident you are this would improve outcomes
|
|
38
|
+
4. **Summary**: One paragraph summarizing the session quality.
|
|
39
|
+
|
|
40
|
+
Return your response as JSON matching this schema:
|
|
41
|
+
{
|
|
42
|
+
"adherenceScore": <number 0-100>,
|
|
43
|
+
"deviations": [{ "eventSequence": <number>, "instructionId": "<string>", "description": "<string>", "severity": "<low|medium|high>" }],
|
|
44
|
+
"suggestions": [{ "instructionId": "<string>", "currentContent": "<string>", "suggestedContent": "<string>", "rationale": "<string>", "confidence": <number 0-100> }],
|
|
45
|
+
"summary": "<string>"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Return valid JSON only.`}i(Me,"buildAnalysisPrompt");function Je(n){try{let e=n.match(/\{[\s\S]*\}/);if(!e)return null;let t=JSON.parse(e[0]);return typeof t.adherenceScore!="number"||!Array.isArray(t.deviations)||!Array.isArray(t.suggestions)||typeof t.summary!="string"?null:{adherenceScore:t.adherenceScore,deviations:t.deviations,suggestions:t.suggestions,summary:t.summary,analyzedAt:new Date().toISOString()}}catch{return null}}i(Je,"parseAnalysisResponse");import{readdir as G,stat as L}from"fs/promises";import{basename as Be,join as I}from"path";import{homedir as $}from"os";var Ge={"claude-opus-4-7":"Opus 4.7","claude-opus-4-6":"Opus 4.6","claude-opus-4-5":"Opus 4.5","claude-opus-4-1":"Opus 4.1","claude-opus-4":"Opus 4","claude-sonnet-4-6":"Sonnet 4.6","claude-sonnet-4-5":"Sonnet 4.5","claude-sonnet-4":"Sonnet 4","claude-3-7-sonnet":"Sonnet 3.7","claude-3-5-sonnet":"Sonnet 3.5","claude-haiku-4-5":"Haiku 4.5","claude-3-5-haiku":"Haiku 3.5"};function Le(){return process.env.CLAUDE_CONFIG_DIR||I($(),".claude")}i(Le,"getClaudeDir");function Fe(){return I(Le(),"projects")}i(Fe,"getProjectsDir");function We(){return process.platform==="darwin"?I($(),"Library","Application Support","Claude","local-agent-mode-sessions"):process.platform==="win32"?I($(),"AppData","Roaming","Claude","local-agent-mode-sessions"):I($(),".config","Claude","local-agent-mode-sessions")}i(We,"getDesktopSessionsDir");async function He(n){let e=[];async function t(s,o){if(o>8)return;let r=await G(s).catch(()=>[]);for(let l of r){if(l==="node_modules"||l===".git")continue;let p=I(s,l);if((await L(p).catch(()=>null))?.isDirectory())if(l==="projects"){let u=await G(p).catch(()=>[]);for(let m of u){let f=I(p,m);(await L(f).catch(()=>null))?.isDirectory()&&e.push(f)}}else await t(p,o+1)}}return i(t,"walk"),await t(n,0),e}i(He,"findDesktopProjectDirs");var Q={name:"claude",displayName:"Claude Code",modelDisplayName(n){let e=n.replace(/@.*$/,"").replace(/-\d{8}$/,"");for(let[t,s]of Object.entries(Ge))if(e.startsWith(t))return s;return e},toolDisplayName(n){return n},async discoverSessions(){let n=[],e=Fe();try{let s=await G(e);for(let o of s){let r=I(e,o);(await L(r).catch(()=>null))?.isDirectory()&&n.push({path:r,project:o,provider:"claude"})}}catch{}let t=await He(We());for(let s of t)n.push({path:s,project:Be(s),provider:"claude"});return n},createSessionParser(){return{async*parse(){}}}};import{readdir as j,readFile as ee,stat as ze}from"fs/promises";import{basename as Ke,join as A}from"path";import{homedir as Ve}from"os";var Ye={"gpt-5.3-codex":"GPT-5.3 Codex","gpt-5.4-mini":"GPT-5.4 Mini","gpt-5.4":"GPT-5.4","gpt-5":"GPT-5","gpt-4o-mini":"GPT-4o Mini","gpt-4o":"GPT-4o"},te={exec_command:"Bash",read_file:"Read",write_file:"Edit",apply_diff:"Edit",apply_patch:"Edit",spawn_agent:"Agent",close_agent:"Agent",wait_agent:"Agent",read_dir:"Glob"};function Xe(){return process.env.CODEX_HOME??A(Ve(),".codex")}i(Xe,"getCodexDir");function Ze(n){return n.replace(/^\//,"").replace(/\//g,"-")}i(Ze,"sanitizeProject");async function Qe(n){try{let t=(await ee(n,"utf-8")).split(`
|
|
49
|
+
`)[0];return t?.trim()?JSON.parse(t):null}catch{return null}}i(Qe,"readFirstLine");async function et(n){let e=await Qe(n);if(!e)return{valid:!1};let t=e.type==="session_meta"&&typeof e.payload?.originator=="string"&&e.payload.originator.toLowerCase().startsWith("codex");return{valid:t,meta:t?e:void 0}}i(et,"isValidCodexSession");async function tt(n){let e=A(n,"sessions"),t=[],s;try{s=await j(e)}catch{return t}for(let o of s){if(!/^\d{4}$/.test(o))continue;let r=A(e,o),l=await j(r).catch(()=>[]);for(let p of l){if(!/^\d{2}$/.test(p))continue;let a=A(r,p),u=await j(a).catch(()=>[]);for(let m of u){if(!/^\d{2}$/.test(m))continue;let f=A(a,m),d=await j(f).catch(()=>[]);for(let y of d){if(!y.startsWith("rollout-")||!y.endsWith(".jsonl"))continue;let c=A(f,y);if(!(await ze(c).catch(()=>null))?.isFile())continue;let{valid:_,meta:h}=await et(c);if(!_||!h)continue;let x=h.payload?.cwd??"unknown";t.push({path:c,project:Ze(x),provider:"codex"})}}}}return t}i(tt,"discoverSessionsInDir");function nt(n,e){return n?.info?.model??n?.info?.model_name??e??"gpt-5"}i(nt,"resolveModel");function ot(n,e){return{async*parse(){let t;try{t=await ee(n.path,"utf-8")}catch{return}let s=t.split(`
|
|
50
|
+
`).filter(y=>y.trim()),o,r="",l=0,p=0,a=0,u=0,m=0,f=[],d="";for(let y of s){let c;try{c=JSON.parse(y)}catch{continue}if(c.type==="session_meta"){r=c.payload?.session_id??Ke(n.path,".jsonl"),o=c.payload?.model;continue}if(c.type==="response_item"&&c.payload?.type==="function_call"){let g=c.payload.name??"";f.push(te[g]??g);continue}if(c.type==="response_item"&&c.payload?.type==="message"&&c.payload?.role==="user"){let g=(c.payload.content??[]).filter(_=>_.type==="input_text").map(_=>_.text??"").filter(Boolean);g.length>0&&(d=g.join(" "));continue}if(c.type==="event_msg"&&c.payload?.type==="token_count"){let g=c.payload.info;if(!g)continue;let _=g.total_token_usage?.total_tokens??0;if(_>0&&_===l)continue;l=_;let h=g.last_token_usage,x=0,S=0,w=0,v=0;if(h)x=h.input_tokens??0,S=h.cached_input_tokens??0,w=h.output_tokens??0,v=h.reasoning_output_tokens??0;else if(_>0){let T=g.total_token_usage;if(!T)continue;x=(T.input_tokens??0)-p,S=(T.cached_input_tokens??0)-a,w=(T.output_tokens??0)-u,v=(T.reasoning_output_tokens??0)-m}if(!h){let T=g.total_token_usage;T&&(p=T.input_tokens??0,a=T.cached_input_tokens??0,u=T.output_tokens??0,m=T.reasoning_output_tokens??0)}if(x+S+w+v===0)continue;let be=Math.max(0,x-S),De=nt(c.payload,o),Y=c.timestamp??"",B=`codex:${n.path}:${Y}:${_}`;if(e.has(B))continue;e.add(B),yield{provider:"codex",model:De,inputTokens:be,outputTokens:w,cacheCreationInputTokens:0,cacheReadInputTokens:S,cachedInputTokens:S,reasoningTokens:v,costUSD:0,tools:f,bashCommands:[],timestamp:Y,speed:"standard",deduplicationKey:B,userMessage:d,sessionId:r},f=[],d=""}}}}}i(ot,"createParser");var ne={name:"codex",displayName:"Codex",modelDisplayName(n){for(let[e,t]of Object.entries(Ye))if(n.startsWith(e))return t;return n},toolDisplayName(n){return te[n]??n},async discoverSessions(){return tt(Xe())},createSessionParser(n,e){return ot(n,e)}};import{readdir as st,readFile as oe,stat as rt}from"fs/promises";import{basename as se,dirname as at,join as F}from"path";import{homedir as it}from"os";var lt={"gpt-4.1-nano":"GPT-4.1 Nano","gpt-4.1-mini":"GPT-4.1 Mini","gpt-4.1":"GPT-4.1","gpt-4o-mini":"GPT-4o Mini","gpt-4o":"GPT-4o","gpt-5-mini":"GPT-5 Mini","gpt-5":"GPT-5","claude-sonnet-4-5":"Sonnet 4.5","claude-sonnet-4":"Sonnet 4","claude-3-7-sonnet":"Sonnet 3.7","claude-3-5-sonnet":"Sonnet 3.5","o4-mini":"o4-mini",o3:"o3"},re={bash:"Bash",read_file:"Read",write_file:"Edit",edit_file:"Edit",create_file:"Write",delete_file:"Delete",search_files:"Grep",find_files:"Glob",list_directory:"LS",web_search:"WebSearch",fetch_webpage:"WebFetch",github_repo:"GitHub"},ct=Object.entries(lt).sort((n,e)=>e[0].length-n[0].length);function ut(){return F(it(),".copilot","session-state")}i(ut,"getCopilotSessionStateDir");function pt(n){let e=n.match(/^cwd:\s*(.+)$/m);return e?.[1]&&e[1].replace(/\s*#.*$/,"").replace(/^['"]|['"]$/g,"").trim()||null}i(pt,"parseCwd");function dt(n,e){return{async*parse(){let t;try{t=await oe(n.path,"utf-8")}catch{return}let s=se(at(n.path)),o=t.split(`
|
|
51
|
+
`).filter(p=>p.trim()),r="",l="";for(let p of o){let a;try{a=JSON.parse(p)}catch{continue}if(a.type==="session.model_change"){r=a.data.newModel??r;continue}if(a.type==="user.message"){l=a.data.content??"";continue}if(a.type==="assistant.message"){let{messageId:u,outputTokens:m,toolRequests:f=[]}=a.data;if(m===0||!r)continue;let d=`copilot:${s}:${u}`;if(e.has(d))continue;e.add(d);let y=f.map(c=>c.name??"").filter(Boolean).map(c=>re[c]??c);yield{provider:"copilot",model:r,inputTokens:0,outputTokens:m,cacheCreationInputTokens:0,cacheReadInputTokens:0,cachedInputTokens:0,reasoningTokens:0,costUSD:0,tools:y,bashCommands:[],timestamp:a.timestamp??"",speed:"standard",deduplicationKey:d,userMessage:l,sessionId:s},l=""}}}}}i(dt,"createParser");async function mt(n){let e=[],t;try{t=await st(n)}catch{return e}for(let s of t){let o=F(n,s,"events.jsonl");if(!(await rt(o).catch(()=>null))?.isFile())continue;let l=s;try{let p=await oe(F(n,s,"workspace.yaml"),"utf-8"),a=pt(p);a&&(l=se(a))}catch{}e.push({path:o,project:l,provider:"copilot"})}return e}i(mt,"discoverSessionsInDir");var ae={name:"copilot",displayName:"GitHub Copilot",modelDisplayName(n){for(let[e,t]of ct)if(n===e||n.startsWith(e+"-"))return t;return n},toolDisplayName(n){return re[n]??n},async discoverSessions(){return mt(ut())},createSessionParser(n,e){return dt(n,e)}};import{readdir as ie,readFile as ce,stat as le}from"fs/promises";import{basename as ue,join as W}from"path";import{homedir as ft}from"os";var ht={"gpt-5.4":"GPT-5.4","gpt-5.4-mini":"GPT-5.4 Mini","gpt-5":"GPT-5","gpt-4o":"GPT-4o","gpt-4o-mini":"GPT-4o Mini"},pe={bash:"Bash",read:"Read",edit:"Edit",write:"Write",glob:"Glob",grep:"Grep",task:"Agent",dispatch_agent:"Agent",fetch:"WebFetch",search:"WebSearch",todo:"TodoWrite",patch:"Patch"},gt=Object.entries(ht).sort((n,e)=>e[0].length-n[0].length);function yt(){return W(ft(),".pi","agent","sessions")}i(yt,"getPiSessionsDir");async function _t(n){try{let t=(await ce(n,"utf-8")).split(`
|
|
52
|
+
`)[0];return t?.trim()?JSON.parse(t):null}catch{return null}}i(_t,"readFirstEntry");function St(n){return n.split(/[;&|]+/).map(e=>e.trim().split(/\s+/)[0]).filter(Boolean)}i(St,"extractBashCommands");async function vt(n){let e=[],t;try{t=await ie(n)}catch{return e}for(let s of t){let o=W(n,s);if(!(await le(o).catch(()=>null))?.isDirectory())continue;let l;try{l=await ie(o)}catch{continue}for(let p of l){if(!p.endsWith(".jsonl"))continue;let a=W(o,p);if(!(await le(a).catch(()=>null))?.isFile())continue;let m=await _t(a);if(!m||m.type!=="session")continue;let f=m.cwd??s;e.push({path:a,project:ue(f),provider:"pi"})}}return e}i(vt,"discoverSessionsInDir");function wt(n,e){return{async*parse(){let t;try{t=await ce(n.path,"utf-8")}catch{return}let s=t.split(`
|
|
53
|
+
`).filter(l=>l.trim()),o=ue(n.path,".jsonl"),r="";for(let[l,p]of s.entries()){let a;try{a=JSON.parse(p)}catch{continue}if(a.type==="session"){o=a.id??o;continue}if(a.type!=="message")continue;let u=a.message;if(!u)continue;if(u.role==="user"){let v=(u.content??[]).filter(k=>k.type==="text").map(k=>k.text??"").filter(Boolean);v.length>0&&(r=v.join(" "));continue}if(u.role!=="assistant"||!u.usage)continue;let{input:m,output:f,cacheRead:d,cacheWrite:y}=u.usage;if(m===0&&f===0)continue;let c=u.model??"gpt-5",g=u.responseId??"",_=`pi:${n.path}:${g||a.id||a.timestamp||String(l)}`;if(e.has(_))continue;e.add(_);let h=(u.content??[]).filter(v=>v.type==="toolCall"&&v.name),x=h.map(v=>pe[v.name]??v.name),S=h.filter(v=>v.name==="bash").flatMap(v=>{let k=v.arguments?.command;return typeof k=="string"?St(k):[]}),w=a.timestamp??"";yield{provider:"pi",model:c,inputTokens:m,outputTokens:f,cacheCreationInputTokens:y,cacheReadInputTokens:d,cachedInputTokens:d,reasoningTokens:0,costUSD:0,tools:x,bashCommands:S,timestamp:w,speed:"standard",deduplicationKey:_,userMessage:r,sessionId:o},r=""}}}}i(wt,"createParser");var de={name:"pi",displayName:"Pi",modelDisplayName(n){for(let[e,t]of gt)if(n.startsWith(e))return t;return n},toolDisplayName(n){return pe[n]??n},async discoverSessions(){return vt(yt())},createSessionParser(n,e){return wt(n,e)}};var ye=[Q,ne,ae,de],me=null,fe=!1;async function _e(){if(fe)return me;fe=!0;try{let{cursor:n}=await import("./cursor-T7AMCMKS.js");return me=n,n}catch{return null}}i(_e,"loadCursor");var he=null,ge=!1;async function Se(){if(ge)return he;ge=!0;try{let{opencode:n}=await import("./opencode-QRJ3BH23.js");return he=n,n}catch{return null}}i(Se,"loadOpenCode");async function ve(){let[n,e]=await Promise.all([_e(),Se()]),t=[...ye];return n&&t.push(n),e&&t.push(e),t}i(ve,"getAllProviders");async function xt(n){let e=await ve(),t=n&&n!=="all"?e.filter(o=>o.name===n):e,s=[];for(let o of t){let r=await o.discoverSessions();s.push(...r)}return s}i(xt,"discoverAllSessions");async function Tt(n){return n==="cursor"?await _e()??void 0:n==="opencode"?await Se()??void 0:ye.find(e=>e.name===n)}i(Tt,"getProvider");import{spawn as V}from"node:child_process";import{randomUUID as Ot}from"node:crypto";import{writeFile as xe}from"node:fs/promises";import{tmpdir as Te}from"node:os";import{join as Ie}from"node:path";import{spawn as It}from"node:child_process";function H(n){return`rm-${n.trim().replace(/[^A-Za-z0-9_.-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"session"}`}i(H,"sanitizeTmuxName");function z(n){let e=n.runId?["env",`RULEMETRIC_RUN_ID=${n.runId}`,"claude"]:["claude"];return n.resumeSessionId&&e.push("--resume",n.resumeSessionId),n.model&&e.push("--model",n.model),["new-session","-d","-s",n.sessionName,"-c",n.projectPath,"--",...e]}i(z,"buildTmuxLaunchArgs");function U(n,e,t={}){return t.literal===!1?["send-keys","-t",n,e]:["send-keys","-t",n,"-l","--",e]}i(U,"buildTmuxSendKeysArgs");function kt(n){return["has-session","-t",n]}i(kt,"buildTmuxHasSessionArgs");function q(n){return`tmux attach -t ${n}`}i(q,"buildTmuxAttachCommand");function At(){let n=["/opt/homebrew/bin","/usr/local/bin"],e=(process.env.PATH??"").split(":").filter(Boolean),t=n.filter(s=>!e.includes(s));return t.length===0?process.env:{...process.env,PATH:[...e,...t].join(":")}}i(At,"tmuxSpawnEnv");function K(n){return new Promise(e=>{let t=It("tmux",n,{stdio:["ignore","ignore","pipe"],env:At()}),s="";t.stderr.on("data",o=>{s+=o.toString()}),t.on("close",o=>e({code:o,stderr:s})),t.on("error",o=>e({code:null,stderr:o.message}))})}i(K,"runTmux");async function we(){return(await K(["-V"])).code===0}i(we,"isTmuxAvailable");var Nt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Pt(n){if(n!==void 0){if(Nt.test(n))return n;console.warn(`[claude-code-launcher] dropping non-uuid runId (RULEMETRIC_RUN_ID not injected): ${JSON.stringify(n)}`)}}i(Pt,"validateRunId");function bt(n){return`'${n.replace(/'/g,"'\\''")}'`}i(bt,"shellSingleQuote");var E=class{static{i(this,"ClaudeCodeLauncher")}options;tool="claude_code";constructor(e={}){this.options=e}capabilities={headless:!0,interactive:!0,remoteSpawn:!0};async launch(e){let t=Ot(),s={...e,runId:Pt(e.runId)};return s.mode==="headless"?this.launchHeadless(s,t):this.launchInteractive(s,t)}async launchHeadless(e,t){let s=["-p",e.prompt??"","--output-format","json"];e.systemPrompt&&s.push("--system-prompt",e.systemPrompt),e.model&&s.push("--model",e.model);let o={...process.env};return delete o.CLAUDECODE,delete o.HTTPS_PROXY,e.runId&&(o.RULEMETRIC_RUN_ID=e.runId),new Promise(r=>{let l=V("claude",s,{cwd:e.projectPath,env:o,stdio:["ignore","pipe","pipe"]}),p="",a="";l.stdout.on("data",m=>{p+=m.toString()}),l.stderr.on("data",m=>{a+=m.toString()});let u=e.timeout?setTimeout(()=>{l.kill("SIGTERM")},e.timeout):null;l.on("close",m=>{u&&clearTimeout(u);let f=p;try{let d=JSON.parse(p);f=d.result??d.content??p}catch{}r({sessionId:t,pid:l.pid,exitCode:m,output:f,error:m!==0?a:void 0})}),l.on("error",m=>{u&&clearTimeout(u),r({sessionId:t,error:`Failed to spawn claude: ${m.message}`})})})}async launchInteractive(e,t){return await(this.options.tmuxAvailable??we)().catch(()=>!1)?this.launchInteractiveTmux(e,t):this.launchInteractiveTerminal(e,t,"tmux_not_found")}async launchInteractiveTmux(e,t){let s=this.options.runTmux??K,o=H(`claude-${e.resumeSessionId??t}`),r=await s(z({sessionName:o,projectPath:e.projectPath,resumeSessionId:e.resumeSessionId,model:e.model,runId:e.runId}));if(r.code!==0)return this.launchInteractiveTerminal(e,t,"tmux_launch_failed",`tmux new-session exited ${r.code}: ${r.stderr.trim()||"no stderr"}`);let l=await this.openTerminalAttach(o,t);if(e.prompt){let p=await s(U(o,e.prompt));if(p.code!==0)return{sessionId:t,liveSendAvailable:!1,fallbackReason:"tmux_launch_failed",error:`tmux send-keys exited ${p.code}: ${p.stderr.trim()||"no stderr"}`};let a=await s(U(o,"Enter",{literal:!1}));if(a.code!==0)return{sessionId:t,liveSendAvailable:!1,fallbackReason:"tmux_launch_failed",error:`tmux send Enter exited ${a.code}: ${a.stderr.trim()||"no stderr"}`}}return{sessionId:t,pid:l.pid,liveSendAvailable:!0,...l.error?{error:l.error}:{},terminalTarget:{kind:"tmux",target:o,attachCommand:q(o),live:!0}}}async openTerminalAttach(e,t){let s=Ie(Te(),`rulemetric-attach-${t}.command`),o=`#!/bin/zsh
|
|
54
|
+
rm -- "$0"
|
|
55
|
+
${q(e)}
|
|
56
|
+
`;return await xe(s,o,{mode:493}),new Promise(r=>{let l=V("open",["-a","Terminal",s],{stdio:["ignore","pipe","pipe"]}),p="";l.stderr.on("data",a=>{p+=a.toString()}),l.on("close",a=>{r(a===0?{pid:l.pid}:{pid:l.pid,error:`open attach exited ${a}: ${p.trim()||"no stderr"}`})}),l.on("error",a=>{r({error:`Failed to spawn open attach: ${a.message}`})})})}async launchInteractiveTerminal(e,t,s,o){let r=["claude"];e.resumeSessionId?r.push("--resume",e.resumeSessionId):e.prompt&&r.push("-p",JSON.stringify(e.prompt)),e.model&&r.push("--model",e.model);let l=r.join(" "),p=Ie(Te(),`rulemetric-launch-${t}.command`),a=e.runId?`export RULEMETRIC_RUN_ID=${bt(e.runId)}
|
|
57
|
+
`:"",u=`#!/bin/zsh
|
|
58
|
+
rm -- "$0"
|
|
59
|
+
cd ${JSON.stringify(e.projectPath)} || exit
|
|
60
|
+
`+a+`${l}
|
|
61
|
+
`;return await xe(p,u,{mode:493}),new Promise(m=>{let f=V("open",["-a","Terminal",p],{stdio:["ignore","pipe","pipe"]}),d="";f.stderr.on("data",y=>{d+=y.toString()}),f.on("close",y=>{if(y===0)m({sessionId:t,pid:f.pid,liveSendAvailable:!1,fallbackReason:s,...o?{error:o}:{}});else{let c=d.trim()||"no stderr";m({sessionId:t,pid:f.pid,liveSendAvailable:!1,fallbackReason:s,error:o?`${o}; open exited ${y}: ${c}`:`open exited ${y}: ${c}`})}}),f.on("error",y=>{m({sessionId:t,liveSendAvailable:!1,fallbackReason:s,error:`Failed to spawn open: ${y.message}`})})})}};import{spawn as ke}from"node:child_process";import{randomUUID as Dt}from"node:crypto";var R=class{static{i(this,"CodexLauncher")}tool="codex";capabilities={headless:!0,interactive:!0,remoteSpawn:!0};async launch(e){let t=Dt();return e.mode==="headless"?this.launchHeadless(e,t):this.launchInteractive(e,t)}launchHeadless(e,t){let s=["-q",e.prompt??""];return e.model&&s.push("--model",e.model),new Promise(o=>{let r=ke("codex",s,{cwd:e.projectPath,stdio:["ignore","pipe","pipe"]}),l="",p="";r.stdout.on("data",u=>{l+=u.toString()}),r.stderr.on("data",u=>{p+=u.toString()});let a=e.timeout?setTimeout(()=>{r.kill("SIGTERM")},e.timeout):null;r.on("close",u=>{a&&clearTimeout(a),o({sessionId:t,pid:r.pid,exitCode:u,output:l,error:u!==0?p:void 0})}),r.on("error",u=>{a&&clearTimeout(a),o({sessionId:t,error:`Failed to spawn codex: ${u.message}`})})})}launchInteractive(e,t){let s=["codex"];e.prompt&&s.push(JSON.stringify(e.prompt));let o=`cd ${JSON.stringify(e.projectPath)} && ${s.join(" ")}`,r=ke("osascript",["-e",`tell application "Terminal" to do script ${JSON.stringify(o)}`],{stdio:"ignore",detached:!0});return r.unref(),Promise.resolve({sessionId:t,pid:r.pid})}};import{spawn as Ae}from"node:child_process";import{randomUUID as Ct}from"node:crypto";var M=class{static{i(this,"AiderLauncher")}tool="aider";capabilities={headless:!0,interactive:!0,remoteSpawn:!0};async launch(e){let t=Ct();return e.mode==="headless"?this.launchHeadless(e,t):this.launchInteractive(e,t)}launchHeadless(e,t){let s=["--message",e.prompt??"","--yes"];return e.model&&s.push("--model",e.model),new Promise(o=>{let r=Ae("aider",s,{cwd:e.projectPath,stdio:["ignore","pipe","pipe"]}),l="",p="";r.stdout.on("data",u=>{l+=u.toString()}),r.stderr.on("data",u=>{p+=u.toString()});let a=e.timeout?setTimeout(()=>{r.kill("SIGTERM")},e.timeout):null;r.on("close",u=>{a&&clearTimeout(a),o({sessionId:t,pid:r.pid,exitCode:u,output:l,error:u!==0?p:void 0})}),r.on("error",u=>{a&&clearTimeout(a),o({sessionId:t,error:`Failed to spawn aider: ${u.message}`})})})}launchInteractive(e,t){let s=["aider"];e.model&&s.push("--model",e.model);let o=`cd ${JSON.stringify(e.projectPath)} && ${s.join(" ")}`,r=Ae("osascript",["-e",`tell application "Terminal" to do script ${JSON.stringify(o)}`],{stdio:"ignore",detached:!0});return r.unref(),Promise.resolve({sessionId:t,pid:r.pid})}};import{spawn as $t}from"node:child_process";import{randomUUID as jt}from"node:crypto";var J=class{static{i(this,"GenericLauncher")}tool;constructor(e){this.tool=e}capabilities={headless:!1,interactive:!0,remoteSpawn:!1};async launch(e){let t=jt();if(e.mode==="headless")return{sessionId:t,error:`${this.tool} does not support headless mode`};let s=`cd ${JSON.stringify(e.projectPath)} && echo "Session ${t} \u2014 tool: ${this.tool}" && exec $SHELL`,o=$t("osascript",["-e",`tell application "Terminal" to do script ${JSON.stringify(s)}`],{stdio:"ignore",detached:!0});return o.unref(),{sessionId:t,pid:o.pid}}};var Oe={claude_code:i(()=>new E,"claude_code"),codex:i(()=>new R,"codex"),aider:i(()=>new M,"aider")};function Ut(n){let e=Oe[n];return e?e():new J(n)}i(Ut,"getLauncher");function qt(){return Object.entries(Oe).map(([n,e])=>({tool:n,capabilities:e().capabilities}))}i(qt,"getAvailableLaunchers");import Ne from"node:path";function Pe(n){return n.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^[-.]+|[-.]+$/g,"")||"worktree"}i(Pe,"sanitizeBranch");function Et(n){return Ne.resolve(n.basePath??Ne.join(n.repoRoot,"..",".rulemetric-worktrees",Pe(n.branch)))}i(Et,"worktreePathFor");export{Rt as a,Mt as b,O as c,N as d,P as e,b as f,D as g,Z as h,C as i,Ee as j,Re as k,Me as l,Je as m,ve as n,xt as o,Tt as p,H as q,z as r,U as s,kt as t,q as u,Ut as v,qt as w,Pe as x,Et as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as d}from"./chunk-NJ5UED3H.js";import{a as o}from"./chunk-ZLLER3HP.js";import{Box as s,Text as i}from"ink";import{jsx as l,jsxs as u}from"react/jsx-runtime";function h({title:e,color:r,children:t,width:n}){return u(s,{flexDirection:"column",borderStyle:"round",borderColor:r,paddingX:1,width:n,overflowX:"hidden",children:[l(i,{bold:!0,color:r,children:e}),t]})}o(h,"Panel");function _(e){let r=e<=.5?Math.round(91+e*2*164):255,t=e<=.5?Math.round(158+e*2*42):Math.round(200-(e-.5)*2*109),n=e<=.5?Math.round(245-e*2*154):91;return`#${r.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}o(_,"gradientColor");function m({value:e,max:r,width:t}){if(r===0)return l(i,{color:d,children:"\u2591".repeat(t)});let n=Math.round(e/r*t),c=[];for(let a=0;a<Math.min(n,t);a++)c.push(l(i,{color:_(a/t),children:"\u2588"},a));return u(i,{children:[c,l(i,{color:"#333333",children:"\u2591".repeat(Math.max(t-n,0))})]})}o(m,"HBar");function p(e,r){return e.length>r?e.slice(0,r):e.padEnd(r)}o(p,"fit");function b(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}o(b,"formatTokens");function $(e){return e>=1e3?`$${(e/1e3).toFixed(1)}K`:e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(3)}`}o($,"formatCost");var g={fully_achieved:"Fully Achieved",mostly_achieved:"Mostly Achieved",partially_achieved:"Partially Achieved",not_achieved:"Not Achieved",unclear_from_transcript:"Unclear",misunderstood_request:"Misunderstood Request",wrong_approach:"Wrong Approach",buggy_code:"Buggy Code",user_rejected_action:"User Rejected",excessive_changes:"Excessive Changes",wrong_file_or_location:"Wrong File/Location",slow_or_verbose:"Slow/Verbose",tool_failed:"Tool Failed"};function v(e){return g[e]||e.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}o(v,"friendlyLabel");export{h as a,m as b,p as c,b as d,$ as e,v as f};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{f as d}from"./chunk-RTWRHIKY.js";import{c as e,d as o,h as y}from"./chunk-H4SV7FN4.js";import{a as g}from"./chunk-ZLLER3HP.js";import{eq as c,asc as P,sql as R}from"drizzle-orm";var T=1800*1e3,I=300*1e3,h=10,D=`Given these messages from an AI coding session, write a 1-2 sentence summary of what the user is trying to accomplish. Focus on the goal, not the steps. No preamble.
|
|
2
|
+
|
|
3
|
+
Return strict JSON in the form: {"goalSummary": "..."}`;async function b(t,a={}){let n=a.db??y(),f=a.llm??d,r=a.now??Date.now,[i]=await n.select().from(e).where(c(e.id,t.sessionId)).limit(1);if(!i)return{skipped:"not_found"};let w=(await n.execute(R`SELECT MAX(timestamp) AS last_at FROM session_events WHERE session_id = ${t.sessionId}`))?.[0]?.last_at??i.startedAt,_=new Date(w).getTime();if(r()-_>T)return{skipped:"stale"};let m=i.analysis??{},p=m.goalSummaryAt?new Date(m.goalSummaryAt).getTime():0;if(p&&r()-p<I)return{skipped:"recent"};let u=(await n.select().from(o).where(c(o.sessionId,t.sessionId)).orderBy(P(o.timestamp)).limit(h*2)).filter(s=>s.content&&(s.eventType==="user_message"||s.eventType==="assistant_response")).map(s=>`${s.eventType==="user_message"?"USER":"ASSISTANT"}: ${s.content}`).join(`
|
|
4
|
+
|
|
5
|
+
`);if(!u)return{skipped:"no_content"};let S=await f(D,u,200),l=typeof S?.goalSummary=="string"?S.goalSummary.trim():"";if(!l)return{skipped:"llm_empty"};let A=new Date(r()).toISOString();return await n.update(e).set({analysis:{...m,goalSummary:l,goalSummaryAt:A}}).where(c(e.id,t.sessionId)),{goalSummary:l}}g(b,"processSessionGoal");export{b as a};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import{a as p}from"./chunk-MGHFDHHM.js";import{a as c}from"./chunk-ZLLER3HP.js";var v=`You are a rigorous eval grader. Your job is to evaluate whether an AI assistant's output meets a set of expectations.
|
|
2
|
+
|
|
3
|
+
You will receive:
|
|
4
|
+
1. The original prompt that was given to the AI
|
|
5
|
+
2. The AI's output/response
|
|
6
|
+
3. A list of expectations (assertions) to evaluate
|
|
7
|
+
|
|
8
|
+
For each expectation:
|
|
9
|
+
- Search the output for evidence that the expectation is met
|
|
10
|
+
- Determine PASS or FAIL (no partial credit)
|
|
11
|
+
- Cite specific evidence (quote or description)
|
|
12
|
+
|
|
13
|
+
PASS criteria:
|
|
14
|
+
- Clear evidence the assertion is true
|
|
15
|
+
- Evidence reflects genuine completion, not surface compliance
|
|
16
|
+
|
|
17
|
+
FAIL criteria:
|
|
18
|
+
- No evidence found
|
|
19
|
+
- Evidence contradicts the expectation
|
|
20
|
+
- Cannot verify from available information
|
|
21
|
+
|
|
22
|
+
Beyond the predefined expectations, extract implicit claims from the output:
|
|
23
|
+
- Factual claims ("uses TypeScript", "has 3 parameters")
|
|
24
|
+
- Process claims ("used async/await pattern")
|
|
25
|
+
- Quality claims ("handles edge cases")
|
|
26
|
+
|
|
27
|
+
Verify each claim against the actual output.
|
|
28
|
+
|
|
29
|
+
Finally, critique the eval itself \u2014 identify assertions that are too weak (pass for wrong outputs) or important outcomes that no assertion covers.
|
|
30
|
+
|
|
31
|
+
You MUST respond with ONLY a valid JSON object matching this exact structure (no markdown, no explanation, just JSON):
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
"expectations": [
|
|
35
|
+
{ "text": "assertion text", "passed": true, "evidence": "specific quote or description" }
|
|
36
|
+
],
|
|
37
|
+
"summary": { "passed": 2, "failed": 1, "total": 3, "pass_rate": 0.67 },
|
|
38
|
+
"claims": [
|
|
39
|
+
{ "claim": "statement", "type": "factual", "verified": true, "evidence": "..." }
|
|
40
|
+
],
|
|
41
|
+
"eval_feedback": {
|
|
42
|
+
"suggestions": [{ "assertion": "suggested new assertion", "reason": "why it matters" }],
|
|
43
|
+
"overall": "brief summary assessment"
|
|
44
|
+
}
|
|
45
|
+
}`;async function y(l){let{prompt:u,output:d,expectations:t,model:m,timeout:g=12e4}=l,f=`## Original Prompt
|
|
46
|
+
|
|
47
|
+
${u}
|
|
48
|
+
|
|
49
|
+
## AI Output
|
|
50
|
+
|
|
51
|
+
${d}
|
|
52
|
+
|
|
53
|
+
## Expectations to Evaluate
|
|
54
|
+
|
|
55
|
+
${t.map((e,s)=>`${s+1}. ${e}`).join(`
|
|
56
|
+
`)}
|
|
57
|
+
|
|
58
|
+
Grade the output against each expectation. Respond with ONLY valid JSON.`,a=await p({prompt:f,targetContent:v,timeout:g,model:m});if(a.error)return{expectations:t.map(e=>({text:e,passed:!1,evidence:`Grader error: ${a.error}`})),summary:{passed:0,failed:t.length,total:t.length,pass_rate:0},claims:[],eval_feedback:{suggestions:[],overall:`Grading failed: ${a.error}`}};try{let e=a.output.trim(),s=e.match(/```(?:json)?\s*([\s\S]*?)```/);s&&(e=s[1].trim());let n=e.match(/\{[\s\S]*\}/);n&&(e=n[0]);let r=JSON.parse(e),o=r.expectations.filter(h=>h.passed).length,i=r.expectations.length;return r.summary={passed:o,failed:i-o,total:i,pass_rate:i>0?o/i:0},r}catch{return{expectations:t.map(e=>({text:e,passed:!1,evidence:"Grader output was not valid JSON"})),summary:{passed:0,failed:t.length,total:t.length,pass_rate:0},claims:[],eval_feedback:{suggestions:[],overall:`Grader returned unparseable output: ${a.output.slice(0,200)}`}}}}c(y,"gradeEvalOutput");export{y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o,b as n}from"./chunk-ZLLER3HP.js";import*as s from"node:fs";import*as t from"node:path";import*as c from"node:os";import{SkillCatalog as g}from"@rulemetric/skills-registry";var a=t.join(c.homedir(),".config","rulemetric","skills-registry.json");function u(){try{let e=t.dirname(n.resolve("@rulemetric/skills-registry/package.json")),r=t.join(e,"registry.json");if(s.existsSync(r))return r}catch{let e=t.resolve(process.cwd(),"packages","skills-registry","registry.json");if(s.existsSync(e))return e}return null}o(u,"findBundledRegistry");async function y(e){let r=new g;if(s.existsSync(a))try{let i=JSON.parse(s.readFileSync(a,"utf-8"));return r.load(i),r}catch{}let l=u();if(l)try{let i=JSON.parse(s.readFileSync(l,"utf-8"));return r.load(i),r}catch{}return e.log("No local registry found. Run: rulemetric skills update"),r}o(y,"loadRegistry");export{y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-ZLLER3HP.js";import{createHash as d}from"node:crypto";import{readdirSync as h,readFileSync as l}from"node:fs";import{join as u,relative as g}from"node:path";var _=new Set(["node_modules",".git","dist","build","out",".next","coverage",".turbo","vendor",".venv"]),a=50,f=8,m=o(s=>d("sha256").update(s).digest("hex"),"sha256");function p(s){let n=[],r=o((i,t)=>{if(n.length>=a||t>f)return;let c;try{c=h(i,{withFileTypes:!0})}catch{return}for(let e of c){if(n.length>=a)return;if(e.isDirectory()){if(_.has(e.name)||e.name.startsWith("."))continue;r(u(i,e.name),t+1)}else e.isFile()&&e.name==="CLAUDE.md"&&n.push(u(i,e.name))}},"walk");return r(s,0),n.sort()}o(p,"findClaudeMdFiles");function S(s){let n=[],r=[];for(let i of p(s)){let t;try{t=l(i,"utf-8")}catch{continue}if(!t.trim())continue;let c=r.length;r.push(t),n.push({type:"claude_md",name:g(s,i)||"CLAUDE.md",content_hash:m(t),char_count:t.length,estimated_tokens:Math.ceil(t.length/4),instruction_index:c})}return n.length===0?null:{provider:"claude_code",model:"unknown",system_prompt:"",system_hash:m(""),injected_instructions:r,context_items:n,metadata:{source:"hook_instruction_snapshot"}}}o(S,"buildInstructionSnapshot");export{S as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as E}from"./chunk-NBTC5FNV.js";import{a as J}from"./chunk-TU2AR6XO.js";import{d as T}from"./chunk-NJ5UED3H.js";import{a as j}from"./chunk-RDET7CKR.js";import{b as I,c as P,d as v}from"./chunk-ZR3MUNLS.js";import{a as b}from"./chunk-ZLLER3HP.js";import{useEffect as R,useState as i}from"react";import{Box as l,Text as s,useInput as Z}from"ink";import{jsx as t,jsxs as a}from"react/jsx-runtime";function K({onClose:A,activeOrg:F,defaultProjectPath:y,width:_}){let{jobs:u,error:L,loading:$,refetch:S}=j(20),[M,C]=i([]),[d,m]=i("list"),[f,w]=i(0),[h,g]=i(null),[x,B]=i(null),[p,c]=i(null);R(()=>{v().then(C).catch(o=>{let r=o instanceof Error?o.message:String(o);c(`couldn't load launchers: ${r}`),C([{tool:"claude_code",capabilities:{headless:!0,interactive:!0,remoteSpawn:!0}}])})},[]),R(()=>{if(!p)return;let o=setTimeout(()=>c(null),5e3);return()=>clearTimeout(o)},[p]),Z((o,r)=>{if(h){if(o==="y"||o==="Y"){let e=h.id;g(null),P(e).then(()=>{S(),c(`cancelled ${e.slice(0,8)}`)}).catch(n=>c(`cancel failed: ${n instanceof Error?n.message:String(n)}`))}else(o==="n"||o==="N"||r.escape)&&g(null);return}if(r.escape){if(d!=="none"){m("none");return}A();return}if(r.tab){m(e=>e==="list"?"form":e==="form"?"none":"list");return}if(o!=="q"&&d==="list"){if(r.upArrow)w(e=>Math.max(0,e-1));else if(r.downArrow)w(e=>Math.min(u.length-1,e+1));else if(o==="c"){let e=u[f];e&&(e.status==="running"||e.status==="queued"||e.status==="pending")&&g(e)}else if(o==="r"){let e=u[f],n=e?.result?.externalSessionId;e&&e.tool==="claude_code"&&n?(B({tool:"claude_code",projectPath:e.config.projectPath,resumeSessionId:n}),m("form")):c("resume needs a Claude Code session with a session id")}else if(o==="o"){let n=u[f]?.result?.externalSessionId;if(n){let O=process.env.RULEMETRIC_WEB_URL??"http://localhost:5174";import("node:child_process").then(({spawn:U})=>{U("open",[`${O}/sessions/${n}`],{detached:!0,stdio:"ignore"}).unref()})}}}});async function N(o){await I(o),B(null),m("list"),c("launched"),S()}return b(N,"handleSubmit"),a(l,{flexDirection:"column",borderStyle:"round",borderColor:T,width:_,paddingX:1,children:[a(l,{children:[t(s,{bold:!0,color:T,children:"Launcher"}),t(s,{dimColor:!0,children:" active org: "}),t(s,{children:F??"(none)"}),$&&t(s,{dimColor:!0,children:" loading\u2026"}),L&&a(s,{color:"#F55B5B",children:[" \u26A0 ",L]})]}),t(l,{marginTop:1,children:t(E,{jobs:u,selectedIndex:f,focused:d==="list"})}),t(l,{marginTop:1,children:t(J,{launchers:M,defaultProjectPath:x?.projectPath??y,defaultTool:x?.tool,defaultResumeSessionId:x?.resumeSessionId,focused:d==="form",onSubmit:N})}),h&&t(l,{marginTop:1,children:a(s,{color:"#FFD700",children:["Cancel job ",h.id.slice(0,8),"? (y/n)"]})}),p&&t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\xB7 ",p]})}),t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\u2191\u2193 select tab focus c cancel r resume o open esc ",d==="none"?"close":"back"]})})]})}b(K,"LauncherOverlay");export{K as a};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{c as v}from"./chunk-VUGRXM7R.js";import{a as y,b as R}from"./chunk-KKDHD4XA.js";import{a as i}from"./chunk-ZLLER3HP.js";import{spawn as M}from"node:child_process";import*as T from"node:fs";import*as h from"node:http";import*as m from"node:net";import*as E from"node:os";import*as w from"node:path";var O=8787,S=8788,b=3e3,N=500,I=6e4,B=w.join(E.homedir(),".config","rulemetric","proxy-addon.version"),P=w.join(E.homedir(),".config","rulemetric","proxy.pid"),u=!1;var $=null,H=0,A="unknown",f=null;function c(e){let t=new Date().toISOString();console.log(`[${t}] ${e}`)}i(c,"log");function D(){try{return T.readFileSync(B,"utf-8").trim()||null}catch{return null}}i(D,"readAddonVersion");function _(e,t){if(e==="unknown"||!t)return;let n=D();if(!n||n==="unknown"||n===$)return;if($=n,n===e){c(`addon version matches gateway (${e})`);return}let o=Date.now()-H;if(o<I){c(`addon version drift (gateway=${e}, addon=${n}); restart cooldown active (${Math.round((I-o)/1e3)}s left)`);return}c(`addon version drift detected (gateway=${e}, addon=${n}). Restarting proxy to pick up latest code.`),H=Date.now(),C(t)}i(_,"maybeRestartOnDrift");function C(e){if(!e)return c("cannot restart proxy: no CLI entry recorded (RULEMETRIC_CLI_ENTRY unset)"),!1;try{return M(process.execPath,[e,"proxy","restart"],{detached:!0,stdio:"ignore"}).unref(),!0}catch(t){return c(`restart spawn failed: ${t.message}`),!1}}i(C,"spawnProxyRestart");function Y(){try{let e=T.readFileSync(P,"utf-8").trim();return/^\d+$/.test(e)}catch{return!1}}i(Y,"proxyCrashEvidence");function L(e){let t=m.connect({port:e,timeout:N});t.on("connect",()=>{t.destroy(),u||(u=!0,c(`mitmproxy up on :${e}, routing through proxy`)),f?.onHealthCheck(!0)}),t.on("error",()=>{u&&(u=!1,c(`mitmproxy down on :${e}, routing direct`)),f?.onHealthCheck(!1)}),t.on("timeout",()=>{t.destroy(),u&&(u=!1,c(`mitmproxy timeout on :${e}, routing direct`)),f?.onHealthCheck(!1)})}i(L,"checkProxyHealth");function U(e,t,n,o){let[a,s]=(e.url??"").split(":"),d=parseInt(s,10)||443;if(u){let r=m.connect({port:o,host:"127.0.0.1"});r.on("connect",()=>{r.write(`CONNECT ${e.url} HTTP/1.1\r
|
|
2
|
+
Host: ${e.url}\r
|
|
3
|
+
\r
|
|
4
|
+
`)});let l=Buffer.alloc(0),p=i(g=>{l=Buffer.concat([l,g]),l.toString().includes(`\r
|
|
5
|
+
\r
|
|
6
|
+
`)&&(r.removeListener("data",p),t.write(`HTTP/1.1 200 Connection Established\r
|
|
7
|
+
\r
|
|
8
|
+
`),n.length>0&&r.write(n),t.pipe(r),r.pipe(t))},"onData");r.on("data",p),r.on("error",g=>{c(`proxy socket error for ${e.url}: ${g.message}, falling back to direct`),x(e,t,n,a,d)}),t.on("error",()=>{r.destroy()})}else x(e,t,n,a,d)}i(U,"handleConnect");function x(e,t,n,o,a){let s=m.connect({port:a,host:o});s.on("connect",()=>{t.write(`HTTP/1.1 200 Connection Established\r
|
|
9
|
+
\r
|
|
10
|
+
`),n.length>0&&s.write(n),t.pipe(s),s.pipe(t)}),s.on("error",d=>{c(`upstream error for ${e.url}: ${d.message}`),t.end(`HTTP/1.1 502 Bad Gateway\r
|
|
11
|
+
\r
|
|
12
|
+
`)}),t.on("error",()=>{s.destroy()})}i(x,"connectDirect");function V(e,t,n){if(e.url===y){t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify({service:R,version:A,pid:process.pid,mitmproxyAlive:u}));return}let o=e.url??"",a;try{a=new URL(o)}catch{t.writeHead(400),t.end("Bad Request");return}let s={hostname:u?"127.0.0.1":a.hostname,port:u?n:parseInt(a.port,10)||80,path:u?o:a.pathname+a.search,method:e.method,headers:e.headers},d=h.request(s,r=>{t.writeHead(r.statusCode??502,r.headers),r.pipe(t)});d.on("error",r=>{c(`HTTP proxy error for ${o}: ${r.message}`),t.writeHead(502),t.end("Bad Gateway")}),e.pipe(d)}i(V,"handleRequest");function j(e=O,t=S,n={}){let o=n.cliVersion??process.env.RULEMETRIC_CLI_VERSION??"unknown",a=n.cliEntry??process.env.RULEMETRIC_CLI_ENTRY??null;A=o,f=new v({hasCrashEvidence:Y,respawn:i(()=>C(a),"respawn"),log:c});let s=h.createServer((r,l)=>{V(r,l,t)});s.on("connect",(r,l,p)=>{U(r,l,p,t)}),s.on("clientError",(r,l)=>{l.writable&&l.end(`HTTP/1.1 400 Bad Request\r
|
|
13
|
+
\r
|
|
14
|
+
`)});let d=setInterval(()=>{L(t),_(o,a)},b);return L(t),_(o,a),s.listen(e,"127.0.0.1",()=>{c(`gateway listening on 127.0.0.1:${e} (mitmproxy target: :${t}, cli version: ${o})`)}),{server:s,healthInterval:d}}i(j,"startGateway");export{O as a,S as b,j as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as j,f as y}from"./chunk-RTWRHIKY.js";import{b as R}from"./chunk-ZL4MZMUK.js";import{a as S}from"./chunk-TDD7IOV2.js";import{a as p}from"./chunk-MODXEGCU.js";import{e as i,f as l}from"./chunk-H2ORWIEY.js";import{a as g}from"./chunk-ZLLER3HP.js";import{readFileSync as b}from"node:fs";import E from"node:path";import $ from"node:os";var N=5,L=Number(process.env.RULEMETRIC_MAX_SUGGESTION_PROJECTS??10),T=48,M=.5,k=400;async function O(){let d=E.join($.homedir(),".config","rulemetric","skills-registry.json");try{let o=b(d,"utf-8"),s=JSON.parse(o);return Date.now()-new Date(s.generatedAt).getTime()>T*60*60*1e3}catch{return!0}}g(O,"checkSkillsRegistryStale");var X=g(async(d,o)=>{let s=j();if(s==="none"){o.logger.warn("No LLM backend available (claude CLI missing and ANTHROPIC_API_KEY unset); skipping suggestion compute");return}o.logger.info(`Scoring backend: ${s}`);let r;try{r=(await i("/api/sessions/project-paths?limit="+L)).projectPaths}catch(e){o.logger.warn(`Failed to fetch project paths: ${e instanceof Error?e.message:String(e)}`);return}if(r.length===0){o.logger.info("No recent project paths; nothing to score");return}let m=new Map;try{let e=await i("/api/projects?limit=200");for(let t of e.projects??[])t.primaryCheckoutPath&&m.set(p(t.primaryCheckoutPath),t.id)}catch(e){o.logger.warn(`Failed to fetch projects for id resolution: ${e instanceof Error?e.message:String(e)}`)}let a=new Map;try{let e=await i("/api/catalog?limit=200");for(let t of e)a.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,k)})}catch(e){o.logger.warn(`Failed to fetch catalog: ${e instanceof Error?e.message:String(e)}`)}try{let e=await i("/api/instructions?limit=100");for(let t of e.instructions??[])a.has(t.id)||a.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,k)})}catch(e){o.logger.warn(`Failed to fetch personal instructions: ${e instanceof Error?e.message:String(e)}`)}let c=[...a.values()];if(c.length===0){o.logger.info("No candidate instructions; nothing to score");return}o.logger.info(`Scoring ${c.length} candidates across ${r.length} project(s)`);let u=0;for(let e of r)try{let t=p(e),f=S(t);if(f.length===0){o.logger.info(`Skipping ${t}: insufficient language signals`);continue}let C={name:E.basename(t),description:null,languages:f,topics:[],dependencies:[]},I=R(C,c),w=await y(I,"",4096);if(!w){o.logger.warn(`LLM returned null for ${t} (backend ${s})`);continue}let P=(w.recommendations??[]).filter(n=>typeof n.instructionId=="string"&&typeof n.score=="number"&&typeof n.reason=="string").map(n=>({instructionId:n.instructionId,score:n.score,reason:n.reason})).filter(n=>n.score>=M).sort((n,_)=>_.score-n.score).slice(0,N);if(P.length===0){o.logger.info(`No suggestions over threshold for ${t}`);continue}let h=m.get(t);await l("/api/instruction-suggestions/batch-upsert",{projectPath:t,...h?{projectId:h}:{},suggestions:P.map(n=>({instructionId:n.instructionId,score:n.score,reason:n.reason}))}),u++}catch(t){o.logger.warn(`Failed to score ${e}: ${t instanceof Error?t.message:String(t)}`)}if(await O())try{await l("/api/instruction-suggestions/mark-stale",{}),o.logger.warn("Skills registry is stale (>48h); marked all suggestions stale")}catch{}o.logger.info(`Done: scored ${u}/${r.length} projects`)},"cronSuggestInstructions");export{X as a};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import{a as p}from"./chunk-MGHFDHHM.js";import{a as c}from"./chunk-ZLLER3HP.js";var y=`You are an expert at improving AI coding instructions, skills, and prompts. You receive eval results showing how well the current content performs, and your job is to propose specific improvements.
|
|
2
|
+
|
|
3
|
+
You will receive:
|
|
4
|
+
1. The current content of the eval target
|
|
5
|
+
2. Eval results: for each eval, the prompt, expectations, pass/fail results, and grader feedback
|
|
6
|
+
3. The pass rate and areas of weakness
|
|
7
|
+
|
|
8
|
+
Analyze the failures and propose concrete edits to improve the content. Focus on:
|
|
9
|
+
- Expectations that consistently fail \u2014 what's missing from the content?
|
|
10
|
+
- Grader feedback suggesting new assertions \u2014 what outcomes aren't being tested?
|
|
11
|
+
- Patterns across failures \u2014 is there a systemic gap?
|
|
12
|
+
|
|
13
|
+
Your proposed content should be a complete replacement, not a diff. Keep what works, fix what doesn't.
|
|
14
|
+
|
|
15
|
+
You MUST respond with ONLY a valid JSON object:
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
"suggestions": [
|
|
19
|
+
{
|
|
20
|
+
"section": "which part of the content",
|
|
21
|
+
"current": "brief quote of current text",
|
|
22
|
+
"proposed": "what it should say instead",
|
|
23
|
+
"reasoning": "why this change helps"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"overallAssessment": "brief summary of what's working and what's not",
|
|
27
|
+
"proposedContent": "the full improved content"
|
|
28
|
+
}`;async function w(l){let{content:o,evalResults:u,model:d,timeout:m=12e4,userFeedback:i}=l,g=u.map(e=>{let t=e.grading,n=t?.expectations??[],r=t?.summary?.pass_rate??"N/A",v=t?.eval_feedback?.overall??"";return`## Eval: ${e.evalName}
|
|
29
|
+
Prompt: ${e.prompt}
|
|
30
|
+
Pass rate: ${typeof r=="number"?(r*100).toFixed(0)+"%":r}
|
|
31
|
+
|
|
32
|
+
Expectations:
|
|
33
|
+
${n.map(a=>` ${a.passed?"PASS":"FAIL"} \u2014 ${a.text}: ${a.evidence}`).join(`
|
|
34
|
+
`)}
|
|
35
|
+
|
|
36
|
+
Feedback: ${v}`}).join(`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
`),h=i?`
|
|
41
|
+
|
|
42
|
+
## User Feedback
|
|
43
|
+
|
|
44
|
+
${i}`:`
|
|
45
|
+
|
|
46
|
+
## User Feedback
|
|
47
|
+
|
|
48
|
+
No specific feedback provided.`,f=`## Current Content
|
|
49
|
+
|
|
50
|
+
${o}
|
|
51
|
+
|
|
52
|
+
## Eval Results
|
|
53
|
+
|
|
54
|
+
${g}${h}
|
|
55
|
+
|
|
56
|
+
Analyze the results and propose improvements. Respond with ONLY valid JSON.`,s=await p({prompt:f,targetContent:y,timeout:m,model:d});if(s.error)return{suggestions:[],overallAssessment:`Analysis failed: ${s.error}`,proposedContent:o};try{let e=s.output.trim(),t=e.match(/```(?:json)?\s*([\s\S]*?)```/);t&&(e=t[1].trim());let n=e.match(/\{[\s\S]*\}/);return n&&(e=n[0]),JSON.parse(e)}catch{return{suggestions:[],overallAssessment:`Analysis returned unparseable output: ${s.output.slice(0,200)}`,proposedContent:o}}}c(w,"analyzeEvalResults");export{w as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c,b as p,c as x,f as u}from"./chunk-ARNZQBMX.js";import{d as l,h as m}from"./chunk-NJ5UED3H.js";import{a as f}from"./chunk-ZLLER3HP.js";import{Text as r}from"ink";import{jsx as t,jsxs as P}from"react/jsx-runtime";function S({api:s,width:n,barWidth:d}){if(!s)return t(c,{title:"Friction Points",color:m,width:n,children:t(r,{dimColor:!0,children:"API offline \u2014 no friction data"})});let h=s.friction??{},e=Object.entries(h).sort(([,i],[,o])=>o-i);if(e.length===0)return t(c,{title:"Friction Points",color:l,width:n,children:t(r,{dimColor:!0,children:"No friction detected \u2014 nice!"})});let T=e[0][1],a=e.reduce((i,[,o])=>i+o,0),g=Math.max(8,n-d-20);return t(c,{title:`Friction Points (${a} incidents)`,color:m,width:n,children:e.map(([i,o])=>{let b=a>0?Math.round(o/a*100):0;return P(r,{wrap:"truncate-end",children:[t(p,{value:o,max:T,width:d}),P(r,{color:l,children:[" ",x(u(i),g)]}),t(r,{children:String(o).padStart(5)}),t(r,{dimColor:!0,children:(b+"%").padStart(5)})]},i)})})}f(S,"FrictionPanel");export{S as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as R,f as _}from"./chunk-H2ORWIEY.js";import{a as f}from"./chunk-ZLLER3HP.js";function p(a){if(a.length===0)return{mean:0,stddev:0,min:0,max:0};let i=a.reduce((o,c)=>o+c,0)/a.length,m=a.reduce((o,c)=>o+(c-i)**2,0)/a.length;return{mean:Math.round(i*1e3)/1e3,stddev:Math.round(Math.sqrt(m)*1e3)/1e3,min:Math.min(...a),max:Math.max(...a)}}f(p,"computeStats");async function y(a,i){let m=i?`&iteration=${i}`:"",o=100,c=[];for(let t=0;t<1e5;t+=o){let n=await R(`/api/eval-targets/${a}/runs?limit=${o}&offset=${t}${m}`);if(c.push(...n),n.length<o)break}let l=c.filter(t=>t.status==="completed");if(l.length===0)return{runSummary:{},notes:["No completed runs found"],totalRuns:0};let g={};for(let t of l)g[t.configuration]||(g[t.configuration]=[]),g[t.configuration].push(t);let e={},u=[];for(let[t,n]of Object.entries(g)){let r=n.filter(s=>Object.keys(s.grading).length>0).map(s=>s.grading.summary?.pass_rate??0),d=n.map(s=>s.timing.duration_ms/1e3).filter(s=>!isNaN(s)),h=n.map(s=>s.timing.total_tokens??0).filter(s=>s>0);e[t]={},r.length>0&&(e[t].pass_rate=p(r)),d.length>0&&(e[t].time_seconds=p(d)),h.length>0&&(e[t].tokens=p(h))}if(e.with_target&&e.without_target){let t={};for(let d of["pass_rate","time_seconds","tokens"]){let h=e.with_target[d]?.mean??0,s=e.without_target[d]?.mean??0,b=h-s;t[d]=`${b>=0?"+":""}${Math.round(b*1e3)/1e3}`}e.delta=t,u.push(`Delta is a raw mean difference over ${g.with_target.length} with-target / ${g.without_target.length} without-target runs \u2014 no significance test; small samples are not statistically meaningful.`);let n=(e.with_target.pass_rate?.mean??0)-(e.without_target.pass_rate?.mean??0);n>.1?u.push(`Target improves pass rate by ${(n*100).toFixed(0)}%`):n<-.1?u.push(`Target decreases pass rate by ${(Math.abs(n)*100).toFixed(0)}%`):u.push("Target has minimal impact on pass rate");let r=(e.with_target.time_seconds?.mean??0)-(e.without_target.time_seconds?.mean??0);Math.abs(r)>5&&u.push(`Target ${r>0?"adds":"saves"} ${Math.abs(r).toFixed(1)}s average execution time`)}for(let[t,n]of Object.entries(e)){if(t==="delta")continue;let r=n.pass_rate;r&&r.stddev>.2&&u.push(`${t} shows high pass rate variance (stddev=${r.stddev.toFixed(2)}) \u2014 results may be unreliable`)}return{runSummary:e,notes:u,totalRuns:l.length}}f(y,"aggregateBenchmark");async function $(a,i,m){return _(`/api/eval-targets/${a}/benchmarks`,{iteration:i,runSummary:m.runSummary,notes:m.notes})}f($,"postBenchmark");export{y as a,$ as b};
|