@sigrun/tui 0.1.0 → 0.1.1

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 (84) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/actions.d.ts +43 -2
  3. package/dist/api.d.ts +5 -0
  4. package/dist/api.js +5 -1
  5. package/dist/blocks/braille.d.ts +41 -0
  6. package/dist/blocks/braille.js +131 -0
  7. package/dist/blocks/chart.d.ts +20 -0
  8. package/dist/blocks/chart.js +397 -0
  9. package/dist/blocks/collection/calendar.d.ts +28 -0
  10. package/dist/blocks/collection/calendar.js +232 -0
  11. package/dist/blocks/collection/card.d.ts +36 -0
  12. package/dist/blocks/collection/card.js +128 -0
  13. package/dist/blocks/collection/collection.d.ts +9 -0
  14. package/dist/blocks/collection/collection.js +26 -0
  15. package/dist/blocks/collection/grid.d.ts +18 -0
  16. package/dist/blocks/collection/grid.js +72 -0
  17. package/dist/blocks/collection/lanes.d.ts +32 -0
  18. package/dist/blocks/collection/lanes.js +320 -0
  19. package/dist/blocks/collection/list.d.ts +30 -0
  20. package/dist/blocks/collection/list.js +273 -0
  21. package/dist/blocks/collection/move.d.ts +67 -0
  22. package/dist/blocks/collection/move.js +96 -0
  23. package/dist/blocks/collection/shared.d.ts +87 -0
  24. package/dist/blocks/collection/shared.js +177 -0
  25. package/dist/blocks/collection/table.d.ts +26 -0
  26. package/dist/blocks/collection/table.js +221 -0
  27. package/dist/blocks/content.d.ts +48 -0
  28. package/dist/blocks/content.js +253 -0
  29. package/dist/blocks/context.d.ts +96 -0
  30. package/dist/blocks/context.js +65 -0
  31. package/dist/blocks/diff.d.ts +21 -0
  32. package/dist/blocks/diff.js +25 -0
  33. package/dist/blocks/ext-transport.d.ts +70 -0
  34. package/dist/blocks/ext-transport.js +165 -0
  35. package/dist/blocks/form/choice.d.ts +54 -0
  36. package/dist/blocks/form/choice.js +175 -0
  37. package/dist/blocks/form/fields.d.ts +56 -0
  38. package/dist/blocks/form/fields.js +136 -0
  39. package/dist/blocks/form/file.d.ts +61 -0
  40. package/dist/blocks/form/file.js +121 -0
  41. package/dist/blocks/form/form.d.ts +53 -0
  42. package/dist/blocks/form/form.js +703 -0
  43. package/dist/blocks/form/list.d.ts +37 -0
  44. package/dist/blocks/form/list.js +70 -0
  45. package/dist/blocks/form/values.d.ts +20 -0
  46. package/dist/blocks/form/values.js +104 -0
  47. package/dist/blocks/icons.d.ts +14 -0
  48. package/dist/blocks/icons.js +74 -0
  49. package/dist/blocks/image.d.ts +39 -0
  50. package/dist/blocks/image.js +82 -0
  51. package/dist/blocks/layout.d.ts +31 -0
  52. package/dist/blocks/layout.js +155 -0
  53. package/dist/blocks/log.d.ts +24 -0
  54. package/dist/blocks/log.js +111 -0
  55. package/dist/blocks/meter.d.ts +16 -0
  56. package/dist/blocks/meter.js +50 -0
  57. package/dist/blocks/page.d.ts +54 -0
  58. package/dist/blocks/page.js +355 -0
  59. package/dist/blocks/render.d.ts +31 -0
  60. package/dist/blocks/render.js +145 -0
  61. package/dist/blocks/surface-view.d.ts +33 -0
  62. package/dist/blocks/surface-view.js +86 -0
  63. package/dist/blocks/surface.d.ts +75 -0
  64. package/dist/blocks/surface.js +468 -0
  65. package/dist/blocks/tones.d.ts +23 -0
  66. package/dist/blocks/tones.js +63 -0
  67. package/dist/blocks/treeview.d.ts +22 -0
  68. package/dist/blocks/treeview.js +121 -0
  69. package/dist/blocks/width.d.ts +32 -0
  70. package/dist/blocks/width.js +70 -0
  71. package/dist/keymaps/emacs.js +39 -0
  72. package/dist/keymaps/standard.js +45 -1
  73. package/dist/keymaps/vim.js +37 -0
  74. package/dist/launch.js +13 -0
  75. package/dist/sse.d.ts +8 -0
  76. package/dist/sse.js +27 -0
  77. package/dist/theme.d.ts +2 -2
  78. package/dist/theme.js +16 -2
  79. package/dist/ui/app.d.ts +36 -0
  80. package/dist/ui/app.js +84 -0
  81. package/dist/ui/interactions.js +2 -7
  82. package/dist/ui/sidebar.d.ts +25 -2
  83. package/dist/ui/sidebar.js +64 -0
  84. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.1] - 2026-10-24
