@danypops/papyrus 0.15.1 → 0.15.2
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.
|
@@ -13,19 +13,6 @@ const SEGMENT_COLORS: Record<ContextSegment["key"], ThemeColor> = {
|
|
|
13
13
|
other: "muted",
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
/** Short, fixed-width column labels for the vertical deep-dive graph -- must match VERTICAL_BAR_WIDTH exactly so each label sits centered under its own bar. */
|
|
17
|
-
const SEGMENT_SHORT_LABELS: Record<ContextSegment["key"], string> = {
|
|
18
|
-
rules: "Rul",
|
|
19
|
-
tasks: "Tsk",
|
|
20
|
-
skills: "Skl",
|
|
21
|
-
basePrompt: "Bse",
|
|
22
|
-
messageHistory: "Msg",
|
|
23
|
-
other: "Oth",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const VERTICAL_BAR_HEIGHT = 6;
|
|
27
|
-
const VERTICAL_BAR_WIDTH = 3;
|
|
28
|
-
|
|
29
16
|
/**
|
|
30
17
|
* One row in the unified scrollable view. Every segment that has any real (nonzero) content
|
|
31
18
|
* is fully expanded inline -- there is no separate "select a segment, then drill in" step.
|
|
@@ -121,12 +108,6 @@ class ContextViewport {
|
|
|
121
108
|
if (this.breakdown.overshootTokens > 0) {
|
|
122
109
|
lines.push(truncateToWidth(theme.fg("warning", `Estimates exceed real total by ~${this.breakdown.overshootTokens} tok — sizes below are approximate, not exact`), contentWidth, ""));
|
|
123
110
|
}
|
|
124
|
-
const verticalBars = renderContextVerticalBars(theme, this.breakdown.segments);
|
|
125
|
-
if (verticalBars.length > 0) {
|
|
126
|
-
lines.push("");
|
|
127
|
-
lines.push(theme.fg("dim", "Composition of used tokens:"));
|
|
128
|
-
for (const barLine of verticalBars) lines.push(truncateToWidth(barLine, contentWidth, ""));
|
|
129
|
-
}
|
|
130
111
|
lines.push("");
|
|
131
112
|
|
|
132
113
|
this.visibleWindow().forEach(({ row, index }) => {
|
|
@@ -220,36 +201,6 @@ export function renderContextBar(theme: Theme, segments: ReadonlyArray<ContextSe
|
|
|
220
201
|
return output;
|
|
221
202
|
}
|
|
222
203
|
|
|
223
|
-
/**
|
|
224
|
-
* Renders the "used" portion's own composition as a small vertical bar chart, one column per
|
|
225
|
-
* segment with real content, scaled so the largest segment fills the full height -- the
|
|
226
|
-
* "deep dive" graph, complementing the horizontal used-vs-unused bar above it. Any segment
|
|
227
|
-
* with real (nonzero) tokens gets at least one filled row so it stays visible even next to a
|
|
228
|
-
* much larger segment. Returns an empty array (nothing to render) when no segment has any
|
|
229
|
-
* tokens yet, matching the same zero-noise principle as the row list below it.
|
|
230
|
-
*/
|
|
231
|
-
export function renderContextVerticalBars(theme: Theme, segments: ReadonlyArray<ContextSegment>): string[] {
|
|
232
|
-
const visible = segments.filter((segment) => segment.estimatedTokens > 0);
|
|
233
|
-
if (visible.length === 0) return [];
|
|
234
|
-
const max = Math.max(...visible.map((segment) => segment.estimatedTokens));
|
|
235
|
-
const filledRows = new Map(visible.map((segment) => [segment.key, Math.max(1, Math.round((segment.estimatedTokens / max) * VERTICAL_BAR_HEIGHT))]));
|
|
236
|
-
|
|
237
|
-
const lines: string[] = [];
|
|
238
|
-
for (let row = 0; row < VERTICAL_BAR_HEIGHT; row++) {
|
|
239
|
-
const rowsFromBottom = VERTICAL_BAR_HEIGHT - row;
|
|
240
|
-
let line = "";
|
|
241
|
-
for (const segment of visible) {
|
|
242
|
-
const filled = (filledRows.get(segment.key) ?? 0) >= rowsFromBottom;
|
|
243
|
-
line += `${filled ? theme.fg(SEGMENT_COLORS[segment.key], "█".repeat(VERTICAL_BAR_WIDTH)) : " ".repeat(VERTICAL_BAR_WIDTH)} `;
|
|
244
|
-
}
|
|
245
|
-
lines.push(line);
|
|
246
|
-
}
|
|
247
|
-
let legend = "";
|
|
248
|
-
for (const segment of visible) legend += `${theme.fg(SEGMENT_COLORS[segment.key], SEGMENT_SHORT_LABELS[segment.key])} `;
|
|
249
|
-
lines.push(legend);
|
|
250
|
-
return lines;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
204
|
/** Non-interactive fallback (print mode, RPC, etc.): the same unified row list, as plain text lines. */
|
|
254
205
|
function fallbackReport(breakdown: ContextBreakdown): string {
|
|
255
206
|
const totalLine = breakdown.totalTokens !== null
|
package/package.json
CHANGED