ctxtop 4.0.0 → 4.1.0

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 (89) hide show
  1. package/.antigravity-plugin/plugin.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHECKSUMS.sha256 +59 -42
  4. package/README.md +351 -330
  5. package/bin/ah-statusline.mjs +30 -0
  6. package/bin/ctxtop.mjs +330 -5
  7. package/config/default_flightcheck.json +19 -0
  8. package/config/modelCatalog.json +165 -0
  9. package/hooks/handlers/compact-lifecycle.mjs +323 -8
  10. package/hooks/handlers/config-change.mjs +402 -0
  11. package/hooks/handlers/hookIo.mjs +56 -0
  12. package/hooks/handlers/post-model-switch.mjs +111 -0
  13. package/hooks/handlers/post-tool-use.mjs +117 -16
  14. package/hooks/handlers/pre-model-switch.mjs +823 -24
  15. package/hooks/handlers/pre-tool-use.mjs +271 -4
  16. package/hooks/handlers/stop-gate.mjs +297 -11
  17. package/hooks/handlers/user-prompt-submit.mjs +224 -0
  18. package/hooks/hooks.json +50 -0
  19. package/hooks/post_tool_use.mjs +8 -0
  20. package/hooks/register.js +48 -9
  21. package/hooks/session_start.mjs +11 -1
  22. package/hooks/stop.mjs +11 -1
  23. package/package.json +11 -4
  24. package/packages/antigravity/package.json +1 -1
  25. package/packages/claude-code/package.json +1 -1
  26. package/packages/core/package.json +1 -1
  27. package/packages/engine-node/package.json +1 -1
  28. package/packages/mcp/package.json +1 -1
  29. package/packages/mcp/src/server.mjs +1 -1
  30. package/packages/pro/package.json +1 -1
  31. package/plugin.json +1 -1
  32. package/sidecars/horizon-daemon/server.mjs +38 -2
  33. package/skills/handoff/SKILL.md +8 -0
  34. package/src/adapters/antigravity/index.mjs +31 -1
  35. package/src/adapters/claude-code/index.mjs +40 -1
  36. package/src/cli/horizon_hud.mjs +254 -52
  37. package/src/config/modelCatalog.json +84 -0
  38. package/src/core/bucket_b_runtime.mjs +1200 -0
  39. package/src/core/constants.mjs +191 -4
  40. package/src/core/detectors_det01_to_16.mjs +54 -5
  41. package/src/core/doc_indexer.mjs +338 -0
  42. package/src/core/layer5_hygiene.mjs +118 -0
  43. package/src/core/parser.mjs +2 -1
  44. package/src/core/paths.mjs +3 -2
  45. package/src/core/rsl_clash_auditor.mjs +423 -0
  46. package/src/core/rsl_distiller.mjs +372 -0
  47. package/src/core/rsl_ledger.mjs +969 -0
  48. package/src/core/rsl_triage.mjs +909 -0
  49. package/src/core/session_auditor.mjs +658 -0
  50. package/src/core/shield_manager.mjs +1417 -0
  51. package/src/core/task_quota_router.mjs +1 -1
  52. package/src/core-isomorphic/coach/cacheGravityRouter.mjs +874 -47
  53. package/src/core-isomorphic/coach/resumeToolsetAuditor.mjs +321 -0
  54. package/src/core-isomorphic/coach/smartCompactAdvisor.mjs +305 -0
  55. package/src/core-isomorphic/coach/ttlWatchdog.mjs +13 -6
  56. package/src/core-isomorphic/config/anthropicModelCatalog.json +404 -1
  57. package/src/core-isomorphic/config/catalogLoader.mjs +546 -46
  58. package/src/core-isomorphic/config/horizonConfig.mjs +47 -1
  59. package/src/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +266 -0
  60. package/src/core-isomorphic/economics/cacheGravity.mjs +18 -0
  61. package/src/core-isomorphic/economics/cliffBreaker.mjs +98 -12
  62. package/src/core-isomorphic/economics/driftLatency.mjs +114 -0
  63. package/src/core-isomorphic/guards/bucketBAlphaBeta.mjs +860 -0
  64. package/src/core-isomorphic/guards/bucketBGamma.mjs +442 -0
  65. package/src/core-isomorphic/guards/bucketBHeuristics.mjs +37 -0
  66. package/src/core-isomorphic/guards/circuitBreakers.mjs +191 -191
  67. package/src/core-isomorphic/guards/det01_03_shell_secret.mjs +154 -5
  68. package/src/core-isomorphic/guards/det04_12_thrash_rot.mjs +103 -11
  69. package/src/core-isomorphic/guards/det13_20_mcp_scope.mjs +311 -1
  70. package/src/core-isomorphic/guards/docIndexCore.mjs +446 -0
  71. package/src/core-isomorphic/guards/losslessPostSanitizer.mjs +16 -0
  72. package/src/core-isomorphic/guards/slopsquatGate.mjs +551 -0
  73. package/src/core-isomorphic/index.js +1 -0
  74. package/src/core-isomorphic/telemetry/telemetryBridge.mjs +36 -12
  75. package/src/core-isomorphic/ui/horizonPanelHtml.mjs +293 -237
  76. package/src/core-isomorphic/ui/modViews.mjs +35 -9
  77. package/src/diagnostics/claudeHookCapabilities.mjs +396 -0
  78. package/src/diagnostics/doctorEngine.mjs +95 -3
  79. package/src/engine-node/db/probe.mjs +234 -2
  80. package/src/engine-node/index.mjs +3 -0
  81. package/src/engine-node/sensors/blindspots.mjs +13 -6
  82. package/src/hooks/antigravity_rsl_hook.mjs +250 -0
  83. package/src/hooks/claude_rsl_hook.mjs +288 -0
  84. package/src/hooks/post_invocation.mjs +196 -4
  85. package/src/hooks/pre_invocation.mjs +732 -22
  86. package/src/hooks/session_start.mjs +39 -1
  87. package/src/utils/modelSwitchTelemetry.mjs +308 -0
  88. package/src/utils/sessionCalibration.mjs +657 -0
  89. package/src/webview/horizon_panel.html +1325 -317
