@awebai/oats 0.55.1 → 0.57.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/oats.mjs +96 -72
- package/docs/capabilities.md +67 -3
- package/docs/design/2026-09-23-workspace-module-contracts.md +27 -3
- package/docs/desktop-cli-api.md +375 -37
- package/docs/desktop-instance-start.md +105 -12
- package/docs/desktop.md +65 -11
- package/docs/execution-targets.md +184 -9
- package/docs/harness-trust.md +128 -11
- package/docs/implementation.md +153 -11
- package/docs/integrations.md +5 -3
- package/docs/knowledge.md +117 -43
- package/docs/official-catalog.md +3 -3
- package/docs/packages.md +12 -12
- package/docs/release-lane.md +26 -1
- package/docs/release-notes/v0.56.0.md +699 -0
- package/docs/release-notes/v0.57.0.md +283 -0
- package/docs/schedules.md +8 -3
- package/docs/servers.md +21 -5
- package/docs/souls-and-instances.md +134 -19
- package/docs/tui.md +215 -31
- package/docs/upgrading.md +4 -1
- package/docs/workspaces.md +26 -6
- package/lib/automations.mjs +3 -4
- package/lib/bounded-read.mjs +18 -0
- package/lib/capability-show.mjs +13 -2
- package/lib/claim.mjs +3 -4
- package/lib/core.mjs +919 -278
- package/lib/errors.mjs +39 -0
- package/lib/harness-trust-write.mjs +119 -40
- package/lib/harness-trust.mjs +31 -18
- package/lib/instance-inspect.mjs +160 -11
- package/lib/instance-lifecycle.mjs +90 -37
- package/lib/packages.mjs +8 -5
- package/lib/pi-bridge.mjs +18 -19
- package/lib/remote.mjs +88 -51
- package/lib/retire-output.mjs +9 -4
- package/lib/schedule.mjs +3 -4
- package/lib/servers.mjs +39 -6
- package/lib/session-viewer.mjs +25 -1
- package/lib/triggers.mjs +3 -4
- package/lib/workspace.mjs +6 -6
- package/lib/worktree.mjs +33 -8
- package/lib/write-through-private-file.mjs +26 -0
- package/package-catalog.json +2 -2
- package/package.json +1 -1
- package/packages/client/cli-adapter.mjs +108 -13
- package/packages/client/cli-locator.mjs +16 -14
- package/packages/client/deployment-panel.mjs +4 -3
- package/packages/client/display-text.mjs +2 -1
- package/packages/client/instance-events-contract.mjs +4 -3
- package/packages/client/instance-lifecycle.mjs +235 -0
- package/packages/client/instance-presentation.mjs +9 -0
- package/packages/client/instance-tree.mjs +10 -8
- package/packages/client/kernel-lines.mjs +3 -3
- package/packages/client/launch-contract.mjs +11 -0
- package/packages/client/launch-prompt-outcome.mjs +1 -1
- package/packages/client/lifecycle-cli.mjs +12 -6
- package/packages/client/lifecycle-confirmation.mjs +407 -0
- package/packages/client/lifecycle-contract.mjs +6 -2
- package/packages/client/own-codes.mjs +1 -0
- package/packages/client/panel-views.mjs +39 -2
- package/packages/client/readiness-contract.mjs +2 -2
- package/packages/client/remote-roster.mjs +50 -5
- package/packages/client/roster-sections.mjs +3 -3
- package/packages/client/session-start.mjs +98 -0
- package/packages/client/start-gate.mjs +46 -0
- package/packages/client/start-messages.mjs +17 -0
- package/packages/client/workspace-views.mjs +2 -2
- package/packages/tui/README.md +21 -8
- package/packages/tui/lib/actions.mjs +11 -2
- package/packages/tui/lib/client.mjs +9 -2
- package/packages/tui/lib/config.mjs +39 -9
- package/packages/tui/lib/main.mjs +168 -20
- package/packages/tui/lib/model.mjs +315 -13
- package/packages/tui/lib/open.mjs +45 -0
- package/packages/tui/lib/read.mjs +171 -16
- package/packages/tui/lib/store.mjs +171 -10
- package/packages/tui/lib/term/tty.mjs +71 -12
- package/packages/tui/lib/views/act.mjs +85 -0
- package/packages/tui/lib/views/frame.mjs +145 -33
- package/packages/tui/lib/views/help.mjs +46 -11
- package/skills/oats-getting-started/SKILL.md +6 -3
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// no mouse or focus reporting, no keyboard protocol, no keypad or cursor-key mode, no title, no
|
|
5
5
|
// clipboard, no bell, no query that expects a reply.
|
|
6
6
|
//
|
|
7
|
-
// Handing the terminal to someone else (the shell at a suspend;
|
|
7
|
+
// Handing the terminal to someone else (the shell at a suspend; the kernel's viewer at a lend) is
|
|
8
8
|
// leave() and enter(), and only that pair.
|
|
9
9
|
|
|
10
10
|
const mode = (number, on) => `\x1b[?${number}${on ? "h" : "l"}`;
|
|
@@ -22,6 +22,9 @@ export const SIGNAL_STATUS = Object.freeze({ SIGINT: 130, SIGTERM: 143, SIGHUP:
|
|
|
22
22
|
export const TERMINAL_GONE_STATUS = SIGNAL_STATUS.SIGHUP;
|
|
23
23
|
/** How long a suspend waits for the stop before it concludes there was none. */
|
|
24
24
|
const STOP_GRACE_MS = 100;
|
|
25
|
+
/** How long a run that is ending while the terminal is lent waits for the borrower to close after
|
|
26
|
+
* it was asked to end, before it ends anyway. */
|
|
27
|
+
export const LEND_END_GRACE_MS = 3000;
|
|
25
28
|
|
|
26
29
|
/** A terminal on both ends that can be addressed: no escape byte is ever written to anything else. */
|
|
27
30
|
export function isTerminal({ stdin, stdout, env }) {
|
|
@@ -41,6 +44,9 @@ export function createGuard({ stdin, stdout, proc, frame, onInput, onResize, onR
|
|
|
41
44
|
let entered = false, raw = false, modes = false;
|
|
42
45
|
let suspended = false, stopTimer = null;
|
|
43
46
|
let over = false, blocked = false, stale = false;
|
|
47
|
+
/** While the terminal is lent: `{ end, ending }`, the borrower's end() and, once the run is
|
|
48
|
+
* ending, the `[status, error]` it ends with when the borrower has closed. Else null. */
|
|
49
|
+
let lent = null, endTimer = null;
|
|
44
50
|
let settle;
|
|
45
51
|
const done = new Promise((resolve) => { settle = resolve; });
|
|
46
52
|
const listeners = [];
|
|
@@ -72,6 +78,7 @@ export function createGuard({ stdin, stdout, proc, frame, onInput, onResize, onR
|
|
|
72
78
|
if (over) return;
|
|
73
79
|
over = true;
|
|
74
80
|
leave();
|
|
81
|
+
if (endTimer !== null) { clearTimer(endTimer); endTimer = null; }
|
|
75
82
|
// What it throws must not keep the run from ending, nor replace the status it ends with.
|
|
76
83
|
if (onEnd) quietly(onEnd);
|
|
77
84
|
if (stopTimer !== null) { clearTimer(stopTimer); stopTimer = null; }
|
|
@@ -82,15 +89,15 @@ export function createGuard({ stdin, stdout, proc, frame, onInput, onResize, onR
|
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
/** Run one of the loop's own steps. What it throws ends the run as an uncaught error would,
|
|
85
|
-
* without waiting for the process to say so. */
|
|
92
|
+
* without waiting for the process to say so (while the terminal is lent, the borrower first). */
|
|
86
93
|
function attempt(step) {
|
|
87
|
-
try { step(); } catch (error) {
|
|
94
|
+
try { step(); } catch (error) { out(1, error); }
|
|
88
95
|
}
|
|
89
96
|
|
|
90
97
|
/** One write per frame. While the last write has not drained nothing is queued: the newest frame
|
|
91
98
|
* is made when it has. */
|
|
92
99
|
function draw() {
|
|
93
|
-
if (!entered || over) return;
|
|
100
|
+
if (!entered || over || lent) return;
|
|
94
101
|
if (blocked) { stale = true; return; }
|
|
95
102
|
const bytes = frame();
|
|
96
103
|
if (bytes && stdout.write(bytes) === false) blocked = true;
|
|
@@ -143,27 +150,79 @@ export function createGuard({ stdin, stdout, proc, frame, onInput, onResize, onR
|
|
|
143
150
|
/** SIGCONT. After our own suspend: come back. Otherwise the process was stopped and continued
|
|
144
151
|
* from outside while it held the terminal. */
|
|
145
152
|
function continued() {
|
|
146
|
-
if (over) return;
|
|
153
|
+
if (over || lent) return; // a lent terminal is the borrower's: it takes care of its own
|
|
147
154
|
if (suspended) return resume();
|
|
148
155
|
if (onResume && entered) { attempt(() => onResume(false)); if (over) return; }
|
|
149
156
|
reassert();
|
|
150
157
|
}
|
|
151
158
|
|
|
159
|
+
/** Lend the terminal to a program of its own (the kernel's viewer) and take it back when it
|
|
160
|
+
* ends. The suspend path, without the stop: leave() (the modes, then raw mode off), input
|
|
161
|
+
* paused, so two readers do not split the keys; then `run()`, which starts the borrower with
|
|
162
|
+
* the terminal as its own and resolves when it has closed; then enter(), input resumed and a
|
|
163
|
+
* full redraw. Answers a promise of `{ value }` (what run resolved with) or `{ error }` (what it
|
|
164
|
+
* threw or rejected with: the terminal is taken back all the same).
|
|
165
|
+
* WHILE LENT nothing is drawn, whatever asks; a SIGQUIT does not end the run (a second
|
|
166
|
+
* Ctrl+\ after the viewer gave the terminal back is the terminal's QUIT, and the viewer handles
|
|
167
|
+
* its own); a SIGTSTP is not heard, so its default action stops the whole group and SIGCONT
|
|
168
|
+
* continues it, and nothing of the suspend path runs. SIGINT, SIGTERM, SIGHUP, a terminal that
|
|
169
|
+
* goes away and an uncaught error end the run as always, but the borrower first: `end()` is
|
|
170
|
+
* called and the run ends when the borrower has closed, or LEND_END_GRACE_MS later. The
|
|
171
|
+
* terminal is already restored, so nothing more is written to it.
|
|
172
|
+
* Lending a terminal that is not the TUI's now (not entered, lent, over) runs nothing. */
|
|
173
|
+
function lend(run, { end = null, release = null } = {}) {
|
|
174
|
+
if (!entered || over || lent) return Promise.resolve({ error: new Error("the terminal is not the TUI's to lend now") });
|
|
175
|
+
leave();
|
|
176
|
+
quietly(() => stdin.pause());
|
|
177
|
+
proc.removeListener("SIGTSTP", suspend);
|
|
178
|
+
const mine = lent = { end, release, ending: null };
|
|
179
|
+
let running;
|
|
180
|
+
try { running = Promise.resolve(run()); } catch (error) { running = Promise.reject(error); }
|
|
181
|
+
return running.then((value) => ({ value }), (error) => ({ error })).then((outcome) => {
|
|
182
|
+
lent = null;
|
|
183
|
+
if (mine.ending) { finish(...mine.ending); return outcome; }
|
|
184
|
+
if (over) return outcome;
|
|
185
|
+
proc.on("SIGTSTP", suspend);
|
|
186
|
+
try { enter(); } catch { finish(TERMINAL_GONE_STATUS); return outcome; }
|
|
187
|
+
if (!over) stdin.resume();
|
|
188
|
+
attempt(onRedraw);
|
|
189
|
+
return outcome;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/** A way out that arrives while the terminal is lent: end the borrower and wait for it. A second
|
|
193
|
+
* one does not wait. */
|
|
194
|
+
function endLent(status, error) {
|
|
195
|
+
// The run does not wait for a borrower past this: what holds it (its handle, its pipe) is let
|
|
196
|
+
// go, so the process can end with the status of the signal although the borrower lives on.
|
|
197
|
+
const mine = lent, givenUp = () => { if (mine.release) attempt(mine.release); finish(status, error); };
|
|
198
|
+
if (mine.ending) return givenUp();
|
|
199
|
+
mine.ending = [status, error];
|
|
200
|
+
if (mine.end) attempt(mine.end);
|
|
201
|
+
if (over) return;
|
|
202
|
+
endTimer = setTimer(() => { endTimer = null; givenUp(); }, LEND_END_GRACE_MS);
|
|
203
|
+
}
|
|
204
|
+
/** Every way out the run can be told of: a signal, an error nobody caught, a terminal gone. */
|
|
205
|
+
function out(status, error) {
|
|
206
|
+
if (over) return;
|
|
207
|
+
if (lent) return endLent(status, error);
|
|
208
|
+
finish(status, error);
|
|
209
|
+
}
|
|
210
|
+
|
|
152
211
|
/** Every way out is registered before the terminal is touched; then enter. A signal cannot land
|
|
153
212
|
* inside enter(), which is synchronous, and one that lands after it finds its listener. */
|
|
154
213
|
function start() {
|
|
155
|
-
for (const [signal, status] of Object.entries(SIGNAL_STATUS)) on(proc, signal, () =>
|
|
214
|
+
for (const [signal, status] of Object.entries(SIGNAL_STATUS)) on(proc, signal, () => { if (!(lent && signal === "SIGQUIT")) out(status); });
|
|
156
215
|
on(proc, "SIGCONT", continued);
|
|
157
216
|
proc.on("SIGTSTP", suspend);
|
|
158
|
-
on(proc, "uncaughtException", (error) =>
|
|
159
|
-
on(proc, "unhandledRejection", (reason) =>
|
|
217
|
+
on(proc, "uncaughtException", (error) => out(1, error));
|
|
218
|
+
on(proc, "unhandledRejection", (reason) => out(1, reason));
|
|
160
219
|
on(proc, "exit", () => { leave(); if (onEnd) quietly(onEnd); }); // the last resort: a process.exit() nobody expected
|
|
161
220
|
// A dead terminal answers a write or a read with an error event. These two listeners are never
|
|
162
221
|
// removed: the write that restores the terminal can fail after the run is over, and an error
|
|
163
222
|
// event nobody hears is an uncaught exception, which would turn the status into 1.
|
|
164
|
-
for (const stream of [stdin, stdout]) stream.on("error", () =>
|
|
165
|
-
on(stdin, "end", () =>
|
|
166
|
-
on(stdin, "close", () =>
|
|
223
|
+
for (const stream of [stdin, stdout]) stream.on("error", () => out(TERMINAL_GONE_STATUS));
|
|
224
|
+
on(stdin, "end", () => out(TERMINAL_GONE_STATUS));
|
|
225
|
+
on(stdin, "close", () => out(TERMINAL_GONE_STATUS));
|
|
167
226
|
on(stdin, "data", (bytes) => { if (entered) attempt(() => onInput(bytes)); });
|
|
168
227
|
on(stdout, "resize", () => { if (entered) attempt(onResize); });
|
|
169
228
|
on(stdout, "drain", drained);
|
|
@@ -174,5 +233,5 @@ export function createGuard({ stdin, stdout, proc, frame, onInput, onResize, onR
|
|
|
174
233
|
/** The terminal's size now; 80x24 when the terminal does not say. */
|
|
175
234
|
const size = () => ({ cols: Number.isInteger(stdout.columns) && stdout.columns > 0 ? stdout.columns : 80, rows: Number.isInteger(stdout.rows) && stdout.rows > 0 ? stdout.rows : 24 });
|
|
176
235
|
|
|
177
|
-
return { start, enter, leave, finish, suspend, reassert, attempt, draw, size, done, get entered() { return entered; } };
|
|
236
|
+
return { start, enter, leave, finish, suspend, reassert, attempt, draw, lend, size, done, get entered() { return entered; }, get lent() { return lent !== null; } };
|
|
178
237
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// The act view: one confirmation of a stop, a retire, a start or a restart, over the list of
|
|
2
|
+
// instances (as the help is). Pure: no IO, no clock, no escape byte. (model, area) -> rows.
|
|
3
|
+
// The content (lib/model.mjs actView) scrolls when it is taller than the area; the buttons keep
|
|
4
|
+
// the area's last row. The TUI's own words are lit(); every shared sentence, the kernel's lines,
|
|
5
|
+
// a name and a path go through shown(). Meaning never rests on colour alone: the button with the
|
|
6
|
+
// focus is drawn between `>` and `<` as well as in reverse.
|
|
7
|
+
import { EMPTY, lit, shown, shownLines, textOf } from "../term/text.mjs";
|
|
8
|
+
import { textWidth } from "../term/width.mjs";
|
|
9
|
+
import { style } from "../term/style.mjs";
|
|
10
|
+
import { partRows } from "./frame.mjs";
|
|
11
|
+
import { cutNote } from "./instances.mjs";
|
|
12
|
+
import { windowOf } from "./scroll.mjs";
|
|
13
|
+
|
|
14
|
+
const LEFT = 2;
|
|
15
|
+
const GAP = 3;
|
|
16
|
+
/** The most rows one line of the content takes. */
|
|
17
|
+
const LINE_ROWS = 12;
|
|
18
|
+
const BOLD = style({ bold: true });
|
|
19
|
+
const DIM = style({ dim: true });
|
|
20
|
+
const FOCUSED = style({ bold: true, reverse: true });
|
|
21
|
+
const LOOKS = Object.freeze({ bold: BOLD, dim: DIM });
|
|
22
|
+
|
|
23
|
+
/** A line's own rows of spans from column 0, in `width` cells. */
|
|
24
|
+
function lineRows(line, width, ascii) {
|
|
25
|
+
const look = LOOKS[line.look];
|
|
26
|
+
const styled = (spans) => (look ? spans.map((span) => ({ ...span, style: look })) : spans);
|
|
27
|
+
if (line.gap) return [[]];
|
|
28
|
+
if (line.said) return partRows(line.said, width, LINE_ROWS, { ascii }).map(styled);
|
|
29
|
+
if (line.own !== undefined) return partRows([{ own: line.own }], width, LINE_ROWS, { ascii }).map(styled);
|
|
30
|
+
if (line.pair) {
|
|
31
|
+
// A state row's label is the shared plan's (a target's name among them), so it is text from
|
|
32
|
+
// outside like its value: filtered, cut to half the width, and measured as it is drawn.
|
|
33
|
+
const [label, value] = line.pair;
|
|
34
|
+
const name = shownLines(label, Math.max(1, Math.floor(width / 2)), 1, { ascii })[0] ?? EMPTY;
|
|
35
|
+
const used = textWidth(textOf(name)), at = used + 2;
|
|
36
|
+
return [[{ col: 0, text: name, style: DIM, width: used }, { col: at, text: shown(value), width: Math.max(0, width - at) }]];
|
|
37
|
+
}
|
|
38
|
+
if (line.choice) {
|
|
39
|
+
const box = line.choice.value ? "[x]" : "[ ]";
|
|
40
|
+
return shownLines(line.choice.sentence, Math.max(1, width - 4), LINE_ROWS, { ascii })
|
|
41
|
+
.map((text, i) => [...(i === 0 ? [{ col: 0, text: lit(box), width: 3 }] : []), { col: 4, text, width: Math.max(0, width - 4) }]);
|
|
42
|
+
}
|
|
43
|
+
// A shared sentence or the kernel's line, with a path after it: one text from outside.
|
|
44
|
+
const text = line.path ? `${line.text ?? ""} ${line.path}` : line.text;
|
|
45
|
+
return shownLines(text, width, LINE_ROWS, { ascii }).map((value) => styled([{ col: 0, text: value, width }]));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Every row of the content for an area `cols` wide, before it is scrolled: the title, then the lines. */
|
|
49
|
+
export function actRows(m, cols) {
|
|
50
|
+
const width = Math.max(1, cols - 2 * LEFT);
|
|
51
|
+
const t = m.act.title;
|
|
52
|
+
const title = t.said ? partRows(t.said, width, 2, { ascii: m.ascii }) : shownLines(t.text, width, 2, { ascii: m.ascii }).map((text) => [{ col: 0, text, width }]);
|
|
53
|
+
const rows = [...title.map((spans) => spans.map((span) => ({ ...span, style: BOLD }))), []];
|
|
54
|
+
for (const line of m.act.lines) rows.push(...lineRows(line, width, m.ascii));
|
|
55
|
+
return rows.map((spans) => spans.map((span) => ({ ...span, col: span.col + LEFT })));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The buttons, one per offer of the confirmation and in its order, on one row; the one with the
|
|
59
|
+
* focus between `>` and `<`. */
|
|
60
|
+
function buttonRow(buttons, cols) {
|
|
61
|
+
const spans = [];
|
|
62
|
+
let col = LEFT;
|
|
63
|
+
for (const button of buttons) {
|
|
64
|
+
const label = button.focused ? `> ${button.label} <` : `[ ${button.label} ]`;
|
|
65
|
+
if (col + label.length > cols) break;
|
|
66
|
+
spans.push({ col, text: lit(label), width: label.length, ...(button.focused ? { style: FOCUSED } : {}) });
|
|
67
|
+
col += label.length + GAP;
|
|
68
|
+
}
|
|
69
|
+
return spans;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** `{ rows, extent, room }`: `size.rows` rows for an area `size.cols` wide: the content scrolled
|
|
73
|
+
* to the confirmation's `top`, then an empty row and the buttons on the last row. `extent` and
|
|
74
|
+
* `room` are the content's, for the store's scroll. */
|
|
75
|
+
export function act(m, size) {
|
|
76
|
+
const rows = Array.from({ length: size.rows }, () => []);
|
|
77
|
+
const room = Math.max(0, size.rows - 2);
|
|
78
|
+
const all = actRows(m, size.cols);
|
|
79
|
+
const win = windowOf({ top: m.act.top ?? 0, count: all.length, height: room });
|
|
80
|
+
all.slice(win.top, win.top + win.size).forEach((spans, i) => { rows[i] = spans; });
|
|
81
|
+
const note = cutNote(win.above, win.below);
|
|
82
|
+
if (note && room > 0) rows[room - 1] = [{ col: LEFT, text: lit(note), style: DIM, width: Math.max(0, size.cols - LEFT) }];
|
|
83
|
+
if (size.rows > 0) rows[size.rows - 1] = buttonRow(m.act.buttons, size.cols);
|
|
84
|
+
return { rows, extent: all.length, room: Math.max(1, room) };
|
|
85
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { keyLabel } from "../actions.mjs";
|
|
7
7
|
import { lit, shown, shownLines } from "../term/text.mjs";
|
|
8
8
|
import { style } from "../term/style.mjs";
|
|
9
|
+
import { act } from "./act.mjs";
|
|
9
10
|
import { detail } from "./detail.mjs";
|
|
10
11
|
import { help, keyText } from "./help.mjs";
|
|
11
12
|
import { instances, measured } from "./instances.mjs";
|
|
@@ -60,24 +61,72 @@ function rule(cols, ascii, joint = null) {
|
|
|
60
61
|
return spans;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
/** A sentence made of parts (lib/model.mjs OPEN_WORDS): the TUI's own words (`{ own }`) and text
|
|
65
|
+
* from outside (`{ shown }`, a name), each made safe on its own, so no word of the TUI's is ever
|
|
66
|
+
* filtered with a name and no name is ever taken for the TUI's. Set on at most `max` rows of at
|
|
67
|
+
* most `width` cells, broken at the spaces of the TUI's words; a name and what is written against
|
|
68
|
+
* it (a full stop) are never broken apart, and a name wider than a row is cut there. Answers rows
|
|
69
|
+
* of spans from column 0; when more was left, the last row ends in the cut mark. */
|
|
70
|
+
export function partRows(parts, width, max, { ascii = false } = {}) {
|
|
71
|
+
if (width < 1 || max < 1) return [];
|
|
72
|
+
// Units: what is written together, a space between two.
|
|
73
|
+
const units = [];
|
|
74
|
+
let glue = false;
|
|
75
|
+
const put = (piece) => { if (glue && units.length) units.at(-1).push(piece); else units.push([piece]); glue = true; };
|
|
76
|
+
for (const part of parts) {
|
|
77
|
+
if (part.own !== undefined) part.own.split(" ").forEach((word, i) => { if (i > 0) glue = false; if (word) put({ text: lit(word), width: word.length }); });
|
|
78
|
+
else { const m = measured(part.shown); if (m.width > 0) put(m); }
|
|
79
|
+
}
|
|
80
|
+
const unitWidth = (unit) => unit.reduce((sum, piece) => sum + piece.width, 0);
|
|
81
|
+
const rows = [];
|
|
82
|
+
let row = [], used = 0, i = 0;
|
|
83
|
+
for (; i < units.length; i++) {
|
|
84
|
+
const w = unitWidth(units[i]);
|
|
85
|
+
if (row.length && used + 1 + w > width) {
|
|
86
|
+
rows.push(row);
|
|
87
|
+
if (rows.length === max) break;
|
|
88
|
+
row = []; used = 0;
|
|
89
|
+
}
|
|
90
|
+
let col = row.length ? used + 1 : 0;
|
|
91
|
+
for (const piece of units[i]) { if (col < width) row.push({ col, text: piece.text, width: Math.min(piece.width, width - col) }); col += piece.width; }
|
|
92
|
+
used = Math.min(width, col);
|
|
93
|
+
}
|
|
94
|
+
if (i === units.length && row.length) rows.push(row);
|
|
95
|
+
const mark = ascii ? "..." : "\u2026";
|
|
96
|
+
if (i < units.length && rows.length && mark.length <= width) {
|
|
97
|
+
const last = rows[rows.length - 1];
|
|
98
|
+
while (last.length && last.at(-1).col + last.at(-1).width + 1 + mark.length > width) last.pop();
|
|
99
|
+
const end = last.length ? last.at(-1).col + last.at(-1).width + 1 : 0;
|
|
100
|
+
last.push({ col: end, text: lit(mark), width: mark.length });
|
|
101
|
+
}
|
|
102
|
+
return rows;
|
|
103
|
+
}
|
|
104
|
+
|
|
63
105
|
/** Where everything stands for a size: the body under the header, the reason of a deployment
|
|
64
|
-
* that is not live
|
|
65
|
-
* here, since their rows take room from the panes), and the
|
|
66
|
-
* model's (lib/model.mjs): the main loop asks for
|
|
67
|
-
* is as tall, and the sentences in its list as wide,
|
|
68
|
-
* `note` is the note's rows
|
|
69
|
-
|
|
106
|
+
* that is not live, the note of the one deployment of a view without headings and the line after
|
|
107
|
+
* an agent was opened (each wrapped here, since their rows take room from the panes), and the
|
|
108
|
+
* panes. `notice`, `note` and `outcome` are the model's (lib/model.mjs): the main loop asks for
|
|
109
|
+
* the layout first, because the model's window is as tall, and the sentences in its list as wide,
|
|
110
|
+
* as the list pane this gives. The answer's `note` is the note's rows and `outcome` the line's:
|
|
111
|
+
* its sentence and each text under it (what the viewer printed, what the kernel said) set as a
|
|
112
|
+
* reason is, on as many rows as a reason may take. */
|
|
113
|
+
export function layout(notice, size, { observed = true, note = null, ascii = false, outcome = null } = {}) {
|
|
70
114
|
const body = { top: 3, rows: Math.max(0, size.rows - 5) };
|
|
71
115
|
const wide = size.cols >= WIDE;
|
|
72
116
|
const listCols = wide ? clamp(Math.floor(size.cols * 0.48), 36, 60) : size.cols;
|
|
73
117
|
const across = Math.max(1, size.cols - 2 * MARGIN);
|
|
74
|
-
const
|
|
118
|
+
const reasonRows = clamp(Math.floor(body.rows / 4), 1, REASON_ROWS);
|
|
119
|
+
const reason = notice ? shownLines(notice.reason, across, reasonRows, { ascii }) : [];
|
|
75
120
|
const noted = note ? shownLines(note, across, NOTE_ROWS, { ascii }) : [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
121
|
+
const after = outcome ? [
|
|
122
|
+
...partRows(outcome.said, across, reasonRows, { ascii }),
|
|
123
|
+
...outcome.under.flatMap((text) => shownLines(text, across, reasonRows, { ascii }).map((line) => [{ col: 0, text: line, width: across }])),
|
|
124
|
+
] : [];
|
|
125
|
+
// The state and its reason, then the note, then the line after an open, stand above the panes,
|
|
126
|
+
// over the whole width; a rule closes them when instances follow.
|
|
127
|
+
const said = (notice ? 1 + reason.length : 0) + noted.length + after.length;
|
|
79
128
|
const above = said ? Math.min(body.rows, said + (observed ? 1 : 0)) : 0;
|
|
80
|
-
return { body, wide, listCols, reason, note: noted, above, panes: { top: body.top + above, rows: Math.max(0, body.rows - above) }, page: Math.max(0, body.rows - above) };
|
|
129
|
+
return { body, wide, listCols, reason, note: noted, outcome: after, above, panes: { top: body.top + above, rows: Math.max(0, body.rows - above) }, page: Math.max(0, body.rows - above) };
|
|
81
130
|
}
|
|
82
131
|
|
|
83
132
|
/** The header's middle, from `col` on in `room` cells: the workspace's name and, when the view
|
|
@@ -130,54 +179,109 @@ function countSpans(counts, cols) {
|
|
|
130
179
|
|
|
131
180
|
/** The footer: the filter field while it is open; else the actions that apply now, read from the
|
|
132
181
|
* effective table, as many as fit, `help` and `quit` last and always: their room is set aside
|
|
133
|
-
* first, and a kept filter and the other hints take what is left.
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
182
|
+
* first, and a kept filter and the other hints take what is left. The hints stand in the order
|
|
183
|
+
* given, and when they do not all fit they are given up in an order of their own (`keep`, the
|
|
184
|
+
* first kept longest), so a hint can stand first and still be given up before another: in the
|
|
185
|
+
* list of instances the acts go first (`restart`, `start`, `retire`, then `stop`), then
|
|
186
|
+
* `workspaces`, `refresh`, the key that clears a kept filter, `detail`, `open` and last `filter`
|
|
187
|
+
* (`filter` before `open` while a filter is kept: its own `/` stands in the footer then). A row
|
|
188
|
+
* too narrow for the whole of a hint drops it.
|
|
189
|
+
* `open` stands first while Enter would open the selected agent's terminal, and names the key
|
|
190
|
+
* that brings the TUI back (tui.json's `open.detachKey`, text from outside); while another
|
|
191
|
+
* machine is asked first, the key that gives the open up stands in its place. After it stand
|
|
192
|
+
* the acts whose key opens a confirmation for the selected row now (the model's `actable`). In a
|
|
193
|
+
* confirmation the buttons are on the screen, and the footer says how to work them: the close
|
|
194
|
+
* key with the close button's label, the keys that move, Enter, and `quit`. The switcher has a
|
|
195
|
+
* filter of its own, drawn as the list's. A key's label is the user's (views/help.mjs keyText);
|
|
196
|
+
* everything is placed by cells. */
|
|
138
197
|
function footer(m, cols) {
|
|
139
198
|
const action = (id) => m.actions.find((a) => a.id === id && a.keys.length);
|
|
140
|
-
/** A hint: a key and what it does. */
|
|
141
|
-
const made = (key, word) =>
|
|
199
|
+
/** A hint: a key and what it does, the TUI's word or safe text with its width. */
|
|
200
|
+
const made = (key, word) => {
|
|
201
|
+
const said = typeof word === "string" ? { text: lit(word), width: word.length } : word;
|
|
202
|
+
return { key, word: said, width: key.width + 1 + said.width };
|
|
203
|
+
};
|
|
142
204
|
const hint = (id, label) => { const a = action(id); return a ? made(keyText(keyLabel(a.keys[0])), label ?? a.label) : null; };
|
|
143
205
|
const edge = cols - MARGIN; // nothing stands at or past it
|
|
144
206
|
/** A hint's spans at `col`, never past the edge. */
|
|
145
207
|
const put = (h, col, look) => [
|
|
146
208
|
{ col, text: h.key.text, width: Math.max(0, Math.min(h.key.width, edge - col)), ...look },
|
|
147
|
-
{ col: col + h.key.width + 1
|
|
209
|
+
...h.word.spans.map((span) => ({ ...span, col: col + h.key.width + 1 + span.col })).map((span) => ({ ...span, width: Math.max(0, Math.min(span.width, edge - span.col)), ...look })),
|
|
148
210
|
].filter((span) => span.width > 0);
|
|
149
211
|
const span = (hints) => hints.reduce((sum, h) => sum + h.width, 0) + Math.max(0, hints.length - 1) * GAP;
|
|
212
|
+
// A word is drawn as one span, or as the open hint's three: `open (`, the key, `returns)`.
|
|
213
|
+
const spansOf = (h) => ({ ...h, word: { ...h.word, spans: h.word.spans ?? [{ col: 0, text: h.word.text, width: h.word.width }] } });
|
|
150
214
|
|
|
151
215
|
if (m.view !== "help" && m.filter.editing) {
|
|
152
|
-
const hints = [made({ text: lit("Enter"), width: "Enter".length }, "keep"), hint("close", "clear")].filter(Boolean);
|
|
216
|
+
const hints = [made({ text: lit("Enter"), width: "Enter".length }, "keep"), hint("close", "clear")].filter(Boolean).map(spansOf);
|
|
153
217
|
const spans = [{ col: MARGIN, text: lit("/"), style: BOLD, width: 1 }, { col: MARGIN + 1, text: shown(m.filter.query), width: Math.max(0, edge - span(hints) - GAP - MARGIN - 1) }];
|
|
154
218
|
let col = Math.max(MARGIN + 2, edge - span(hints));
|
|
155
219
|
for (const h of hints) { spans.push(...put(h, col, { style: DIM })); col += h.width + GAP; }
|
|
156
220
|
return spans;
|
|
157
221
|
}
|
|
158
|
-
|
|
222
|
+
/** The open hint: `Enter open (C-\ returns)`, the detach key drawn as text from outside. */
|
|
223
|
+
const opener = () => {
|
|
224
|
+
const a = action("open");
|
|
225
|
+
if (!a) return null;
|
|
226
|
+
const key = keyText(m.detachKey), lead = "open (", tail = "returns)";
|
|
227
|
+
const spans = [{ col: 0, text: lit(lead), width: lead.length }, { col: lead.length, text: key.text, width: key.width }, { col: lead.length + key.width + 1, text: lit(tail), width: tail.length }];
|
|
228
|
+
return made(keyText(keyLabel(a.keys[0])), { spans, width: lead.length + key.width + 1 + tail.length });
|
|
229
|
+
};
|
|
230
|
+
if (m.view === "act" && m.act) {
|
|
231
|
+
// The confirmation: its buttons are the offers, on the screen; the footer says how to work them.
|
|
232
|
+
const close = action("close"), shut = m.act.buttons.find((button) => button.id === "close");
|
|
233
|
+
const hints = [
|
|
234
|
+
...(close && shut ? [made(keyText(keyLabel(close.keys[0])), shut.label)] : []),
|
|
235
|
+
...(m.act.buttons.length > 1 ? [made({ text: lit("Left/Right"), width: "Left/Right".length }, "move")] : []),
|
|
236
|
+
made({ text: lit("Enter"), width: "Enter".length }, "press"),
|
|
237
|
+
].map(spansOf);
|
|
238
|
+
const quit = hint("quit");
|
|
239
|
+
const all = [...hints, ...(quit ? [spansOf(quit)] : [])];
|
|
240
|
+
const spans = [];
|
|
241
|
+
let col = MARGIN;
|
|
242
|
+
for (const h of all) { if (col + h.width > edge) break; spans.push(...put(h, col)); col += h.width + GAP; }
|
|
243
|
+
return spans;
|
|
244
|
+
}
|
|
245
|
+
const listing = m.view !== "help" && m.view !== "switcher";
|
|
246
|
+
// While another machine is asked first, Esc gives the open up, and that is all it does: the
|
|
247
|
+
// hint stands where `open` stood, is kept as long, and `close` is not listed beside it.
|
|
248
|
+
const asking = listing && m.opening?.phase === "preflight";
|
|
249
|
+
// An action with no key (tui.json may unbind one) has no hint: nothing stands first then.
|
|
250
|
+
const first = (asking ? [["open", hint("close", "stop opening")]] : listing && m.openable ? [["open", opener()]] : []).filter(([, h]) => h);
|
|
251
|
+
// The acts the selected row offers now stand after `open`, and are the first given up.
|
|
252
|
+
const acts = listing && !asking ? (m.actable ?? []).map((verb) => [verb, hint(verb)]).filter(([, h]) => h) : [];
|
|
253
|
+
const ACTS = ["stop", "retire", "start", "restart"];
|
|
254
|
+
const [ids, keep] = m.view === "help" ? [["close"], ["close"]]
|
|
159
255
|
// Esc closes the switcher only onto a view, and there is none before a workspace is opened.
|
|
160
256
|
// A kept filter puts `close` before `refresh`, as in the list: the key that clears it is the hint to keep.
|
|
161
|
-
: m.view === "switcher" ? ["open
|
|
162
|
-
: m.focus === "detail" ? ["detail", "close", "refresh"]
|
|
163
|
-
|
|
164
|
-
|
|
257
|
+
: m.view === "switcher" ? [["open", "filter", ...(m.filter.query ? ["close", "refresh"] : ["refresh", ...(m.open ? ["close"] : [])])], null]
|
|
258
|
+
: m.focus === "detail" ? [["detail", "close", "refresh"], ["open", "detail", "close", "refresh", ...ACTS]]
|
|
259
|
+
// A kept filter shows its own `/` beside the hints: then `open` outlives the `/ filter` hint.
|
|
260
|
+
: [["filter", "detail", ...(m.filter.query ? ["close"] : []), "refresh", "workspaces"], [...(m.filter.query ? ["open", "filter"] : ["filter", "open"]), "detail", "close", "refresh", "workspaces", ...ACTS]];
|
|
261
|
+
const hints = [...first, ...acts, ...ids.filter((id) => !(asking && id === "close")).map((id) => [id, hint(id)])].filter(([, h]) => h).map(([id, h]) => [id, spansOf(h)]);
|
|
262
|
+
const last = ["help", "quit"].map((id) => hint(id)).filter(Boolean).map(spansOf);
|
|
165
263
|
const spans = [];
|
|
166
264
|
let col = MARGIN;
|
|
167
265
|
if (m.view !== "help" && m.filter.query) {
|
|
168
266
|
// The kept filter has a place of its own width, so the hints stand where they always do;
|
|
169
|
-
// it gives way, down to nothing, before `help` and `quit` do
|
|
170
|
-
|
|
267
|
+
// it gives way, down to nothing, before `help` and `quit` do, and before the hint that
|
|
268
|
+
// stands first while Enter would open an agent (or Esc gives an open up).
|
|
269
|
+
const held = first.length ? first[0][1].width + GAP : 0;
|
|
270
|
+
const slot = Math.min(FILTER_COLS - GAP, edge - MARGIN - span(last) - (last.length ? GAP : 0) - held);
|
|
171
271
|
if (slot >= 2) {
|
|
172
272
|
spans.push({ col, text: lit("/"), style: BOLD, width: 1 }, { col: col + 1, text: shown(m.filter.query), style: BOLD, width: slot - 1 });
|
|
173
273
|
col += slot + GAP;
|
|
174
274
|
}
|
|
175
275
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
276
|
+
// Give up hints until the rest fit: the one kept least first, else (no order of its own) the last.
|
|
277
|
+
let kept = hints;
|
|
278
|
+
const room = () => col + span(kept.map(([, h]) => h)) + (kept.length ? GAP : 0) + span(last) <= edge;
|
|
279
|
+
while (kept.length && !room()) {
|
|
280
|
+
const order = keep ?? kept.map(([id]) => id);
|
|
281
|
+
const least = [...order].reverse().find((id) => kept.some(([k]) => k === id)) ?? kept.at(-1)[0];
|
|
282
|
+
kept = kept.filter(([id]) => id !== least);
|
|
180
283
|
}
|
|
284
|
+
for (const [, h] of kept) { spans.push(...put(h, col)); col += h.width + GAP; }
|
|
181
285
|
for (const h of last) { spans.push(...put(h, col)); col += h.width + GAP; }
|
|
182
286
|
return spans;
|
|
183
287
|
}
|
|
@@ -192,7 +296,7 @@ const placed = (spans, col) => spans.map((span) => ({ ...span, col: span.col + c
|
|
|
192
296
|
export function frame(m, size) {
|
|
193
297
|
if (tooSmall(size)) return { rows: tooSmallRows(size), page: 1, extent: 0, room: 1 };
|
|
194
298
|
const rows = Array.from({ length: size.rows }, () => []);
|
|
195
|
-
const g = layout(m.notice, size, { observed: m.observed, note: m.note, ascii: m.ascii });
|
|
299
|
+
const g = layout(m.notice, size, { observed: m.observed, note: m.note, ascii: m.ascii, outcome: m.outcome });
|
|
196
300
|
const { cols } = size;
|
|
197
301
|
// The switcher is no view of the three: while it is shown, or is under the help, none is current.
|
|
198
302
|
const listing = m.under === "switcher";
|
|
@@ -205,10 +309,17 @@ export function frame(m, size) {
|
|
|
205
309
|
if (m.readAt) { const read = `read ${m.readAt}`; rows[1].push({ col: cols - MARGIN - read.length, text: lit(read), style: DIM, width: read.length }); }
|
|
206
310
|
rows[size.rows - 1] = footer(m, cols);
|
|
207
311
|
|
|
312
|
+
if (m.view === "act" && m.act) {
|
|
313
|
+
rows[2] = rule(cols, m.ascii);
|
|
314
|
+
rows[size.rows - 2] = rule(cols, m.ascii);
|
|
315
|
+
const drawn = act(m, { cols, rows: g.body.rows });
|
|
316
|
+
drawn.rows.forEach((spans, i) => { rows[g.body.top + i] = spans; });
|
|
317
|
+
return { rows, page: Math.max(1, g.page), extent: drawn.extent, room: drawn.room };
|
|
318
|
+
}
|
|
208
319
|
if (m.view === "help") {
|
|
209
320
|
rows[2] = rule(cols, m.ascii);
|
|
210
321
|
rows[size.rows - 2] = rule(cols, m.ascii);
|
|
211
|
-
const drawn = help(m.actions, { cols, rows: g.body.rows }, { top: m.helpTop, ascii: m.ascii });
|
|
322
|
+
const drawn = help(m.actions, { cols, rows: g.body.rows }, { top: m.helpTop, ascii: m.ascii, detachKey: m.detachKey });
|
|
212
323
|
drawn.rows.forEach((spans, i) => { rows[g.body.top + i] = spans; });
|
|
213
324
|
return { rows, page: Math.max(1, g.page), extent: drawn.extent, room: g.body.rows };
|
|
214
325
|
}
|
|
@@ -232,6 +343,7 @@ export function frame(m, size) {
|
|
|
232
343
|
for (const line of g.reason) said.push([{ col: MARGIN, text: line, width: cols - 2 * MARGIN }]);
|
|
233
344
|
}
|
|
234
345
|
for (const line of g.note) said.push([{ col: MARGIN, text: line, width: cols - 2 * MARGIN }]);
|
|
346
|
+
for (const spans of g.outcome) said.push(placed(spans, MARGIN));
|
|
235
347
|
said.slice(0, g.above).forEach((spans, i) => { rows[g.body.top + i] = spans; });
|
|
236
348
|
const paged = !g.wide && m.focus === "detail" && m.detail;
|
|
237
349
|
// Two panes only over an observed deployment: with no instance there is nothing to put beside the list.
|
|
@@ -29,10 +29,8 @@ export function keyText(label) {
|
|
|
29
29
|
* kernel's own usage, so the help cannot name a command that does not exist. A later version
|
|
30
30
|
* removes a line when it adds the act. */
|
|
31
31
|
export const NOT_YET = Object.freeze([
|
|
32
|
-
Object.freeze({ what: "open an agent
|
|
33
|
-
Object.freeze({ what: "
|
|
34
|
-
Object.freeze({ what: "start or restart an agent", command: "oats session start --home <home>" }),
|
|
35
|
-
Object.freeze({ what: "retire an agent", command: "oats retire <instance>" }),
|
|
32
|
+
Object.freeze({ what: "open an agent in its own tmux window", command: "oats session attach --home <home>" }),
|
|
33
|
+
Object.freeze({ what: "start with another harness or model", command: "oats session start --home <home>" }),
|
|
36
34
|
Object.freeze({ what: "add a machine to this workspace", command: "oats server connect <id> --ssh <alias>" }),
|
|
37
35
|
Object.freeze({ what: "check a machine", command: "oats server check <id>" }),
|
|
38
36
|
Object.freeze({ what: "remove a machine", command: "oats server remove <id>" }),
|
|
@@ -67,7 +65,10 @@ const flow = (pieces, room) => pieces.reduce((lines, piece) => {
|
|
|
67
65
|
* piece wider than that column puts every meaning under its entry instead, so no row is cut at
|
|
68
66
|
* the smallest width the frame draws at. */
|
|
69
67
|
function table(pairs, cols, look) {
|
|
70
|
-
// An entry is the TUI's own word, or text made elsewhere with its width (a key's label).
|
|
68
|
+
// An entry is the TUI's own word, or text made elsewhere with its width (a key's label). A
|
|
69
|
+
// third member makes rows of its own under the entry's meaning: given the meaning's column and
|
|
70
|
+
// the cells it has, it answers rows of spans placed from column 0.
|
|
71
|
+
const under = new Map(pairs.map(([, pieces, more]) => [pieces, more]));
|
|
71
72
|
pairs = pairs.map(([left, pieces]) => [typeof left === "string" ? { text: lit(left), width: left.length } : left, pieces]);
|
|
72
73
|
const entry = (left) => ({ col: INDENT, text: left.text, width: left.width, ...(look ? { style: look } : {}) });
|
|
73
74
|
const column = INDENT + Math.max(...pairs.map(([left]) => left.width)) + GAP;
|
|
@@ -75,9 +76,36 @@ function table(pairs, cols, look) {
|
|
|
75
76
|
const at = stacked ? INDENT + 2 : column;
|
|
76
77
|
return pairs.flatMap(([left, pieces]) => {
|
|
77
78
|
const lines = flow(pieces, cols - at).map((text) => ({ col: at, text: lit(text) }));
|
|
78
|
-
|
|
79
|
+
const more = (under.get(pieces)?.(cols - at) ?? []).map((spans) => spans.map((span) => ({ ...span, col: span.col + at })));
|
|
80
|
+
return [...(stacked ? [[entry(left)], ...lines.map((line) => [line])] : lines.map((line, i) => (i === 0 ? [entry(left), line] : [line]))), ...more];
|
|
79
81
|
});
|
|
80
82
|
}
|
|
83
|
+
|
|
84
|
+
/** The TUI's own sentences under the line of `open` in the list of instances: the kernel's rule
|
|
85
|
+
* about tmux's copy mode, and where the keys that can be chosen are listed (the help does not
|
|
86
|
+
* restate the grammar). */
|
|
87
|
+
export const OPEN_RULES = Object.freeze([
|
|
88
|
+
"A key that tmux's copy mode binds leaves the viewer once the mode is left.",
|
|
89
|
+
"docs/execution-targets.md has the keys that can be chosen.",
|
|
90
|
+
]);
|
|
91
|
+
/** The rows under the line of `open`, in `room` cells: the key that leaves an agent's terminal
|
|
92
|
+
* (tui.json's, text from outside), then OPEN_RULES, each sentence on as many rows as it needs. */
|
|
93
|
+
function openRows(detachKey, room) {
|
|
94
|
+
const key = keyText(detachKey), said = "brings oats tui back; the agent keeps running.";
|
|
95
|
+
const first = flow(words(said), Math.max(1, room - key.width - 1));
|
|
96
|
+
return [
|
|
97
|
+
[{ col: 0, text: key.text, width: key.width }, { col: key.width + 1, text: lit(first[0]) }],
|
|
98
|
+
...first.slice(1).map((text) => [{ col: key.width + 1, text: lit(text) }]),
|
|
99
|
+
...OPEN_RULES.flatMap((sentence) => flow(words(sentence), room).map((text) => [{ col: 0, text: lit(text) }])),
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
/** The TUI's own sentences under the line of the last act: how a confirmation is worked, and that
|
|
103
|
+
* what it sent is never ended by the TUI. */
|
|
104
|
+
export const ACT_RULES = Object.freeze([
|
|
105
|
+
"Each act opens a confirmation with Cancel chosen: move to the act with Left/Right or Tab, then press Enter.",
|
|
106
|
+
"Esc closes a confirmation; an act it sent goes on, also after oats tui quits.",
|
|
107
|
+
]);
|
|
108
|
+
const actRows = (room) => ACT_RULES.flatMap((sentence) => flow(words(sentence), room).map((text) => [{ col: 0, text: lit(text) }]));
|
|
81
109
|
const heading = (text) => [{ col: INDENT, text: lit(text), style: TITLE }];
|
|
82
110
|
/** Sentences, each from the left margin on as many rows as it needs, with that margin kept at
|
|
83
111
|
* the right too: its later rows are set in, so the next sentence is seen to start. */
|
|
@@ -88,14 +116,21 @@ const sentences = (list, cols) => list.flatMap((sentence) => {
|
|
|
88
116
|
|
|
89
117
|
/** Every row of the help for an area `cols` wide, before it is scrolled. Unbound actions are
|
|
90
118
|
* listed as such: the table can be changed by the user's tui.json, and the help says what is so
|
|
91
|
-
* now.
|
|
92
|
-
|
|
119
|
+
* now. An action that does one thing in each view has a line per view, its key on each; under
|
|
120
|
+
* the line of opening an agent stand the key that leaves its terminal (`detachKey`, tui.json's
|
|
121
|
+
* `open.detachKey`) and the rules of OPEN_RULES; under the line of the last act, ACT_RULES. */
|
|
122
|
+
export function helpRows(actions, ascii, cols = 100, detachKey = null) {
|
|
93
123
|
const marks = marksOf(ascii);
|
|
94
124
|
const closing = keyText(["close", "help"].map((id) => actions.find((action) => action.id === id)).filter((action) => action?.keys.length).map((action) => keyLabel(action.keys[0])).join(" or "));
|
|
95
125
|
return [
|
|
96
126
|
heading("Keys"),
|
|
97
127
|
[],
|
|
98
|
-
...table(actions.
|
|
128
|
+
...table(actions.flatMap((action) => {
|
|
129
|
+
const left = action.keys.length ? keyText(keysLabel(action)) : "(no key)";
|
|
130
|
+
if (!action.views) return [[left, words(action.label)]];
|
|
131
|
+
return action.views.map(([view, said]) => [left, words(said), action.id === "open" && view === "instances" && detachKey !== null ? (room) => openRows(detachKey, room)
|
|
132
|
+
: action.id === "restart" ? actRows : undefined]);
|
|
133
|
+
}), cols, KEYS),
|
|
99
134
|
[],
|
|
100
135
|
heading("Marks"),
|
|
101
136
|
[],
|
|
@@ -129,8 +164,8 @@ export function helpRows(actions, ascii, cols = 100) {
|
|
|
129
164
|
|
|
130
165
|
/** `{ rows, extent }`: `size.rows` rows for an area `size.cols` wide, scrolled to `top`, and how
|
|
131
166
|
* many rows the whole help has. The movement keys scroll it. */
|
|
132
|
-
export function help(actions, size, { top = 0, ascii = false } = {}) {
|
|
133
|
-
const all = helpRows(actions, ascii, size.cols);
|
|
167
|
+
export function help(actions, size, { top = 0, ascii = false, detachKey = null } = {}) {
|
|
168
|
+
const all = helpRows(actions, ascii, size.cols, detachKey);
|
|
134
169
|
const rows = Array.from({ length: size.rows }, () => []);
|
|
135
170
|
const win = windowOf({ top, count: all.length, height: size.rows });
|
|
136
171
|
all.slice(win.top, win.top + win.size).forEach((spans, i) => { rows[i] = spans; });
|
|
@@ -60,8 +60,8 @@ 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.10.
|
|
64
|
-
oats.okf: v5.0
|
|
63
|
+
oats.framework: v1.10.2 # bare versions resolve through the official catalog
|
|
64
|
+
oats.okf: v5.2.0
|
|
65
65
|
defaults:
|
|
66
66
|
capabilities: { oats.core: { from: package } }
|
|
67
67
|
knowledge: { oats.okf: { from: package } }
|
|
@@ -192,7 +192,10 @@ native configuration writers quiescent. Use `codex` or `all` for those selected
|
|
|
192
192
|
harnesses; inspect the exact canonical root and effective native file first.
|
|
193
193
|
The command changes only deployment-root trust and records an audit under
|
|
194
194
|
`D/.agents/harness-trust.jsonl`. A failure can retain an applied native change;
|
|
195
|
-
inspect its per-file outcome and audit before retrying.
|
|
195
|
+
inspect its per-file outcome and audit before retrying. A refused entry's
|
|
196
|
+
`problem` names the check that refused its file; for a macOS `@` marker, accept
|
|
197
|
+
the harness's own folder-trust dialog instead and check the `harness-trust`
|
|
198
|
+
item of `oats readiness` (see "When the writer refuses"). Nested Git boundaries
|
|
196
199
|
can prevent Claude inheritance. See [harness trust](../../docs/harness-trust.md). Folder-trust
|
|
197
200
|
and API-key questions remain unexpected and blocked. The confirmation is
|
|
198
201
|
answered with one Enter only when the screen equals an entry of the tolerance
|