ctxtop 4.1.0 โ†’ 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (318) hide show
  1. package/.antigravity-plugin/plugin.json +1 -1
  2. package/.claude-plugin/plugin.json +21 -18
  3. package/CHECKSUMS.sha256 +51 -44
  4. package/LICENSE +27 -27
  5. package/README.md +90 -56
  6. package/SECURITY.md +7 -1
  7. package/assets/hero-demo.svg +1 -1
  8. package/bin/ctxtop.mjs +267 -54
  9. package/config/modelCatalog.json +847 -273
  10. package/hooks/handlers/hookIpcClient.mjs +8 -4
  11. package/hooks/handlers/post-model-switch.mjs +39 -2
  12. package/hooks/handlers/post-tool-use-core.mjs +394 -0
  13. package/hooks/handlers/post-tool-use.mjs +54 -321
  14. package/hooks/handlers/pre-model-switch.mjs +115 -5
  15. package/hooks/handlers/pre-tool-use-core.mjs +680 -0
  16. package/hooks/handlers/pre-tool-use.mjs +61 -571
  17. package/hooks/handlers/stop-gate.mjs +20 -8
  18. package/hooks/handlers/user-prompt-submit.mjs +111 -2
  19. package/hooks/post_tool_use.mjs +17 -4
  20. package/hooks/pre_tool_use.mjs +84 -54
  21. package/hooks.json +56 -56
  22. package/package.json +4 -3
  23. package/packages/antigravity/package.json +10 -3
  24. package/packages/antigravity/src/adapter.mjs +109 -0
  25. package/packages/antigravity/src/index.mjs +7 -1
  26. package/packages/claude-code/package.json +10 -3
  27. package/packages/claude-code/src/adapter.mjs +194 -0
  28. package/packages/claude-code/src/index.mjs +8 -2
  29. package/packages/claude-code/src/register.js +726 -0
  30. package/packages/core/package.json +6 -2
  31. package/packages/core/src/catalog/detectorCatalog.mjs +558 -0
  32. package/packages/core/src/catalog/index.mjs +1 -0
  33. package/packages/core/src/catalog/safeguardGuide.mjs +412 -0
  34. package/packages/core/src/coach/cacheGravityRouter.mjs +1547 -0
  35. package/packages/core/src/coach/effortShiftDetector.mjs +316 -0
  36. package/packages/core/src/coach/microSkills.mjs +1 -0
  37. package/packages/core/src/coach/promptHygieneGovernor.mjs +1 -0
  38. package/packages/core/src/coach/repoCalibration.mjs +254 -0
  39. package/packages/core/src/coach/resumeToolsetAuditor.mjs +321 -0
  40. package/packages/core/src/coach/savedQuotaLedger.mjs +527 -0
  41. package/packages/core/src/coach/smartCompactAdvisor.mjs +339 -0
  42. package/packages/core/src/coach/stateBatonHydrator.mjs +810 -0
  43. package/packages/core/src/coach/ttlWatchdog.mjs +464 -0
  44. package/packages/core/src/config/anthropicModelCatalog.json +607 -0
  45. package/packages/core/src/config/catalogLoader.mjs +1271 -0
  46. package/packages/core/src/config/horizonConfig.mjs +1055 -0
  47. package/packages/core/src/control/callTree.mjs +338 -0
  48. package/packages/core/src/control/coachLatches.mjs +126 -0
  49. package/packages/core/src/control/controlStateMachine.mjs +205 -0
  50. package/packages/core/src/control/index.mjs +49 -0
  51. package/packages/core/src/control/swarmWorktree.mjs +109 -0
  52. package/packages/core/src/control/toolSuspension.mjs +197 -0
  53. package/packages/core/src/diagnostics/drift_guard.mjs +382 -0
  54. package/packages/core/src/diagnostics/index.mjs +9 -0
  55. package/packages/core/src/diagnostics/micro_skills.mjs +471 -0
  56. package/packages/core/src/diagnostics/prompt_hygiene_governor.mjs +888 -0
  57. package/packages/core/src/economics/billingBlocks.mjs +251 -0
  58. package/packages/core/src/economics/cacheGravity.mjs +371 -0
  59. package/packages/core/src/economics/cliffBreaker.mjs +256 -0
  60. package/packages/core/src/economics/driftLatency.mjs +433 -0
  61. package/packages/core/src/economics/dualTtl.mjs +198 -0
  62. package/packages/core/src/economics/index.mjs +47 -0
  63. package/packages/core/src/economics/retentionRadar.mjs +348 -0
  64. package/packages/core/src/economics/shadowAutoModel.mjs +228 -0
  65. package/packages/core/src/guards/bucketBAlphaBeta.mjs +860 -0
  66. package/packages/core/src/guards/bucketBGamma.mjs +442 -0
  67. package/packages/core/src/guards/bucketBHeuristics.mjs +37 -0
  68. package/packages/core/src/guards/circuitBreakers.mjs +1202 -0
  69. package/packages/core/src/guards/det01_03_shell_secret.mjs +1184 -0
  70. package/packages/core/src/guards/det04_12_thrash_rot.mjs +572 -0
  71. package/packages/core/src/guards/det13_20_mcp_scope.mjs +913 -0
  72. package/packages/core/src/guards/docIndexCore.mjs +446 -0
  73. package/packages/core/src/guards/losslessPostSanitizer.mjs +317 -0
  74. package/packages/core/src/guards/slopsquatGate.mjs +551 -0
  75. package/packages/core/src/index.js +27 -0
  76. package/packages/core/src/index.mjs +25 -1
  77. package/packages/core/src/telemetry/otelExporter.mjs +187 -0
  78. package/packages/core/src/telemetry/scopeLockRegistry.mjs +522 -0
  79. package/packages/core/src/telemetry/sprintMetrics.mjs +327 -0
  80. package/packages/core/src/telemetry/swarmTopology.mjs +152 -0
  81. package/packages/core/src/telemetry/telemetryBridge.mjs +1232 -0
  82. package/packages/core/src/ui/brailleSparkline.mjs +142 -0
  83. package/packages/core/src/ui/costRadarSvg.mjs +276 -0
  84. package/packages/core/src/ui/horizonGrid.mjs +475 -0
  85. package/packages/core/src/ui/horizonPanelHtml.mjs +1502 -0
  86. package/packages/core/src/ui/modViews.mjs +1558 -0
  87. package/packages/core/src/ui/pdfReceiptGenerator.mjs +329 -0
  88. package/packages/core/src/ustf/index.mjs +7 -0
  89. package/packages/core/src/ustf/normalizer.mjs +512 -0
  90. package/packages/core/src/ustf/schema.mjs +186 -0
  91. package/packages/core/src/utils/runtime.mjs +962 -0
  92. package/packages/engine-node/package.json +6 -2
  93. package/packages/engine-node/src/db/index.mjs +58 -0
  94. package/packages/engine-node/src/db/jsonl_fallback.mjs +184 -0
  95. package/packages/engine-node/src/db/probe.mjs +342 -0
  96. package/packages/engine-node/src/db/sqlite_wrapper.mjs +122 -0
  97. package/packages/engine-node/src/index.mjs +11 -1
  98. package/packages/engine-node/src/ipc/client.mjs +447 -0
  99. package/packages/engine-node/src/ipc/fast_client.mjs +191 -0
  100. package/packages/engine-node/src/ipc/index.mjs +24 -0
  101. package/packages/engine-node/src/ipc/protocol.mjs +177 -0
  102. package/packages/engine-node/src/ipc/server.mjs +445 -0
  103. package/packages/engine-node/src/multi_host_mcp.mjs +168 -0
  104. package/packages/engine-node/src/offloader/index.mjs +6 -0
  105. package/packages/engine-node/src/offloader/tool_offloader.mjs +241 -0
  106. package/packages/engine-node/src/rsl/index.mjs +3 -0
  107. package/packages/engine-node/src/sensors/blindspots.mjs +376 -0
  108. package/packages/engine-node/src/sensors/git_merge_tree.mjs +223 -0
  109. package/packages/engine-node/src/sensors/index.mjs +7 -0
  110. package/packages/engine-node/src/vendor/config/default_flightcheck.json +133 -0
  111. package/packages/engine-node/src/vendor/config/modelCatalog.json +1359 -0
  112. package/packages/engine-node/src/vendor/config/platformQuirks.json +19 -0
  113. package/packages/engine-node/src/vendor/core/atomic_io.mjs +124 -0
  114. package/packages/engine-node/src/vendor/core/constants.mjs +2150 -0
  115. package/packages/engine-node/src/vendor/core/doc_indexer.mjs +338 -0
  116. package/packages/engine-node/src/vendor/core/rsl_clash_auditor.mjs +423 -0
  117. package/packages/engine-node/src/vendor/core/rsl_distiller.mjs +394 -0
  118. package/packages/engine-node/src/vendor/core/rsl_ledger.mjs +1029 -0
  119. package/packages/engine-node/src/vendor/core/rsl_triage.mjs +1051 -0
  120. package/packages/engine-node/src/vendor/core/shield_manager.mjs +1417 -0
  121. package/packages/engine-node/src/vendor/core-isomorphic/catalog/detectorCatalog.mjs +558 -0
  122. package/packages/engine-node/src/vendor/core-isomorphic/catalog/index.mjs +1 -0
  123. package/packages/engine-node/src/vendor/core-isomorphic/catalog/safeguardGuide.mjs +412 -0
  124. package/packages/engine-node/src/vendor/core-isomorphic/coach/cacheGravityRouter.mjs +1547 -0
  125. package/packages/engine-node/src/vendor/core-isomorphic/coach/effortShiftDetector.mjs +316 -0
  126. package/packages/engine-node/src/vendor/core-isomorphic/coach/microSkills.mjs +1 -0
  127. package/packages/engine-node/src/vendor/core-isomorphic/coach/promptHygieneGovernor.mjs +1 -0
  128. package/packages/engine-node/src/vendor/core-isomorphic/coach/repoCalibration.mjs +254 -0
  129. package/packages/engine-node/src/vendor/core-isomorphic/coach/resumeToolsetAuditor.mjs +321 -0
  130. package/packages/engine-node/src/vendor/core-isomorphic/coach/savedQuotaLedger.mjs +527 -0
  131. package/packages/engine-node/src/vendor/core-isomorphic/coach/smartCompactAdvisor.mjs +339 -0
  132. package/packages/engine-node/src/vendor/core-isomorphic/coach/stateBatonHydrator.mjs +810 -0
  133. package/packages/engine-node/src/vendor/core-isomorphic/coach/ttlWatchdog.mjs +464 -0
  134. package/packages/engine-node/src/vendor/core-isomorphic/config/anthropicModelCatalog.json +607 -0
  135. package/packages/engine-node/src/vendor/core-isomorphic/config/catalogLoader.mjs +1271 -0
  136. package/packages/engine-node/src/vendor/core-isomorphic/config/horizonConfig.mjs +1055 -0
  137. package/packages/engine-node/src/vendor/core-isomorphic/control/callTree.mjs +338 -0
  138. package/packages/engine-node/src/vendor/core-isomorphic/control/coachLatches.mjs +126 -0
  139. package/packages/engine-node/src/vendor/core-isomorphic/control/controlStateMachine.mjs +205 -0
  140. package/packages/engine-node/src/vendor/core-isomorphic/control/index.mjs +49 -0
  141. package/packages/engine-node/src/vendor/core-isomorphic/control/swarmWorktree.mjs +109 -0
  142. package/packages/engine-node/src/vendor/core-isomorphic/control/toolSuspension.mjs +197 -0
  143. package/packages/engine-node/src/vendor/core-isomorphic/diagnostics/drift_guard.mjs +382 -0
  144. package/packages/engine-node/src/vendor/core-isomorphic/diagnostics/index.mjs +9 -0
  145. package/packages/engine-node/src/vendor/core-isomorphic/diagnostics/micro_skills.mjs +471 -0
  146. package/packages/engine-node/src/vendor/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +888 -0
  147. package/packages/engine-node/src/vendor/core-isomorphic/economics/billingBlocks.mjs +251 -0
  148. package/packages/engine-node/src/vendor/core-isomorphic/economics/cacheGravity.mjs +371 -0
  149. package/packages/engine-node/src/vendor/core-isomorphic/economics/cliffBreaker.mjs +256 -0
  150. package/packages/engine-node/src/vendor/core-isomorphic/economics/driftLatency.mjs +433 -0
  151. package/packages/engine-node/src/vendor/core-isomorphic/economics/dualTtl.mjs +198 -0
  152. package/packages/engine-node/src/vendor/core-isomorphic/economics/index.mjs +47 -0
  153. package/packages/engine-node/src/vendor/core-isomorphic/economics/retentionRadar.mjs +348 -0
  154. package/packages/engine-node/src/vendor/core-isomorphic/economics/shadowAutoModel.mjs +228 -0
  155. package/packages/engine-node/src/vendor/core-isomorphic/guards/bucketBAlphaBeta.mjs +860 -0
  156. package/packages/engine-node/src/vendor/core-isomorphic/guards/bucketBGamma.mjs +442 -0
  157. package/packages/engine-node/src/vendor/core-isomorphic/guards/bucketBHeuristics.mjs +37 -0
  158. package/packages/engine-node/src/vendor/core-isomorphic/guards/circuitBreakers.mjs +1202 -0
  159. package/packages/engine-node/src/vendor/core-isomorphic/guards/det01_03_shell_secret.mjs +1184 -0
  160. package/packages/engine-node/src/vendor/core-isomorphic/guards/det04_12_thrash_rot.mjs +572 -0
  161. package/packages/engine-node/src/vendor/core-isomorphic/guards/det13_20_mcp_scope.mjs +913 -0
  162. package/packages/engine-node/src/vendor/core-isomorphic/guards/docIndexCore.mjs +446 -0
  163. package/packages/engine-node/src/vendor/core-isomorphic/guards/losslessPostSanitizer.mjs +317 -0
  164. package/packages/engine-node/src/vendor/core-isomorphic/guards/slopsquatGate.mjs +551 -0
  165. package/packages/engine-node/src/vendor/core-isomorphic/index.js +27 -0
  166. package/packages/engine-node/src/vendor/core-isomorphic/telemetry/otelExporter.mjs +187 -0
  167. package/packages/engine-node/src/vendor/core-isomorphic/telemetry/scopeLockRegistry.mjs +522 -0
  168. package/packages/engine-node/src/vendor/core-isomorphic/telemetry/sprintMetrics.mjs +327 -0
  169. package/packages/engine-node/src/vendor/core-isomorphic/telemetry/swarmTopology.mjs +152 -0
  170. package/packages/engine-node/src/vendor/core-isomorphic/telemetry/telemetryBridge.mjs +1232 -0
  171. package/packages/engine-node/src/vendor/core-isomorphic/ui/brailleSparkline.mjs +142 -0
  172. package/packages/engine-node/src/vendor/core-isomorphic/ui/costRadarSvg.mjs +276 -0
  173. package/packages/engine-node/src/vendor/core-isomorphic/ui/horizonGrid.mjs +475 -0
  174. package/packages/engine-node/src/vendor/core-isomorphic/ui/horizonPanelHtml.mjs +1502 -0
  175. package/packages/engine-node/src/vendor/core-isomorphic/ui/modViews.mjs +1558 -0
  176. package/packages/engine-node/src/vendor/core-isomorphic/ui/pdfReceiptGenerator.mjs +329 -0
  177. package/packages/engine-node/src/vendor/core-isomorphic/ustf/index.mjs +7 -0
  178. package/packages/engine-node/src/vendor/core-isomorphic/ustf/normalizer.mjs +512 -0
  179. package/packages/engine-node/src/vendor/core-isomorphic/ustf/schema.mjs +186 -0
  180. package/packages/engine-node/src/vendor/core-isomorphic/utils/runtime.mjs +962 -0
  181. package/packages/mcp/package.json +7 -3
  182. package/packages/mcp/src/server.mjs +115 -14
  183. package/packages/mcp/src/vendor/config/default_flightcheck.json +133 -0
  184. package/packages/mcp/src/vendor/config/modelCatalog.json +1359 -0
  185. package/packages/mcp/src/vendor/config/platformQuirks.json +19 -0
  186. package/packages/mcp/src/vendor/core/atomic_io.mjs +124 -0
  187. package/packages/mcp/src/vendor/core/coach/saved_quota_ledger.mjs +615 -0
  188. package/packages/mcp/src/vendor/core/constants.mjs +2150 -0
  189. package/packages/mcp/src/vendor/core/doc_indexer.mjs +338 -0
  190. package/packages/mcp/src/vendor/core/fts5_output_compressor.mjs +596 -0
  191. package/packages/mcp/src/vendor/core/hook_diagnostics.mjs +158 -0
  192. package/packages/mcp/src/vendor/core/paths.mjs +311 -0
  193. package/packages/mcp/src/vendor/core/session_auditor.mjs +1109 -0
  194. package/packages/mcp/src/vendor/core/sqlite_client.mjs +289 -0
  195. package/packages/mcp/src/vendor/core/telemetry/scope_lock_registry.mjs +578 -0
  196. package/packages/mcp/src/vendor/core-isomorphic/catalog/detectorCatalog.mjs +558 -0
  197. package/packages/mcp/src/vendor/core-isomorphic/catalog/index.mjs +1 -0
  198. package/packages/mcp/src/vendor/core-isomorphic/catalog/safeguardGuide.mjs +412 -0
  199. package/packages/mcp/src/vendor/core-isomorphic/coach/cacheGravityRouter.mjs +1547 -0
  200. package/packages/mcp/src/vendor/core-isomorphic/coach/effortShiftDetector.mjs +316 -0
  201. package/packages/mcp/src/vendor/core-isomorphic/coach/microSkills.mjs +1 -0
  202. package/packages/mcp/src/vendor/core-isomorphic/coach/promptHygieneGovernor.mjs +1 -0
  203. package/packages/mcp/src/vendor/core-isomorphic/coach/repoCalibration.mjs +254 -0
  204. package/packages/mcp/src/vendor/core-isomorphic/coach/resumeToolsetAuditor.mjs +321 -0
  205. package/packages/mcp/src/vendor/core-isomorphic/coach/savedQuotaLedger.mjs +527 -0
  206. package/packages/mcp/src/vendor/core-isomorphic/coach/smartCompactAdvisor.mjs +339 -0
  207. package/packages/mcp/src/vendor/core-isomorphic/coach/stateBatonHydrator.mjs +810 -0
  208. package/packages/mcp/src/vendor/core-isomorphic/coach/ttlWatchdog.mjs +464 -0
  209. package/packages/mcp/src/vendor/core-isomorphic/config/anthropicModelCatalog.json +607 -0
  210. package/packages/mcp/src/vendor/core-isomorphic/config/catalogLoader.mjs +1271 -0
  211. package/packages/mcp/src/vendor/core-isomorphic/config/horizonConfig.mjs +1055 -0
  212. package/packages/mcp/src/vendor/core-isomorphic/control/callTree.mjs +338 -0
  213. package/packages/mcp/src/vendor/core-isomorphic/control/coachLatches.mjs +126 -0
  214. package/packages/mcp/src/vendor/core-isomorphic/control/controlStateMachine.mjs +205 -0
  215. package/packages/mcp/src/vendor/core-isomorphic/control/index.mjs +49 -0
  216. package/packages/mcp/src/vendor/core-isomorphic/control/swarmWorktree.mjs +109 -0
  217. package/packages/mcp/src/vendor/core-isomorphic/control/toolSuspension.mjs +197 -0
  218. package/packages/mcp/src/vendor/core-isomorphic/diagnostics/drift_guard.mjs +382 -0
  219. package/packages/mcp/src/vendor/core-isomorphic/diagnostics/index.mjs +9 -0
  220. package/packages/mcp/src/vendor/core-isomorphic/diagnostics/micro_skills.mjs +471 -0
  221. package/packages/mcp/src/vendor/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +888 -0
  222. package/packages/mcp/src/vendor/core-isomorphic/economics/billingBlocks.mjs +251 -0
  223. package/packages/mcp/src/vendor/core-isomorphic/economics/cacheGravity.mjs +371 -0
  224. package/packages/mcp/src/vendor/core-isomorphic/economics/cliffBreaker.mjs +256 -0
  225. package/packages/mcp/src/vendor/core-isomorphic/economics/driftLatency.mjs +433 -0
  226. package/packages/mcp/src/vendor/core-isomorphic/economics/dualTtl.mjs +198 -0
  227. package/packages/mcp/src/vendor/core-isomorphic/economics/index.mjs +47 -0
  228. package/packages/mcp/src/vendor/core-isomorphic/economics/retentionRadar.mjs +348 -0
  229. package/packages/mcp/src/vendor/core-isomorphic/economics/shadowAutoModel.mjs +228 -0
  230. package/packages/mcp/src/vendor/core-isomorphic/guards/bucketBAlphaBeta.mjs +860 -0
  231. package/packages/mcp/src/vendor/core-isomorphic/guards/bucketBGamma.mjs +442 -0
  232. package/packages/mcp/src/vendor/core-isomorphic/guards/bucketBHeuristics.mjs +37 -0
  233. package/packages/mcp/src/vendor/core-isomorphic/guards/circuitBreakers.mjs +1202 -0
  234. package/packages/mcp/src/vendor/core-isomorphic/guards/det01_03_shell_secret.mjs +1184 -0
  235. package/packages/mcp/src/vendor/core-isomorphic/guards/det04_12_thrash_rot.mjs +572 -0
  236. package/packages/mcp/src/vendor/core-isomorphic/guards/det13_20_mcp_scope.mjs +913 -0
  237. package/packages/mcp/src/vendor/core-isomorphic/guards/docIndexCore.mjs +446 -0
  238. package/packages/mcp/src/vendor/core-isomorphic/guards/losslessPostSanitizer.mjs +317 -0
  239. package/packages/mcp/src/vendor/core-isomorphic/guards/slopsquatGate.mjs +551 -0
  240. package/packages/mcp/src/vendor/core-isomorphic/index.js +27 -0
  241. package/packages/mcp/src/vendor/core-isomorphic/telemetry/otelExporter.mjs +187 -0
  242. package/packages/mcp/src/vendor/core-isomorphic/telemetry/scopeLockRegistry.mjs +522 -0
  243. package/packages/mcp/src/vendor/core-isomorphic/telemetry/sprintMetrics.mjs +327 -0
  244. package/packages/mcp/src/vendor/core-isomorphic/telemetry/swarmTopology.mjs +152 -0
  245. package/packages/mcp/src/vendor/core-isomorphic/telemetry/telemetryBridge.mjs +1232 -0
  246. package/packages/mcp/src/vendor/core-isomorphic/ui/brailleSparkline.mjs +142 -0
  247. package/packages/mcp/src/vendor/core-isomorphic/ui/costRadarSvg.mjs +276 -0
  248. package/packages/mcp/src/vendor/core-isomorphic/ui/horizonGrid.mjs +475 -0
  249. package/packages/mcp/src/vendor/core-isomorphic/ui/horizonPanelHtml.mjs +1502 -0
  250. package/packages/mcp/src/vendor/core-isomorphic/ui/modViews.mjs +1558 -0
  251. package/packages/mcp/src/vendor/core-isomorphic/ui/pdfReceiptGenerator.mjs +329 -0
  252. package/packages/mcp/src/vendor/core-isomorphic/ustf/index.mjs +7 -0
  253. package/packages/mcp/src/vendor/core-isomorphic/ustf/normalizer.mjs +512 -0
  254. package/packages/mcp/src/vendor/core-isomorphic/ustf/schema.mjs +186 -0
  255. package/packages/mcp/src/vendor/core-isomorphic/utils/runtime.mjs +962 -0
  256. package/packages/mcp/src/vendor/engine-node/db/probe.mjs +342 -0
  257. package/packages/mcp/src/vendor/pro/pro_license.mjs +547 -0
  258. package/packages/pro/package.json +23 -16
  259. package/packages/pro/src/index.mjs +9 -3
  260. package/packages/pro/src/pro_license.mjs +547 -0
  261. package/packages/pro/src/team_finops_pack.mjs +241 -241
  262. package/packages/pro/workers/polar_webhook_worker.mjs +219 -215
  263. package/plugin.json +1 -1
  264. package/sidecars/horizon-daemon/server.mjs +482 -44
  265. package/src/cli/doctor.mjs +11 -2
  266. package/src/cli/horizon_hud.mjs +31 -15
  267. package/src/cli/init.mjs +46 -13
  268. package/src/config/modelCatalog.json +886 -231
  269. package/src/core/classifier.mjs +25 -11
  270. package/src/core/coach/circuit_breakers.mjs +84 -6
  271. package/src/core/coach/task_quota_router.mjs +8 -0
  272. package/src/core/code_fold_lite.mjs +169 -0
  273. package/src/core/config.mjs +44 -0
  274. package/src/core/constants.mjs +175 -12
  275. package/src/core/detectors_det01_to_16.mjs +44 -3
  276. package/src/core/fts5_output_compressor.mjs +272 -35
  277. package/src/core/horizon_config.mjs +42 -0
  278. package/src/core/parser.mjs +86 -11
  279. package/src/core/pro_license.mjs +174 -12
  280. package/src/core/pruner.mjs +7 -146
  281. package/src/core/quota.mjs +14 -2
  282. package/src/core/rsl_distiller.mjs +31 -9
  283. package/src/core/rsl_ledger.mjs +66 -6
  284. package/src/core/rsl_triage.mjs +159 -17
  285. package/src/core/session_auditor.mjs +476 -25
  286. package/src/core/shadow_auto_ledger.mjs +205 -0
  287. package/src/core/sqlite_client.mjs +10 -4
  288. package/src/core/subagents.mjs +18 -2
  289. package/src/core/task_quota_router.mjs +61 -4
  290. package/src/core-isomorphic/catalog/safeguardGuide.mjs +412 -0
  291. package/src/core-isomorphic/coach/effortShiftDetector.mjs +316 -0
  292. package/src/core-isomorphic/coach/smartCompactAdvisor.mjs +54 -20
  293. package/src/core-isomorphic/config/anthropicModelCatalog.json +1 -0
  294. package/src/core-isomorphic/config/catalogLoader.mjs +6 -3
  295. package/src/core-isomorphic/config/horizonConfig.mjs +1 -1
  296. package/src/core-isomorphic/economics/cacheGravity.mjs +3 -1
  297. package/src/core-isomorphic/economics/shadowAutoModel.mjs +228 -0
  298. package/src/core-isomorphic/guards/bucketBGamma.mjs +1 -1
  299. package/src/core-isomorphic/telemetry/telemetryBridge.mjs +77 -1
  300. package/src/core-isomorphic/ui/horizonPanelHtml.mjs +395 -130
  301. package/src/core-isomorphic/ui/modViews.mjs +62 -8
  302. package/src/diagnostics/claudeHookCapabilities.mjs +32 -2
  303. package/src/diagnostics/doctorEngine.mjs +28 -2
  304. package/src/engine-node/ipc/fast_client.mjs +191 -0
  305. package/src/engine-node/ipc/index.mjs +2 -0
  306. package/src/engine-node/multi_host_mcp.mjs +168 -0
  307. package/src/hooks/antigravity_rsl_hook.mjs +24 -2
  308. package/src/hooks/claude_rsl_hook.mjs +22 -2
  309. package/src/hooks/daemon_hook_bridge.mjs +256 -0
  310. package/src/hooks/fast_hook_ipc.mjs +295 -0
  311. package/src/hooks/post_invocation.mjs +37 -597
  312. package/src/hooks/post_invocation_core.mjs +623 -0
  313. package/src/hooks/pre_invocation.mjs +103 -1668
  314. package/src/hooks/pre_invocation_core.mjs +1830 -0
  315. package/src/utils/sessionCalibration.mjs +52 -5
  316. package/src/webview/advanced_view.html +34 -18
  317. package/src/webview/horizon_panel.html +3233 -675
  318. package/src/webview/simple_view.html +1 -1
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  <div align="center">
2
2
 