@@ -472,6 +472,256 @@ if (isMain) {
472
472
  }
473
473
  }
474
474
 
475
+ /**
476
+ * Adapts an Antigravity `classifyHorizon` state object into the Claude Code
477
+ * static HUD contract consumed by `renderHorizonPanelHtml`. Passes native
478
+ * Claude Code states through unchanged.
479
+ */
480
+ export function adaptClassifierStateForStaticHud(state = {}, options = {}) {
481
+ const isAntigravityState = Boolean(
482
+ state &&
483
+ typeof state === 'object' &&
484
+ state.window &&
485
+ typeof state.window.totalActiveTokens === 'number' &&
486
+ !state.contextWindow &&
487
+ typeof state.totalInputTokens !== 'number'
488
+ );
489
+ if (!isAntigravityState) {
490
+ return { state, options };
491
+ }
492
+
493
+ const totalInputTokens = Math.max(0, Number(state.window.totalActiveTokens || 0));
494
+ const contextCeiling = Math.max(0, Number(state.window.maxTokens || 0));
495
+ const breakdown = state.breakdown || {};
496
+ const systemTokens = Math.max(0, Number(breakdown.ANCHOR ?? state.baseline?.totalEst ?? 0));
497
+ const dupTok = Math.max(0, Number(breakdown.STALE_DUPLICATE ?? breakdown.DUPLICATE_READ ?? 0));
498
+ const oldHistTok = Math.max(0, Number(breakdown.STALE_TURN ?? 0));
499
+ const deadErrTok = Math.max(0, Number(breakdown.DEAD_ERROR ?? 0));
500
+ const bleedTok = Math.max(0, Number(breakdown.FOREIGN_BLEED ?? 0));
501
+ const distractorTokens = dupTok + oldHistTok + deadErrTok + bleedTok;
502
+
503
+ const cacheObj = state.quota?.cache || {};
504
+ const ttlSec = Math.max(0, Math.round(Number(cacheObj.ttlRemainingSec || 0) || 0));
505
+ const hitPct = Math.max(0, Math.min(100, Math.round(Number(cacheObj.hitRatePct || 0) || 0)));
506
+ const cacheReadTokens = Math.max(0, Number(cacheObj.cacheReadTokens || 0));
507
+ const isWarm = Boolean(
508
+ !cacheObj.isCacheCold &&
509
+ !cacheObj.prefixBustDetected &&
510
+ ttlSec > 0 &&
511
+ (cacheReadTokens > 0 || hitPct > 0)
512
+ );
513
+ const nonAnchorOrDistractor = Math.max(0, totalInputTokens - systemTokens - distractorTokens);
514
+
515
+ const adaptedState = {
516
+ sessionId: state.sessionId || 'horizon-hud',
517
+ model: state.model?.id || 'claude-sonnet-5-5',
518
+ modelLabel: state.model?.displayName || state.model?.rawLabel || state.model?.id || 'claude-sonnet-5-5',
519
+ totalInputTokens,
520
+ contextCeiling: contextCeiling > 0 ? contextCeiling : undefined,
521
+ systemTokens,
522
+ distractorTokens,
523
+ cachedTokens: isWarm ? nonAnchorOrDistractor : 0,
524
+ cacheReadTokens,
525
+ uncachedInputTokens: isWarm ? 0 : nonAnchorOrDistractor,
526
+ promptCache: {
527
+ warm: isWarm,
528
+ ttlRemainingSec: isWarm ? ttlSec : 0,
529
+ ttlTier: '5m'
530
+ },
531
+ cacheRoi: {
532
+ cacheHitRatio: hitPct / 100
533
+ },
534
+ amnesiaRisk: Boolean(
535
+ state.amputation?.amputationCrisis ||
536
+ state.amputation?.inAmputationZone ||
537
+ state.telemetry?.amputationRisk
538
+ ),
539
+ sessionTimeline: state.sessionTimeline || null,
540
+ autoFixLog: state.autoFixLog || null,
541
+ compactCommand: typeof state.compaction?.parameterizedCommand === 'string' &&
542
+ state.compaction.parameterizedCommand.startsWith('/compact ')
543
+ ? state.compaction.parameterizedCommand
544
+ : '/compact'
545
+ };
546
+
547
+ const mergedOptions = { ...options };
548
+ if (!Array.isArray(mergedOptions.offenders)) {
549
+ const derivedOffenders = [];
550
+ const seen = new Set();
551
+ const bs = state.brainSignals || {};
552
+ const topFiles = Array.isArray(bs.duplicateReads?.topFiles) ? bs.duplicateReads.topFiles : [];
553
+ for (const f of topFiles) {
554
+ const target = f?.path || f?.file;
555
+ const wastedTokens = Number(f?.wastedTokens ?? f?.tokens ?? 0);
556
+ if (!target || wastedTokens <= 0) continue;
557
+ seen.add(String(target).toLowerCase());
558
+ derivedOffenders.push({
559
+ target,
560
+ occurrences: Number(f.occurrences || f.reads || 1),
561
+ wastedTokens,
562
+ category: '[D]'
563
+ });
564
+ }
565
+ for (const o of (Array.isArray(state.offenders) ? state.offenders : [])) {
566
+ const rawTarget = String(o?.target || '');
567
+ const wastedTokens = Number(o?.wastedTokens || 0);
568
+ if (!rawTarget || wastedTokens <= 0) continue;
569
+ if (rawTarget === 'Foreign Bleed Knowledge') continue;
570
+ const key = rawTarget.toLowerCase();
571
+ if (seen.has(key)) continue;
572
+ seen.add(key);
573
+ derivedOffenders.push({
574
+ target: rawTarget,
575
+ occurrences: Number(o.occurrences || 1),
576
+ wastedTokens,
577
+ category: '[D]'
578
+ });
579
+ }
580
+ if (bleedTok > 0) {
581
+ derivedOffenders.push({
582
+ target: 'Cross-project memory bleed (foreign KIs)',
583
+ occurrences: 1,
584
+ wastedTokens: bleedTok,
585
+ category: '[D]'
586
+ });
587
+ }
588
+ for (const b of (Array.isArray(bs.blowupSteps) ? bs.blowupSteps : [])) {
589
+ const wastedTokens = Number(b?.tokens || 0);
590
+ if (wastedTokens <= 0) continue;
591
+ const isFile = b.payload?.kind === 'file' && Boolean(b.payload?.path);
592
+ const target = isFile ? b.payload.path : (b.payload?.detail || b.target || 'Output spike');
593
+ const key = String(target).toLowerCase();
594
+ if (seen.has(key)) continue;
595
+ seen.add(key);
596
+ derivedOffenders.push({
597
+ target,
598
+ occurrences: 1,
599
+ wastedTokens,
600
+ category: isFile ? '[D]' : '[W]'
601
+ });
602
+ }
603
+ for (const srv of (Array.isArray(bs.mcpAudit?.unusedEagerServers) ? bs.mcpAudit.unusedEagerServers : [])) {
604
+ const schemaTokens = Number(srv?.schemaTokens || 0);
605
+ if (!srv?.name || schemaTokens <= 0) continue;
606
+ derivedOffenders.push({
607
+ target: srv.name,
608
+ occurrences: 1,
609
+ wastedTokens: schemaTokens,
610
+ category: '[S]'
611
+ });
612
+ }
613
+ derivedOffenders.sort((a, b) => (b.wastedTokens || 0) - (a.wastedTokens || 0));
614
+ mergedOptions.offenders = derivedOffenders;
615
+ }
616
+
617
+ if (!mergedOptions.breakerVerdict) {
618
+ const tripped = state.coachState?.detectors?.tripped;
619
+ const isErrLoop = Boolean(state.brainSignals?.deadErrors?.isErrorLoop);
620
+ const errCount = Number(state.brainSignals?.deadErrors?.errorCount || 0);
621
+ if (state.amputation?.amputationCrisis) {
622
+ mergedOptions.breakerVerdict = {
623
+ triggered: true,
624
+ detectorId: tripped?.detectorId || 'CRISIS',
625
+ reason: tripped?.reason || `Context truncation crisis (${Math.round(totalInputTokens / 1000)}k used — oldest rules at risk).`
626
+ };
627
+ } else if (tripped && tripped.detectorId) {
628
+ mergedOptions.breakerVerdict = {
629
+ triggered: true,
630
+ detectorId: tripped.detectorId,
631
+ reason: tripped.reason || `${tripped.detectorId} guard triggered.`
632
+ };
633
+ } else if (isErrLoop) {
634
+ mergedOptions.breakerVerdict = {
635
+ triggered: true,
636
+ detectorId: 'ERR-LOOP',
637
+ reason: `Stuck error loop (${errCount}x failing attempts). Pause retries and isolate a minimal repro.`
638
+ };
639
+ }
640
+ }
641
+
642
+ if (state.savings && mergedOptions.sessionSavedTokens === undefined) {
643
+ const sessTok = Math.max(0, Number(state.savings?.session?.totalPhysicalTokens ?? state.savings?.session?.totalTokens ?? 0));
644
+ const sessUsd = Math.max(0, Number(state.savings?.session?.estimatedInputValueUsd ?? state.savings?.session?.estimatedUsd ?? Number(((sessTok / 1_000_000) * 2).toFixed(2))));
645
+ const wsTok = Math.max(sessTok, Number(state.savings?.workspace30d?.totalPhysicalTokens ?? state.savings?.workspace30d?.totalTokens ?? 0));
646
+ const wsUsd = Math.max(sessUsd, Number(state.savings?.workspace30d?.estimatedInputValueUsd ?? state.savings?.workspace30d?.estimatedUsd ?? Number(((wsTok / 1_000_000) * 2).toFixed(2))));
647
+ mergedOptions.sessionSavedTokens = sessTok;
648
+ mergedOptions.sessionSavedUSD = sessUsd;
649
+ mergedOptions.workspace30dSavedTokens = wsTok;
650
+ mergedOptions.workspace30dSavedUSD = wsUsd;
651
+ if (mergedOptions.includeDiskLedger === undefined) {
652
+ mergedOptions.includeDiskLedger = false;
653
+ }
654
+ }
655
+
656
+ return { state: adaptedState, options: mergedOptions };
657
+ }
658
+
659
+ /**
660
+ * Renders the static HTML HUD from either an Antigravity `classifyHorizon`
661
+ * state or a native Claude Code state.
662
+ */
663
+ export function renderClassifierHudHtml(state = {}, options = {}) {
664
+ const { state: adaptedState, options: mergedOptions } = adaptClassifierStateForStaticHud(state, options);
665
+ return renderHorizonPanelHtml(adaptedState, mergedOptions);
666
+ }
667
+
668
+ /**
669
+ * Formats the single-line ANSI CLI status bar for a `classifyHorizon` state
670
+ * clamped cleanly to `columns` when <= 80.
671
+ */
672
+ export function formatCliStatusLine(state = {}, { columns = 120 } = {}) {
673
+ let cellCount = 40;
674
+ if (columns < 80) cellCount = 10;
675
+ else if (columns < 120) cellCount = 20;
676
+
677
+ const downsampleRatio = 40 / cellCount;
678
+ const isAmputation = Boolean(state.amputation?.inAmputationZone);
679
+ const isCrisis = Boolean(state.amputation?.amputationCrisis);
680
+
681
+ let bar = isCrisis ? '\x1b[48;5;196m\x1b[38;5;255m![ 🚨 \x1b[0m ' : (isAmputation ? '\x1b[38;5;196m![\x1b[0m' : '[');
682
+ for (let i = 0; i < cellCount; i++) {
683
+ const origStart = Math.floor(i * downsampleRatio);
684
+ const origEnd = Math.floor((i + 1) * downsampleRatio);
685
+ const slice = (state.cells || []).slice(origStart, origEnd);
686
+ const dominant = slice[0]?.dominantCategory || H_CATEGORIES.FREE_HEADROOM;
687
+ const meta = CATEGORY_METADATA[dominant] || CATEGORY_METADATA.FREE_HEADROOM;
688
+ if (slice.some(c => c.isCrisisCell)) {
689
+ bar += `\x1b[48;5;196m\x1b[38;5;255m${meta.symbol}\x1b[0m`;
690
+ } else {
691
+ bar += `${meta.ansiCode}${meta.symbol}\x1b[0m`;
692
+ }
693
+ }
694
+ bar += isCrisis ? ' \x1b[48;5;196m\x1b[38;5;255m]!\x1b[0m' : (isAmputation ? '\x1b[38;5;196m]!\x1b[0m' : ']');
695
+
696
+ const activeK = Math.round((state.window?.totalActiveTokens || 0) / 1000);
697
+ const maxK = Math.round((state.window?.maxTokens || 0) / 1000);
698
+ const usedPct = maxK > 0 ? Math.round((activeK / maxK) * 100) : 0;
699
+ const purity = state.metrics?.signalPurityPct ?? 100;
700
+ const noiseK = Math.round((state.metrics?.sludgeTokens || 0) / 1000);
701
+ const rawRecCmd = state.diagnostics?.recommendedCommand || 'Ready';
702
+ const recCmd = rawRecCmd === '/fast' ? 'Ready' : rawRecCmd;
703
+ const isCacheCold = state.quota?.cache ? Boolean(state.quota.cache.isCacheCold) : false;
704
+ const ttlSec = Math.max(0, Math.round(Number(state.quota?.cache?.ttlRemainingSec || 0) || 0));
705
+ const cacheHitPct = Math.max(0, Number(state.quota?.cache?.hitRatePct || 0) || 0);
706
+ const cacheLabel = (!isCacheCold && ttlSec > 0 && cacheHitPct > 0) ? `Warm(${ttlSec}s)` : 'Cold';
707
+ const modeTag = state.workloadMode?.tag || '[Mode: Read-Heavy Audit]';
708
+ const strandedCnt = Number(state.attentionHeatmap?.strandedSignalCount || 0);
709
+ const strandedSuffix = strandedCnt > 0 ? ` | \u26A0 ${strandedCnt}/40 mid-window blocks` : '';
710
+
711
+ let line1 = '';
712
+ if (cellCount === 40) {
713
+ line1 = `${bar} [ ${activeK}k / ${maxK}k · ${usedPct}% ] \x1b[1mPurity:\x1b[0m ${purity}% | \x1b[1mCache Hit:\x1b[0m ${cacheHitPct}% | \x1b[1mWaste:\x1b[0m ${noiseK}k tok | \x1b[1mCache:\x1b[0m ${cacheLabel} | ${modeTag}${strandedSuffix} \x1b[38;5;51m-> ${recCmd}\x1b[0m`;
714
+ } else if (cellCount === 20) {
715
+ line1 = `${bar} [${activeK}k/${maxK}k·${usedPct}%] P:${purity}% Waste:${noiseK}k -> ${recCmd}`;
716
+ } else {
717
+ line1 = `${bar} ${activeK}k P:${purity}% ${recCmd}`;
718
+ }
719
+ if (columns <= 80) {
720
+ line1 = clampAnsiText(line1, Math.min(columns, 80));
721
+ }
722
+ return line1;
723
+ }
724
+
475
725
  /**
476
726
  * Renders the ANSI statusLine bar and full 256K-aware HorizonStatePayload for Antigravity CLI / Sidecar Daemon
477
727
  */
