pi-mega-compact 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,6 +132,31 @@ function visibleWidth(s: string): number {
132
132
  }
133
133
 
134
134
  /** Pad a content string (with ANSI colors) to `width` cells using panel bg. */
135
+ /** Wrap a string (with ANSI codes) to fit within `maxWidth` visible chars.
136
+ * Splits at │ separators or whitespace when possible. */
137
+ function wrapLine(text: string, maxWidth: number): string[] {
138
+ if (maxWidth <= 0) return [text];
139
+ const result: string[] = [];
140
+ let current = "";
141
+ let currentW = 0;
142
+ // Split at │ boundaries first
143
+ const segments = text.split("│");
144
+ for (let i = 0; i < segments.length; i++) {
145
+ const seg = (i > 0 ? "│" : "") + segments[i];
146
+ const segW = visibleWidth(PANEL_BG + seg.replace(/\x1b\[0m/g, PANEL_RST));
147
+ if (currentW + segW <= maxWidth || currentW === 0) {
148
+ current += seg;
149
+ currentW += segW;
150
+ } else {
151
+ result.push(current);
152
+ current = seg;
153
+ currentW = segW;
154
+ }
155
+ }
156
+ if (current) result.push(current);
157
+ return result;
158
+ }
159
+
135
160
  function panelLine(content: string, width: number): string {
136
161
  const withBg = PANEL_BG + content.replace(/\x1b\[0m/g, PANEL_RST);
137
162
  const pad = Math.max(0, width - visibleWidth(withBg));
@@ -720,24 +745,26 @@ export class MegaRuntime {
720
745
  const pulse = wd.pulsing
721
746
  ? `${C.cyan}${PULSE[Math.floor(Date.now() / 250) % PULSE.length]}${C.reset} `
722
747
  : "";
748
+ const sep = ` ${C.dim}│${C.reset} `;
749
+ // Build one long content line — let terminal wrap it naturally
750
+ const content = [
751
+ `${C.amber}⚡ ${wd.tierLabel}${C.reset} v${C.bold}${wd.version}${C.reset} ${ramp(wd.ctxPct, 20)} ${C.bold}${wd.pctStr}${C.reset} ${wd.tokStr}/${wd.maxStr}`,
752
+ wd.triggerLabel,
753
+ `${C.cyan}${wd.modelStr}${C.reset}`,
754
+ `${wd.chk} chk${wd.agentStr}${wd.turnStr}`,
755
+ `${C.magenta}dup ${wd.dedupStr}${C.reset}`,
756
+ `${C.gray}sess${C.reset} ${fmtTokens(wd.sessIn)}→${fmtTokens(wd.sessKept)} kept ${C.green}(${wd.sTxt}% freed)${C.reset}`,
757
+ `${C.gray}all-time${C.reset} ${fmtTokens(wd.repoIn)}→${fmtTokens(wd.repoKept)} kept ${C.blue}(${wd.rTxt}% freed)${C.reset}`,
758
+ `${wd.repoChk} chk/${wd.repoSess} sess`,
759
+ `${C.gray}mem${C.reset} ${wd.embedderName} · ${wd.chk} chunks · ${C.blue}comp ${wd.compStr}${C.reset}`,
760
+ `${C.gray}drift${C.reset} ${wd.driftStatus === "ok" ? C.green : C.amber}${wd.driftStatus}${C.reset}`,
761
+ `${C.gray}compact${C.reset} ${sinceCompactStr(wd.sinceCompact)}`,
762
+ ].join(sep);
763
+ // Wrap to terminal width and pad each line
764
+ const wrapped = wrapLine(content, width - 2); // 2-char indent
723
765
  const lines: string[] = [
724
- // top border
725
766
  panelBar(width, "─"),
726
- // L1 header: tier + ctx bar + pct/tokens + status + model + chk + agents/turn
727
- panelLine(
728
- ` ${C.amber}⚡ ${wd.tierLabel}${C.reset} v${C.bold}${wd.version}${C.reset} ${ramp(wd.ctxPct, 20)} ${C.bold}${wd.pctStr}${C.reset} ${wd.tokStr}/${wd.maxStr} │ ${wd.triggerLabel} │ ${C.cyan}${wd.modelStr}${C.reset} │ ${wd.chk} chk${wd.agentStr}${wd.turnStr}`,
729
- width,
730
- ),
731
- // L2 — savings reconciled (session + all-time)
732
- panelLine(
733
- ` ${C.magenta}dup ${wd.dedupStr}${C.reset} │ ${C.gray}sess${C.reset} ${fmtTokens(wd.sessIn)}→${fmtTokens(wd.sessKept)} kept ${C.green}(${wd.sTxt}% freed)${C.reset} · ${C.gray}all-time${C.reset} ${fmtTokens(wd.repoIn)}→${fmtTokens(wd.repoKept)} kept ${C.blue}(${wd.rTxt}% freed)${C.reset} │ ${wd.repoChk} chk/${wd.repoSess} sess`,
734
- width,
735
- ),
736
- // L3 — memory store + compression + drift + since-compact (NEW)
737
- panelLine(
738
- ` ${C.gray}mem${C.reset} ${wd.embedderName} · ${wd.chk} chunks · ${C.blue}comp ${wd.compStr}${C.reset} │ ${C.gray}drift${C.reset} ${wd.driftStatus === "ok" ? C.green : C.amber}${wd.driftStatus}${C.reset} │ ${C.gray}compact${C.reset} ${sinceCompactStr(wd.sinceCompact)}`,
739
- width,
740
- ),
767
+ ...wrapped.map((l) => panelLine(l, width)),
741
768
  ];
742
769
  // L4 — agents block (S27, count + status; per-agent tokens gated on P0)
743
770
  if (wd.agentsActive) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-2-Clause",