@awebai/oats 0.58.0 → 0.59.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.
Files changed (53) hide show
  1. package/bin/oats.mjs +1 -1
  2. package/docs/desktop-cli-api.md +68 -3
  3. package/docs/desktop.md +30 -3
  4. package/docs/execution-targets.md +11 -0
  5. package/docs/implementation.md +2 -0
  6. package/docs/integrations.md +2 -2
  7. package/docs/knowledge.md +4 -4
  8. package/docs/official-catalog.md +4 -4
  9. package/docs/packages.md +14 -14
  10. package/docs/release-notes/v0.59.0.md +288 -0
  11. package/docs/servers.md +4 -1
  12. package/docs/souls-and-instances.md +21 -0
  13. package/docs/tui.md +644 -118
  14. package/docs/workspaces.md +2 -2
  15. package/lib/core.mjs +216 -42
  16. package/lib/read-ahead-worker.mjs +119 -0
  17. package/lib/read-ahead.mjs +115 -0
  18. package/lib/retire-state.mjs +33 -0
  19. package/lib/servers.mjs +9 -1
  20. package/lib/session-input.mjs +14 -4
  21. package/package-catalog.json +3 -3
  22. package/package.json +1 -1
  23. package/packages/client/cli-locator.mjs +2 -2
  24. package/packages/client/deployment-data.mjs +4 -0
  25. package/packages/client/deployment-panel.mjs +3 -0
  26. package/packages/client/instance-acts.mjs +23 -8
  27. package/packages/client/instance-presentation.mjs +3 -2
  28. package/packages/client/instance-tree.mjs +84 -39
  29. package/packages/client/lifecycle-confirmation.mjs +9 -3
  30. package/packages/client/remote-roster.mjs +4 -1
  31. package/packages/client/retire-in-flight.mjs +65 -0
  32. package/packages/client/retire-state.mjs +30 -0
  33. package/packages/client/spawn-apply.mjs +13 -4
  34. package/packages/tui/README.md +23 -10
  35. package/packages/tui/lib/actions.mjs +63 -5
  36. package/packages/tui/lib/client.mjs +12 -1
  37. package/packages/tui/lib/config.mjs +7 -2
  38. package/packages/tui/lib/main.mjs +315 -82
  39. package/packages/tui/lib/model.mjs +523 -56
  40. package/packages/tui/lib/panel.mjs +436 -125
  41. package/packages/tui/lib/read.mjs +52 -26
  42. package/packages/tui/lib/store.mjs +908 -65
  43. package/packages/tui/lib/term/keys.mjs +9 -2
  44. package/packages/tui/lib/term/text.mjs +4 -0
  45. package/packages/tui/lib/term/through.mjs +12 -1
  46. package/packages/tui/lib/views/frame.mjs +394 -95
  47. package/packages/tui/lib/views/help.mjs +54 -13
  48. package/packages/tui/lib/views/instances.mjs +43 -25
  49. package/packages/tui/lib/views/palette.mjs +61 -0
  50. package/packages/tui/lib/views/souls.mjs +268 -0
  51. package/packages/tui/lib/views/spawn.mjs +299 -0
  52. package/packages/tui/lib/views/split.mjs +29 -0
  53. package/skills/oats-getting-started/SKILL.md +2 -2
@@ -35,11 +35,16 @@ const GRAPHEMES = new Intl.Segmenter("en", { granularity: "grapheme" });
35
35
 
36
36
  const named = (name, ctrl = false, alt = false, shift = false) => ({ name, ctrl, alt, shift });
37
37
 
38
- /** The key of a C0 byte or DEL, or null for a byte that is no key (NUL, 0x1c..0x1f). */
38
+ /** Control with one of \ ] ^ _: the C0 bytes 0x1c..0x1f, in that order. */
39
+ const CTRL_PUNCTUATION = "\\]^_";
40
+
41
+ /** The key of a C0 byte or DEL, or null for a byte that is no key (NUL). 0x1c..0x1f are Control
42
+ * with \ ] ^ _ (the leader, `C-\` by default, is one of them: docs/tui.md, "The leader"). */
39
43
  function c0Key(b) {
40
44
  if (b === 0x0d || b === 0x0a) return named("enter");
41
45
  if (b === 0x09) return named("tab");
42
46
  if (b === 0x7f || b === 0x08) return named("backspace");
47
+ if (b >= 0x1c && b <= 0x1f) return named(CTRL_PUNCTUATION[b - 0x1c], true);
43
48
  return b >= 0x01 && b <= 0x1a ? named(String.fromCharCode(b + 0x60), true) : null;
44
49
  }
45
50
 
