@awebai/oats 0.63.0 → 0.65.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 +14 -1
- package/bin/oats.mjs +158 -26
- package/docs/desktop-cli-api.md +127 -3
- package/docs/desktop.md +14 -5
- package/docs/execution-targets.md +9 -5
- package/docs/first-team.md +6 -0
- package/docs/implementation.md +17 -3
- package/docs/official-catalog.md +1 -1
- package/docs/packages.md +5 -5
- package/docs/release-notes/v0.64.0.md +105 -0
- package/docs/release-notes/v0.65.0.md +187 -0
- package/docs/souls-and-instances.md +26 -6
- package/docs/tui.md +416 -238
- package/docs/upgrading.md +2 -1
- package/docs/workspaces.md +125 -1
- package/lib/core.mjs +43 -11
- package/lib/deployments.mjs +325 -0
- package/lib/resolved-deployment.mjs +37 -0
- package/lib/session-input.mjs +12 -2
- package/lib/workspace.mjs +2 -0
- package/package-catalog.json +1 -1
- package/package.json +1 -1
- package/packages/client/cli-locator.mjs +2 -2
- package/packages/client/deployment-label.mjs +2 -2
- package/packages/client/deployment-list-cli.mjs +98 -0
- package/packages/client/deployment-list.mjs +91 -0
- package/packages/client/instance-tree.mjs +53 -3
- package/packages/client/keymap.mjs +106 -0
- package/packages/client/own-codes.mjs +2 -0
- package/packages/client/panel-views.mjs +1 -1
- package/packages/client/roster-sections.mjs +22 -6
- package/packages/client/workspace-admission.mjs +2 -1
- package/packages/tui/README.md +4 -4
- package/packages/tui/lib/actions.mjs +29 -5
- package/packages/tui/lib/client.mjs +3 -1
- package/packages/tui/lib/config.mjs +21 -14
- package/packages/tui/lib/main.mjs +108 -31
- package/packages/tui/lib/model.mjs +71 -41
- package/packages/tui/lib/read.mjs +15 -45
- package/packages/tui/lib/store.mjs +158 -39
- package/packages/tui/lib/term/through.mjs +40 -18
- package/packages/tui/lib/views/act.mjs +17 -13
- package/packages/tui/lib/views/frame.mjs +418 -421
- package/packages/tui/lib/views/help.mjs +41 -19
- package/packages/tui/lib/views/instances.mjs +38 -9
- package/packages/tui/lib/views/switcher.mjs +65 -21
- package/skills/oats-getting-started/SKILL.md +440 -170
package/lib/session-input.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { randomUUID } from "node:crypto";
|
|
|
5
5
|
import { performance } from "node:perf_hooks";
|
|
6
6
|
|
|
7
7
|
const shells = new Set(["sh", "bash", "zsh", "fish", "dash", "ksh", "login"]);
|
|
8
|
+
const isShellProcess = (name) => shells.has(basename(name).replace(/^-/, ""));
|
|
8
9
|
function tmux(target, args, { exec = execFileSync, input, timeout = 10000, killSignal } = {}) {
|
|
9
10
|
// launchd does not supply a UTF-8 locale. In that environment tmux replaces
|
|
10
11
|
// the tab delimiters in list-panes output with underscores unless forced.
|
|
@@ -55,7 +56,16 @@ export function createSessionPaneInspector(io) {
|
|
|
55
56
|
throw new Error("invalid tmux pane response");
|
|
56
57
|
}
|
|
57
58
|
let state = dead === "1" ? "stopped" : "unknown";
|
|
58
|
-
|
|
59
|
+
let shell = shells.has(command);
|
|
60
|
+
if (dead === "0" && (command === "" || command === "unset") && /^\d+$/.test(panePid)) {
|
|
61
|
+
// A missing tmux label can still be a fallback shell. Only the pane's
|
|
62
|
+
// own comm can establish that; an optional failed read stays unknown.
|
|
63
|
+
try {
|
|
64
|
+
const own = readProcesses().find(([, pid]) => pid === panePid);
|
|
65
|
+
shell = own ? isShellProcess(own[3]) : false;
|
|
66
|
+
} catch { /* missing process information is not proof of a fallback shell */ }
|
|
67
|
+
}
|
|
68
|
+
if (dead === "0" && shell) {
|
|
59
69
|
// macOS tmux can report the wrapper shell while the harness is its child.
|
|
60
70
|
// Only a shell with no non-shell descendants is a fallback prompt.
|
|
61
71
|
if (!/^\d+$/.test(panePid)) throw new Error("tmux returned no pane process id");
|
|
@@ -67,7 +77,7 @@ export function createSessionPaneInspector(io) {
|
|
|
67
77
|
for (const [, pid, parent, name] of processes) {
|
|
68
78
|
if (descendants.has(parent) && !descendants.has(pid)) {
|
|
69
79
|
descendants.add(pid); changed = true;
|
|
70
|
-
if (!
|
|
80
|
+
if (!isShellProcess(name)) active = true;
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
}
|
package/lib/workspace.mjs
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { readFileSync, existsSync } from "node:fs";
|
|
14
14
|
import { dirname, join, resolve } from "node:path";
|
|
15
15
|
import { recordLocalInput } from "./local-inputs.mjs";
|
|
16
|
+
import { resolvedDeployment } from "./resolved-deployment.mjs";
|
|
16
17
|
import { parseConfigData } from "./config-data.mjs";
|
|
17
18
|
import { oatsError } from "./errors.mjs";
|
|
18
19
|
import * as defaultRemote from "./remote.mjs";
|
|
@@ -431,6 +432,7 @@ export function loadLocal(dir) {
|
|
|
431
432
|
else {
|
|
432
433
|
if (legacy.length) throw fail("E_CONFIG_BROKEN", `${legacy.join(", ")}: ${LEGACY_CONFIG_MIGRATION}`, { dir: resolve(dir), deployment: current, files: legacy, reason: "legacy-config" });
|
|
433
434
|
const origin = { kind: "local", path: candidate };
|
|
435
|
+
resolvedDeployment(current);
|
|
434
436
|
const bytes = readFileSync(candidate);
|
|
435
437
|
recordLocalInput(candidate, bytes);
|
|
436
438
|
const read = readDeclaration("local", bytes, origin);
|
package/package-catalog.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awebai/oats",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"description": "OATS (Open Agent Team Specification) — durable souls, disposable instances, targetable capability packages, and the runtime-neutral oats CLI/kernel.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// Every candidate is canonicalized to an absolute executable and accepted
|
|
14
14
|
// ONLY if executable and `<bin> version --json` returns the v1 probe:
|
|
15
15
|
// {"schemaVersion":1,"name":"@awebai/oats","version":"0.24.x","desktopApi":1}
|
|
16
|
-
// Desktop accepts desktopApi === 1 and semver >=0.26.0 <0.
|
|
16
|
+
// Desktop accepts desktopApi === 1 and semver >=0.26.0 <0.66.0 (the band is
|
|
17
17
|
// spelled ONCE, in ACCEPT_RANGE below — this line only paraphrases it).
|
|
18
18
|
// API version — not source adjacency — is authoritative.
|
|
19
19
|
//
|
|
@@ -52,7 +52,7 @@ export const DESKTOP_API = 1;
|
|
|
52
52
|
// carry a `description` for every kind and `<kind> update <id> --description`
|
|
53
53
|
// sets one (feature `automation-descriptions`, which gates the Desktop's
|
|
54
54
|
// summary writes). The Desktop v1 surface is otherwise unchanged.
|
|
55
|
-
export const ACCEPT_RANGE = { min: [0, 26, 0], maxExclusive: [0,
|
|
55
|
+
export const ACCEPT_RANGE = { min: [0, 26, 0], maxExclusive: [0, 66, 0] };
|
|
56
56
|
/** The band as humans read it — derived, never hand-spelled, so the probe
|
|
57
57
|
* rejection reason, the backend's /api status and the degradation card can
|
|
58
58
|
* never disagree with the numbers actually enforced above. */
|
|
@@ -23,7 +23,7 @@ export function shortPath(path, { home = null } = {}) {
|
|
|
23
23
|
return parts.length > 2 ? `…/${parts.slice(-2).join('/')}` : shown;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** The two halves of a deployment's label: `{ machine, path }` ("This Mac", "~/
|
|
26
|
+
/** The two halves of a deployment's label: `{ machine, path }` ("This Mac", "~/acme"; path ''
|
|
27
27
|
* when none). Headings style them apart: a machine label may be uppercased, a path never. */
|
|
28
28
|
export function deploymentLabelParts(deployment, terms) {
|
|
29
29
|
requireTerms(terms, 'deploymentLabelParts');
|
|
@@ -32,7 +32,7 @@ export function deploymentLabelParts(deployment, terms) {
|
|
|
32
32
|
return { machine, path };
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/** `This Mac · ~/
|
|
35
|
+
/** `This Mac · ~/acme`, `altair · ~/northwind`. */
|
|
36
36
|
export function deploymentLabel(deployment, terms) {
|
|
37
37
|
requireTerms(terms, 'deploymentLabel');
|
|
38
38
|
const { machine, path } = deploymentLabelParts(deployment, terms);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** This computer's deployments list, through the kernel (awebai/oats#1390): the four `oats deployments`
|
|
2
|
+
* verbs a client runs, fixed argv, bounded output, the instance environment scrubbed. The answers are
|
|
3
|
+
* read by deployment-list.mjs; only the kernel's JSON crosses back, and a refusal is its code and message.
|
|
4
|
+
* list → `oats deployments --json` (cwd /)
|
|
5
|
+
* add → `oats deployments add <path> --via <client> --json` (cwd <path>)
|
|
6
|
+
* remove → `oats deployments remove <path> --json` (cwd /)
|
|
7
|
+
* import → `oats deployments import --from <client> <path>… --json` (cwd /; no path is a valid call;
|
|
8
|
+
* each path absolute as the client saved it, which the kernel canonicalizes)
|
|
9
|
+
* Each needs the probe's `deployments-list` feature: without it nothing runs, and nothing falls back to
|
|
10
|
+
* looking at the disk. `/` is the working directory of the verbs that name no deployment, so a client
|
|
11
|
+
* started inside one never has it resolved by the kernel on the way. */
|
|
12
|
+
import { execFile } from 'node:child_process';
|
|
13
|
+
import { cliEnvironment } from './cli-environment.mjs';
|
|
14
|
+
import { withoutInstanceVariables } from './kernel-environment.mjs';
|
|
15
|
+
import { absolutePath, deploymentsListSupported, listedPath, readDeploymentAdd, readDeploymentImport, readDeploymentList, readDeploymentRemove } from './deployment-list.mjs';
|
|
16
|
+
|
|
17
|
+
/** The kernel waits up to 3 s for the list's lock; the rest is a node start and a small file. */
|
|
18
|
+
export const DEPLOYMENT_LIST_TIMEOUT = 15_000;
|
|
19
|
+
/** The list file is at most 1 MiB; its answer adds a name and a state per row. */
|
|
20
|
+
export const DEPLOYMENT_LIST_MAX_BUFFER = 4 * 1024 * 1024;
|
|
21
|
+
/** The most paths one import names: an argv bound, far above any saved set. A longer import is refused
|
|
22
|
+
* whole, never cut: the caller keeps what it would import. */
|
|
23
|
+
export const DEPLOYMENT_IMPORT_MAX = 2000;
|
|
24
|
+
/** The clients the kernel takes in `--via` and `--from`. */
|
|
25
|
+
const CLIENTS = ['desktop', 'tui'];
|
|
26
|
+
|
|
27
|
+
const messages = Object.freeze({
|
|
28
|
+
E_CLI_UNAVAILABLE: 'Choose a compatible installed OATS CLI first.',
|
|
29
|
+
E_DEPLOYMENTS_FEATURE: "This oats can't list this computer's deployments. Update oats.",
|
|
30
|
+
E_BAD_ARGS: "The request to this computer's deployments list was not valid.",
|
|
31
|
+
E_CLI_FAILED: "The installed OATS CLI could not change or read this computer's deployments list.",
|
|
32
|
+
E_CLI_PROTOCOL: "The installed OATS CLI returned an invalid answer about this computer's deployments.",
|
|
33
|
+
E_CLI_TIMEOUT: "The installed OATS CLI did not answer about this computer's deployments in time.",
|
|
34
|
+
E_CLI_OUTPUT_LIMIT: "The installed OATS CLI's answer about this computer's deployments was too large.",
|
|
35
|
+
});
|
|
36
|
+
export const DEPLOYMENT_LIST_FAILURE_CODES = Object.freeze(Object.keys(messages));
|
|
37
|
+
const failure = (code) => ({ ok: false, reason: { code, message: messages[code] } });
|
|
38
|
+
const record = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
39
|
+
|
|
40
|
+
/** The argv and working directory of one verb, or null for a request that could not be one. */
|
|
41
|
+
export function deploymentListArgv(options) {
|
|
42
|
+
if (!record(options)) return null;
|
|
43
|
+
const keys = Object.keys(options), only = (...allowed) => keys.every((key) => allowed.includes(key));
|
|
44
|
+
switch (options.action) {
|
|
45
|
+
case 'list': return only('action') ? { argv: ['deployments', '--json'], cwd: '/' } : null;
|
|
46
|
+
case 'add':
|
|
47
|
+
if (!only('action', 'path', 'via') || !listedPath(options.path) || !CLIENTS.includes(options.via)) return null;
|
|
48
|
+
return { argv: ['deployments', 'add', options.path, '--via', options.via, '--json'], cwd: options.path };
|
|
49
|
+
case 'remove':
|
|
50
|
+
if (!only('action', 'path') || !listedPath(options.path)) return null;
|
|
51
|
+
return { argv: ['deployments', 'remove', options.path, '--json'], cwd: '/' };
|
|
52
|
+
case 'import':
|
|
53
|
+
if (!only('action', 'from', 'paths') || !CLIENTS.includes(options.from) || !Array.isArray(options.paths)
|
|
54
|
+
|| options.paths.length > DEPLOYMENT_IMPORT_MAX || !options.paths.every(absolutePath)) return null;
|
|
55
|
+
return { argv: ['deployments', 'import', '--from', options.from, ...options.paths, '--json'], cwd: '/' };
|
|
56
|
+
default: return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const READERS = { list: readDeploymentList, add: readDeploymentAdd, remove: readDeploymentRemove, import: readDeploymentImport };
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Run one verb. `cli` is the client's accepted probe (`{ ok, bin, features }`); `io.exec` its own `execFile`
|
|
64
|
+
* (cli-adapter.mjs `runJson` says what it must keep).
|
|
65
|
+
* @returns {Promise<{ ok: true, value: object } | { ok: false, reason: { code: string, message: string } }>}
|
|
66
|
+
* `value` is what deployment-list.mjs reads from the answer (the list's `{ ok: true, rows }`, the add's `{ path, added }`, …).
|
|
67
|
+
*/
|
|
68
|
+
export function cliDeploymentList(cli, options, io = {}) {
|
|
69
|
+
if (cli?.ok !== true || typeof cli.bin !== 'string' || !cli.bin.startsWith('/')) return Promise.resolve(failure('E_CLI_UNAVAILABLE'));
|
|
70
|
+
if (!deploymentsListSupported(cli)) return Promise.resolve(failure('E_DEPLOYMENTS_FEATURE'));
|
|
71
|
+
const plan = deploymentListArgv(options);
|
|
72
|
+
if (!plan) return Promise.resolve(failure('E_BAD_ARGS'));
|
|
73
|
+
const env = withoutInstanceVariables(cliEnvironment(io.env ?? process.env));
|
|
74
|
+
return new Promise((done) => {
|
|
75
|
+
const fail = (code) => done(failure(code));
|
|
76
|
+
try {
|
|
77
|
+
(io.exec ?? execFile)(cli.bin, plan.argv, { cwd: plan.cwd, env, shell: false, encoding: 'utf8', timeout: DEPLOYMENT_LIST_TIMEOUT, maxBuffer: DEPLOYMENT_LIST_MAX_BUFFER }, (error, stdout) => {
|
|
78
|
+
if (error?.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') return fail('E_CLI_OUTPUT_LIMIT');
|
|
79
|
+
if (error?.killed) return fail('E_CLI_TIMEOUT');
|
|
80
|
+
if (typeof stdout !== 'string') return fail(error ? 'E_CLI_FAILED' : 'E_CLI_PROTOCOL');
|
|
81
|
+
let document;
|
|
82
|
+
try { document = JSON.parse(stdout); } catch { return fail(error ? 'E_CLI_FAILED' : 'E_CLI_PROTOCOL'); }
|
|
83
|
+
if (!record(document) || document.schemaVersion !== 1 || typeof document.ok !== 'boolean') return fail('E_CLI_PROTOCOL');
|
|
84
|
+
if (document.ok === false) {
|
|
85
|
+
const reason = document.error;
|
|
86
|
+
if (!record(reason) || typeof reason.code !== 'string' || !/^E_[A-Z0-9_]{1,62}$/.test(reason.code)
|
|
87
|
+
|| typeof reason.message !== 'string' || !reason.message || reason.message.length > 8192) return fail('E_CLI_PROTOCOL');
|
|
88
|
+
// A refusal is a nonzero exit; a success exit cannot carry one.
|
|
89
|
+
return error ? done({ ok: false, reason: { code: reason.code, message: reason.message } }) : fail('E_CLI_PROTOCOL');
|
|
90
|
+
}
|
|
91
|
+
if (error) return fail('E_CLI_FAILED'); // success is exit 0 only
|
|
92
|
+
const value = READERS[options.action](document.result);
|
|
93
|
+
if (!value || value.ok === false) return fail('E_CLI_PROTOCOL');
|
|
94
|
+
done({ ok: true, value });
|
|
95
|
+
});
|
|
96
|
+
} catch { fail('E_CLI_FAILED'); }
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** This computer's deployments, as the kernel lists them (awebai/oats#1390): the `result` of
|
|
2
|
+
* `oats deployments --json` (feature `deployments-list`, `deploymentsApi: 1`) read into rows of
|
|
3
|
+
* `{ path, name, state }`. The list is the kernel's, kept in `~/.oats/config/deployments.json`; a client
|
|
4
|
+
* reads it, never the file, and changes it only through `oats deployments add|remove|import`.
|
|
5
|
+
*
|
|
6
|
+
* A row's `state` comes from the kernel's existence check (nothing of the deployment is read): one of
|
|
7
|
+
* DEPLOYMENT_STATES. Each client puts the four states into its own words. A row is a suggestion: a
|
|
8
|
+
* client that opens one validates it again first (workspace-admission.mjs).
|
|
9
|
+
*
|
|
10
|
+
* The document's shape is closed (docs/desktop-cli-api.md): a key, a state or a `via` this reader does
|
|
11
|
+
* not know, a duplicate path or a path that is not absolute refuses the whole document. It is never
|
|
12
|
+
* guessed at, and never read in part. The answers of the writes are read here too. Nothing here keeps
|
|
13
|
+
* state between calls. */
|
|
14
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
15
|
+
|
|
16
|
+
/** The probe feature that makes `oats deployments` exist. */
|
|
17
|
+
export const DEPLOYMENTS_LIST_FEATURE = 'deployments-list';
|
|
18
|
+
/** The integer the list document carries. */
|
|
19
|
+
export const DEPLOYMENTS_API = 1;
|
|
20
|
+
/** Every state a row can have: `ok` (a deployment), `missing` (the path is gone, or on a volume not
|
|
21
|
+
* mounted), `not-a-deployment` (the folder has no oats-local.yaml), `unreadable` (the check failed). */
|
|
22
|
+
export const DEPLOYMENT_STATES = Object.freeze(['ok', 'missing', 'not-a-deployment', 'unreadable']);
|
|
23
|
+
/** How a row joined the list: information only, never acted on. */
|
|
24
|
+
export const DEPLOYMENT_VIAS = Object.freeze(['onboard', 'tui', 'desktop', 'cli', 'import:agents-dir', 'import:desktop']);
|
|
25
|
+
|
|
26
|
+
const DOCUMENT_KEYS = ['deploymentsApi', 'file', 'deployments', 'imports'];
|
|
27
|
+
const ROW_KEYS = ['path', 'name', 'state', 'addedAt', 'via'];
|
|
28
|
+
|
|
29
|
+
const record = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
30
|
+
const exactKeys = (value, keys) => Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
|
|
31
|
+
const text = (value) => typeof value === 'string' && value.length > 0 && !value.includes('\0');
|
|
32
|
+
/** An absolute path as the kernel stores it: canonical in form (no `.`, `..`, `//` or trailing `/`). */
|
|
33
|
+
export const listedPath = (value) => text(value) && isAbsolute(value) && resolve(value) === value;
|
|
34
|
+
/** An absolute path in any form: what an import names, as a client saved it (the kernel canonicalizes it). */
|
|
35
|
+
export const absolutePath = (value) => text(value) && isAbsolute(value);
|
|
36
|
+
|
|
37
|
+
/** Whether a probe (`oats version --json`, accepted) declares the list. */
|
|
38
|
+
export const deploymentsListSupported = (cli) => Array.isArray(cli?.features) && cli.features.includes(DEPLOYMENTS_LIST_FEATURE);
|
|
39
|
+
|
|
40
|
+
const refused = (reason) => ({ ok: false, rows: [], reason });
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {unknown} result the envelope's `result` of `oats deployments --json`
|
|
44
|
+
* @returns {{ ok: true, rows: Array<{ path: string, name: string, state: string }> } | { ok: false, rows: [], reason: string }}
|
|
45
|
+
* rows in the kernel's order; `reason` says, for a log, why the document was refused.
|
|
46
|
+
*/
|
|
47
|
+
export function readDeploymentList(result) {
|
|
48
|
+
if (!record(result)) return refused('the list is not an object');
|
|
49
|
+
if (result.deploymentsApi !== DEPLOYMENTS_API) return refused(`deploymentsApi is not ${DEPLOYMENTS_API}`);
|
|
50
|
+
if (!exactKeys(result, DOCUMENT_KEYS)) return refused('the list has keys this client does not read');
|
|
51
|
+
if (!listedPath(result.file)) return refused('file is not an absolute path');
|
|
52
|
+
if (!record(result.imports) || !Object.values(result.imports).every(text)) return refused('imports is not a set of markers');
|
|
53
|
+
if (!Array.isArray(result.deployments)) return refused('deployments is not a list');
|
|
54
|
+
const rows = [], seen = new Set();
|
|
55
|
+
for (const row of result.deployments) {
|
|
56
|
+
if (!record(row) || !exactKeys(row, ROW_KEYS)) return refused('a row has keys this client does not read');
|
|
57
|
+
if (!listedPath(row.path)) return refused('a row path is not an absolute path');
|
|
58
|
+
if (seen.has(row.path)) return refused(`${row.path} is listed twice`);
|
|
59
|
+
if (!text(row.name)) return refused(`${row.path} has no name`);
|
|
60
|
+
if (!DEPLOYMENT_STATES.includes(row.state)) return refused(`${row.path} has a state this client does not know`);
|
|
61
|
+
if (!text(row.addedAt)) return refused(`${row.path} has no addedAt`);
|
|
62
|
+
if (!DEPLOYMENT_VIAS.includes(row.via)) return refused(`${row.path} has a via this client does not know`);
|
|
63
|
+
seen.add(row.path);
|
|
64
|
+
rows.push({ path: row.path, name: row.name, state: row.state });
|
|
65
|
+
}
|
|
66
|
+
return { ok: true, rows };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* The answers of the three writes, each a closed `result` like the list's. Each reader answers its
|
|
70
|
+
* fields, or null for a document it cannot read. */
|
|
71
|
+
|
|
72
|
+
/** `oats deployments add <dir> --json`: `{ path, added }`; `added` is false when the path was listed already. */
|
|
73
|
+
export function readDeploymentAdd(result) {
|
|
74
|
+
return record(result) && exactKeys(result, ['path', 'added']) && listedPath(result.path) && typeof result.added === 'boolean'
|
|
75
|
+
? { path: result.path, added: result.added } : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** `oats deployments remove <path> --json`: `{ path, removed }`; `removed` is false when the path was not listed. */
|
|
79
|
+
export function readDeploymentRemove(result) {
|
|
80
|
+
return record(result) && exactKeys(result, ['path', 'removed']) && listedPath(result.path) && typeof result.removed === 'boolean'
|
|
81
|
+
? { path: result.path, removed: result.removed } : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** `oats deployments import --from <client> <path>… --json`: `{ imported: true, at, added: [path…] }` the first
|
|
85
|
+
* time, `{ imported: false, at }` after it (`at` is the import's marker). Either answer means the import is done. */
|
|
86
|
+
export function readDeploymentImport(result) {
|
|
87
|
+
if (!record(result) || !text(result.at)) return null;
|
|
88
|
+
if (result.imported === false) return exactKeys(result, ['imported', 'at']) ? { imported: false, at: result.at, added: [] } : null;
|
|
89
|
+
if (result.imported !== true || !exactKeys(result, ['imported', 'at', 'added']) || !Array.isArray(result.added) || !result.added.every(absolutePath)) return null;
|
|
90
|
+
return { imported: true, at: result.at, added: [...result.added] };
|
|
91
|
+
}
|
|
@@ -185,6 +185,51 @@ export function clusterInstances(instances, { links = instanceLinks } = {}) {
|
|
|
185
185
|
return clusters.sort((a, b) => rank(a.head, b.head)).map(({ head: _head, ...c }) => c);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
/** `clusterInstances` output ordered by last focus (#1383; the command palette's order, never the sidebar's).
|
|
189
|
+
* `lastFocus` is Map<instanceId, time>. A node's key is the latest focus time over the node and all of its
|
|
190
|
+
* descendants; a node with no focus anywhere in its subtree has none. Clusters are ordered by their key, most
|
|
191
|
+
* recent first, and so is each set of nodes at one level of a cluster: its depth-0 roots, and the children of
|
|
192
|
+
* each parent. Nodes without a key follow every node with one, in their input order (a stable sort), so an
|
|
193
|
+
* empty record returns the input order. A child stays under its parent: each cluster is walked again in
|
|
194
|
+
* pre-order, every depth unchanged. Parentage is read from the pre-order and the depths alone (a node's
|
|
195
|
+
* children are the following rows one level deeper, until a row at its depth or above), never from names: the
|
|
196
|
+
* tree was built by identity, and a malformed cycle's depth-0 leftovers are roots like any other. Returns new
|
|
197
|
+
* cluster objects over the same rows; the input is not mutated. */
|
|
198
|
+
export function recencyOrder(clusters, lastFocus) {
|
|
199
|
+
const timeOf = (inst) => {
|
|
200
|
+
const time = lastFocus?.get(instanceId(inst));
|
|
201
|
+
return Number.isFinite(time) ? time : null;
|
|
202
|
+
};
|
|
203
|
+
const recentFirst = (a, b) => (a.key === null ? (b.key === null ? 0 : 1) : b.key === null ? -1 : b.key - a.key);
|
|
204
|
+
const ranked = clusters.map((cluster) => {
|
|
205
|
+
const roots = [];
|
|
206
|
+
const open = []; // the path from a root to the last row read
|
|
207
|
+
for (const inst of cluster.instances) {
|
|
208
|
+
const node = { inst, depth: inst.depth || 0, key: timeOf(inst), kids: [] };
|
|
209
|
+
while (open.length && open.at(-1).depth >= node.depth) open.pop();
|
|
210
|
+
(open.length ? open.at(-1).kids : roots).push(node);
|
|
211
|
+
open.push(node);
|
|
212
|
+
}
|
|
213
|
+
// Keys bottom-up, then each level sorted (stable) and walked again in pre-order.
|
|
214
|
+
const keyOf = (node) => {
|
|
215
|
+
for (const kid of node.kids) {
|
|
216
|
+
const key = keyOf(kid);
|
|
217
|
+
if (key !== null && (node.key === null || key > node.key)) node.key = key;
|
|
218
|
+
}
|
|
219
|
+
return node.key;
|
|
220
|
+
};
|
|
221
|
+
const instances = [];
|
|
222
|
+
const walk = (nodes) => {
|
|
223
|
+
for (const node of [...nodes].sort(recentFirst)) { instances.push(node.inst); walk(node.kids); }
|
|
224
|
+
};
|
|
225
|
+
const top = { key: null, kids: roots };
|
|
226
|
+
keyOf(top);
|
|
227
|
+
walk(roots);
|
|
228
|
+
return { key: top.key, cluster: { ...cluster, instances } };
|
|
229
|
+
});
|
|
230
|
+
return ranked.sort(recentFirst).map(({ cluster }) => cluster);
|
|
231
|
+
}
|
|
232
|
+
|
|
188
233
|
/** Find the roster instance a UI reference means. References carry the
|
|
189
234
|
* display name plus whatever identity the caller knows (home/agentsRoot —
|
|
190
235
|
* sidebar rows know both; older callers pass a bare name). Identity match
|
|
@@ -449,12 +494,17 @@ export function visibleClusters(allInstances, visibleInstances, { links = instan
|
|
|
449
494
|
* [{ key, label, clusters: [{ key, instances }] }], each cluster projected to its visible members, which carry
|
|
450
495
|
* their tree depth. A group's key is unique even when two roots share a name (other agents roots or hosts), and
|
|
451
496
|
* does not depend on what is visible: a cluster's is `cluster:<its place among the full roster's multi-member
|
|
452
|
-
* clusters>:<name>`, a run's `independent:<instanceId of its first member in the full roster>`.
|
|
453
|
-
|
|
497
|
+
* clusters>:<name>`, a run's `independent:<instanceId of its first member in the full roster>`.
|
|
498
|
+
* `lastFocus` (Map<instanceId, time>, optional; the command palette's, #1383): the full roster's clusters are
|
|
499
|
+
* ordered by last focus (`recencyOrder`) before the groups form by the same rule, so a run is the consecutive
|
|
500
|
+
* single clusters of that order, keyed by its first member there. What is visible still decides only which rows
|
|
501
|
+
* are listed, never the order. Without it, the roster's own order (the sidebar's and the TUI's). */
|
|
502
|
+
export function rosterGroups(allInstances, visibleInstances, { links = instanceLinks, lastFocus } = {}) {
|
|
454
503
|
const visibleIds = new Set(visibleInstances.map((i) => instanceId(i)));
|
|
455
504
|
const groups = [];
|
|
456
505
|
let place = 0, run = null;
|
|
457
|
-
|
|
506
|
+
const clusters = clusterInstances(allInstances, { links });
|
|
507
|
+
for (const c of lastFocus instanceof Map ? recencyOrder(clusters, lastFocus) : clusters) {
|
|
458
508
|
const shown = { ...c, instances: c.instances.filter((i) => visibleIds.has(instanceId(i))) };
|
|
459
509
|
if (c.instances.length > 1) {
|
|
460
510
|
run = null;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** The keys both clients share: the leader, the table read after it, and the plain keys of the list
|
|
2
|
+
* of instances. Written down once, here; the Desktop reads its defaults from it, and the TUI's own
|
|
3
|
+
* table (packages/tui/lib/actions.mjs LEADER) is held equal to LEADER_TABLE by the root test
|
|
4
|
+
* test/keymap-parity.test.mjs until the TUI imports this module.
|
|
5
|
+
*
|
|
6
|
+
* Pure data and readers: no state, no DOM, no imports. Every value is frozen.
|
|
7
|
+
*
|
|
8
|
+
* Key ids are the TUI's spelling (packages/tui/lib/term/keys.mjs keyId): one character as itself,
|
|
9
|
+
* case kept (`n`, `N`, `|`, `?`, `/`, `-`); named keys `up` `down` `left` `right` `tab` `escape`
|
|
10
|
+
* `space` `enter` `home` `end` `pageup` `pagedown`; modifiers as `ctrl+` / `alt+` prefixes.
|
|
11
|
+
*
|
|
12
|
+
* leaderKey(isMac) -> the leader's key id on that platform "ctrl+\\" / "alt+o"
|
|
13
|
+
* leaderDoes(key) -> what the leader then does for a key id, or null
|
|
14
|
+
* plainKeys(does) -> the plain key ids of an action (empty when it has none)
|
|
15
|
+
* leaderRows() -> LEADER_TABLE
|
|
16
|
+
*
|
|
17
|
+
* `does` names an action, not a client's code: each client maps it to its own. */
|
|
18
|
+
|
|
19
|
+
/** The leader per platform: Ctrl+\ on macOS, Alt+O elsewhere. */
|
|
20
|
+
export const LEADER = Object.freeze({ mac: "ctrl+\\", other: "alt+o" });
|
|
21
|
+
|
|
22
|
+
/** The keys read after the leader, in the TUI's order, and what each does. `terminal`: named in
|
|
23
|
+
* the hint only while a terminal is open. The leader pressed twice is not here: it is the user's
|
|
24
|
+
* key, and each client says what it does. */
|
|
25
|
+
export const LEADER_TABLE = Object.freeze([
|
|
26
|
+
{ keys: ["k", "space"], does: "palette", label: "palette" },
|
|
27
|
+
{ keys: ["1"], does: "instances", label: "instances" },
|
|
28
|
+
{ keys: ["2"], does: "souls", label: "souls" },
|
|
29
|
+
{ keys: ["3"], does: "capabilities", label: "capabilities" },
|
|
30
|
+
{ keys: ["up"], does: "previous", label: "previous instance" },
|
|
31
|
+
{ keys: ["down"], does: "next", label: "next instance" },
|
|
32
|
+
{ keys: ["z"], does: "zoom", label: "zoom", terminal: true },
|
|
33
|
+
{ keys: ["w"], does: "close-terminal", label: "close terminal", terminal: true },
|
|
34
|
+
{ keys: ["left"], does: "tab-previous", label: "previous tab", terminal: true },
|
|
35
|
+
{ keys: ["right"], does: "tab-next", label: "next tab", terminal: true },
|
|
36
|
+
{ keys: ["|"], does: "split-right", label: "split right", terminal: true },
|
|
37
|
+
{ keys: ["-"], does: "split-down", label: "split down", terminal: true },
|
|
38
|
+
{ keys: ["tab"], does: "group-next", label: "next group", terminal: true },
|
|
39
|
+
{ keys: ["m"], does: "tab-move", label: "move tab", terminal: true },
|
|
40
|
+
{ keys: ["x"], does: "group-close", label: "close group", terminal: true },
|
|
41
|
+
{ keys: ["X"], does: "stop", label: "stop" },
|
|
42
|
+
{ keys: ["R"], does: "restart", label: "restart" },
|
|
43
|
+
{ keys: ["S"], does: "start", label: "start" },
|
|
44
|
+
{ keys: ["D"], does: "retire", label: "retire" },
|
|
45
|
+
{ keys: ["n"], does: "spawn", label: "spawn" },
|
|
46
|
+
{ keys: ["N"], does: "spawn-another", label: "spawn another" },
|
|
47
|
+
{ keys: ["/"], does: "filter", label: "filter" },
|
|
48
|
+
{ keys: ["o"], does: "workspaces", label: "workspaces" },
|
|
49
|
+
{ keys: ["?"], does: "help", label: "help" },
|
|
50
|
+
{ keys: ["escape"], does: "list", label: "the list" },
|
|
51
|
+
].map((row) => Object.freeze({ ...row, keys: Object.freeze([...row.keys]) })));
|
|
52
|
+
|
|
53
|
+
/** The plain keys both clients read in the list of instances (the TUI's ACTIONS), one entry per action. */
|
|
54
|
+
export const PLAIN_KEYS = Object.freeze([
|
|
55
|
+
{ does: "up", keys: ["up", "k"] },
|
|
56
|
+
{ does: "down", keys: ["down", "j"] },
|
|
57
|
+
{ does: "top", keys: ["g", "home"] },
|
|
58
|
+
{ does: "bottom", keys: ["G", "end"] },
|
|
59
|
+
{ does: "page-up", keys: ["pageup"] },
|
|
60
|
+
{ does: "page-down", keys: ["pagedown"] },
|
|
61
|
+
{ does: "collapse", keys: ["left", "h"] },
|
|
62
|
+
{ does: "expand", keys: ["right", "l"] },
|
|
63
|
+
{ does: "filter", keys: ["/"] },
|
|
64
|
+
{ does: "refresh", keys: ["r"] },
|
|
65
|
+
{ does: "instances", keys: ["1"] },
|
|
66
|
+
{ does: "souls", keys: ["2"] },
|
|
67
|
+
{ does: "capabilities", keys: ["3"] },
|
|
68
|
+
{ does: "workspaces", keys: ["w"] },
|
|
69
|
+
{ does: "open", keys: ["enter"] },
|
|
70
|
+
{ does: "zoom", keys: ["z"] },
|
|
71
|
+
{ does: "close-terminal", keys: ["c"] },
|
|
72
|
+
{ does: "tab-previous", keys: ["["] },
|
|
73
|
+
{ does: "tab-next", keys: ["]"] },
|
|
74
|
+
{ does: "split-right", keys: ["|"] },
|
|
75
|
+
{ does: "split-down", keys: ["-"] },
|
|
76
|
+
{ does: "stop", keys: ["X"] },
|
|
77
|
+
{ does: "retire", keys: ["D"] },
|
|
78
|
+
{ does: "start", keys: ["S"] },
|
|
79
|
+
{ does: "restart", keys: ["R"] },
|
|
80
|
+
{ does: "spawn", keys: ["n"] },
|
|
81
|
+
{ does: "spawn-another", keys: ["N"] },
|
|
82
|
+
{ does: "help", keys: ["?"] },
|
|
83
|
+
].map((entry) => Object.freeze({ ...entry, keys: Object.freeze([...entry.keys]) })));
|
|
84
|
+
|
|
85
|
+
const NONE = Object.freeze([]);
|
|
86
|
+
|
|
87
|
+
/** The leader's key id on macOS (`true`) or elsewhere. */
|
|
88
|
+
export function leaderKey(isMac) {
|
|
89
|
+
return isMac ? LEADER.mac : LEADER.other;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** What the leader then does for `keyId`, or null when the table has no such key. */
|
|
93
|
+
export function leaderDoes(keyId) {
|
|
94
|
+
for (const row of LEADER_TABLE) if (row.keys.includes(keyId)) return row.does;
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The plain key ids of the action `does`, frozen; empty when it has none. */
|
|
99
|
+
export function plainKeys(does) {
|
|
100
|
+
return PLAIN_KEYS.find((entry) => entry.does === does)?.keys ?? NONE;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The leader's table, LEADER_TABLE itself. */
|
|
104
|
+
export function leaderRows() {
|
|
105
|
+
return LEADER_TABLE;
|
|
106
|
+
}
|
|
@@ -14,6 +14,8 @@ export const CLIENT_OWN_CODES = Object.freeze([
|
|
|
14
14
|
// Reading a deployment, a workspace and another machine's roster.
|
|
15
15
|
'E_CAPABILITY_SHOW_FEATURE', 'E_DEPLOYMENT_BUSY', 'E_DEPLOYMENT_FEATURE', 'E_DEPLOYMENT_SCOPE', 'E_DEPLOYMENT_STALE',
|
|
16
16
|
'E_REMOTE_ROSTER', 'E_WORKSPACE_FEATURE', 'E_WORKSPACE_UNKNOWN',
|
|
17
|
+
// This computer's deployments list (#1390): a CLI without it.
|
|
18
|
+
'E_DEPLOYMENTS_FEATURE',
|
|
17
19
|
// A spawn: its preview, its apply and the wake saved with it.
|
|
18
20
|
'E_APPLY_UNAVAILABLE', 'E_BACKEND_UNAVAILABLE', 'E_BUSY', 'E_FORBIDDEN_FRAME', 'E_INPUT_PREPARATION', 'E_INSTANCE_GONE',
|
|
19
21
|
'E_INTENT_EXPIRED', 'E_OUTCOME_UNKNOWN', 'E_PREFLIGHT_INCOMPLETE', 'E_PREVIEW_UNAVAILABLE', 'E_TARGET_CHANGED',
|
|
@@ -319,7 +319,7 @@ export function workspaceChoices(held, terms, model) {
|
|
|
319
319
|
// before views, not as "not matched" (each deployment's own reason still says why).
|
|
320
320
|
const unmatched = v.unattached && identityFeature(held);
|
|
321
321
|
return { id: v.id, name: v.name, team: null, deployments: [...v.deployments],
|
|
322
|
-
// The deployments' labels, in the same order, for a view that is not on screen ("This Mac · ~/
|
|
322
|
+
// The deployments' labels, in the same order, for a view that is not on screen ("This Mac · ~/acme").
|
|
323
323
|
deploymentLabels: v.deployments.map((id) => deploymentLabel(model.infos.get(id), terms)),
|
|
324
324
|
// The switcher's one-liner (UI spec, #482): the machines, in order and once each, and how many deployments aren't live.
|
|
325
325
|
machines: [...new Set(v.deployments.map((id) => model.infos.get(id)?.machine).filter(Boolean))],
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* A deployment is `{ id, machine, path, label, local, reachable, identityFrom, primary, stale?, reason? }`
|
|
6
6
|
* and a row carries `deployment: { id }`. Nothing is derived from a host name or a path beyond the
|
|
7
7
|
* display label. A view with one deployment has one section and no heading. */
|
|
8
|
-
import { rosterGroups } from './instance-tree.mjs';
|
|
8
|
+
import { rosterGroups, instanceId } from './instance-tree.mjs';
|
|
9
9
|
import { machineLabelParts } from './deployment-label.mjs';
|
|
10
10
|
import { requireTerms } from './client-terms.mjs';
|
|
11
11
|
|
|
@@ -51,16 +51,32 @@ export const rowStale = (row, deployments) => {
|
|
|
51
51
|
* Sections with no visible row are left out. Each is labelled by its machine, with the path tail
|
|
52
52
|
* only when one machine holds two (deployment-label.mjs machineLabels), in the client's terms
|
|
53
53
|
* (client-terms.mjs: the label of a deployment that names no machine). Returns
|
|
54
|
-
* `[{ deployment|null, label|null, groups }]`, a group being `{ key, label, clusters }` as before.
|
|
55
|
-
|
|
54
|
+
* `[{ deployment|null, label|null, groups }]`, a group being `{ key, label, clusters }` as before.
|
|
55
|
+
* `lastFocus` (Map<instanceId, time>, optional; the command palette's, #1383): each section's groups follow
|
|
56
|
+
* last focus (rosterGroups), and the sections are ordered by the latest focus over each one's full roster,
|
|
57
|
+
* most recent first, then the panel's order. Without it, the panel's order (the sidebar's and the TUI's). */
|
|
58
|
+
export function rosterSections(instances, visible, deployments, terms, { lastFocus } = {}) {
|
|
56
59
|
requireTerms(terms, 'rosterSections');
|
|
57
|
-
const
|
|
60
|
+
const recency = lastFocus instanceof Map ? { lastFocus } : {};
|
|
61
|
+
const groupsOf = (all, shown) => rosterGroups(all, shown, recency); // the relation groups the palette lists too
|
|
58
62
|
if (!isMultiDeployment(deployments)) return [{ deployment: null, label: null, groups: groupsOf(instances, visible) }];
|
|
59
63
|
const sectionOf = splitByDeployment(deployments);
|
|
60
64
|
const all = sectionOf(instances), shown = sectionOf(visible), labels = machineLabelParts(deployments, terms);
|
|
61
65
|
const label = ({ machine, tail }) => (tail ? `${machine} · ${tail}` : machine);
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
const sections = deployments.map(d => ({ deployment: d, parts: labels.get(d.id), all: all.get(d.id), shown: shown.get(d.id) }));
|
|
67
|
+
if (recency.lastFocus) {
|
|
68
|
+
const latest = rows => rows.reduce((max, row) => {
|
|
69
|
+
const time = lastFocus.get(instanceId(row));
|
|
70
|
+
return Number.isFinite(time) && (max === null || time > max) ? time : max;
|
|
71
|
+
}, null);
|
|
72
|
+
const keyed = new Map(sections.map(s => [s, latest(s.all)]));
|
|
73
|
+
// Stable: sections without a focus keep the panel's order, after those with one.
|
|
74
|
+
sections.sort((a, b) => {
|
|
75
|
+
const ka = keyed.get(a), kb = keyed.get(b);
|
|
76
|
+
return ka === null ? (kb === null ? 0 : 1) : kb === null ? -1 : kb - ka;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return sections.filter(s => s.shown.length)
|
|
64
80
|
.map(s => ({ deployment: s.deployment, label: label(s.parts), machine: s.parts.machine, tail: s.parts.tail, groups: groupsOf(s.all, s.shown) }));
|
|
65
81
|
}
|
|
66
82
|
|
|
@@ -12,7 +12,8 @@ export const deploymentCheck = (io) => (p) => { try { return io.isDeployment(p)
|
|
|
12
12
|
|
|
13
13
|
/** The deployments directly inside `dir`, sorted by name: at most PICK_SCAN_LIMIT entries read, a
|
|
14
14
|
* link never followed, nothing parsed. An unreadable or missing `dir` holds none. Used for a picked
|
|
15
|
-
* parent folder
|
|
15
|
+
* parent folder. The deployments the Desktop offers unasked come from this computer's deployments
|
|
16
|
+
* list, which the kernel keeps (deployment-list.mjs, #1390), not from a look inside a folder.
|
|
16
17
|
* @param {string} dir
|
|
17
18
|
* @param {object} io
|
|
18
19
|
* @param {(dir: string, limit: number) => { entries: Array<{ name: string, isDirectory: boolean }>, limited: boolean }} io.list
|
package/packages/tui/README.md
CHANGED
|
@@ -20,12 +20,12 @@ never does.
|
|
|
20
20
|
| path | contents |
|
|
21
21
|
|---|---|
|
|
22
22
|
| `bin/tui.mjs` | the entry `bin/oats.mjs` loads: it imports the whole module graph, then runs `main()` |
|
|
23
|
-
| `lib/main.mjs` | the start (arguments, environment, terminal, `tui.json`, deployment, kernel) and the loop: events through `reduce`, effects out, the frame drawn |
|
|
24
|
-
| `lib/actions.mjs` | the action table and its default keys: the reducer, the
|
|
23
|
+
| `lib/main.mjs` | the start (arguments, environment, terminal, `tui.json`, deployment, kernel, and outside every deployment this computer's list of deployments) and the loop: events through `reduce`, effects out, the frame drawn; the list's reads, the add of the deployment the run starts in and the switcher's Remove, through the shared `cliDeploymentList` |
|
|
24
|
+
| `lib/actions.mjs` | the action table and its default keys: the reducer, the cheat sheet and the help read the effective one |
|
|
25
25
|
| `lib/config.mjs` | `tui.json`: read once, checked, and the effective action table |
|
|
26
26
|
| `lib/client.mjs` | the one module that imports the shared readers (`packages/client/`), and the client's terms |
|
|
27
27
|
| `lib/panel.mjs` | the open terminals, as tabs: the run's private tmux server (one control client, one window per tab, up to `MAX_TERMINALS`, each at the size its caller gives), the kernel's `oats session attach` in a pane of each, captures of the displayed tabs only (up to `MAX_SHOWN`, one per group of a split) when tmux says their pane changed, a hidden tab's output marking it, keys typed into the shown tab, and the sweep of what a dead run left; the only module that runs tmux (THE TABS in its header) |
|
|
28
|
-
| `lib/read.mjs` | the effects of reading: the deployment, the kernel record, the observer of every deployment opened in the run, the roster of other machines (`oats server roster --json`), the refresh loop, the liveness collector, ending every read, the changes (a stop or retire apply, a start or restart: never ended, their output in files of the run's private directory),
|
|
28
|
+
| `lib/read.mjs` | the effects of reading: the deployment, the kernel record, the observer of every deployment opened in the run, the roster of other machines (`oats server roster --json`), the refresh loop, the liveness collector, ending every read, the changes (a stop or retire apply, a start or restart: never ended, their output in files of the run's private directory), the one look at the file system the switcher needs (whether a picked row is a deployment), and `startExec`, the exec of the list's read before the terminal is taken |
|
|
29
29
|
| `lib/store.mjs` | the state and `reduce(state, event)`: pure. It holds the tabs' order, their groups, the shown one of each and the rule for the neighbour after a close (`TAB_LIMIT`, held to the panel's `MAX_TERMINALS` by a test) |
|
|
30
30
|
| `lib/model.mjs` | from the state to the rows and the detail to draw, and to the switcher's rows, by calling the shared readers: pure, no cell position |
|
|
31
31
|
| `lib/term/keys.mjs` | bytes to key events: a pure parser with an injected clock |
|
|
@@ -36,7 +36,7 @@ never does.
|
|
|
36
36
|
| `lib/term/through.mjs` | the bytes typed while a terminal has the focus: the back key's grammar and bytes, and the scanner that takes the back key and a bracketed paste out of them |
|
|
37
37
|
| `lib/term/screen.mjs` | the cell buffer and the bytes of a frame |
|
|
38
38
|
| `lib/term/tty.mjs` | the guard: enter, leave, signals, suspend, resize, one write per frame |
|
|
39
|
-
| `lib/views/` | pure functions from the model and a size to rows of spans: the frame, the list, the detail, the Capabilities view (`capabilities.mjs`), the switcher, the help, the confirmation of an act (`act.mjs`), the spawn prompt (`spawn.mjs`), the split's geometry (`split.mjs`) |
|
|
39
|
+
| `lib/views/` | pure functions from the model and a size to rows of spans: the frame (the sidebar: its title, the accordion of the three views and the cheat sheet; the main area beside it), the list, the detail, the Capabilities view (`capabilities.mjs`), the switcher, the help, the confirmation of an act (`act.mjs`), the spawn prompt (`spawn.mjs`), the split's geometry (`split.mjs`) |
|
|
40
40
|
|
|
41
41
|
Rules the tests pin (`test/tui-boundary.test.mjs` reads the files):
|
|
42
42
|
|