@rulemetric/cli 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-command.js +13 -52
- package/dist/base-command.js.map +7 -1
- package/dist/chunk-2AM54TUK.js +59 -0
- package/dist/chunk-2AM54TUK.js.map +7 -0
- package/dist/chunk-3TIMQ3O6.js +96 -0
- package/dist/chunk-3TIMQ3O6.js.map +7 -0
- package/dist/chunk-4BHDHHKL.js +48 -0
- package/dist/chunk-4BHDHHKL.js.map +7 -0
- package/dist/chunk-4D537GXE.js +99 -0
- package/dist/chunk-4D537GXE.js.map +7 -0
- package/dist/chunk-4SCZK7AL.js +129 -0
- package/dist/chunk-4SCZK7AL.js.map +7 -0
- package/dist/chunk-4WFE4PFP.js +61 -0
- package/dist/chunk-4WFE4PFP.js.map +7 -0
- package/dist/chunk-52WIYRZH.js +73 -0
- package/dist/chunk-52WIYRZH.js.map +7 -0
- package/dist/chunk-7FAA3YNB.js +1549 -0
- package/dist/chunk-7FAA3YNB.js.map +7 -0
- package/dist/chunk-7NYKWN7U.js +12 -0
- package/dist/chunk-7NYKWN7U.js.map +7 -0
- package/dist/chunk-AULP2OWH.js +99 -0
- package/dist/chunk-AULP2OWH.js.map +7 -0
- package/dist/chunk-B5KNTGMJ.js +1788 -0
- package/dist/chunk-B5KNTGMJ.js.map +7 -0
- package/dist/chunk-BD7CY42U.js +23 -0
- package/dist/chunk-BD7CY42U.js.map +7 -0
- package/dist/chunk-BO76WKJR.js +42 -0
- package/dist/chunk-BO76WKJR.js.map +7 -0
- package/dist/chunk-BRD5RUGM.js +53 -0
- package/dist/chunk-BRD5RUGM.js.map +7 -0
- package/dist/chunk-BT6Z6545.js +43 -0
- package/dist/chunk-BT6Z6545.js.map +7 -0
- package/dist/chunk-BZDKEQKU.js +39 -0
- package/dist/chunk-BZDKEQKU.js.map +7 -0
- package/dist/chunk-CROYS75W.js +161 -0
- package/dist/chunk-CROYS75W.js.map +7 -0
- package/dist/chunk-DGHWRQXL.js +17 -0
- package/dist/chunk-DGHWRQXL.js.map +7 -0
- package/dist/chunk-DQ3KELXD.js +74 -0
- package/dist/chunk-DQ3KELXD.js.map +7 -0
- package/dist/chunk-DTFXCHHI.js +108 -0
- package/dist/chunk-DTFXCHHI.js.map +7 -0
- package/dist/chunk-DU73QUS3.js +75 -0
- package/dist/chunk-DU73QUS3.js.map +7 -0
- package/dist/chunk-EHZJ6OXD.js +307 -0
- package/dist/chunk-EHZJ6OXD.js.map +7 -0
- package/dist/chunk-EJOI2ZGU.js +109 -0
- package/dist/chunk-EJOI2ZGU.js.map +7 -0
- package/dist/chunk-EKJ2CABV.js +76 -0
- package/dist/chunk-EKJ2CABV.js.map +7 -0
- package/dist/chunk-EKP32DLN.js +16 -0
- package/dist/chunk-EKP32DLN.js.map +7 -0
- package/dist/chunk-EOOP6WTC.js +148 -0
- package/dist/chunk-EOOP6WTC.js.map +7 -0
- package/dist/chunk-ERPMDAO3.js +20 -0
- package/dist/chunk-ERPMDAO3.js.map +7 -0
- package/dist/chunk-FTJRMUID.js +96 -0
- package/dist/chunk-FTJRMUID.js.map +7 -0
- package/dist/chunk-FZKLLNDS.js +228 -0
- package/dist/chunk-FZKLLNDS.js.map +7 -0
- package/dist/chunk-GQCISMAH.js +157 -0
- package/dist/chunk-GQCISMAH.js.map +7 -0
- package/dist/chunk-IGXX624H.js +55 -0
- package/dist/chunk-IGXX624H.js.map +7 -0
- package/dist/chunk-IJGF2ETG.js +68 -0
- package/dist/chunk-IJGF2ETG.js.map +7 -0
- package/dist/chunk-IWYCRLEK.js +220 -0
- package/dist/chunk-IWYCRLEK.js.map +7 -0
- package/dist/chunk-J7N3DLH6.js +117 -0
- package/dist/chunk-J7N3DLH6.js.map +7 -0
- package/dist/chunk-JX5UI6RW.js +99 -0
- package/dist/chunk-JX5UI6RW.js.map +7 -0
- package/dist/chunk-K3BFZ7KG.js +154 -0
- package/dist/chunk-K3BFZ7KG.js.map +7 -0
- package/dist/chunk-KHJUQFIK.js +51 -0
- package/dist/chunk-KHJUQFIK.js.map +7 -0
- package/dist/chunk-KRBQLMOP.js +41 -0
- package/dist/chunk-KRBQLMOP.js.map +7 -0
- package/dist/chunk-KZRFUXGF.js +145 -0
- package/dist/chunk-KZRFUXGF.js.map +7 -0
- package/dist/chunk-L674RNKQ.js +492 -0
- package/dist/chunk-L674RNKQ.js.map +7 -0
- package/dist/chunk-N52AHNBH.js +47 -0
- package/dist/chunk-N52AHNBH.js.map +7 -0
- package/dist/chunk-NIDLJO6F.js +228 -0
- package/dist/chunk-NIDLJO6F.js.map +7 -0
- package/dist/chunk-NSBPE2FW.js +17 -0
- package/dist/chunk-NSBPE2FW.js.map +7 -0
- package/dist/chunk-OGVORIFM.js +70 -0
- package/dist/chunk-OGVORIFM.js.map +7 -0
- package/dist/chunk-OQSQC7VB.js +77 -0
- package/dist/chunk-OQSQC7VB.js.map +7 -0
- package/dist/chunk-PHLMIZKM.js +153 -0
- package/dist/chunk-PHLMIZKM.js.map +7 -0
- package/dist/chunk-PQU7GZ7A.js +92 -0
- package/dist/chunk-PQU7GZ7A.js.map +7 -0
- package/dist/chunk-PXVQLD7S.js +196 -0
- package/dist/chunk-PXVQLD7S.js.map +7 -0
- package/dist/chunk-QD6X4L4L.js +79 -0
- package/dist/chunk-QD6X4L4L.js.map +7 -0
- package/dist/chunk-QJQS6TUN.js +44 -0
- package/dist/chunk-QJQS6TUN.js.map +7 -0
- package/dist/chunk-QJXAULRC.js +191 -0
- package/dist/chunk-QJXAULRC.js.map +7 -0
- package/dist/chunk-QN34TGD3.js +83 -0
- package/dist/chunk-QN34TGD3.js.map +7 -0
- package/dist/chunk-R5MFHGHR.js +122 -0
- package/dist/chunk-R5MFHGHR.js.map +7 -0
- package/dist/chunk-RH7NHVSK.js +16 -0
- package/dist/chunk-RH7NHVSK.js.map +7 -0
- package/dist/chunk-RJ7BHDLM.js +121 -0
- package/dist/chunk-RJ7BHDLM.js.map +7 -0
- package/dist/chunk-RQ2TMLKG.js +142 -0
- package/dist/chunk-RQ2TMLKG.js.map +7 -0
- package/dist/chunk-S56LOTGQ.js +63 -0
- package/dist/chunk-S56LOTGQ.js.map +7 -0
- package/dist/chunk-UF73WX2J.js +49 -0
- package/dist/chunk-UF73WX2J.js.map +7 -0
- package/dist/chunk-W53GKIZQ.js +50 -0
- package/dist/chunk-W53GKIZQ.js.map +7 -0
- package/dist/chunk-WA4MWYRW.js +254 -0
- package/dist/chunk-WA4MWYRW.js.map +7 -0
- package/dist/chunk-WFULKPEQ.js +269 -0
- package/dist/chunk-WFULKPEQ.js.map +7 -0
- package/dist/chunk-XC6M4CSW.js +44 -0
- package/dist/chunk-XC6M4CSW.js.map +7 -0
- package/dist/chunk-XPUEGHXN.js +243 -0
- package/dist/chunk-XPUEGHXN.js.map +7 -0
- package/dist/chunk-XZXS2W24.js +148 -0
- package/dist/chunk-XZXS2W24.js.map +7 -0
- package/dist/chunk-YBNW7ARH.js +167 -0
- package/dist/chunk-YBNW7ARH.js.map +7 -0
- package/dist/chunk-YNIH3KMU.js +121 -0
- package/dist/chunk-YNIH3KMU.js.map +7 -0
- package/dist/commands/antigravity/backfill.js +135 -0
- package/dist/commands/antigravity/backfill.js.map +7 -0
- package/dist/commands/auth/create-key.js +48 -33
- package/dist/commands/auth/create-key.js.map +7 -1
- package/dist/commands/auth/login.js +58 -46
- package/dist/commands/auth/login.js.map +7 -1
- package/dist/commands/auth/logout.js +28 -13
- package/dist/commands/auth/logout.js.map +7 -1
- package/dist/commands/auth/revoke-key.js +32 -18
- package/dist/commands/auth/revoke-key.js.map +7 -1
- package/dist/commands/auth/status.js +40 -22
- package/dist/commands/auth/status.js.map +7 -1
- package/dist/commands/catalog/index.js +50 -34
- package/dist/commands/catalog/index.js.map +7 -1
- package/dist/commands/catalog/recommend.js +41 -26
- package/dist/commands/catalog/recommend.js.map +7 -1
- package/dist/commands/convert.js +72 -54
- package/dist/commands/convert.js.map +7 -1
- package/dist/commands/converters.js +52 -38
- package/dist/commands/converters.js.map +7 -1
- package/dist/commands/crons/list.js +50 -24
- package/dist/commands/crons/list.js.map +7 -1
- package/dist/commands/crons/run.js +72 -47
- package/dist/commands/crons/run.js.map +7 -1
- package/dist/commands/dashboard.js +45 -24
- package/dist/commands/dashboard.js.map +7 -1
- package/dist/commands/eval-targets/create.js +51 -39
- package/dist/commands/eval-targets/create.js.map +7 -1
- package/dist/commands/eval-targets/list.js +52 -35
- package/dist/commands/eval-targets/list.js.map +7 -1
- package/dist/commands/evals/agent.js +292 -0
- package/dist/commands/evals/agent.js.map +7 -0
- package/dist/commands/evals/benchmark.js +70 -51
- package/dist/commands/evals/benchmark.js.map +7 -1
- package/dist/commands/evals/compare.js +90 -78
- package/dist/commands/evals/compare.js.map +7 -1
- package/dist/commands/evals/create.js +64 -50
- package/dist/commands/evals/create.js.map +7 -1
- package/dist/commands/evals/optimize-description.js +225 -222
- package/dist/commands/evals/optimize-description.js.map +7 -1
- package/dist/commands/evals/optimize.js +206 -196
- package/dist/commands/evals/optimize.js.map +7 -1
- package/dist/commands/evals/run.js +178 -164
- package/dist/commands/evals/run.js.map +7 -1
- package/dist/commands/gateway/ensure.js +33 -19
- package/dist/commands/gateway/ensure.js.map +7 -1
- package/dist/commands/hooks/install.js +335 -275
- package/dist/commands/hooks/install.js.map +7 -1
- package/dist/commands/hooks/run.js +72 -53
- package/dist/commands/hooks/run.js.map +7 -1
- package/dist/commands/hooks/uninstall.js +117 -94
- package/dist/commands/hooks/uninstall.js.map +7 -1
- package/dist/commands/import.js +63 -53
- package/dist/commands/import.js.map +7 -1
- package/dist/commands/instructions/create.js +71 -58
- package/dist/commands/instructions/create.js.map +7 -1
- package/dist/commands/instructions/delete.js +53 -36
- package/dist/commands/instructions/delete.js.map +7 -1
- package/dist/commands/instructions/fork.js +33 -19
- package/dist/commands/instructions/fork.js.map +7 -1
- package/dist/commands/instructions/get.js +66 -49
- package/dist/commands/instructions/get.js.map +7 -1
- package/dist/commands/instructions/list.js +63 -46
- package/dist/commands/instructions/list.js.map +7 -1
- package/dist/commands/instructions/promote.js +41 -27
- package/dist/commands/instructions/promote.js.map +7 -1
- package/dist/commands/instructions/pull.js +37 -21
- package/dist/commands/instructions/pull.js.map +7 -1
- package/dist/commands/instructions/upstream.js +36 -21
- package/dist/commands/instructions/upstream.js.map +7 -1
- package/dist/commands/instructions/versions.js +51 -33
- package/dist/commands/instructions/versions.js.map +7 -1
- package/dist/commands/launcher.js +39 -0
- package/dist/commands/launcher.js.map +7 -0
- package/dist/commands/org/current.js +74 -68
- package/dist/commands/org/current.js.map +7 -1
- package/dist/commands/org/list.js +50 -36
- package/dist/commands/org/list.js.map +7 -1
- package/dist/commands/org/switch.js +69 -51
- package/dist/commands/org/switch.js.map +7 -1
- package/dist/commands/packs/add-instruction.js +36 -22
- package/dist/commands/packs/add-instruction.js.map +7 -1
- package/dist/commands/packs/apply.js +38 -24
- package/dist/commands/packs/apply.js.map +7 -1
- package/dist/commands/packs/create.js +47 -33
- package/dist/commands/packs/create.js.map +7 -1
- package/dist/commands/packs/fork.js +33 -19
- package/dist/commands/packs/fork.js.map +7 -1
- package/dist/commands/packs/get.js +54 -35
- package/dist/commands/packs/get.js.map +7 -1
- package/dist/commands/packs/list.js +64 -47
- package/dist/commands/packs/list.js.map +7 -1
- package/dist/commands/packs/remove-instruction.js +34 -20
- package/dist/commands/packs/remove-instruction.js.map +7 -1
- package/dist/commands/proxy/env.js +126 -116
- package/dist/commands/proxy/env.js.map +7 -1
- package/dist/commands/proxy/logs.js +83 -74
- package/dist/commands/proxy/logs.js.map +7 -1
- package/dist/commands/proxy/restart.js +34 -36
- package/dist/commands/proxy/restart.js.map +7 -1
- package/dist/commands/proxy/setup.js +432 -375
- package/dist/commands/proxy/setup.js.map +7 -1
- package/dist/commands/proxy/start.js +289 -289
- package/dist/commands/proxy/start.js.map +7 -1
- package/dist/commands/proxy/status.js +74 -64
- package/dist/commands/proxy/status.js.map +7 -1
- package/dist/commands/proxy/stop.js +81 -75
- package/dist/commands/proxy/stop.js.map +7 -1
- package/dist/commands/research/backfill.js +58 -0
- package/dist/commands/research/backfill.js.map +7 -0
- package/dist/commands/research/tail-transcript.js +69 -0
- package/dist/commands/research/tail-transcript.js.map +7 -0
- package/dist/commands/service/install.js +639 -405
- package/dist/commands/service/install.js.map +7 -1
- package/dist/commands/service/status.js +178 -111
- package/dist/commands/service/status.js.map +7 -1
- package/dist/commands/service/uninstall.js +85 -110
- package/dist/commands/service/uninstall.js.map +7 -1
- package/dist/commands/sessions/analyze.js +46 -25
- package/dist/commands/sessions/analyze.js.map +7 -1
- package/dist/commands/sessions/end.js +81 -79
- package/dist/commands/sessions/end.js.map +7 -1
- package/dist/commands/sessions/import.js +44 -27
- package/dist/commands/sessions/import.js.map +7 -1
- package/dist/commands/sessions/list.js +46 -33
- package/dist/commands/sessions/list.js.map +7 -1
- package/dist/commands/sessions/start.js +88 -87
- package/dist/commands/sessions/start.js.map +7 -1
- package/dist/commands/signals/report.js +42 -34
- package/dist/commands/signals/report.js.map +7 -1
- package/dist/commands/skills/export-approved.js +44 -30
- package/dist/commands/skills/export-approved.js.map +7 -1
- package/dist/commands/skills/install.js +99 -84
- package/dist/commands/skills/install.js.map +7 -1
- package/dist/commands/skills/list.js +59 -42
- package/dist/commands/skills/list.js.map +7 -1
- package/dist/commands/skills/publish.js +95 -78
- package/dist/commands/skills/publish.js.map +7 -1
- package/dist/commands/skills/search.js +68 -53
- package/dist/commands/skills/search.js.map +7 -1
- package/dist/commands/skills/update.js +52 -39
- package/dist/commands/skills/update.js.map +7 -1
- package/dist/commands/suggestions/accept.js +82 -59
- package/dist/commands/suggestions/accept.js.map +7 -1
- package/dist/commands/suggestions/dismiss.js +44 -26
- package/dist/commands/suggestions/dismiss.js.map +7 -1
- package/dist/commands/suggestions/list.js +59 -39
- package/dist/commands/suggestions/list.js.map +7 -1
- package/dist/commands/suggestions/refresh.js +26 -11
- package/dist/commands/suggestions/refresh.js.map +7 -1
- package/dist/cursor-BGQJ4CWI.js +134 -0
- package/dist/cursor-BGQJ4CWI.js.map +7 -0
- package/dist/dashboard/Dashboard.js +229 -126
- package/dist/dashboard/Dashboard.js.map +7 -1
- package/dist/dashboard/data.js +13 -137
- package/dist/dashboard/data.js.map +7 -1
- package/dist/dashboard/launcher/ActiveJobsList.js +10 -0
- package/dist/dashboard/launcher/ActiveJobsList.js.map +7 -0
- package/dist/dashboard/launcher/LauncherOverlay.js +14 -0
- package/dist/dashboard/launcher/LauncherOverlay.js.map +7 -0
- package/dist/dashboard/launcher/NewLaunchForm.js +10 -0
- package/dist/dashboard/launcher/NewLaunchForm.js.map +7 -0
- package/dist/dashboard/launcher/api.js +14 -0
- package/dist/dashboard/launcher/api.js.map +7 -0
- package/dist/dashboard/launcher/tool-labels.js +10 -0
- package/dist/dashboard/launcher/tool-labels.js.map +7 -0
- package/dist/dashboard/launcher/types.js +1 -0
- package/dist/dashboard/launcher/types.js.map +7 -0
- package/dist/dashboard/launcher/useLaunchJobs.js +9 -0
- package/dist/dashboard/launcher/useLaunchJobs.js.map +7 -0
- package/dist/dashboard/panels/friction.js +10 -22
- package/dist/dashboard/panels/friction.js.map +7 -1
- package/dist/dashboard/panels/insights.js +10 -109
- package/dist/dashboard/panels/insights.js.map +7 -1
- package/dist/dashboard/panels/instructions.js +10 -17
- package/dist/dashboard/panels/instructions.js.map +7 -1
- package/dist/dashboard/panels/outcomes.js +9 -28
- package/dist/dashboard/panels/outcomes.js.map +7 -1
- package/dist/dashboard/panels/overview.js +10 -20
- package/dist/dashboard/panels/overview.js.map +7 -1
- package/dist/dashboard/panels/shared.js +18 -61
- package/dist/dashboard/panels/shared.js.map +7 -1
- package/dist/dashboard/types.js +23 -26
- package/dist/dashboard/types.js.map +7 -1
- package/dist/dist-CSUYFYKI.js +52 -0
- package/dist/dist-CSUYFYKI.js.map +7 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +7 -1
- package/dist/lib/active-org-refresh.js +15 -108
- package/dist/lib/active-org-refresh.js.map +7 -1
- package/dist/lib/active-org.js +15 -95
- package/dist/lib/active-org.js.map +7 -1
- package/dist/lib/agent-loop.js +44 -0
- package/dist/lib/agent-loop.js.map +7 -0
- package/dist/lib/antigravity-transcript.js +22 -0
- package/dist/lib/antigravity-transcript.js.map +7 -0
- package/dist/lib/api-client.js +21 -92
- package/dist/lib/api-client.js.map +7 -1
- package/dist/lib/auth.js +26 -137
- package/dist/lib/auth.js.map +7 -1
- package/dist/lib/detect-languages.js +8 -113
- package/dist/lib/detect-languages.js.map +7 -1
- package/dist/lib/detect-tmux.js +9 -0
- package/dist/lib/detect-tmux.js.map +7 -0
- package/dist/lib/eval-analyzer.js +9 -89
- package/dist/lib/eval-analyzer.js.map +7 -1
- package/dist/lib/eval-benchmark.js +12 -92
- package/dist/lib/eval-benchmark.js.map +7 -1
- package/dist/lib/eval-conversation-handler.js +13 -200
- package/dist/lib/eval-conversation-handler.js.map +7 -1
- package/dist/lib/eval-executor.js +8 -83
- package/dist/lib/eval-executor.js.map +7 -1
- package/dist/lib/eval-grader.js +9 -123
- package/dist/lib/eval-grader.js.map +7 -1
- package/dist/lib/eval-meta-judge.js +9 -116
- package/dist/lib/eval-meta-judge.js.map +7 -1
- package/dist/lib/eval-trigger-tester.js +11 -96
- package/dist/lib/eval-trigger-tester.js.map +7 -1
- package/dist/lib/eval-worktree.js +8 -87
- package/dist/lib/eval-worktree.js.map +7 -1
- package/dist/lib/gateway-entry.js +20 -18
- package/dist/lib/gateway-entry.js.map +7 -1
- package/dist/lib/gateway-lifecycle.js +22 -97
- package/dist/lib/gateway-lifecycle.js.map +7 -1
- package/dist/lib/gateway.js +12 -216
- package/dist/lib/gateway.js.map +7 -1
- package/dist/lib/handlers/cron-close-stale-sessions.js +18 -7
- package/dist/lib/handlers/cron-close-stale-sessions.js.map +7 -1
- package/dist/lib/handlers/cron-data-integrity-audit.js +21 -15
- package/dist/lib/handlers/cron-data-integrity-audit.js.map +7 -1
- package/dist/lib/handlers/cron-refresh-skills.js +7 -90
- package/dist/lib/handlers/cron-refresh-skills.js.map +7 -1
- package/dist/lib/handlers/cron-suggest-instructions.js +14 -158
- package/dist/lib/handlers/cron-suggest-instructions.js.map +7 -1
- package/dist/lib/handlers/process-announcement.js +11 -0
- package/dist/lib/handlers/process-announcement.js.map +7 -0
- package/dist/lib/handlers/process-changelog.js +11 -0
- package/dist/lib/handlers/process-changelog.js.map +7 -0
- package/dist/lib/handlers/process-conversation.js +14 -35
- package/dist/lib/handlers/process-conversation.js.map +7 -1
- package/dist/lib/handlers/process-eval.js +15 -207
- package/dist/lib/handlers/process-eval.js.map +7 -1
- package/dist/lib/handlers/process-insights.js +14 -300
- package/dist/lib/handlers/process-insights.js.map +7 -1
- package/dist/lib/handlers/process-launch.js +16 -41
- package/dist/lib/handlers/process-launch.js.map +7 -1
- package/dist/lib/handlers/process-run-cleanup.js +13 -0
- package/dist/lib/handlers/process-run-cleanup.js.map +7 -0
- package/dist/lib/handlers/process-send-message.js +10 -0
- package/dist/lib/handlers/process-send-message.js.map +7 -0
- package/dist/lib/handlers/process-session-goal.js +11 -74
- package/dist/lib/handlers/process-session-goal.js.map +7 -1
- package/dist/lib/hooks-config.js +52 -544
- package/dist/lib/hooks-config.js.map +7 -1
- package/dist/lib/insights-prompts.js +12 -145
- package/dist/lib/insights-prompts.js.map +7 -1
- package/dist/lib/job-helpers.js +1 -0
- package/dist/lib/job-helpers.js.map +7 -0
- package/dist/lib/llm-client.js +16 -274
- package/dist/lib/llm-client.js.map +7 -1
- package/dist/lib/manual-tasks.js +22 -0
- package/dist/lib/manual-tasks.js.map +7 -0
- package/dist/lib/output.js +12 -36
- package/dist/lib/output.js.map +7 -1
- package/dist/lib/permanent-job-error.js +10 -23
- package/dist/lib/permanent-job-error.js.map +7 -1
- package/dist/lib/provider-aggregator.js +57 -55
- package/dist/lib/provider-aggregator.js.map +7 -1
- package/dist/lib/research-client.js +12 -0
- package/dist/lib/research-client.js.map +7 -0
- package/dist/lib/skills-loader.js +8 -51
- package/dist/lib/skills-loader.js.map +7 -1
- package/dist/lib/statusline-shim.js +16 -0
- package/dist/lib/statusline-shim.js.map +7 -0
- package/dist/lib/terminal-target-heartbeat.js +15 -0
- package/dist/lib/terminal-target-heartbeat.js.map +7 -0
- package/dist/lib/tmux.js +16 -0
- package/dist/lib/tmux.js.map +7 -0
- package/dist/lib/transcript-rate-limit-watcher.js +22 -0
- package/dist/lib/transcript-rate-limit-watcher.js.map +7 -0
- package/dist/lib/types.js +8 -7
- package/dist/lib/types.js.map +7 -1
- package/dist/lib/version-check.js +10 -106
- package/dist/lib/version-check.js.map +7 -1
- package/dist/lib/which.js +8 -0
- package/dist/lib/which.js.map +7 -0
- package/dist/lib/worktree.js +17 -0
- package/dist/lib/worktree.js.map +7 -0
- package/dist/opencode-IQ7X5YMJ.js +190 -0
- package/dist/opencode-IQ7X5YMJ.js.map +7 -0
- package/oclif.manifest.json +299 -66
- package/package.json +26 -10
- package/dist/base-command.d.ts +0 -12
- package/dist/base-command.d.ts.map +0 -1
- package/dist/commands/auth/create-key.d.ts +0 -11
- package/dist/commands/auth/create-key.d.ts.map +0 -1
- package/dist/commands/auth/login.d.ts +0 -11
- package/dist/commands/auth/login.d.ts.map +0 -1
- package/dist/commands/auth/logout.d.ts +0 -7
- package/dist/commands/auth/logout.d.ts.map +0 -1
- package/dist/commands/auth/revoke-key.d.ts +0 -10
- package/dist/commands/auth/revoke-key.d.ts.map +0 -1
- package/dist/commands/auth/status.d.ts +0 -7
- package/dist/commands/auth/status.d.ts.map +0 -1
- package/dist/commands/catalog/index.d.ts +0 -11
- package/dist/commands/catalog/index.d.ts.map +0 -1
- package/dist/commands/catalog/recommend.d.ts +0 -9
- package/dist/commands/catalog/recommend.d.ts.map +0 -1
- package/dist/commands/convert.d.ts +0 -15
- package/dist/commands/convert.d.ts.map +0 -1
- package/dist/commands/converters.d.ts +0 -12
- package/dist/commands/converters.d.ts.map +0 -1
- package/dist/commands/crons/list.d.ts +0 -7
- package/dist/commands/crons/list.d.ts.map +0 -1
- package/dist/commands/crons/run.d.ts +0 -13
- package/dist/commands/crons/run.d.ts.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -10
- package/dist/commands/dashboard.d.ts.map +0 -1
- package/dist/commands/eval-targets/create.d.ts +0 -14
- package/dist/commands/eval-targets/create.d.ts.map +0 -1
- package/dist/commands/eval-targets/list.d.ts +0 -10
- package/dist/commands/eval-targets/list.d.ts.map +0 -1
- package/dist/commands/evals/benchmark.d.ts +0 -13
- package/dist/commands/evals/benchmark.d.ts.map +0 -1
- package/dist/commands/evals/compare.d.ts +0 -15
- package/dist/commands/evals/compare.d.ts.map +0 -1
- package/dist/commands/evals/create.d.ts +0 -17
- package/dist/commands/evals/create.d.ts.map +0 -1
- package/dist/commands/evals/listen.d.ts +0 -37
- package/dist/commands/evals/listen.d.ts.map +0 -1
- package/dist/commands/evals/listen.js +0 -188
- package/dist/commands/evals/listen.js.map +0 -1
- package/dist/commands/evals/listen.test.d.ts +0 -2
- package/dist/commands/evals/listen.test.d.ts.map +0 -1
- package/dist/commands/evals/listen.test.js +0 -48
- package/dist/commands/evals/listen.test.js.map +0 -1
- package/dist/commands/evals/optimize-description.d.ts +0 -22
- package/dist/commands/evals/optimize-description.d.ts.map +0 -1
- package/dist/commands/evals/optimize.d.ts +0 -22
- package/dist/commands/evals/optimize.d.ts.map +0 -1
- package/dist/commands/evals/run.d.ts +0 -21
- package/dist/commands/evals/run.d.ts.map +0 -1
- package/dist/commands/gateway/ensure.d.ts +0 -7
- package/dist/commands/gateway/ensure.d.ts.map +0 -1
- package/dist/commands/hooks/install.d.ts +0 -16
- package/dist/commands/hooks/install.d.ts.map +0 -1
- package/dist/commands/hooks/run.d.ts +0 -11
- package/dist/commands/hooks/run.d.ts.map +0 -1
- package/dist/commands/hooks/uninstall.d.ts +0 -7
- package/dist/commands/hooks/uninstall.d.ts.map +0 -1
- package/dist/commands/import.d.ts +0 -17
- package/dist/commands/import.d.ts.map +0 -1
- package/dist/commands/instructions/create.d.ts +0 -17
- package/dist/commands/instructions/create.d.ts.map +0 -1
- package/dist/commands/instructions/delete.d.ts +0 -13
- package/dist/commands/instructions/delete.d.ts.map +0 -1
- package/dist/commands/instructions/fork.d.ts +0 -10
- package/dist/commands/instructions/fork.d.ts.map +0 -1
- package/dist/commands/instructions/get.d.ts +0 -15
- package/dist/commands/instructions/get.d.ts.map +0 -1
- package/dist/commands/instructions/list.d.ts +0 -12
- package/dist/commands/instructions/list.d.ts.map +0 -1
- package/dist/commands/instructions/promote.d.ts +0 -14
- package/dist/commands/instructions/promote.d.ts.map +0 -1
- package/dist/commands/instructions/pull.d.ts +0 -9
- package/dist/commands/instructions/pull.d.ts.map +0 -1
- package/dist/commands/instructions/upstream.d.ts +0 -9
- package/dist/commands/instructions/upstream.d.ts.map +0 -1
- package/dist/commands/instructions/versions.d.ts +0 -12
- package/dist/commands/instructions/versions.d.ts.map +0 -1
- package/dist/commands/org/current.d.ts +0 -7
- package/dist/commands/org/current.d.ts.map +0 -1
- package/dist/commands/org/list.d.ts +0 -7
- package/dist/commands/org/list.d.ts.map +0 -1
- package/dist/commands/org/switch.d.ts +0 -13
- package/dist/commands/org/switch.d.ts.map +0 -1
- package/dist/commands/packs/add-instruction.d.ts +0 -11
- package/dist/commands/packs/add-instruction.d.ts.map +0 -1
- package/dist/commands/packs/apply.d.ts +0 -13
- package/dist/commands/packs/apply.d.ts.map +0 -1
- package/dist/commands/packs/create.d.ts +0 -13
- package/dist/commands/packs/create.d.ts.map +0 -1
- package/dist/commands/packs/fork.d.ts +0 -10
- package/dist/commands/packs/fork.d.ts.map +0 -1
- package/dist/commands/packs/get.d.ts +0 -10
- package/dist/commands/packs/get.d.ts.map +0 -1
- package/dist/commands/packs/list.d.ts +0 -22
- package/dist/commands/packs/list.d.ts.map +0 -1
- package/dist/commands/packs/remove-instruction.d.ts +0 -11
- package/dist/commands/packs/remove-instruction.d.ts.map +0 -1
- package/dist/commands/proxy/env.d.ts +0 -14
- package/dist/commands/proxy/env.d.ts.map +0 -1
- package/dist/commands/proxy/logs.d.ts +0 -11
- package/dist/commands/proxy/logs.d.ts.map +0 -1
- package/dist/commands/proxy/restart.d.ts +0 -11
- package/dist/commands/proxy/restart.d.ts.map +0 -1
- package/dist/commands/proxy/setup.d.ts +0 -23
- package/dist/commands/proxy/setup.d.ts.map +0 -1
- package/dist/commands/proxy/start.d.ts +0 -17
- package/dist/commands/proxy/start.d.ts.map +0 -1
- package/dist/commands/proxy/status.d.ts +0 -7
- package/dist/commands/proxy/status.d.ts.map +0 -1
- package/dist/commands/proxy/stop.d.ts +0 -8
- package/dist/commands/proxy/stop.d.ts.map +0 -1
- package/dist/commands/service/install.d.ts +0 -33
- package/dist/commands/service/install.d.ts.map +0 -1
- package/dist/commands/service/install.test.d.ts +0 -2
- package/dist/commands/service/install.test.d.ts.map +0 -1
- package/dist/commands/service/install.test.js +0 -345
- package/dist/commands/service/install.test.js.map +0 -1
- package/dist/commands/service/status.d.ts +0 -6
- package/dist/commands/service/status.d.ts.map +0 -1
- package/dist/commands/service/uninstall.d.ts +0 -6
- package/dist/commands/service/uninstall.d.ts.map +0 -1
- package/dist/commands/sessions/analyze.d.ts +0 -10
- package/dist/commands/sessions/analyze.d.ts.map +0 -1
- package/dist/commands/sessions/end.d.ts +0 -9
- package/dist/commands/sessions/end.d.ts.map +0 -1
- package/dist/commands/sessions/import.d.ts +0 -13
- package/dist/commands/sessions/import.d.ts.map +0 -1
- package/dist/commands/sessions/list.d.ts +0 -11
- package/dist/commands/sessions/list.d.ts.map +0 -1
- package/dist/commands/sessions/start.d.ts +0 -11
- package/dist/commands/sessions/start.d.ts.map +0 -1
- package/dist/commands/signals/report.d.ts +0 -10
- package/dist/commands/signals/report.d.ts.map +0 -1
- package/dist/commands/signals/report.test.d.ts +0 -2
- package/dist/commands/signals/report.test.d.ts.map +0 -1
- package/dist/commands/signals/report.test.js +0 -65
- package/dist/commands/signals/report.test.js.map +0 -1
- package/dist/commands/skills/export-approved.d.ts +0 -10
- package/dist/commands/skills/export-approved.d.ts.map +0 -1
- package/dist/commands/skills/install.d.ts +0 -15
- package/dist/commands/skills/install.d.ts.map +0 -1
- package/dist/commands/skills/list.d.ts +0 -11
- package/dist/commands/skills/list.d.ts.map +0 -1
- package/dist/commands/skills/publish.d.ts +0 -17
- package/dist/commands/skills/publish.d.ts.map +0 -1
- package/dist/commands/skills/search.d.ts +0 -17
- package/dist/commands/skills/search.d.ts.map +0 -1
- package/dist/commands/skills/update.d.ts +0 -10
- package/dist/commands/skills/update.d.ts.map +0 -1
- package/dist/commands/suggestions/accept.d.ts +0 -16
- package/dist/commands/suggestions/accept.d.ts.map +0 -1
- package/dist/commands/suggestions/accept.test.d.ts +0 -2
- package/dist/commands/suggestions/accept.test.d.ts.map +0 -1
- package/dist/commands/suggestions/accept.test.js +0 -52
- package/dist/commands/suggestions/accept.test.js.map +0 -1
- package/dist/commands/suggestions/dismiss.d.ts +0 -10
- package/dist/commands/suggestions/dismiss.d.ts.map +0 -1
- package/dist/commands/suggestions/list.d.ts +0 -10
- package/dist/commands/suggestions/list.d.ts.map +0 -1
- package/dist/commands/suggestions/refresh.d.ts +0 -7
- package/dist/commands/suggestions/refresh.d.ts.map +0 -1
- package/dist/dashboard/Dashboard.d.ts +0 -3
- package/dist/dashboard/Dashboard.d.ts.map +0 -1
- package/dist/dashboard/data.d.ts +0 -11
- package/dist/dashboard/data.d.ts.map +0 -1
- package/dist/dashboard/panels/friction.d.ts +0 -7
- package/dist/dashboard/panels/friction.d.ts.map +0 -1
- package/dist/dashboard/panels/insights.d.ts +0 -8
- package/dist/dashboard/panels/insights.d.ts.map +0 -1
- package/dist/dashboard/panels/instructions.d.ts +0 -9
- package/dist/dashboard/panels/instructions.d.ts.map +0 -1
- package/dist/dashboard/panels/outcomes.d.ts +0 -7
- package/dist/dashboard/panels/outcomes.d.ts.map +0 -1
- package/dist/dashboard/panels/overview.d.ts +0 -8
- package/dist/dashboard/panels/overview.d.ts.map +0 -1
- package/dist/dashboard/panels/shared.d.ts +0 -17
- package/dist/dashboard/panels/shared.d.ts.map +0 -1
- package/dist/dashboard/types.d.ts +0 -80
- package/dist/dashboard/types.d.ts.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/active-org-refresh.d.ts +0 -22
- package/dist/lib/active-org-refresh.d.ts.map +0 -1
- package/dist/lib/active-org-refresh.test.d.ts +0 -2
- package/dist/lib/active-org-refresh.test.d.ts.map +0 -1
- package/dist/lib/active-org-refresh.test.js +0 -190
- package/dist/lib/active-org-refresh.test.js.map +0 -1
- package/dist/lib/active-org.d.ts +0 -43
- package/dist/lib/active-org.d.ts.map +0 -1
- package/dist/lib/active-org.test.d.ts +0 -2
- package/dist/lib/active-org.test.d.ts.map +0 -1
- package/dist/lib/active-org.test.js +0 -147
- package/dist/lib/active-org.test.js.map +0 -1
- package/dist/lib/api-client.d.ts +0 -17
- package/dist/lib/api-client.d.ts.map +0 -1
- package/dist/lib/api-client.test.d.ts +0 -2
- package/dist/lib/api-client.test.d.ts.map +0 -1
- package/dist/lib/api-client.test.js +0 -161
- package/dist/lib/api-client.test.js.map +0 -1
- package/dist/lib/auth.d.ts +0 -27
- package/dist/lib/auth.d.ts.map +0 -1
- package/dist/lib/auth.test.d.ts +0 -2
- package/dist/lib/auth.test.d.ts.map +0 -1
- package/dist/lib/auth.test.js +0 -110
- package/dist/lib/auth.test.js.map +0 -1
- package/dist/lib/cron-registry.d.ts +0 -47
- package/dist/lib/cron-registry.d.ts.map +0 -1
- package/dist/lib/cron-registry.js +0 -102
- package/dist/lib/cron-registry.js.map +0 -1
- package/dist/lib/cron-registry.test.d.ts +0 -2
- package/dist/lib/cron-registry.test.d.ts.map +0 -1
- package/dist/lib/cron-registry.test.js +0 -136
- package/dist/lib/cron-registry.test.js.map +0 -1
- package/dist/lib/cron-runner.d.ts +0 -16
- package/dist/lib/cron-runner.d.ts.map +0 -1
- package/dist/lib/cron-runner.js +0 -68
- package/dist/lib/cron-runner.js.map +0 -1
- package/dist/lib/detect-languages.d.ts +0 -7
- package/dist/lib/detect-languages.d.ts.map +0 -1
- package/dist/lib/detect-languages.test.d.ts +0 -2
- package/dist/lib/detect-languages.test.d.ts.map +0 -1
- package/dist/lib/detect-languages.test.js +0 -29
- package/dist/lib/detect-languages.test.js.map +0 -1
- package/dist/lib/eval-analyzer.d.ts +0 -23
- package/dist/lib/eval-analyzer.d.ts.map +0 -1
- package/dist/lib/eval-benchmark.d.ts +0 -17
- package/dist/lib/eval-benchmark.d.ts.map +0 -1
- package/dist/lib/eval-conversation-handler.d.ts +0 -9
- package/dist/lib/eval-conversation-handler.d.ts.map +0 -1
- package/dist/lib/eval-executor.d.ts +0 -21
- package/dist/lib/eval-executor.d.ts.map +0 -1
- package/dist/lib/eval-executor.test.d.ts +0 -2
- package/dist/lib/eval-executor.test.d.ts.map +0 -1
- package/dist/lib/eval-executor.test.js +0 -8
- package/dist/lib/eval-executor.test.js.map +0 -1
- package/dist/lib/eval-grader.d.ts +0 -38
- package/dist/lib/eval-grader.d.ts.map +0 -1
- package/dist/lib/eval-grader.test.d.ts +0 -2
- package/dist/lib/eval-grader.test.d.ts.map +0 -1
- package/dist/lib/eval-grader.test.js +0 -8
- package/dist/lib/eval-grader.test.js.map +0 -1
- package/dist/lib/eval-meta-judge.d.ts +0 -28
- package/dist/lib/eval-meta-judge.d.ts.map +0 -1
- package/dist/lib/eval-trigger-tester.d.ts +0 -19
- package/dist/lib/eval-trigger-tester.d.ts.map +0 -1
- package/dist/lib/eval-worktree.d.ts +0 -11
- package/dist/lib/eval-worktree.d.ts.map +0 -1
- package/dist/lib/eval-worktree.test.d.ts +0 -2
- package/dist/lib/eval-worktree.test.d.ts.map +0 -1
- package/dist/lib/eval-worktree.test.js +0 -68
- package/dist/lib/eval-worktree.test.js.map +0 -1
- package/dist/lib/gateway-entry.d.ts +0 -3
- package/dist/lib/gateway-entry.d.ts.map +0 -1
- package/dist/lib/gateway-lifecycle.d.ts +0 -9
- package/dist/lib/gateway-lifecycle.d.ts.map +0 -1
- package/dist/lib/gateway.d.ts +0 -11
- package/dist/lib/gateway.d.ts.map +0 -1
- package/dist/lib/graphile-worker-runner.d.ts +0 -124
- package/dist/lib/graphile-worker-runner.d.ts.map +0 -1
- package/dist/lib/graphile-worker-runner.js +0 -530
- package/dist/lib/graphile-worker-runner.js.map +0 -1
- package/dist/lib/graphile-worker-runner.test.d.ts +0 -2
- package/dist/lib/graphile-worker-runner.test.d.ts.map +0 -1
- package/dist/lib/graphile-worker-runner.test.js +0 -153
- package/dist/lib/graphile-worker-runner.test.js.map +0 -1
- package/dist/lib/handlers/cron-close-stale-sessions.d.ts +0 -3
- package/dist/lib/handlers/cron-close-stale-sessions.d.ts.map +0 -1
- package/dist/lib/handlers/cron-data-integrity-audit.d.ts +0 -3
- package/dist/lib/handlers/cron-data-integrity-audit.d.ts.map +0 -1
- package/dist/lib/handlers/cron-refresh-skills.d.ts +0 -3
- package/dist/lib/handlers/cron-refresh-skills.d.ts.map +0 -1
- package/dist/lib/handlers/cron-refresh-skills.test.d.ts +0 -2
- package/dist/lib/handlers/cron-refresh-skills.test.d.ts.map +0 -1
- package/dist/lib/handlers/cron-refresh-skills.test.js +0 -114
- package/dist/lib/handlers/cron-refresh-skills.test.js.map +0 -1
- package/dist/lib/handlers/cron-regenerate-insights.d.ts +0 -3
- package/dist/lib/handlers/cron-regenerate-insights.d.ts.map +0 -1
- package/dist/lib/handlers/cron-regenerate-insights.js +0 -6
- package/dist/lib/handlers/cron-regenerate-insights.js.map +0 -1
- package/dist/lib/handlers/cron-suggest-instructions.d.ts +0 -3
- package/dist/lib/handlers/cron-suggest-instructions.d.ts.map +0 -1
- package/dist/lib/handlers/cron-suggest-instructions.test.d.ts +0 -2
- package/dist/lib/handlers/cron-suggest-instructions.test.d.ts.map +0 -1
- package/dist/lib/handlers/cron-suggest-instructions.test.js +0 -80
- package/dist/lib/handlers/cron-suggest-instructions.test.js.map +0 -1
- package/dist/lib/handlers/process-conversation.d.ts +0 -35
- package/dist/lib/handlers/process-conversation.d.ts.map +0 -1
- package/dist/lib/handlers/process-eval.d.ts +0 -32
- package/dist/lib/handlers/process-eval.d.ts.map +0 -1
- package/dist/lib/handlers/process-insights.d.ts +0 -39
- package/dist/lib/handlers/process-insights.d.ts.map +0 -1
- package/dist/lib/handlers/process-launch.d.ts +0 -29
- package/dist/lib/handlers/process-launch.d.ts.map +0 -1
- package/dist/lib/handlers/process-session-goal.d.ts +0 -29
- package/dist/lib/handlers/process-session-goal.d.ts.map +0 -1
- package/dist/lib/handlers/process-session-goal.test.d.ts +0 -2
- package/dist/lib/handlers/process-session-goal.test.d.ts.map +0 -1
- package/dist/lib/handlers/process-session-goal.test.js +0 -134
- package/dist/lib/handlers/process-session-goal.test.js.map +0 -1
- package/dist/lib/hooks-config.d.ts +0 -119
- package/dist/lib/hooks-config.d.ts.map +0 -1
- package/dist/lib/hooks-config.test.d.ts +0 -2
- package/dist/lib/hooks-config.test.d.ts.map +0 -1
- package/dist/lib/hooks-config.test.js +0 -231
- package/dist/lib/hooks-config.test.js.map +0 -1
- package/dist/lib/insights-prompts.d.ts +0 -13
- package/dist/lib/insights-prompts.d.ts.map +0 -1
- package/dist/lib/llm-client.d.ts +0 -26
- package/dist/lib/llm-client.d.ts.map +0 -1
- package/dist/lib/llm-client.test.d.ts +0 -2
- package/dist/lib/llm-client.test.d.ts.map +0 -1
- package/dist/lib/llm-client.test.js +0 -62
- package/dist/lib/llm-client.test.js.map +0 -1
- package/dist/lib/mirror-writer-db.d.ts +0 -12
- package/dist/lib/mirror-writer-db.d.ts.map +0 -1
- package/dist/lib/mirror-writer-db.js +0 -51
- package/dist/lib/mirror-writer-db.js.map +0 -1
- package/dist/lib/mirror-writer.d.ts +0 -35
- package/dist/lib/mirror-writer.d.ts.map +0 -1
- package/dist/lib/mirror-writer.js +0 -27
- package/dist/lib/mirror-writer.js.map +0 -1
- package/dist/lib/mirror-writer.test.d.ts +0 -2
- package/dist/lib/mirror-writer.test.d.ts.map +0 -1
- package/dist/lib/mirror-writer.test.js +0 -47
- package/dist/lib/mirror-writer.test.js.map +0 -1
- package/dist/lib/output.d.ts +0 -4
- package/dist/lib/output.d.ts.map +0 -1
- package/dist/lib/output.test.d.ts +0 -2
- package/dist/lib/output.test.d.ts.map +0 -1
- package/dist/lib/output.test.js +0 -71
- package/dist/lib/output.test.js.map +0 -1
- package/dist/lib/permanent-job-error.d.ts +0 -17
- package/dist/lib/permanent-job-error.d.ts.map +0 -1
- package/dist/lib/permanent-job-error.test.d.ts +0 -2
- package/dist/lib/permanent-job-error.test.d.ts.map +0 -1
- package/dist/lib/permanent-job-error.test.js +0 -29
- package/dist/lib/permanent-job-error.test.js.map +0 -1
- package/dist/lib/provider-aggregator.d.ts +0 -24
- package/dist/lib/provider-aggregator.d.ts.map +0 -1
- package/dist/lib/provider-aggregator.test.d.ts +0 -2
- package/dist/lib/provider-aggregator.test.d.ts.map +0 -1
- package/dist/lib/provider-aggregator.test.js +0 -103
- package/dist/lib/provider-aggregator.test.js.map +0 -1
- package/dist/lib/skills-loader.d.ts +0 -6
- package/dist/lib/skills-loader.d.ts.map +0 -1
- package/dist/lib/types.d.ts +0 -48
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/version-check.d.ts +0 -11
- package/dist/lib/version-check.d.ts.map +0 -1
- package/dist/test-helpers.d.ts +0 -58
- package/dist/test-helpers.d.ts.map +0 -1
- package/dist/test-helpers.js +0 -58
- package/dist/test-helpers.js.map +0 -1
|
@@ -0,0 +1,1788 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-NSBPE2FW.js";
|
|
4
|
+
|
|
5
|
+
// ../../packages/session/dist/types.js
|
|
6
|
+
var SESSION_TOOLS = ["claude_code", "cursor", "vscode_copilot", "copilot_agent", "rulemetric_mcp", "codex", "pi", "opencode", "antigravity"];
|
|
7
|
+
var SESSION_EVENT_TYPES = [
|
|
8
|
+
"user_message",
|
|
9
|
+
"assistant_message",
|
|
10
|
+
"tool_call",
|
|
11
|
+
"tool_result",
|
|
12
|
+
"thinking",
|
|
13
|
+
"error"
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
// ../../packages/session/dist/adapters/claude-code.js
|
|
17
|
+
var ClaudeCodeAdapter = class {
|
|
18
|
+
tool = "claude_code";
|
|
19
|
+
parse(input) {
|
|
20
|
+
const lines = input.split("\n").filter((line) => line.trim());
|
|
21
|
+
const records = [];
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
try {
|
|
24
|
+
records.push(JSON.parse(line));
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const messageRecords = records.filter((r) => r.type === "user" || r.type === "assistant");
|
|
29
|
+
let projectPath = null;
|
|
30
|
+
let gitBranch = null;
|
|
31
|
+
const metadata = {};
|
|
32
|
+
const firstUser = records.find((r) => r.type === "user");
|
|
33
|
+
if (firstUser) {
|
|
34
|
+
projectPath = firstUser.cwd ?? null;
|
|
35
|
+
gitBranch = firstUser.gitBranch ?? null;
|
|
36
|
+
if (firstUser.version)
|
|
37
|
+
metadata.claudeCodeVersion = firstUser.version;
|
|
38
|
+
if (firstUser.sessionId)
|
|
39
|
+
metadata.sessionId = firstUser.sessionId;
|
|
40
|
+
}
|
|
41
|
+
const firstAssistant = records.find((r) => r.type === "assistant");
|
|
42
|
+
if (firstAssistant?.message?.model)
|
|
43
|
+
metadata.model = firstAssistant.message.model;
|
|
44
|
+
const events = [];
|
|
45
|
+
let sequence = 0;
|
|
46
|
+
for (const record of messageRecords) {
|
|
47
|
+
const timestamp = record.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
48
|
+
if (record.type === "user") {
|
|
49
|
+
const messageContent = record.message?.content;
|
|
50
|
+
if (typeof messageContent === "string") {
|
|
51
|
+
events.push({
|
|
52
|
+
sequence: sequence++,
|
|
53
|
+
eventType: "user_message",
|
|
54
|
+
content: messageContent,
|
|
55
|
+
toolName: null,
|
|
56
|
+
toolInput: null,
|
|
57
|
+
toolOutput: null,
|
|
58
|
+
tokenUsage: null,
|
|
59
|
+
timestamp,
|
|
60
|
+
metadata: {}
|
|
61
|
+
});
|
|
62
|
+
} else if (Array.isArray(messageContent)) {
|
|
63
|
+
for (const block of messageContent) {
|
|
64
|
+
if (block.type === "tool_result") {
|
|
65
|
+
events.push({
|
|
66
|
+
sequence: sequence++,
|
|
67
|
+
eventType: "tool_result",
|
|
68
|
+
content: typeof block.content === "string" ? block.content : JSON.stringify(block.content),
|
|
69
|
+
toolName: null,
|
|
70
|
+
toolInput: null,
|
|
71
|
+
toolOutput: null,
|
|
72
|
+
tokenUsage: null,
|
|
73
|
+
timestamp,
|
|
74
|
+
metadata: { toolUseId: block.tool_use_id }
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} else if (record.type === "assistant") {
|
|
80
|
+
const contentBlocks = Array.isArray(record.message?.content) ? record.message.content : [];
|
|
81
|
+
const usage = record.message?.usage;
|
|
82
|
+
const tokenUsage = usage ? {
|
|
83
|
+
input: usage.input_tokens ?? 0,
|
|
84
|
+
output: usage.output_tokens ?? 0,
|
|
85
|
+
cacheRead: usage.cache_read_input_tokens ?? 0,
|
|
86
|
+
cacheWrite: usage.cache_creation_input_tokens ?? 0
|
|
87
|
+
} : null;
|
|
88
|
+
const assistantMeta = {};
|
|
89
|
+
if (record.message?.model)
|
|
90
|
+
assistantMeta.model = record.message.model;
|
|
91
|
+
if (record.message?.stop_reason)
|
|
92
|
+
assistantMeta.stopReason = record.message.stop_reason;
|
|
93
|
+
if (record.requestId)
|
|
94
|
+
assistantMeta.requestId = record.requestId;
|
|
95
|
+
if (usage?.service_tier)
|
|
96
|
+
assistantMeta.serviceTier = usage.service_tier;
|
|
97
|
+
if (usage?.speed)
|
|
98
|
+
assistantMeta.speed = usage.speed;
|
|
99
|
+
if (usage?.cache_creation)
|
|
100
|
+
assistantMeta.cacheCreationDetail = usage.cache_creation;
|
|
101
|
+
if (usage?.server_tool_use)
|
|
102
|
+
assistantMeta.serverToolUse = usage.server_tool_use;
|
|
103
|
+
for (const block of contentBlocks) {
|
|
104
|
+
if (block.type === "text") {
|
|
105
|
+
events.push({
|
|
106
|
+
sequence: sequence++,
|
|
107
|
+
eventType: "assistant_message",
|
|
108
|
+
content: block.text ?? "",
|
|
109
|
+
toolName: null,
|
|
110
|
+
toolInput: null,
|
|
111
|
+
toolOutput: null,
|
|
112
|
+
tokenUsage,
|
|
113
|
+
timestamp,
|
|
114
|
+
metadata: assistantMeta
|
|
115
|
+
});
|
|
116
|
+
} else if (block.type === "thinking") {
|
|
117
|
+
events.push({
|
|
118
|
+
sequence: sequence++,
|
|
119
|
+
eventType: "thinking",
|
|
120
|
+
content: block.thinking ?? "",
|
|
121
|
+
toolName: null,
|
|
122
|
+
toolInput: null,
|
|
123
|
+
toolOutput: null,
|
|
124
|
+
tokenUsage,
|
|
125
|
+
timestamp,
|
|
126
|
+
metadata: assistantMeta
|
|
127
|
+
});
|
|
128
|
+
} else if (block.type === "tool_use") {
|
|
129
|
+
events.push({
|
|
130
|
+
sequence: sequence++,
|
|
131
|
+
eventType: "tool_call",
|
|
132
|
+
content: null,
|
|
133
|
+
toolName: block.name ?? "unknown",
|
|
134
|
+
toolInput: block.input ?? null,
|
|
135
|
+
toolOutput: null,
|
|
136
|
+
tokenUsage,
|
|
137
|
+
timestamp,
|
|
138
|
+
metadata: { ...assistantMeta, toolUseId: block.id }
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const timestamps = events.map((e) => e.timestamp).sort();
|
|
145
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
146
|
+
return {
|
|
147
|
+
tool: "claude_code",
|
|
148
|
+
projectPath,
|
|
149
|
+
gitBranch,
|
|
150
|
+
startedAt: timestamps[0] ?? now,
|
|
151
|
+
endedAt: timestamps[timestamps.length - 1] ?? null,
|
|
152
|
+
events,
|
|
153
|
+
metadata
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// ../../packages/session/dist/adapters/cursor.js
|
|
159
|
+
var CursorAdapter = class {
|
|
160
|
+
tool = "cursor";
|
|
161
|
+
/**
|
|
162
|
+
* Parse from a SQLite database file path.
|
|
163
|
+
* Reads `composer.composerData` from the ItemTable.
|
|
164
|
+
*/
|
|
165
|
+
parse(dbPath) {
|
|
166
|
+
const Database = __require("better-sqlite3");
|
|
167
|
+
const db = new Database(dbPath, { readonly: true });
|
|
168
|
+
try {
|
|
169
|
+
const row = db.prepare("SELECT value FROM ItemTable WHERE key = 'composer.composerData'").get();
|
|
170
|
+
if (!row) {
|
|
171
|
+
return this.emptySession();
|
|
172
|
+
}
|
|
173
|
+
return this.parseComposerJson(row.value);
|
|
174
|
+
} finally {
|
|
175
|
+
db.close();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Parse from raw composer data JSON (for testing without SQLite).
|
|
180
|
+
*/
|
|
181
|
+
parseComposerJson(json) {
|
|
182
|
+
let data;
|
|
183
|
+
try {
|
|
184
|
+
data = JSON.parse(json);
|
|
185
|
+
} catch {
|
|
186
|
+
return this.emptySession();
|
|
187
|
+
}
|
|
188
|
+
const composers = Object.values(data.allComposers ?? {});
|
|
189
|
+
if (composers.length === 0) {
|
|
190
|
+
return this.emptySession();
|
|
191
|
+
}
|
|
192
|
+
const composer = composers.sort((a, b) => {
|
|
193
|
+
const aTime = a.createdAt ? new Date(a.createdAt).getTime() : 0;
|
|
194
|
+
const bTime = b.createdAt ? new Date(b.createdAt).getTime() : 0;
|
|
195
|
+
return bTime - aTime;
|
|
196
|
+
})[0];
|
|
197
|
+
const bubbles = composer.conversation ?? [];
|
|
198
|
+
const events = [];
|
|
199
|
+
for (let i = 0; i < bubbles.length; i++) {
|
|
200
|
+
const bubble = bubbles[i];
|
|
201
|
+
const timestamp = bubble.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
202
|
+
events.push({
|
|
203
|
+
sequence: i,
|
|
204
|
+
eventType: bubble.type === 1 ? "user_message" : "assistant_message",
|
|
205
|
+
content: bubble.text,
|
|
206
|
+
toolName: null,
|
|
207
|
+
toolInput: null,
|
|
208
|
+
toolOutput: null,
|
|
209
|
+
tokenUsage: null,
|
|
210
|
+
timestamp,
|
|
211
|
+
metadata: {}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const timestamps = events.map((e) => e.timestamp).sort();
|
|
215
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
216
|
+
return {
|
|
217
|
+
tool: "cursor",
|
|
218
|
+
projectPath: null,
|
|
219
|
+
gitBranch: null,
|
|
220
|
+
startedAt: timestamps[0] ?? now,
|
|
221
|
+
endedAt: timestamps[timestamps.length - 1] ?? null,
|
|
222
|
+
events,
|
|
223
|
+
metadata: { composerId: composer.composerId }
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
emptySession() {
|
|
227
|
+
return {
|
|
228
|
+
tool: "cursor",
|
|
229
|
+
projectPath: null,
|
|
230
|
+
gitBranch: null,
|
|
231
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
232
|
+
endedAt: null,
|
|
233
|
+
events: [],
|
|
234
|
+
metadata: {}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// ../../packages/session/dist/adapters/vscode-copilot.js
|
|
240
|
+
var VSCodeCopilotAdapter = class {
|
|
241
|
+
tool = "vscode_copilot";
|
|
242
|
+
parse(input) {
|
|
243
|
+
let data;
|
|
244
|
+
try {
|
|
245
|
+
data = JSON.parse(input);
|
|
246
|
+
} catch {
|
|
247
|
+
return this.emptySession();
|
|
248
|
+
}
|
|
249
|
+
const requests = data.requests ?? [];
|
|
250
|
+
const events = [];
|
|
251
|
+
let sequence = 0;
|
|
252
|
+
for (const req of requests) {
|
|
253
|
+
const userTimestamp = req.timestamp ? new Date(req.timestamp).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
|
|
254
|
+
events.push({
|
|
255
|
+
sequence: sequence++,
|
|
256
|
+
eventType: "user_message",
|
|
257
|
+
content: req.message,
|
|
258
|
+
toolName: null,
|
|
259
|
+
toolInput: null,
|
|
260
|
+
toolOutput: null,
|
|
261
|
+
tokenUsage: null,
|
|
262
|
+
timestamp: userTimestamp,
|
|
263
|
+
metadata: {}
|
|
264
|
+
});
|
|
265
|
+
if (req.response) {
|
|
266
|
+
const assistantTimestamp = req.response.timestamp ? new Date(req.response.timestamp).toISOString() : userTimestamp;
|
|
267
|
+
events.push({
|
|
268
|
+
sequence: sequence++,
|
|
269
|
+
eventType: "assistant_message",
|
|
270
|
+
content: req.response.message,
|
|
271
|
+
toolName: null,
|
|
272
|
+
toolInput: null,
|
|
273
|
+
toolOutput: null,
|
|
274
|
+
tokenUsage: null,
|
|
275
|
+
timestamp: assistantTimestamp,
|
|
276
|
+
metadata: {}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const timestamps = events.map((e) => e.timestamp).sort();
|
|
281
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
282
|
+
return {
|
|
283
|
+
tool: "vscode_copilot",
|
|
284
|
+
projectPath: null,
|
|
285
|
+
gitBranch: null,
|
|
286
|
+
startedAt: timestamps[0] ?? now,
|
|
287
|
+
endedAt: timestamps[timestamps.length - 1] ?? null,
|
|
288
|
+
events,
|
|
289
|
+
metadata: {
|
|
290
|
+
...data.requesterUsername && { username: data.requesterUsername },
|
|
291
|
+
...data.customTitle && { title: data.customTitle }
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
emptySession() {
|
|
296
|
+
return {
|
|
297
|
+
tool: "vscode_copilot",
|
|
298
|
+
projectPath: null,
|
|
299
|
+
gitBranch: null,
|
|
300
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
301
|
+
endedAt: null,
|
|
302
|
+
events: [],
|
|
303
|
+
metadata: {}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// ../../packages/session/dist/adapters/copilot-agent.js
|
|
309
|
+
var CopilotAgentAdapter = class {
|
|
310
|
+
tool = "copilot_agent";
|
|
311
|
+
parse(input) {
|
|
312
|
+
let data;
|
|
313
|
+
try {
|
|
314
|
+
data = JSON.parse(input);
|
|
315
|
+
} catch {
|
|
316
|
+
return this.emptySession();
|
|
317
|
+
}
|
|
318
|
+
const requests = data.requests ?? [];
|
|
319
|
+
const events = [];
|
|
320
|
+
let sequence = 0;
|
|
321
|
+
for (const req of requests) {
|
|
322
|
+
const userTimestamp = req.timestamp ? new Date(req.timestamp).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
|
|
323
|
+
events.push({
|
|
324
|
+
sequence: sequence++,
|
|
325
|
+
eventType: "user_message",
|
|
326
|
+
content: req.message,
|
|
327
|
+
toolName: null,
|
|
328
|
+
toolInput: null,
|
|
329
|
+
toolOutput: null,
|
|
330
|
+
tokenUsage: null,
|
|
331
|
+
timestamp: userTimestamp,
|
|
332
|
+
metadata: {}
|
|
333
|
+
});
|
|
334
|
+
if (req.toolCalls) {
|
|
335
|
+
for (const tc of req.toolCalls) {
|
|
336
|
+
const toolTimestamp = tc.timestamp ? new Date(tc.timestamp).toISOString() : userTimestamp;
|
|
337
|
+
events.push({
|
|
338
|
+
sequence: sequence++,
|
|
339
|
+
eventType: "tool_call",
|
|
340
|
+
content: null,
|
|
341
|
+
toolName: tc.name ?? "unknown",
|
|
342
|
+
toolInput: tc.input ?? null,
|
|
343
|
+
toolOutput: tc.output ?? null,
|
|
344
|
+
tokenUsage: null,
|
|
345
|
+
timestamp: toolTimestamp,
|
|
346
|
+
metadata: {}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (req.response) {
|
|
351
|
+
const assistantTimestamp = req.response.timestamp ? new Date(req.response.timestamp).toISOString() : userTimestamp;
|
|
352
|
+
events.push({
|
|
353
|
+
sequence: sequence++,
|
|
354
|
+
eventType: "assistant_message",
|
|
355
|
+
content: req.response.message,
|
|
356
|
+
toolName: null,
|
|
357
|
+
toolInput: null,
|
|
358
|
+
toolOutput: null,
|
|
359
|
+
tokenUsage: null,
|
|
360
|
+
timestamp: assistantTimestamp,
|
|
361
|
+
metadata: {}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const timestamps = events.map((e) => e.timestamp).sort();
|
|
366
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
367
|
+
return {
|
|
368
|
+
tool: "copilot_agent",
|
|
369
|
+
projectPath: null,
|
|
370
|
+
gitBranch: null,
|
|
371
|
+
startedAt: timestamps[0] ?? now,
|
|
372
|
+
endedAt: timestamps[timestamps.length - 1] ?? null,
|
|
373
|
+
events,
|
|
374
|
+
metadata: {
|
|
375
|
+
...data.requesterUsername && { username: data.requesterUsername },
|
|
376
|
+
...data.customTitle && { title: data.customTitle },
|
|
377
|
+
...data.agentMode != null && { agentMode: data.agentMode }
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
emptySession() {
|
|
382
|
+
return {
|
|
383
|
+
tool: "copilot_agent",
|
|
384
|
+
projectPath: null,
|
|
385
|
+
gitBranch: null,
|
|
386
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
387
|
+
endedAt: null,
|
|
388
|
+
events: [],
|
|
389
|
+
metadata: {}
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// ../../packages/session/dist/adapters/rulemetric-mcp.js
|
|
395
|
+
var RuleMetricMcpAdapter = class {
|
|
396
|
+
tool = "rulemetric_mcp";
|
|
397
|
+
parse(input) {
|
|
398
|
+
let data;
|
|
399
|
+
try {
|
|
400
|
+
data = JSON.parse(input);
|
|
401
|
+
} catch {
|
|
402
|
+
return this.emptySession();
|
|
403
|
+
}
|
|
404
|
+
const rawEvents = data.events ?? [];
|
|
405
|
+
const events = rawEvents.map((e, i) => ({
|
|
406
|
+
sequence: e.sequence ?? i,
|
|
407
|
+
eventType: this.normalizeEventType(e.eventType),
|
|
408
|
+
content: e.content ?? null,
|
|
409
|
+
toolName: e.toolName ?? null,
|
|
410
|
+
toolInput: e.toolInput ?? null,
|
|
411
|
+
toolOutput: e.toolOutput ?? null,
|
|
412
|
+
tokenUsage: e.tokenUsage ?? null,
|
|
413
|
+
timestamp: e.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
414
|
+
metadata: e.metadata ?? {}
|
|
415
|
+
}));
|
|
416
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
417
|
+
return {
|
|
418
|
+
tool: "rulemetric_mcp",
|
|
419
|
+
projectPath: data.projectPath ?? null,
|
|
420
|
+
gitBranch: data.gitBranch ?? null,
|
|
421
|
+
startedAt: data.startedAt ?? events[0]?.timestamp ?? now,
|
|
422
|
+
endedAt: data.endedAt ?? events[events.length - 1]?.timestamp ?? null,
|
|
423
|
+
events,
|
|
424
|
+
metadata: data.metadata ?? {}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
normalizeEventType(type) {
|
|
428
|
+
const valid = ["user_message", "assistant_message", "tool_call", "tool_result", "thinking", "error"];
|
|
429
|
+
if (type && valid.includes(type))
|
|
430
|
+
return type;
|
|
431
|
+
return "assistant_message";
|
|
432
|
+
}
|
|
433
|
+
emptySession() {
|
|
434
|
+
return {
|
|
435
|
+
tool: "rulemetric_mcp",
|
|
436
|
+
projectPath: null,
|
|
437
|
+
gitBranch: null,
|
|
438
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
439
|
+
endedAt: null,
|
|
440
|
+
events: [],
|
|
441
|
+
metadata: {}
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
// ../../packages/session/dist/registry.js
|
|
447
|
+
var adapters = {
|
|
448
|
+
claude_code: () => new ClaudeCodeAdapter(),
|
|
449
|
+
cursor: () => new CursorAdapter(),
|
|
450
|
+
vscode_copilot: () => new VSCodeCopilotAdapter(),
|
|
451
|
+
copilot_agent: () => new CopilotAgentAdapter(),
|
|
452
|
+
rulemetric_mcp: () => new RuleMetricMcpAdapter()
|
|
453
|
+
};
|
|
454
|
+
function getAdapter(tool) {
|
|
455
|
+
const factory = adapters[tool];
|
|
456
|
+
if (!factory) {
|
|
457
|
+
throw new Error(`Unknown session tool: ${tool}`);
|
|
458
|
+
}
|
|
459
|
+
return factory();
|
|
460
|
+
}
|
|
461
|
+
function detectTool(input) {
|
|
462
|
+
const trimmed = input.trim();
|
|
463
|
+
if (trimmed.startsWith("{")) {
|
|
464
|
+
const firstLine = trimmed.split("\n")[0];
|
|
465
|
+
let parsed = null;
|
|
466
|
+
try {
|
|
467
|
+
parsed = JSON.parse(firstLine);
|
|
468
|
+
} catch {
|
|
469
|
+
try {
|
|
470
|
+
parsed = JSON.parse(trimmed);
|
|
471
|
+
} catch {
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (parsed) {
|
|
475
|
+
if (parsed.type === "user" || parsed.type === "assistant") {
|
|
476
|
+
return "claude_code";
|
|
477
|
+
}
|
|
478
|
+
if (Array.isArray(parsed.events) && !parsed.requests && !parsed.allComposers) {
|
|
479
|
+
return "rulemetric_mcp";
|
|
480
|
+
}
|
|
481
|
+
if (Array.isArray(parsed.requests)) {
|
|
482
|
+
const hasToolCalls = parsed.requests.some((r) => Array.isArray(r.toolCalls));
|
|
483
|
+
if (hasToolCalls || parsed.agentMode) {
|
|
484
|
+
return "copilot_agent";
|
|
485
|
+
}
|
|
486
|
+
return "vscode_copilot";
|
|
487
|
+
}
|
|
488
|
+
if (parsed.allComposers) {
|
|
489
|
+
return "cursor";
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (!parsed) {
|
|
493
|
+
try {
|
|
494
|
+
const lines = trimmed.split("\n").filter((l) => l.trim());
|
|
495
|
+
if (lines.length > 1) {
|
|
496
|
+
const first = JSON.parse(lines[0]);
|
|
497
|
+
if (first.type === "user" || first.type === "assistant") {
|
|
498
|
+
return "claude_code";
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
} catch {
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// ../../packages/session/dist/analyzer.js
|
|
509
|
+
function buildAnalysisPrompt(events, instructions) {
|
|
510
|
+
const instructionSection = instructions.length > 0 ? instructions.map((i) => `### ${i.name} (ID: ${i.id})
|
|
511
|
+
|
|
512
|
+
${i.content}`).join("\n\n---\n\n") : "No instructions were linked to this session.";
|
|
513
|
+
const eventSummary = events.map((e) => {
|
|
514
|
+
const prefix = `[${e.sequence}] ${e.eventType}`;
|
|
515
|
+
if (e.eventType === "tool_call") {
|
|
516
|
+
return `${prefix}: ${e.toolName}(${JSON.stringify(e.toolInput)})`;
|
|
517
|
+
}
|
|
518
|
+
if (e.eventType === "tool_result") {
|
|
519
|
+
const preview2 = e.content?.slice(0, 200) ?? "";
|
|
520
|
+
return `${prefix}: ${preview2}${e.content && e.content.length > 200 ? "..." : ""}`;
|
|
521
|
+
}
|
|
522
|
+
const preview = e.content?.slice(0, 300) ?? "";
|
|
523
|
+
return `${prefix}: ${preview}${e.content && e.content.length > 300 ? "..." : ""}`;
|
|
524
|
+
}).join("\n");
|
|
525
|
+
return `You are analyzing an AI coding session to evaluate how well the agent followed its instructions and to suggest improvements.
|
|
526
|
+
|
|
527
|
+
## Active Instructions
|
|
528
|
+
|
|
529
|
+
${instructionSection}
|
|
530
|
+
|
|
531
|
+
## Session Transcript
|
|
532
|
+
|
|
533
|
+
${eventSummary}
|
|
534
|
+
|
|
535
|
+
## Analysis Tasks
|
|
536
|
+
|
|
537
|
+
1. **Adherence Score** (0-100): Rate how well the agent followed each active instruction. 100 = perfect adherence.
|
|
538
|
+
2. **Deviations**: List specific events where the agent deviated from instructions. Each deviation needs:
|
|
539
|
+
- eventSequence: the event number
|
|
540
|
+
- instructionId: which instruction was violated
|
|
541
|
+
- description: what went wrong
|
|
542
|
+
- severity: "low", "medium", or "high"
|
|
543
|
+
3. **Suggestions**: For each gap or deviation, propose a specific edit to the instruction. Each suggestion needs:
|
|
544
|
+
- instructionId: which instruction to improve
|
|
545
|
+
- currentContent: the relevant excerpt from the instruction
|
|
546
|
+
- suggestedContent: your proposed replacement text
|
|
547
|
+
- rationale: why this change would help
|
|
548
|
+
- confidence: 0-100 how confident you are this would improve outcomes
|
|
549
|
+
4. **Summary**: One paragraph summarizing the session quality.
|
|
550
|
+
|
|
551
|
+
Return your response as JSON matching this schema:
|
|
552
|
+
{
|
|
553
|
+
"adherenceScore": <number 0-100>,
|
|
554
|
+
"deviations": [{ "eventSequence": <number>, "instructionId": "<string>", "description": "<string>", "severity": "<low|medium|high>" }],
|
|
555
|
+
"suggestions": [{ "instructionId": "<string>", "currentContent": "<string>", "suggestedContent": "<string>", "rationale": "<string>", "confidence": <number 0-100> }],
|
|
556
|
+
"summary": "<string>"
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
Return valid JSON only.`;
|
|
560
|
+
}
|
|
561
|
+
function parseAnalysisResponse(response) {
|
|
562
|
+
try {
|
|
563
|
+
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
564
|
+
if (!jsonMatch)
|
|
565
|
+
return null;
|
|
566
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
567
|
+
if (typeof parsed.adherenceScore !== "number" || !Array.isArray(parsed.deviations) || !Array.isArray(parsed.suggestions) || typeof parsed.summary !== "string") {
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
adherenceScore: parsed.adherenceScore,
|
|
572
|
+
deviations: parsed.deviations,
|
|
573
|
+
suggestions: parsed.suggestions,
|
|
574
|
+
summary: parsed.summary,
|
|
575
|
+
analyzedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
576
|
+
};
|
|
577
|
+
} catch {
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// ../../packages/session/dist/providers/claude-code.js
|
|
583
|
+
import { readdir, stat } from "fs/promises";
|
|
584
|
+
import { basename, join } from "path";
|
|
585
|
+
import { homedir } from "os";
|
|
586
|
+
var shortNames = {
|
|
587
|
+
"claude-opus-4-7": "Opus 4.7",
|
|
588
|
+
"claude-opus-4-6": "Opus 4.6",
|
|
589
|
+
"claude-opus-4-5": "Opus 4.5",
|
|
590
|
+
"claude-opus-4-1": "Opus 4.1",
|
|
591
|
+
"claude-opus-4": "Opus 4",
|
|
592
|
+
"claude-sonnet-4-6": "Sonnet 4.6",
|
|
593
|
+
"claude-sonnet-4-5": "Sonnet 4.5",
|
|
594
|
+
"claude-sonnet-4": "Sonnet 4",
|
|
595
|
+
"claude-3-7-sonnet": "Sonnet 3.7",
|
|
596
|
+
"claude-3-5-sonnet": "Sonnet 3.5",
|
|
597
|
+
"claude-haiku-4-5": "Haiku 4.5",
|
|
598
|
+
"claude-3-5-haiku": "Haiku 3.5"
|
|
599
|
+
};
|
|
600
|
+
function getClaudeDir() {
|
|
601
|
+
return process.env["CLAUDE_CONFIG_DIR"] || join(homedir(), ".claude");
|
|
602
|
+
}
|
|
603
|
+
function getProjectsDir() {
|
|
604
|
+
return join(getClaudeDir(), "projects");
|
|
605
|
+
}
|
|
606
|
+
function getDesktopSessionsDir() {
|
|
607
|
+
if (process.platform === "darwin")
|
|
608
|
+
return join(homedir(), "Library", "Application Support", "Claude", "local-agent-mode-sessions");
|
|
609
|
+
if (process.platform === "win32")
|
|
610
|
+
return join(homedir(), "AppData", "Roaming", "Claude", "local-agent-mode-sessions");
|
|
611
|
+
return join(homedir(), ".config", "Claude", "local-agent-mode-sessions");
|
|
612
|
+
}
|
|
613
|
+
async function findDesktopProjectDirs(base) {
|
|
614
|
+
const results = [];
|
|
615
|
+
async function walk(dir, depth) {
|
|
616
|
+
if (depth > 8)
|
|
617
|
+
return;
|
|
618
|
+
const entries = await readdir(dir).catch(() => []);
|
|
619
|
+
for (const entry of entries) {
|
|
620
|
+
if (entry === "node_modules" || entry === ".git")
|
|
621
|
+
continue;
|
|
622
|
+
const full = join(dir, entry);
|
|
623
|
+
const s = await stat(full).catch(() => null);
|
|
624
|
+
if (!s?.isDirectory())
|
|
625
|
+
continue;
|
|
626
|
+
if (entry === "projects") {
|
|
627
|
+
const projectDirs = await readdir(full).catch(() => []);
|
|
628
|
+
for (const pd of projectDirs) {
|
|
629
|
+
const pdFull = join(full, pd);
|
|
630
|
+
const pdStat = await stat(pdFull).catch(() => null);
|
|
631
|
+
if (pdStat?.isDirectory())
|
|
632
|
+
results.push(pdFull);
|
|
633
|
+
}
|
|
634
|
+
} else {
|
|
635
|
+
await walk(full, depth + 1);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
await walk(base, 0);
|
|
640
|
+
return results;
|
|
641
|
+
}
|
|
642
|
+
var claudeCode = {
|
|
643
|
+
name: "claude",
|
|
644
|
+
displayName: "Claude Code",
|
|
645
|
+
modelDisplayName(model) {
|
|
646
|
+
const canonical = model.replace(/@.*$/, "").replace(/-\d{8}$/, "");
|
|
647
|
+
for (const [key, name] of Object.entries(shortNames)) {
|
|
648
|
+
if (canonical.startsWith(key))
|
|
649
|
+
return name;
|
|
650
|
+
}
|
|
651
|
+
return canonical;
|
|
652
|
+
},
|
|
653
|
+
toolDisplayName(rawTool) {
|
|
654
|
+
return rawTool;
|
|
655
|
+
},
|
|
656
|
+
async discoverSessions() {
|
|
657
|
+
const sources = [];
|
|
658
|
+
const projectsDir = getProjectsDir();
|
|
659
|
+
try {
|
|
660
|
+
const entries = await readdir(projectsDir);
|
|
661
|
+
for (const dirName of entries) {
|
|
662
|
+
const dirPath = join(projectsDir, dirName);
|
|
663
|
+
const dirStat = await stat(dirPath).catch(() => null);
|
|
664
|
+
if (dirStat?.isDirectory()) {
|
|
665
|
+
sources.push({ path: dirPath, project: dirName, provider: "claude" });
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
} catch {
|
|
669
|
+
}
|
|
670
|
+
const desktopDirs = await findDesktopProjectDirs(getDesktopSessionsDir());
|
|
671
|
+
for (const dirPath of desktopDirs) {
|
|
672
|
+
sources.push({ path: dirPath, project: basename(dirPath), provider: "claude" });
|
|
673
|
+
}
|
|
674
|
+
return sources;
|
|
675
|
+
},
|
|
676
|
+
createSessionParser() {
|
|
677
|
+
return {
|
|
678
|
+
async *parse() {
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
// ../../packages/session/dist/providers/codex.js
|
|
685
|
+
import { readdir as readdir2, readFile, stat as stat2 } from "fs/promises";
|
|
686
|
+
import { basename as basename2, join as join2 } from "path";
|
|
687
|
+
import { homedir as homedir2 } from "os";
|
|
688
|
+
var modelDisplayNames = {
|
|
689
|
+
"gpt-5.3-codex": "GPT-5.3 Codex",
|
|
690
|
+
"gpt-5.4-mini": "GPT-5.4 Mini",
|
|
691
|
+
"gpt-5.4": "GPT-5.4",
|
|
692
|
+
"gpt-5": "GPT-5",
|
|
693
|
+
"gpt-4o-mini": "GPT-4o Mini",
|
|
694
|
+
"gpt-4o": "GPT-4o"
|
|
695
|
+
};
|
|
696
|
+
var toolNameMap = {
|
|
697
|
+
exec_command: "Bash",
|
|
698
|
+
read_file: "Read",
|
|
699
|
+
write_file: "Edit",
|
|
700
|
+
apply_diff: "Edit",
|
|
701
|
+
apply_patch: "Edit",
|
|
702
|
+
spawn_agent: "Agent",
|
|
703
|
+
close_agent: "Agent",
|
|
704
|
+
wait_agent: "Agent",
|
|
705
|
+
read_dir: "Glob"
|
|
706
|
+
};
|
|
707
|
+
function getCodexDir() {
|
|
708
|
+
return process.env["CODEX_HOME"] ?? join2(homedir2(), ".codex");
|
|
709
|
+
}
|
|
710
|
+
function sanitizeProject(cwd) {
|
|
711
|
+
return cwd.replace(/^\//, "").replace(/\//g, "-");
|
|
712
|
+
}
|
|
713
|
+
async function readFirstLine(filePath) {
|
|
714
|
+
try {
|
|
715
|
+
const content = await readFile(filePath, "utf-8");
|
|
716
|
+
const line = content.split("\n")[0];
|
|
717
|
+
if (!line?.trim())
|
|
718
|
+
return null;
|
|
719
|
+
return JSON.parse(line);
|
|
720
|
+
} catch {
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
async function isValidCodexSession(filePath) {
|
|
725
|
+
const entry = await readFirstLine(filePath);
|
|
726
|
+
if (!entry)
|
|
727
|
+
return { valid: false };
|
|
728
|
+
const valid = entry.type === "session_meta" && typeof entry.payload?.originator === "string" && entry.payload.originator.toLowerCase().startsWith("codex");
|
|
729
|
+
return { valid, meta: valid ? entry : void 0 };
|
|
730
|
+
}
|
|
731
|
+
async function discoverSessionsInDir(codexDir) {
|
|
732
|
+
const sessionsDir = join2(codexDir, "sessions");
|
|
733
|
+
const sources = [];
|
|
734
|
+
let years;
|
|
735
|
+
try {
|
|
736
|
+
years = await readdir2(sessionsDir);
|
|
737
|
+
} catch {
|
|
738
|
+
return sources;
|
|
739
|
+
}
|
|
740
|
+
for (const year of years) {
|
|
741
|
+
if (!/^\d{4}$/.test(year))
|
|
742
|
+
continue;
|
|
743
|
+
const yearDir = join2(sessionsDir, year);
|
|
744
|
+
const months = await readdir2(yearDir).catch(() => []);
|
|
745
|
+
for (const month of months) {
|
|
746
|
+
if (!/^\d{2}$/.test(month))
|
|
747
|
+
continue;
|
|
748
|
+
const monthDir = join2(yearDir, month);
|
|
749
|
+
const days = await readdir2(monthDir).catch(() => []);
|
|
750
|
+
for (const day of days) {
|
|
751
|
+
if (!/^\d{2}$/.test(day))
|
|
752
|
+
continue;
|
|
753
|
+
const dayDir = join2(monthDir, day);
|
|
754
|
+
const files = await readdir2(dayDir).catch(() => []);
|
|
755
|
+
for (const file of files) {
|
|
756
|
+
if (!file.startsWith("rollout-") || !file.endsWith(".jsonl"))
|
|
757
|
+
continue;
|
|
758
|
+
const filePath = join2(dayDir, file);
|
|
759
|
+
const s = await stat2(filePath).catch(() => null);
|
|
760
|
+
if (!s?.isFile())
|
|
761
|
+
continue;
|
|
762
|
+
const { valid, meta } = await isValidCodexSession(filePath);
|
|
763
|
+
if (!valid || !meta)
|
|
764
|
+
continue;
|
|
765
|
+
const cwd = meta.payload?.cwd ?? "unknown";
|
|
766
|
+
sources.push({ path: filePath, project: sanitizeProject(cwd), provider: "codex" });
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return sources;
|
|
772
|
+
}
|
|
773
|
+
function resolveModel(info, sessionModel) {
|
|
774
|
+
return info?.info?.model ?? info?.info?.model_name ?? sessionModel ?? "gpt-5";
|
|
775
|
+
}
|
|
776
|
+
function createParser(source, seenKeys) {
|
|
777
|
+
return {
|
|
778
|
+
async *parse() {
|
|
779
|
+
let content;
|
|
780
|
+
try {
|
|
781
|
+
content = await readFile(source.path, "utf-8");
|
|
782
|
+
} catch {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
786
|
+
let sessionModel;
|
|
787
|
+
let sessionId = "";
|
|
788
|
+
let prevCumulativeTotal = 0;
|
|
789
|
+
let prevInput = 0;
|
|
790
|
+
let prevCached = 0;
|
|
791
|
+
let prevOutput = 0;
|
|
792
|
+
let prevReasoning = 0;
|
|
793
|
+
let pendingTools = [];
|
|
794
|
+
let pendingUserMessage = "";
|
|
795
|
+
for (const line of lines) {
|
|
796
|
+
let entry;
|
|
797
|
+
try {
|
|
798
|
+
entry = JSON.parse(line);
|
|
799
|
+
} catch {
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (entry.type === "session_meta") {
|
|
803
|
+
sessionId = entry.payload?.session_id ?? basename2(source.path, ".jsonl");
|
|
804
|
+
sessionModel = entry.payload?.model;
|
|
805
|
+
continue;
|
|
806
|
+
}
|
|
807
|
+
if (entry.type === "response_item" && entry.payload?.type === "function_call") {
|
|
808
|
+
const rawName = entry.payload.name ?? "";
|
|
809
|
+
pendingTools.push(toolNameMap[rawName] ?? rawName);
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
if (entry.type === "response_item" && entry.payload?.type === "message" && entry.payload?.role === "user") {
|
|
813
|
+
const texts = (entry.payload.content ?? []).filter((c) => c.type === "input_text").map((c) => c.text ?? "").filter(Boolean);
|
|
814
|
+
if (texts.length > 0)
|
|
815
|
+
pendingUserMessage = texts.join(" ");
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
if (entry.type === "event_msg" && entry.payload?.type === "token_count") {
|
|
819
|
+
const info = entry.payload.info;
|
|
820
|
+
if (!info)
|
|
821
|
+
continue;
|
|
822
|
+
const cumulativeTotal = info.total_token_usage?.total_tokens ?? 0;
|
|
823
|
+
if (cumulativeTotal > 0 && cumulativeTotal === prevCumulativeTotal)
|
|
824
|
+
continue;
|
|
825
|
+
prevCumulativeTotal = cumulativeTotal;
|
|
826
|
+
const last = info.last_token_usage;
|
|
827
|
+
let inputTokens = 0;
|
|
828
|
+
let cachedInputTokens = 0;
|
|
829
|
+
let outputTokens = 0;
|
|
830
|
+
let reasoningTokens = 0;
|
|
831
|
+
if (last) {
|
|
832
|
+
inputTokens = last.input_tokens ?? 0;
|
|
833
|
+
cachedInputTokens = last.cached_input_tokens ?? 0;
|
|
834
|
+
outputTokens = last.output_tokens ?? 0;
|
|
835
|
+
reasoningTokens = last.reasoning_output_tokens ?? 0;
|
|
836
|
+
} else if (cumulativeTotal > 0) {
|
|
837
|
+
const total = info.total_token_usage;
|
|
838
|
+
if (!total)
|
|
839
|
+
continue;
|
|
840
|
+
inputTokens = (total.input_tokens ?? 0) - prevInput;
|
|
841
|
+
cachedInputTokens = (total.cached_input_tokens ?? 0) - prevCached;
|
|
842
|
+
outputTokens = (total.output_tokens ?? 0) - prevOutput;
|
|
843
|
+
reasoningTokens = (total.reasoning_output_tokens ?? 0) - prevReasoning;
|
|
844
|
+
}
|
|
845
|
+
if (!last) {
|
|
846
|
+
const total = info.total_token_usage;
|
|
847
|
+
if (total) {
|
|
848
|
+
prevInput = total.input_tokens ?? 0;
|
|
849
|
+
prevCached = total.cached_input_tokens ?? 0;
|
|
850
|
+
prevOutput = total.output_tokens ?? 0;
|
|
851
|
+
prevReasoning = total.reasoning_output_tokens ?? 0;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
const totalTokens = inputTokens + cachedInputTokens + outputTokens + reasoningTokens;
|
|
855
|
+
if (totalTokens === 0)
|
|
856
|
+
continue;
|
|
857
|
+
const uncachedInputTokens = Math.max(0, inputTokens - cachedInputTokens);
|
|
858
|
+
const model = resolveModel(entry.payload, sessionModel);
|
|
859
|
+
const timestamp = entry.timestamp ?? "";
|
|
860
|
+
const dedupKey = `codex:${source.path}:${timestamp}:${cumulativeTotal}`;
|
|
861
|
+
if (seenKeys.has(dedupKey))
|
|
862
|
+
continue;
|
|
863
|
+
seenKeys.add(dedupKey);
|
|
864
|
+
yield {
|
|
865
|
+
provider: "codex",
|
|
866
|
+
model,
|
|
867
|
+
inputTokens: uncachedInputTokens,
|
|
868
|
+
outputTokens,
|
|
869
|
+
cacheCreationInputTokens: 0,
|
|
870
|
+
cacheReadInputTokens: cachedInputTokens,
|
|
871
|
+
cachedInputTokens,
|
|
872
|
+
reasoningTokens,
|
|
873
|
+
costUSD: 0,
|
|
874
|
+
// Cost calculated downstream
|
|
875
|
+
tools: pendingTools,
|
|
876
|
+
bashCommands: [],
|
|
877
|
+
timestamp,
|
|
878
|
+
speed: "standard",
|
|
879
|
+
deduplicationKey: dedupKey,
|
|
880
|
+
userMessage: pendingUserMessage,
|
|
881
|
+
sessionId
|
|
882
|
+
};
|
|
883
|
+
pendingTools = [];
|
|
884
|
+
pendingUserMessage = "";
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
var codex = {
|
|
891
|
+
name: "codex",
|
|
892
|
+
displayName: "Codex",
|
|
893
|
+
modelDisplayName(model) {
|
|
894
|
+
for (const [key, name] of Object.entries(modelDisplayNames)) {
|
|
895
|
+
if (model.startsWith(key))
|
|
896
|
+
return name;
|
|
897
|
+
}
|
|
898
|
+
return model;
|
|
899
|
+
},
|
|
900
|
+
toolDisplayName(rawTool) {
|
|
901
|
+
return toolNameMap[rawTool] ?? rawTool;
|
|
902
|
+
},
|
|
903
|
+
async discoverSessions() {
|
|
904
|
+
return discoverSessionsInDir(getCodexDir());
|
|
905
|
+
},
|
|
906
|
+
createSessionParser(source, seenKeys) {
|
|
907
|
+
return createParser(source, seenKeys);
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
// ../../packages/session/dist/providers/copilot.js
|
|
912
|
+
import { readdir as readdir3, readFile as readFile2, stat as stat3 } from "fs/promises";
|
|
913
|
+
import { basename as basename3, dirname, join as join3 } from "path";
|
|
914
|
+
import { homedir as homedir3 } from "os";
|
|
915
|
+
var modelDisplayNames2 = {
|
|
916
|
+
"gpt-4.1-nano": "GPT-4.1 Nano",
|
|
917
|
+
"gpt-4.1-mini": "GPT-4.1 Mini",
|
|
918
|
+
"gpt-4.1": "GPT-4.1",
|
|
919
|
+
"gpt-4o-mini": "GPT-4o Mini",
|
|
920
|
+
"gpt-4o": "GPT-4o",
|
|
921
|
+
"gpt-5-mini": "GPT-5 Mini",
|
|
922
|
+
"gpt-5": "GPT-5",
|
|
923
|
+
"claude-sonnet-4-5": "Sonnet 4.5",
|
|
924
|
+
"claude-sonnet-4": "Sonnet 4",
|
|
925
|
+
"claude-3-7-sonnet": "Sonnet 3.7",
|
|
926
|
+
"claude-3-5-sonnet": "Sonnet 3.5",
|
|
927
|
+
"o4-mini": "o4-mini",
|
|
928
|
+
"o3": "o3"
|
|
929
|
+
};
|
|
930
|
+
var toolNameMap2 = {
|
|
931
|
+
bash: "Bash",
|
|
932
|
+
read_file: "Read",
|
|
933
|
+
write_file: "Edit",
|
|
934
|
+
edit_file: "Edit",
|
|
935
|
+
create_file: "Write",
|
|
936
|
+
delete_file: "Delete",
|
|
937
|
+
search_files: "Grep",
|
|
938
|
+
find_files: "Glob",
|
|
939
|
+
list_directory: "LS",
|
|
940
|
+
web_search: "WebSearch",
|
|
941
|
+
fetch_webpage: "WebFetch",
|
|
942
|
+
github_repo: "GitHub"
|
|
943
|
+
};
|
|
944
|
+
var modelDisplayEntries = Object.entries(modelDisplayNames2).sort((a, b) => b[0].length - a[0].length);
|
|
945
|
+
function getCopilotSessionStateDir() {
|
|
946
|
+
return join3(homedir3(), ".copilot", "session-state");
|
|
947
|
+
}
|
|
948
|
+
function parseCwd(yaml) {
|
|
949
|
+
const match = yaml.match(/^cwd:\s*(.+)$/m);
|
|
950
|
+
if (!match?.[1])
|
|
951
|
+
return null;
|
|
952
|
+
return match[1].replace(/\s*#.*$/, "").replace(/^['"]|['"]$/g, "").trim() || null;
|
|
953
|
+
}
|
|
954
|
+
function createParser2(source, seenKeys) {
|
|
955
|
+
return {
|
|
956
|
+
async *parse() {
|
|
957
|
+
let content;
|
|
958
|
+
try {
|
|
959
|
+
content = await readFile2(source.path, "utf-8");
|
|
960
|
+
} catch {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
const sessionId = basename3(dirname(source.path));
|
|
964
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
965
|
+
let currentModel = "";
|
|
966
|
+
let pendingUserMessage = "";
|
|
967
|
+
for (const line of lines) {
|
|
968
|
+
let event;
|
|
969
|
+
try {
|
|
970
|
+
event = JSON.parse(line);
|
|
971
|
+
} catch {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
if (event.type === "session.model_change") {
|
|
975
|
+
currentModel = event.data.newModel ?? currentModel;
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
if (event.type === "user.message") {
|
|
979
|
+
pendingUserMessage = event.data.content ?? "";
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
if (event.type === "assistant.message") {
|
|
983
|
+
const { messageId, outputTokens, toolRequests = [] } = event.data;
|
|
984
|
+
if (outputTokens === 0)
|
|
985
|
+
continue;
|
|
986
|
+
if (!currentModel)
|
|
987
|
+
continue;
|
|
988
|
+
const dedupKey = `copilot:${sessionId}:${messageId}`;
|
|
989
|
+
if (seenKeys.has(dedupKey))
|
|
990
|
+
continue;
|
|
991
|
+
seenKeys.add(dedupKey);
|
|
992
|
+
const tools = toolRequests.map((t) => t.name ?? "").filter(Boolean).map((n) => toolNameMap2[n] ?? n);
|
|
993
|
+
yield {
|
|
994
|
+
provider: "copilot",
|
|
995
|
+
model: currentModel,
|
|
996
|
+
inputTokens: 0,
|
|
997
|
+
// Copilot only logs outputTokens
|
|
998
|
+
outputTokens,
|
|
999
|
+
cacheCreationInputTokens: 0,
|
|
1000
|
+
cacheReadInputTokens: 0,
|
|
1001
|
+
cachedInputTokens: 0,
|
|
1002
|
+
reasoningTokens: 0,
|
|
1003
|
+
costUSD: 0,
|
|
1004
|
+
tools,
|
|
1005
|
+
bashCommands: [],
|
|
1006
|
+
timestamp: event.timestamp ?? "",
|
|
1007
|
+
speed: "standard",
|
|
1008
|
+
deduplicationKey: dedupKey,
|
|
1009
|
+
userMessage: pendingUserMessage,
|
|
1010
|
+
sessionId
|
|
1011
|
+
};
|
|
1012
|
+
pendingUserMessage = "";
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
async function discoverSessionsInDir2(sessionStateDir) {
|
|
1019
|
+
const sources = [];
|
|
1020
|
+
let sessionDirs;
|
|
1021
|
+
try {
|
|
1022
|
+
sessionDirs = await readdir3(sessionStateDir);
|
|
1023
|
+
} catch {
|
|
1024
|
+
return sources;
|
|
1025
|
+
}
|
|
1026
|
+
for (const sessionId of sessionDirs) {
|
|
1027
|
+
const eventsPath = join3(sessionStateDir, sessionId, "events.jsonl");
|
|
1028
|
+
const s = await stat3(eventsPath).catch(() => null);
|
|
1029
|
+
if (!s?.isFile())
|
|
1030
|
+
continue;
|
|
1031
|
+
let project = sessionId;
|
|
1032
|
+
try {
|
|
1033
|
+
const yaml = await readFile2(join3(sessionStateDir, sessionId, "workspace.yaml"), "utf-8");
|
|
1034
|
+
const cwd = parseCwd(yaml);
|
|
1035
|
+
if (cwd)
|
|
1036
|
+
project = basename3(cwd);
|
|
1037
|
+
} catch {
|
|
1038
|
+
}
|
|
1039
|
+
sources.push({ path: eventsPath, project, provider: "copilot" });
|
|
1040
|
+
}
|
|
1041
|
+
return sources;
|
|
1042
|
+
}
|
|
1043
|
+
var copilot = {
|
|
1044
|
+
name: "copilot",
|
|
1045
|
+
displayName: "GitHub Copilot",
|
|
1046
|
+
modelDisplayName(model) {
|
|
1047
|
+
for (const [key, name] of modelDisplayEntries) {
|
|
1048
|
+
if (model === key || model.startsWith(key + "-"))
|
|
1049
|
+
return name;
|
|
1050
|
+
}
|
|
1051
|
+
return model;
|
|
1052
|
+
},
|
|
1053
|
+
toolDisplayName(rawTool) {
|
|
1054
|
+
return toolNameMap2[rawTool] ?? rawTool;
|
|
1055
|
+
},
|
|
1056
|
+
async discoverSessions() {
|
|
1057
|
+
return discoverSessionsInDir2(getCopilotSessionStateDir());
|
|
1058
|
+
},
|
|
1059
|
+
createSessionParser(source, seenKeys) {
|
|
1060
|
+
return createParser2(source, seenKeys);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
// ../../packages/session/dist/providers/pi.js
|
|
1065
|
+
import { readdir as readdir4, readFile as readFile3, stat as stat4 } from "fs/promises";
|
|
1066
|
+
import { basename as basename4, join as join4 } from "path";
|
|
1067
|
+
import { homedir as homedir4 } from "os";
|
|
1068
|
+
var modelDisplayNames3 = {
|
|
1069
|
+
"gpt-5.4": "GPT-5.4",
|
|
1070
|
+
"gpt-5.4-mini": "GPT-5.4 Mini",
|
|
1071
|
+
"gpt-5": "GPT-5",
|
|
1072
|
+
"gpt-4o": "GPT-4o",
|
|
1073
|
+
"gpt-4o-mini": "GPT-4o Mini"
|
|
1074
|
+
};
|
|
1075
|
+
var toolNameMap3 = {
|
|
1076
|
+
bash: "Bash",
|
|
1077
|
+
read: "Read",
|
|
1078
|
+
edit: "Edit",
|
|
1079
|
+
write: "Write",
|
|
1080
|
+
glob: "Glob",
|
|
1081
|
+
grep: "Grep",
|
|
1082
|
+
task: "Agent",
|
|
1083
|
+
dispatch_agent: "Agent",
|
|
1084
|
+
fetch: "WebFetch",
|
|
1085
|
+
search: "WebSearch",
|
|
1086
|
+
todo: "TodoWrite",
|
|
1087
|
+
patch: "Patch"
|
|
1088
|
+
};
|
|
1089
|
+
var modelDisplayEntries2 = Object.entries(modelDisplayNames3).sort((a, b) => b[0].length - a[0].length);
|
|
1090
|
+
function getPiSessionsDir() {
|
|
1091
|
+
return join4(homedir4(), ".pi", "agent", "sessions");
|
|
1092
|
+
}
|
|
1093
|
+
async function readFirstEntry(filePath) {
|
|
1094
|
+
try {
|
|
1095
|
+
const content = await readFile3(filePath, "utf-8");
|
|
1096
|
+
const line = content.split("\n")[0];
|
|
1097
|
+
if (!line?.trim())
|
|
1098
|
+
return null;
|
|
1099
|
+
return JSON.parse(line);
|
|
1100
|
+
} catch {
|
|
1101
|
+
return null;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
function extractBashCommands(cmd) {
|
|
1105
|
+
return cmd.split(/[;&|]+/).map((s) => s.trim().split(/\s+/)[0]).filter(Boolean);
|
|
1106
|
+
}
|
|
1107
|
+
async function discoverSessionsInDir3(sessionsDir) {
|
|
1108
|
+
const sources = [];
|
|
1109
|
+
let projectDirs;
|
|
1110
|
+
try {
|
|
1111
|
+
projectDirs = await readdir4(sessionsDir);
|
|
1112
|
+
} catch {
|
|
1113
|
+
return sources;
|
|
1114
|
+
}
|
|
1115
|
+
for (const dirName of projectDirs) {
|
|
1116
|
+
const dirPath = join4(sessionsDir, dirName);
|
|
1117
|
+
const dirStat = await stat4(dirPath).catch(() => null);
|
|
1118
|
+
if (!dirStat?.isDirectory())
|
|
1119
|
+
continue;
|
|
1120
|
+
let files;
|
|
1121
|
+
try {
|
|
1122
|
+
files = await readdir4(dirPath);
|
|
1123
|
+
} catch {
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
for (const file of files) {
|
|
1127
|
+
if (!file.endsWith(".jsonl"))
|
|
1128
|
+
continue;
|
|
1129
|
+
const filePath = join4(dirPath, file);
|
|
1130
|
+
const fileStat = await stat4(filePath).catch(() => null);
|
|
1131
|
+
if (!fileStat?.isFile())
|
|
1132
|
+
continue;
|
|
1133
|
+
const first = await readFirstEntry(filePath);
|
|
1134
|
+
if (!first || first.type !== "session")
|
|
1135
|
+
continue;
|
|
1136
|
+
const cwd = first.cwd ?? dirName;
|
|
1137
|
+
sources.push({ path: filePath, project: basename4(cwd), provider: "pi" });
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return sources;
|
|
1141
|
+
}
|
|
1142
|
+
function createParser3(source, seenKeys) {
|
|
1143
|
+
return {
|
|
1144
|
+
async *parse() {
|
|
1145
|
+
let content;
|
|
1146
|
+
try {
|
|
1147
|
+
content = await readFile3(source.path, "utf-8");
|
|
1148
|
+
} catch {
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
1152
|
+
let sessionId = basename4(source.path, ".jsonl");
|
|
1153
|
+
let pendingUserMessage = "";
|
|
1154
|
+
for (const [lineIdx, line] of lines.entries()) {
|
|
1155
|
+
let entry;
|
|
1156
|
+
try {
|
|
1157
|
+
entry = JSON.parse(line);
|
|
1158
|
+
} catch {
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
if (entry.type === "session") {
|
|
1162
|
+
sessionId = entry.id ?? sessionId;
|
|
1163
|
+
continue;
|
|
1164
|
+
}
|
|
1165
|
+
if (entry.type !== "message")
|
|
1166
|
+
continue;
|
|
1167
|
+
const msg = entry.message;
|
|
1168
|
+
if (!msg)
|
|
1169
|
+
continue;
|
|
1170
|
+
if (msg.role === "user") {
|
|
1171
|
+
const texts = (msg.content ?? []).filter((c) => c.type === "text").map((c) => c.text ?? "").filter(Boolean);
|
|
1172
|
+
if (texts.length > 0)
|
|
1173
|
+
pendingUserMessage = texts.join(" ");
|
|
1174
|
+
continue;
|
|
1175
|
+
}
|
|
1176
|
+
if (msg.role !== "assistant" || !msg.usage)
|
|
1177
|
+
continue;
|
|
1178
|
+
const { input, output, cacheRead, cacheWrite } = msg.usage;
|
|
1179
|
+
if (input === 0 && output === 0)
|
|
1180
|
+
continue;
|
|
1181
|
+
const model = msg.model ?? "gpt-5";
|
|
1182
|
+
const responseId = msg.responseId ?? "";
|
|
1183
|
+
const dedupKey = `pi:${source.path}:${responseId || entry.id || entry.timestamp || String(lineIdx)}`;
|
|
1184
|
+
if (seenKeys.has(dedupKey))
|
|
1185
|
+
continue;
|
|
1186
|
+
seenKeys.add(dedupKey);
|
|
1187
|
+
const toolCalls = (msg.content ?? []).filter((c) => c.type === "toolCall" && c.name);
|
|
1188
|
+
const tools = toolCalls.map((c) => toolNameMap3[c.name] ?? c.name);
|
|
1189
|
+
const bashCommands = toolCalls.filter((c) => c.name === "bash").flatMap((c) => {
|
|
1190
|
+
const cmd = c.arguments?.["command"];
|
|
1191
|
+
return typeof cmd === "string" ? extractBashCommands(cmd) : [];
|
|
1192
|
+
});
|
|
1193
|
+
const timestamp = entry.timestamp ?? "";
|
|
1194
|
+
yield {
|
|
1195
|
+
provider: "pi",
|
|
1196
|
+
model,
|
|
1197
|
+
inputTokens: input,
|
|
1198
|
+
outputTokens: output,
|
|
1199
|
+
cacheCreationInputTokens: cacheWrite,
|
|
1200
|
+
cacheReadInputTokens: cacheRead,
|
|
1201
|
+
cachedInputTokens: cacheRead,
|
|
1202
|
+
reasoningTokens: 0,
|
|
1203
|
+
costUSD: 0,
|
|
1204
|
+
tools,
|
|
1205
|
+
bashCommands,
|
|
1206
|
+
timestamp,
|
|
1207
|
+
speed: "standard",
|
|
1208
|
+
deduplicationKey: dedupKey,
|
|
1209
|
+
userMessage: pendingUserMessage,
|
|
1210
|
+
sessionId
|
|
1211
|
+
};
|
|
1212
|
+
pendingUserMessage = "";
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
var pi = {
|
|
1218
|
+
name: "pi",
|
|
1219
|
+
displayName: "Pi",
|
|
1220
|
+
modelDisplayName(model) {
|
|
1221
|
+
for (const [key, name] of modelDisplayEntries2) {
|
|
1222
|
+
if (model.startsWith(key))
|
|
1223
|
+
return name;
|
|
1224
|
+
}
|
|
1225
|
+
return model;
|
|
1226
|
+
},
|
|
1227
|
+
toolDisplayName(rawTool) {
|
|
1228
|
+
return toolNameMap3[rawTool] ?? rawTool;
|
|
1229
|
+
},
|
|
1230
|
+
async discoverSessions() {
|
|
1231
|
+
return discoverSessionsInDir3(getPiSessionsDir());
|
|
1232
|
+
},
|
|
1233
|
+
createSessionParser(source, seenKeys) {
|
|
1234
|
+
return createParser3(source, seenKeys);
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// ../../packages/session/dist/providers/index.js
|
|
1239
|
+
var coreProviders = [claudeCode, codex, copilot, pi];
|
|
1240
|
+
var cursorProvider = null;
|
|
1241
|
+
var cursorLoadAttempted = false;
|
|
1242
|
+
async function loadCursor() {
|
|
1243
|
+
if (cursorLoadAttempted)
|
|
1244
|
+
return cursorProvider;
|
|
1245
|
+
cursorLoadAttempted = true;
|
|
1246
|
+
try {
|
|
1247
|
+
const { cursor } = await import("./cursor-BGQJ4CWI.js");
|
|
1248
|
+
cursorProvider = cursor;
|
|
1249
|
+
return cursor;
|
|
1250
|
+
} catch {
|
|
1251
|
+
return null;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
var opencodeProvider = null;
|
|
1255
|
+
var opencodeLoadAttempted = false;
|
|
1256
|
+
async function loadOpenCode() {
|
|
1257
|
+
if (opencodeLoadAttempted)
|
|
1258
|
+
return opencodeProvider;
|
|
1259
|
+
opencodeLoadAttempted = true;
|
|
1260
|
+
try {
|
|
1261
|
+
const { opencode } = await import("./opencode-IQ7X5YMJ.js");
|
|
1262
|
+
opencodeProvider = opencode;
|
|
1263
|
+
return opencode;
|
|
1264
|
+
} catch {
|
|
1265
|
+
return null;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
async function getAllProviders() {
|
|
1269
|
+
const [cursor, opencode] = await Promise.all([loadCursor(), loadOpenCode()]);
|
|
1270
|
+
const all = [...coreProviders];
|
|
1271
|
+
if (cursor)
|
|
1272
|
+
all.push(cursor);
|
|
1273
|
+
if (opencode)
|
|
1274
|
+
all.push(opencode);
|
|
1275
|
+
return all;
|
|
1276
|
+
}
|
|
1277
|
+
async function discoverAllSessions(providerFilter) {
|
|
1278
|
+
const allProviders = await getAllProviders();
|
|
1279
|
+
const filtered = providerFilter && providerFilter !== "all" ? allProviders.filter((p) => p.name === providerFilter) : allProviders;
|
|
1280
|
+
const all = [];
|
|
1281
|
+
for (const provider of filtered) {
|
|
1282
|
+
const sessions = await provider.discoverSessions();
|
|
1283
|
+
all.push(...sessions);
|
|
1284
|
+
}
|
|
1285
|
+
return all;
|
|
1286
|
+
}
|
|
1287
|
+
async function getProvider(name) {
|
|
1288
|
+
if (name === "cursor")
|
|
1289
|
+
return await loadCursor() ?? void 0;
|
|
1290
|
+
if (name === "opencode")
|
|
1291
|
+
return await loadOpenCode() ?? void 0;
|
|
1292
|
+
return coreProviders.find((p) => p.name === name);
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// ../../packages/session/dist/launchers/claude-code.js
|
|
1296
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
1297
|
+
import { randomUUID } from "node:crypto";
|
|
1298
|
+
import { writeFile } from "node:fs/promises";
|
|
1299
|
+
import { tmpdir } from "node:os";
|
|
1300
|
+
import { join as join5 } from "node:path";
|
|
1301
|
+
|
|
1302
|
+
// ../../packages/session/dist/terminal/tmux.js
|
|
1303
|
+
import { spawn } from "node:child_process";
|
|
1304
|
+
function sanitizeTmuxName(input) {
|
|
1305
|
+
const cleaned = input.trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
1306
|
+
return `rm-${cleaned || "session"}`;
|
|
1307
|
+
}
|
|
1308
|
+
function buildTmuxLaunchArgs(input) {
|
|
1309
|
+
const claudeArgs = input.runId ? ["env", `RULEMETRIC_RUN_ID=${input.runId}`, "claude"] : ["claude"];
|
|
1310
|
+
if (input.resumeSessionId) {
|
|
1311
|
+
claudeArgs.push("--resume", input.resumeSessionId);
|
|
1312
|
+
}
|
|
1313
|
+
if (input.model) {
|
|
1314
|
+
claudeArgs.push("--model", input.model);
|
|
1315
|
+
}
|
|
1316
|
+
return [
|
|
1317
|
+
"new-session",
|
|
1318
|
+
"-d",
|
|
1319
|
+
"-s",
|
|
1320
|
+
input.sessionName,
|
|
1321
|
+
"-c",
|
|
1322
|
+
input.projectPath,
|
|
1323
|
+
"--",
|
|
1324
|
+
...claudeArgs
|
|
1325
|
+
];
|
|
1326
|
+
}
|
|
1327
|
+
function buildTmuxSendKeysArgs(target, message, options = {}) {
|
|
1328
|
+
if (options.literal === false) {
|
|
1329
|
+
return ["send-keys", "-t", target, message];
|
|
1330
|
+
}
|
|
1331
|
+
return ["send-keys", "-t", target, "-l", "--", message];
|
|
1332
|
+
}
|
|
1333
|
+
function buildTmuxHasSessionArgs(target) {
|
|
1334
|
+
return ["has-session", "-t", target];
|
|
1335
|
+
}
|
|
1336
|
+
function buildTmuxAttachCommand(target) {
|
|
1337
|
+
return `tmux attach -t ${target}`;
|
|
1338
|
+
}
|
|
1339
|
+
function tmuxSpawnEnv() {
|
|
1340
|
+
const extraDirs = ["/opt/homebrew/bin", "/usr/local/bin"];
|
|
1341
|
+
const parts = (process.env.PATH ?? "").split(":").filter(Boolean);
|
|
1342
|
+
const missing = extraDirs.filter((d) => !parts.includes(d));
|
|
1343
|
+
if (missing.length === 0)
|
|
1344
|
+
return process.env;
|
|
1345
|
+
return { ...process.env, PATH: [...parts, ...missing].join(":") };
|
|
1346
|
+
}
|
|
1347
|
+
function runTmux(args) {
|
|
1348
|
+
return new Promise((resolve) => {
|
|
1349
|
+
const proc = spawn("tmux", args, {
|
|
1350
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
1351
|
+
env: tmuxSpawnEnv()
|
|
1352
|
+
});
|
|
1353
|
+
let stderr = "";
|
|
1354
|
+
proc.stderr.on("data", (d) => {
|
|
1355
|
+
stderr += d.toString();
|
|
1356
|
+
});
|
|
1357
|
+
proc.on("close", (code) => resolve({ code, stderr }));
|
|
1358
|
+
proc.on("error", (err) => resolve({ code: null, stderr: err.message }));
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
async function isTmuxAvailable() {
|
|
1362
|
+
const result = await runTmux(["-V"]);
|
|
1363
|
+
return result.code === 0;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// ../../packages/session/dist/launchers/claude-code.js
|
|
1367
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1368
|
+
function validateRunId(runId) {
|
|
1369
|
+
if (runId === void 0)
|
|
1370
|
+
return void 0;
|
|
1371
|
+
if (UUID_RE.test(runId))
|
|
1372
|
+
return runId;
|
|
1373
|
+
console.warn(`[claude-code-launcher] dropping non-uuid runId (RULEMETRIC_RUN_ID not injected): ${JSON.stringify(runId)}`);
|
|
1374
|
+
return void 0;
|
|
1375
|
+
}
|
|
1376
|
+
function shellSingleQuote(s) {
|
|
1377
|
+
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
1378
|
+
}
|
|
1379
|
+
var ClaudeCodeLauncher = class {
|
|
1380
|
+
options;
|
|
1381
|
+
tool = "claude_code";
|
|
1382
|
+
constructor(options = {}) {
|
|
1383
|
+
this.options = options;
|
|
1384
|
+
}
|
|
1385
|
+
capabilities = {
|
|
1386
|
+
headless: true,
|
|
1387
|
+
interactive: true,
|
|
1388
|
+
remoteSpawn: true
|
|
1389
|
+
};
|
|
1390
|
+
async launch(config) {
|
|
1391
|
+
const sessionId = randomUUID();
|
|
1392
|
+
const safeConfig = { ...config, runId: validateRunId(config.runId) };
|
|
1393
|
+
if (safeConfig.mode === "headless") {
|
|
1394
|
+
return this.launchHeadless(safeConfig, sessionId);
|
|
1395
|
+
}
|
|
1396
|
+
return this.launchInteractive(safeConfig, sessionId);
|
|
1397
|
+
}
|
|
1398
|
+
async launchHeadless(config, sessionId) {
|
|
1399
|
+
const args = ["-p", config.prompt ?? "", "--output-format", "json"];
|
|
1400
|
+
if (config.systemPrompt)
|
|
1401
|
+
args.push("--system-prompt", config.systemPrompt);
|
|
1402
|
+
if (config.model)
|
|
1403
|
+
args.push("--model", config.model);
|
|
1404
|
+
const env = { ...process.env };
|
|
1405
|
+
delete env.CLAUDECODE;
|
|
1406
|
+
delete env.HTTPS_PROXY;
|
|
1407
|
+
if (config.runId)
|
|
1408
|
+
env.RULEMETRIC_RUN_ID = config.runId;
|
|
1409
|
+
return new Promise((resolve) => {
|
|
1410
|
+
const proc = spawn2("claude", args, {
|
|
1411
|
+
cwd: config.projectPath,
|
|
1412
|
+
env,
|
|
1413
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1414
|
+
});
|
|
1415
|
+
let stdout = "";
|
|
1416
|
+
let stderr = "";
|
|
1417
|
+
proc.stdout.on("data", (d) => {
|
|
1418
|
+
stdout += d.toString();
|
|
1419
|
+
});
|
|
1420
|
+
proc.stderr.on("data", (d) => {
|
|
1421
|
+
stderr += d.toString();
|
|
1422
|
+
});
|
|
1423
|
+
const timer = config.timeout ? setTimeout(() => {
|
|
1424
|
+
proc.kill("SIGTERM");
|
|
1425
|
+
}, config.timeout) : null;
|
|
1426
|
+
proc.on("close", (code) => {
|
|
1427
|
+
if (timer)
|
|
1428
|
+
clearTimeout(timer);
|
|
1429
|
+
let output = stdout;
|
|
1430
|
+
try {
|
|
1431
|
+
const parsed = JSON.parse(stdout);
|
|
1432
|
+
output = parsed.result ?? parsed.content ?? stdout;
|
|
1433
|
+
} catch {
|
|
1434
|
+
}
|
|
1435
|
+
resolve({
|
|
1436
|
+
sessionId,
|
|
1437
|
+
pid: proc.pid,
|
|
1438
|
+
exitCode: code,
|
|
1439
|
+
output,
|
|
1440
|
+
error: code !== 0 ? stderr : void 0
|
|
1441
|
+
});
|
|
1442
|
+
});
|
|
1443
|
+
proc.on("error", (err) => {
|
|
1444
|
+
if (timer)
|
|
1445
|
+
clearTimeout(timer);
|
|
1446
|
+
resolve({ sessionId, error: `Failed to spawn claude: ${err.message}` });
|
|
1447
|
+
});
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
async launchInteractive(config, sessionId) {
|
|
1451
|
+
const tmuxAvailableCheck = this.options.tmuxAvailable ?? isTmuxAvailable;
|
|
1452
|
+
if (await tmuxAvailableCheck().catch(() => false)) {
|
|
1453
|
+
return this.launchInteractiveTmux(config, sessionId);
|
|
1454
|
+
}
|
|
1455
|
+
return this.launchInteractiveTerminal(config, sessionId, "tmux_not_found");
|
|
1456
|
+
}
|
|
1457
|
+
async launchInteractiveTmux(config, sessionId) {
|
|
1458
|
+
const run = this.options.runTmux ?? runTmux;
|
|
1459
|
+
const target = sanitizeTmuxName(`claude-${config.resumeSessionId ?? sessionId}`);
|
|
1460
|
+
const launchResult = await run(buildTmuxLaunchArgs({
|
|
1461
|
+
sessionName: target,
|
|
1462
|
+
projectPath: config.projectPath,
|
|
1463
|
+
resumeSessionId: config.resumeSessionId,
|
|
1464
|
+
model: config.model,
|
|
1465
|
+
// Task 3.1: inject the run id into the spawned session's env so its
|
|
1466
|
+
// session-start hook forwards it to POST /api/sessions (stamps run_id).
|
|
1467
|
+
runId: config.runId
|
|
1468
|
+
}));
|
|
1469
|
+
if (launchResult.code !== 0) {
|
|
1470
|
+
return this.launchInteractiveTerminal(config, sessionId, "tmux_launch_failed", `tmux new-session exited ${launchResult.code}: ${launchResult.stderr.trim() || "no stderr"}`);
|
|
1471
|
+
}
|
|
1472
|
+
const attachResult = await this.openTerminalAttach(target, sessionId);
|
|
1473
|
+
if (config.prompt) {
|
|
1474
|
+
const sendResult = await run(buildTmuxSendKeysArgs(target, config.prompt));
|
|
1475
|
+
if (sendResult.code !== 0) {
|
|
1476
|
+
return {
|
|
1477
|
+
sessionId,
|
|
1478
|
+
liveSendAvailable: false,
|
|
1479
|
+
fallbackReason: "tmux_launch_failed",
|
|
1480
|
+
error: `tmux send-keys exited ${sendResult.code}: ${sendResult.stderr.trim() || "no stderr"}`
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
const enterResult = await run(buildTmuxSendKeysArgs(target, "Enter", { literal: false }));
|
|
1484
|
+
if (enterResult.code !== 0) {
|
|
1485
|
+
return {
|
|
1486
|
+
sessionId,
|
|
1487
|
+
liveSendAvailable: false,
|
|
1488
|
+
fallbackReason: "tmux_launch_failed",
|
|
1489
|
+
error: `tmux send Enter exited ${enterResult.code}: ${enterResult.stderr.trim() || "no stderr"}`
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
return {
|
|
1494
|
+
sessionId,
|
|
1495
|
+
pid: attachResult.pid,
|
|
1496
|
+
liveSendAvailable: true,
|
|
1497
|
+
...attachResult.error ? { error: attachResult.error } : {},
|
|
1498
|
+
terminalTarget: {
|
|
1499
|
+
kind: "tmux",
|
|
1500
|
+
target,
|
|
1501
|
+
attachCommand: buildTmuxAttachCommand(target),
|
|
1502
|
+
live: true
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
async openTerminalAttach(target, sessionId) {
|
|
1507
|
+
const scriptPath = join5(tmpdir(), `rulemetric-attach-${sessionId}.command`);
|
|
1508
|
+
const scriptBody = `#!/bin/zsh
|
|
1509
|
+
rm -- "$0"
|
|
1510
|
+
${buildTmuxAttachCommand(target)}
|
|
1511
|
+
`;
|
|
1512
|
+
await writeFile(scriptPath, scriptBody, { mode: 493 });
|
|
1513
|
+
return new Promise((resolve) => {
|
|
1514
|
+
const proc = spawn2("open", ["-a", "Terminal", scriptPath], {
|
|
1515
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1516
|
+
});
|
|
1517
|
+
let stderr = "";
|
|
1518
|
+
proc.stderr.on("data", (d) => {
|
|
1519
|
+
stderr += d.toString();
|
|
1520
|
+
});
|
|
1521
|
+
proc.on("close", (code) => {
|
|
1522
|
+
if (code === 0) {
|
|
1523
|
+
resolve({ pid: proc.pid });
|
|
1524
|
+
} else {
|
|
1525
|
+
resolve({
|
|
1526
|
+
pid: proc.pid,
|
|
1527
|
+
error: `open attach exited ${code}: ${stderr.trim() || "no stderr"}`
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
proc.on("error", (err) => {
|
|
1532
|
+
resolve({ error: `Failed to spawn open attach: ${err.message}` });
|
|
1533
|
+
});
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
async launchInteractiveTerminal(config, sessionId, fallbackReason, fallbackDetail) {
|
|
1537
|
+
const parts = ["claude"];
|
|
1538
|
+
if (config.resumeSessionId) {
|
|
1539
|
+
parts.push("--resume", config.resumeSessionId);
|
|
1540
|
+
} else if (config.prompt) {
|
|
1541
|
+
parts.push("-p", JSON.stringify(config.prompt));
|
|
1542
|
+
}
|
|
1543
|
+
if (config.model)
|
|
1544
|
+
parts.push("--model", config.model);
|
|
1545
|
+
const cmd = parts.join(" ");
|
|
1546
|
+
const scriptPath = join5(tmpdir(), `rulemetric-launch-${sessionId}.command`);
|
|
1547
|
+
const runIdExport = config.runId ? `export RULEMETRIC_RUN_ID=${shellSingleQuote(config.runId)}
|
|
1548
|
+
` : "";
|
|
1549
|
+
const scriptBody = `#!/bin/zsh
|
|
1550
|
+
rm -- "$0"
|
|
1551
|
+
cd ${JSON.stringify(config.projectPath)} || exit
|
|
1552
|
+
` + runIdExport + `${cmd}
|
|
1553
|
+
`;
|
|
1554
|
+
await writeFile(scriptPath, scriptBody, { mode: 493 });
|
|
1555
|
+
return new Promise((resolve) => {
|
|
1556
|
+
const proc = spawn2("open", ["-a", "Terminal", scriptPath], {
|
|
1557
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1558
|
+
});
|
|
1559
|
+
let stderr = "";
|
|
1560
|
+
proc.stderr.on("data", (d) => {
|
|
1561
|
+
stderr += d.toString();
|
|
1562
|
+
});
|
|
1563
|
+
proc.on("close", (code) => {
|
|
1564
|
+
if (code === 0) {
|
|
1565
|
+
resolve({
|
|
1566
|
+
sessionId,
|
|
1567
|
+
pid: proc.pid,
|
|
1568
|
+
liveSendAvailable: false,
|
|
1569
|
+
fallbackReason,
|
|
1570
|
+
...fallbackDetail ? { error: fallbackDetail } : {}
|
|
1571
|
+
});
|
|
1572
|
+
} else {
|
|
1573
|
+
const tail = stderr.trim() || "no stderr";
|
|
1574
|
+
resolve({
|
|
1575
|
+
sessionId,
|
|
1576
|
+
pid: proc.pid,
|
|
1577
|
+
liveSendAvailable: false,
|
|
1578
|
+
fallbackReason,
|
|
1579
|
+
error: fallbackDetail ? `${fallbackDetail}; open exited ${code}: ${tail}` : `open exited ${code}: ${tail}`
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
});
|
|
1583
|
+
proc.on("error", (err) => {
|
|
1584
|
+
resolve({
|
|
1585
|
+
sessionId,
|
|
1586
|
+
liveSendAvailable: false,
|
|
1587
|
+
fallbackReason,
|
|
1588
|
+
error: `Failed to spawn open: ${err.message}`
|
|
1589
|
+
});
|
|
1590
|
+
});
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
// ../../packages/session/dist/launchers/codex.js
|
|
1596
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
1597
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1598
|
+
var CodexLauncher = class {
|
|
1599
|
+
tool = "codex";
|
|
1600
|
+
capabilities = { headless: true, interactive: true, remoteSpawn: true };
|
|
1601
|
+
async launch(config) {
|
|
1602
|
+
const sessionId = randomUUID2();
|
|
1603
|
+
if (config.mode === "headless") {
|
|
1604
|
+
return this.launchHeadless(config, sessionId);
|
|
1605
|
+
}
|
|
1606
|
+
return this.launchInteractive(config, sessionId);
|
|
1607
|
+
}
|
|
1608
|
+
launchHeadless(config, sessionId) {
|
|
1609
|
+
const args = ["-q", config.prompt ?? ""];
|
|
1610
|
+
if (config.model)
|
|
1611
|
+
args.push("--model", config.model);
|
|
1612
|
+
return new Promise((resolve) => {
|
|
1613
|
+
const proc = spawn3("codex", args, {
|
|
1614
|
+
cwd: config.projectPath,
|
|
1615
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1616
|
+
});
|
|
1617
|
+
let stdout = "";
|
|
1618
|
+
let stderr = "";
|
|
1619
|
+
proc.stdout.on("data", (d) => {
|
|
1620
|
+
stdout += d.toString();
|
|
1621
|
+
});
|
|
1622
|
+
proc.stderr.on("data", (d) => {
|
|
1623
|
+
stderr += d.toString();
|
|
1624
|
+
});
|
|
1625
|
+
const timer = config.timeout ? setTimeout(() => {
|
|
1626
|
+
proc.kill("SIGTERM");
|
|
1627
|
+
}, config.timeout) : null;
|
|
1628
|
+
proc.on("close", (code) => {
|
|
1629
|
+
if (timer)
|
|
1630
|
+
clearTimeout(timer);
|
|
1631
|
+
resolve({ sessionId, pid: proc.pid, exitCode: code, output: stdout, error: code !== 0 ? stderr : void 0 });
|
|
1632
|
+
});
|
|
1633
|
+
proc.on("error", (err) => {
|
|
1634
|
+
if (timer)
|
|
1635
|
+
clearTimeout(timer);
|
|
1636
|
+
resolve({ sessionId, error: `Failed to spawn codex: ${err.message}` });
|
|
1637
|
+
});
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
launchInteractive(config, sessionId) {
|
|
1641
|
+
const parts = ["codex"];
|
|
1642
|
+
if (config.prompt)
|
|
1643
|
+
parts.push(JSON.stringify(config.prompt));
|
|
1644
|
+
const script = `cd ${JSON.stringify(config.projectPath)} && ${parts.join(" ")}`;
|
|
1645
|
+
const proc = spawn3("osascript", ["-e", `tell application "Terminal" to do script ${JSON.stringify(script)}`], {
|
|
1646
|
+
stdio: "ignore",
|
|
1647
|
+
detached: true
|
|
1648
|
+
});
|
|
1649
|
+
proc.unref();
|
|
1650
|
+
return Promise.resolve({ sessionId, pid: proc.pid });
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1654
|
+
// ../../packages/session/dist/launchers/aider.js
|
|
1655
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
1656
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
1657
|
+
var AiderLauncher = class {
|
|
1658
|
+
tool = "aider";
|
|
1659
|
+
capabilities = { headless: true, interactive: true, remoteSpawn: true };
|
|
1660
|
+
async launch(config) {
|
|
1661
|
+
const sessionId = randomUUID3();
|
|
1662
|
+
if (config.mode === "headless") {
|
|
1663
|
+
return this.launchHeadless(config, sessionId);
|
|
1664
|
+
}
|
|
1665
|
+
return this.launchInteractive(config, sessionId);
|
|
1666
|
+
}
|
|
1667
|
+
launchHeadless(config, sessionId) {
|
|
1668
|
+
const args = ["--message", config.prompt ?? "", "--yes"];
|
|
1669
|
+
if (config.model)
|
|
1670
|
+
args.push("--model", config.model);
|
|
1671
|
+
return new Promise((resolve) => {
|
|
1672
|
+
const proc = spawn4("aider", args, {
|
|
1673
|
+
cwd: config.projectPath,
|
|
1674
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1675
|
+
});
|
|
1676
|
+
let stdout = "";
|
|
1677
|
+
let stderr = "";
|
|
1678
|
+
proc.stdout.on("data", (d) => {
|
|
1679
|
+
stdout += d.toString();
|
|
1680
|
+
});
|
|
1681
|
+
proc.stderr.on("data", (d) => {
|
|
1682
|
+
stderr += d.toString();
|
|
1683
|
+
});
|
|
1684
|
+
const timer = config.timeout ? setTimeout(() => {
|
|
1685
|
+
proc.kill("SIGTERM");
|
|
1686
|
+
}, config.timeout) : null;
|
|
1687
|
+
proc.on("close", (code) => {
|
|
1688
|
+
if (timer)
|
|
1689
|
+
clearTimeout(timer);
|
|
1690
|
+
resolve({ sessionId, pid: proc.pid, exitCode: code, output: stdout, error: code !== 0 ? stderr : void 0 });
|
|
1691
|
+
});
|
|
1692
|
+
proc.on("error", (err) => {
|
|
1693
|
+
if (timer)
|
|
1694
|
+
clearTimeout(timer);
|
|
1695
|
+
resolve({ sessionId, error: `Failed to spawn aider: ${err.message}` });
|
|
1696
|
+
});
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
launchInteractive(config, sessionId) {
|
|
1700
|
+
const parts = ["aider"];
|
|
1701
|
+
if (config.model)
|
|
1702
|
+
parts.push("--model", config.model);
|
|
1703
|
+
const script = `cd ${JSON.stringify(config.projectPath)} && ${parts.join(" ")}`;
|
|
1704
|
+
const proc = spawn4("osascript", ["-e", `tell application "Terminal" to do script ${JSON.stringify(script)}`], {
|
|
1705
|
+
stdio: "ignore",
|
|
1706
|
+
detached: true
|
|
1707
|
+
});
|
|
1708
|
+
proc.unref();
|
|
1709
|
+
return Promise.resolve({ sessionId, pid: proc.pid });
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
// ../../packages/session/dist/launchers/generic.js
|
|
1714
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
1715
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
1716
|
+
var GenericLauncher = class {
|
|
1717
|
+
tool;
|
|
1718
|
+
constructor(tool) {
|
|
1719
|
+
this.tool = tool;
|
|
1720
|
+
}
|
|
1721
|
+
capabilities = { headless: false, interactive: true, remoteSpawn: false };
|
|
1722
|
+
async launch(config) {
|
|
1723
|
+
const sessionId = randomUUID4();
|
|
1724
|
+
if (config.mode === "headless") {
|
|
1725
|
+
return { sessionId, error: `${this.tool} does not support headless mode` };
|
|
1726
|
+
}
|
|
1727
|
+
const script = `cd ${JSON.stringify(config.projectPath)} && echo "Session ${sessionId} \u2014 tool: ${this.tool}" && exec $SHELL`;
|
|
1728
|
+
const proc = spawn5("osascript", ["-e", `tell application "Terminal" to do script ${JSON.stringify(script)}`], {
|
|
1729
|
+
stdio: "ignore",
|
|
1730
|
+
detached: true
|
|
1731
|
+
});
|
|
1732
|
+
proc.unref();
|
|
1733
|
+
return { sessionId, pid: proc.pid };
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1737
|
+
// ../../packages/session/dist/launchers/index.js
|
|
1738
|
+
var launchers = {
|
|
1739
|
+
claude_code: () => new ClaudeCodeLauncher(),
|
|
1740
|
+
codex: () => new CodexLauncher(),
|
|
1741
|
+
aider: () => new AiderLauncher()
|
|
1742
|
+
};
|
|
1743
|
+
function getLauncher(tool) {
|
|
1744
|
+
const factory = launchers[tool];
|
|
1745
|
+
return factory ? factory() : new GenericLauncher(tool);
|
|
1746
|
+
}
|
|
1747
|
+
function getAvailableLaunchers() {
|
|
1748
|
+
return Object.entries(launchers).map(([tool, factory]) => ({
|
|
1749
|
+
tool,
|
|
1750
|
+
capabilities: factory().capabilities
|
|
1751
|
+
}));
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
// ../../packages/session/dist/launchers/worktree-path.js
|
|
1755
|
+
import path from "node:path";
|
|
1756
|
+
function sanitizeBranch(branch) {
|
|
1757
|
+
return branch.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^[-.]+|[-.]+$/g, "") || "worktree";
|
|
1758
|
+
}
|
|
1759
|
+
function worktreePathFor(options) {
|
|
1760
|
+
return path.resolve(options.basePath ?? path.join(options.repoRoot, "..", ".rulemetric-worktrees", sanitizeBranch(options.branch)));
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
export {
|
|
1764
|
+
SESSION_TOOLS,
|
|
1765
|
+
SESSION_EVENT_TYPES,
|
|
1766
|
+
ClaudeCodeAdapter,
|
|
1767
|
+
CursorAdapter,
|
|
1768
|
+
VSCodeCopilotAdapter,
|
|
1769
|
+
CopilotAgentAdapter,
|
|
1770
|
+
RuleMetricMcpAdapter,
|
|
1771
|
+
getAdapter,
|
|
1772
|
+
detectTool,
|
|
1773
|
+
buildAnalysisPrompt,
|
|
1774
|
+
parseAnalysisResponse,
|
|
1775
|
+
getAllProviders,
|
|
1776
|
+
discoverAllSessions,
|
|
1777
|
+
getProvider,
|
|
1778
|
+
sanitizeTmuxName,
|
|
1779
|
+
buildTmuxLaunchArgs,
|
|
1780
|
+
buildTmuxSendKeysArgs,
|
|
1781
|
+
buildTmuxHasSessionArgs,
|
|
1782
|
+
buildTmuxAttachCommand,
|
|
1783
|
+
getLauncher,
|
|
1784
|
+
getAvailableLaunchers,
|
|
1785
|
+
sanitizeBranch,
|
|
1786
|
+
worktreePathFor
|
|
1787
|
+
};
|
|
1788
|
+
//# sourceMappingURL=chunk-B5KNTGMJ.js.map
|