11
+ ### Added
12
+ - Extension surfaces and live surface updates.
13
+ - Typed block rendering: content, braille charts, collections, forms,
14
+ page shells, images, navigation, and all three keymaps.
15
+
10
16
  ## [0.1.0] - 2026-10-21
11
17
  ### Added
12
18
  - First published release of the TUI (workspace package of
package/dist/actions.d.ts CHANGED
@@ -9,8 +9,13 @@
9
9
  * keymap decides WHICH action a key means per focus; the app decides
10
10
  * what the action DOES per focus.
11
11
  */
12
- /** The three focusable regions. */
13
- export type Focus = "composer" | "list" | "transcript";
12
+ /** The three focusable regions. `surface` (Task 4, UI-blocks U2) is a
13
+ * block surface pane (lanes/calendar/collection) — the blocks.* keys
14
+ * route ONLY while it has focus. While a surface is focused the
15
+ * transcript/list nav keys (y/f/e//?) are inert (the keymaps pass
16
+ * them); Task 6's surface host decides any surface-side meaning for
17
+ * them. */
18
+ export type Focus = "composer" | "list" | "transcript" | "surface";
14
19
  /** Every dispatchable intent. */
15
20
  export type Action = {
16
21
  readonly type: "focus";
@@ -71,6 +76,42 @@ export type Action = {
71
76
  } | {
72
77
  readonly type: "run-command";
73
78
  readonly line: string;
79
+ }
80
+ /** Pick up the item under the cursor (m / M-m). */
81
+ | {
82
+ readonly type: "blocks.pickUp";
83
+ }
84
+ /** Drop the picked-up item at its placement (Enter). */
85
+ | {
86
+ readonly type: "blocks.drop";
87
+ }
88
+ /** Cancel the pick-up (Esc). */
89
+ | {
90
+ readonly type: "blocks.cancelMove";
91
+ }
92
+ /** Toggle the selection of the item under the cursor (Space). */
93
+ | {
94
+ readonly type: "blocks.select";
95
+ }
96
+ /** Open the action menu (`.` — bulk actions, "Move to…"). */
97
+ | {
98
+ readonly type: "blocks.actionMenu";
99
+ }
100
+ /** Toggle the checkable field of the item under the cursor (x). */
101
+ | {
102
+ readonly type: "blocks.check";
103
+ }
104
+ /** Previous calendar range ([). */
105
+ | {
106
+ readonly type: "blocks.rangePrev";
107
+ }
108
+ /** Next calendar range (]). */
109
+ | {
110
+ readonly type: "blocks.rangeNext";
111
+ }
112
+ /** Return the calendar range to today (t). */
113
+ | {
114
+ readonly type: "blocks.today";
74
115
  };
75
116
  /** The dispatch surface {@link TuiApp} implements. */
76
117
  export interface ActionHost {
package/dist/api.d.ts CHANGED
@@ -25,6 +25,7 @@ export type { AbortResponse, AmbientList, AmbientWire, CompactResponse, Configur
25
25
  export type { CommandRunResponse, CommandsResponse, SlashCommand } from "@sigrun/shared/commands";
26
26
  export type { JobSpec, JobSchedule, JobAction, JobWire, JobRunWire, JobRevisionWire, } from "@sigrun/shared/jobs";
27
27
  export type { JobsResponse, JobRunResponse } from "@sigrun/shared/views";
28
+ export type { ExtensionsResponse, ExtensionInfo, ExtensionSurfaceInfo } from "@sigrun/shared/views";
28
29
  export type { SessionMeta, SessionMetaPatch } from "@sigrun/shared/session-meta";
29
30
  /** One answer to a pending interaction (the ONE generic route's body). */
30
31
  export interface InteractionAnswerInput {
@@ -80,6 +81,7 @@ export interface SigrunClientOptions {
80
81
  readonly fetch?: FetchLike;
81
82
  }
82
83
  /** The typed §5 client. See {@link SigrunClientOptions} for the seams. */
84
+ import type { ExtensionsResponse } from "@sigrun/shared/views";
83
85
  export declare class SigrunClient {
84
86
  #private;
85
87
  constructor(options: SigrunClientOptions);
@@ -117,6 +119,9 @@ export declare class SigrunClient {
117
119
  getAmbient(id: number): Promise<AmbientList>;
118
120
  /** `GET /v1/commands` — the slash-command catalog (a boot constant). */
119
121
  getCommands(): Promise<CommandsResponse>;
122
+ /** `GET /v1/extensions` — the loaded-extension inventory (U3 Task 5:
123
+ * the sidebar's Views group + panels read the declared surfaces). */
124
+ listExtensions(): Promise<ExtensionsResponse>;
120
125
  /**
121
126
  * `POST /v1/conversations/:id/commands/:name` — invoke an extension
122
127
  * slash command (W5 Task 3): the server runs the winning declaration
package/dist/api.js CHANGED
@@ -27,7 +27,6 @@ export class SigrunApiError extends Error {
27
27
  this.body = body;
28
28
  }
29
29
  }
30
- /** The typed §5 client. See {@link SigrunClientOptions} for the seams. */
31
30
  export class SigrunClient {
32
31
  #baseUrl;
33
32
  #fetch;
@@ -139,6 +138,11 @@ export class SigrunClient {
139
138
  getCommands() {
140
139
  return this.#get("/v1/commands");
141
140
  }
141
+ /** `GET /v1/extensions` — the loaded-extension inventory (U3 Task 5:
142
+ * the sidebar's Views group + panels read the declared surfaces). */
143
+ listExtensions() {
144
+ return this.#get("/v1/extensions");
145
+ }
142
146
  /**
143
147
  * `POST /v1/conversations/:id/commands/:name` — invoke an extension
144
148
  * slash command (W5 Task 3): the server runs the winning declaration
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The Braille dot canvas and the display ramps (UI-blocks spec §5.4):
3
+ * the pieces `chart` and the narrow-fallback sparkline draw with.
4
+ *
5
+ * - {@link BrailleCanvas} is a `cells×rows` cell grid of 2×4 dot
6
+ * subpixels (Unicode Braille Patterns, U+2800 base). Each cell also
7
+ * records the index of the series that plotted into it LAST, which
8
+ * is how multi-colour charts colour a shared cell.
9
+ * - {@link sparkline} renders a value series onto the eighth-block
10
+ * ramp `▁▂▃▄▅▆▇█` (or the ASCII ramp `_.,-+=*#` on a no-Unicode
11
+ * terminal), downsampling with the shared `lttb` when the series is
12
+ * longer than the cell budget.
13
+ */
14
+ /** A Braille dot canvas: `cells` columns × `rows` rows of 2×4 dots. */
15
+ export declare class BrailleCanvas {
16
+ #private;
17
+ constructor(cells: number, rows: number);
18
+ /** Plot one dot; out-of-range coordinates are ignored. */
19
+ plot(x: number, y: number, series?: number): void;
20
+ /** A straight dot-space line from (x0, y0) to (x1, y1): the steps
21
+ * are the CHEBYSHEV distance (diagonal-adjacent dots step one
22
+ * dot-space cell at a time). */
23
+ line(x0: number, y0: number, x1: number, y1: number, series?: number): void;
24
+ /** Fill the dot rectangle (x0..x1, y0..y1) inclusive. */
25
+ fill(x0: number, y0: number, x1: number, y1: number, series?: number): void;
26
+ /** The dot bits set in one cell. */
27
+ cellBits(cellX: number, cellY: number): number;
28
+ /** The series index that plotted into this cell last (−1: none). */
29
+ cellOwner(cellX: number, cellY: number): number;
30
+ /** Clear one cell row (a threshold rule paints over it). */
31
+ blankRow(cellY: number): void;
32
+ /** The canvas as one Braille string per cell row. */
33
+ rows(): string[];
34
+ }
35
+ /**
36
+ * A one-cell-per-sample sparkline of `values`, at most `maxCells`
37
+ * cells (longer series downsample with `lttb`, keeping both ends).
38
+ * `unicode: false` selects the ASCII ramp. Empty input renders empty;
39
+ * a flat series renders mid-height cells.
40
+ */
41
+ export declare function sparkline(values: readonly number[], maxCells: number, unicode: boolean): string;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * The Braille dot canvas and the display ramps (UI-blocks spec §5.4):
3
+ * the pieces `chart` and the narrow-fallback sparkline draw with.
4
+ *
5
+ * - {@link BrailleCanvas} is a `cells×rows` cell grid of 2×4 dot
6
+ * subpixels (Unicode Braille Patterns, U+2800 base). Each cell also
7
+ * records the index of the series that plotted into it LAST, which
8
+ * is how multi-colour charts colour a shared cell.
9
+ * - {@link sparkline} renders a value series onto the eighth-block
10
+ * ramp `▁▂▃▄▅▆▇█` (or the ASCII ramp `_.,-+=*#` on a no-Unicode
11
+ * terminal), downsampling with the shared `lttb` when the series is
12
+ * longer than the cell budget.
13
+ */
14
+ import { lttb } from "@sigrun/shared/blocks";
15
+ /**
16
+ * Dot bit per (x, y) subpixel: the Unicode standard layout — the
17
+ * left column holds dots 1,2,3,7 and the right column dots 4,5,6,8,
18
+ * TOP-DOWN. Dot space is TOP-DOWN too: (x, 0) is the TOP row of the
19
+ * canvas (plot(0,0) = dot 1 = 0x01). The suite pins plot(0,0)=0x01,
20
+ * plot(0,2)=0x04, plot(1,1)=0x10, plot(1,3)=0x80 on a one-row
21
+ * canvas; chart inverts its y axis before plotting.
22
+ */
23
+ const DOT_BIT = [
24
+ [0x01, 0x02, 0x04, 0x40],
25
+ [0x08, 0x10, 0x20, 0x80],
26
+ ];
27
+ /** A Braille dot canvas: `cells` columns × `rows` rows of 2×4 dots. */
28
+ export class BrailleCanvas {
29
+ #cells;
30
+ #rows;
31
+ #bits;
32
+ #owner;
33
+ constructor(cells, rows) {
34
+ this.#cells = Math.max(0, cells);
35
+ this.#rows = Math.max(0, rows);
36
+ this.#bits = new Uint8Array(this.#cells * this.#rows);
37
+ this.#owner = new Int32Array(this.#cells * this.#rows).fill(-1);
38
+ }
39
+ /** Plot one dot; out-of-range coordinates are ignored. */
40
+ plot(x, y, series) {
41
+ const cellX = Math.floor(x / 2);
42
+ const cellY = Math.floor(y / 4);
43
+ if (cellX < 0 || cellY < 0 || cellX >= this.#cells || cellY >= this.#rows)
44
+ return;
45
+ const index = cellY * this.#cells + cellX;
46
+ const row = y % 4;
47
+ const col = x % 2;
48
+ const bit = DOT_BIT[col][row] ?? 0;
49
+ this.#bits[index] = (this.#bits[index] ?? 0) | bit;
50
+ if (series !== undefined)
51
+ this.#owner[index] = series;
52
+ }
53
+ /** A straight dot-space line from (x0, y0) to (x1, y1): the steps
54
+ * are the CHEBYSHEV distance (diagonal-adjacent dots step one
55
+ * dot-space cell at a time). */
56
+ line(x0, y0, x1, y1, series) {
57
+ const steps = Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0), 1);
58
+ for (let i = 0; i <= steps; i++) {
59
+ this.plot(Math.round(x0 + ((x1 - x0) * i) / steps), Math.round(y0 + ((y1 - y0) * i) / steps), series);
60
+ }
61
+ }
62
+ /** Fill the dot rectangle (x0..x1, y0..y1) inclusive. */
63
+ fill(x0, y0, x1, y1, series) {
64
+ for (let y = Math.min(y0, y1); y <= Math.max(y0, y1); y++) {
65
+ for (let x = Math.min(x0, x1); x <= Math.max(x0, x1); x++) {
66
+ this.plot(x, y, series);
67
+ }
68
+ }
69
+ }
70
+ /** The dot bits set in one cell. */
71
+ cellBits(cellX, cellY) {
72
+ return this.#bits[cellY * this.#cells + cellX] ?? 0;
73
+ }
74
+ /** The series index that plotted into this cell last (−1: none). */
75
+ cellOwner(cellX, cellY) {
76
+ return this.#owner[cellY * this.#cells + cellX] ?? -1;
77
+ }
78
+ /** Clear one cell row (a threshold rule paints over it). */
79
+ blankRow(cellY) {
80
+ if (cellY < 0 || cellY >= this.#rows)
81
+ return;
82
+ for (let cell = 0; cell < this.#cells; cell++) {
83
+ const index = cellY * this.#cells + cell;
84
+ this.#bits[index] = 0;
85
+ this.#owner[index] = -1;
86
+ }
87
+ }
88
+ /** The canvas as one Braille string per cell row. */
89
+ rows() {
90
+ const out = [];
91
+ for (let row = 0; row < this.#rows; row++) {
92
+ let line = "";
93
+ for (let cell = 0; cell < this.#cells; cell++) {
94
+ line += String.fromCharCode(0x2800 + this.cellBits(cell, row));
95
+ }
96
+ out.push(line);
97
+ }
98
+ return out;
99
+ }
100
+ }
101
+ /** The eighth-block ramp (index 0..8: empty through full). */
102
+ const BLOCK_RAMP = "▁▂▃▄▅▆▇█"; // 8 cells, index 0..7
103
+ /** The ASCII ramp for no-Unicode terminals (same 8 shape heights). */
104
+ const ASCII_RAMP = "_.,-+=*#";
105
+ /**
106
+ * A one-cell-per-sample sparkline of `values`, at most `maxCells`
107
+ * cells (longer series downsample with `lttb`, keeping both ends).
108
+ * `unicode: false` selects the ASCII ramp. Empty input renders empty;
109
+ * a flat series renders mid-height cells.
110
+ */
111
+ export function sparkline(values, maxCells, unicode) {
112
+ if (values.length === 0 || maxCells <= 0)
113
+ return "";
114
+ const points = values.map((value, index) => [index, value]);
115
+ const sampled = lttb(points, Math.max(1, maxCells));
116
+ const ys = sampled.map((point) => point[1]);
117
+ const min = Math.min(...ys);
118
+ const max = Math.max(...ys);
119
+ const ramp = unicode ? BLOCK_RAMP : ASCII_RAMP;
120
+ // One shape per cell: floor(t * 8) clamped to the ramp (the top
121
+ // eighth of the range is the full block). A flat series renders
122
+ // mid-height (index 3 of 8).
123
+ return sampled
124
+ .map((point) => {
125
+ if (max === min)
126
+ return ramp[3];
127
+ const t = (point[1] - min) / (max - min);
128
+ return ramp[Math.max(0, Math.min(7, Math.floor(t * 8)))];
129
+ })
130
+ .join("");
131
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The `chart` block (UI-blocks spec §5.4): one y-axis, mixed series
3
+ * kinds, thresholds as horizontal rules.
4
+ *
5
+ * - Lines and areas draw on a {@link BrailleCanvas} (2×4 dots per
6
+ * cell); bars draw with the block ramp `▁▂▃▄▅▆▇█` on one row per
7
+ * tick; stacked `area`/`bar` series accumulate.
8
+ * - A threshold draws as a dashed rule (`╌`, ASCII `-`) in its tone.
9
+ * - Below 30 cells the chart degrades to a sparkline plus the latest
10
+ * value per series (§12.3); below 80 the legend moves below the
11
+ * plot.
12
+ * - Long series downsample with the shared `lttb` before plotting.
13
+ */
14
+ import type { Component } from "@earendil-works/pi-tui";
15
+ import type { ChartBlock, ChartSeries } from "@sigrun/shared/blocks";
16
+ import { type BlockCtx } from "./context.js";
17
+ /** `chart`: the spec §5.4 block. */
18
+ export declare function renderChart(block: ChartBlock, ctx: BlockCtx): Component;
19
+ /** Re-exported so the render dispatch imports one module per block. */
20
+ export type { ChartSeries };