MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / formatContextMeter

Function formatContextMeter

src/cli/viewport.ts:75–82  ·  view source on GitHub ↗
(used: number, window: number, barWidth = 10)

Source from the content-addressed store, hash-verified

73 * Returns '' when the window size is unknown (nothing useful to show).
74 */
75export function formatContextMeter(used: number, window: number, barWidth = 10): string {
76 if (!window || window <= 0 || used <= 0) return '';
77 const pct = Math.min(100, Math.round((used / window) * 100));
78 const filled = Math.min(barWidth, Math.round((pct / 100) * barWidth));
79 const bar = '█'.repeat(filled) + '░'.repeat(barWidth - filled);
80 const k = (n: number) => (n >= 1000 ? `${(n / 1000).toFixed(n >= 10000 ? 0 : 1)}k` : String(n));
81 return `${k(used)}/${k(window)} ${bar} ${pct}%`;
82}

Callers 2

viewport.test.tsFile · 0.90
StatusBarFunction · 0.85

Calls 1

kFunction · 0.85

Tested by

no test coverage detected