3
- # Highbeam (ctxtop v4.0) โ€” Active Context Surgeon, KV-Cache Shield & Token FinOps for Claude Code & Google Antigravity
3
+ # Highbeam (`ctxtop` v4.1) โ€” Active Context Surgeon, KV-Cache Shield & Token FinOps for Claude Code, Google Antigravity & MCP Hosts
4
4
 
5
- **Local Context Window Profiler, KV-Cache TTL Monitor & Deterministic PreInvocation / PreToolUse Surgeon (`~0.18ms` Tier-1 In-Process / `~25โ€“90ms` Tier-2 CLI Hook) for Claude Code & Google Antigravity**
5
+ **Local Context Window Profiler, KV-Cache TTL Monitor, Multi-Family FTS5 Output Compressor & Deterministic PreInvocation / PreToolUse Surgeon (`~0.1โ€“2.9ms` avg Tier-1 In-Process ยท `~58ms` Warm IPC / `~105ms` Cold Windows Tier-2 Hook) across Google Antigravity, Claude Code, Codex CLI, Gemini CLI & Cursor**
6
6
 
7
7
  [![Zero Runtime Dependencies](https://img.shields.io/badge/dependencies-0_runtime-brightgreen.svg)](#systems-architecture--zero-trust-security)
8
- [![Hook Latency](https://img.shields.io/badge/Tier--1_in--process-~0.18ms_p95_%7C_Tier--2_CLI_hook-~25--90ms-00e5ff.svg)](#deterministic-preinvocation-router--6-local-sensors)
9
- [![Node.js >= 20](https://img.shields.io/badge/node-%3E%3D20_zero_deps-339933.svg)](#quick-start)
8
+ [![Hook Latency](https://img.shields.io/badge/Tier--1_in--process-~2.9ms_avg_%7C_Tier--2_hook-~58ms_IPC%2F~105ms_cold-00e5ff.svg)](#deterministic-preinvocation-router--6-local-sensors)
9
+ [![Node.js >= 20](https://img.shields.io/badge/node-%3E%3D20_zero_deps-339933.svg)](#try-in-10-seconds-zero-hooks--zero-writes)
10
10
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
11
- [![Claude Code & Antigravity](https://img.shields.io/badge/Hosts-Claude_Code_%2B_Google_Antigravity-blueviolet.svg)](#-installation--quick-start)
11
+ [![Multi-Host Parity](https://img.shields.io/badge/Hosts-Antigravity_%7C_Claude_%7C_Codex_%7C_Gemini_%7C_Cursor-blueviolet.svg)](#-installation--quick-start)
12
12
 
13
- [**Live Interactive Demo**](https://gizzant.github.io/attention-horizon-antigravity/) โ€ข [**Quick Start**](#-installation--quick-start) โ€ข [**Cookbook & Recipes**](docs/COOKBOOK.md) โ€ข [**Systems Architecture**](#systems-architecture--zero-trust-security)
13
+ [**Live Interactive Demo**](https://gizzant.github.io/attention-horizon-antigravity/) โ€ข [**10-Second 5-Host Audit**](#try-in-10-seconds-zero-hooks--zero-writes) โ€ข [**Quick Start**](#-installation--quick-start) โ€ข [**Cookbook**](docs/COOKBOOK.md) โ€ข [**Benchmarks**](docs/ANTIGRAVITY_AND_COMPRESSION_BENCHMARK.md) โ€ข [**Enterprise MDM**](docs/ENTERPRISE_MDM.md)
14
14
 
15
15
  <br/>
16
16
 
@@ -20,33 +20,52 @@
20
20
 
21
21
  ---
22
22
 
23
- ## โšก Installation & Quick Start
23
+ ## โšก Try in 10 Seconds (Zero Hooks / Zero Writes)
24
24
 
25
- | **Google Antigravity** *(1-Line Install)* | **Claude Code** *(1-Line Install)* |
26
- | :--- | :--- |
25
+ Before installing any hooks or modifying config files, scan your last 7 days of local **Google Antigravity**, **Claude Code**, **OpenAI Codex CLI**, **Gemini CLI**, and **Cursor** sessions strictly read-only to measure preventable token waste, cold-cache spikes, and oversized tool dumps:
26
+
27
+ ```bash
28
+ npx ctxtop audit --days 7
29
+ ```
30
+
31
+ ```text
32
+ [Highbeam Session ROI Audit] Window: 7d | Platform: all | Sessions: 12
33
+ Sludge Tax Preventable : 1,420,850 tok ($2.84 USD)
34
+ Cold-Cache Spikes (>5m): 14 | 3x Thrash Loops: 4
35
+ Un-Sliced Large Reads : 11 | Oversized Tool Dumps: 38
36
+ ```
37
+
38
+ ---
39
+
40
+ ## ๐Ÿš€ Installation & Quick Start
41
+
42
+ | **Google Antigravity** *(1-Line Install)* | **Claude Code** *(1-Line Install)* | **Cursor / Windsurf / Codex / Gemini CLI** |
43
+ | :--- | :--- | :--- |
27
44
  | ```bash
28
45
  npx ctxtop init
29
46
  ``` | ```bash
30
- npx ctxtop install --claude
47
+ npx ctxtop install --global
48
+ ``` | ```bash
49
+ npx ctxtop init --cursor --windsurf --codex --gemini-cli
31
50
  ``` |
32
- | *Workspace-only*: `npx ctxtop init --workspace`<br/>*Health check*: `npx ctxtop doctor` | *StatusLine HUD*: `npx ah-statusline --demo`<br/>*In-chat pane*: `/horizon` ยท `/cost-radar` ยท `/handoff` |
51
+ | *Workspace-only*: `npx ctxtop init --workspace`<br/>*Health check*: `npx ctxtop doctor` | *StatusLine HUD*: `npx ctxtop statusline --demo`<br/>*In-chat pane*: `/horizon` ยท `/cost-radar` ยท `/handoff` | *Universal `.mcp.json`*: `npx ctxtop init --all-hosts`<br/>*FTS5 search*: `npx ctxtop search "<keyword>"` |
33
52
 
34
53
  ### Your First 5 Minutes After Installing
35
54
 
36
55
  #### 1. Google Antigravity Workflow
37
56
  1. **Install hooks & sidecar**: Run `npx ctxtop init` in your project root (or globally).
38
- 2. **Open the Highbeam Sidepane**: Launch the local telemetry WebView (`npx ctxtop --serve` or via the Antigravity sidepane) to view real-time context health:
57
+ 2. **Open the Highbeam Sidepane**: Launch the local telemetry WebView (`npx ctxtop ui` or via the Antigravity sidepane) to view real-time context health:
39
58
  - **Simple View (Default)**: 4 glanceable zonesโ€”**Zone A** (Safe Headroom & Warm KV Cache TTL), **Zone B** (`DO / AVOID / HOLD` Model & Effort switch guidance), **Zone C** (Live automated interventions), and **Zone D** (Verified tokens/USD saved + 1-click `/compact`).
40
- - **Advanced View (1-Click Toggle)**: Expands the **40-Cell Chrono-Positional Recall Grid** (`Primacy 0โ€“30%`, `Mid-Trough 30โ€“70%`, `Recency 70โ€“100%`), top token consumer file table, `Off / Coach / Auto-Pilot` mode switcher, and the full `DET-01..32` guard log.
59
+ - **Advanced View (1-Click Toggle)**: Expands the **40-Cell Chrono-Positional Recall Grid** (`Primacy 0โ€“30%`, `Mid-Trough 30โ€“70%`, `Recency 70โ€“100%`), top token consumer file table, `Off / Coach / Auto` mode switcher, and the full `DET-01..32` guard log.
41
60
  3. **Code normally**: Highbeam runs in **`COACH` mode** by defaultโ€”automatically compressing verbose CLI test dumps via SQLite FTS5 and folding repeat file reads without interrupting your prompts.
42
61
 
43
62
  #### 2. Claude Code Workflow
44
- 1. **Install plugin & hooks**: Run `npx ctxtop install --claude` to wire `.claude-plugin/plugin.json`, `hooks/hooks.json`, and the live terminal `statusLine`.
63
+ 1. **Install plugin & hooks**: Run `npx ctxtop install --global` (or `npx ctxtop init --claude`) to wire `.claude-plugin/plugin.json`, `hooks/hooks.json`, and the live terminal `statusLine`.
45
64
  2. **Watch the Live Terminal `statusLine`**: At the bottom of your terminal, Highbeam renders an auto-adapting (`80 / 110 / 144` col) telemetry bar:
46
65
  ```text
47
66
  AH [SCCCCCCC................] sonnet-5-5 64k/200k (32%) ยท Cache 88% (4m12s) ยท COACH ยท Saved $1.84
48
67
  ```
49
- 3. **Open the In-Chat Docked HUD**: Type `/horizon` in chat (or run `npx ah-claude panel` for the standalone HTML workbench) to inspect cache gravity, active guards, and reclaimable tokens.
68
+ 3. **Open the In-Chat Docked HUD**: Type `/horizon` in chat (or run `npx ctxtop panel` for the standalone HTML workbench) to inspect cache gravity, active guards, and reclaimable tokens.
50
69
 
51
70
  ---
52
71
 
@@ -70,7 +89,7 @@ All 6 slash skills are registered identically in both **Google Antigravity** (`p
70
89
 
71
90
  ---
72
91
 
73
- ## ๐Ÿ›ก๏ธ Verified Token Receipt: `+164.0k` Tokens Saved in One 4-Step Coding Loop
92
+ ## ๐Ÿ›ก๏ธ Example Session Receipt: `+164.0k` Tokens Saved in One 4-Step Loop
74
93
 
75
94
  Most CLI trackers passively count tokens *after* your quota is already burned. Highbeam intercepts redundant reads, compresses noisy test dumps via local SQLite FTS5, and shields warm KV prefixes **before** they hit your billing meter:
76
95
 
@@ -78,12 +97,14 @@ Most CLI trackers passively count tokens *after* your quota is already burned. H
78
97
  <img src="assets/zone_c_step3_shield_full.png" alt="Highbeam Zone C Active Protection & Verified Token Receipt (+164.0k tokens saved)" width="460" />
79
98
  </div>
80
99
 
81
- | Step in Coding Loop | Developer / Agent Action | Highbeam Active Intervention (Zone C) | Verified Savings |
100
+ | Step in Coding Loop | Developer / Agent Action | Highbeam Active Intervention (Zone C) | Verified Incident Savings |
82
101
  | :--- | :--- | :--- | :---: |
83
102
  | **1. Warm KV Cache + Repeat Read** | Agent re-reads an unmodified 800-line source file on a `100k` warm cache | **GUARD-4** intercepts the duplicate read (`AST signature stub`) and preserves the `95%` warm KV cache discount | **`+95.0k` tok** *(KV cache)*<br/>**`+800` tok** *(deduped read)* |
84
103
  | **2. Failing Test Suite Dump** | `npm test` dumps `120+` lines of verbose stdout (`~11.4k` tokens) | **SQLite FTS5 BM25 Compressor** indexes raw stdout locally and injects only the 160-token failing assertion digest | **`+11.2k` tok** |
85
104
  | **3. Mid-Session Rule Edit** | Agent updates `AGENTS.md` / `CLAUDE.md` while `60k` prefix is warm (`2m 55s` TTL left) | **PrefixCacheShield** queues the rule delta until TTL expiry or `/compact`, preventing a cold prefix rebuild | **`+57.0k` tok** |
86
- | **Total Verified Session Receipt** | **4-Step Feature / Bugfix Loop** | **Zero context dilution ยท 100% critical error retention** | **`+164.0k` tok (`~$0.33`)** |
105
+ | **Example Incident Receipt** | **4-Step Feature / Bugfix Loop** | **Zero context dilution ยท 100% critical error retention** | **`+164.0k` tok (`~$0.33`)** |
106
+
107
+ > **Reconciled Monthly Expectation:** Across normal coding weeks without deliberate cache-busting, our bottom-up benchmark model estimates **`~$9.42/wk` (`~$40.79/mo`, `~6%โ€“11%` of raw API spend)** saved for a full-time agentic developer, alongside **`30%โ€“50%` longer 5-hour subscription sprints** by cutting `O(Nยฒ)` tool-log compounding.
87
108
 
88
109
  ---
89
110
 
@@ -93,47 +114,40 @@ In agentic coding, every turn re-sends the entire prior conversation history. A
93
114
 
94
115
  1. **For Fixed-Subscription Users (`Claude Pro / Max`, `Antigravity OAuth Seats`) โ€” Stop 2:00 PM Quota Lockouts & Context Rot**:
95
116
  - Compressing noisy tool outputs and duplicate file reads on early turns prevents `O(Nยฒ)` history compounding, **stretching 5-hour sprint quotas by `30%โ€“50%`**.
96
- - Even more importantly, keeping your session below the **70% Safe Horizon** prevents **Context Rot** (middle-window attention decay where the model starts forgetting `AGENTS.md`/`CLAUDE.md` rules, hallucinating imports, and breaking working code).
117
+ - Staying below the **70% Safe Horizon** prevents **Context Rot** (middle-window attention decay where the model starts overlooking `AGENTS.md`/`CLAUDE.md` rules or hallucinating imports).
97
118
  2. **For Metered API & Enterprise Teams โ€” Self-Expensing FinOps ROI**:
98
- - Preventing just two accidental warm-cache busts per day (switching models mid-TTL or editing rule files on a `100k` warm prefix) plus FTS5 log compression saves **`$3โ€“$12/day` (`$60โ€“$240/month`) per active seat**.
119
+ - Preventing accidental warm-cache busts plus automatic FTS5 log compression saves **`~$40.79/mo` (`$9.42/wk`)** for average full-time API devs (`~$149/mo` for heavy 100kโ€“200k Opus swarm users).
99
120
  3. **Daily Cockpit Decisions No Human Can Calculate in Their Head (Zone B)**:
100
- - *"If I downshift from Opus/Argon to Sonnet/Flash right now, will I save quota or pay a 10x cold-prefill penalty?"* โ€” Highbeam computes the horizon-aware KV-cache break-even limit (`C_max`) and post-switch warm-request payback in real time and displays a 1-line verdict: **`Model: Hold (03:34) โ€” switching busts warm cache ยท Effort: changing busts warm cache`**.
121
+ - *"If I downshift from Opus to Sonnet right now, will I save quota or pay a 10x cold-prefill penalty?"* โ€” Highbeam computes the horizon-aware KV-cache break-even limit (`C_max`) and post-switch warm-request payback in real time and displays a 1-line verdict: **`Model: Hold (03:34) โ€” switching busts warm cache`**.
101
122
 
102
123
  ---
103
124
 
104
- ## โš™๏ธ What Runs Automatically (Zero-Friction `COACH` Default)
125
+ ## โš™๏ธ What Runs Automatically (100% Free `COACH` Default)
105
126
 
106
- Highbeam defaults to **`COACH` mode**โ€”performing lossless token surgery silently in the background while never blocking your chat prompt unless a true 3-strike identical failure loop or destructive git command occurs:
127
+ Highbeam defaults to **`COACH` mode**โ€”performing lossless token surgery silently in the background while never blocking your chat prompt unless a 3-strike identical failure loop or destructive git command occurs:
107
128
 
108
129
  | Automated Feature | How It Works Under the Hood | Developer Experience |
109
130
  | :--- | :--- | :--- |
110
131
  | **1. SQLite FTS5 CLI & Test Output Compression** (`PostToolUse`) | Strips ANSI/progress noise, indexes full stdout in local SQLite FTS5 (`porter unicode61`), and injects only the compact failing assertion digest | **100% automatic** โ€” saves `50%โ€“90%` of test/build log tokens with zero lost stack traces |
111
132
  | **2. Post-Edit Delta Diffs & 3rd-Read AST Stubs** (`GUARD-4` in `PreToolUse`) | When the agent re-reads a file after editing 5 lines (or reads the same unclipped file `>=3` times), returns a unified line diff or function-signature AST stub | **100% automatic** โ€” cuts repeat-read token burn by `80%+` without interrupting the agent |
112
- | **3. `PrefixCacheShield` Warm Rule & Effort Deferral** (`DET-09`) | Intercepts mid-session edits to `AGENTS.md` / `CLAUDE.md` while a KV cache is warm, and checks `MODEL_EFFORT_CACHE_CAPABILITIES` on effort changes: defers on `4.6` models (`EF1_46` / article), stays silent on measured cache-preserving `claude-sonnet-5-5` (`r2_effort.csv`, `n = 3` with thinking expansion) and `claude-opus-5-5` (`currency_55.csv` `effort_only_55`, behaviour **unverified**), and warns with `"unverified for this model"` on untested models | **Model-aware cache protection** โ€” prevents silent `4.6` / rule-file cold prefix rebuilds without false-positiving on `5.5` effort |
133
+ | **3. `PrefixCacheShield` Warm Rule & Effort Deferral** (`DET-09`) | Intercepts mid-session edits to `AGENTS.md` / `CLAUDE.md` while a KV cache is warm, and checks `MODEL_EFFORT_CACHE_CAPABILITIES` on effort changes (defers on `4.6`, silent on cache-preserving `5.5` models, warns on untested models) | **Model-aware cache protection** โ€” prevents silent cold prefix rebuilds without false-positiving on `5.5` effort |
113
134
  | **4. Live Model & Effort Switch Verdict** (`Zone B`) | Evaluates remaining KV cache TTL (`5m`/`1h`) and horizon break-even (`C_max` & warm-request payback) across `MODEL / HOLD / SWITCH / LOCK` states | **Instant visual guidance** โ€” tells you when to hold vs. switch models or lower thinking effort |
114
- | **5. Held Downshift & Boundary Lifecycle** (`SessionStart:compact` / `Stop`) | Surfaces held `pending_downshift` after compaction via `SessionStart:compact` `systemMessage` (`0` `/v1/messages` tokens leaked) without adding custom `PreCompact` or `SessionStart` preservation templates; optional task-boundary `/compact` advisor is gated **OFF by default** (`smartCompactBoundarySuggest: false`, boundary detector **unverified**) | **Post-compact downshift handoff** โ€” reminds `/model <target>` once after compaction, when switching avoids full pre-compact rewrites |
135
+ | **5. Held Downshift & Boundary Lifecycle** (`SessionStart:compact` / `Stop`) | Surfaces held `pending_downshift` after compaction via a zero-token `SessionStart:compact` `systemMessage` reminder (`/model <target>`), with optional boundary prompts disabled by default | **Post-compact downshift handoff** โ€” reminds `/model <target>` cleanly right after compaction |
115
136
  | **6. Git Hook-Bypass & Destructive Shell Guard** (`DET-18` / `DET-19`) | Blocks `git commit --no-verify`, `-n`, `core.hooksPath` tampering, and unconfirmed `git reset --hard` | **Zero-config repo safety** โ€” keeps frustrated agents from bypassing your pre-commit linters |
116
- | **7. `PreModelSwitch` Warm KV-Cache Guard** (`DET-08`) | Evaluates KV-cache TTL (`5m`/`1h`), Stop-hook shrunk rolling-median `requestsPerTurn` (`R`, cold-start placeholder prior overridden once `>= 3` non-current, non-benchmark deduplicated sessions exist in `~/.claude/projects/**/*.jsonl`), Stop-hook rolling median prompt growth (`g` tok/turn, capped at `g = 0` until `n >= 5` observed turns and a stable regime; with `< 5` observed turns, the hook omits the net dollar figure and shows payback in requests first and turns in parentheses), horizon limit `C_max`, Stop-hook rolling output shrinkage, and warm-request payback (`AUTO_PILOT`). **Catalog-derived per-pair payback:** All break-even thresholds (`C*`, `C_max`), cold-write penalties, and warm-request paybacks (`~a / b` where `a = P_write,B - P_read,A` and `b = P_read,A - P_read,B`, less output credit and `R - 1` switch-turn reads) are derived at runtime from `anthropicModelCatalog.json` with no hard-coded constants. Unknown model IDs return explicit `unknownModel: true` with `null` USD fields, no price-based hold, a one-line unknown-price advisory, and a `ctxtop doctor` `WARN`. Under headless `claude -p`/SDK, `"ask"` becomes `blocked_by_hook`; override with `"DET-08": "warn"` or `expectedRemainingTurns`. | **Protects mid-session switches** โ€” reports payback in post-switch warm requests (turns in parentheses), allows post-compaction splits cleanly, and never hallucinates fallback prices |
137
+ | **7. `PreModelSwitch` Warm KV-Cache Guard** (`DET-08`) | Computes break-even (`C*`, `C_max`), cold-write penalties, and warm-request paybacks directly from `anthropicModelCatalog.json` using rolling session turns (`R`, `g`), returning explicit `unknownModel: true` without fallback price guesses | **Protects mid-session switches** โ€” prevents losing money on short-horizon downgrades while allowing profitable early switches |
117
138
 
118
139
  ---
119
140
 
120
- ## Measured behaviour (Claude Code 2.1.325)
121
-
122
- Empirical findings from the suite (every item cites its source file; unmeasured behaviors are labeled **unverified**):
123
-
124
- - Editing `CLAUDE.md` before `--resume` does not invalidate the cache; the old and new versions both stay in context (`T6 CC-M`, `t6_layers.csv`).
125
- - `--append-system-prompt` is ignored on `--resume` (`T6 CC-S`, `t6_layers.csv`).
126
- - Changing MCP servers or the tool list on resume wipes the cache (`T6 CC-T`, `t6_layers.csv`).
127
- - `PreCompact` instructions must be plain text on stdout; JSON is dropped (`Phase 0`, `$0` binary & mock-SSE audit; Highbeam emits zero custom `PreCompact` or `SessionStart` preservation templates since `summary_smart_compact.md` found `0/6` violations up to `28.10x` compression without them).
128
- - Auto-memory added about `23.5%` to session cost in the smart-compact fixture (`n = 2 vs 2`, `summary_smart_compact.md`); this is a cost note, not a recommendation to disable it.
129
- - On OpenRouter, `max_tokens: 0` still generates output; cache pre-warming with 0 output works on the direct API only (`Phase 0`, `T3b`).
130
- - A 1-hour cache costs `2x` on writes and wins once a `5โ€“60` minute pause occurs (`T3a`).
141
+ ## ๐Ÿ“Š Empirical Wire Highlights (Claude Code `2.1.325`)
131
142
 
132
- **SDK / `stream-json` host downshift pattern (`Item 4.2`):** Interactive hooks (`SessionStart:compact`, `PostCompact`) cannot set `mainLoopModel` (`Phase 0`). In interactive Claude Code, Highbeam emits a one-line `SessionStart:compact` `systemMessage` (`0` tokens injected into `/v1/messages`, verified at `$0` on `claude.exe@2.1.325`) naming `/model <target>`, and avoids invalid `PostCompact` `hookSpecificOutput`. In SDK or `stream-json` hosts, inspect stream frames for `compact_boundary` and call `set_model` on the host controller immediately afterward โ€” never from inside a hook.
143
+ Highbeam's cache-economics engine is backed by **45 pre-registered randomized runs (`540` live wire-reconciled turns)** and **6 live 30-turn compaction studies** against first-party Anthropic via OpenRouter:
133
144
 
134
- **Resume toolset visibility (`Item 6`):** On `claude.exe@2.1.325`, `SessionStart:resume` stdin supplies `context_tokens` and `prompt_cache_likely_expired` but does not expose `tools` or `mcp_servers` (and `deferred_tools_delta` is written to `.jsonl` after `SessionStart`). Highbeam therefore hashes observable config files (`.mcp.json`, `.claude/settings*.json`, `~/.claude.json`), CLI `--mcp-config`/`--tools` flags when provided, and optional host arrays, and warns when hashes differ on large non-expired resumes (`t6_layers.csv` `CC-T`).
145
+ - **Downgrading Mid-Chat Can Cost More Than Staying on Opus:** At `~58k` context, switching `Opus 4.6 -> Sonnet 4.6` at Turn 6 produced a `0.0%` cache hit (`+$0.1783` spike) and increased 12-turn session cost (`$0.8611` vs `$0.7789` Opus control).
146
+ - **Changing `--effort` Busted `4.6` Caches (`+$0.0853`), Fixed in `5.5`:** Wire diffs caught `output_config.effort` invalidating `4.6` prompt caches while `claude-sonnet-5-5` preserved warm cache hits (`n = 3`).
147
+ - **Stock `/compact` Scored `0/6` Violations Up to `28.10x` Compression:** Because default compaction preserved constraints cleanly without custom templates, Highbeam emits zero `PreCompact` bloat.
148
+ - **MCP / Tool-List Swaps on `--resume` Wipe Cache; `CLAUDE.md` Edits Do Not:** Highbeam hashes `.mcp.json` / `.claude/settings*.json` across resumes and warns before uncached rebuilds.
135
149
 
136
- **Unverified items explicitly labeled:** `claude-opus-5-5` effort-change behaviour (`currency_55.csv` verified cache preservation only; reasoning output change unverified), `DET-09` effort behaviour on non-`4.6`/non-`5.5` models (`"unverified for this model"`), and `evaluateTaskBoundaryTurn` compaction suggestions (`phase1_boundary_detector.csv`: `80.00%` precision on scripted plans, `0` organic boundaries; `smartCompactBoundarySuggest` defaults to `false` and suggests only with estimated `~2-minute` pause per `summary_smart_compact.md` H4/H7).
150
+ ๐Ÿ‘‰ See full methodology, per-arm datasets, SDK `stream-json` `set_model` patterns, and explicit unverified boundaries in [**`docs/EMPIRICAL_BENCHMARKS.md`**](docs/EMPIRICAL_BENCHMARKS.md).
137
151
 
138
152
  ---
139
153
 
@@ -272,26 +286,43 @@ npx ctxtop config DET-19 block
272
286
  - **`"AUTO_PILOT"`**: Enforces strict pre-turn & stop-gate verification locks (e.g., requiring tests to run after source edits before session completion).
273
287
  - **`"SILENT"` / `"OFF"`**: Passive telemetry collection only.
274
288
 
275
- ### 2. Using Highbeam as an MCP Server (`ctxtop-mcp`)
276
- Any MCP-compatible client (**Google Antigravity**, **Claude Code**, **Cursor**, **Windsurf**, or **Claude Desktop**) can query Highbeam's telemetry and KV-cache advisor via standard JSON-RPC stdio:
289
+ ### 2. Using Highbeam as an MCP Server (`npx ctxtop mcp`)
290
+ Any MCP-compatible client (**Google Antigravity**, **Claude Code**, **OpenAI Codex CLI**, **Gemini CLI**, **Cursor**, **Windsurf**, or **Claude Desktop**) can auto-configure Highbeam via `npx ctxtop init --cursor --windsurf --codex --gemini-cli` or run standard JSON-RPC stdio directly:
277
291
 
278
292
  ```json
279
293
  {
280
294
  "mcpServers": {
281
295
  "highbeam": {
282
296
  "command": "npx",
283
- "args": ["-y", "ctxtop-mcp"]
297
+ "args": ["-y", "ctxtop", "mcp"]
284
298
  }
285
299
  }
286
300
  }
287
301
  ```
288
- Exposes 4 read-only MCP tools (`<5ms` response): `get_context_telemetry`, `check_cache_gravity`, `get_savings_receipt`, and `inspect_detectors`.
302
+ Exposes **7 standalone zero-network MCP tools** (`<5ms` response): `horizon_status`, `cache_gravity_check`, `scope_lock_claim`, `export_receipt_pdf`, `horizon_compress_cli`, `horizon_search_logs`, and `horizon_audit_sessions`.
303
+
304
+ For centralized organization deployment (Jamf / Intune / GPO), `CHECKSUMS.sha256` verification, and BYO-Grafana OpenTelemetry telemetry, see [**Enterprise & MDM Deployment Guide**](docs/ENTERPRISE_MDM.md).
305
+
306
+ ---
307
+
308
+ ## ๐Ÿ“ฆ Editions: Free (`MIT` Core + `COACH`) vs. Pro & Team
309
+
310
+ | Feature / Capability | Free Core (`MIT`) | Highbeam Pro (`$15/mo` ยท 14d Trial) | Team / FinOps (`$39/seat/mo`) |
311
+ | :--- | :---: | :---: | :---: |
312
+ | Simple & Advanced 40-Cell HUD + `5m/1h` Live TTL Timer | โœ… | โœ… | โœ… |
313
+ | Multi-Family FTS5 Compression (`test`, `lint`, `git`, `docker`/`kubectl`) & `ctxtop search` | โœ… | โœ… | โœ… |
314
+ | Automated Repeat-Read Delta Diffs & AST Stubs (`GUARD-4`) | โœ… | โœ… | โœ… |
315
+ | `COACH` Non-Blocking Advisories & 32 Auditable Guards across 5 Hosts | โœ… | โœ… | โœ… |
316
+ | `AUTO_PILOT` Hands-Free Enforcement & Horizon `C_max` Holds | Preview | โœ… | โœ… |
317
+ | 30-Day Chronic Offender Memory & Workspace Savings Ledger | โ€” | โœ… | โœ… |
318
+ | Signed Corporate PDF 1.4 FinOps + GreenOps Receipt (`ctxtop receipt --pdf`) | โ€” | โœ… | โœ… |
319
+ | Shared `.agents/rules/` Governance, MDM Policy & OTel / Grafana Pack | โ€” | โ€” | โœ… |
289
320
 
290
321
  ---
291
322
 
292
323
  ## Deterministic `PreInvocation` Router & 6 Local Sensors
293
324
 
294
- When registered in `hooks.json`, `src/hooks/pre_invocation.mjs` evaluates incoming prompts across 8 deterministic router states (**Tier-1 In-Process Router Evaluation: `~0.18ms p95`** inside a warm V8 isolate; **Tier-2 Spawned CLI Hook End-to-End Wall Time: `~25โ€“45ms` POSIX / `~40โ€“90ms` Windows PowerShell** including Node process startup):
325
+ When registered in `hooks.json`, `src/hooks/pre_invocation.mjs` evaluates incoming prompts across 8 deterministic router states (**Tier-1 In-Process `PreInvocation`: `~0.1โ€“2.9ms` avg / `~3.4ms` p95** inside a warm V8 isolate; **Tier-2 CLI Hook End-to-End Wall Time on Windows: `~58ms` p50 warm daemon IPC / `~105ms` avg cold fallback (`~25โ€“60ms` POSIX)** including Node process startup):
295
326
 
296
327
  1. `ALLOW_SILENT`: Immediate pass-through (`{}`) on `!` bypass prefix or healthy turns.
297
328
  2. `ALLOW_ACTIVE_SET`: Silent pass-through when referenced files are already warm in the last 5 turns.
@@ -308,27 +339,30 @@ When registered in `hooks.json`, `src/hooks/pre_invocation.mjs` evaluates incomi
308
339
 
309
340
  | Command | Description |
310
341
  | :--- | :--- |
311
- | `npx ctxtop init [--workspace]` | Installs Google Antigravity plugin manifests, lifecycle hooks, and sidecar configuration. |
312
- | `npx ctxtop install --claude` | Installs Claude Code `.claude-plugin` manifest, Tier-1/Tier-2 hooks, and terminal `statusLine`. |
313
- | `npx ctxtop doctor [--diagnostic]` | Validates hook registration, config overlays, dynamic model ceilings, 3-way WebView SHA-256 parity, and SQLite/JSONL health. |
342
+ | `npx ctxtop audit [--platform all\|antigravity\|claude\|codex\|gemini\|cursor] [--days 7] [--json]` | Zero-write, hookless 5-host audit of Sludge Tax, cold-cache spikes, and oversized tool dumps. |
343
+ | `npx ctxtop init [--cursor \| --windsurf \| --codex \| --gemini-cli \| --all-hosts]` | Installs Google Antigravity, Claude Code, and 1-command MCP configurations across editors & CLIs. |
344
+ | `npx ctxtop search [<turn-id>] "<keyword>" [--json]` | Searches local SQLite FTS5 offloaded CLI dumps and artifacts via BM25 matching. |
345
+ | `npx ctxtop install --global` | Installs Claude Code `.claude-plugin` manifest, Tier-1/Tier-2 hooks, and terminal `statusLine`. |
346
+ | `npx ctxtop ui [--demo]` | Launches the local HTTP/SSE telemetry daemon (`127.0.0.1`) and interactive WebView (`/` Simple, `/advanced` Advanced). |
347
+ | `npx ctxtop mcp` | Starts the standalone zero-network 7-tool JSON-RPC stdio MCP server (`@ctxtop/mcp`). |
348
+ | `npx ctxtop doctor [--diagnostic]` | Validates hook registration, FTS5 offload readiness, warm-IPC path, model ceilings, 3-way SHA-256 parity, and SQLite health. |
314
349
  | `npx ctxtop postmortem [--last N] [--json]` | Scans the last `N` local sessions, classifies root causes (`CONTEXT_ROT_DECAY`, `VERIFICATION_CHURN`, `SPEC_AMBIGUITY`, `CLEAN`), lists top duplicate-read files, and audits Turn-0 MCP schema overhead. |
315
350
  | `npx ctxtop receipt [--markdown \| --pdf]` | Exports a SHA-256 verified FinOps + GreenOps token/USD savings receipt for the active workspace. |
316
- | `npx ctxtop verify [--json]` | Verifies cryptographic SHA-256 integrity of all 149 release files against `CHECKSUMS.sha256`. |
351
+ | `npx ctxtop verify [--json]` | Verifies cryptographic SHA-256 integrity of all tracked release files against `CHECKSUMS.sha256`. |
317
352
  | `npx ctxtop --roast` | Prints a terminal forensic summary of recent sessions with top duplicate-read file offenders and copy-pasteable remediations. |
318
- | `npx ctxtop --serve` | Launches the local HTTP/SSE telemetry daemon (`127.0.0.1`) and interactive WebView (`/` Simple, `/advanced` Advanced). |
319
353
  | `npx ctxtop --demo-animate` | Plays the 5-stage terminal crisis simulation across synthetic fixtures. |
320
354
 
321
355
  ---
322
356
 
323
357
  ## Verification & Benchmarks
324
358
 
325
- Run the full zero-dependency test and verification suite (**1,050+ tests across 215+ suites**):
359
+ Run the full zero-dependency test and verification suites (**1,060+ tests across 215+ suites** โ€” see [**Empirical Benchmarks**](docs/EMPIRICAL_BENCHMARKS.md) & [**Compression & Antigravity Parity Report**](docs/ANTIGRAVITY_AND_COMPRESSION_BENCHMARK.md)):
326
360
 
327
361
  ```bash
328
- # Full Coach, UI, & 360ยฐ Capability-Proof suite (911+ tests across 183+ suites)
362
+ # Full Coach, UI, & 360ยฐ Capability-Proof suite
329
363
  npm run test:coach
330
364
 
331
- # Claude Code dual-tier Mod, CLI hooks, statusLine, and 5-category ledger suite (168 tests)
365
+ # Claude Code dual-tier Mod, CLI hooks, statusLine, and 5-category ledger suite (195 tests)
332
366
  npm run test:claude
333
367
 
334
368
  # Unit & Multi-Harness Wedge suite (89 tests across 31 suites)
@@ -337,10 +371,10 @@ npm run test:unit
337
371
  # Architectural verification suite (Gates 0-6 & Phases 1-7: SQLite read-only locks, JSDOM UI, MCP audit)
338
372
  npm run test:gates && npm run test:phases
339
373
 
340
- # End-to-end context memory & live loopback daemon integration suite (7 layers)
341
- npm run test:e2e
374
+ # Reproducible 10-family CLI compression + 12-session Antigravity & 5-host parity benchmark
375
+ npm run bench:parity
342
376
 
343
- # Latency benchmark (200 iterations/path: Tier-1 ~3.0ms avg / <15ms SLA, Tier-2 CLI Hook, <45ms HUD)
377
+ # Latency benchmark (200 iterations/path: Tier-1 ~2.9ms avg, Tier-2 ~58ms warm IPC / ~105ms cold Windows, ~5.4ms HUD)
344
378
  npm run bench
345
379
  ```
346
380
 
package/SECURITY.md CHANGED
@@ -17,6 +17,12 @@ To eliminate any risk of database lock contention or corruption while Google Ant
17
17
  2. **Read-Only JSONL File Descriptors (`'r'`):** Incremental transcript slicing (`transcript_full.jsonl` and `transcript.jsonl`) opens log files strictly with read-only flag `'r'` (`fs.openSync(filePath, 'r')`) and never acquires write locks on active Antigravity session databases.
18
18
  3. **Atomic Sidecar & Backup I/O:** Any optional user-triggered state (such as `docs/HANDOFF_<timestamp>.md` generation or `.bak` transcript backups prior to surgical pruning) is written atomically via PID-scoped temporary files and rename operations.
19
19
 
20
- ## 3. Reporting a Vulnerability
20
+ ## 3. Multi-Host Read-Only Scoping & Open-Core Cryptographic Model
21
+
22
+ 1. **5-Host Read-Only Transcript Scoping (`ctxtop audit` & `horizon_audit_sessions`)**: When auditing sessions across Antigravity, Claude Code, Codex CLI, Gemini CLI, and Cursor, `ctxtop` reads solely completed/active conversation transcript files (e.g. Gemini CLI `~/.gemini/tmp/**/chats/session-*.json`). Highbeam never reads OAuth credential files (`~/.gemini/oauth_creds.json`, Keychain/Credential Manager tokens) and never spawns host CLIs against interactive OAuth seats.
23
+ 2. **Release Checksums & npm Provenance**: Tracked runtime files can be verified offline anytime via `npx ctxtop verify --json` (`CHECKSUMS.sha256`), and CI releases publish with `--provenance` OIDC attestation.
24
+ 3. **Offline Ed25519 Entitlement Verification (`@ctxtop/pro`)**: License verification runs locally using Node.js native `node:crypto` Ed25519 signature checks with zero license phone-home pings; enterprises may pin their own SPKI key via `CTXTOP_ED25519_PUBLIC_KEY_PEM`. For central MDM policy deployment see [docs/ENTERPRISE_MDM.md](docs/ENTERPRISE_MDM.md).
25
+
26
+ ## 4. Reporting a Vulnerability
21
27
 
22
28
  If you discover a security or path-handling issue, please open a GitHub Security Advisory on the repository or contact `frankmiller@gmail.com`. We respond to security reports within 48 hours.
@@ -31,7 +31,7 @@
31
31
  <circle cx="42" cy="20" r="6" fill="#f59e0b"/>
32
32
  <circle cx="62" cy="20" r="6" fill="#22c55e"/>
33
33
  <text x="480" y="25" text-anchor="middle" fill="#94a3b8" font-size="13" font-weight="600" class="mono">
34
- Highbeam (ctxtop v3.4.0) โ€” 40-Cell Context Telemetry HUD &amp; PreInvocation Flight Check
34
+ Highbeam (ctxtop v4.1.0) โ€” 40-Cell Context Telemetry HUD &amp; PreInvocation Flight Check
35
35
  </text>
36
36
 
37
37
  <!-- Section 1: Turn 50 Prefix Amputation & Sludge Crisis -->