@@ -492,7 +742,7 @@ export async function runCLI(options = {}) {
492
742
  );
493
743
  if (options.emitWidget || (Array.isArray(process.argv) && process.argv.includes('--emit-widget'))) {
494
744
  const target = path.resolve(options.out || 'horizon_widget.html');
495
- const { html } = renderHorizonPanelHtml(state, { viewMode: 'simple' });
745
+ const { html } = renderClassifierHudHtml(state, { viewMode: 'simple' });
496
746
  fs.mkdirSync(path.dirname(target), { recursive: true });
497
747
  fs.writeFileSync(target, html, 'utf8');
498
748
  const fileUri = `file:///${target.replace(/\\/g, '/').replace(/^\/+/, '')}`;
@@ -602,59 +852,11 @@ export async function runCLI(options = {}) {
602
852
  writeJsonAtomicSync(path.join(cacheDir, 'latest.state.json'), state);
603
853
  } catch {}
604
854
 
605
- let cellCount = 40;
606
- if (columns < 80) cellCount = 10;
607
- else if (columns < 120) cellCount = 20;
608
-
609
- const downsampleRatio = 40 / cellCount;
610
- const isAmputation = state.amputation.inAmputationZone;
611
- const isCrisis = state.amputation.amputationCrisis;
612
-
613
- let bar = isCrisis ? '\x1b[48;5;196m\x1b[38;5;255m![ 🚨 \x1b[0m ' : (isAmputation ? '\x1b[38;5;196m![\x1b[0m' : '[');
614
- for (let i = 0; i < cellCount; i++) {
615
- const origStart = Math.floor(i * downsampleRatio);
616
- const origEnd = Math.floor((i + 1) * downsampleRatio);
617
- const slice = state.cells.slice(origStart, origEnd);
618
- const dominant = slice[0]?.dominantCategory || H_CATEGORIES.FREE_HEADROOM;
619
- const meta = CATEGORY_METADATA[dominant] || CATEGORY_METADATA.FREE_HEADROOM;
620
- if (slice.some(c => c.isCrisisCell)) {
621
- bar += `\x1b[48;5;196m\x1b[38;5;255m${meta.symbol}\x1b[0m`;
622
- } else {
623
- bar += `${meta.ansiCode}${meta.symbol}\x1b[0m`;
624
- }
625
- }
626
- bar += isCrisis ? ' \x1b[48;5;196m\x1b[38;5;255m]!\x1b[0m' : (isAmputation ? '\x1b[38;5;196m]!\x1b[0m' : ']');
627
-
628
- const activeK = Math.round(state.window.totalActiveTokens / 1000);
629
- const maxK = Math.round(state.window.maxTokens / 1000);
630
- const usedPct = maxK > 0 ? Math.round((activeK / maxK) * 100) : 0;
631
- const purity = state.metrics.signalPurityPct;
632
- const noiseK = Math.round((state.metrics.sludgeTokens || 0) / 1000);
633
- const rawRecCmd = state.diagnostics.recommendedCommand || 'Ready';
634
- const recCmd = rawRecCmd === '/fast' ? 'Ready' : rawRecCmd;
635
- const isCacheCold = state.quota?.cache ? Boolean(state.quota.cache.isCacheCold) : false;
636
- const ttlSec = Math.max(0, Math.round(Number(state.quota?.cache?.ttlRemainingSec || 0) || 0));
637
- const cacheHitPct = Math.max(0, Number(state.quota?.cache?.hitRatePct || 0) || 0);
638
- const cacheLabel = (!isCacheCold && ttlSec > 0 && cacheHitPct > 0) ? `Warm(${ttlSec}s)` : 'Cold';
639
- const modeTag = state.workloadMode?.tag || '[Mode: Read-Heavy Audit]';
640
- const strandedCnt = Number(state.attentionHeatmap?.strandedSignalCount || 0);
641
- const strandedSuffix = strandedCnt > 0 ? ` | \u26A0 ${strandedCnt}/40 mid-window blocks` : '';
642
-
643
- let line1 = '';
644
- if (cellCount === 40) {
645
- line1 = `${bar} [ ${activeK}k / ${maxK}k · ${usedPct}% ] \x1b[1mPurity:\x1b[0m ${purity}% | \x1b[1mCache Hit:\x1b[0m ${cacheHitPct}% | \x1b[1mWaste:\x1b[0m ${noiseK}k tok | \x1b[1mCache:\x1b[0m ${cacheLabel} | ${modeTag}${strandedSuffix} \x1b[38;5;51m-> ${recCmd}\x1b[0m`;
646
- } else if (cellCount === 20) {
647
- line1 = `${bar} [${activeK}k/${maxK}k·${usedPct}%] P:${purity}% Waste:${noiseK}k -> ${recCmd}`;
648
- } else {
649
- line1 = `${bar} ${activeK}k P:${purity}% ${recCmd}`;
650
- }
651
- if (columns <= 80) {
652
- line1 = clampAnsiText(line1, Math.min(columns, 80));
653
- }
855
+ const line1 = formatCliStatusLine(state, { columns });
654
856
 
655
857
  if (options.emitWidget || (Array.isArray(process.argv) && process.argv.includes('--emit-widget'))) {
656
858
  const target = path.resolve(options.out || 'horizon_widget.html');
657
- const { html } = renderHorizonPanelHtml(state, { viewMode: 'simple' });
859
+ const { html } = renderClassifierHudHtml(state, { viewMode: 'simple' });
658
860
  fs.mkdirSync(path.dirname(target), { recursive: true });
659
861
  fs.writeFileSync(target, html, 'utf8');
660
862
  const fileUri = `file:///${target.replace(/\\/g, '/').replace(/^\/+/, '')}`;
@@ -674,7 +876,7 @@ export async function emitHorizonWidget(options = {}) {
674
876
  const targetPath = path.resolve(options.out || 'horizon_widget.html');
675
877
  const cliRes = await runCLI({ ...options, silent: true, useNativeCeiling: true });
676
878
  const state = cliRes?.state || {};
677
- const { html } = renderHorizonPanelHtml(state, { viewMode: 'simple' });
879
+ const { html } = renderClassifierHudHtml(state, { viewMode: 'simple' });
678
880
  fs.mkdirSync(path.dirname(targetPath), { recursive: true });
679
881
  fs.writeFileSync(targetPath, html, 'utf8');
680
882
  const fileUri = `file:///${targetPath.replace(/\\/g, '/').replace(/^\/+/, '')}`;
@@ -615,6 +615,90 @@
615
615
  }
616
616
  }
617
617
  ]
