@h-rig/cli 0.0.6-alpha.89 → 0.0.6-alpha.90

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 (231) hide show
  1. package/dist/bin/build-rig-binaries.js +8 -40
  2. package/dist/bin/rig.js +12519 -26675
  3. package/dist/src/app/board.js +74 -693
  4. package/dist/src/app/drone-ui.js +1 -1
  5. package/dist/src/app/theme.js +0 -1
  6. package/dist/src/commands/_async-ui.js +1 -1
  7. package/dist/src/commands/_authority-runs.d.ts +1 -1
  8. package/dist/src/commands/_authority-runs.js +12 -2
  9. package/dist/src/commands/_cli-format.d.ts +1 -10
  10. package/dist/src/commands/_cli-format.js +2 -5
  11. package/dist/src/commands/_connection-state.d.ts +1 -11
  12. package/dist/src/commands/_connection-state.js +5 -50
  13. package/dist/src/commands/_doctor-checks.js +40 -501
  14. package/dist/src/commands/_help-catalog.js +17 -99
  15. package/dist/src/commands/_json-output.js +0 -4
  16. package/dist/src/commands/_operator-view.js +54 -575
  17. package/dist/src/commands/_pi-frontend.d.ts +0 -27
  18. package/dist/src/commands/_pi-frontend.js +52 -576
  19. package/dist/src/commands/_preflight.js +66 -553
  20. package/dist/src/commands/_server-client.d.ts +0 -33
  21. package/dist/src/commands/_server-client.js +46 -541
  22. package/dist/src/commands/_snapshot-upload.js +42 -503
  23. package/dist/src/commands/_spinner.js +1 -1
  24. package/dist/src/commands/agent.js +12 -2
  25. package/dist/src/commands/browser.js +1 -1
  26. package/dist/src/commands/connect.js +15 -626
  27. package/dist/src/commands/doctor.js +41 -502
  28. package/dist/src/commands/github.js +51 -584
  29. package/dist/src/commands/inbox.js +41 -502
  30. package/dist/src/commands/init.js +74 -561
  31. package/dist/src/commands/inspect.js +41 -502
  32. package/dist/src/commands/run.js +54 -578
  33. package/dist/src/commands/server.js +163 -692
  34. package/dist/src/commands/setup.js +46 -507
  35. package/dist/src/commands/stats.js +58 -601
  36. package/dist/src/commands/task-run-driver.js +58 -509
  37. package/dist/src/commands/task.js +110 -729
  38. package/dist/src/commands.js +237 -1112
  39. package/dist/src/index.js +244 -1123
  40. package/dist/src/launcher.js +0 -4
  41. package/package.json +9 -13
  42. package/dist/src/app-opentui/adapters/command.d.ts +0 -2
  43. package/dist/src/app-opentui/adapters/command.js +0 -329
  44. package/dist/src/app-opentui/adapters/common.d.ts +0 -56
  45. package/dist/src/app-opentui/adapters/common.js +0 -153
  46. package/dist/src/app-opentui/adapters/doctor.d.ts +0 -9
  47. package/dist/src/app-opentui/adapters/doctor.js +0 -1217
  48. package/dist/src/app-opentui/adapters/family.d.ts +0 -62
  49. package/dist/src/app-opentui/adapters/family.js +0 -14855
  50. package/dist/src/app-opentui/adapters/fleet.d.ts +0 -14
  51. package/dist/src/app-opentui/adapters/fleet.js +0 -1335
  52. package/dist/src/app-opentui/adapters/inbox.d.ts +0 -43
  53. package/dist/src/app-opentui/adapters/inbox.js +0 -1944
  54. package/dist/src/app-opentui/adapters/init.d.ts +0 -11
  55. package/dist/src/app-opentui/adapters/init.js +0 -2818
  56. package/dist/src/app-opentui/adapters/inspect.d.ts +0 -52
  57. package/dist/src/app-opentui/adapters/inspect.js +0 -1455
  58. package/dist/src/app-opentui/adapters/pi-attach.d.ts +0 -32
  59. package/dist/src/app-opentui/adapters/pi-attach.js +0 -2101
  60. package/dist/src/app-opentui/adapters/pi.d.ts +0 -23
  61. package/dist/src/app-opentui/adapters/pi.js +0 -363
  62. package/dist/src/app-opentui/adapters/plugin.d.ts +0 -84
  63. package/dist/src/app-opentui/adapters/plugin.js +0 -544
  64. package/dist/src/app-opentui/adapters/repo.d.ts +0 -37
  65. package/dist/src/app-opentui/adapters/repo.js +0 -186
  66. package/dist/src/app-opentui/adapters/run-detail.d.ts +0 -27
  67. package/dist/src/app-opentui/adapters/run-detail.js +0 -1441
  68. package/dist/src/app-opentui/adapters/server.d.ts +0 -48
  69. package/dist/src/app-opentui/adapters/server.js +0 -1561
  70. package/dist/src/app-opentui/adapters/tasks.d.ts +0 -64
  71. package/dist/src/app-opentui/adapters/tasks.js +0 -4524
  72. package/dist/src/app-opentui/adapters/workspace.d.ts +0 -49
  73. package/dist/src/app-opentui/adapters/workspace.js +0 -333
  74. package/dist/src/app-opentui/autocomplete.d.ts +0 -20
  75. package/dist/src/app-opentui/autocomplete.js +0 -578
  76. package/dist/src/app-opentui/bootstrap.d.ts +0 -11
  77. package/dist/src/app-opentui/bootstrap.js +0 -27833
  78. package/dist/src/app-opentui/command-palette.d.ts +0 -3
  79. package/dist/src/app-opentui/command-palette.js +0 -1038
  80. package/dist/src/app-opentui/command-pty-host.d.ts +0 -62
  81. package/dist/src/app-opentui/command-pty-host.js +0 -248
  82. package/dist/src/app-opentui/drone.d.ts +0 -12
  83. package/dist/src/app-opentui/drone.js +0 -230
  84. package/dist/src/app-opentui/events.d.ts +0 -7
  85. package/dist/src/app-opentui/events.js +0 -28
  86. package/dist/src/app-opentui/fleet-stats.d.ts +0 -32
  87. package/dist/src/app-opentui/fleet-stats.js +0 -114
  88. package/dist/src/app-opentui/focus-manager.d.ts +0 -14
  89. package/dist/src/app-opentui/focus-manager.js +0 -24
  90. package/dist/src/app-opentui/index.d.ts +0 -8
  91. package/dist/src/app-opentui/index.js +0 -5260
  92. package/dist/src/app-opentui/intent.d.ts +0 -3
  93. package/dist/src/app-opentui/intent.js +0 -365
  94. package/dist/src/app-opentui/keymap.d.ts +0 -21
  95. package/dist/src/app-opentui/keymap.js +0 -1377
  96. package/dist/src/app-opentui/launch-routing.d.ts +0 -16
  97. package/dist/src/app-opentui/launch-routing.js +0 -55
  98. package/dist/src/app-opentui/layout.d.ts +0 -22
  99. package/dist/src/app-opentui/layout.js +0 -51
  100. package/dist/src/app-opentui/list-search.d.ts +0 -36
  101. package/dist/src/app-opentui/list-search.js +0 -130
  102. package/dist/src/app-opentui/pi-host-child.d.ts +0 -2
  103. package/dist/src/app-opentui/pi-host-child.js +0 -1299
  104. package/dist/src/app-opentui/pi-pty-host.d.ts +0 -28
  105. package/dist/src/app-opentui/pi-pty-host.js +0 -10
  106. package/dist/src/app-opentui/react/App.d.ts +0 -9
  107. package/dist/src/app-opentui/react/App.js +0 -3866
  108. package/dist/src/app-opentui/react/Backdrop.d.ts +0 -5
  109. package/dist/src/app-opentui/react/Backdrop.js +0 -823
  110. package/dist/src/app-opentui/react/ChromeHost.d.ts +0 -5
  111. package/dist/src/app-opentui/react/ChromeHost.js +0 -1539
  112. package/dist/src/app-opentui/react/SceneFrameView.d.ts +0 -7
  113. package/dist/src/app-opentui/react/SceneFrameView.js +0 -579
  114. package/dist/src/app-opentui/react/context.d.ts +0 -17
  115. package/dist/src/app-opentui/react/context.js +0 -37
  116. package/dist/src/app-opentui/react/launch.d.ts +0 -2
  117. package/dist/src/app-opentui/react/launch.js +0 -4897
  118. package/dist/src/app-opentui/react/nav.d.ts +0 -18
  119. package/dist/src/app-opentui/react/nav.js +0 -54
  120. package/dist/src/app-opentui/react/scroll.d.ts +0 -12
  121. package/dist/src/app-opentui/react/scroll.js +0 -21
  122. package/dist/src/app-opentui/react/syntax.d.ts +0 -2
  123. package/dist/src/app-opentui/react/syntax.js +0 -65
  124. package/dist/src/app-opentui/registry.d.ts +0 -4
  125. package/dist/src/app-opentui/registry.js +0 -22876
  126. package/dist/src/app-opentui/remote-link.d.ts +0 -10
  127. package/dist/src/app-opentui/remote-link.js +0 -47
  128. package/dist/src/app-opentui/render/ascii-fleet.d.ts +0 -15
  129. package/dist/src/app-opentui/render/ascii-fleet.js +0 -82
  130. package/dist/src/app-opentui/render/constants.d.ts +0 -30
  131. package/dist/src/app-opentui/render/constants.js +0 -64
  132. package/dist/src/app-opentui/render/graphics.d.ts +0 -40
  133. package/dist/src/app-opentui/render/graphics.js +0 -713
  134. package/dist/src/app-opentui/render/hover.d.ts +0 -11
  135. package/dist/src/app-opentui/render/hover.js +0 -34
  136. package/dist/src/app-opentui/render/native-host.d.ts +0 -37
  137. package/dist/src/app-opentui/render/native-host.js +0 -180
  138. package/dist/src/app-opentui/render/panel-layout.d.ts +0 -38
  139. package/dist/src/app-opentui/render/panel-layout.js +0 -48
  140. package/dist/src/app-opentui/render/panels.d.ts +0 -12
  141. package/dist/src/app-opentui/render/panels.js +0 -288
  142. package/dist/src/app-opentui/render/preloader.d.ts +0 -10
  143. package/dist/src/app-opentui/render/preloader.js +0 -166
  144. package/dist/src/app-opentui/render/scene.d.ts +0 -68
  145. package/dist/src/app-opentui/render/scene.js +0 -300
  146. package/dist/src/app-opentui/render/terminal-handoff.d.ts +0 -16
  147. package/dist/src/app-opentui/render/terminal-handoff.js +0 -14
  148. package/dist/src/app-opentui/render/text.d.ts +0 -29
  149. package/dist/src/app-opentui/render/text.js +0 -177
  150. package/dist/src/app-opentui/render/type-bar.d.ts +0 -15
  151. package/dist/src/app-opentui/render/type-bar.js +0 -212
  152. package/dist/src/app-opentui/runtime-resources.d.ts +0 -16
  153. package/dist/src/app-opentui/runtime-resources.js +0 -62
  154. package/dist/src/app-opentui/runtime.d.ts +0 -45
  155. package/dist/src/app-opentui/runtime.js +0 -5232
  156. package/dist/src/app-opentui/scenes/command.d.ts +0 -3
  157. package/dist/src/app-opentui/scenes/command.js +0 -118
  158. package/dist/src/app-opentui/scenes/doctor.d.ts +0 -3
  159. package/dist/src/app-opentui/scenes/doctor.js +0 -296
  160. package/dist/src/app-opentui/scenes/error.d.ts +0 -2
  161. package/dist/src/app-opentui/scenes/error.js +0 -277
  162. package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +0 -2
  163. package/dist/src/app-opentui/scenes/family-domains/agent.js +0 -349
  164. package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +0 -2
  165. package/dist/src/app-opentui/scenes/family-domains/browser.js +0 -196
  166. package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +0 -2
  167. package/dist/src/app-opentui/scenes/family-domains/dist.js +0 -244
  168. package/dist/src/app-opentui/scenes/family-domains/git.d.ts +0 -2
  169. package/dist/src/app-opentui/scenes/family-domains/git.js +0 -196
  170. package/dist/src/app-opentui/scenes/family-domains/github.d.ts +0 -2
  171. package/dist/src/app-opentui/scenes/family-domains/github.js +0 -275
  172. package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +0 -2
  173. package/dist/src/app-opentui/scenes/family-domains/harness.js +0 -153
  174. package/dist/src/app-opentui/scenes/family-domains/index.d.ts +0 -4
  175. package/dist/src/app-opentui/scenes/family-domains/index.js +0 -1680
  176. package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +0 -76
  177. package/dist/src/app-opentui/scenes/family-domains/kit.js +0 -306
  178. package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +0 -2
  179. package/dist/src/app-opentui/scenes/family-domains/profile.js +0 -213
  180. package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +0 -2
  181. package/dist/src/app-opentui/scenes/family-domains/queue.js +0 -147
  182. package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +0 -2
  183. package/dist/src/app-opentui/scenes/family-domains/remote.js +0 -519
  184. package/dist/src/app-opentui/scenes/family-domains/review.d.ts +0 -2
  185. package/dist/src/app-opentui/scenes/family-domains/review.js +0 -281
  186. package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +0 -2
  187. package/dist/src/app-opentui/scenes/family-domains/setup.js +0 -268
  188. package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +0 -2
  189. package/dist/src/app-opentui/scenes/family-domains/stats.js +0 -371
  190. package/dist/src/app-opentui/scenes/family.d.ts +0 -3
  191. package/dist/src/app-opentui/scenes/family.js +0 -2199
  192. package/dist/src/app-opentui/scenes/fleet.d.ts +0 -3
  193. package/dist/src/app-opentui/scenes/fleet.js +0 -766
  194. package/dist/src/app-opentui/scenes/handoff.d.ts +0 -2
  195. package/dist/src/app-opentui/scenes/handoff.js +0 -455
  196. package/dist/src/app-opentui/scenes/help.d.ts +0 -3
  197. package/dist/src/app-opentui/scenes/help.js +0 -725
  198. package/dist/src/app-opentui/scenes/inbox.d.ts +0 -3
  199. package/dist/src/app-opentui/scenes/inbox.js +0 -427
  200. package/dist/src/app-opentui/scenes/init.d.ts +0 -3
  201. package/dist/src/app-opentui/scenes/init.js +0 -181
  202. package/dist/src/app-opentui/scenes/inspect.d.ts +0 -3
  203. package/dist/src/app-opentui/scenes/inspect.js +0 -794
  204. package/dist/src/app-opentui/scenes/main.d.ts +0 -3
  205. package/dist/src/app-opentui/scenes/main.js +0 -332
  206. package/dist/src/app-opentui/scenes/pi.d.ts +0 -3
  207. package/dist/src/app-opentui/scenes/pi.js +0 -509
  208. package/dist/src/app-opentui/scenes/plugin.d.ts +0 -3
  209. package/dist/src/app-opentui/scenes/plugin.js +0 -487
  210. package/dist/src/app-opentui/scenes/repo.d.ts +0 -3
  211. package/dist/src/app-opentui/scenes/repo.js +0 -425
  212. package/dist/src/app-opentui/scenes/run-detail.d.ts +0 -3
  213. package/dist/src/app-opentui/scenes/run-detail.js +0 -467
  214. package/dist/src/app-opentui/scenes/server.d.ts +0 -3
  215. package/dist/src/app-opentui/scenes/server.js +0 -378
  216. package/dist/src/app-opentui/scenes/tasks.d.ts +0 -3
  217. package/dist/src/app-opentui/scenes/tasks.js +0 -768
  218. package/dist/src/app-opentui/scenes/workspace.d.ts +0 -3
  219. package/dist/src/app-opentui/scenes/workspace.js +0 -427
  220. package/dist/src/app-opentui/selectable.d.ts +0 -19
  221. package/dist/src/app-opentui/selectable.js +0 -80
  222. package/dist/src/app-opentui/state.d.ts +0 -4
  223. package/dist/src/app-opentui/state.js +0 -399
  224. package/dist/src/app-opentui/surface-catalog.d.ts +0 -20
  225. package/dist/src/app-opentui/surface-catalog.js +0 -542
  226. package/dist/src/app-opentui/theme.d.ts +0 -59
  227. package/dist/src/app-opentui/theme.js +0 -142
  228. package/dist/src/app-opentui/types.d.ts +0 -313
  229. package/dist/src/app-opentui/types.js +0 -1
  230. package/dist/src/commands/_server-events.d.ts +0 -26
  231. package/dist/src/commands/_server-events.js +0 -715
