@gorlitzer-labs/seldon 0.21.0 → 0.22.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/bin/seldon.js +37 -18
- package/lib/workspace.mjs +11 -0
- package/package.json +1 -1
package/bin/seldon.js
CHANGED
|
@@ -17,7 +17,7 @@ import { notify } from "../lib/notify.mjs";
|
|
|
17
17
|
import { sendCard, watchCard, KINDS, tokenName, readChat, writeChat, chatFromUpdates, getUpdates, sendText, sendFile, pollUpdates, fileFromMessage, inboxName, freeName, noteLine, downloadFile, react, MAX_DOWNLOAD } from "../lib/telegram.mjs";
|
|
18
18
|
import { reportFromEvent, mergeCodexHooks, removeCodexHooks, opencodePlugin } from "../lib/reports.mjs";
|
|
19
19
|
import { buildRows, headline, ago, laneDetail, unlistedAgents, GLYPH } from "../lib/home.mjs";
|
|
20
|
-
import { WS_SOCKET, WS_SESSION, NARROW, SIDE_WIDTH, assignEmoji, wsRows, nextNeeding, findRow, paneCommand, setupCommands, rowCells, wsHeadline } from "../lib/workspace.mjs";
|
|
20
|
+
import { tooSmall, WS_SOCKET, WS_SESSION, NARROW, SIDE_WIDTH, assignEmoji, wsRows, nextNeeding, findRow, paneCommand, setupCommands, rowCells, wsHeadline } from "../lib/workspace.mjs";
|
|
21
21
|
import { parseDuration, describe as describeHold, NAME_RE, DEFAULT_FOR_MS } from "../lib/holds.mjs";
|
|
22
22
|
import { tryHold, release as releaseHold, listHolds, findOwner } from "../lib/holds-store.mjs";
|
|
23
23
|
|
|
@@ -870,13 +870,16 @@ const KEYS = { escapeCodeTimeout: 50 };
|
|
|
870
870
|
// `onError` gets anything a key handler throws — shown, never swallowed.
|
|
871
871
|
function rawSession({ draw, onKey, onError }) {
|
|
872
872
|
let done = null;
|
|
873
|
+
process.once("exit", () => process.stdout.write("\x1b[?25h"));
|
|
873
874
|
const listen = () => {
|
|
875
|
+
process.stdout.write("\x1b[?25l"); // no stray cursor blinking after the hints
|
|
874
876
|
readline.emitKeypressEvents(process.stdin, KEYS);
|
|
875
877
|
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
876
878
|
process.stdin.resume();
|
|
877
879
|
process.stdin.on("keypress", handler);
|
|
878
880
|
};
|
|
879
881
|
const release = () => {
|
|
882
|
+
process.stdout.write("\x1b[?25h");
|
|
880
883
|
process.stdin.off("keypress", handler);
|
|
881
884
|
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
882
885
|
process.stdin.pause();
|
|
@@ -948,6 +951,7 @@ async function panel({ newFor = null } = {}) {
|
|
|
948
951
|
// Below 70 columns (a phone over ssh) a lane is one short line: glyph, name, the state in a
|
|
949
952
|
// word. The full detail is one ⏎ away.
|
|
950
953
|
const narrow = () => (process.stdout.columns || 100) < 70;
|
|
954
|
+
let foot = [];
|
|
951
955
|
const laneCells = (l, sel) => {
|
|
952
956
|
const color = tint[l.state] || ((x) => x);
|
|
953
957
|
const name = (l.name || l.id || "?");
|
|
@@ -972,22 +976,21 @@ async function panel({ newFor = null } = {}) {
|
|
|
972
976
|
const plan = p.hive ? C.dim(`plan ${p.hive.queueOpen} · ${p.hive.done} done`) : "";
|
|
973
977
|
const why = p.hive?.needsYou && p.hive.why ? C.gold(" ⚑ " + p.hive.why) : "";
|
|
974
978
|
const others = unlistedAgents(p);
|
|
975
|
-
|
|
976
|
-
|
|
979
|
+
// padded to where the lanes' agent column starts, so plan · harness line up
|
|
980
|
+
out.push(` ${cursor} ${pad(p.name, 30, C.bold)} ${plan}${others.length ? C.green(" agents: " + others.join(", ")) : ""}${why}`);
|
|
977
981
|
} else {
|
|
978
982
|
out.push(` ${cursor} ${laneCells(r.lane, sel)}`);
|
|
979
983
|
if (sel && r.lane.cwd !== r.project.root && !narrow()) out.push(` ${C.dim(r.lane.cwd)}`);
|
|
980
984
|
}
|
|
981
985
|
});
|
|
982
986
|
const sel = rows[cur];
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
? "
|
|
988
|
-
: "
|
|
989
|
-
|
|
990
|
-
}
|
|
987
|
+
const hint = (k, w) => C.bold(k) + " " + C.dim(w);
|
|
988
|
+
foot = narrow()
|
|
989
|
+
? [sel?.type === "lane" ? [hint("⏎", "open"), hint("xx", "stop"), hint("q", "quit")] : [hint("n", "new"), hint("p", "plan"), hint("q", "quit")]]
|
|
990
|
+
: [sel?.type === "lane"
|
|
991
|
+
? [hint("⏎", "open"), hint("n", "new agent"), hint("xx", "stop"), hint("R", "resume"), hint("p", "plan"), hint("q", "quit")]
|
|
992
|
+
: [hint("n", "new agent"), hint("p", "plan"), hint("⏎", "go"), hint("s", "staff"), hint("b", "board"), hint("q", "quit")]];
|
|
993
|
+
foot = foot.map((hs) => " " + hs.join(" "));
|
|
991
994
|
};
|
|
992
995
|
|
|
993
996
|
const drawPlan = (out) => {
|
|
@@ -1024,6 +1027,9 @@ async function panel({ newFor = null } = {}) {
|
|
|
1024
1027
|
};
|
|
1025
1028
|
|
|
1026
1029
|
const draw = () => {
|
|
1030
|
+
const small = tooSmall(process.stdout.columns, process.stdout.rows);
|
|
1031
|
+
if (small) { clearScreen(); process.stdout.write(small.map((l, i) => (i === small.length - 3 ? C.gold(l) : C.dim(l))).join("\n")); return; }
|
|
1032
|
+
foot = [];
|
|
1027
1033
|
const out = [""];
|
|
1028
1034
|
out.push(" " + C.gold(C.bold("SELDON")) + " " + headline(groups) + " " + C.dim([
|
|
1029
1035
|
svc("watcher", !!daemonUp("seldon-watch")), svc("voice", !!daemonUp("demerzel")),
|
|
@@ -1036,9 +1042,13 @@ async function panel({ newFor = null } = {}) {
|
|
|
1036
1042
|
if (hs.length) out.push(" " + C.dim("held: ") + hs.map((h) => `${C.bold(h.resource)} ${C.dim("→ " + h.who + " " + ago(h.since))}`).join(C.dim(" ")));
|
|
1037
1043
|
out.push("");
|
|
1038
1044
|
({ home: drawHome, plan: drawPlan, input: drawInput, harness: drawHarness })[mode.name](out);
|
|
1039
|
-
if (note) out.push("
|
|
1045
|
+
if (note) out.push("", " " + note);
|
|
1046
|
+
// the hints live on the bottom rows, under a rule, like the workspace list
|
|
1047
|
+
const height = process.stdout.rows || 40, cols = process.stdout.columns || 100;
|
|
1048
|
+
const bottom = foot.length ? [C.dim(" " + "─".repeat(Math.max(4, cols - 4))), ...foot] : [];
|
|
1049
|
+
const fill = Math.max(1, height - out.length - bottom.length);
|
|
1040
1050
|
clearScreen();
|
|
1041
|
-
process.stdout.write(out.
|
|
1051
|
+
process.stdout.write([...out, ...Array(fill).fill(""), ...bottom].join("\n"));
|
|
1042
1052
|
};
|
|
1043
1053
|
|
|
1044
1054
|
load(true);
|
|
@@ -1616,14 +1626,22 @@ async function wsSidebar() {
|
|
|
1616
1626
|
const tint = TINT;
|
|
1617
1627
|
const draw = () => {
|
|
1618
1628
|
const width = process.stdout.columns || 38, height = process.stdout.rows || 40;
|
|
1629
|
+
const small = tooSmall(process.stdout.columns, process.stdout.rows);
|
|
1630
|
+
if (small) { clearScreen(); process.stdout.write(small.map((l, i) => (i === small.length - 3 ? C.gold(l) : C.dim(l))).join("\n")); return; }
|
|
1619
1631
|
const open = wsCurrent(), h = wsHeadline(rows);
|
|
1620
|
-
|
|
1621
|
-
|
|
1632
|
+
// Header: name on the left, the two counts that matter right-aligned. A rule under it and
|
|
1633
|
+
// above the hints, which sit on the bottom rows whatever the list's length.
|
|
1634
|
+
const counts = `⚑ ${h.need} ● ${h.busy}`;
|
|
1635
|
+
const rule = C.dim(" " + "─".repeat(Math.max(4, width - 2)));
|
|
1636
|
+
const head = [` ${C.bold("SELDON")}${" ".repeat(Math.max(1, width - 8 - counts.length))}${h.need ? C.gold(`⚑ ${h.need}`) : C.dim("⚑ 0")} ${C.green(`● ${h.busy}`)}`, rule];
|
|
1637
|
+
const hint = (k, w) => C.bold(k) + " " + C.dim(w);
|
|
1638
|
+
const foot = [rule, " " + [hint("⏎", "open"), hint("n", "new"), hint("⇥", "next ⚑")].join(" "),
|
|
1639
|
+
" " + [hint("h", "home"), hint("q", "leave"), hint("⌥1-9", "jump")].join(" "), ...(note ? [" " + note] : [])];
|
|
1622
1640
|
const body = []; let curLine = 0, last = null;
|
|
1623
|
-
if (!rows.length) body.push(C.dim(" no agents
|
|
1641
|
+
if (!rows.length) body.push("", C.dim(" no agents yet"), " " + C.bold("n") + C.dim(" starts one"));
|
|
1624
1642
|
const faces = assignEmoji(rows.map((r) => r.name));
|
|
1625
1643
|
rows.forEach((r, i) => {
|
|
1626
|
-
if (r.project !== last) {
|
|
1644
|
+
if (r.project !== last) { body.push(" " + C.dim(C.bold(r.project.toUpperCase().slice(0, width - 2)))); last = r.project; }
|
|
1627
1645
|
const c = rowCells(r, width, ago, faces.get(r.name)), color = tint[c.state] || ((x) => x);
|
|
1628
1646
|
const mark = i === cur ? C.gold("❯") : r.key === open ? C.cyan("▸") : " ";
|
|
1629
1647
|
if (i === cur) curLine = body.length;
|
|
@@ -1632,8 +1650,9 @@ async function wsSidebar() {
|
|
|
1632
1650
|
});
|
|
1633
1651
|
const room = Math.max(2, height - head.length - foot.length);
|
|
1634
1652
|
const from = Math.max(0, Math.min(curLine - Math.floor(room / 2), body.length - room));
|
|
1653
|
+
const shown = body.slice(from, from + room);
|
|
1635
1654
|
clearScreen();
|
|
1636
|
-
process.stdout.write([...head, ...
|
|
1655
|
+
process.stdout.write([...head, ...shown, ...Array(room - shown.length).fill(""), ...foot].join("\n"));
|
|
1637
1656
|
};
|
|
1638
1657
|
const openRow = (r) => { if (r) { wsOpen(wsReadRows().find((x) => x.key === r.key) || r); note = ""; } };
|
|
1639
1658
|
load();
|
package/lib/workspace.mjs
CHANGED
|
@@ -173,3 +173,14 @@ export function wsHeadline(rows) {
|
|
|
173
173
|
const busy = live.filter((r) => r.state === "working" || r.state === "running").length;
|
|
174
174
|
return { need, busy, total: rows.length };
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
// ---- too small ---------------------------------------------------------------------
|
|
178
|
+
// Below this a list row no longer fits on one line and the footer pushes the agents off
|
|
179
|
+
// screen. Like btop: say so, centred, instead of drawing a broken screen.
|
|
180
|
+
export const MIN_COLS = 30, MIN_ROWS = 10; // the list pane is 38 wide: it must fit
|
|
181
|
+
export function tooSmall(cols, rows, min = { cols: MIN_COLS, rows: MIN_ROWS }) {
|
|
182
|
+
if (!cols || !rows || (cols >= min.cols && rows >= min.rows)) return null;
|
|
183
|
+
const lines = ["terminal too small", `${cols}×${rows} · needs ${min.cols}×${min.rows}`, "make the window bigger"];
|
|
184
|
+
const top = Math.max(0, Math.floor((rows - lines.length) / 2));
|
|
185
|
+
return [...Array(top).fill(""), ...lines.map((l) => " ".repeat(Math.max(0, Math.floor((cols - l.length) / 2))) + l)];
|
|
186
|
+
}
|