Official
chat
Built-in chat UI (JavaScript UI plugin).
The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/chat@0.2.7
Permissions in 0.2.7
Files
terminal.tsx3.2 KB
// A read-only log view for captured terminal bytes. The shell terminal node
// requires a kernel-owned PTY, so captured output uses monospace ANSI runs.
import type { Element } from "divergence";
type Run = { text: string; color?: string; background?: string; bold?: boolean };
const palette = ["faint", "danger", "success", "warning", "info", "primary", "info", "foreground"];
const hex = (n: number) => Math.max(0, Math.min(255, n)).toString(16).padStart(2, "0");
function indexed(n: number): string | undefined {
if (n < 16) return palette[n % 8];
if (n >= 232) return `#${hex(8 + (n - 232) * 10).repeat(3)}`;
const v = n - 16,
channel = (i: number) => (i ? 55 + i * 40 : 0);
return `#${[Math.floor(v / 36), Math.floor(v / 6) % 6, v % 6].map((i) => hex(channel(i))).join("")}`;
}
export function ansiLines(output: string): Run[][] {
const lines: Run[][] = [[]];
let style: Omit<Run, "text"> = {};
const tokens = output.match(/\x1b\][\s\S]*?(?:\x07|\x1b\\)|\x1b\[[0-?]*[ -/]*[@-~]|[^\x1b]+/g) ?? [];
for (const token of tokens) {
if (token.startsWith("\x1b")) {
if (!token.startsWith("\x1b[") || !token.endsWith("m")) continue;
const codes = token.slice(2, -1).split(";").map(Number);
for (let i = 0; i < codes.length; i++) {
const c = codes[i]!;
if (c === 0) style = {};
else if (c === 1 || c === 22) style.bold = c === 1;
else if (c === 39) delete style.color;
else if (c === 49) delete style.background;
else if ((c >= 30 && c <= 37) || (c >= 90 && c <= 97)) style.color = palette[c % 10];
else if ((c >= 40 && c <= 47) || (c >= 100 && c <= 107)) style.background = palette[c % 10];
else if (c === 38 || c === 48) {
const key = c === 38 ? "color" : "background";
if (codes[i + 1] === 5 && codes[i + 2] !== undefined) {
style[key] = indexed(codes[i + 2]!);
i += 2;
} else if (codes[i + 1] === 2 && codes[i + 4] !== undefined) {
style[key] = `#${codes
.slice(i + 2, i + 5)
.map(hex)
.join("")}`;
i += 4;
}
}
}
continue;
}
for (const piece of token.split(/(\r\n|\n|\r)/)) {
if (piece === "\n" || piece === "\r\n") lines.push([]);
else if (piece === "\r") lines[lines.length - 1] = [];
else if (piece) lines[lines.length - 1]!.push({ text: piece.replace(/\x08/g, ""), ...style });
}
}
return lines;
}
// Each line wraps at the pane's edge, as a terminal's lines do. A line in
// one style is one text that wraps as a whole; a line of several styles
// wraps between its runs, and a run too long for the line wraps in place.
export function terminalOutput(output: string): Element[] {
return ansiLines(output).map((line) => {
if (!line.length) return <text style="mono" text={" "} />;
const runs = line.map((run) => {
const text = <text style="mono" color={run.color} bold={run.bold} text={run.text} />;
return run.background ? <div background={run.background} minWidth={0}>{text}</div> : text;
});
return runs.length === 1 && !line[0]!.background
? runs[0]!
: <div flexDirection="row" flexWrap="wrap" alignItems="start" minWidth={0}>{runs}</div>;
});
}Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.9latest | Nov 21, 2026 | >=5 <6 | 349 KB | 5 permissions | Listed |
| 0.2.8 | Nov 16, 2026 | >=5 <6 | 348.6 KB | 5 permissions | Listed |
| 0.2.7 | Nov 11, 2026 | >=5 <6 | 314.3 KB | 5 permissions | Listed |
| 0.2.6 | Nov 9, 2026 | >=5 <6 | 306.2 KB | 5 permissions | Listed |
| 0.2.5 | Oct 27, 2026 | >=2 <4 | 178.6 KB | 5 permissions | Listed |
No comments yet.