@gorlitzer-labs/seldon 0.20.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/README.md CHANGED
@@ -48,6 +48,8 @@ Every agent, on every machine, beside the one you're talking to. One key to swit
48
48
  | `Alt-h` | home: the full panel on the right |
49
49
  | `Alt-q` | leave. Agents keep running |
50
50
 
51
+ In the list: `n` **new agent** (type the task, pick 1 claude · 2 codex · 3 opencode), `⏎` open, `tab` next ⚑.
52
+
51
53
  - **Real terminals.** The right side is the agent itself, not a copy.
52
54
  - **Switching never stops anything.** Leave, reconnect from anywhere, it's all still there.
53
55
  - **Both laptops, one list.** Agents on `seldon machines` open over ssh in the same pane. A sleeping one shows ☾ and waits.
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();
@@ -908,7 +911,7 @@ const pad = (text, width, color = (x) => x) => color(String(text)) + " ".repeat(
908
911
  // grouped by the project it works on, the ones waiting on you first. Lanes are read from the
909
912
  // harnesses themselves (lib/agents.mjs), not from rooms, so the panel works with or without
910
913
  // factory and apiary; when factory is there its projects and plans are shown too.
911
- async function panel() {
914
+ async function panel({ newFor = null } = {}) {
912
915
  ensureSiblingPath();
913
916
  let groups = [], state = null, rows = [], cur = 0, note = "";
914
917
  let lastState = 0;
@@ -948,6 +951,7 @@ async function panel() {
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() {
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
- out.push(` ${cursor} ${pad(p.name, 22, C.bold)} ${plan}${others.length ? C.green(" agents: " + others.join(", ")) : ""}${why}`);
976
- if (sel && !narrow()) out.push(` ${C.dim(p.root)}`);
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
- out.push("");
984
- if (narrow()) out.push(" " + C.dim(sel?.type === "lane" ? "⏎ open · x stop · R resume · q" : "n lane · p plan · ⏎ go · q"));
985
- else {
986
- out.push(" " + C.dim(sel?.type === "lane"
987
- ? "↑↓ move · ⏎ open · x stop · R resume · n new lane · p plan · r refresh · q quit"
988
- : "↑↓ move · n new lane · p plan · ⏎ go (staff + room) · s staff · a room · b board · q quit"));
989
- out.push(" " + C.dim("U start stack · D stop stack · i install"));
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() {
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() {
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("\n " + note);
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.join("\n") + "\n");
1051
+ process.stdout.write([...out, ...Array(fill).fill(""), ...bottom].join("\n"));
1042
1052
  };
1043
1053
 
1044
1054
  load(true);
@@ -1158,6 +1168,14 @@ async function panel() {
1158
1168
  },
1159
1169
  };
1160
1170
 
1171
+ // Opened by the workspace's n: go straight to "new agent" for the project of the agent that
1172
+ // was selected there (or the repo seldon runs in), so starting one is one key from the list.
1173
+ if (newFor !== null) {
1174
+ const projects = rows.filter((r) => r.type === "project").map((r) => r.project);
1175
+ const p = projects.find((x) => (x.lanes || []).some((l) => l.key === newFor)) || projects.find((x) => sameDir(x.root, here)) || projects[0];
1176
+ if (p) ask(`NEW AGENT · ${p.name}`, "task ›", (task) => pickHarness(p, task));
1177
+ }
1178
+
1161
1179
  await rawSession({
1162
1180
  draw,
1163
1181
  onError: (e) => { note = C.red("error: ") + (e?.message || String(e)); mode = { name: "home" }; },
@@ -1570,6 +1588,14 @@ function wsOpen(row) {
1570
1588
  wsSave(WS_CURRENT, row.off ? "" : row.key);
1571
1589
  wsFocus(main);
1572
1590
  }
1591
+ // n in the list: the panel, on the right, already asking for the new agent's task.
1592
+ function wsNewAgent(row) {
1593
+ const main = wsOpt("@main");
1594
+ const argv = ["panel", "--new", ...(row && !row.off ? ["--for", row.key] : [])].map(shq).join(" ");
1595
+ wsTmux(["respawn-pane", "-k", "-t", main, `sh -c ${shq(`${wsSelf()} ${argv}; exec ${wsHome()}`)}`]);
1596
+ wsSave(WS_CURRENT, "");
1597
+ wsFocus(main);
1598
+ }
1573
1599
  function wsGoHome() {
1574
1600
  const main = wsOpt("@main");
1575
1601
  wsTmux(["respawn-pane", "-k", "-t", main, wsHome()]);
@@ -1600,14 +1626,22 @@ async function wsSidebar() {
1600
1626
  const tint = TINT;
1601
1627
  const draw = () => {
1602
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; }
1603
1631
  const open = wsCurrent(), h = wsHeadline(rows);
1604
- const head = [` ${C.bold("SELDON")} ${h.need ? C.gold(`⚑ ${h.need}`) : C.dim("⚑ 0")} ${C.green(`● ${h.busy}`)}`, ""];
1605
- const foot = ["", C.dim(" ⏎ open · n next ⚑ · h home"), C.dim(" Alt-1…9 from any pane · q leave"), ...(note ? [" " + note] : [])];
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] : [])];
1606
1640
  const body = []; let curLine = 0, last = null;
1607
- if (!rows.length) body.push(C.dim(" no agents running"), C.dim(" h, then n starts one"));
1641
+ if (!rows.length) body.push("", C.dim(" no agents yet"), " " + C.bold("n") + C.dim(" starts one"));
1608
1642
  const faces = assignEmoji(rows.map((r) => r.name));
1609
1643
  rows.forEach((r, i) => {
1610
- if (r.project !== last) { if (last !== null) body.push(""); body.push(" " + C.dim(r.project.slice(0, width - 2))); last = r.project; }
1644
+ if (r.project !== last) { body.push(" " + C.dim(C.bold(r.project.toUpperCase().slice(0, width - 2)))); last = r.project; }
1611
1645
  const c = rowCells(r, width, ago, faces.get(r.name)), color = tint[c.state] || ((x) => x);
1612
1646
  const mark = i === cur ? C.gold("❯") : r.key === open ? C.cyan("▸") : " ";
1613
1647
  if (i === cur) curLine = body.length;
@@ -1616,8 +1650,9 @@ async function wsSidebar() {
1616
1650
  });
1617
1651
  const room = Math.max(2, height - head.length - foot.length);
1618
1652
  const from = Math.max(0, Math.min(curLine - Math.floor(room / 2), body.length - room));
1653
+ const shown = body.slice(from, from + room);
1619
1654
  clearScreen();
1620
- process.stdout.write([...head, ...body.slice(from, from + room), ...foot].join("\n"));
1655
+ process.stdout.write([...head, ...shown, ...Array(room - shown.length).fill(""), ...foot].join("\n"));
1621
1656
  };
1622
1657
  const openRow = (r) => { if (r) { wsOpen(wsReadRows().find((x) => x.key === r.key) || r); note = ""; } };
1623
1658
  load();
@@ -1631,7 +1666,8 @@ async function wsSidebar() {
1631
1666
  else if (key?.name === "down" || str === "j") cur = Math.min(rows.length - 1, cur + 1);
1632
1667
  else if (key?.name === "return") openRow(rows[cur]);
1633
1668
  else if (/^[1-9]$/.test(str || "")) openRow(findRow(rows, str));
1634
- else if (str === "n") { const r = nextNeeding(rows, wsCurrent()); if (r) openRow(r); else note = C.dim("nobody is waiting on you"); }
1669
+ else if (str === "n") wsNewAgent(rows[cur]);
1670
+ else if (key?.name === "tab") { const r = nextNeeding(rows, wsCurrent()); if (r) openRow(r); else note = C.dim("nobody is waiting on you"); }
1635
1671
  else if (str === "h") wsGoHome();
1636
1672
  else if (str === "r") load();
1637
1673
  else if (str === "q" || (key?.ctrl && key.name === "c")) wsTmux(["detach-client"]);
@@ -1983,7 +2019,7 @@ const ids = tokens.filter((id) => byId[id]); // only the valid module
1983
2019
  if (cmd === "tell") return tellCmd(tokens, flags);
1984
2020
  if (cmd === "inbox") return inboxCmd(flags);
1985
2021
  if (cmd === "setup") return setupCmd(tokens[0], flags);
1986
- if (cmd === "panel") return panel();
2022
+ if (cmd === "panel") return panel({ newFor: flags.new ? (typeof flags.for === "string" ? flags.for : "") : null });
1987
2023
  if (cmd && cmd !== "install") { help(); process.exitCode = 1; return; }
1988
2024
  if (cmd === "install") return install_picker({ dev }); // `install` with no ids
1989
2025
 
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gorlitzer-labs/seldon",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "Install the Seldon stack — pick your tools from a checklist; each installs via its native method.",
5
5
  "type": "module",
6
6
  "bin": {