agent-coord-mcp 0.4.5 → 0.4.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/package.json +1 -1
- package/scripts/coord-chat.mjs +42 -6
package/package.json
CHANGED
package/scripts/coord-chat.mjs
CHANGED
|
@@ -670,13 +670,49 @@ function printMsg(kind, m, opts = {}) {
|
|
|
670
670
|
const tag = kind === "DM" ? A.bold(A.cyan("DM")) : A.dim("room");
|
|
671
671
|
const nick = A.bold(color(who));
|
|
672
672
|
const meta = `${A.dim(t)} ${tag} ${nick}`;
|
|
673
|
-
const body = (m.text ?? "").split("\n").map(formatBody);
|
|
674
|
-
const indent = " ";
|
|
675
|
-
const first = body[0] ?? "";
|
|
676
|
-
const rest = body.slice(1).map((l) => `${gutter} ${indent}${A.dim("│ ")}${l}`);
|
|
677
673
|
const prefix = opts.history ? A.dim(" ") : "";
|
|
678
|
-
|
|
679
|
-
|
|
674
|
+
|
|
675
|
+
// Visible widths: prefix + "▎ " + meta + " " on the first line;
|
|
676
|
+
// prefix + "▎ " on continuation lines. We wrap manually so the
|
|
677
|
+
// colored gutter prepends every wrapped line — terminal auto-wrap
|
|
678
|
+
// would lose it.
|
|
679
|
+
const prefixW = visibleLength(prefix);
|
|
680
|
+
const firstChrome = prefixW + visibleLength(`▎ ${meta} `);
|
|
681
|
+
const restChrome = prefixW + visibleLength(`▎ `);
|
|
682
|
+
const firstWidth = Math.max(20, COLS - firstChrome);
|
|
683
|
+
const restWidth = Math.max(20, COLS - restChrome);
|
|
684
|
+
|
|
685
|
+
const text = (m.text ?? "").split("\n").map(formatBody).join("\n");
|
|
686
|
+
const lines = wrapText(text, firstWidth, restWidth);
|
|
687
|
+
say(`${prefix}${gutter} ${meta} ${lines[0] ?? ""}`);
|
|
688
|
+
for (const line of lines.slice(1)) say(`${prefix}${gutter} ${line}`);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
function visibleLength(s) {
|
|
692
|
+
// Strip ANSI SGR sequences so we measure on-screen width, not raw bytes.
|
|
693
|
+
return s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function wrapText(text, firstWidth, restWidth) {
|
|
697
|
+
if (firstWidth <= 0 || restWidth <= 0) return [text];
|
|
698
|
+
const out = [];
|
|
699
|
+
for (const para of text.split("\n")) {
|
|
700
|
+
const words = para.split(" ");
|
|
701
|
+
let line = "";
|
|
702
|
+
let currentWidth = out.length === 0 ? firstWidth : restWidth;
|
|
703
|
+
for (const word of words) {
|
|
704
|
+
const proposed = line ? line + " " + word : word;
|
|
705
|
+
if (visibleLength(proposed) > currentWidth && line) {
|
|
706
|
+
out.push(line);
|
|
707
|
+
line = word;
|
|
708
|
+
currentWidth = restWidth;
|
|
709
|
+
} else {
|
|
710
|
+
line = proposed;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (line || words.length === 0) out.push(line);
|
|
714
|
+
}
|
|
715
|
+
return out;
|
|
680
716
|
}
|
|
681
717
|
|
|
682
718
|
// Lightweight inline-only "chat markdown" formatter — no dep. Handles bold,
|