618
+ },
619
+ "gemini-3.1-pro": {
620
+ "id": "gemini-3.1-pro",
621
+ "aliases": ["gemini-3.1-pro-preview", "gemini-3-1-pro", "gemini-3-1-pro-preview"],
622
+ "family": "gemini-pro",
623
+ "label": "Gemini 3.1 Pro",
624
+ "supported_efforts": ["low", "medium", "high"],
625
+ "caching_mode": "explicit_and_implicit",
626
+ "supports_explicit_cache": true,
627
+ "antigravity_min_tier": "pro",
628
+ "shared_pool_ceiling": 1000000,
629
+ "deprecated_after": null,
630
+ "prompt_cliff_tokens": 200000,
631
+ "quota_multipliers": { "low": 2.0, "med": 3.5, "medium": 3.5, "high": 5.5 },
632
+ "rate_schedules": [
633
+ {
634
+ "id": "gemini-3-1-pro-standard",
635
+ "effective_from_utc": null,
636
+ "effective_until_utc": null,
637
+ "standard": {
638
+ "input_per_1m": 1.25,
639
+ "output_per_1m": 10.00,
640
+ "write_5m_per_1m": 1.25,
641
+ "write_1h_per_1m": 1.25,
642
+ "cached_read_per_1m": 0.125
643
+ },
644
+ "cliff_over_200k": {
645
+ "input_per_1m": 2.50,
646
+ "output_per_1m": 15.00,
647
+ "write_5m_per_1m": 2.50,
648
+ "write_1h_per_1m": 2.50,
649
+ "cached_read_per_1m": 0.25
650
+ },
651
+ "priority": {
652
+ "input_per_1m": 1.25,
653
+ "output_per_1m": 10.00,
654
+ "write_5m_per_1m": 1.25,
655
+ "write_1h_per_1m": 1.25,
656
+ "cached_read_per_1m": 0.125
657
+ }
658
+ }
659
+ ]
660
+ },
661
+ "gemini-2.5-pro": {
662
+ "id": "gemini-2.5-pro",
663
+ "aliases": ["gemini-2.5-pro-preview", "gemini-2-5-pro", "gemini-2.5-pro-1m"],
664
+ "family": "gemini-pro",
665
+ "label": "Gemini 2.5 Pro",
666
+ "supported_efforts": ["low", "medium", "high"],
667
+ "caching_mode": "explicit_and_implicit",
668
+ "supports_explicit_cache": true,
669
+ "antigravity_min_tier": "pro",
670
+ "shared_pool_ceiling": 1000000,
671
+ "deprecated_after": null,
672
+ "prompt_cliff_tokens": 200000,
673
+ "quota_multipliers": { "low": 2.0, "med": 3.5, "medium": 3.5, "high": 5.5 },
674
+ "rate_schedules": [
675
+ {
676
+ "id": "gemini-2-5-pro-standard",
677
+ "effective_from_utc": null,
678
+ "effective_until_utc": null,
679
+ "standard": {
680
+ "input_per_1m": 1.25,
681
+ "output_per_1m": 10.00,
682
+ "write_5m_per_1m": 1.25,
683
+ "write_1h_per_1m": 1.25,
684
+ "cached_read_per_1m": 0.125
685
+ },
686
+ "cliff_over_200k": {
687
+ "input_per_1m": 2.50,
688
+ "output_per_1m": 15.00,
689
+ "write_5m_per_1m": 2.50,
690
+ "write_1h_per_1m": 2.50,
691
+ "cached_read_per_1m": 0.25
692
+ },
693
+ "priority": {
694
+ "input_per_1m": 1.25,
695
+ "output_per_1m": 10.00,
696
+ "write_5m_per_1m": 1.25,
697
+ "write_1h_per_1m": 1.25,
698
+ "cached_read_per_1m": 0.125
699
+ }
700
+ }
701
+ ]
618
702
  }
619
703
  }
620
704
  }