@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
@@ -13,9 +13,7 @@ import {
13
13
  RigInboxInputsOutput,
14
14
  RigRunListOutput,
15
15
  RigRunShowOutput,
16
- RigServerRepairLinkOutput,
17
16
  RigServerStatusOutput,
18
- RigServerUseOutput,
19
17
  RigStatsOutput,
20
18
  RigTaskListOutput,
21
19
  RigTaskShowOutput
@@ -25,9 +23,7 @@ var CLI_OUTPUT_SCHEMAS = {
25
23
  "task show": RigTaskShowOutput,
26
24
  "run list": RigRunListOutput,
27
25
  "run show": RigRunShowOutput,
28
- "server use": RigServerUseOutput,
29
26
  "server status": RigServerStatusOutput,
30
- "server repair-link": RigServerRepairLinkOutput,
31
27
  "inbox approvals": RigInboxApprovalsOutput,
32
28
  "inbox inputs": RigInboxInputsOutput,
33
29
  "doctor check": RigDoctorCheckOutput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/cli",
3
- "version": "0.0.6-alpha.89",
3
+ "version": "0.0.6-alpha.90",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",
@@ -26,18 +26,14 @@
26
26
  "dependencies": {
27
27
  "@earendil-works/pi-coding-agent": "0.79.0",
28
28
  "@earendil-works/pi-tui": "^0.79.0",
29
- "@opentui/core": "^0.4.1",
30
- "@opentui/react": "0.4.1",
31
- "@rig/client": "npm:@h-rig/client@0.0.6-alpha.89",
32
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.89",
33
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.89",
34
- "@rig/pi-rig": "npm:@h-rig/pi-rig@0.0.6-alpha.89",
35
- "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.89",
36
- "@rig/server": "npm:@h-rig/server@0.0.6-alpha.89",
37
- "@rig/standard-plugin": "npm:@h-rig/standard-plugin@0.0.6-alpha.89",
38
- "@xterm/headless": "^6.0.0",
29
+ "@rig/client": "npm:@h-rig/client@0.0.6-alpha.90",
30
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.90",
31
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.90",
32
+ "@rig/pi-rig": "npm:@h-rig/pi-rig@0.0.6-alpha.90",
33
+ "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.90",
34
+ "@rig/server": "npm:@h-rig/server@0.0.6-alpha.90",
35
+ "@rig/standard-plugin": "npm:@h-rig/standard-plugin@0.0.6-alpha.90",
39
36
  "effect": "4.0.0-beta.78",
40
- "picocolors": "^1.1.1",
41
- "react": "^19.2.0"
37
+ "picocolors": "^1.1.1"
42
38
  }
43
39
  }
@@ -1,2 +0,0 @@
1
- import type { AppAdapterContext } from "./common";
2
- export declare function runCommandInAppPty(ctx: AppAdapterContext, argv: readonly string[]): Promise<void>;
@@ -1,329 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/adapters/common.ts
3
- function projectRootOf(ctx) {
4
- const root = ctx.rig?.projectRoot ?? ctx.projectRoot ?? ctx.getState().projectRoot;
5
- if (typeof root === "string" && root.trim())
6
- return root;
7
- throw new Error("App adapter requires a projectRoot.");
8
- }
9
- function normalizeAppError(error) {
10
- const message = error instanceof Error ? error.message : String(error);
11
- const rawHint = error instanceof Error ? error.hint : undefined;
12
- return {
13
- message,
14
- ...typeof rawHint === "string" && rawHint.trim() ? { hint: rawHint.trim() } : {}
15
- };
16
- }
17
- function emitStarted(ctx, label, optimistic) {
18
- ctx.emit({ type: "action.started", label, ...optimistic ? { optimistic } : {} });
19
- }
20
- function emitCompleted(ctx, label, data) {
21
- ctx.emit({ type: "action.completed", label, ...data ? { data } : {} });
22
- }
23
- function emitFailed(ctx, label, error, data) {
24
- if (data)
25
- patchData(ctx, data);
26
- const normalized = normalizeAppError(error);
27
- ctx.emit({
28
- type: "action.failed",
29
- label,
30
- message: normalized.message,
31
- ...normalized.hint ? { hint: normalized.hint } : {},
32
- cause: error
33
- });
34
- }
35
- function patchData(ctx, data) {
36
- ctx.emit({ type: "data.patch", data });
37
- }
38
- function patchFooter(ctx, footer) {
39
- ctx.emit({ type: "footer.patch", footer });
40
- }
41
-
42
- // packages/cli/src/app-opentui/command-pty-host.ts
43
- import { basename } from "path";
44
- import { fileURLToPath } from "url";
45
- import { Terminal as XtermTerminal } from "@xterm/headless";
46
- var MIN_COLS = 40;
47
- var MIN_ROWS = 10;
48
- var MAX_ROWS = 300;
49
- var MAX_SNAPSHOT_LINES = 420;
50
- var SNAPSHOT_DELAY_MS = 80;
51
- var fallbackCliScriptPath = fileURLToPath(new URL("../../bin/rig.ts", import.meta.url));
52
- var activeHost = null;
53
- function clampCols(cols) {
54
- return Math.max(MIN_COLS, Math.trunc(cols || 120));
55
- }
56
- function clampRows(rows) {
57
- return Math.max(MIN_ROWS, Math.min(MAX_ROWS, Math.trunc(rows || 36)));
58
- }
59
- function childCommandPrefix() {
60
- const execName = basename(process.execPath).toLowerCase();
61
- const currentEntry = process.argv[1];
62
- if (execName === "bun" || execName === "bun.exe") {
63
- return currentEntry ? [process.execPath, currentEntry] : [process.execPath, fallbackCliScriptPath];
64
- }
65
- return [process.execPath];
66
- }
67
- function withEnv(base) {
68
- const env = {};
69
- for (const [key, value] of Object.entries(base ?? process.env)) {
70
- if (key === "NO_COLOR")
71
- continue;
72
- if (typeof value === "string")
73
- env[key] = value;
74
- }
75
- return {
76
- ...env,
77
- TERM: "xterm-256color",
78
- COLORTERM: "truecolor",
79
- FORCE_COLOR: env.FORCE_COLOR ?? "1",
80
- RIG_PLAIN: "1",
81
- RIG_OPENTUI_COMMAND_HOST: "1",
82
- RIG_CLI_PLAIN_HELP: env.RIG_CLI_PLAIN_HELP ?? "1"
83
- };
84
- }
85
- function commandLabel(argv, fallback) {
86
- const command = argv.join(" ").trim();
87
- return fallback?.trim() || (command ? `rig ${command}` : "rig");
88
- }
89
- async function startCommandPtyHost(options) {
90
- activeHost?.dispose("replace");
91
- const host = new CommandPtyHost(options);
92
- activeHost = host;
93
- await host.start();
94
- return host;
95
- }
96
-
97
- class CommandPtyHost {
98
- argv;
99
- projectRoot;
100
- label;
101
- env;
102
- onSnapshot;
103
- onExit;
104
- onError;
105
- terminal;
106
- decoder = new TextDecoder("utf-8");
107
- proc = null;
108
- pty = null;
109
- status = "starting";
110
- cols;
111
- rows;
112
- message = "starting command";
113
- exitCode;
114
- signal;
115
- notifyTimer = null;
116
- _disposed = false;
117
- constructor(options) {
118
- this.argv = [...options.argv];
119
- this.projectRoot = options.projectRoot;
120
- this.label = commandLabel(options.argv, options.label);
121
- this.env = options.env;
122
- this.cols = clampCols(options.cols);
123
- this.rows = clampRows(options.rows);
124
- this.onSnapshot = options.onSnapshot;
125
- this.onExit = options.onExit;
126
- this.onError = options.onError;
127
- this.terminal = new XtermTerminal({ allowProposedApi: true, cols: this.cols, rows: this.rows, scrollback: 2000 });
128
- }
129
- get disposed() {
130
- return this._disposed;
131
- }
132
- get snapshot() {
133
- return this.createSnapshot();
134
- }
135
- async start() {
136
- if (this._disposed)
137
- throw new Error("Command PTY host is disposed.");
138
- if (typeof Bun.Terminal !== "function") {
139
- throw new Error("Bun native PTY is unavailable in this runtime. Command host requires Bun.Terminal.");
140
- }
141
- const spawnOptions = {
142
- cwd: this.projectRoot,
143
- env: withEnv(this.env),
144
- terminal: {
145
- cols: this.cols,
146
- rows: this.rows,
147
- name: "xterm-256color",
148
- data: (_terminal, data) => this.handlePtyData(data)
149
- }
150
- };
151
- const proc = Bun.spawn([...childCommandPrefix(), ...this.argv], spawnOptions);
152
- if (!proc.terminal)
153
- throw new Error("Bun did not attach a terminal to the command child process.");
154
- this.proc = proc;
155
- this.pty = proc.terminal;
156
- this.status = "running";
157
- this.message = "running";
158
- this.emitSnapshotSoon(0);
159
- proc.exited.then((exitCode) => {
160
- if (this._disposed)
161
- return;
162
- this.status = exitCode === 0 ? "exited" : "failed";
163
- this.exitCode = exitCode;
164
- this.signal = null;
165
- this.message = exitCode === 0 ? "completed" : `exited with code ${exitCode}`;
166
- const snapshot = this.createSnapshot();
167
- this.onSnapshot?.(snapshot);
168
- this.onExit?.(snapshot);
169
- if (activeHost === this)
170
- activeHost = null;
171
- this.dispose("exit", { kill: false, notify: false });
172
- }).catch((error) => {
173
- if (this._disposed)
174
- return;
175
- this.status = "failed";
176
- this.message = error instanceof Error ? error.message : String(error);
177
- const snapshot = this.createSnapshot();
178
- this.onSnapshot?.(snapshot);
179
- this.onError?.(error, snapshot);
180
- if (activeHost === this)
181
- activeHost = null;
182
- this.dispose("error", { kill: false, notify: false });
183
- });
184
- }
185
- write(data) {
186
- if (this._disposed || !this.pty)
187
- return;
188
- try {
189
- this.pty.write(data);
190
- } catch (error) {
191
- this.status = "failed";
192
- this.message = error instanceof Error ? error.message : String(error);
193
- const snapshot = this.createSnapshot();
194
- this.onSnapshot?.(snapshot);
195
- this.onError?.(error, snapshot);
196
- }
197
- }
198
- resize(cols, rows) {
199
- const nextCols = clampCols(cols);
200
- const nextRows = clampRows(rows);
201
- if (nextCols === this.cols && nextRows === this.rows)
202
- return;
203
- this.cols = nextCols;
204
- this.rows = nextRows;
205
- this.terminal.resize(nextCols, nextRows);
206
- try {
207
- this.pty?.resize(nextCols, nextRows);
208
- } catch {}
209
- this.emitSnapshotSoon(0);
210
- }
211
- dispose(reason = "dispose", options = {}) {
212
- if (this._disposed)
213
- return;
214
- this._disposed = true;
215
- if (this.notifyTimer)
216
- clearTimeout(this.notifyTimer);
217
- this.notifyTimer = null;
218
- if (options.kill !== false) {
219
- try {
220
- this.proc?.kill("SIGTERM");
221
- } catch {}
222
- }
223
- try {
224
- this.pty?.close();
225
- } catch {}
226
- try {
227
- this.terminal.dispose();
228
- } catch {}
229
- if (activeHost === this)
230
- activeHost = null;
231
- if (options.notify) {
232
- this.message = reason;
233
- this.onSnapshot?.(this.createSnapshot(reason));
234
- }
235
- }
236
- handlePtyData(data) {
237
- if (this._disposed)
238
- return;
239
- this.decoder.decode(data, { stream: true });
240
- this.terminal.write(data, () => this.emitSnapshotSoon());
241
- }
242
- emitSnapshotSoon(delayMs = SNAPSHOT_DELAY_MS) {
243
- if (this._disposed || this.notifyTimer)
244
- return;
245
- this.notifyTimer = setTimeout(() => {
246
- this.notifyTimer = null;
247
- if (this._disposed)
248
- return;
249
- this.onSnapshot?.(this.createSnapshot());
250
- }, delayMs);
251
- }
252
- createSnapshot(message = this.message) {
253
- const buffer = this.terminal.buffer.active;
254
- const end = buffer.length;
255
- const start = Math.max(0, end - MAX_SNAPSHOT_LINES);
256
- const lines = [];
257
- for (let row = start;row < end; row += 1) {
258
- const line = buffer.getLine(row);
259
- lines.push((line?.translateToString(false) ?? "").slice(0, this.cols));
260
- }
261
- while (lines.length < this.rows)
262
- lines.push("");
263
- return {
264
- command: this.argv,
265
- label: this.label,
266
- status: this.status,
267
- cols: this.cols,
268
- rows: this.rows,
269
- lines,
270
- message,
271
- ...this.exitCode !== undefined ? { exitCode: this.exitCode } : {},
272
- ...this.signal !== undefined ? { signal: this.signal } : {}
273
- };
274
- }
275
- }
276
-
277
- // packages/cli/src/app-opentui/adapters/command.ts
278
- function commandLabel2(argv) {
279
- const command = argv.join(" ").trim();
280
- return command ? `rig ${command}` : "rig";
281
- }
282
- async function runCommandInAppPty(ctx, argv) {
283
- const label = commandLabel2(argv);
284
- emitStarted(ctx, label, { command: { label, argv, status: "starting" } });
285
- patchData(ctx, {
286
- command: { label, argv, status: "starting" },
287
- commandTerminal: {
288
- command: argv,
289
- label,
290
- status: "starting",
291
- cols: 120,
292
- rows: 32,
293
- lines: [],
294
- message: "starting"
295
- }
296
- });
297
- patchFooter(ctx, { message: label });
298
- try {
299
- const host = await startCommandPtyHost({
300
- argv,
301
- projectRoot: projectRootOf(ctx),
302
- cols: 120,
303
- rows: 32,
304
- label,
305
- onSnapshot(snapshot) {
306
- patchData(ctx, { commandTerminal: snapshot, command: { label, argv, status: snapshot.status, message: snapshot.message } });
307
- patchFooter(ctx, { message: `${label} \xB7 ${snapshot.message ?? snapshot.status}` });
308
- },
309
- onExit(snapshot) {
310
- patchData(ctx, { commandTerminal: snapshot, command: { label, argv, status: snapshot.status, message: snapshot.message } });
311
- if (snapshot.status === "exited")
312
- emitCompleted(ctx, label, { exitCode: snapshot.exitCode ?? 0 });
313
- else
314
- emitFailed(ctx, label, new Error(snapshot.message ?? "Command failed"), { commandTerminal: snapshot });
315
- },
316
- onError(error, snapshot) {
317
- patchData(ctx, { commandTerminal: snapshot, command: { label, argv, status: "failed", message: snapshot.message } });
318
- emitFailed(ctx, label, error, { commandTerminal: snapshot });
319
- }
320
- });
321
- patchData(ctx, { commandTerminal: host.snapshot });
322
- } catch (error) {
323
- emitFailed(ctx, label, error);
324
- throw error;
325
- }
326
- }
327
- export {
328
- runCommandInAppPty
329
- };
@@ -1,56 +0,0 @@
1
- import type { RunnerContext } from "../../runner";
2
- import type { AppEvent, AppIntent, AppRuntime, AppSceneId } from "../types";
3
- export type AppStateLike = {
4
- readonly projectRoot?: string;
5
- readonly scene?: AppSceneId;
6
- readonly status?: string;
7
- readonly tick?: number;
8
- readonly argv?: readonly string[];
9
- readonly data?: Record<string, unknown>;
10
- readonly footer?: Record<string, unknown>;
11
- readonly [key: string]: unknown;
12
- };
13
- export type AppAdapterEvent = AppEvent;
14
- export type AppRendererHandoff = {
15
- readonly suspend?: () => void | Promise<void>;
16
- readonly resume?: () => void | Promise<void>;
17
- readonly destroy?: () => void | Promise<void>;
18
- };
19
- export type AppAdapterContext = {
20
- readonly projectRoot?: string;
21
- readonly rig?: Pick<RunnerContext, "projectRoot" | "runId" | "outputMode">;
22
- readonly renderer?: AppRendererHandoff;
23
- readonly ensureRuntime?: () => Promise<RunnerContext>;
24
- emit(event: AppAdapterEvent): void;
25
- getState(): AppStateLike;
26
- };
27
- export declare function adapterContextFromRuntime(runtime: AppRuntime, renderer?: AppRendererHandoff): AppAdapterContext;
28
- export type NormalizedAppError = {
29
- readonly message: string;
30
- readonly hint?: string;
31
- };
32
- export type CapturedConsole = {
33
- readonly result: unknown;
34
- readonly output: readonly string[];
35
- };
36
- export declare function projectRootOf(ctx: AppAdapterContext): string;
37
- export declare function runtimeOf(ctx: AppAdapterContext): Promise<RunnerContext>;
38
- export declare function normalizeAppError(error: unknown): NormalizedAppError;
39
- export declare function emitStarted(ctx: AppAdapterContext, label: string, optimistic?: Record<string, unknown>): void;
40
- export declare function emitProgress(ctx: AppAdapterContext, label: string, detail?: string, data?: Record<string, unknown>): void;
41
- export declare function emitCompleted(ctx: AppAdapterContext, label: string, data?: Record<string, unknown>): void;
42
- export declare function emitFailed(ctx: AppAdapterContext, label: string, error: unknown, data?: Record<string, unknown>): void;
43
- export declare function patchData(ctx: AppAdapterContext, data: Record<string, unknown>): void;
44
- export declare function patchFooter(ctx: AppAdapterContext, footer: Record<string, unknown>): void;
45
- export declare function captureConsole<T>(fn: () => Promise<T> | T): Promise<{
46
- result: T;
47
- output: readonly string[];
48
- }>;
49
- export declare function releaseRendererForExternalTui(ctx: AppAdapterContext): Promise<void>;
50
- /** Re-take the terminal after an external TUI (native Pi) exits — resumes the
51
- * suspended OpenTUI renderer so the shell repaints and input flows again. */
52
- export declare function resumeRendererAfterExternalTui(ctx: AppAdapterContext): Promise<void>;
53
- export declare function arrayFromPayload(value: unknown): Record<string, unknown>[];
54
- export declare function stringField(record: Record<string, unknown>, keys: readonly string[], fallback?: string): string;
55
- export declare function compactRecord(record: Record<string, unknown>, keys: readonly string[]): Record<string, unknown>;
56
- export declare function payloadString(intent: AppIntent, key: string): string | undefined;
@@ -1,153 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/adapters/common.ts
3
- function adapterContextFromRuntime(runtime, renderer) {
4
- return {
5
- projectRoot: runtime.getState().projectRoot,
6
- renderer,
7
- ensureRuntime: () => runtime.getRunnerContext(),
8
- emit: (event) => runtime.emit(event),
9
- getState: () => runtime.getState()
10
- };
11
- }
12
- function projectRootOf(ctx) {
13
- const root = ctx.rig?.projectRoot ?? ctx.projectRoot ?? ctx.getState().projectRoot;
14
- if (typeof root === "string" && root.trim())
15
- return root;
16
- throw new Error("App adapter requires a projectRoot.");
17
- }
18
- async function runtimeOf(ctx) {
19
- if (ctx.rig && "runId" in ctx.rig && ctx.ensureRuntime === undefined) {
20
- return ctx.rig;
21
- }
22
- if (ctx.ensureRuntime)
23
- return ctx.ensureRuntime();
24
- throw new Error("App adapter requires ensureRuntime() before this action can run.");
25
- }
26
- function normalizeAppError(error) {
27
- const message = error instanceof Error ? error.message : String(error);
28
- const rawHint = error instanceof Error ? error.hint : undefined;
29
- return {
30
- message,
31
- ...typeof rawHint === "string" && rawHint.trim() ? { hint: rawHint.trim() } : {}
32
- };
33
- }
34
- function emitStarted(ctx, label, optimistic) {
35
- ctx.emit({ type: "action.started", label, ...optimistic ? { optimistic } : {} });
36
- }
37
- function emitProgress(ctx, label, detail, data) {
38
- ctx.emit({ type: "action.progress", label, ...detail ? { detail } : {}, ...data ? { data } : {} });
39
- }
40
- function emitCompleted(ctx, label, data) {
41
- ctx.emit({ type: "action.completed", label, ...data ? { data } : {} });
42
- }
43
- function emitFailed(ctx, label, error, data) {
44
- if (data)
45
- patchData(ctx, data);
46
- const normalized = normalizeAppError(error);
47
- ctx.emit({
48
- type: "action.failed",
49
- label,
50
- message: normalized.message,
51
- ...normalized.hint ? { hint: normalized.hint } : {},
52
- cause: error
53
- });
54
- }
55
- function patchData(ctx, data) {
56
- ctx.emit({ type: "data.patch", data });
57
- }
58
- function patchFooter(ctx, footer) {
59
- ctx.emit({ type: "footer.patch", footer });
60
- }
61
- async function captureConsole(fn) {
62
- const output = [];
63
- const original = {
64
- log: console.log,
65
- info: console.info,
66
- warn: console.warn,
67
- error: console.error
68
- };
69
- const capture = (...parts) => {
70
- output.push(parts.map((part) => typeof part === "string" ? part : JSON.stringify(part)).join(" "));
71
- };
72
- console.log = capture;
73
- console.info = capture;
74
- console.warn = capture;
75
- console.error = capture;
76
- try {
77
- const result = await fn();
78
- return { result, output };
79
- } finally {
80
- console.log = original.log;
81
- console.info = original.info;
82
- console.warn = original.warn;
83
- console.error = original.error;
84
- }
85
- }
86
- async function releaseRendererForExternalTui(ctx) {
87
- const renderer = ctx.renderer;
88
- if (!renderer)
89
- return;
90
- if (renderer.suspend) {
91
- await renderer.suspend();
92
- return;
93
- }
94
- if (renderer.destroy) {
95
- await renderer.destroy();
96
- }
97
- }
98
- async function resumeRendererAfterExternalTui(ctx) {
99
- await ctx.renderer?.resume?.();
100
- }
101
- function arrayFromPayload(value) {
102
- if (Array.isArray(value)) {
103
- return value.filter((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry)));
104
- }
105
- if (value && typeof value === "object" && !Array.isArray(value)) {
106
- const entries = value.entries;
107
- if (Array.isArray(entries))
108
- return arrayFromPayload(entries);
109
- }
110
- return [];
111
- }
112
- function stringField(record, keys, fallback = "") {
113
- for (const key of keys) {
114
- const value = record[key];
115
- if (typeof value === "string" && value.trim())
116
- return value.trim();
117
- if (typeof value === "number" && Number.isFinite(value))
118
- return String(value);
119
- }
120
- return fallback;
121
- }
122
- function compactRecord(record, keys) {
123
- const out = {};
124
- for (const key of keys) {
125
- const value = record[key];
126
- if (value !== undefined && value !== null && value !== "")
127
- out[key] = value;
128
- }
129
- return out;
130
- }
131
- function payloadString(intent, key) {
132
- const value = intent.action.payload?.[key];
133
- return typeof value === "string" && value.trim() ? value.trim() : undefined;
134
- }
135
- export {
136
- stringField,
137
- runtimeOf,
138
- resumeRendererAfterExternalTui,
139
- releaseRendererForExternalTui,
140
- projectRootOf,
141
- payloadString,
142
- patchFooter,
143
- patchData,
144
- normalizeAppError,
145
- emitStarted,
146
- emitProgress,
147
- emitFailed,
148
- emitCompleted,
149
- compactRecord,
150
- captureConsole,
151
- arrayFromPayload,
152
- adapterContextFromRuntime
153
- };
@@ -1,9 +0,0 @@
1
- import { type AppAdapterContext } from "./common";
2
- export type AppDoctorCheck = {
3
- readonly id: string;
4
- readonly label: string;
5
- readonly status: "pass" | "warn" | "fail";
6
- readonly detail?: string;
7
- readonly remediation?: string;
8
- };
9
- export declare function runDoctorChecksForApp(ctx: AppAdapterContext): Promise<AppDoctorCheck[]>;