@awebai/oats 0.59.0 → 0.60.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/docs/desktop-cli-api.md +12 -5
- package/docs/execution-targets.md +7 -2
- package/docs/implementation.md +1 -0
- package/docs/integrations.md +1 -1
- package/docs/official-catalog.md +2 -2
- package/docs/packages.md +7 -7
- package/docs/release-notes/v0.60.0.md +104 -0
- package/docs/tui.md +123 -15
- package/docs/workspaces.md +1 -1
- package/lib/core.mjs +42 -15
- package/lib/session-input.mjs +45 -28
- package/package-catalog.json +2 -2
- package/package.json +1 -1
- package/packages/client/capability-catalog.mjs +93 -0
- package/packages/client/capability-facts.mjs +59 -0
- package/packages/client/capability-rows.mjs +121 -0
- package/packages/client/catalog-messages.mjs +12 -0
- package/packages/client/cli-locator.mjs +2 -2
- package/packages/client/soul-catalog.mjs +8 -0
- package/packages/client/soul-facts.mjs +7 -0
- package/packages/client/spawn-messages.mjs +8 -0
- package/packages/client/subsequence-score.mjs +15 -0
- package/packages/tui/README.md +1 -1
- package/packages/tui/lib/actions.mjs +1 -1
- package/packages/tui/lib/client.mjs +7 -2
- package/packages/tui/lib/main.mjs +58 -9
- package/packages/tui/lib/model.mjs +136 -46
- package/packages/tui/lib/store.mjs +133 -16
- package/packages/tui/lib/views/capabilities.mjs +239 -0
- package/packages/tui/lib/views/frame.mjs +55 -20
- package/packages/tui/lib/views/help.mjs +9 -4
- package/packages/tui/lib/views/palette.mjs +9 -4
- package/packages/tui/lib/views/souls.mjs +6 -4
- package/packages/tui/lib/views/spawn.mjs +5 -3
- package/skills/oats-getting-started/SKILL.md +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// byte. It places the views: the header, the list of instances and the detail beside it (or as a
|
|
3
3
|
// page of its own on a narrow terminal), an agent's open terminal in the detail's place (or over
|
|
4
4
|
// the whole body, zoomed), the souls of the open workspace and a soul's detail in the same places,
|
|
5
|
+
// and its capabilities and a capability's detail there too,
|
|
5
6
|
// the switcher of workspaces over the whole body, the palette and the spawn prompt over the whole
|
|
6
7
|
// body too, the help, and the footer. The TUI's own words are lit(); everything else is shown().
|
|
7
8
|
// Meaning never rests on colour alone: what is dim or bold also says what it is in words or by a
|
|
@@ -16,6 +17,7 @@ import { instances, measured } from "./instances.mjs";
|
|
|
16
17
|
import { textWidth } from "../term/width.mjs";
|
|
17
18
|
import { palette } from "./palette.mjs";
|
|
18
19
|
import { soulDetail, soulsList, soulsListed } from "./souls.mjs";
|
|
20
|
+
import { capabilitiesList, capabilitiesListed, capabilityDetail } from "./capabilities.mjs";
|
|
19
21
|
import { spawn } from "./spawn.mjs";
|
|
20
22
|
import { splitFits, splitRegions } from "./split.mjs";
|
|
21
23
|
import { switcher } from "./switcher.mjs";
|
|
@@ -215,9 +217,11 @@ function countSpans(counts, cols) {
|
|
|
215
217
|
* first kept longest), so a hint can stand first and still be given up before another: in the
|
|
216
218
|
* list of instances the acts go first (`restart`, `start`, `retire`, then `stop`), then
|
|
217
219
|
* `workspaces`, `refresh`, the key that clears a
|
|
218
|
-
* kept filter,
|
|
220
|
+
* kept filter, the keys that show the tab before and after (`[/] tab`, with two tabs or more in
|
|
221
|
+
* the focused group), `detail`, the open terminal's `close-terminal` and `zoom`, `open` and last `filter`
|
|
219
222
|
* (`filter` before `open` while a filter is kept: its own `/` stands in the footer then); in the
|
|
220
|
-
* Souls view `workspaces`, `refresh`, `filter`, `close`, then `i` and last Enter
|
|
223
|
+
* Souls view `workspaces`, `refresh`, `filter`, `close`, then `i` and last Enter, and in the
|
|
224
|
+
* Capabilities view the same without `i`. A row
|
|
221
225
|
* too narrow for the whole of a hint drops it. The views have no hint: the header names them.
|
|
222
226
|
* The palette's footer says how to work it: Enter, Up/Down and Esc; the spawn prompt's, how to
|
|
223
227
|
* work its step (spawnHints).
|
|
@@ -239,7 +243,10 @@ function footer(m, cols) {
|
|
|
239
243
|
// Enter does (from the list it shows the detail, from the detail the soul's instances) stands
|
|
240
244
|
// first, as `open` does in the list, so a kept filter leaves it its room.
|
|
241
245
|
const soul = m.view === "souls" && m.souls ? m.souls : null;
|
|
242
|
-
|
|
246
|
+
// The Capabilities view's the same way: from the list Enter shows the detail, and from the detail
|
|
247
|
+
// the marked soul of "Used by" in the Souls view (no hint while none is marked).
|
|
248
|
+
const capability = m.view === "capabilities" && m.capabilities ? m.capabilities : null;
|
|
249
|
+
const filter = soul ? soul.filter : capability ? capability.filter : m.filter;
|
|
243
250
|
// A filter is kept by its text, or in the list of instances by a soul (the Souls view's `i`):
|
|
244
251
|
// drawn `soul <name>` where the text's `/` stands.
|
|
245
252
|
const bySoul = !soul && m.view === "instances" && filter.soul && !filter.query ? filter.soul : null;
|
|
@@ -250,6 +257,8 @@ function footer(m, cols) {
|
|
|
250
257
|
return { key, word: said, width: key.width + 1 + said.width };
|
|
251
258
|
};
|
|
252
259
|
const hint = (id, label) => { const a = action(id); return a ? made(keyText(keyLabel(a.keys[0])), label ?? a.label) : null; };
|
|
260
|
+
/** `[/] tab`: the keys of `tab-previous` and `tab-next`, while both have one. */
|
|
261
|
+
const tabsHint = () => { const [before, after] = [action("tab-previous"), action("tab-next")]; return before && after ? made(keyText(`${keyLabel(before.keys[0])}/${keyLabel(after.keys[0])}`), "tab") : null; };
|
|
253
262
|
/** The hints that are no one action's: made below. */
|
|
254
263
|
const hintOf = {};
|
|
255
264
|
const edge = cols - MARGIN; // nothing stands at or past it
|
|
@@ -316,9 +325,11 @@ function footer(m, cols) {
|
|
|
316
325
|
// An action with no key (tui.json may unbind one) has no hint: nothing stands first then. On the
|
|
317
326
|
// row whose terminal is open, Enter goes to it.
|
|
318
327
|
const first = (asking ? [["open", hint("close", "stop opening")]] : listing && m.onTerminal ? [["open", hint("open", "focus terminal")]] : listing && m.openable ? [["open", hint("open")]]
|
|
319
|
-
: soul?.detail ? [["open", hint("open", soul.focus === "detail" ? "instances" : "detail")]]
|
|
320
|
-
|
|
321
|
-
|
|
328
|
+
: soul?.detail ? [["open", hint("open", soul.focus === "detail" ? "instances" : "detail")]]
|
|
329
|
+
: capability?.detail ? (capability.focus !== "detail" ? [["open", hint("open", "detail")]] : capability.mark >= 0 ? [["open", hint("open", "soul")]] : []) : []).filter(([, h]) => h);
|
|
330
|
+
// With a terminal open, the keys that zoom it and close it stand after `open`, kept as long;
|
|
331
|
+
// with two tabs or more in the focused group, then the keys that show the tab before and after.
|
|
332
|
+
const terminal = listing && m.terminal ? [["zoom", hint("zoom")], ["close-terminal", hint("close-terminal")], ...((m.tabs?.length ?? 0) > 1 ? [["tabs", tabsHint()]] : [])].filter(([, h]) => h) : [];
|
|
322
333
|
// The acts the selected row offers now stand after those, and are the first given up.
|
|
323
334
|
const acts = listing && !asking ? (m.actable ?? []).map((verb) => [verb, hint(verb)]).filter(([, h]) => h) : [];
|
|
324
335
|
const ACTS = ["stop", "retire", "start", "restart"];
|
|
@@ -332,13 +343,16 @@ function footer(m, cols) {
|
|
|
332
343
|
// help names n and N.
|
|
333
344
|
: soul ? (soul.local === false ? [["close", "workspaces"], ["close", "workspaces"]]
|
|
334
345
|
: [[...(soul.detail ? ["soul-instances"] : []), "filter", "refresh", "close", "workspaces"], ["open", "soul-instances", "close", "filter", "refresh", "workspaces"]])
|
|
335
|
-
|
|
346
|
+
// The Capabilities view: the filter, a read again, Esc and the workspaces, given up from the
|
|
347
|
+
// workspaces on; Enter last. With no workspace of this machine, Esc and the workspaces only.
|
|
348
|
+
: capability ? (capability.local === false ? [["close", "workspaces"], ["close", "workspaces"]]
|
|
349
|
+
: [["filter", "refresh", "close", "workspaces"], ["open", "close", "filter", "refresh", "workspaces"]])
|
|
336
350
|
// Esc closes the switcher only onto a view, and there is none before a workspace is opened.
|
|
337
351
|
// A kept filter puts `close` before `refresh`, as in the list: the key that clears it is the hint to keep.
|
|
338
352
|
: m.view === "switcher" ? [["open", "filter", ...(m.filter.query ? ["close", "refresh"] : ["refresh", ...(m.open ? ["close"] : [])])], null]
|
|
339
|
-
: m.focus === "detail" ? [["detail", "close", "refresh"], ["open", "zoom", "close-terminal", "detail", "close", "refresh", ...ACTS]]
|
|
353
|
+
: m.focus === "detail" ? [["detail", "close", "refresh"], ["open", "zoom", "close-terminal", "detail", "tabs", "close", "refresh", ...ACTS]]
|
|
340
354
|
// A kept filter shows its own `/` beside the hints: then `open` outlives the `/ filter` hint.
|
|
341
|
-
: [["filter", "detail", ...(filtered ? ["close"] : []), "refresh", "workspaces", ...VIEW_KEYS], [...(filtered ? ["open", "zoom", "close-terminal", "filter"] : ["filter", "open", "zoom", "close-terminal"]), "detail", "close", "refresh", "workspaces", ...VIEW_KEYS, ...ACTS]];
|
|
355
|
+
: [["filter", "detail", ...(filtered ? ["close"] : []), "refresh", "workspaces", ...VIEW_KEYS], [...(filtered ? ["open", "zoom", "close-terminal", "filter"] : ["filter", "open", "zoom", "close-terminal"]), "detail", "tabs", "close", "refresh", "workspaces", ...VIEW_KEYS, ...ACTS]];
|
|
342
356
|
const hints = [...first, ...terminal, ...acts, ...ids.filter((id) => !(asking && id === "close")).map((id) => [id, id in hintOf ? hintOf[id] : hint(id)])].filter(([, h]) => h).map(([id, h]) => [id, spansOf(h)]);
|
|
343
357
|
// `help` and `quit` stand last, and always but in one case: when the two do not fit whole
|
|
344
358
|
// after the leader (keys tui.json made long), `help` is given up, then `quit`. The leader
|
|
@@ -475,13 +489,14 @@ function framed(m, size) {
|
|
|
475
489
|
return { rows, page: Math.max(1, g.body.rows), extent: 0, room: 1, cursor: { row: g.body.top, col: drawn.cursor } };
|
|
476
490
|
}
|
|
477
491
|
// The spawn prompt in the same place (the palette wins if both are ever set). `extent` and `room`
|
|
478
|
-
// are its preview's, which the store scrolls as it scrolls a confirmation; `
|
|
492
|
+
// are its preview's, which the store scrolls as it scrolls a confirmation; `drawnTop` the
|
|
493
|
+
// row its window was drawn from, which the loop gives the store once the frame is written; `armed` says the ready
|
|
479
494
|
// Spawn button is drawn, which the loop tells the store once the frame is written.
|
|
480
495
|
if (m.spawn) {
|
|
481
496
|
rows[2] = rule(cols, m.ascii);
|
|
482
497
|
const drawn = spawn(m, { cols, rows: g.body.rows });
|
|
483
498
|
drawn.rows.forEach((spans, i) => { rows[g.body.top + i] = spans; });
|
|
484
|
-
return { rows, page: Math.max(1, g.body.rows), extent: drawn.extent, room: drawn.room, cursor: drawn.cursor ? { row: g.body.top + drawn.cursor.row, col: drawn.cursor.col } : null, ...(drawn.armed ? { armed: true } : {}) };
|
|
499
|
+
return { rows, page: Math.max(1, g.body.rows), extent: drawn.extent, room: drawn.room, ...(drawn.top !== undefined ? { drawnTop: drawn.top } : {}), cursor: drawn.cursor ? { row: g.body.top + drawn.cursor.row, col: drawn.cursor.col } : null, ...(drawn.armed ? { armed: true } : {}) };
|
|
485
500
|
}
|
|
486
501
|
if (m.view === "act" && m.act) {
|
|
487
502
|
rows[2] = rule(cols, m.ascii);
|
|
@@ -504,14 +519,6 @@ function framed(m, size) {
|
|
|
504
519
|
return { rows, page: Math.max(1, g.body.rows), extent: 0, room: 1 };
|
|
505
520
|
}
|
|
506
521
|
|
|
507
|
-
// The view of this machine not in this version says what it will hold, and what to run until
|
|
508
|
-
// then. The Souls view is drawn below, in the panes of the list.
|
|
509
|
-
if (m.view === "capabilities") {
|
|
510
|
-
rows[2] = rule(cols, m.ascii);
|
|
511
|
-
partRows(m.body?.said ?? [], cols - 2 * MARGIN, g.body.rows, { ascii: m.ascii }).forEach((spans, i) => { rows[g.body.top + 1 + i] = placed(spans, MARGIN); });
|
|
512
|
-
return { rows, page: Math.max(1, g.body.rows), extent: 0, room: 1 };
|
|
513
|
-
}
|
|
514
|
-
|
|
515
522
|
// The state of a deployment that is not live, and on rows of its own the reason, which is the
|
|
516
523
|
// shared home's sentence or the kernel's: nothing of the TUI's stands on a reason's row. Then
|
|
517
524
|
// the note of the one deployment of a view without headings, the shared home's sentence too.
|
|
@@ -525,6 +532,7 @@ function framed(m, size) {
|
|
|
525
532
|
for (const spans of g.outcome) said.push(placed(spans, MARGIN));
|
|
526
533
|
said.slice(0, g.above).forEach((spans, i) => { rows[g.body.top + i] = spans; });
|
|
527
534
|
if (m.view === "souls" && m.souls) return soulsFrame(m, size, g, rows);
|
|
535
|
+
if (m.view === "capabilities" && m.capabilities) return capabilitiesFrame(m, size, g, rows);
|
|
528
536
|
const area = terminalAt(m, size, g);
|
|
529
537
|
const zoomed = area !== null && area.whole;
|
|
530
538
|
const paged = !zoomed && !g.wide && m.focus === "detail" && m.detail;
|
|
@@ -547,7 +555,8 @@ function framed(m, size) {
|
|
|
547
555
|
// The rule between two groups: a column side by side, a row one above the other.
|
|
548
556
|
const p = area.panel, r = area.rule;
|
|
549
557
|
if (r?.col !== undefined) for (let i = 0; i <= p.rows; i++) rows[p.title + i] = [...rows[p.title + i], { col: r.col, text: lit(m.ascii ? "|" : "\u2502"), style: DIM, width: 1 }];
|
|
550
|
-
|
|
558
|
+
// Beside the list, the row meets the list's bar there: a joint (`├`, `+` in ASCII).
|
|
559
|
+
if (r?.row !== undefined) rows[r.row] = [...rows[r.row], ...(split && p.col === g.listCols + 1 ? [{ col: g.listCols, text: lit(m.ascii ? "+" : "\u251c"), style: DIM, width: 1 }] : []), { col: p.col, text: lit((m.ascii ? "-" : "\u2500").repeat(p.cols)), style: DIM, width: p.cols }];
|
|
551
560
|
} else if (split || paged) {
|
|
552
561
|
const at = paged ? MARGIN : g.listCols + 2;
|
|
553
562
|
const drawn = detail(m, { cols: Math.max(0, cols - at - MARGIN), rows: g.panes.rows });
|
|
@@ -590,6 +599,32 @@ function soulsFrame(m, size, g, rows) {
|
|
|
590
599
|
return { rows, page: Math.max(1, g.page), extent, room: Math.max(1, g.panes.rows) };
|
|
591
600
|
}
|
|
592
601
|
|
|
602
|
+
/** The Capabilities view in the panes of the list (views/capabilities.mjs), as the Souls view: the
|
|
603
|
+
* capabilities in the list's place and width, and beside them the selected capability's detail;
|
|
604
|
+
* under WIDE columns the list alone, and the detail in its place while it has the focus. A body of
|
|
605
|
+
* one sentence has the whole width. `capabilitiesTop` is the row the detail was drawn from, which
|
|
606
|
+
* the loop gives the store once the frame is written (it keeps the marked soul in sight). */
|
|
607
|
+
function capabilitiesFrame(m, size, g, rows) {
|
|
608
|
+
const { cols } = size, c = m.capabilities;
|
|
609
|
+
const paged = !g.wide && c.focus === "detail" && Boolean(c.detail);
|
|
610
|
+
const split = g.wide && g.panes.rows > 0 && capabilitiesListed(c);
|
|
611
|
+
const joint = split ? { col: g.listCols } : null;
|
|
612
|
+
const opening = m.observed && g.above > 0 ? g.panes.top - 1 : 2;
|
|
613
|
+
rows[2] = rule(cols, m.ascii, opening === 2 ? joint : null);
|
|
614
|
+
if (opening !== 2 && opening < size.rows - 1) rows[opening] = rule(cols, m.ascii, joint);
|
|
615
|
+
if (!paged) capabilitiesList(m, { cols: split ? g.listCols : cols, rows: g.panes.rows }).forEach((spans, i) => { rows[g.panes.top + i] = spans; });
|
|
616
|
+
let extent = 0, top;
|
|
617
|
+
if (split || paged) {
|
|
618
|
+
const at = paged ? MARGIN : g.listCols + 2;
|
|
619
|
+
const bar = split ? [{ col: g.listCols, text: lit(m.ascii ? "|" : "│"), style: DIM, width: 1 }] : [];
|
|
620
|
+
const drawn = capabilityDetail(m, { cols: Math.max(0, cols - at - MARGIN), rows: g.panes.rows });
|
|
621
|
+
extent = drawn.extent;
|
|
622
|
+
top = drawn.top;
|
|
623
|
+
drawn.rows.forEach((spans, i) => { rows[g.panes.top + i] = [...rows[g.panes.top + i], ...bar, ...placed(spans, at)]; });
|
|
624
|
+
}
|
|
625
|
+
return { rows, page: Math.max(1, g.page), extent, room: Math.max(1, g.panes.rows), ...(top !== undefined ? { capabilitiesTop: top } : {}) };
|
|
626
|
+
}
|
|
627
|
+
|
|
593
628
|
/** Where the open terminal stands for a model and a size, or null while it is not shown (no
|
|
594
629
|
* terminal; another view over the body; the detail in its place; the list's focus on a terminal
|
|
595
630
|
* too narrow for it beside the list). `{ title, top, col, cols, rows, whole }`, the focused
|
|
@@ -7,6 +7,7 @@ import { lit, ownEllipsis } from "../term/text.mjs";
|
|
|
7
7
|
import { style } from "../term/style.mjs";
|
|
8
8
|
import { cutNote, marksOf, measured } from "./instances.mjs";
|
|
9
9
|
import { windowOf } from "./scroll.mjs";
|
|
10
|
+
import { SOUL_MARK } from "./souls.mjs";
|
|
10
11
|
import { OPEN_MARK } from "./switcher.mjs";
|
|
11
12
|
|
|
12
13
|
const TITLE = style({ bold: true });
|
|
@@ -33,6 +34,8 @@ export const NOT_YET = Object.freeze([
|
|
|
33
34
|
// choose, and no task: the rest is the kernel's command's (run on that machine for another).
|
|
34
35
|
Object.freeze({ what: "spawn on another machine", command: "oats spawn <soul>" }),
|
|
35
36
|
Object.freeze({ what: "spawn with a harness, model or task", command: "oats spawn <soul>" }),
|
|
37
|
+
// The Capabilities view lists them and their facts: a capability's skills' text and its files are the kernel's command's.
|
|
38
|
+
Object.freeze({ what: "see a capability's skills and files", command: "oats capabilities show <name>" }),
|
|
36
39
|
Object.freeze({ what: "open an agent in its own tmux window", command: "oats session attach --home <home>" }),
|
|
37
40
|
Object.freeze({ what: "start with another harness or model", command: "oats session start --home <home>" }),
|
|
38
41
|
Object.freeze({ what: "add a machine to this workspace", command: "oats server connect <id> --ssh <alias>" }),
|
|
@@ -46,14 +49,14 @@ export const NOT_YET = Object.freeze([
|
|
|
46
49
|
export const MACHINES = Object.freeze([
|
|
47
50
|
"A machine's rows are what it reported at the time on its heading (in a view of one machine, in the header).",
|
|
48
51
|
"Nothing is kept on disk: a machine not reached in this run is listed by its own name.",
|
|
49
|
-
"Souls and Capabilities
|
|
52
|
+
"Souls and Capabilities are this machine's.",
|
|
50
53
|
]);
|
|
51
|
-
/** The views the frame names, what each holds, and what to run for what a view does not do yet
|
|
52
|
-
*
|
|
54
|
+
/** The views the frame names, what each holds, and what to run for what a view does not do yet.
|
|
55
|
+
* The Souls view spawns an agent of the selected soul (n, N). */
|
|
53
56
|
export const VIEWS = Object.freeze([
|
|
54
57
|
Object.freeze({ name: "1 Instances", what: "the instances of the open workspace", commands: Object.freeze([]) }),
|
|
55
58
|
Object.freeze({ name: "2 Souls", what: "the souls of the open workspace and their detail, i their instances, n an agent of the selected soul", commands: Object.freeze([]) }),
|
|
56
|
-
Object.freeze({ name: "3 Capabilities", what: "
|
|
59
|
+
Object.freeze({ name: "3 Capabilities", what: "the capabilities of the open workspace and their detail, Enter on a soul that uses one shows it in Souls", commands: Object.freeze([]) }),
|
|
57
60
|
]);
|
|
58
61
|
|
|
59
62
|
const words = (text) => text.split(" ");
|
|
@@ -188,6 +191,8 @@ export function helpRows(actions, ascii, cols = 100, detachKey = null) {
|
|
|
188
191
|
[`${marks.waiting}N`, "N instances folded away below it need input"],
|
|
189
192
|
[marks.selected, "the selected row, and the pane the movement keys act on"],
|
|
190
193
|
[OPEN_MARK, "among the workspaces: the one that is open"],
|
|
194
|
+
[ascii ? SOUL_MARK.ascii : SOUL_MARK.utf8, "among the souls: a soul, in its colour"],
|
|
195
|
+
["!", "among the souls: a spawn of it here would be refused"],
|
|
191
196
|
].map(([mark, meaning]) => [mark, words(meaning)]), cols),
|
|
192
197
|
[],
|
|
193
198
|
heading("Views"),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// The palette (docs/tui.md, "The palette"): (model, area) -> rows of spans, over the whole body.
|
|
2
2
|
// Pure: no IO, no clock, no escape byte. One input over a list: the query on the first row, then
|
|
3
3
|
// the window of the rows lib/model.mjs paletteItems lists, the selected one in reverse with `>`.
|
|
4
|
-
// An instance's or a
|
|
5
|
-
// through shown(); the labels of the views, the acts and the
|
|
6
|
-
// is told by colour alone: each row says in a word what kind it is.
|
|
4
|
+
// An instance's, a soul's or a capability's name, a machine, where a capability comes from and the
|
|
5
|
+
// query are text the TUI did not write and go through shown(); the labels of the views, the acts and the
|
|
6
|
+
// commands are the TUI's own. Nothing is told by colour alone: each row says in a word what kind it is.
|
|
7
7
|
import { lit, shown } from "../term/text.mjs";
|
|
8
8
|
import { style } from "../term/style.mjs";
|
|
9
9
|
import { cutNote, marksOf, measured } from "./instances.mjs";
|
|
@@ -13,7 +13,7 @@ const PROMPT = ">", PROMPT_CELLS = 2;
|
|
|
13
13
|
/** The cells a row's text starts at: the selection mark, a gap, an instance's state mark, a gap. */
|
|
14
14
|
const LEAD = 4;
|
|
15
15
|
/** The word at a row's right edge that says what it is. */
|
|
16
|
-
const KINDS = Object.freeze({ instance: "instance", soul: "soul", view: "view", act: "act", command: "command" });
|
|
16
|
+
const KINDS = Object.freeze({ instance: "instance", soul: "soul", capability: "capability", view: "view", act: "act", command: "command" });
|
|
17
17
|
/** The TUI's word before another machine's name. */
|
|
18
18
|
const ON = "on";
|
|
19
19
|
|
|
@@ -37,6 +37,11 @@ function itemRow(item, cols, marks) {
|
|
|
37
37
|
const name = measured(item.name);
|
|
38
38
|
put(name.text, name.width, PLAIN);
|
|
39
39
|
if (item.machine !== null && item.machine !== undefined) { put(lit(ON), ON.length, DIM); const where = measured(item.machine); put(where.text, where.width, DIM); }
|
|
40
|
+
} else if (item.kind === "capability") {
|
|
41
|
+
// A capability's name and, dim, where it comes from (its repository or package): text from outside.
|
|
42
|
+
const name = measured(item.name), where = measured(item.source);
|
|
43
|
+
put(name.text, name.width, PLAIN);
|
|
44
|
+
put(where.text, where.width, DIM);
|
|
40
45
|
} else {
|
|
41
46
|
put(lit(item.label), item.label.length, PLAIN);
|
|
42
47
|
if (item.kind === "act") { const name = measured(item.name); put(name.text, name.width, DIM); }
|
|
@@ -79,8 +79,9 @@ export function soulsListed(s) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/** A line of the TUI's own on as many rows of `width` cells as it needs, broken at its spaces but
|
|
82
|
-
* never inside a command between backticks: a command cut in two cannot be typed.
|
|
83
|
-
|
|
82
|
+
* never inside a command between backticks: a command cut in two cannot be typed. The Capabilities
|
|
83
|
+
* view sets its own lines with it too. */
|
|
84
|
+
export function ownLines(text, width) {
|
|
84
85
|
const words = text.match(/`[^`]*`[^\s`]*|\S+/g) ?? [];
|
|
85
86
|
return words.reduce((lines, word) => {
|
|
86
87
|
const last = lines.at(-1);
|
|
@@ -92,8 +93,9 @@ function ownLines(text, width) {
|
|
|
92
93
|
|
|
93
94
|
/** Units set on rows of `width` cells from column 0, `gap` cells between two: a unit is pieces
|
|
94
95
|
* (`{ text, width, style, glue }`) written together, one cell between two but before a glued one
|
|
95
|
-
* (a comma). A unit is never broken over two rows; one wider than a row is cut there.
|
|
96
|
-
|
|
96
|
+
* (a comma). A unit is never broken over two rows; one wider than a row is cut there. The
|
|
97
|
+
* Capabilities view flows what a capability provides with it. */
|
|
98
|
+
export function flowed(units, width, gap = 1) {
|
|
97
99
|
const unitWidth = (unit) => unit.reduce((sum, piece, i) => sum + piece.width + (i > 0 && !piece.glue ? 1 : 0), 0);
|
|
98
100
|
const rows = [];
|
|
99
101
|
let row = [], used = 0;
|
|
@@ -272,7 +272,9 @@ const SCROLL_MIN = 3;
|
|
|
272
272
|
* above them the rest scrolled to the model's `top`, or to the window that holds the fold with
|
|
273
273
|
* the focus (the store scrolls only with the movement keys; Tab can land on a fold out of sight).
|
|
274
274
|
* The scrolling part's last row says what is cut off. `extent` and `room` are the scrolling
|
|
275
|
-
* part's, for the store's scroll
|
|
275
|
+
* part's, for the store's scroll, and `top` the row the window drawn starts at (which keeps the
|
|
276
|
+
* focused fold in sight, and so may stand where the model's `top` does not), which the loop
|
|
277
|
+
* gives the store once it is painted; `armed` is whether the ready Spawn button is on the screen. */
|
|
276
278
|
function preview(s, size, ascii) {
|
|
277
279
|
const rows = Array.from({ length: size.rows }, () => []);
|
|
278
280
|
const fixed = previewRows(s, size.cols, ascii, { problemRows: 0 }).pinned.length;
|
|
@@ -286,10 +288,10 @@ function preview(s, size, ascii) {
|
|
|
286
288
|
pinned.forEach((spans, i) => { rows[room + i] = spans; });
|
|
287
289
|
const cut = all.pinned.length - pinned.length;
|
|
288
290
|
const cursor = all.cursor && all.cursor.row >= cut ? { row: room + all.cursor.row - cut, col: all.cursor.col } : null;
|
|
289
|
-
return { rows, cursor, extent: all.scroll.length, room: Math.max(1, room), armed: s.ready === true && all.button >= cut };
|
|
291
|
+
return { rows, cursor, extent: all.scroll.length, room: Math.max(1, room), top: win.top, armed: s.ready === true && all.button >= cut };
|
|
290
292
|
}
|
|
291
293
|
|
|
292
|
-
/** `{ rows, cursor, extent, room, armed? }`: `size.rows` rows for an area `size.cols` wide, the step of the
|
|
294
|
+
/** `{ rows, cursor, extent, room, top?, armed? }`: `size.rows` rows for an area `size.cols` wide, the step of the
|
|
293
295
|
* prompt the model is at. `cursor` is `{ row, col }` in the area (the query's end, or the name
|
|
294
296
|
* field's while it has the focus), or null; `extent` and `room` are the preview's scrolling
|
|
295
297
|
* part's, for the store's scroll (0 and 1 for the picker, which the model windows itself). */
|
|
@@ -60,7 +60,7 @@ members:
|
|
|
60
60
|
- git:github.com/acme/agents # the host is a member too
|
|
61
61
|
- git:github.com/acme/platform
|
|
62
62
|
packages:
|
|
63
|
-
oats.framework: v1.12.
|
|
63
|
+
oats.framework: v1.12.3 # bare versions resolve through the official catalog
|
|
64
64
|
oats.okf: v5.2.1
|
|
65
65
|
defaults:
|
|
66
66
|
capabilities: { oats.core: { from: package } }
|