@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/oclif.manifest.json
CHANGED
|
@@ -493,7 +493,7 @@
|
|
|
493
493
|
"description": "Create a long-lived API key for CLI and proxy authentication",
|
|
494
494
|
"examples": [
|
|
495
495
|
"<%= config.bin %> auth create-key --name \"laptop\"",
|
|
496
|
-
"<%= config.bin %> auth create-key --name \"
|
|
496
|
+
"<%= config.bin %> auth create-key --name \"ci token\" --no-save"
|
|
497
497
|
],
|
|
498
498
|
"flags": {
|
|
499
499
|
"api-url": {
|
|
@@ -518,7 +518,7 @@
|
|
|
518
518
|
"char": "s",
|
|
519
519
|
"description": "Save key to ~/.config/rulemetric/env for hooks/proxy",
|
|
520
520
|
"name": "save",
|
|
521
|
-
"allowNo":
|
|
521
|
+
"allowNo": true,
|
|
522
522
|
"type": "boolean"
|
|
523
523
|
}
|
|
524
524
|
},
|
|
@@ -627,14 +627,15 @@
|
|
|
627
627
|
"aliases": [],
|
|
628
628
|
"args": {
|
|
629
629
|
"id": {
|
|
630
|
-
"description": "API key ID
|
|
631
|
-
"name": "id"
|
|
632
|
-
"required": true
|
|
630
|
+
"description": "API key ID, prefix (rm_xxxxxxxx), or name",
|
|
631
|
+
"name": "id"
|
|
633
632
|
}
|
|
634
633
|
},
|
|
635
|
-
"description": "Revoke an API key",
|
|
634
|
+
"description": "Revoke an API key (run with no argument to list active keys)",
|
|
636
635
|
"examples": [
|
|
637
|
-
"<%= config.bin %> auth revoke-key
|
|
636
|
+
"<%= config.bin %> auth revoke-key",
|
|
637
|
+
"<%= config.bin %> auth revoke-key rm_abc12345",
|
|
638
|
+
"<%= config.bin %> auth revoke-key \"my-laptop (auto)\""
|
|
638
639
|
],
|
|
639
640
|
"flags": {
|
|
640
641
|
"api-url": {
|
|
@@ -1243,13 +1244,6 @@
|
|
|
1243
1244
|
"multiple": false,
|
|
1244
1245
|
"type": "option"
|
|
1245
1246
|
},
|
|
1246
|
-
"expected-output": {
|
|
1247
|
-
"description": "Expected output description",
|
|
1248
|
-
"name": "expected-output",
|
|
1249
|
-
"hasDynamicHelp": false,
|
|
1250
|
-
"multiple": false,
|
|
1251
|
-
"type": "option"
|
|
1252
|
-
},
|
|
1253
1247
|
"expectations": {
|
|
1254
1248
|
"char": "e",
|
|
1255
1249
|
"description": "Assertion (repeatable)",
|
|
@@ -1430,22 +1424,6 @@
|
|
|
1430
1424
|
"multiple": false,
|
|
1431
1425
|
"type": "option"
|
|
1432
1426
|
},
|
|
1433
|
-
"runs-per-eval": {
|
|
1434
|
-
"description": "Runs per eval per iteration",
|
|
1435
|
-
"name": "runs-per-eval",
|
|
1436
|
-
"default": 1,
|
|
1437
|
-
"hasDynamicHelp": false,
|
|
1438
|
-
"multiple": false,
|
|
1439
|
-
"type": "option"
|
|
1440
|
-
},
|
|
1441
|
-
"parallel": {
|
|
1442
|
-
"description": "Number of parallel eval executions",
|
|
1443
|
-
"name": "parallel",
|
|
1444
|
-
"default": 1,
|
|
1445
|
-
"hasDynamicHelp": false,
|
|
1446
|
-
"multiple": false,
|
|
1447
|
-
"type": "option"
|
|
1448
|
-
},
|
|
1449
1427
|
"timeout": {
|
|
1450
1428
|
"description": "Timeout per eval in ms",
|
|
1451
1429
|
"name": "timeout",
|
|
@@ -1784,8 +1762,8 @@
|
|
|
1784
1762
|
},
|
|
1785
1763
|
"description": "Create a new instruction",
|
|
1786
1764
|
"examples": [
|
|
1787
|
-
"<%= config.bin %> instructions create ./my-instruction.md --name \"My Rules\"",
|
|
1788
|
-
"<%= config.bin %> instructions create ./rules.md -n \"Rules\" -s project"
|
|
1765
|
+
"<%= config.bin %> instructions create ./my-instruction.md --name \"My Rules\" --description \"Team coding rules\"",
|
|
1766
|
+
"<%= config.bin %> instructions create ./rules.md -n \"Rules\" -d \"Project rules\" -s project"
|
|
1789
1767
|
],
|
|
1790
1768
|
"flags": {
|
|
1791
1769
|
"api-url": {
|
|
@@ -3259,7 +3237,7 @@
|
|
|
3259
3237
|
"service:status": {
|
|
3260
3238
|
"aliases": [],
|
|
3261
3239
|
"args": {},
|
|
3262
|
-
"description": "Check the status of
|
|
3240
|
+
"description": "Check the status of installed RuleMetric services (launchd on macOS; systemd --user worker on Linux)",
|
|
3263
3241
|
"flags": {
|
|
3264
3242
|
"api-url": {
|
|
3265
3243
|
"description": "Override API base URL",
|
|
@@ -4099,5 +4077,5 @@
|
|
|
4099
4077
|
]
|
|
4100
4078
|
}
|
|
4101
4079
|
},
|
|
4102
|
-
"version": "0.7.
|
|
4080
|
+
"version": "0.7.5"
|
|
4103
4081
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulemetric/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"bin",
|
|
16
16
|
"dist",
|
|
17
|
-
"oclif.manifest.json"
|
|
17
|
+
"oclif.manifest.json",
|
|
18
|
+
"!dist/**/*.map"
|
|
18
19
|
],
|
|
19
20
|
"oclif": {
|
|
20
21
|
"commands": "./dist/commands",
|
|
@@ -73,9 +74,9 @@
|
|
|
73
74
|
"postgres": "^3.4.0",
|
|
74
75
|
"react": "^19.0.0",
|
|
75
76
|
"zod": "^3.24.0",
|
|
76
|
-
"@rulemetric/
|
|
77
|
-
"@rulemetric/
|
|
78
|
-
"@rulemetric/
|
|
77
|
+
"@rulemetric/proxy": "0.7.5",
|
|
78
|
+
"@rulemetric/skills-registry": "0.7.5",
|
|
79
|
+
"@rulemetric/hooks": "0.7.5"
|
|
79
80
|
},
|
|
80
81
|
"//deps": "Worker (`evals agent`) runtime deps: the @opentelemetry/* set, @sentry/node, and postgres are STATIC top-level imports loaded at worker startup (via bundled @rulemetric/{telemetry,db}) — they MUST be runtime deps or a clean `npm i -g` crashes with ModuleLoadError. `better-sqlite3` is optionalDependencies (below): it's a native module, lazy `require()`'d inside a try/catch (packages/session providers cursor/opencode) so a missing binary degrades gracefully — making it a hard dep would break `npm i -g` on platforms without prebuilt binaries. `resend` stays a devDep: lazy `await import('resend')` guarded by RESEND_API_KEY, which end-user workers never set (provider falls back to noop). Classification verified via import-graph scan of dist/commands/evals/agent.js + per-importer static/lazy check.",
|
|
81
82
|
"optionalDependencies": {
|
|
@@ -95,11 +96,11 @@
|
|
|
95
96
|
"vitest": "^3.2.0",
|
|
96
97
|
"@rulemetric/api": "0.0.1",
|
|
97
98
|
"@rulemetric/core": "0.0.1",
|
|
98
|
-
"@rulemetric/
|
|
99
|
+
"@rulemetric/db": "0.0.1",
|
|
99
100
|
"@rulemetric/email": "0.0.1",
|
|
100
|
-
"@rulemetric/
|
|
101
|
+
"@rulemetric/session": "0.2.1",
|
|
101
102
|
"@rulemetric/typescript-config": "0.0.0",
|
|
102
|
-
"@rulemetric/
|
|
103
|
+
"@rulemetric/telemetry": "0.0.1"
|
|
103
104
|
},
|
|
104
105
|
"scripts": {
|
|
105
106
|
"build": "node scripts/build.mjs",
|
package/dist/base-command.js.map
DELETED
package/dist/chunk-2HK7RGZB.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getUpgradeBanner,
|
|
3
|
-
refreshVersionCacheInBackground
|
|
4
|
-
} from "./chunk-R56PH7YE.js";
|
|
5
|
-
import {
|
|
6
|
-
emitErrorBeacon
|
|
7
|
-
} from "./chunk-GQNJO2P2.js";
|
|
8
|
-
import {
|
|
9
|
-
maybeRefreshActiveOrg
|
|
10
|
-
} from "./chunk-37LN5O7M.js";
|
|
11
|
-
import {
|
|
12
|
-
ApiError
|
|
13
|
-
} from "./chunk-ZUJBM6HE.js";
|
|
14
|
-
import {
|
|
15
|
-
isAuthenticated
|
|
16
|
-
} from "./chunk-W2YERO7E.js";
|
|
17
|
-
|
|
18
|
-
// src/base-command.ts
|
|
19
|
-
import { Command, Flags } from "@oclif/core";
|
|
20
|
-
function isAvailabilityError(err) {
|
|
21
|
-
if (err instanceof ApiError) {
|
|
22
|
-
return err.statusCode >= 500 || err.statusCode === 408 || err.statusCode === 0;
|
|
23
|
-
}
|
|
24
|
-
return /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|bad gateway|timed out/i.test(
|
|
25
|
-
err.message ?? ""
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
var BaseCommand = class extends Command {
|
|
29
|
-
static baseFlags = {
|
|
30
|
-
"api-url": Flags.string({
|
|
31
|
-
description: "Override API base URL",
|
|
32
|
-
env: "RULEMETRIC_API_URL",
|
|
33
|
-
hidden: true
|
|
34
|
-
})
|
|
35
|
-
};
|
|
36
|
-
async init() {
|
|
37
|
-
await super.init();
|
|
38
|
-
const { flags } = await this.parse(this.constructor);
|
|
39
|
-
if (flags["api-url"]) {
|
|
40
|
-
process.env.RULEMETRIC_API_URL = flags["api-url"];
|
|
41
|
-
}
|
|
42
|
-
const banner = getUpgradeBanner(this.config.version);
|
|
43
|
-
if (banner && !this.argv.includes("--quiet") && !process.env.RULEMETRIC_QUIET) {
|
|
44
|
-
process.stderr.write(`
|
|
45
|
-
${banner}
|
|
46
|
-
|
|
47
|
-
`);
|
|
48
|
-
}
|
|
49
|
-
refreshVersionCacheInBackground();
|
|
50
|
-
}
|
|
51
|
-
requireAuth() {
|
|
52
|
-
if (!isAuthenticated()) {
|
|
53
|
-
this.error("Not logged in. Run `rulemetric auth login` to authenticate.");
|
|
54
|
-
}
|
|
55
|
-
void maybeRefreshActiveOrg();
|
|
56
|
-
}
|
|
57
|
-
async catch(err) {
|
|
58
|
-
if (isAvailabilityError(err)) {
|
|
59
|
-
await emitErrorBeacon({
|
|
60
|
-
command: this.id,
|
|
61
|
-
statusCode: err instanceof ApiError ? err.statusCode : void 0,
|
|
62
|
-
message: err.message,
|
|
63
|
-
cliVersion: this.config.version
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if (err instanceof ApiError) {
|
|
67
|
-
if (err.statusCode === 401) {
|
|
68
|
-
this.error("Session expired. Run `rulemetric auth login` to re-authenticate.");
|
|
69
|
-
}
|
|
70
|
-
this.error(err.message);
|
|
71
|
-
}
|
|
72
|
-
if (err.message?.includes("fetch failed") || err.message?.includes("ECONNREFUSED")) {
|
|
73
|
-
this.error("Could not connect to the API server. Is it running?");
|
|
74
|
-
}
|
|
75
|
-
throw err;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export {
|
|
80
|
-
BaseCommand
|
|
81
|
-
};
|
|
82
|
-
//# sourceMappingURL=chunk-2HK7RGZB.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/base-command.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command, Flags } from '@oclif/core';\nimport { isAuthenticated } from './lib/auth.js';\nimport { ApiError } from './lib/api-client.js';\nimport { maybeRefreshActiveOrg } from './lib/active-org-refresh.js';\nimport { getUpgradeBanner, refreshVersionCacheInBackground } from './lib/version-check.js';\nimport { emitErrorBeacon } from './lib/telemetry.js';\n\n/**\n * Is this error an API AVAILABILITY failure (server/edge/proxy unreachable), as\n * opposed to a normal 4xx business error (401/404/409)? These are the failures\n * the unauthenticated error beacon exists to surface \u2014 a 502 from a broken local\n * gateway, a 5xx from the edge, a client timeout (408, added in api-client), or\n * a raw connection failure \u2014 precisely the class that authenticated telemetry\n * can never report because it happens before/instead of auth.\n */\nfunction isAvailabilityError(err: Error): boolean {\n if (err instanceof ApiError) {\n return err.statusCode >= 500 || err.statusCode === 408 || err.statusCode === 0;\n }\n return /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|bad gateway|timed out/i.test(\n err.message ?? '',\n );\n}\n\nexport abstract class BaseCommand extends Command {\n static override baseFlags = {\n 'api-url': Flags.string({\n description: 'Override API base URL',\n env: 'RULEMETRIC_API_URL',\n hidden: true,\n }),\n };\n\n protected override async init(): Promise<void> {\n await super.init();\n const { flags } = await this.parse(this.constructor as typeof BaseCommand);\n if (flags['api-url']) {\n process.env.RULEMETRIC_API_URL = flags['api-url'];\n }\n // Print the upgrade banner from the cache (populated by the previous\n // command). To stderr so it doesn't pollute scriptable stdout. Then\n // kick off a background refresh for the *next* invocation. Suppressed\n // on commands meant to be machine-readable (`hooks run`, etc.) since\n // a banner there would corrupt JSON output piped to other tools.\n const banner = getUpgradeBanner(this.config.version);\n if (banner && !this.argv.includes('--quiet') && !process.env.RULEMETRIC_QUIET) {\n process.stderr.write(`\\n${banner}\\n\\n`);\n }\n refreshVersionCacheInBackground();\n }\n\n protected requireAuth(): void {\n if (!isAuthenticated()) {\n this.error('Not logged in. Run `rulemetric auth login` to authenticate.');\n }\n // Fire-and-forget refresh of the local active-org cache. Doesn't block\n // the command \u2014 its only side effect is rewriting the cache file.\n void maybeRefreshActiveOrg();\n }\n\n protected override async catch(err: Error & { exitCode?: number }): Promise<void> {\n // Surface availability failures (5xx / 502 / timeout / connection refused) to\n // the unauthenticated, proxy-bypassing error beacon FIRST \u2014 this is the only\n // path that makes a pre-auth / broken-gateway onboarding failure visible\n // server-side. Best-effort + bounded internally; awaited so it lands before\n // this.error() exits the process.\n if (isAvailabilityError(err)) {\n await emitErrorBeacon({\n command: this.id,\n statusCode: err instanceof ApiError ? err.statusCode : undefined,\n message: err.message,\n cliVersion: this.config.version,\n });\n }\n\n if (err instanceof ApiError) {\n if (err.statusCode === 401) {\n this.error('Session expired. Run `rulemetric auth login` to re-authenticate.');\n }\n\n this.error(err.message);\n }\n\n if (err.message?.includes('fetch failed') || err.message?.includes('ECONNREFUSED')) {\n this.error('Could not connect to the API server. Is it running?');\n }\n\n throw err;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,aAAa;AAe/B,SAAS,oBAAoB,KAAqB;AAChD,MAAI,eAAe,UAAU;AAC3B,WAAO,IAAI,cAAc,OAAO,IAAI,eAAe,OAAO,IAAI,eAAe;AAAA,EAC/E;AACA,SAAO,kFAAkF;AAAA,IACvF,IAAI,WAAW;AAAA,EACjB;AACF;AAEO,IAAe,cAAf,cAAmC,QAAQ;AAAA,EAChD,OAAgB,YAAY;AAAA,IAC1B,WAAW,MAAM,OAAO;AAAA,MACtB,aAAa;AAAA,MACb,KAAK;AAAA,MACL,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAAA,EAEA,MAAyB,OAAsB;AAC7C,UAAM,MAAM,KAAK;AACjB,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,MAAM,KAAK,WAAiC;AACzE,QAAI,MAAM,SAAS,GAAG;AACpB,cAAQ,IAAI,qBAAqB,MAAM,SAAS;AAAA,IAClD;AAMA,UAAM,SAAS,iBAAiB,KAAK,OAAO,OAAO;AACnD,QAAI,UAAU,CAAC,KAAK,KAAK,SAAS,SAAS,KAAK,CAAC,QAAQ,IAAI,kBAAkB;AAC7E,cAAQ,OAAO,MAAM;AAAA,EAAK,MAAM;AAAA;AAAA,CAAM;AAAA,IACxC;AACA,oCAAgC;AAAA,EAClC;AAAA,EAEU,cAAoB;AAC5B,QAAI,CAAC,gBAAgB,GAAG;AACtB,WAAK,MAAM,6DAA6D;AAAA,IAC1E;AAGA,SAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,MAAyB,MAAM,KAAmD;AAMhF,QAAI,oBAAoB,GAAG,GAAG;AAC5B,YAAM,gBAAgB;AAAA,QACpB,SAAS,KAAK;AAAA,QACd,YAAY,eAAe,WAAW,IAAI,aAAa;AAAA,QACvD,SAAS,IAAI;AAAA,QACb,YAAY,KAAK,OAAO;AAAA,MAC1B,CAAC;AAAA,IACH;AAEA,QAAI,eAAe,UAAU;AAC3B,UAAI,IAAI,eAAe,KAAK;AAC1B,aAAK,MAAM,kEAAkE;AAAA,MAC/E;AAEA,WAAK,MAAM,IAAI,OAAO;AAAA,IACxB;AAEA,QAAI,IAAI,SAAS,SAAS,cAAc,KAAK,IAAI,SAAS,SAAS,cAAc,GAAG;AAClF,WAAK,MAAM,qDAAqD;AAAA,IAClE;AAEA,UAAM;AAAA,EACR;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/chunk-2ORJWTNZ.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ApiError,
|
|
3
|
-
api
|
|
4
|
-
} from "./chunk-ZUJBM6HE.js";
|
|
5
|
-
|
|
6
|
-
// src/lib/antigravity-transcript.ts
|
|
7
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, rmdirSync, writeFileSync } from "node:fs";
|
|
8
|
-
import { homedir, tmpdir } from "node:os";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
var MAX_RECORDS_PER_FIRE = 100;
|
|
11
|
-
var TOOL_CALL_TYPES = /* @__PURE__ */ new Set([
|
|
12
|
-
"RUN_COMMAND",
|
|
13
|
-
"VIEW_FILE",
|
|
14
|
-
"LIST_DIRECTORY",
|
|
15
|
-
"CODE_ACTION",
|
|
16
|
-
"GREP_SEARCH",
|
|
17
|
-
"SEARCH_WEB"
|
|
18
|
-
]);
|
|
19
|
-
var SKIP_TYPES = /* @__PURE__ */ new Set([
|
|
20
|
-
"CONVERSATION_HISTORY",
|
|
21
|
-
"KNOWLEDGE_ARTIFACTS",
|
|
22
|
-
"CHECKPOINT"
|
|
23
|
-
]);
|
|
24
|
-
function configDir() {
|
|
25
|
-
return process.env.RULEMETRIC_CONFIG_DIR ?? join(homedir(), ".config", "rulemetric");
|
|
26
|
-
}
|
|
27
|
-
function stateDir() {
|
|
28
|
-
return join(configDir(), "antigravity-state");
|
|
29
|
-
}
|
|
30
|
-
function stateFile(conversationId) {
|
|
31
|
-
return join(stateDir(), `${conversationId}.json`);
|
|
32
|
-
}
|
|
33
|
-
function loadEnvFile() {
|
|
34
|
-
const envPath = join(configDir(), "env");
|
|
35
|
-
if (!existsSync(envPath)) return;
|
|
36
|
-
try {
|
|
37
|
-
const text = readFileSync(envPath, "utf-8");
|
|
38
|
-
for (const line of text.split(/\r?\n/)) {
|
|
39
|
-
const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
40
|
-
if (!m) continue;
|
|
41
|
-
const key = m[1];
|
|
42
|
-
if (process.env[key] !== void 0) continue;
|
|
43
|
-
let value = m[2];
|
|
44
|
-
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
45
|
-
value = value.slice(1, -1);
|
|
46
|
-
}
|
|
47
|
-
process.env[key] = value;
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function loadState(conversationId) {
|
|
53
|
-
try {
|
|
54
|
-
const text = readFileSync(stateFile(conversationId), "utf-8");
|
|
55
|
-
const parsed = JSON.parse(text);
|
|
56
|
-
if (parsed && typeof parsed === "object" && "lastStepIdx" in parsed) {
|
|
57
|
-
const v = parsed.lastStepIdx;
|
|
58
|
-
if (typeof v === "number" && Number.isFinite(v)) {
|
|
59
|
-
return { lastStepIdx: v };
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} catch {
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
function saveState(conversationId, state) {
|
|
67
|
-
mkdirSync(stateDir(), { recursive: true });
|
|
68
|
-
const target = stateFile(conversationId);
|
|
69
|
-
const tmpPath = `${target}.tmp`;
|
|
70
|
-
writeFileSync(tmpPath, JSON.stringify(state), { mode: 384 });
|
|
71
|
-
try {
|
|
72
|
-
renameSync(tmpPath, target);
|
|
73
|
-
} catch {
|
|
74
|
-
writeFileSync(target, JSON.stringify(state), { mode: 384 });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function resolveRwSessionId(externalSessionId) {
|
|
78
|
-
const tempDir = process.env.TMPDIR ?? tmpdir();
|
|
79
|
-
const rulemetricTempDir = join(tempDir, "rulemetric");
|
|
80
|
-
const path = join(rulemetricTempDir, externalSessionId);
|
|
81
|
-
try {
|
|
82
|
-
const id = readFileSync(path, "utf-8").trim();
|
|
83
|
-
return id || null;
|
|
84
|
-
} catch {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function nextSequence(externalSessionId) {
|
|
89
|
-
const tempDir = process.env.TMPDIR ?? tmpdir();
|
|
90
|
-
const rulemetricTempDir = join(tempDir, "rulemetric");
|
|
91
|
-
const seqPath = join(rulemetricTempDir, `${externalSessionId}.seq`);
|
|
92
|
-
const lockDir = join(rulemetricTempDir, `${externalSessionId}.seqlock`);
|
|
93
|
-
const deadline = Date.now() + 5e3;
|
|
94
|
-
while (Date.now() < deadline) {
|
|
95
|
-
try {
|
|
96
|
-
mkdirSync(lockDir);
|
|
97
|
-
break;
|
|
98
|
-
} catch {
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
let seq = 1;
|
|
102
|
-
try {
|
|
103
|
-
seq = parseInt(readFileSync(seqPath, "utf-8").trim(), 10) + 1;
|
|
104
|
-
if (!Number.isFinite(seq) || seq < 1) seq = 1;
|
|
105
|
-
} catch {
|
|
106
|
-
seq = 1;
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
writeFileSync(seqPath, String(seq));
|
|
110
|
-
} catch {
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
rmdirSync(lockDir);
|
|
114
|
-
} catch {
|
|
115
|
-
}
|
|
116
|
-
return seq;
|
|
117
|
-
}
|
|
118
|
-
function readNewRecords(transcriptPath, afterStepIdx) {
|
|
119
|
-
let text;
|
|
120
|
-
try {
|
|
121
|
-
text = readFileSync(transcriptPath, "utf-8");
|
|
122
|
-
} catch {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
const out = [];
|
|
126
|
-
for (const line of text.split(/\r?\n/)) {
|
|
127
|
-
if (!line.trim()) continue;
|
|
128
|
-
try {
|
|
129
|
-
const r = JSON.parse(line);
|
|
130
|
-
if (typeof r.step_index === "number" && r.step_index > afterStepIdx) {
|
|
131
|
-
out.push(r);
|
|
132
|
-
}
|
|
133
|
-
} catch {
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
out.sort((a, b) => a.step_index - b.step_index);
|
|
137
|
-
return out;
|
|
138
|
-
}
|
|
139
|
-
function findMaxStepIndex(transcriptPath) {
|
|
140
|
-
let text;
|
|
141
|
-
try {
|
|
142
|
-
text = readFileSync(transcriptPath, "utf-8");
|
|
143
|
-
} catch {
|
|
144
|
-
return -1;
|
|
145
|
-
}
|
|
146
|
-
let max = -1;
|
|
147
|
-
for (const line of text.split(/\r?\n/)) {
|
|
148
|
-
if (!line.trim()) continue;
|
|
149
|
-
try {
|
|
150
|
-
const r = JSON.parse(line);
|
|
151
|
-
if (typeof r.step_index === "number" && r.step_index > max) max = r.step_index;
|
|
152
|
-
} catch {
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return max;
|
|
156
|
-
}
|
|
157
|
-
function extractUserPrompt(raw) {
|
|
158
|
-
const m = raw.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
159
|
-
return m ? m[1].trim() : raw.trim();
|
|
160
|
-
}
|
|
161
|
-
function classifyRecord(record, sequence) {
|
|
162
|
-
const timestamp = record.created_at ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
163
|
-
const metadata = {
|
|
164
|
-
antigravityStepIndex: record.step_index,
|
|
165
|
-
antigravitySource: record.source,
|
|
166
|
-
antigravityType: record.type
|
|
167
|
-
};
|
|
168
|
-
if (SKIP_TYPES.has(record.type)) return null;
|
|
169
|
-
if (TOOL_CALL_TYPES.has(record.type)) return null;
|
|
170
|
-
if (record.source === "USER_EXPLICIT" && record.type === "USER_INPUT") {
|
|
171
|
-
return {
|
|
172
|
-
sequence,
|
|
173
|
-
// The events API accepts `user_message` (Claude Code's convention) but
|
|
174
|
-
// rejects `user_prompt`. Stay aligned with the existing vocabulary so
|
|
175
|
-
// the same downstream readers (insights, dashboard) light up for
|
|
176
|
-
// Antigravity sessions without API changes.
|
|
177
|
-
eventType: "user_message",
|
|
178
|
-
content: extractUserPrompt(record.content ?? ""),
|
|
179
|
-
timestamp,
|
|
180
|
-
metadata
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
if (record.source === "MODEL" && record.type === "PLANNER_RESPONSE") {
|
|
184
|
-
const parts = [];
|
|
185
|
-
if (record.thinking && record.thinking.trim()) {
|
|
186
|
-
parts.push(`[thinking]
|
|
187
|
-
${record.thinking.trim()}`);
|
|
188
|
-
}
|
|
189
|
-
if (record.content && record.content.trim()) {
|
|
190
|
-
parts.push(record.content.trim());
|
|
191
|
-
}
|
|
192
|
-
if (record.tool_calls && record.tool_calls.length > 0) {
|
|
193
|
-
metadata.antigravityToolCalls = record.tool_calls.map((tc) => tc.name).filter(Boolean);
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
sequence,
|
|
197
|
-
eventType: "assistant_response",
|
|
198
|
-
content: parts.join("\n\n") || null,
|
|
199
|
-
timestamp,
|
|
200
|
-
metadata
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
if (record.source === "MODEL" && record.type === "GENERIC") {
|
|
204
|
-
return {
|
|
205
|
-
sequence,
|
|
206
|
-
eventType: "tool_result",
|
|
207
|
-
content: record.content ?? null,
|
|
208
|
-
timestamp,
|
|
209
|
-
metadata
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
if (record.source === "SYSTEM" && (record.type === "SYSTEM_MESSAGE" || record.type === "ERROR_MESSAGE")) {
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
sequence,
|
|
217
|
-
eventType: `antigravity_${record.type.toLowerCase()}`,
|
|
218
|
-
content: record.content ?? null,
|
|
219
|
-
timestamp,
|
|
220
|
-
metadata
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
function parseHookPayload(stdin) {
|
|
224
|
-
try {
|
|
225
|
-
const parsed = JSON.parse(stdin);
|
|
226
|
-
return parsed && typeof parsed === "object" ? parsed : null;
|
|
227
|
-
} catch {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
async function emitRecordsAsEvents(records, rwSessionId, conversationId, initialHighestStepIdx, options = {}) {
|
|
232
|
-
const sink = options.errorSink ?? ((line) => process.stderr.write(line));
|
|
233
|
-
let attempted = 0;
|
|
234
|
-
let emitted = 0;
|
|
235
|
-
let failed = 0;
|
|
236
|
-
let skipped = 0;
|
|
237
|
-
let highest = initialHighestStepIdx;
|
|
238
|
-
for (const record of records) {
|
|
239
|
-
attempted++;
|
|
240
|
-
options.onProgress?.({ attempted, total: records.length, record });
|
|
241
|
-
const sequence = nextSequence(conversationId);
|
|
242
|
-
const event = classifyRecord(record, sequence);
|
|
243
|
-
if (!event) {
|
|
244
|
-
skipped++;
|
|
245
|
-
} else {
|
|
246
|
-
try {
|
|
247
|
-
await api(`/api/sessions/${rwSessionId}/events`, {
|
|
248
|
-
method: "POST",
|
|
249
|
-
body: event
|
|
250
|
-
});
|
|
251
|
-
emitted++;
|
|
252
|
-
} catch (err) {
|
|
253
|
-
failed++;
|
|
254
|
-
const code = err instanceof ApiError ? err.statusCode : "unknown";
|
|
255
|
-
sink(
|
|
256
|
-
`[antigravity-tailer] failed step=${record.step_index} type=${record.type} status=${code}
|
|
257
|
-
`
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
if (record.step_index > highest) highest = record.step_index;
|
|
262
|
-
}
|
|
263
|
-
return { attempted, emitted, failed, skipped, highestStepIdx: highest };
|
|
264
|
-
}
|
|
265
|
-
async function tailAntigravityTranscript(stdin) {
|
|
266
|
-
const payload = parseHookPayload(stdin);
|
|
267
|
-
if (!payload?.conversationId || !payload?.transcriptPath) return;
|
|
268
|
-
loadEnvFile();
|
|
269
|
-
if (!process.env.RULEMETRIC_API_URL) return;
|
|
270
|
-
const rwSessionId = resolveRwSessionId(payload.conversationId);
|
|
271
|
-
if (!rwSessionId) return;
|
|
272
|
-
const existingState = loadState(payload.conversationId);
|
|
273
|
-
if (existingState === null) {
|
|
274
|
-
const primed = findMaxStepIndex(payload.transcriptPath);
|
|
275
|
-
saveState(payload.conversationId, { lastStepIdx: primed });
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
let records = readNewRecords(payload.transcriptPath, existingState.lastStepIdx);
|
|
279
|
-
if (records.length === 0) return;
|
|
280
|
-
if (records.length > MAX_RECORDS_PER_FIRE) {
|
|
281
|
-
records = records.slice(0, MAX_RECORDS_PER_FIRE);
|
|
282
|
-
}
|
|
283
|
-
const result = await emitRecordsAsEvents(
|
|
284
|
-
records,
|
|
285
|
-
rwSessionId,
|
|
286
|
-
payload.conversationId,
|
|
287
|
-
existingState.lastStepIdx
|
|
288
|
-
);
|
|
289
|
-
saveState(payload.conversationId, { lastStepIdx: result.highestStepIdx });
|
|
290
|
-
}
|
|
291
|
-
var stateApi = {
|
|
292
|
-
load: loadState,
|
|
293
|
-
save: saveState,
|
|
294
|
-
resolveRwSessionId,
|
|
295
|
-
loadEnvFile
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export {
|
|
299
|
-
readNewRecords,
|
|
300
|
-
findMaxStepIndex,
|
|
301
|
-
extractUserPrompt,
|
|
302
|
-
classifyRecord,
|
|
303
|
-
emitRecordsAsEvents,
|
|
304
|
-
tailAntigravityTranscript,
|
|
305
|
-
stateApi
|
|
306
|
-
};
|
|
307
|
-
//# sourceMappingURL=chunk-2ORJWTNZ.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/antigravity-transcript.ts"],
|
|
4
|
-
"sourcesContent": ["// Antigravity transcript tailer.\n//\n// Antigravity fires PreToolUse/PostToolUse hooks but no UserPromptSubmit /\n// Stop hooks, and the Gemini streaming traffic bypasses the proxy entirely\n// (the language_server binary opens direct sockets to\n// generativelanguage.googleapis.com). However, every hook payload includes\n// a `transcriptPath` pointing at a JSONL file that contains the full\n// conversation: user inputs, planner responses (with thinking), tool calls,\n// and tool results \u2014 all step-indexed.\n//\n// On each post-tool-use fire we tail that file forward from the last\n// step_index we processed and emit RuleMetric events for the new records.\n\nimport { existsSync, mkdirSync, readFileSync, renameSync, rmdirSync, writeFileSync } from 'node:fs';\nimport { homedir, tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport { api, ApiError } from './api-client.js';\n\ninterface HookPayload {\n conversationId?: string;\n transcriptPath?: string;\n}\n\ninterface TranscriptRecord {\n step_index: number;\n source: 'USER_EXPLICIT' | 'SYSTEM' | 'MODEL' | string;\n type: string;\n status?: string;\n created_at?: string;\n content?: string;\n thinking?: string;\n tool_calls?: Array<{ name?: string; args?: Record<string, unknown> }>;\n error?: string;\n}\n\ninterface State {\n lastStepIdx: number;\n}\n\n// Antigravity caps hook execution at 30s. Each emitted event is one HTTP\n// POST; at ~50ms/POST a fresh session with thousands of records would blow\n// the timeout. On first fire we therefore SKIP the backlog and prime\n// state to the current transcript end \u2014 only forward-going events get\n// captured. Subsequent fires process the new tail. We also hard-cap any\n// single fire to keep the latency bounded after a pause.\nconst MAX_RECORDS_PER_FIRE = 100;\n\ninterface OutgoingEvent {\n sequence: number;\n eventType: string;\n content: string | null;\n toolName?: string | null;\n toolInput?: Record<string, unknown> | null;\n toolOutput?: Record<string, unknown> | null;\n timestamp: string;\n metadata?: Record<string, unknown>;\n}\n\n// Tool call types are already captured by the PostToolUse hook itself.\n// We skip them in the transcript pass to avoid duplicate events.\nconst TOOL_CALL_TYPES = new Set([\n 'RUN_COMMAND',\n 'VIEW_FILE',\n 'LIST_DIRECTORY',\n 'CODE_ACTION',\n 'GREP_SEARCH',\n 'SEARCH_WEB',\n]);\n\n// Housekeeping records with no user-visible content.\nconst SKIP_TYPES = new Set([\n 'CONVERSATION_HISTORY',\n 'KNOWLEDGE_ARTIFACTS',\n 'CHECKPOINT',\n]);\n\nfunction configDir(): string {\n return process.env.RULEMETRIC_CONFIG_DIR ?? join(homedir(), '.config', 'rulemetric');\n}\n\nfunction stateDir(): string {\n return join(configDir(), 'antigravity-state');\n}\n\nfunction stateFile(conversationId: string): string {\n return join(stateDir(), `${conversationId}.json`);\n}\n\nfunction loadEnvFile(): void {\n // Mirror the bash _config.sh fallback: if RULEMETRIC_API_URL / _API_KEY are\n // unset in process.env (because launchd-inherited env didn't carry them),\n // read them from ~/.config/rulemetric/env.\n const envPath = join(configDir(), 'env');\n if (!existsSync(envPath)) return;\n try {\n const text = readFileSync(envPath, 'utf-8');\n for (const line of text.split(/\\r?\\n/)) {\n const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);\n if (!m) continue;\n const key = m[1];\n // Don't override an existing value \u2014 env wins over file.\n if (process.env[key] !== undefined) continue;\n let value = m[2];\n // Strip surrounding quotes if present.\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n process.env[key] = value;\n }\n } catch {\n // Best effort.\n }\n}\n\nfunction loadState(conversationId: string): State | null {\n try {\n const text = readFileSync(stateFile(conversationId), 'utf-8');\n const parsed = JSON.parse(text) as unknown;\n if (parsed && typeof parsed === 'object' && 'lastStepIdx' in parsed) {\n const v = (parsed as { lastStepIdx: unknown }).lastStepIdx;\n if (typeof v === 'number' && Number.isFinite(v)) {\n return { lastStepIdx: v };\n }\n }\n } catch {\n // First fire for this conversation \u2014 return null so caller can prime.\n }\n return null;\n}\n\nfunction saveState(conversationId: string, state: State): void {\n mkdirSync(stateDir(), { recursive: true });\n const target = stateFile(conversationId);\n const tmpPath = `${target}.tmp`;\n writeFileSync(tmpPath, JSON.stringify(state), { mode: 0o600 });\n try {\n renameSync(tmpPath, target);\n } catch {\n writeFileSync(target, JSON.stringify(state), { mode: 0o600 });\n }\n}\n\nfunction resolveRwSessionId(externalSessionId: string): string | null {\n // The bash hook writes the RW session UUID to $TMPDIR/rulemetric/<id>.\n const tempDir = process.env.TMPDIR ?? tmpdir();\n const rulemetricTempDir = join(tempDir, 'rulemetric');\n const path = join(rulemetricTempDir, externalSessionId);\n try {\n const id = readFileSync(path, 'utf-8').trim();\n return id || null;\n } catch {\n return null;\n }\n}\n\nfunction nextSequence(externalSessionId: string): number {\n const tempDir = process.env.TMPDIR ?? tmpdir();\n const rulemetricTempDir = join(tempDir, 'rulemetric');\n const seqPath = join(rulemetricTempDir, `${externalSessionId}.seq`);\n const lockDir = join(rulemetricTempDir, `${externalSessionId}.seqlock`);\n\n // Acquire the same mkdir-based lock the bash script uses, so seq numbers\n // remain strictly monotonic when the tailer and bash script interleave.\n const deadline = Date.now() + 5_000;\n while (Date.now() < deadline) {\n try {\n mkdirSync(lockDir);\n break;\n } catch {\n // Spin.\n }\n }\n\n let seq = 1;\n try {\n seq = parseInt(readFileSync(seqPath, 'utf-8').trim(), 10) + 1;\n if (!Number.isFinite(seq) || seq < 1) seq = 1;\n } catch {\n seq = 1;\n }\n try {\n writeFileSync(seqPath, String(seq));\n } catch {\n // ignore\n }\n try {\n rmdirSync(lockDir);\n } catch {\n // ignore\n }\n return seq;\n}\n\n/**\n * Read transcript.jsonl, parse each line as a TranscriptRecord, return only\n * records whose step_index is strictly greater than `afterStepIdx`.\n * Records with malformed JSON are silently dropped.\n */\nexport function readNewRecords(\n transcriptPath: string,\n afterStepIdx: number,\n): TranscriptRecord[] {\n let text: string;\n try {\n text = readFileSync(transcriptPath, 'utf-8');\n } catch {\n return [];\n }\n const out: TranscriptRecord[] = [];\n for (const line of text.split(/\\r?\\n/)) {\n if (!line.trim()) continue;\n try {\n const r = JSON.parse(line) as TranscriptRecord;\n if (typeof r.step_index === 'number' && r.step_index > afterStepIdx) {\n out.push(r);\n }\n } catch {\n // skip malformed lines\n }\n }\n // Defensive: keep monotonic order (transcript already is, but don't trust).\n out.sort((a, b) => a.step_index - b.step_index);\n return out;\n}\n\n/** Highest step_index present in the transcript, or -1 if empty/unreadable. */\nexport function findMaxStepIndex(transcriptPath: string): number {\n let text: string;\n try {\n text = readFileSync(transcriptPath, 'utf-8');\n } catch {\n return -1;\n }\n let max = -1;\n for (const line of text.split(/\\r?\\n/)) {\n if (!line.trim()) continue;\n try {\n const r = JSON.parse(line) as { step_index?: unknown };\n if (typeof r.step_index === 'number' && r.step_index > max) max = r.step_index;\n } catch {\n // skip\n }\n }\n return max;\n}\n\n/**\n * Strip Antigravity's <USER_REQUEST>...</USER_REQUEST> wrapper from a\n * USER_INPUT record's content. Returns the original string if no wrapper\n * is present. Some user inputs have additional non-request fragments after\n * the request block (e.g. <ADDITIONAL_CONTEXT>...) \u2014 we keep only the\n * request body since that's the actual prompt text.\n */\nexport function extractUserPrompt(raw: string): string {\n const m = raw.match(/<USER_REQUEST>\\s*([\\s\\S]*?)\\s*<\\/USER_REQUEST>/);\n return m ? m[1].trim() : raw.trim();\n}\n\n/**\n * Classify a transcript record into an outgoing RuleMetric event, or null\n * if the record should be skipped.\n */\nexport function classifyRecord(\n record: TranscriptRecord,\n sequence: number,\n): OutgoingEvent | null {\n const timestamp = record.created_at ?? new Date().toISOString();\n const metadata: Record<string, unknown> = {\n antigravityStepIndex: record.step_index,\n antigravitySource: record.source,\n antigravityType: record.type,\n };\n\n if (SKIP_TYPES.has(record.type)) return null;\n // Tool-call types are owned by the PostToolUse hook regardless of who\n // initiated them (MODEL agent calls + USER_EXPLICIT file-opens both fall\n // here). Skip in the transcript pass to avoid duplicates and fallback\n // event types the API doesn't accept.\n if (TOOL_CALL_TYPES.has(record.type)) return null;\n\n if (record.source === 'USER_EXPLICIT' && record.type === 'USER_INPUT') {\n return {\n sequence,\n // The events API accepts `user_message` (Claude Code's convention) but\n // rejects `user_prompt`. Stay aligned with the existing vocabulary so\n // the same downstream readers (insights, dashboard) light up for\n // Antigravity sessions without API changes.\n eventType: 'user_message',\n content: extractUserPrompt(record.content ?? ''),\n timestamp,\n metadata,\n };\n }\n\n if (record.source === 'MODEL' && record.type === 'PLANNER_RESPONSE') {\n const parts: string[] = [];\n if (record.thinking && record.thinking.trim()) {\n parts.push(`[thinking]\\n${record.thinking.trim()}`);\n }\n if (record.content && record.content.trim()) {\n parts.push(record.content.trim());\n }\n if (record.tool_calls && record.tool_calls.length > 0) {\n metadata.antigravityToolCalls = record.tool_calls.map((tc) => tc.name).filter(Boolean);\n }\n return {\n sequence,\n eventType: 'assistant_response',\n content: parts.join('\\n\\n') || null,\n timestamp,\n metadata,\n };\n }\n\n if (record.source === 'MODEL' && record.type === 'GENERIC') {\n return {\n sequence,\n eventType: 'tool_result',\n content: record.content ?? null,\n timestamp,\n metadata,\n };\n }\n\n if (record.source === 'SYSTEM' && (record.type === 'SYSTEM_MESSAGE' || record.type === 'ERROR_MESSAGE')) {\n // The events API doesn't currently accept a `system_message` eventType.\n // Skip rather than fabricate \u2014 these are housekeeping/error records and\n // losing them doesn't break the user-facing capture story. Revisit if\n // SYSTEM records ever carry user-relevant content.\n return null;\n }\n\n // Unknown (source, type) \u2014 keep with a generic eventType so we don't\n // lose data and can extend the classifier later from real samples.\n return {\n sequence,\n eventType: `antigravity_${record.type.toLowerCase()}`,\n content: record.content ?? null,\n timestamp,\n metadata,\n };\n}\n\nfunction parseHookPayload(stdin: string): HookPayload | null {\n try {\n const parsed = JSON.parse(stdin) as HookPayload;\n return parsed && typeof parsed === 'object' ? parsed : null;\n } catch {\n return null;\n }\n}\n\ninterface EmitResult {\n attempted: number;\n emitted: number;\n failed: number;\n skipped: number;\n highestStepIdx: number;\n}\n\ninterface EmitOptions {\n /** Called once per record processed; useful for CLI progress. */\n onProgress?: (info: { attempted: number; total: number; record: TranscriptRecord }) => void;\n /** Where to write per-failure diagnostic lines. Defaults to process.stderr. */\n errorSink?: (line: string) => void;\n}\n\n/**\n * POST a sequence of transcript records as RuleMetric events on `rwSessionId`.\n * Returns counters describing what happened. Never throws \u2014 individual POST\n * failures are reported via `errorSink` and counted as `failed`.\n *\n * The sequence number for each event is drawn from the shared per-conversation\n * counter at `$TMPDIR/rulemetric/<conversationId>.seq` (the bash hook reads\n * and writes the same file). The caller is responsible for persisting state\n * after this returns.\n */\nexport async function emitRecordsAsEvents(\n records: TranscriptRecord[],\n rwSessionId: string,\n conversationId: string,\n initialHighestStepIdx: number,\n options: EmitOptions = {},\n): Promise<EmitResult> {\n const sink = options.errorSink ?? ((line) => process.stderr.write(line));\n let attempted = 0;\n let emitted = 0;\n let failed = 0;\n let skipped = 0;\n let highest = initialHighestStepIdx;\n\n for (const record of records) {\n attempted++;\n options.onProgress?.({ attempted, total: records.length, record });\n const sequence = nextSequence(conversationId);\n const event = classifyRecord(record, sequence);\n if (!event) {\n skipped++;\n } else {\n try {\n await api(`/api/sessions/${rwSessionId}/events`, {\n method: 'POST',\n body: event,\n });\n emitted++;\n } catch (err) {\n failed++;\n const code = err instanceof ApiError ? err.statusCode : 'unknown';\n sink(\n `[antigravity-tailer] failed step=${record.step_index} type=${record.type} status=${code}\\n`,\n );\n }\n }\n if (record.step_index > highest) highest = record.step_index;\n }\n\n return { attempted, emitted, failed, skipped, highestStepIdx: highest };\n}\n\n/**\n * Tail the Antigravity transcript described by the hook payload, POSTing\n * any new events to the RuleMetric API. Never throws \u2014 best-effort, errors\n * land on stderr.\n */\nexport async function tailAntigravityTranscript(stdin: string): Promise<void> {\n const payload = parseHookPayload(stdin);\n if (!payload?.conversationId || !payload?.transcriptPath) return;\n\n loadEnvFile();\n if (!process.env.RULEMETRIC_API_URL) return;\n\n const rwSessionId = resolveRwSessionId(payload.conversationId);\n if (!rwSessionId) return;\n\n const existingState = loadState(payload.conversationId);\n if (existingState === null) {\n // First fire for this conversation. Prime state to the current end of\n // the transcript instead of replaying history through 800+ HTTP POSTs \u2014\n // that would blow Antigravity's 30s hook timeout. Capture is\n // forward-only from the moment hooks are installed for a conversation.\n // Use `rulemetric antigravity backfill` to seed historical events.\n const primed = findMaxStepIndex(payload.transcriptPath);\n saveState(payload.conversationId, { lastStepIdx: primed });\n return;\n }\n\n let records = readNewRecords(payload.transcriptPath, existingState.lastStepIdx);\n if (records.length === 0) return;\n if (records.length > MAX_RECORDS_PER_FIRE) {\n records = records.slice(0, MAX_RECORDS_PER_FIRE);\n }\n\n const result = await emitRecordsAsEvents(\n records,\n rwSessionId,\n payload.conversationId,\n existingState.lastStepIdx,\n );\n saveState(payload.conversationId, { lastStepIdx: result.highestStepIdx });\n}\n\n/**\n * Helpers exposed for the backfill command. Re-exporting from one place so\n * the command surface stays decoupled from filesystem layout.\n */\nexport const stateApi = {\n load: loadState,\n save: saveState,\n resolveRwSessionId,\n loadEnvFile,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAaA,SAAS,YAAY,WAAW,cAAc,YAAY,WAAW,qBAAqB;AAC1F,SAAS,SAAS,cAAc;AAChC,SAAS,YAAY;AA8BrB,IAAM,uBAAuB;AAe7B,IAAM,kBAAkB,oBAAI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Q;AACxE;AAOA,eAAsB,0BAA0B,OAA8B;AAC5E,QAAM,UAAU,iBAAiB,KAAK;AACtC,MAAI,CAAC,SAAS,kBAAkB,CAAC,SAAS,eAAgB;AAE1D,cAAY;AACZ,MAAI,CAAC,QAAQ,IAAI,mBAAoB;AAErC,QAAM,cAAc,mBAAmB,QAAQ,cAAc;AAC7D,MAAI,CAAC,YAAa;AAElB,QAAM,gBAAgB,UAAU,QAAQ,cAAc;AACtD,MAAI,kBAAkB,MAAM;AAM1B,UAAM,SAAS,iBAAiB,QAAQ,cAAc;AACtD,cAAU,QAAQ,gBAAgB,EAAE,aAAa,OAAO,CAAC;AACzD;AAAA,EACF;AAEA,MAAI,UAAU,eAAe,QAAQ,gBAAgB,cAAc,WAAW;AAC9E,MAAI,QAAQ,WAAW,EAAG;AAC1B,MAAI,QAAQ,SAAS,sBAAsB;AACzC,cAAU,QAAQ,MAAM,GAAG,oBAAoB;AAAA,EACjD;AAEA,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,cAAc;AAAA,EAChB;AACA,YAAU,QAAQ,gBAAgB,EAAE,aAAa,OAAO,eAAe,CAAC;AAC1E;AAMO,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,MAAM;AAAA,EACN;AAAA,EACA;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/chunk-37LN5O7M.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
clearActiveOrg,
|
|
3
|
-
isStale,
|
|
4
|
-
readActiveOrg,
|
|
5
|
-
writeActiveOrg
|
|
6
|
-
} from "./chunk-EKJ2CABV.js";
|
|
7
|
-
import {
|
|
8
|
-
apiGet
|
|
9
|
-
} from "./chunk-ZUJBM6HE.js";
|
|
10
|
-
|
|
11
|
-
// src/lib/active-org-refresh.ts
|
|
12
|
-
var attempted = false;
|
|
13
|
-
async function syncActiveOrgFromServer() {
|
|
14
|
-
if (process.env.RULEMETRIC_ORG_ID) return;
|
|
15
|
-
const cached = readActiveOrg();
|
|
16
|
-
if (cached && !isStale(cached)) return;
|
|
17
|
-
try {
|
|
18
|
-
const profile = await apiGet("/api/profile");
|
|
19
|
-
if (!profile.activeOrgId) {
|
|
20
|
-
clearActiveOrg();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (cached && profile.activeOrgId === cached.orgId) {
|
|
24
|
-
writeActiveOrg({
|
|
25
|
-
orgId: cached.orgId,
|
|
26
|
-
orgSlug: cached.orgSlug,
|
|
27
|
-
syncedAt: Date.now()
|
|
28
|
-
});
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const orgs = await apiGet("/api/orgs");
|
|
32
|
-
const match = orgs.find((o) => o.id === profile.activeOrgId);
|
|
33
|
-
writeActiveOrg({
|
|
34
|
-
orgId: profile.activeOrgId,
|
|
35
|
-
orgSlug: match?.slug,
|
|
36
|
-
syncedAt: Date.now()
|
|
37
|
-
});
|
|
38
|
-
} catch {
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function maybeRefreshActiveOrg() {
|
|
42
|
-
if (attempted) return;
|
|
43
|
-
attempted = true;
|
|
44
|
-
await syncActiveOrgFromServer();
|
|
45
|
-
}
|
|
46
|
-
async function bootstrapActiveOrg() {
|
|
47
|
-
attempted = true;
|
|
48
|
-
await syncActiveOrgFromServer();
|
|
49
|
-
}
|
|
50
|
-
function _resetRefreshAttempt() {
|
|
51
|
-
attempted = false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
maybeRefreshActiveOrg,
|
|
56
|
-
bootstrapActiveOrg,
|
|
57
|
-
_resetRefreshAttempt
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=chunk-37LN5O7M.js.map
|