@@ -1,62 +0,0 @@
1
- export type CommandPtyHostStatus = "starting" | "running" | "exited" | "failed";
2
- export type CommandPtyHostSnapshot = {
3
- readonly command: readonly string[];
4
- readonly label: string;
5
- readonly status: CommandPtyHostStatus;
6
- readonly cols: number;
7
- readonly rows: number;
8
- readonly lines: readonly string[];
9
- readonly message?: string;
10
- readonly exitCode?: number;
11
- readonly signal?: string | null;
12
- };
13
- type CommandPtyInput = string | Uint8Array<ArrayBufferLike> | BufferSource;
14
- export type CommandPtyHostOptions = {
15
- readonly argv: readonly string[];
16
- readonly projectRoot: string;
17
- readonly cols: number;
18
- readonly rows: number;
19
- readonly label?: string;
20
- readonly env?: NodeJS.ProcessEnv;
21
- readonly onSnapshot?: (snapshot: CommandPtyHostSnapshot) => void;
22
- readonly onExit?: (snapshot: CommandPtyHostSnapshot) => void;
23
- readonly onError?: (error: unknown, snapshot: CommandPtyHostSnapshot) => void;
24
- };
25
- export declare function getActiveCommandHost(): CommandPtyHost | null;
26
- export declare function stopActiveCommandHost(reason?: string): void;
27
- export declare function startCommandPtyHost(options: CommandPtyHostOptions): Promise<CommandPtyHost>;
28
- export declare class CommandPtyHost {
29
- private readonly argv;
30
- private readonly projectRoot;
31
- private readonly label;
32
- private readonly env?;
33
- private readonly onSnapshot?;
34
- private readonly onExit?;
35
- private readonly onError?;
36
- private readonly terminal;
37
- private readonly decoder;
38
- private proc;
39
- private pty;
40
- private status;
41
- private cols;
42
- private rows;
43
- private message;
44
- private exitCode;
45
- private signal;
46
- private notifyTimer;
47
- private _disposed;
48
- constructor(options: CommandPtyHostOptions);
49
- get disposed(): boolean;
50
- get snapshot(): CommandPtyHostSnapshot;
51
- start(): Promise<void>;
52
- write(data: CommandPtyInput): void;
53
- resize(cols: number, rows: number): void;
54
- dispose(reason?: string, options?: {
55
- readonly kill?: boolean;
56
- readonly notify?: boolean;
57
- }): void;
58
- private handlePtyData;
59
- private emitSnapshotSoon;
60
- private createSnapshot;
61
- }
62
- export {};
@@ -1,248 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/command-pty-host.ts
3
- import { basename } from "path";
4
- import { fileURLToPath } from "url";
5
- import { Terminal as XtermTerminal } from "@xterm/headless";
6
- var MIN_COLS = 40;
7
- var MIN_ROWS = 10;
8
- var MAX_ROWS = 300;
9
- var MAX_SNAPSHOT_LINES = 420;
10
- var SNAPSHOT_DELAY_MS = 80;
11
- var fallbackCliScriptPath = fileURLToPath(new URL("../../bin/rig.ts", import.meta.url));
12
- var activeHost = null;
13
- function clampCols(cols) {
14
- return Math.max(MIN_COLS, Math.trunc(cols || 120));
15
- }
16
- function clampRows(rows) {
17
- return Math.max(MIN_ROWS, Math.min(MAX_ROWS, Math.trunc(rows || 36)));
18
- }
19
- function childCommandPrefix() {
20
- const execName = basename(process.execPath).toLowerCase();
21
- const currentEntry = process.argv[1];
22
- if (execName === "bun" || execName === "bun.exe") {
23
- return currentEntry ? [process.execPath, currentEntry] : [process.execPath, fallbackCliScriptPath];
24
- }
25
- return [process.execPath];
26
- }
27
- function withEnv(base) {
28
- const env = {};
29
- for (const [key, value] of Object.entries(base ?? process.env)) {
30
- if (key === "NO_COLOR")
31
- continue;
32
- if (typeof value === "string")
33
- env[key] = value;
34
- }
35
- return {
36
- ...env,
37
- TERM: "xterm-256color",
38
- COLORTERM: "truecolor",
39
- FORCE_COLOR: env.FORCE_COLOR ?? "1",
40
- RIG_PLAIN: "1",
41
- RIG_OPENTUI_COMMAND_HOST: "1",
42
- RIG_CLI_PLAIN_HELP: env.RIG_CLI_PLAIN_HELP ?? "1"
43
- };
44
- }
45
- function commandLabel(argv, fallback) {
46
- const command = argv.join(" ").trim();
47
- return fallback?.trim() || (command ? `rig ${command}` : "rig");
48
- }
49
- function getActiveCommandHost() {
50
- return activeHost && !activeHost.disposed ? activeHost : null;
51
- }
52
- function stopActiveCommandHost(reason = "detach") {
53
- activeHost?.dispose(reason);
54
- activeHost = null;
55
- }
56
- async function startCommandPtyHost(options) {
57
- activeHost?.dispose("replace");
58
- const host = new CommandPtyHost(options);
59
- activeHost = host;
60
- await host.start();
61
- return host;
62
- }
63
-
64
- class CommandPtyHost {
65
- argv;
66
- projectRoot;
67
- label;
68
- env;
69
- onSnapshot;
70
- onExit;
71
- onError;
72
- terminal;
73
- decoder = new TextDecoder("utf-8");
74
- proc = null;
75
- pty = null;
76
- status = "starting";
77
- cols;
78
- rows;
79
- message = "starting command";
80
- exitCode;
81
- signal;
82
- notifyTimer = null;
83
- _disposed = false;
84
- constructor(options) {
85
- this.argv = [...options.argv];
86
- this.projectRoot = options.projectRoot;
87
- this.label = commandLabel(options.argv, options.label);
88
- this.env = options.env;
89
- this.cols = clampCols(options.cols);
90
- this.rows = clampRows(options.rows);
91
- this.onSnapshot = options.onSnapshot;
92
- this.onExit = options.onExit;
93
- this.onError = options.onError;
94
- this.terminal = new XtermTerminal({ allowProposedApi: true, cols: this.cols, rows: this.rows, scrollback: 2000 });
95
- }
96
- get disposed() {
97
- return this._disposed;
98
- }
99
- get snapshot() {
100
- return this.createSnapshot();
101
- }
102
- async start() {
103
- if (this._disposed)
104
- throw new Error("Command PTY host is disposed.");
105
- if (typeof Bun.Terminal !== "function") {
106
- throw new Error("Bun native PTY is unavailable in this runtime. Command host requires Bun.Terminal.");
107
- }
108
- const spawnOptions = {
109
- cwd: this.projectRoot,
110
- env: withEnv(this.env),
111
- terminal: {
112
- cols: this.cols,
113
- rows: this.rows,
114
- name: "xterm-256color",
115
- data: (_terminal, data) => this.handlePtyData(data)
116
- }
117
- };
118
- const proc = Bun.spawn([...childCommandPrefix(), ...this.argv], spawnOptions);
119
- if (!proc.terminal)
120
- throw new Error("Bun did not attach a terminal to the command child process.");
121
- this.proc = proc;
122
- this.pty = proc.terminal;
123
- this.status = "running";
124
- this.message = "running";
125
- this.emitSnapshotSoon(0);
126
- proc.exited.then((exitCode) => {
127
- if (this._disposed)
128
- return;
129
- this.status = exitCode === 0 ? "exited" : "failed";
130
- this.exitCode = exitCode;
131
- this.signal = null;
132
- this.message = exitCode === 0 ? "completed" : `exited with code ${exitCode}`;
133
- const snapshot = this.createSnapshot();
134
- this.onSnapshot?.(snapshot);
135
- this.onExit?.(snapshot);
136
- if (activeHost === this)
137
- activeHost = null;
138
- this.dispose("exit", { kill: false, notify: false });
139
- }).catch((error) => {
140
- if (this._disposed)
141
- return;
142
- this.status = "failed";
143
- this.message = error instanceof Error ? error.message : String(error);
144
- const snapshot = this.createSnapshot();
145
- this.onSnapshot?.(snapshot);
146
- this.onError?.(error, snapshot);
147
- if (activeHost === this)
148
- activeHost = null;
149
- this.dispose("error", { kill: false, notify: false });
150
- });
151
- }
152
- write(data) {
153
- if (this._disposed || !this.pty)
154
- return;
155
- try {
156
- this.pty.write(data);
157
- } catch (error) {
158
- this.status = "failed";
159
- this.message = error instanceof Error ? error.message : String(error);
160
- const snapshot = this.createSnapshot();
161
- this.onSnapshot?.(snapshot);
162
- this.onError?.(error, snapshot);
163
- }
164
- }
165
- resize(cols, rows) {
166
- const nextCols = clampCols(cols);
167
- const nextRows = clampRows(rows);
168
- if (nextCols === this.cols && nextRows === this.rows)
169
- return;
170
- this.cols = nextCols;
171
- this.rows = nextRows;
172
- this.terminal.resize(nextCols, nextRows);
173
- try {
174
- this.pty?.resize(nextCols, nextRows);
175
- } catch {}
176
- this.emitSnapshotSoon(0);
177
- }
178
- dispose(reason = "dispose", options = {}) {
179
- if (this._disposed)
180
- return;
181
- this._disposed = true;
182
- if (this.notifyTimer)
183
- clearTimeout(this.notifyTimer);
184
- this.notifyTimer = null;
185
- if (options.kill !== false) {
186
- try {
187
- this.proc?.kill("SIGTERM");
188
- } catch {}
189
- }
190
- try {
191
- this.pty?.close();
192
- } catch {}
193
- try {
194
- this.terminal.dispose();
195
- } catch {}
196
- if (activeHost === this)
197
- activeHost = null;
198
- if (options.notify) {
199
- this.message = reason;
200
- this.onSnapshot?.(this.createSnapshot(reason));
201
- }
202
- }
203
- handlePtyData(data) {
204
- if (this._disposed)
205
- return;
206
- this.decoder.decode(data, { stream: true });
207
- this.terminal.write(data, () => this.emitSnapshotSoon());
208
- }
209
- emitSnapshotSoon(delayMs = SNAPSHOT_DELAY_MS) {
210
- if (this._disposed || this.notifyTimer)
211
- return;
212
- this.notifyTimer = setTimeout(() => {
213
- this.notifyTimer = null;
214
- if (this._disposed)
215
- return;
216
- this.onSnapshot?.(this.createSnapshot());
217
- }, delayMs);
218
- }
219
- createSnapshot(message = this.message) {
220
- const buffer = this.terminal.buffer.active;
221
- const end = buffer.length;
222
- const start = Math.max(0, end - MAX_SNAPSHOT_LINES);
223
- const lines = [];
224
- for (let row = start;row < end; row += 1) {
225
- const line = buffer.getLine(row);
226
- lines.push((line?.translateToString(false) ?? "").slice(0, this.cols));
227
- }
228
- while (lines.length < this.rows)
229
- lines.push("");
230
- return {
231
- command: this.argv,
232
- label: this.label,
233
- status: this.status,
234
- cols: this.cols,
235
- rows: this.rows,
236
- lines,
237
- message,
238
- ...this.exitCode !== undefined ? { exitCode: this.exitCode } : {},
239
- ...this.signal !== undefined ? { signal: this.signal } : {}
240
- };
241
- }
242
- }
243
- export {
244
- stopActiveCommandHost,
245
- startCommandPtyHost,
246
- getActiveCommandHost,
247
- CommandPtyHost
248
- };
@@ -1,12 +0,0 @@
1
- import type { AppSceneLine } from "./types";
2
- export declare function miniDroneLines(tick: number, align?: AppSceneLine["align"], phase?: number): AppSceneLine[];
3
- export declare function leadMarkLines(tick: number, align?: AppSceneLine["align"], phase?: number): AppSceneLine[];
4
- export declare function brandFleetLines(tick: number, align?: AppSceneLine["align"]): AppSceneLine[];
5
- export declare function pipelineSignalLines(tick: number, align?: AppSceneLine["align"]): AppSceneLine[];
6
- export declare function orbitSignalLines(tick: number, align?: AppSceneLine["align"]): AppSceneLine[];
7
- export declare function dronePlainFrame(tick: number): string[];
8
- export declare function bigDroneLines(tick: number, align?: AppSceneLine["align"]): AppSceneLine[];
9
- export declare function actionDrone(tick: number, phase?: number): string;
10
- export declare function actionDroneLine(tick: number, text: string, fg?: string): AppSceneLine;
11
- export declare function errorDrone(tick: number): AppSceneLine[];
12
- export declare function handoffDrone(tick: number): AppSceneLine[];
@@ -1,230 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/drone.ts
3
- import { RGBA, StyledText, TextAttributes as TextAttributes2 } from "@opentui/core";
4
-
5
- // packages/cli/src/app-opentui/theme.ts
6
- import {
7
- bold as otuiBold,
8
- dim as otuiDim,
9
- fg as otuiFg,
10
- t,
11
- TextAttributes
12
- } from "@opentui/core";
13
- var RIG_UI = {
14
- bg: "#070809",
15
- bg2: "#0b0c0e",
16
- panel: "#101115",
17
- panel2: "#14161b",
18
- hover: "#181b24",
19
- glass: "#1e2230",
20
- border: "#2a2e3a",
21
- ink: "#f4f5f8",
22
- ink2: "#c7c9d3",
23
- ink3: "#9aa0ae",
24
- ink4: "#787b86",
25
- lime: "#ccff4d",
26
- limeDim: "#a9d63f",
27
- cyan: "#56d8ff",
28
- cyanDim: "#3f9fbd",
29
- red: "#ff5d5d",
30
- yellow: "#ffd24d",
31
- magenta: "#ff79b0"
32
- };
33
- var styles = {
34
- ink: otuiFg(RIG_UI.ink),
35
- ink2: otuiFg(RIG_UI.ink2),
36
- ink3: otuiFg(RIG_UI.ink3),
37
- ink4: otuiFg(RIG_UI.ink4),
38
- lime: otuiFg(RIG_UI.lime),
39
- limeDim: otuiFg(RIG_UI.limeDim),
40
- cyan: otuiFg(RIG_UI.cyan),
41
- red: otuiFg(RIG_UI.red),
42
- yellow: otuiFg(RIG_UI.yellow),
43
- magenta: otuiFg(RIG_UI.magenta)
44
- };
45
-
46
- // packages/cli/src/app-opentui/drone.ts
47
- var MINI_DRONE = [
48
- "(!!!) (!!!)",
49
- " \\%==%/ ",
50
- " %%?%% ",
51
- " /%==%\\ ",
52
- "(!!!) (!!!)"
53
- ];
54
- var LEAD_MARK = [
55
- " .-=-. ",
56
- "=%%?%%=",
57
- " '-=-' "
58
- ];
59
- var BLADE_FRAMES = ["---", "\\\\\\", "|||", "///"];
60
- var EYE_FRAMES = ["o", "@", "\u2022", "."];
61
- var COLOR = {
62
- body: RGBA.fromHex(RIG_UI.lime),
63
- mini: RGBA.fromHex(RIG_UI.limeDim),
64
- rotor: RGBA.fromHex(RIG_UI.cyan),
65
- path: RGBA.fromHex(RIG_UI.cyan),
66
- eye: RGBA.fromHex(RIG_UI.ink),
67
- dim: RGBA.fromHex(RIG_UI.ink4),
68
- ink: RGBA.fromHex(RIG_UI.ink2)
69
- };
70
- function bladeForTick(tick, phase = 0) {
71
- return BLADE_FRAMES[(Math.floor(tick / 3) + phase) % BLADE_FRAMES.length];
72
- }
73
- function eyeForTick(tick, phase = 0) {
74
- const pulse = Math.sin(tick * 0.09 + phase);
75
- return pulse > 0.55 ? EYE_FRAMES[1] : pulse > 0.1 ? EYE_FRAMES[0] : pulse > -0.45 ? EYE_FRAMES[2] : EYE_FRAMES[3];
76
- }
77
- function chunk(text, fg, bold = false, dim = false) {
78
- let attributes = TextAttributes2.NONE;
79
- if (bold)
80
- attributes |= TextAttributes2.BOLD;
81
- if (dim)
82
- attributes |= TextAttributes2.DIM;
83
- return { __isChunk: true, text, fg, ...attributes !== TextAttributes2.NONE ? { attributes } : {} };
84
- }
85
- function styledLine(text, colorFor) {
86
- const chunks = [];
87
- let run = "";
88
- let runColor = null;
89
- const flush = () => {
90
- if (!run || !runColor)
91
- return;
92
- chunks.push(chunk(run, COLOR[runColor], runColor === "body" || runColor === "eye", runColor === "dim"));
93
- run = "";
94
- };
95
- for (const char of text) {
96
- const next = colorFor(char);
97
- if (next !== runColor) {
98
- flush();
99
- runColor = next;
100
- }
101
- run += char;
102
- }
103
- flush();
104
- return new StyledText(chunks.length > 0 ? chunks : [chunk("", COLOR.ink)]);
105
- }
106
- function droneColor(char) {
107
- if (char === "?" || char === "o" || char === "@" || char === "\u2022")
108
- return "eye";
109
- if (char === "%" || char === "=")
110
- return "mini";
111
- if (char === "$")
112
- return "body";
113
- if (char === "(" || char === ")" || char === "/" || char === "\\" || char === "|" || char === "-")
114
- return "rotor";
115
- if (char === "\xB7" || char === "\u2022" || char === "'" || char === ".")
116
- return "path";
117
- if (char.trim() === "")
118
- return "dim";
119
- return "ink";
120
- }
121
- function motionColor(char) {
122
- if (char === "\u25CF" || char === "\u25C6" || char === "\u25C9")
123
- return "body";
124
- if (char === "\u2022" || char === "\xB7" || char === "\u2500" || char === "\u2502" || char === "\u2571" || char === "\u2572" || char === "\u256D" || char === "\u256E" || char === "\u2570" || char === "\u256F")
125
- return "path";
126
- if (char === "\u258C" || char === "\u2590" || char === "\u2581" || char === "\u2594")
127
- return "mini";
128
- return droneColor(char);
129
- }
130
- function materializeDrone(lines, tick, phase = 0) {
131
- const blade = bladeForTick(tick, phase);
132
- const eye = eyeForTick(tick, phase);
133
- return lines.map((line) => line.replaceAll("!!!", blade).replaceAll("?", eye));
134
- }
135
- function miniDroneLines(tick, align = "left", phase = 0) {
136
- return materializeDrone(MINI_DRONE, tick, phase).map((text) => ({
137
- text,
138
- styledText: styledLine(text, droneColor),
139
- fg: RIG_UI.limeDim,
140
- align
141
- }));
142
- }
143
- function leadMarkLines(tick, align = "left", phase = 0) {
144
- return materializeDrone(LEAD_MARK, tick, phase).map((text) => ({
145
- text,
146
- styledText: styledLine(text, droneColor),
147
- fg: RIG_UI.lime,
148
- bold: true,
149
- align
150
- }));
151
- }
152
- function brandFleetLines(tick, align = "center") {
153
- const left = materializeDrone(MINI_DRONE, tick, 0);
154
- const right = materializeDrone(MINI_DRONE, tick, 2);
155
- const lead = materializeDrone(LEAD_MARK, tick, 1);
156
- const packet = ["\xB7", "\u2022", "\u25CF", "\u2022"][Math.floor(tick / 2) % 4];
157
- const bridge = [
158
- ` ${left[0]} ${lead[0]} ${right[0]}`,
159
- ` ${left[1]} \xB7\u2500\u2500${packet}\u2500\u2500\xB7 ${lead[1]} \xB7\u2500\u2500${packet}\u2500\u2500\xB7 ${right[1]}`,
160
- ` ${left[2]} \xB7' '${lead[2]}' '\xB7 ${right[2]}`,
161
- ` ${left[3]} \u2572 signal bus \u2571 ${right[3]}`,
162
- ` ${left[4]} \xB7\u2500\u2500\u2500${packet}\u2500\u2500\u2500\u2500\u2500\u2500${packet}\u2500\u2500\u2500\xB7 ${right[4]}`
163
- ];
164
- return bridge.map((text) => ({
165
- text,
166
- styledText: styledLine(text, motionColor),
167
- fg: RIG_UI.limeDim,
168
- align
169
- }));
170
- }
171
- function pipelineSignalLines(tick, align = "center") {
172
- const stages = ["dispatch", "implement", "validate", "ship", "close"];
173
- const active = Math.floor(tick / 12) % stages.length;
174
- const packet = ["\u25CF", "\u2022", "\u25C6", "\u2022"][Math.floor(tick / 3) % 4];
175
- const rail = stages.map((stage, index) => `${index === active ? packet : "\u2022"} ${stage}`).join(" \u2500\u2500 ");
176
- const scan = stages.map((_stage, index) => index === active ? " \u258C\u258C " : " \u2502 ").join(" ");
177
- return [
178
- { text: scan, styledText: styledLine(scan, motionColor), fg: RIG_UI.limeDim, align },
179
- { text: rail, styledText: styledLine(rail, motionColor), fg: RIG_UI.ink2, align }
180
- ];
181
- }
182
- function orbitSignalLines(tick, align = "center") {
183
- const p = Math.floor(tick / 5) % 8;
184
- const dots = Array.from({ length: 8 }, (_, index) => index === p ? "\u25CF" : index === (p + 7) % 8 ? "\u2022" : "\xB7");
185
- const top = ` ${dots[0]}\u2500\u2500\u2500\u2500${dots[1]}\u2500\u2500\u2500\u2500${dots[2]} `;
186
- const mid = `${actionDrone(tick, 0)} ${dots[7]} operator bus ${dots[3]} ${actionDrone(tick, 2)}`;
187
- const bot = ` ${dots[6]}\u2500\u2500\u2500\u2500${dots[5]}\u2500\u2500\u2500\u2500${dots[4]} `;
188
- return [top, mid, bot].map((text) => ({ text, styledText: styledLine(text, motionColor), fg: RIG_UI.ink2, align }));
189
- }
190
- function dronePlainFrame(tick) {
191
- return brandFleetLines(tick).map((entry) => entry.text);
192
- }
193
- function bigDroneLines(tick, align = "center") {
194
- return brandFleetLines(tick, align);
195
- }
196
- function actionDrone(tick, phase = 0) {
197
- const blade = bladeForTick(tick, phase);
198
- const eye = eyeForTick(tick, phase);
199
- return `(${blade})\u2572${eye}\u2571(${blade})`;
200
- }
201
- function actionDroneLine(tick, text, fg = RIG_UI.ink2) {
202
- const prefix = actionDrone(tick);
203
- const content = `${prefix} ${text}`;
204
- return { text: content, styledText: styledLine(content, motionColor), fg, align: "center" };
205
- }
206
- function errorDrone(tick) {
207
- return brandFleetLines(tick).map((line, index) => ({
208
- ...line,
209
- fg: index % 2 === 0 ? RIG_UI.red : line.fg
210
- }));
211
- }
212
- function handoffDrone(tick) {
213
- return orbitSignalLines(tick).map((line, index) => ({
214
- ...line,
215
- fg: index === 1 ? RIG_UI.cyan : line.fg
216
- }));
217
- }
218
- export {
219
- pipelineSignalLines,
220
- orbitSignalLines,
221
- miniDroneLines,
222
- leadMarkLines,
223
- handoffDrone,
224
- errorDrone,
225
- dronePlainFrame,
226
- brandFleetLines,
227
- bigDroneLines,
228
- actionDroneLine,
229
- actionDrone
230
- };
@@ -1,7 +0,0 @@
1
- import type { AppEventBus } from "./types";
2
- export declare function createAppEventBus(): AppEventBus;
3
- export declare function normalizeError(error: unknown): {
4
- message: string;
5
- hint?: string;
6
- cause?: unknown;
7
- };
@@ -1,28 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/events.ts
3
- function createAppEventBus() {
4
- const listeners = new Set;
5
- return {
6
- emit(event) {
7
- for (const listener of [...listeners])
8
- listener(event);
9
- },
10
- subscribe(listener) {
11
- listeners.add(listener);
12
- return () => listeners.delete(listener);
13
- }
14
- };
15
- }
16
- function normalizeError(error) {
17
- const message = error instanceof Error ? error.message : String(error);
18
- const rawHint = error instanceof Error ? error.hint : undefined;
19
- return {
20
- message: message || "Unknown app error",
21
- ...typeof rawHint === "string" && rawHint.trim() ? { hint: rawHint.trim() } : {},
22
- cause: error
23
- };
24
- }
25
- export {
26
- normalizeError,
27
- createAppEventBus
28
- };
@@ -1,32 +0,0 @@
1
- import type { AppRunRecord } from "./adapters/fleet";
2
- import type { AppState } from "./types";
3
- export type FleetStats = {
4
- readonly total: number;
5
- readonly active: number;
6
- readonly succeeded: number;
7
- readonly failed: number;
8
- readonly byStatus: ReadonlyMap<string, number>;
9
- /** 0..1 fleet load: share of runs that are actively working. */
10
- readonly load: number;
11
- /** Recent activity series (oldest→newest) for a throughput sparkline. */
12
- readonly sparkline: readonly number[];
13
- };
14
- /** Derive fleet telemetry from a run list. Pure — same input, same output. */
15
- export declare function computeFleetStats(runs: readonly AppRunRecord[]): FleetStats;
16
- export declare function fleetStatsFromState(state: AppState): FleetStats;
17
- /** Render a 0..1 series as a unicode sparkline string. */
18
- export declare function sparklineString(values: readonly number[], width?: number): string;
19
- /** Render a 0..1 ratio as a partial-block bar of `width` cells. */
20
- export declare function barString(ratio: number, width: number): string;
21
- export type StatusSegments = {
22
- /** Block strings (█…) whose lengths are proportional to each class and sum to width. */
23
- readonly active: string;
24
- readonly done: string;
25
- readonly failed: string;
26
- readonly other: string;
27
- };
28
- /** Proportional status-distribution segments for a full-width stacked bar.
29
- * Largest-remainder apportionment so the segments always sum to exactly `width`. */
30
- export declare function statusSegments(stats: FleetStats, width: number): StatusSegments;
31
- /** A compact one-line summary suitable for a scene header strip. */
32
- export declare function fleetStatsStrip(stats: FleetStats, sparkWidth?: number): string;