pi-mega-compact 0.6.5 → 0.6.6
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/extensions/mega-runtime.js +29 -18
- package/extensions/mega-runtime.ts +27 -18
- package/package.json +1 -1
|
@@ -53,6 +53,7 @@ export const C = {
|
|
|
53
53
|
magenta: "\x1b[38;5;201m", // dedup rate
|
|
54
54
|
blue: "\x1b[38;5;75m", // repo totals
|
|
55
55
|
gray: "\x1b[38;5;245m", // labels
|
|
56
|
+
red: "\x1b[38;5;203m", // pressure / overflow
|
|
56
57
|
};
|
|
57
58
|
const PULSE = ["◐", "◓", "◑", "◒"];
|
|
58
59
|
export class MegaRuntime {
|
|
@@ -315,7 +316,7 @@ export class MegaRuntime {
|
|
|
315
316
|
// 1e6, k at/above 1e3, raw below — so 5,472,700 → "5.5M", 24,100 → "24.1k",
|
|
316
317
|
// 142 → "142". Dropped (in) = Freed + Kept; Freed = rt.tokensSaved (session)
|
|
317
318
|
// / repo.tokensSaved meta (repo); Kept = totalTokenEstimate (stored).
|
|
318
|
-
const fmt = (x) => x >= 1_000_000 ? `${(x / 1_000_000).toFixed(1)}
|
|
319
|
+
const fmt = (x) => x >= 1_000_000 ? `${(x / 1_000_000).toFixed(1)}mil`
|
|
319
320
|
: x >= 1000 ? `${(x / 1000).toFixed(1)}k`
|
|
320
321
|
: `${Math.round(x)}`;
|
|
321
322
|
const agentStr = this.activeAgents > 0 ? ` │ 🤖 ${this.activeAgents} agent${this.activeAgents === 1 ? "" : "s"}` : "";
|
|
@@ -331,21 +332,32 @@ export class MegaRuntime {
|
|
|
331
332
|
const repoKept = repo.totalTokenEstimate;
|
|
332
333
|
const repoFreed = repo.tokensSaved;
|
|
333
334
|
const repoPct = repoIn > 0 ? repoFreed / repoIn : 0;
|
|
335
|
+
// Retro gradient bar — 12 cells, each cell shaded by fill so it reads as a
|
|
336
|
+
// smooth green→amber→red ramp instead of a flat block. Higher fill = more
|
|
337
|
+
// reclaimed, so the bar trends green at the right end.
|
|
338
|
+
const ramp = (pct, w = 12) => {
|
|
339
|
+
const cells = ["▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"];
|
|
340
|
+
const scaled = Math.max(0, Math.min(w, pct * w));
|
|
341
|
+
const full = Math.floor(scaled);
|
|
342
|
+
const frac = scaled - full;
|
|
343
|
+
const fracCell = frac > 0 ? cells[Math.round(frac * (cells.length - 1))] : "";
|
|
344
|
+
let out = "";
|
|
345
|
+
for (let i = 0; i < full; i++)
|
|
346
|
+
out += (i / w < 0.6 ? C.green : i / w < 0.85 ? C.amber : C.red) + "█";
|
|
347
|
+
if (fracCell)
|
|
348
|
+
out += (full / w < 0.6 ? C.green : full / w < 0.85 ? C.amber : C.red) + fracCell;
|
|
349
|
+
out += C.dim + "░".repeat(Math.max(0, w - full - (fracCell ? 1 : 0))) + C.reset;
|
|
350
|
+
return out;
|
|
351
|
+
};
|
|
352
|
+
const ctxPct = this.lastCtxPercent != null ? this.lastCtxPercent / 100 : 0;
|
|
353
|
+
const sTxt = (sessPct * 100).toFixed(sessPct * 100 >= 10 ? 0 : 1);
|
|
354
|
+
const rTxt = (repoPct * 100).toFixed(repoPct * 100 >= 10 ? 0 : 1);
|
|
334
355
|
const lines = [
|
|
335
|
-
|
|
336
|
-
`
|
|
337
|
-
|
|
356
|
+
// L1 — header: tier + ctx fill bar + tokens + checkpoints + agents
|
|
357
|
+
` ${C.amber}⚡ ${tierLabel}${C.reset} v${C.bold}${ownVersion()}${C.reset} ${ramp(ctxPct)} ${C.bold}${pctStr}${C.reset} ${tokStr}/${maxStr} │ ${st.checkpointCount} chk${agentStr}${turnStr}`,
|
|
358
|
+
// L2 — status + dedup + session + all-time savings bars
|
|
359
|
+
` ${triggerLabel} ${C.magenta}dup ${dedupStr}${C.reset} ${C.gray}sess${C.reset} ${ramp(sessPct)} ${C.green}${sTxt}%${C.reset} ${C.gray}all-time${C.reset} ${ramp(repoPct)} ${C.blue}${rTxt}%${C.reset}`,
|
|
338
360
|
];
|
|
339
|
-
// Compression meter — the single headline "% tokens saved" (Freed / In),
|
|
340
|
-
// same formula as the dashboard. Higher = better, so it reads green.
|
|
341
|
-
{
|
|
342
|
-
const w = 10;
|
|
343
|
-
const filled = Math.max(0, Math.min(w, Math.round(sessPct * w)));
|
|
344
|
-
const cbar = C.green + "▓".repeat(filled) + C.dim + "░".repeat(w - filled) + C.reset;
|
|
345
|
-
const sTxt = (sessPct * 100).toFixed(sessPct * 100 >= 10 ? 0 : 1);
|
|
346
|
-
const rTxt = (repoPct * 100).toFixed(repoPct * 100 >= 10 ? 0 : 1);
|
|
347
|
-
lines.push(` ${cbar} ${sTxt}% tokens saved (sess) · ${rTxt}% repo${C.reset}`);
|
|
348
|
-
}
|
|
349
361
|
// Live "now processing" line + why + recent deduped/compacted events,
|
|
350
362
|
// collapsed to ONE rotating line (fresh only). The ticker ring buffer
|
|
351
363
|
// (≤5 most-recent events) is cycled one-per-repaint so the line scrolls
|
|
@@ -367,11 +379,10 @@ export class MegaRuntime {
|
|
|
367
379
|
else if (this.pulsing) {
|
|
368
380
|
lines.push(` ${pulse}${C.teal}compacting…${C.reset}`);
|
|
369
381
|
}
|
|
370
|
-
//
|
|
371
|
-
//
|
|
372
|
-
// (saved) tokens for both this session and all-time across the repo.
|
|
382
|
+
// L4 — accounting: session + all-time in/out/freed, one compact line.
|
|
383
|
+
// in = dropped into compaction, out = kept summaries, freed = saved.
|
|
373
384
|
if (lines.length < 10) {
|
|
374
|
-
lines.push(` ${C.dim}session ↑${fmt(sessIn)} in ↓${fmt(sessKept)} out ·
|
|
385
|
+
lines.push(` ${C.dim}session ↑${fmt(sessIn)} in ↓${fmt(sessKept)} out ↓${fmt(sessFreed)} freed · all-time ↑${fmt(repoIn)} in ↓${fmt(repoKept)} out ↓${fmt(repoFreed)} freed${C.reset}`);
|
|
375
386
|
}
|
|
376
387
|
ctx.ui.setWidget(WIDGET_KEY, lines, { placement: "aboveEditor" });
|
|
377
388
|
}
|
|
@@ -69,6 +69,7 @@ export const C = {
|
|
|
69
69
|
magenta: "\x1b[38;5;201m", // dedup rate
|
|
70
70
|
blue: "\x1b[38;5;75m", // repo totals
|
|
71
71
|
gray: "\x1b[38;5;245m", // labels
|
|
72
|
+
red: "\x1b[38;5;203m", // pressure / overflow
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
const PULSE = ["◐", "◓", "◑", "◒"];
|
|
@@ -344,7 +345,7 @@ export class MegaRuntime {
|
|
|
344
345
|
// 142 → "142". Dropped (in) = Freed + Kept; Freed = rt.tokensSaved (session)
|
|
345
346
|
// / repo.tokensSaved meta (repo); Kept = totalTokenEstimate (stored).
|
|
346
347
|
const fmt = (x: number) =>
|
|
347
|
-
x >= 1_000_000 ? `${(x / 1_000_000).toFixed(1)}
|
|
348
|
+
x >= 1_000_000 ? `${(x / 1_000_000).toFixed(1)}mil`
|
|
348
349
|
: x >= 1000 ? `${(x / 1000).toFixed(1)}k`
|
|
349
350
|
: `${Math.round(x)}`;
|
|
350
351
|
const agentStr = this.activeAgents > 0 ? ` │ 🤖 ${this.activeAgents} agent${this.activeAgents === 1 ? "" : "s"}` : "";
|
|
@@ -360,21 +361,30 @@ export class MegaRuntime {
|
|
|
360
361
|
const repoKept = repo.totalTokenEstimate;
|
|
361
362
|
const repoFreed = repo.tokensSaved;
|
|
362
363
|
const repoPct = repoIn > 0 ? repoFreed / repoIn : 0;
|
|
364
|
+
// Retro gradient bar — 12 cells, each cell shaded by fill so it reads as a
|
|
365
|
+
// smooth green→amber→red ramp instead of a flat block. Higher fill = more
|
|
366
|
+
// reclaimed, so the bar trends green at the right end.
|
|
367
|
+
const ramp = (pct: number, w = 12): string => {
|
|
368
|
+
const cells = ["▏","▎","▍","▌","▋","▊","▉","█"];
|
|
369
|
+
const scaled = Math.max(0, Math.min(w, pct * w));
|
|
370
|
+
const full = Math.floor(scaled);
|
|
371
|
+
const frac = scaled - full;
|
|
372
|
+
const fracCell = frac > 0 ? cells[Math.round(frac * (cells.length - 1))] : "";
|
|
373
|
+
let out = "";
|
|
374
|
+
for (let i = 0; i < full; i++) out += (i / w < 0.6 ? C.green : i / w < 0.85 ? C.amber : C.red) + "█";
|
|
375
|
+
if (fracCell) out += (full / w < 0.6 ? C.green : full / w < 0.85 ? C.amber : C.red) + fracCell;
|
|
376
|
+
out += C.dim + "░".repeat(Math.max(0, w - full - (fracCell ? 1 : 0))) + C.reset;
|
|
377
|
+
return out;
|
|
378
|
+
};
|
|
379
|
+
const ctxPct = this.lastCtxPercent != null ? this.lastCtxPercent / 100 : 0;
|
|
380
|
+
const sTxt = (sessPct * 100).toFixed(sessPct * 100 >= 10 ? 0 : 1);
|
|
381
|
+
const rTxt = (repoPct * 100).toFixed(repoPct * 100 >= 10 ? 0 : 1);
|
|
363
382
|
const lines = [
|
|
364
|
-
|
|
365
|
-
`
|
|
366
|
-
|
|
383
|
+
// L1 — header: tier + ctx fill bar + tokens + checkpoints + agents
|
|
384
|
+
` ${C.amber}⚡ ${tierLabel}${C.reset} v${C.bold}${ownVersion()}${C.reset} ${ramp(ctxPct)} ${C.bold}${pctStr}${C.reset} ${tokStr}/${maxStr} │ ${st.checkpointCount} chk${agentStr}${turnStr}`,
|
|
385
|
+
// L2 — status + dedup + session + all-time savings bars
|
|
386
|
+
` ${triggerLabel} ${C.magenta}dup ${dedupStr}${C.reset} ${C.gray}sess${C.reset} ${ramp(sessPct)} ${C.green}${sTxt}%${C.reset} ${C.gray}all-time${C.reset} ${ramp(repoPct)} ${C.blue}${rTxt}%${C.reset}`,
|
|
367
387
|
];
|
|
368
|
-
// Compression meter — the single headline "% tokens saved" (Freed / In),
|
|
369
|
-
// same formula as the dashboard. Higher = better, so it reads green.
|
|
370
|
-
{
|
|
371
|
-
const w = 10;
|
|
372
|
-
const filled = Math.max(0, Math.min(w, Math.round(sessPct * w)));
|
|
373
|
-
const cbar = C.green + "▓".repeat(filled) + C.dim + "░".repeat(w - filled) + C.reset;
|
|
374
|
-
const sTxt = (sessPct * 100).toFixed(sessPct * 100 >= 10 ? 0 : 1);
|
|
375
|
-
const rTxt = (repoPct * 100).toFixed(repoPct * 100 >= 10 ? 0 : 1);
|
|
376
|
-
lines.push(` ${cbar} ${sTxt}% tokens saved (sess) · ${rTxt}% repo${C.reset}`);
|
|
377
|
-
}
|
|
378
388
|
// Live "now processing" line + why + recent deduped/compacted events,
|
|
379
389
|
// collapsed to ONE rotating line (fresh only). The ticker ring buffer
|
|
380
390
|
// (≤5 most-recent events) is cycled one-per-repaint so the line scrolls
|
|
@@ -394,11 +404,10 @@ export class MegaRuntime {
|
|
|
394
404
|
} else if (this.pulsing) {
|
|
395
405
|
lines.push(` ${pulse}${C.teal}compacting…${C.reset}`);
|
|
396
406
|
}
|
|
397
|
-
//
|
|
398
|
-
//
|
|
399
|
-
// (saved) tokens for both this session and all-time across the repo.
|
|
407
|
+
// L4 — accounting: session + all-time in/out/freed, one compact line.
|
|
408
|
+
// in = dropped into compaction, out = kept summaries, freed = saved.
|
|
400
409
|
if (lines.length < 10) {
|
|
401
|
-
lines.push(` ${C.dim}session ↑${fmt(sessIn)} in ↓${fmt(sessKept)} out ·
|
|
410
|
+
lines.push(` ${C.dim}session ↑${fmt(sessIn)} in ↓${fmt(sessKept)} out ↓${fmt(sessFreed)} freed · all-time ↑${fmt(repoIn)} in ↓${fmt(repoKept)} out ↓${fmt(repoFreed)} freed${C.reset}`);
|
|
402
411
|
}
|
|
403
412
|
ctx.ui.setWidget(WIDGET_KEY, lines, { placement: "aboveEditor" });
|
|
404
413
|
}
|
package/package.json
CHANGED