@@ -325,6 +330,7 @@ export function keyId(event) {
325
330
  /** The names that take every modifier: the keys read by `modified` from a CSI or an SS3. */
326
331
  const MODIFIED_NAMES = new Set([...Object.values(LETTER_KEYS), ...Object.values(TILDE_KEYS)]);
327
332
  const NAMED_ID = /^(ctrl\+)?(alt\+)?(shift\+)?([a-z][a-z0-9]*)$/;
333
+ const CTRL_PUNCTUATION_ID = /^ctrl\+(?:alt\+)?[\\\]^_]$/;
328
334
  /** What no text event holds: a control character (C0, DEL, C1) or half a surrogate pair. */
329
335
  const NOT_TEXT = /[\p{Cc}\p{Cs}]/u;
330
336
  /** The characters that, after an ESC, begin a sequence (CSI, SS3, OSC, DCS, SOS, PM, APC): Alt
@@ -349,13 +355,14 @@ const oneCodePoint = (text) => text.length === (text.codePointAt(0) > 0xffff ? 2
349
355
  * enter, backspace: bare or `alt+`. escape: bare
350
356
  * tab: bare, `alt+tab`, and `shift+tab` with any of `ctrl+`, `alt+` before it
351
357
  * ctrl `ctrl+` or `ctrl+alt+` and a letter a..z whose C0 byte is a key of its own:
352
- * not h, i, j or m, which arrive as Backspace, Tab and Enter */
358
+ * not h, i, j or m, which arrive as Backspace, Tab and Enter; or one of \ ] ^ _ */
353
359
  export function isKeyId(id) {
354
360
  if (typeof id !== "string" || id === "" || NOT_TEXT.test(id)) return false;
355
361
  if (id === "space" || id === "alt+space") return true;
356
362
  if (id === " " || id === "alt+ ") return false;
357
363
  if (oneGrapheme(id)) return true;
358
364
  if (id.startsWith("alt+") && id.length > 4 && oneCodePoint(id.slice(4))) return !INTRODUCERS.includes(id.slice(4));
365
+ if (CTRL_PUNCTUATION_ID.test(id)) return true;
359
366
  const match = NAMED_ID.exec(id);
360
367
  if (!match) return false;
361
368
  const [, ctrl, alt, shift, name] = match;
@@ -47,6 +47,10 @@ export function shown(value) {
47
47
  return line === null ? EMPTY : line === DETAIL_WITHHELD ? WITHHELD : make(line);
48
48
  }
49
49
 
50
+ /** The ellipsis in words the TUI or the shared home wrote ("Retiring…", "Setting up worktree…", "Starting …"): in ASCII
51
+ * three full stops, as the cut mark is. Only for their own words: text from anywhere else is shown as it came. */
52
+ export const ownEllipsis = (string, ascii) => (ascii ? string.replaceAll("\u2026", "...") : string);
53
+
50
54
  /** The cut mark, the screen's own (term/screen.mjs): one cell, or three in ASCII. */
51
55
  const cutMark = (ascii) => (ascii ? "..." : "\u2026");
52
56
  const widthOf = (graphemes) => graphemes.reduce((sum, g) => sum + g.width, 0);
@@ -8,7 +8,7 @@
8
8
  // back from a terminal and name in the footer. It began as the kernel's `--detach-key` grammar
9
9
  // (lib/session-viewer.mjs) and keeps its set and its spelling, so a tui.json written for PR 4 means
10
10
  // the same key; it is not tied to the kernel's, which never sees this key any more.
11
- import { ESC_TIMEOUT_MS, PASTE_LIMIT, PASTE_PAUSE_MS } from "./keys.mjs";
11
+ import { ESC_TIMEOUT_MS, PASTE_LIMIT, PASTE_PAUSE_MS, createKeyParser, keyId } from "./keys.mjs";
12
12
 
13
13
  /** The keys that can be the back key: Control with a letter other than h, i and m (Backspace on
14
14
  * some terminals, Tab, Enter), or one of \ ] ^ _; Meta with a lowercase letter or a digit; or F1
@@ -49,6 +49,17 @@ export function backKeySequences(key) {
49
49
  return forms.map(escaped);
50
50
  }
51
51
 
52
+ /** The key id the key parser (term/keys.mjs) reads a back key's bytes as: what the leader is where
53
+ * the TUI reads keys (docs/tui.md, "The leader"). `C-\\` is `ctrl+\\`, `M-x` is `alt+x`, `F5` is
54
+ * `f5`; `C-j` is `enter`, the byte the parser reads as Enter. Every form of a back key reads as
55
+ * the same id. A key that is no back key (tui.json refuses it) has none: null. */
56
+ export function backKeyId(key) {
57
+ let sequences;
58
+ try { sequences = backKeySequences(key); } catch { return null; } // not a back key: none is read
59
+ const events = createKeyParser({ now: () => 0 }).feed(sequences[0]);
60
+ return events.length === 1 ? keyId(events[0]) : null;
61
+ }
62
+
52
63
  const PASTE_START = escaped("[200~");
53
64
  const PASTE_END = escaped("[201~");
54
65
  /** The first bytes of a paste's start marker that are held when a read ends on them: from `ESC [ 2`