ceulen 0.10.1 → 0.11.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.
- package/CHANGELOG.md +56 -0
- package/README.md +56 -1
- package/extensions/lib/plan-bridge.ts +18 -0
- package/extensions/lib/registry.ts +14 -0
- package/extensions/modules/a2a/index.ts +4 -2
- package/extensions/modules/attachments/configPanel.ts +91 -0
- package/extensions/modules/attachments/index.ts +274 -0
- package/extensions/modules/attachments/lib/clipboard-files.ts +80 -0
- package/extensions/modules/attachments/lib/pastes.ts +45 -0
- package/extensions/modules/attachments/lib/paths.ts +74 -0
- package/extensions/modules/attachments/lib/registry.ts +70 -0
- package/extensions/modules/attachments/lib/settings.ts +99 -0
- package/extensions/modules/attachments/lib/tray.ts +74 -0
- package/extensions/modules/attachments/test/configPanel.test.ts +122 -0
- package/extensions/modules/attachments/test/index.test.ts +870 -0
- package/extensions/modules/attachments/test/module.test.ts +53 -0
- package/extensions/modules/composer/test/module.test.ts +2 -2
- package/extensions/modules/config/index.ts +3 -0
- package/extensions/modules/config/test/renderTools.test.ts +1 -1
- package/extensions/modules/cron/configPanel.ts +103 -0
- package/extensions/modules/cron/index.ts +638 -0
- package/extensions/modules/cron/lib/jobs.ts +201 -0
- package/extensions/modules/cron/lib/schedule.ts +161 -0
- package/extensions/modules/cron/test/cwd-repro.test.ts +98 -0
- package/extensions/modules/cron/test/index.test.ts +859 -0
- package/extensions/modules/cron/test/schedule.test.ts +93 -0
- package/extensions/modules/munin/index.ts +3 -1
- package/extensions/modules/permission/index.ts +567 -0
- package/extensions/modules/permission/test/permission.test.ts +789 -0
- package/extensions/modules/plan/index.ts +5 -0
- package/extensions/modules/repair/index.ts +134 -3
- package/extensions/modules/repair/test/freshness.test.ts +169 -0
- package/extensions/modules/subagent/index.ts +38 -5
- package/extensions/modules/subagent/lib/runner.ts +348 -12
- package/extensions/modules/subagent/test/worktree.test.ts +230 -0
- package/extensions/modules/usage/index.ts +193 -71
- package/extensions/modules/usage/test/context.test.ts +160 -120
- package/extensions/modules/web/index.ts +3 -1
- package/extensions/modules/web/test/a11y.test.ts +1 -1
- package/package.json +2 -2
- package/skills/cron/SKILL.md +58 -0
|
@@ -1516,51 +1516,105 @@ export function formatCtxPercent(tokens: number, contextWindow: number): string
|
|
|
1516
1516
|
|
|
1517
1517
|
/** Waffle-chart glyphs, matching OMP's vocabulary. */
|
|
1518
1518
|
const WAFFLE_FILLED = "⛁";
|
|
1519
|
+
const WAFFLE_MESSAGES = "⛃";
|
|
1519
1520
|
const WAFFLE_FREE = "⛶";
|
|
1520
1521
|
const WAFFLE_BUFFER = "⛝";
|
|
1521
1522
|
|
|
1522
|
-
/** OMP
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1523
|
+
/** OMP grid geometry: 20×10 = 200 space-joined cells beside the legend. */
|
|
1524
|
+
export const CTX_GRID_COLS = 20;
|
|
1525
|
+
export const CTX_GRID_ROWS = 10;
|
|
1526
|
+
const CTX_GUTTER = " ";
|
|
1527
|
+
|
|
1528
|
+
/** One planned cell: glyph + the ThemeColor (or "strong") to paint it with. */
|
|
1529
|
+
export interface CtxCell {
|
|
1530
|
+
glyph: string;
|
|
1531
|
+
color: "accent" | "warning" | "success" | "userMessageText" | "customMessageLabel" | "dim";
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
/** OMP's category→color map (all tokens exist in pi's ThemeColor). */
|
|
1535
|
+
const CTX_CATEGORY_STYLE: Record<string, { glyph: string; color: CtxCell["color"] }> = {
|
|
1536
|
+
"System prompt": { glyph: WAFFLE_FILLED, color: "accent" },
|
|
1537
|
+
"System tools": { glyph: WAFFLE_FILLED, color: "warning" },
|
|
1538
|
+
"System context": { glyph: WAFFLE_FILLED, color: "customMessageLabel" },
|
|
1539
|
+
Skills: { glyph: WAFFLE_FILLED, color: "success" },
|
|
1540
|
+
Messages: { glyph: WAFFLE_MESSAGES, color: "userMessageText" },
|
|
1541
|
+
"Free space": { glyph: WAFFLE_FREE, color: "dim" },
|
|
1542
|
+
"Autocompact buffer": { glyph: WAFFLE_BUFFER, color: "warning" },
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
/** OMP's cell planner over the disjoint categories: cells are allocated by
|
|
1546
|
+
* share of the window, every nonzero category keeps at least one visible cell
|
|
1547
|
+
* (visibility scaling — OMP's ratioCells has no lower share gate). Overflow
|
|
1548
|
+
* trims from the largest category first, never below one cell; the remainder
|
|
1549
|
+
* is painted free, then the autocompact buffer hatches the tail. Always
|
|
1550
|
+
* exactly cols × rows cells. */
|
|
1551
|
+
export function planCtxCells(
|
|
1552
|
+
categories: { label: string; tokens: number }[],
|
|
1532
1553
|
contextWindow: number,
|
|
1533
|
-
cols =
|
|
1534
|
-
rows =
|
|
1535
|
-
):
|
|
1554
|
+
cols = CTX_GRID_COLS,
|
|
1555
|
+
rows = CTX_GRID_ROWS,
|
|
1556
|
+
): CtxCell[] {
|
|
1536
1557
|
const cells = cols * rows;
|
|
1537
|
-
if (!(contextWindow > 0))
|
|
1538
|
-
|
|
1539
|
-
const alloc = slices.map((s) => {
|
|
1540
|
-
const tokens = Math.max(0, s.tokens);
|
|
1541
|
-
if (tokens <= 0) return 0;
|
|
1542
|
-
const share = tokens / contextWindow;
|
|
1543
|
-
return share < MIN_SHARE ? 1 : Math.max(1, Math.round(share * cells));
|
|
1544
|
-
});
|
|
1545
|
-
// Overflow swallows from the largest slice first (never below one cell).
|
|
1546
|
-
let total = alloc.reduce((a, b) => a + b, 0);
|
|
1547
|
-
while (total > cells) {
|
|
1548
|
-
const biggest = alloc.indexOf(Math.max(...alloc));
|
|
1549
|
-
if (alloc[biggest] <= 1) break;
|
|
1550
|
-
alloc[biggest] -= 1;
|
|
1551
|
-
total -= 1;
|
|
1558
|
+
if (!(contextWindow > 0)) {
|
|
1559
|
+
return Array.from({ length: cells }, () => ({ glyph: WAFFLE_FREE, color: "dim" as const }));
|
|
1552
1560
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1561
|
+
const tokensPerCell = contextWindow / cells;
|
|
1562
|
+
const count = (tokens: number) => (tokens > 0 ? Math.max(1, Math.round(tokens / tokensPerCell)) : 0);
|
|
1563
|
+
const planned = categories.map((c) => ({ style: CTX_CATEGORY_STYLE[c.label] ?? { glyph: WAFFLE_FILLED, color: "accent" as const }, n: count(c.tokens) }));
|
|
1564
|
+
let used = planned.reduce((a, p) => a + p.n, 0);
|
|
1565
|
+
if (used > cells) {
|
|
1566
|
+
// Trim from the largest allocations first, preserving visibility for small ones.
|
|
1567
|
+
const order = [...planned].sort((a, b) => b.n - a.n);
|
|
1568
|
+
let overflow = used - cells;
|
|
1569
|
+
for (const p of order) {
|
|
1570
|
+
while (overflow > 0 && p.n > 1) {
|
|
1571
|
+
p.n -= 1;
|
|
1572
|
+
overflow -= 1;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
used = planned.reduce((a, p) => a + p.n, 0);
|
|
1559
1576
|
}
|
|
1560
|
-
const
|
|
1561
|
-
const out:
|
|
1562
|
-
for (let
|
|
1563
|
-
|
|
1577
|
+
const freeCount = Math.max(0, cells - used);
|
|
1578
|
+
const out: CtxCell[] = [];
|
|
1579
|
+
for (const p of planned) for (let i = 0; i < p.n; i++) out.push({ glyph: p.style.glyph, color: p.style.color });
|
|
1580
|
+
for (let i = 0; i < freeCount; i++) out.push({ glyph: WAFFLE_FREE, color: "dim" });
|
|
1581
|
+
while (out.length < cells) out.push({ glyph: WAFFLE_FREE, color: "dim" });
|
|
1582
|
+
return out.slice(0, cells);
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
/** Styled legend runs (OMP's LegendPart shape): `s` is a ThemeColor, "strong"
|
|
1586
|
+
* (bold), or undefined (plain). Plain data — the renderer applies the live
|
|
1587
|
+
* theme at display time. */
|
|
1588
|
+
export type CtxLegendPart = { t: string; s?: CtxCell["color"] | "muted" | "strong" };
|
|
1589
|
+
|
|
1590
|
+
/** Legend lines for the /context panel, mirroring OMP's buildLegendParts:
|
|
1591
|
+
* model header, totals, then the per-category block and free/buffer rows. */
|
|
1592
|
+
export function buildCtxLegend(b: ContextBreakdown): CtxLegendPart[][] {
|
|
1593
|
+
const k = formatCtxTokens;
|
|
1594
|
+
const pct = (n: number) => formatCtxPercent(n, b.contextWindow);
|
|
1595
|
+
const windowLabel = b.contextWindow > 0 ? k(b.contextWindow) : "?";
|
|
1596
|
+
const lines: CtxLegendPart[][] = [];
|
|
1597
|
+
if (b.modelName) lines.push([{ t: b.modelName, s: "strong" }, ...(b.contextWindow > 0 ? [{ t: ` (${windowLabel} context)`, s: "dim" as const }] : [])]);
|
|
1598
|
+
if (b.modelLabel) lines.push([{ t: `${b.modelLabel.split("/").pop()}${b.contextWindow > 0 ? `[${windowLabel}]` : ""}`, s: "muted" as const }]);
|
|
1599
|
+
const used = b.usedTokens ?? b.systemPrompt.total + b.tools.total + b.messages.total;
|
|
1600
|
+
lines.push([
|
|
1601
|
+
{ t: k(used), s: "strong" },
|
|
1602
|
+
{ t: `/${windowLabel} tokens`, s: "dim" },
|
|
1603
|
+
{ t: ` (${formatCtxPercent(used, b.contextWindow)})`, s: "muted" as const },
|
|
1604
|
+
]);
|
|
1605
|
+
lines.push([]);
|
|
1606
|
+
lines.push([{ t: "Estimated usage by category", s: "muted" as const }]);
|
|
1607
|
+
for (const c of b.categories) {
|
|
1608
|
+
const style = CTX_CATEGORY_STYLE[c.label];
|
|
1609
|
+
lines.push([
|
|
1610
|
+
{ t: c.glyph, s: style?.color ?? "accent" },
|
|
1611
|
+
{ t: ` ${c.label}: ` },
|
|
1612
|
+
{ t: k(c.tokens), s: "strong" },
|
|
1613
|
+
{ t: c.tokens === 1 ? " token " : " tokens ", s: "dim" },
|
|
1614
|
+
{ t: `(${pct(c.tokens)})`, s: "dim" },
|
|
1615
|
+
]);
|
|
1616
|
+
}
|
|
1617
|
+
return lines;
|
|
1564
1618
|
}
|
|
1565
1619
|
|
|
1566
1620
|
/** Token cost of one tool as the prompt carries it: description + JSON
|
|
@@ -1758,7 +1812,7 @@ export function computeContextBreakdown(input: ContextBreakdownInput): ContextBr
|
|
|
1758
1812
|
{ label: "System tools", tokens: toolsTotal, glyph: "⛁" },
|
|
1759
1813
|
{ label: "System context", tokens: contextTokens, glyph: "⛁" },
|
|
1760
1814
|
{ label: "Skills", tokens: skillsTokens, glyph: "⛁" },
|
|
1761
|
-
{ label: "Messages", tokens: messagesRow, glyph:
|
|
1815
|
+
{ label: "Messages", tokens: messagesRow, glyph: WAFFLE_MESSAGES },
|
|
1762
1816
|
{ label: "Free space", tokens: freeSpace, glyph: WAFFLE_FREE },
|
|
1763
1817
|
// The reserve is the LAST slice of the window (pi compacts at
|
|
1764
1818
|
// `tokens > window - reserve`), so it renders after free space.
|
|
@@ -1789,9 +1843,10 @@ export function computeContextBreakdown(input: ContextBreakdownInput): ContextBr
|
|
|
1789
1843
|
};
|
|
1790
1844
|
}
|
|
1791
1845
|
|
|
1792
|
-
/** Render the /context panel in OMP's layout:
|
|
1793
|
-
*
|
|
1794
|
-
*
|
|
1846
|
+
/** Render the /context panel in OMP's layout: 20×10 cell grid paired with the
|
|
1847
|
+
* legend beside it (3-space gutter), then detail lists and pruning
|
|
1848
|
+
* recommendations. Returns plain lines for the transcript fallback; the
|
|
1849
|
+
* structured grid+legend for the themed renderer rides in `details`. */
|
|
1795
1850
|
export function renderContextPanel(b: ContextBreakdown): string[] {
|
|
1796
1851
|
const k = formatCtxTokens;
|
|
1797
1852
|
const pct = (n: number) => ` (${formatCtxPercent(n, b.contextWindow)})`;
|
|
@@ -1806,28 +1861,34 @@ export function renderContextPanel(b: ContextBreakdown): string[] {
|
|
|
1806
1861
|
}
|
|
1807
1862
|
const used = b.usedTokens ?? b.systemPrompt.total + b.tools.total + b.messages.total;
|
|
1808
1863
|
|
|
1809
|
-
// ── Header:
|
|
1810
|
-
|
|
1811
|
-
const
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
b.modelName ? `${b.modelName}${b.contextWindow > 0 ? ` (${k(b.contextWindow)} context)` : ""}` : undefined,
|
|
1815
|
-
// OMP shows the bare model id with the window bracketed: `glm-5.3[1m]`.
|
|
1816
|
-
b.modelLabel ? `${b.modelLabel.split("/").pop()}${b.contextWindow > 0 ? `[${k(b.contextWindow)}]` : ""}` : undefined,
|
|
1817
|
-
`${k(used)}/${k(b.contextWindow)} tokens (${formatCtxPercent(used, b.contextWindow)})`,
|
|
1818
|
-
"Estimated usage by category",
|
|
1819
|
-
];
|
|
1820
|
-
for (let r = 0; r < grid.length; r++) {
|
|
1821
|
-
const rightText = right[r];
|
|
1822
|
-
lines.push(rightText ? `${grid[r]} ${rightText}` : grid[r]);
|
|
1864
|
+
// ── Header: 20×10 cell grid on the left, legend on the right ──
|
|
1865
|
+
const cells = planCtxCells(b.categories, b.contextWindow);
|
|
1866
|
+
const gridRows: string[] = [];
|
|
1867
|
+
for (let r = 0; r < CTX_GRID_ROWS; r++) {
|
|
1868
|
+
gridRows.push(cells.slice(r * CTX_GRID_COLS, (r + 1) * CTX_GRID_COLS).map((c) => c.glyph).join(" "));
|
|
1823
1869
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
//
|
|
1870
|
+
// Legend lines share the per-category color map; build them as plain text here.
|
|
1871
|
+
const legend: string[] = [];
|
|
1872
|
+
if (b.modelName) legend.push(`${b.modelName}${b.contextWindow > 0 ? ` (${k(b.contextWindow)} context)` : ""}`);
|
|
1873
|
+
// OMP shows the bare model id with the window bracketed: `glm-5.3[1m]`.
|
|
1874
|
+
if (b.modelLabel) legend.push(`${b.modelLabel.split("/").pop()}${b.contextWindow > 0 ? `[${k(b.contextWindow)}]` : ""}`);
|
|
1875
|
+
legend.push(`${k(used)}/${k(b.contextWindow)} tokens (${formatCtxPercent(used, b.contextWindow)})`);
|
|
1876
|
+
legend.push("");
|
|
1877
|
+
legend.push("Estimated usage by category");
|
|
1828
1878
|
for (const c of b.categories) {
|
|
1829
|
-
|
|
1879
|
+
legend.push(`${c.glyph} ${c.label}: ${k(c.tokens)} token${c.tokens === 1 ? "" : "s"}${pct(c.tokens)}`);
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
const bodyLines = Math.max(CTX_GRID_ROWS, legend.length);
|
|
1883
|
+
const blankGrid = " ".repeat(gridRows[0]?.length ?? 0);
|
|
1884
|
+
for (let r = 0; r < bodyLines; r++) {
|
|
1885
|
+
const g = r < gridRows.length ? gridRows[r] : blankGrid;
|
|
1886
|
+
const l = legend[r] ?? "";
|
|
1887
|
+
lines.push(l.length > 0 ? `${g}${CTX_GUTTER}${l}` : g);
|
|
1830
1888
|
}
|
|
1889
|
+
lines.push("");
|
|
1890
|
+
|
|
1891
|
+
// The autocompact row lives in the legend; a disabled compaction still needs its note.
|
|
1831
1892
|
if (b.compactionDisabled) lines.push(" ⛶ Autocompact buffer: disabled (compaction.enabled=false)");
|
|
1832
1893
|
|
|
1833
1894
|
// ── Detail: system-prompt sections, top tools, per-package attribution ──
|
|
@@ -1980,21 +2041,76 @@ export default function (pi: ExtensionAPI) {
|
|
|
1980
2041
|
|
|
1981
2042
|
// Transcript renderer for /context: pi renders this inline in the scrollback
|
|
1982
2043
|
// (above the editor), like OMP's panel, instead of a dismissable overlay. The
|
|
1983
|
-
// renderer receives the live theme, so
|
|
1984
|
-
// and the panel stays visible while you keep working.
|
|
2044
|
+
// renderer receives the live theme, so grid cells and legend runs keep their
|
|
2045
|
+
// category colors and the panel stays visible while you keep working.
|
|
2046
|
+
// v2 details carry the structured grid + legend as PLAIN data (colors applied
|
|
2047
|
+
// here, at render time — the theme can change between send and render);
|
|
2048
|
+
// legacy entries stored `details.lines` keep the glyph-tint path.
|
|
1985
2049
|
// Optional-call guard: matches pi-a2a/pi-subagent/pi-advisor, and keeps older
|
|
1986
2050
|
// SDK builds (and minimal test harnesses) loadable.
|
|
1987
|
-
pi.registerMessageRenderer?.<{ lines
|
|
2051
|
+
pi.registerMessageRenderer?.<{ grid?: CtxCell[][]; legend?: CtxLegendPart[][]; lines?: string[] }>(MESSAGE_TYPE_CONTEXT, (message, _opts, theme) => {
|
|
1988
2052
|
try {
|
|
1989
2053
|
const fg = theme?.fg ? (c: string, s: string) => theme.fg(c as never, s) : (s: string) => s;
|
|
1990
|
-
const
|
|
1991
|
-
|
|
2054
|
+
const bold = theme?.bold ? (s: string) => theme.bold(s) : (s: string) => s;
|
|
2055
|
+
const details = message.details as { grid?: CtxCell[][]; legend?: CtxLegendPart[][]; lines?: string[] } | undefined;
|
|
2056
|
+
const ANSI_RE = /\u001b\[[0-9;]*m/g;
|
|
2057
|
+
const visibleWidth = (s: string) => [...s.replace(ANSI_RE, "")].length;
|
|
1992
2058
|
const clamp = (line: string, width: number) => {
|
|
1993
|
-
if (width <= 0 ||
|
|
2059
|
+
if (width <= 0 || visibleWidth(line) <= width) return line;
|
|
1994
2060
|
// Ellipsis rather than a mid-word slice — this is a display clamp, not data loss.
|
|
1995
|
-
const chars = [...line];
|
|
1996
|
-
return chars.
|
|
2061
|
+
const chars = [...line.replace(ANSI_RE, "")];
|
|
2062
|
+
return chars.slice(0, Math.max(0, width - 1)).join("") + "…";
|
|
1997
2063
|
};
|
|
2064
|
+
if (details?.grid && details?.legend) {
|
|
2065
|
+
// v2: assemble rows as spans (plain text + style), clamp by VISIBLE
|
|
2066
|
+
// width, and only then paint — the ANSI form's codepoint count is
|
|
2067
|
+
// ~12× the visible width and would shred the grid at real widths.
|
|
2068
|
+
// Cells join with a space like OMP's grid (20 cells → 39 columns).
|
|
2069
|
+
const gridSpans = details.grid.map((row) =>
|
|
2070
|
+
row.flatMap((c, i) => {
|
|
2071
|
+
const cell = { t: c.glyph, s: c.color as string };
|
|
2072
|
+
return i === 0 ? [cell] : [{ t: " ", s: "" }, cell];
|
|
2073
|
+
}),
|
|
2074
|
+
);
|
|
2075
|
+
const blankSpans = details.grid[0]?.length
|
|
2076
|
+
? Array.from({ length: details.grid[0].length * 2 - 1 }, () => ({ t: " ", s: "" }))
|
|
2077
|
+
: [];
|
|
2078
|
+
const bodyLines = Math.max(details.grid.length, details.legend.length);
|
|
2079
|
+
return {
|
|
2080
|
+
render: (width: number) =>
|
|
2081
|
+
Array.from({ length: bodyLines }, (_, r) => {
|
|
2082
|
+
const g = r < gridSpans.length ? gridSpans[r] : blankSpans;
|
|
2083
|
+
const l = details.legend![r] ?? [];
|
|
2084
|
+
// Gutter (3 spaces) rides only when a legend line follows.
|
|
2085
|
+
const gutter: Array<{ t: string; s: string }> = l.length > 0 ? [{ t: CTX_GUTTER, s: "" }] : [];
|
|
2086
|
+
const spans = [...g, ...gutter, ...l.map((p) => ({ t: p.t, s: (p.s ?? "") as string }))];
|
|
2087
|
+
// Emit spans up to the VISIBLE budget; ellipsize the span that
|
|
2088
|
+
// crosses it. Painting happens per span, so escape codes never
|
|
2089
|
+
// inflate the measure.
|
|
2090
|
+
let budget = Math.max(0, width);
|
|
2091
|
+
let out = "";
|
|
2092
|
+
let lastStyle: string | undefined;
|
|
2093
|
+
for (const sp of spans) {
|
|
2094
|
+
if (budget <= 0) break;
|
|
2095
|
+
let t = sp.t;
|
|
2096
|
+
if (visibleWidth(t) > budget) {
|
|
2097
|
+
t = [...t].slice(0, Math.max(0, budget - 1)).join("") + "…";
|
|
2098
|
+
}
|
|
2099
|
+
if (sp.s !== lastStyle) {
|
|
2100
|
+
lastStyle = sp.s;
|
|
2101
|
+
out += sp.s === "strong" ? bold(t) : sp.s ? fg(sp.s as never, t) : t;
|
|
2102
|
+
} else {
|
|
2103
|
+
out += t;
|
|
2104
|
+
}
|
|
2105
|
+
budget -= visibleWidth(t);
|
|
2106
|
+
}
|
|
2107
|
+
return out;
|
|
2108
|
+
}),
|
|
2109
|
+
invalidate: () => {},
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
const body = details?.lines
|
|
2113
|
+
?? (typeof message.content === "string" ? message.content.split("\n") : []);
|
|
1998
2114
|
return {
|
|
1999
2115
|
render: (width: number) => body.map((l) => clamp(l, width)).map((line) => {
|
|
2000
2116
|
// Tint the category glyph; keep the numeric body plain for contrast.
|
|
@@ -2017,10 +2133,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
2017
2133
|
// contexts (ExtensionCommandContext) do not expose them.
|
|
2018
2134
|
const b = computeContextBreakdown({ ctx, allTools: pi.getAllTools(), activeTools: pi.getActiveTools(), model: ctx.model as ContextBreakdownInput["model"], settings: readCompactionSettings() });
|
|
2019
2135
|
const lines = renderContextPanel(b);
|
|
2136
|
+
// Structured v2 details: grid cells + legend runs as plain data — the
|
|
2137
|
+
// transcript renderer applies the live theme (which may differ at replay).
|
|
2138
|
+
const legend = buildCtxLegend(b);
|
|
2139
|
+
const grid: CtxCell[][] = [];
|
|
2140
|
+
const cells = planCtxCells(b.categories, b.contextWindow);
|
|
2141
|
+
for (let r = 0; r < cells.length; r += CTX_GRID_COLS) grid.push(cells.slice(r, r + CTX_GRID_COLS));
|
|
2020
2142
|
// display:true → shown in the transcript (above the editor, like OMP).
|
|
2021
2143
|
// `content` is the plain-text fallback for renderer-less builds and
|
|
2022
|
-
// non-TUI modes; `details
|
|
2023
|
-
pi.sendMessage({ customType: MESSAGE_TYPE_CONTEXT, content: lines.join("\n"), display: true, details: { lines } });
|
|
2144
|
+
// non-TUI modes; `details` feeds the themed transcript renderer.
|
|
2145
|
+
pi.sendMessage({ customType: MESSAGE_TYPE_CONTEXT, content: lines.join("\n"), display: true, details: { grid, legend, lines } });
|
|
2024
2146
|
},
|
|
2025
2147
|
});
|
|
2026
2148
|
|