@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,1680 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/theme.ts
3
- import {
4
- bold as otuiBold,
5
- dim as otuiDim,
6
- fg as otuiFg,
7
- t,
8
- TextAttributes
9
- } from "@opentui/core";
10
- var RIG_UI = {
11
- bg: "#070809",
12
- bg2: "#0b0c0e",
13
- panel: "#101115",
14
- panel2: "#14161b",
15
- hover: "#181b24",
16
- glass: "#1e2230",
17
- border: "#2a2e3a",
18
- ink: "#f4f5f8",
19
- ink2: "#c7c9d3",
20
- ink3: "#9aa0ae",
21
- ink4: "#787b86",
22
- lime: "#ccff4d",
23
- limeDim: "#a9d63f",
24
- cyan: "#56d8ff",
25
- cyanDim: "#3f9fbd",
26
- red: "#ff5d5d",
27
- yellow: "#ffd24d",
28
- magenta: "#ff79b0"
29
- };
30
- var styles = {
31
- ink: otuiFg(RIG_UI.ink),
32
- ink2: otuiFg(RIG_UI.ink2),
33
- ink3: otuiFg(RIG_UI.ink3),
34
- ink4: otuiFg(RIG_UI.ink4),
35
- lime: otuiFg(RIG_UI.lime),
36
- limeDim: otuiFg(RIG_UI.limeDim),
37
- cyan: otuiFg(RIG_UI.cyan),
38
- red: otuiFg(RIG_UI.red),
39
- yellow: otuiFg(RIG_UI.yellow),
40
- magenta: otuiFg(RIG_UI.magenta)
41
- };
42
- function statusColor(status) {
43
- switch (status) {
44
- case "success":
45
- case "completed":
46
- case "merged":
47
- return RIG_UI.lime;
48
- case "running":
49
- case "preparing":
50
- case "created":
51
- case "validating":
52
- case "reviewing":
53
- case "closing-out":
54
- case "stopping":
55
- case "loading":
56
- case "action":
57
- return RIG_UI.cyan;
58
- case "needs-attention":
59
- case "needs_attention":
60
- return RIG_UI.yellow;
61
- case "failed":
62
- case "error":
63
- return RIG_UI.red;
64
- default:
65
- return RIG_UI.ink3;
66
- }
67
- }
68
- function statusGlyph(status) {
69
- switch (status) {
70
- case "success":
71
- case "completed":
72
- case "merged":
73
- return "\u2713";
74
- case "running":
75
- return "\u25CF";
76
- case "preparing":
77
- case "created":
78
- case "validating":
79
- case "reviewing":
80
- case "closing-out":
81
- case "stopping":
82
- case "loading":
83
- case "action":
84
- return "\u25D0";
85
- case "needs-attention":
86
- case "needs_attention":
87
- return "\u26A0";
88
- case "failed":
89
- case "error":
90
- return "\u2717";
91
- default:
92
- return "\xB7";
93
- }
94
- }
95
- function noColorActive() {
96
- const noColor = process.env.NO_COLOR;
97
- if (noColor !== undefined && noColor !== "") {
98
- return true;
99
- }
100
- return process.env.RIG_NO_COLOR !== undefined;
101
- }
102
- function statusLabel(status) {
103
- return {
104
- glyph: statusGlyph(status),
105
- color: noColorActive() ? RIG_UI.ink : statusColor(status)
106
- };
107
- }
108
-
109
- // packages/cli/src/app-opentui/drone.ts
110
- import { RGBA, StyledText, TextAttributes as TextAttributes2 } from "@opentui/core";
111
- var COLOR = {
112
- body: RGBA.fromHex(RIG_UI.lime),
113
- mini: RGBA.fromHex(RIG_UI.limeDim),
114
- rotor: RGBA.fromHex(RIG_UI.cyan),
115
- path: RGBA.fromHex(RIG_UI.cyan),
116
- eye: RGBA.fromHex(RIG_UI.ink),
117
- dim: RGBA.fromHex(RIG_UI.ink4),
118
- ink: RGBA.fromHex(RIG_UI.ink2)
119
- };
120
-
121
- // packages/cli/src/app-opentui/render/scene.ts
122
- function line(text, options = {}) {
123
- return { text, ...options };
124
- }
125
- function blank() {
126
- return { text: "" };
127
- }
128
-
129
- // packages/cli/src/app-opentui/fleet-stats.ts
130
- var ACTIVE_STATUSES = new Set([
131
- "running",
132
- "preparing",
133
- "created",
134
- "validating",
135
- "reviewing",
136
- "closing-out",
137
- "stopping",
138
- "loading"
139
- ]);
140
- var BAR_CHARS = ["\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589", "\u2588"];
141
- function barString(ratio, width) {
142
- if (width <= 0)
143
- return "";
144
- const clamped = Math.max(0, Math.min(1, ratio));
145
- const totalEighths = Math.round(clamped * width * 8);
146
- const full = Math.floor(totalEighths / 8);
147
- const remainder = totalEighths % 8;
148
- let bar = "\u2588".repeat(Math.min(width, full));
149
- if (full < width && remainder > 0)
150
- bar += BAR_CHARS[remainder - 1];
151
- return bar.padEnd(width, " ").slice(0, width);
152
- }
153
- function statusSegments(stats, width) {
154
- if (width <= 0 || stats.total === 0)
155
- return { active: "", done: "", failed: "", other: "" };
156
- const other = Math.max(0, stats.total - stats.active - stats.succeeded - stats.failed);
157
- const raw = [
158
- { key: "active", value: stats.active },
159
- { key: "done", value: stats.succeeded },
160
- { key: "failed", value: stats.failed },
161
- { key: "other", value: other }
162
- ];
163
- const exact = raw.map((entry) => ({ key: entry.key, exact: entry.value / stats.total * width }));
164
- const floored = exact.map((entry) => ({ key: entry.key, n: Math.floor(entry.exact), frac: entry.exact - Math.floor(entry.exact) }));
165
- let remaining = width - floored.reduce((sum, entry) => sum + entry.n, 0);
166
- for (const entry of [...floored].sort((a, b) => b.frac - a.frac)) {
167
- if (remaining <= 0)
168
- break;
169
- entry.n += 1;
170
- remaining -= 1;
171
- }
172
- const widths = new Map(floored.map((entry) => [entry.key, entry.n]));
173
- return {
174
- active: "\u2588".repeat(widths.get("active") ?? 0),
175
- done: "\u2588".repeat(widths.get("done") ?? 0),
176
- failed: "\u2588".repeat(widths.get("failed") ?? 0),
177
- other: "\u2592".repeat(widths.get("other") ?? 0)
178
- };
179
- }
180
-
181
- // packages/cli/src/app-opentui/scenes/family-domains/kit.ts
182
- function relativeTime(iso, now = Date.now()) {
183
- if (!iso)
184
- return "";
185
- const then = Date.parse(iso);
186
- if (!Number.isFinite(then))
187
- return "";
188
- const deltaMs = now - then;
189
- if (deltaMs < 0)
190
- return "just now";
191
- const seconds = Math.floor(deltaMs / 1000);
192
- if (seconds < 60)
193
- return "just now";
194
- const minutes = Math.floor(seconds / 60);
195
- if (minutes < 60)
196
- return `${minutes}m ago`;
197
- const hours = Math.floor(minutes / 60);
198
- if (hours < 24)
199
- return `${hours}h ago`;
200
- const days = Math.floor(hours / 24);
201
- return `${days}d ago`;
202
- }
203
- function actionItemFor(family, sub) {
204
- const base = sub.base.join(" ");
205
- if (sub.direct) {
206
- const label = `run rig ${family} ${base}`.trim();
207
- return {
208
- id: `action:${sub.id}`,
209
- label,
210
- intent: { scene: "command", argv: [family, ...sub.base], action: { kind: "command-run", label: `Run rig ${family} ${base}`.trim(), payload: { argv: [family, ...sub.base], family } } },
211
- message: label
212
- };
213
- }
214
- return {
215
- id: `action:${sub.id}`,
216
- label: `configure ${family} ${base}`.trim(),
217
- intent: { scene: "family", argv: [family], action: { kind: "refresh", label: `Configure ${sub.template}`, payload: { family, formSub: sub.id } } },
218
- message: `configure & run rig ${family} ${sub.template}`
219
- };
220
- }
221
- function actionDetail(sub) {
222
- return sub.direct ? sub.description : `${sub.description} \xB7 ${sub.fields.length} field${sub.fields.length === 1 ? "" : "s"}`;
223
- }
224
- function actionDeck(ctx, subs, heading = "ACTIONS") {
225
- const out = [line(heading, { fg: RIG_UI.ink3, bold: true })];
226
- for (const sub of subs) {
227
- out.push(ctx.cursor.deck({ label: sub.base.join(" ") || ctx.family, detail: actionDetail(sub) }, actionItemFor(ctx.family, sub)));
228
- }
229
- return out;
230
- }
231
- function detailText(details, key) {
232
- const value = details?.[key];
233
- if (value === undefined || value === null)
234
- return;
235
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
236
- return String(value);
237
- return;
238
- }
239
- function metric(label, value, opts = {}) {
240
- return line(` ${label.padEnd(22)} ${value}`, { fg: opts.fg ?? RIG_UI.ink2, bold: opts.bold });
241
- }
242
- function heading(text) {
243
- return line(text, { fg: RIG_UI.ink, bold: true });
244
- }
245
- function drillItem(id, label, message, extra) {
246
- return { id, label, data: { ...extra ?? {}, familyDrillId: id }, message: message ?? label };
247
- }
248
- function drillBackItem(message = "return to overview") {
249
- return { id: "drill-back", label: "back", data: { familyDrillId: undefined }, message };
250
- }
251
-
252
- // packages/cli/src/app-opentui/scenes/family-domains/stats.ts
253
- function num(value) {
254
- return typeof value === "number" && Number.isFinite(value) ? value : 0;
255
- }
256
- function numOrNull(value) {
257
- return typeof value === "number" && Number.isFinite(value) ? value : null;
258
- }
259
- function strOrNull(value) {
260
- return typeof value === "string" && value.length > 0 ? value : null;
261
- }
262
- function statusCounts(value) {
263
- if (typeof value !== "object" || value === null)
264
- return {};
265
- const out = {};
266
- for (const [key, raw] of Object.entries(value)) {
267
- if (typeof raw === "number" && Number.isFinite(raw))
268
- out[key] = raw;
269
- }
270
- return out;
271
- }
272
- function readStats(details) {
273
- if (!details)
274
- return null;
275
- if (typeof details.totalRuns !== "number")
276
- return null;
277
- return {
278
- since: strOrNull(details.since),
279
- totalRuns: num(details.totalRuns),
280
- statusCounts: statusCounts(details.statusCounts),
281
- completedRuns: num(details.completedRuns),
282
- failedRuns: num(details.failedRuns),
283
- needsAttentionRuns: num(details.needsAttentionRuns),
284
- completionRate: numOrNull(details.completionRate),
285
- failureRate: numOrNull(details.failureRate),
286
- needsAttentionRate: numOrNull(details.needsAttentionRate),
287
- medianCompletionMs: numOrNull(details.medianCompletionMs),
288
- steeringTotal: num(details.steeringTotal),
289
- steeringPerRun: numOrNull(details.steeringPerRun),
290
- stallTotal: num(details.stallTotal),
291
- approvalsRequested: num(details.approvalsRequested),
292
- approvalsApproved: num(details.approvalsApproved),
293
- approvalsRejected: num(details.approvalsRejected),
294
- approvalsPending: num(details.approvalsPending)
295
- };
296
- }
297
- function percent(value) {
298
- return value === null ? "\u2014" : `${(value * 100).toFixed(1)}%`;
299
- }
300
- function duration(ms) {
301
- if (ms === null)
302
- return "\u2014";
303
- if (ms < 1000)
304
- return `${Math.round(ms)}ms`;
305
- const seconds = ms / 1000;
306
- if (seconds < 60)
307
- return `${seconds.toFixed(0)}s`;
308
- const minutes = seconds / 60;
309
- if (minutes < 60)
310
- return `${Math.floor(minutes)}m ${Math.round(seconds % 60)}s`;
311
- const hours = Math.floor(minutes / 60);
312
- return `${hours}h ${Math.round(minutes % 60)}m`;
313
- }
314
- function perRun(value) {
315
- return value === null ? "\u2014" : `${value.toFixed(2)}/run`;
316
- }
317
- var ACTIVE_STATUSES2 = new Set([
318
- "running",
319
- "preparing",
320
- "created",
321
- "validating",
322
- "reviewing",
323
- "closing-out",
324
- "stopping",
325
- "loading"
326
- ]);
327
- function distributionStats(stats) {
328
- let active = 0;
329
- const byStatus = new Map;
330
- for (const [status, count] of Object.entries(stats.statusCounts)) {
331
- byStatus.set(status, count);
332
- if (ACTIVE_STATUSES2.has(status))
333
- active += count;
334
- }
335
- return {
336
- total: stats.totalRuns,
337
- active,
338
- succeeded: stats.completedRuns,
339
- failed: stats.failedRuns,
340
- byStatus,
341
- load: stats.totalRuns === 0 ? 0 : active / stats.totalRuns,
342
- sparkline: []
343
- };
344
- }
345
- function distributionBar(stats) {
346
- if (stats.totalRuns === 0)
347
- return [];
348
- const width = 40;
349
- const fleet = distributionStats(stats);
350
- const seg = statusSegments(fleet, width);
351
- const bar = `${seg.active}${seg.done}${seg.failed}${seg.other}`;
352
- const completionBar = barString(stats.completionRate ?? 0, width);
353
- const out = [heading("DISTRIBUTION")];
354
- out.push(line(` ${"completion".padEnd(12)} ${completionBar} ${percent(stats.completionRate)}`, { fg: RIG_UI.lime }));
355
- out.push(line(` ${"status mix".padEnd(12)} ${bar}`, { fg: RIG_UI.ink2 }));
356
- const other = Math.max(0, stats.totalRuns - fleet.active - fleet.succeeded - fleet.failed);
357
- out.push(line(` active ${fleet.active} \xB7 done ${fleet.succeeded} \xB7 failed ${fleet.failed} \xB7 other ${other} \xB7 total ${stats.totalRuns}`, { fg: RIG_UI.ink3 }));
358
- return out;
359
- }
360
- var SINCE_WINDOWS = [
361
- { key: "24h", label: "24h", arg: "1d" },
362
- { key: "7d", label: "7d", arg: "7d" },
363
- { key: "30d", label: "30d", arg: "30d" },
364
- { key: "all", label: "all", arg: null }
365
- ];
366
- function activeWindowKey(since) {
367
- if (since === null)
368
- return "all";
369
- const parsed = Date.parse(since);
370
- if (!Number.isFinite(parsed))
371
- return null;
372
- const ageDays = (Date.now() - parsed) / (24 * 60 * 60 * 1000);
373
- if (ageDays <= 1.5)
374
- return "24h";
375
- if (ageDays <= 14)
376
- return "7d";
377
- return "30d";
378
- }
379
- function sinceSwitcher(ctx, since) {
380
- const active = activeWindowKey(since);
381
- const out = [heading("WINDOW")];
382
- for (const window of SINCE_WINDOWS) {
383
- const isActive = window.key === active;
384
- const argv = window.arg ? ["stats", "show", "--since", window.arg] : ["stats", "show"];
385
- const label = isActive ? `[\u25CF ${window.label}]` : `[ ${window.label}]`;
386
- const item = {
387
- id: `stats-since:${window.key}`,
388
- label: `stats since ${window.label}`,
389
- intent: { scene: "command", argv: [...argv], action: { kind: "command-run", label: `rig ${argv.join(" ")}`, payload: { argv: [...argv], family: ctx.family } } },
390
- message: window.arg ? `recompute fleet stats over the last ${window.label}` : "recompute fleet stats over all time"
391
- };
392
- const content = line(` ${label.padEnd(10)} ${window.arg ? `since ${window.arg}` : "all time"}`, {
393
- fg: isActive ? RIG_UI.bg : RIG_UI.ink2,
394
- bg: isActive ? RIG_UI.lime : undefined,
395
- bold: isActive
396
- });
397
- out.push(ctx.cursor.row(content, item));
398
- }
399
- return out;
400
- }
401
- function volumeTile(label, value, status, fg) {
402
- return {
403
- id: `stats-volume:${status}`,
404
- label: `${label} runs`,
405
- intent: { scene: "fleet", argv: ["run", "list", "--status", status], action: { kind: "navigate", label: `Fleet \xB7 ${status}`, payload: { fleetStatusFilter: status } } },
406
- message: `open the fleet filtered to ${status} runs`,
407
- data: { fg, value }
408
- };
409
- }
410
- var renderStats = (ctx) => {
411
- const lines = [];
412
- const stats = readStats(ctx.details);
413
- if (stats) {
414
- const window = stats.since ? `since ${stats.since}` : "all time";
415
- lines.push(line(`FLEET STATS \xB7 ${window}`, { fg: RIG_UI.lime, bold: true }));
416
- lines.push(blank());
417
- lines.push(...sinceSwitcher(ctx, stats.since));
418
- lines.push(blank());
419
- const dist = distributionBar(stats);
420
- if (dist.length > 0) {
421
- lines.push(...dist);
422
- lines.push(blank());
423
- }
424
- lines.push(heading("VOLUME"));
425
- lines.push(metric("total runs", String(stats.totalRuns), { fg: RIG_UI.ink, bold: true }));
426
- lines.push(ctx.cursor.row(line(` ${"completed".padEnd(22)} ${stats.completedRuns} (${percent(stats.completionRate)}) \u2192`, { fg: RIG_UI.lime }), volumeTile("completed", String(stats.completedRuns), "completed", RIG_UI.lime)));
427
- lines.push(ctx.cursor.row(line(` ${"failed".padEnd(22)} ${stats.failedRuns} (${percent(stats.failureRate)}) \u2192`, { fg: RIG_UI.red }), volumeTile("failed", String(stats.failedRuns), "failed", RIG_UI.red)));
428
- lines.push(ctx.cursor.row(line(` ${"needs attention".padEnd(22)} ${stats.needsAttentionRuns} (${percent(stats.needsAttentionRate)}) \u2192`, { fg: RIG_UI.yellow }), volumeTile("needs-attention", String(stats.needsAttentionRuns), "needs-attention", RIG_UI.yellow)));
429
- lines.push(blank());
430
- lines.push(heading("FLOW"));
431
- lines.push(metric("median run time", duration(stats.medianCompletionMs), { fg: RIG_UI.cyan }));
432
- lines.push(metric("steering", `${stats.steeringTotal} total \xB7 ${perRun(stats.steeringPerRun)}`, { fg: RIG_UI.ink2 }));
433
- lines.push(metric("stalls", String(stats.stallTotal), {
434
- fg: stats.stallTotal > 0 ? RIG_UI.yellow : RIG_UI.ink2
435
- }));
436
- lines.push(blank());
437
- lines.push(heading("APPROVALS"));
438
- lines.push(metric("requested", String(stats.approvalsRequested), { fg: RIG_UI.ink2 }));
439
- lines.push(metric("approved", String(stats.approvalsApproved), { fg: RIG_UI.lime }));
440
- lines.push(metric("rejected", String(stats.approvalsRejected), { fg: RIG_UI.red }));
441
- lines.push(metric("pending", String(stats.approvalsPending), {
442
- fg: stats.approvalsPending > 0 ? RIG_UI.yellow : RIG_UI.ink2
443
- }));
444
- const other = Object.entries(stats.statusCounts).filter(([status]) => !["completed", "failed", "needs-attention"].includes(status)).sort(([, a], [, b]) => b - a);
445
- if (other.length > 0) {
446
- lines.push(blank());
447
- lines.push(heading("OTHER STATUSES"));
448
- for (const [status, count] of other)
449
- lines.push(metric(status, String(count), { fg: RIG_UI.ink2 }));
450
- }
451
- lines.push(blank());
452
- } else if (ctx.state.ran && ctx.state.lines.length > 0) {
453
- lines.push(line("FLEET STATS", { fg: RIG_UI.lime, bold: true }));
454
- lines.push(blank());
455
- lines.push(...sinceSwitcher(ctx, null));
456
- lines.push(blank());
457
- for (const text of ctx.state.lines.slice(0, 60))
458
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
459
- lines.push(blank());
460
- } else {
461
- lines.push(line("FLEET STATS", { fg: RIG_UI.lime, bold: true }));
462
- lines.push(line(" no run data captured yet", { fg: RIG_UI.ink4 }));
463
- lines.push(blank());
464
- }
465
- lines.push(...actionDeck(ctx, ctx.snap.subcommands, "ACTIONS"));
466
- lines.push(blank());
467
- lines.push(line("pick a window cell to re-scope \xB7 a volume tile drills into the fleet \xB7 direct commands run", { fg: RIG_UI.ink4 }));
468
- return lines;
469
- };
470
-
471
- // packages/cli/src/app-opentui/scenes/family-domains/agent.ts
472
- var GUTTER = " ";
473
- var COL = { state: 9, id: 22, mode: 9, task: 16, age: 8 };
474
- var ACTIVE_WINDOW_MS = 60 * 60 * 1000;
475
- function deriveRowState(agent, now) {
476
- if (!agent.taskId)
477
- return { label: "detached", status: "needs-attention" };
478
- const created = Date.parse(agent.createdAt);
479
- if (Number.isFinite(created) && now - created <= ACTIVE_WINDOW_MS) {
480
- return { label: "active", status: "running" };
481
- }
482
- return { label: "idle", status: "loading" };
483
- }
484
- function str(record, key) {
485
- const value = record[key];
486
- return typeof value === "string" ? value : "";
487
- }
488
- function rosterFromDetails(details) {
489
- const raw = details?.["runtimes"];
490
- if (!Array.isArray(raw))
491
- return [];
492
- const rows = [];
493
- for (const entry of raw) {
494
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
495
- continue;
496
- const record = entry;
497
- const id = str(record, "id");
498
- if (!id)
499
- continue;
500
- rows.push({
501
- id,
502
- taskId: str(record, "taskId"),
503
- mode: str(record, "mode") || "worktree",
504
- workspaceDir: str(record, "workspaceDir"),
505
- createdAt: str(record, "createdAt")
506
- });
507
- }
508
- return rows;
509
- }
510
- function subIdByVerb(ctx, verb) {
511
- const sub = ctx.snap.subcommands.find((entry) => entry.base[0] === verb);
512
- return sub?.id ?? null;
513
- }
514
- function workspaceLeaf(path) {
515
- if (!path)
516
- return "";
517
- const parts = path.split("/").filter(Boolean);
518
- return parts[parts.length - 1] ?? path;
519
- }
520
- function rosterItem(agent) {
521
- return drillItem(`agent:${agent.id}`, `inspect runtime ${agent.id}`, `runtime ${agent.id}${agent.taskId ? ` \xB7 task ${agent.taskId}` : ""} \u2014 open detail`, { runtimeId: agent.id, taskId: agent.taskId, workspaceDir: agent.workspaceDir });
522
- }
523
- function commandRow(id, label, argv, detail, message) {
524
- return {
525
- id,
526
- label,
527
- intent: { scene: "command", argv: [...argv], action: { kind: "command-run", label, payload: { argv: [...argv] } } },
528
- message,
529
- data: { detail }
530
- };
531
- }
532
- function formRow(ctx, id, label, subId, message) {
533
- return {
534
- id,
535
- label,
536
- intent: { scene: "family", argv: [ctx.family], action: { kind: "refresh", label, payload: { family: ctx.family, formSub: subId } } },
537
- message
538
- };
539
- }
540
- function agentDetail(ctx, agent, now) {
541
- const lines = [];
542
- const rowState = deriveRowState(agent, now);
543
- const { glyph, color } = statusLabel(rowState.status);
544
- lines.push(line(`AGENT RUNTIME \xB7 ${agent.id}`, { fg: RIG_UI.ink, bold: true }));
545
- lines.push(blank());
546
- lines.push(metric("state", `${glyph} ${rowState.label}`, { fg: color, bold: true }));
547
- lines.push(metric("runtime id", agent.id, { fg: RIG_UI.lime, bold: true }));
548
- lines.push(metric("task", agent.taskId || "\u2014", { fg: agent.taskId ? RIG_UI.cyan : RIG_UI.ink4 }));
549
- lines.push(metric("mode", agent.mode));
550
- lines.push(metric("workspace", agent.workspaceDir || "\u2014", { fg: agent.workspaceDir ? RIG_UI.ink2 : RIG_UI.ink4 }));
551
- if (agent.createdAt) {
552
- const rel = relativeTime(agent.createdAt, now);
553
- lines.push(metric("created", rel ? `${rel} (${agent.createdAt})` : agent.createdAt, { fg: RIG_UI.ink3 }));
554
- }
555
- lines.push(blank());
556
- lines.push(heading("ACTIONS"));
557
- lines.push(ctx.cursor.deck({ label: "back", detail: "return to the agent roster" }, drillBackItem("back to agent roster")));
558
- lines.push(ctx.cursor.deck({ label: "view run", detail: `inspect the run journal for ${agent.id}` }, commandRow(`agent-detail-view-run:${agent.id}`, `view run ${agent.id}`, ["run", "show", agent.id], `inspect the run journal for ${agent.id}`, `show the run journal for runtime ${agent.id}`)));
559
- const runSubId = subIdByVerb(ctx, "run");
560
- if (agent.taskId && runSubId) {
561
- lines.push(ctx.cursor.deck({ label: "re-run task", detail: `open the run form for task ${agent.taskId}` }, formRow(ctx, `agent-detail-rerun:${agent.id}`, `re-run task ${agent.taskId}`, runSubId, `open the run form for task ${agent.taskId}`)));
562
- }
563
- lines.push(ctx.cursor.deck({ label: "cleanup", detail: `tear down runtime ${agent.id}` }, commandRow(`agent-detail-cleanup:${agent.id}`, `cleanup ${agent.id}`, ["agent", "cleanup", "--id", agent.id], `tear down runtime ${agent.id}`, `cleanup runtime ${agent.id}`)));
564
- lines.push(blank());
565
- lines.push(line("back returns to the roster \xB7 view run inspects the journal \xB7 re-run opens the form", { fg: RIG_UI.ink4 }));
566
- return lines;
567
- }
568
- var renderAgent = (ctx) => {
569
- const roster = rosterFromDetails(ctx.details);
570
- const now = Date.now();
571
- if (ctx.drillId) {
572
- const drilled = roster.find((agent) => `agent:${agent.id}` === ctx.drillId);
573
- if (drilled)
574
- return agentDetail(ctx, drilled, now);
575
- }
576
- const lines = [];
577
- lines.push(line(ctx.snap.summary, { fg: RIG_UI.ink3 }));
578
- lines.push(blank());
579
- const probed = ctx.state.ran;
580
- const { glyph, color } = statusLabel(probed && ctx.state.ok ? "success" : "needs-attention");
581
- lines.push(line(`${glyph} AGENT ROSTER \xB7 rig agent list`, { fg: color, bold: true }));
582
- lines.push(metric("prepared runtimes", String(roster.length), { fg: roster.length > 0 ? RIG_UI.lime : RIG_UI.ink3, bold: roster.length > 0 }));
583
- lines.push(blank());
584
- if (roster.length > 0) {
585
- lines.push(line(`${GUTTER}${"STATE".padEnd(COL.state)}${GUTTER}${"RUNTIME".padEnd(COL.id)}${GUTTER}${"MODE".padEnd(COL.mode)}${GUTTER}${"TASK".padEnd(COL.task)}${GUTTER}${"AGE".padEnd(COL.age)}${GUTTER}WORKSPACE`, { fg: RIG_UI.ink, bold: true, bg: RIG_UI.glass }));
586
- for (const agent of roster) {
587
- const active = ctx.cursor.index === ctx.selected;
588
- const rowState = deriveRowState(agent, now);
589
- const stateGlyph = statusLabel(rowState.status);
590
- const id = agent.id.length > COL.id ? `${agent.id.slice(0, COL.id - 1)}\u2026` : agent.id;
591
- const task = agent.taskId ? agent.taskId.length > COL.task ? `${agent.taskId.slice(0, COL.task - 1)}\u2026` : agent.taskId : "\u2014";
592
- const age = relativeTime(agent.createdAt, now) || "\u2014";
593
- const ws = workspaceLeaf(agent.workspaceDir) || "\u2014";
594
- const marker = active ? "\u258C " : " ";
595
- const stateCell = `${stateGlyph.glyph} ${rowState.label}`.padEnd(COL.state);
596
- const content = line(`${marker}${stateCell}${GUTTER}${id.padEnd(COL.id)}${GUTTER}${agent.mode.padEnd(COL.mode)}${GUTTER}${task.padEnd(COL.task)}${GUTTER}${age.padEnd(COL.age)}${GUTTER}${ws}`, {
597
- fg: active ? RIG_UI.ink : RIG_UI.ink2,
598
- ...active ? { bg: RIG_UI.glass } : {}
599
- });
600
- lines.push(ctx.cursor.row(content, rosterItem(agent)));
601
- }
602
- lines.push(blank());
603
- lines.push(line("select a runtime to open its detail screen (view run \xB7 re-run \xB7 cleanup)", { fg: RIG_UI.ink4 }));
604
- lines.push(blank());
605
- } else {
606
- if (probed && ctx.state.lines.length > 0) {
607
- for (const text of ctx.state.lines.slice(0, 40))
608
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
609
- } else {
610
- lines.push(line(" No agent runtimes prepared. Use prepare/run below to provision one.", { fg: RIG_UI.ink3 }));
611
- }
612
- lines.push(blank());
613
- }
614
- lines.push(heading("ACTIONS"));
615
- for (const sub of ctx.snap.subcommands) {
616
- const base = sub.base.join(" ") || ctx.family;
617
- const detail = sub.direct ? sub.description : `${sub.description} \xB7 ${sub.fields.length} field${sub.fields.length === 1 ? "" : "s"}`;
618
- lines.push(ctx.cursor.deck({ label: base, detail }, actionItemFor(ctx.family, sub)));
619
- }
620
- lines.push(blank());
621
- lines.push(line("prepare provisions a runtime \xB7 run executes inside one \xB7 cleanup tears them down", { fg: RIG_UI.ink4 }));
622
- return lines;
623
- };
624
-
625
- // packages/cli/src/app-opentui/scenes/family-domains/queue.ts
626
- var RUN_OPTIONS = [
627
- { flag: "--workers <n>", def: "2", what: "parallel workers draining the queue" },
628
- { flag: "--max-tasks <n>", def: "10", what: "cap on tasks pulled this run" },
629
- { flag: "--action <validate|verify|pipeline>", def: "default", what: "stage each task runs through" },
630
- { flag: "--isolation <off|worktree>", def: "worktree", what: "per-task worktree isolation" },
631
- { flag: "--no-runtime-reuse", def: "reuse on", what: "force a fresh runtime per task" },
632
- { flag: "--fail-fast", def: "off", what: "stop the run on the first failure" },
633
- { flag: "--skip-project-sync", def: "off", what: "skip the main-sync preflight" }
634
- ];
635
- function runSubcommand(subs) {
636
- return subs.find((sub) => sub.base[0] === "run") ?? subs[0];
637
- }
638
- var renderQueue = (ctx) => {
639
- const lines = [];
640
- lines.push(line(ctx.snap.summary || "Run task queues locally.", { fg: RIG_UI.ink3 }));
641
- lines.push(blank());
642
- lines.push(line("\u25CF QUEUE CONTROL \xB7 no live state probe (queue is run-only)", { fg: RIG_UI.cyan, bold: true }));
643
- lines.push(line(" Drains pending task work locally through a pool of parallel workers.", { fg: RIG_UI.ink2 }));
644
- lines.push(line(" Each pulled task runs its action stage, optionally in an isolated worktree.", { fg: RIG_UI.ink2 }));
645
- lines.push(line(" Configure the run below, then launch the worker pool.", { fg: RIG_UI.ink2 }));
646
- lines.push(blank());
647
- lines.push(heading("RUN OPTIONS"));
648
- for (const opt of RUN_OPTIONS) {
649
- lines.push(metric(opt.flag, `${opt.what} \xB7 default ${opt.def}`));
650
- }
651
- lines.push(blank());
652
- lines.push(heading("CONTROLS"));
653
- const run = runSubcommand(ctx.snap.subcommands);
654
- if (run) {
655
- lines.push(ctx.cursor.deck({ label: `\u25B6 queue ${run.base.join(" ") || "run"}`.trim(), detail: "launch the local worker pool \u2014 drain pending tasks" }, actionItemFor(ctx.family, run)));
656
- }
657
- for (const sub of ctx.snap.subcommands) {
658
- if (sub === run)
659
- continue;
660
- lines.push(ctx.cursor.deck({ label: sub.base.join(" ") || ctx.family, detail: sub.description }, actionItemFor(ctx.family, sub)));
661
- }
662
- if (ctx.snap.subcommands.length === 0) {
663
- lines.push(line(" (no queue controls available)", { fg: RIG_UI.ink4 }));
664
- }
665
- lines.push(blank());
666
- lines.push(line("enter a control: direct commands run \xB7 parameterized commands open a form", { fg: RIG_UI.ink4 }));
667
- return lines;
668
- };
669
-
670
- // packages/cli/src/app-opentui/scenes/family-domains/remote.ts
671
- function asRecord(value) {
672
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
673
- }
674
- function pickBool(rec, keys) {
675
- if (!rec)
676
- return;
677
- for (const key of keys) {
678
- const v = rec[key];
679
- if (typeof v === "boolean")
680
- return v;
681
- }
682
- return;
683
- }
684
- function pickScalar(rec, keys) {
685
- if (!rec)
686
- return;
687
- for (const key of keys) {
688
- const v = rec[key];
689
- if (typeof v === "string" && v.trim().length > 0)
690
- return v;
691
- if (typeof v === "number" && Number.isFinite(v))
692
- return String(v);
693
- }
694
- return;
695
- }
696
- function pickNumber(rec, keys) {
697
- if (!rec)
698
- return;
699
- for (const key of keys) {
700
- const v = rec[key];
701
- if (typeof v === "number" && Number.isFinite(v))
702
- return v;
703
- if (typeof v === "string" && v.trim().length > 0 && Number.isFinite(Number(v)))
704
- return Number(v);
705
- }
706
- return;
707
- }
708
- function readEndpoints(details) {
709
- const raw = details?.["endpoints"];
710
- if (!Array.isArray(raw))
711
- return [];
712
- const rows = [];
713
- for (const entry of raw) {
714
- const rec = asRecord(entry);
715
- if (!rec)
716
- continue;
717
- const alias = pickScalar(rec, ["alias"]) ?? "";
718
- const host = pickScalar(rec, ["host"]) ?? "";
719
- if (!alias && !host)
720
- continue;
721
- const tokenConfigured = pickBool(rec, ["tokenConfigured"]) ?? false;
722
- rows.push({
723
- alias: alias || "\u2014",
724
- host,
725
- port: pickScalar(rec, ["port"]) ?? "",
726
- lastConnected: pickScalar(rec, ["lastConnected"]) ?? null,
727
- tokenConfigured
728
- });
729
- }
730
- return rows;
731
- }
732
- function readRemoteTasks(state) {
733
- if (!state)
734
- return [];
735
- const candidates = [state["tasks"], state["taskList"], state["queue"]];
736
- const raw = candidates.find((value) => Array.isArray(value));
737
- if (!Array.isArray(raw))
738
- return [];
739
- const tasks = [];
740
- for (const entry of raw) {
741
- const rec = asRecord(entry);
742
- if (!rec)
743
- continue;
744
- const id = pickScalar(rec, ["id", "taskId", "name"]) ?? "";
745
- if (!id)
746
- continue;
747
- tasks.push({
748
- id,
749
- status: pickScalar(rec, ["status", "state"]) ?? "unknown",
750
- title: pickScalar(rec, ["title", "summary", "description"]) ?? ""
751
- });
752
- }
753
- return tasks;
754
- }
755
- function readRemote(details) {
756
- const conn = asRecord(details?.["remote"]);
757
- const payload = asRecord(details?.["payload"]);
758
- const state = asRecord(payload?.["state"]) ?? asRecord(details?.["state"]);
759
- return { conn, state };
760
- }
761
- function deriveStatus(ran, ok, paused, running) {
762
- if (!ran)
763
- return { status: "loading", paused: false, running: false };
764
- if (!ok)
765
- return { status: "failed", paused: false, running: false };
766
- if (paused === true)
767
- return { status: "needs-attention", paused: true, running: false };
768
- if (running === true || paused === false)
769
- return { status: "running", paused: false, running: true };
770
- return { status: "success", paused: false, running: false };
771
- }
772
- function baseKey(sub) {
773
- return sub.base.join(" ");
774
- }
775
- var GUTTER2 = " ";
776
- var TASK_COL = { id: 18, status: 14 };
777
- var ENDPOINT_COL = { alias: 16, host: 26, last: 12 };
778
- function endpointFormRow(ctx, sub, label, message) {
779
- return {
780
- id: `remote-endpoint:${sub.id}`,
781
- label,
782
- intent: { scene: "family", argv: [ctx.family], action: { kind: "refresh", label, payload: { family: ctx.family, formSub: sub.id } } },
783
- message
784
- };
785
- }
786
- function endpointDataRow(alias) {
787
- const argv = ["remote", "endpoint", "test", "--alias", alias];
788
- const label = `test endpoint ${alias}`;
789
- return {
790
- id: `remote-endpoint-row:${alias}`,
791
- label,
792
- intent: { scene: "command", argv: [...argv], action: { kind: "command-run", label: `rig ${argv.join(" ")}`, payload: { argv: [...argv], family: "remote" } } },
793
- message: `ping configured endpoint ${alias}`
794
- };
795
- }
796
- var renderRemote = (ctx) => {
797
- const lines = [];
798
- lines.push(line(ctx.snap.summary, { fg: RIG_UI.ink3 }));
799
- lines.push(blank());
800
- const { conn, state } = readRemote(ctx.details);
801
- const paused = pickBool(state, ["isPaused", "paused", "isHalted"]);
802
- const running = pickBool(state, ["isRunning", "running", "active", "isActive"]);
803
- const { status, paused: isPaused, running: isRunning } = deriveStatus(ctx.state.ran, ctx.state.ok, paused, running);
804
- const { glyph, color } = statusLabel(status);
805
- const host = detailText(conn, "host");
806
- const port = detailText(conn, "port");
807
- const alias = detailText(conn, "alias");
808
- const source = detailText(conn, "source");
809
- const target = host ? `${host}${port ? `:${port}` : ""}` : alias ?? "(no endpoint resolved)";
810
- const reachable = ctx.state.ran && ctx.state.ok;
811
- const stateWord = !ctx.state.ran ? "probing\u2026" : isPaused ? "PAUSED" : isRunning ? "RUNNING" : ctx.state.ok ? "connected \xB7 idle" : "unreachable";
812
- lines.push(line(`${glyph} REMOTE ORCHESTRATION \xB7 ${stateWord}`, { fg: color, bold: true }));
813
- lines.push(blank());
814
- lines.push(line(`${GUTTER2}${"ALIAS".padEnd(14)}${GUTTER2}${"HOST:PORT".padEnd(26)}${GUTTER2}${"SOURCE".padEnd(8)}${GUTTER2}REACHABLE`, { fg: RIG_UI.ink, bold: true, bg: RIG_UI.glass }));
815
- const reach = !ctx.state.ran ? "\u2026" : reachable ? "\u25CF yes" : "\u2717 no";
816
- const reachFg = !ctx.state.ran ? RIG_UI.ink3 : reachable ? RIG_UI.lime : RIG_UI.red;
817
- lines.push(line(`${GUTTER2}${(alias ?? "\u2014").padEnd(14)}${GUTTER2}${target.padEnd(26)}${GUTTER2}${(source ?? "\u2014").padEnd(8)}${GUTTER2}`, { fg: RIG_UI.ink2 }));
818
- lines.push(line(`${GUTTER2}\u21B3 reachable: ${reach}`, { fg: reachFg }));
819
- const endpoints = readEndpoints(ctx.details);
820
- const now = Date.now();
821
- if (endpoints.length > 0) {
822
- lines.push(blank());
823
- lines.push(line(`${GUTTER2}REGISTRY \xB7 ${endpoints.length} configured endpoint${endpoints.length === 1 ? "" : "s"}`, { fg: RIG_UI.ink3, bold: true }));
824
- lines.push(line(`${GUTTER2} ${"ALIAS".padEnd(ENDPOINT_COL.alias)}${GUTTER2}${"HOST:PORT".padEnd(ENDPOINT_COL.host)}${GUTTER2}${"TOKEN".padEnd(6)}${GUTTER2}${"LAST".padEnd(ENDPOINT_COL.last)}`, { fg: RIG_UI.ink, bold: true, bg: RIG_UI.glass }));
825
- for (const ep of endpoints) {
826
- const active = ctx.cursor.index === ctx.selected;
827
- const isResolved = alias !== undefined && ep.alias === alias;
828
- const hostPort = ep.host ? `${ep.host}${ep.port ? `:${ep.port}` : ""}` : "\u2014";
829
- const hpCell = hostPort.length > ENDPOINT_COL.host ? `${hostPort.slice(0, ENDPOINT_COL.host - 1)}\u2026` : hostPort;
830
- const aliasCell = ep.alias.length > ENDPOINT_COL.alias ? `${ep.alias.slice(0, ENDPOINT_COL.alias - 1)}\u2026` : ep.alias;
831
- const tokenCell = ep.tokenConfigured ? "\u25CF set" : "\u2717 \u2014";
832
- const last = ep.lastConnected ? relativeTime(ep.lastConnected, now) || "\u2014" : "never";
833
- const marker = active ? "\u258C " : " ";
834
- const dot = isResolved ? "\u203A " : " ";
835
- const content = line(`${GUTTER2}${marker}${dot}${aliasCell.padEnd(ENDPOINT_COL.alias)}${GUTTER2}${hpCell.padEnd(ENDPOINT_COL.host)}${GUTTER2}${tokenCell.padEnd(6)}${GUTTER2}${last.padEnd(ENDPOINT_COL.last)}`, {
836
- fg: active ? RIG_UI.ink : RIG_UI.ink2,
837
- ...active ? { bg: RIG_UI.glass } : {}
838
- });
839
- lines.push(ctx.cursor.row(content, endpointDataRow(ep.alias)));
840
- }
841
- lines.push(line(`${GUTTER2} \u203A marks the resolved endpoint \xB7 select a row to test it`, { fg: RIG_UI.ink4 }));
842
- }
843
- const subs = ctx.snap.subcommands;
844
- const byKey = new Map;
845
- for (const sub of subs)
846
- byKey.set(baseKey(sub), sub);
847
- const used = new Set;
848
- const endpointVerbs = [
849
- { key: "endpoint add", label: "add endpoint", message: "register a new remote endpoint" },
850
- { key: "endpoint remove", label: "remove endpoint", message: "remove a configured remote endpoint" },
851
- { key: "endpoint test", label: "test endpoint", message: "ping a configured remote endpoint" },
852
- { key: "endpoint list", label: "list endpoints", message: "list all configured remote endpoints" }
853
- ];
854
- const endpointRows = [];
855
- for (const verb of endpointVerbs) {
856
- const sub = byKey.get(verb.key);
857
- if (!sub)
858
- continue;
859
- used.add(verb.key);
860
- endpointRows.push(ctx.cursor.deck({ label: verb.label, detail: actionDetail(sub) }, endpointFormRow(ctx, sub, verb.label, verb.message)));
861
- }
862
- if (endpointRows.length > 0) {
863
- lines.push(line(" endpoint actions:", { fg: RIG_UI.ink4 }));
864
- lines.push(...endpointRows);
865
- }
866
- lines.push(blank());
867
- const currentIteration = pickNumber(state, ["currentIteration", "iteration", "iterationsUsed"]);
868
- const maxIterations = pickNumber(state, ["maxIterations", "maxIteration", "iterationBudget"]);
869
- const counters = [
870
- ["tasks", pickScalar(state, ["taskCount", "totalTasks", "tasks"])],
871
- ["workers", pickScalar(state, ["maxWorkers", "workers", "activeWorkers"])],
872
- ["orchestration", pickScalar(state, ["orchestrationId", "orchestration"])],
873
- ["model", pickScalar(state, ["model", "agentModel"])]
874
- ];
875
- const hasCounters = counters.some(([, v]) => v !== undefined) || currentIteration !== undefined || maxIterations !== undefined;
876
- if (hasCounters) {
877
- lines.push(heading("RUN STATE"));
878
- if (currentIteration !== undefined && maxIterations !== undefined && maxIterations > 0) {
879
- const ratio = Math.min(1, currentIteration / maxIterations);
880
- const bar = barString(ratio, 24);
881
- const barFg = ratio >= 1 ? RIG_UI.red : ratio >= 0.8 ? RIG_UI.yellow : RIG_UI.lime;
882
- lines.push(line(` ${"iteration budget".padEnd(22)} ${bar} ${currentIteration}/${maxIterations}`, { fg: barFg }));
883
- } else if (currentIteration !== undefined) {
884
- lines.push(metric("iteration", String(currentIteration)));
885
- } else if (maxIterations !== undefined) {
886
- lines.push(metric("max iterations", String(maxIterations)));
887
- }
888
- for (const [label, value] of counters) {
889
- if (value !== undefined)
890
- lines.push(metric(label, value));
891
- }
892
- lines.push(blank());
893
- }
894
- const tasks = readRemoteTasks(state);
895
- if (tasks.length > 0) {
896
- lines.push(heading("REMOTE TASKS"));
897
- lines.push(line(`${GUTTER2}${"TASK".padEnd(TASK_COL.id)}${GUTTER2}${"STATUS".padEnd(TASK_COL.status)}${GUTTER2}TITLE`, { fg: RIG_UI.ink, bold: true, bg: RIG_UI.glass }));
898
- for (const task of tasks.slice(0, 20)) {
899
- const taskStatus = statusLabel(task.status);
900
- const id = task.id.length > TASK_COL.id ? `${task.id.slice(0, TASK_COL.id - 1)}\u2026` : task.id;
901
- const statusCell = `${taskStatus.glyph} ${task.status}`;
902
- const statusClipped = statusCell.length > TASK_COL.status ? `${statusCell.slice(0, TASK_COL.status - 1)}\u2026` : statusCell;
903
- lines.push(line(`${GUTTER2}${id.padEnd(TASK_COL.id)}${GUTTER2}${statusClipped.padEnd(TASK_COL.status)}${GUTTER2}${task.title}`, { fg: RIG_UI.ink2 }));
904
- }
905
- lines.push(blank());
906
- }
907
- const hasStructured = state !== null && Object.keys(state).length > 0;
908
- if (ctx.state.ran && !hasStructured) {
909
- if (ctx.state.lines.length === 0)
910
- lines.push(line(" (no state output)", { fg: RIG_UI.ink4 }));
911
- else
912
- for (const text of ctx.state.lines.slice(0, 24))
913
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
914
- lines.push(blank());
915
- }
916
- if (!ctx.state.ran) {
917
- lines.push(line(" remote status pending \u2014 run `status` below to connect", { fg: RIG_UI.ink4 }));
918
- lines.push(blank());
919
- }
920
- const pushRow = (sub, detailOverride) => {
921
- used.add(baseKey(sub));
922
- lines.push(ctx.cursor.deck({ label: baseKey(sub) || ctx.family, detail: detailOverride ?? actionDetail(sub) }, actionItemFor(ctx.family, sub)));
923
- };
924
- const flowKeys = ["status", "tasks", "watch", "pause", "resume", "continue", "stop", "refresh"];
925
- const flowSubs = flowKeys.map((k) => byKey.get(k)).filter((s) => s !== undefined);
926
- if (flowSubs.length > 0) {
927
- lines.push(heading("FLOW CONTROLS"));
928
- for (const sub of flowSubs) {
929
- const key = baseKey(sub);
930
- let detail;
931
- if (key === "pause")
932
- detail = isRunning ? "halt the running remote \xB7 resume to continue" : "halt the remote run (idle)";
933
- else if (key === "resume")
934
- detail = isPaused ? "resume the PAUSED remote run" : "resume a paused remote run";
935
- else if (key === "stop")
936
- detail = isRunning || isPaused ? "interrupt the active remote run" : "interrupt the remote run";
937
- else if (key === "watch")
938
- detail = "stream remote events live";
939
- else if (key === "status")
940
- detail = "re-probe remote run state";
941
- pushRow(sub, detail);
942
- }
943
- lines.push(blank());
944
- }
945
- const tuneKeys = [
946
- "add-iterations",
947
- "remove-iterations",
948
- "prompt-preview",
949
- "iteration-output"
950
- ];
951
- const tuneSubs = tuneKeys.map((k) => byKey.get(k)).filter((s) => s !== undefined);
952
- if (tuneSubs.length > 0) {
953
- lines.push(heading("RUN TUNING"));
954
- for (const sub of tuneSubs)
955
- pushRow(sub);
956
- lines.push(blank());
957
- }
958
- const orchSubs = subs.filter((s) => baseKey(s).startsWith("orchestrate") && !used.has(baseKey(s)));
959
- if (orchSubs.length > 0) {
960
- lines.push(heading("ORCHESTRATION"));
961
- for (const sub of orchSubs)
962
- pushRow(sub);
963
- lines.push(blank());
964
- }
965
- const rest = subs.filter((s) => !used.has(baseKey(s)));
966
- if (rest.length > 0) {
967
- lines.push(heading("MORE"));
968
- for (const sub of rest)
969
- pushRow(sub);
970
- lines.push(blank());
971
- }
972
- lines.push(line("enter a control: direct commands run \xB7 parameterized commands open a form", { fg: RIG_UI.ink4 }));
973
- return lines;
974
- };
975
-
976
- // packages/cli/src/app-opentui/scenes/family-domains/dist.ts
977
- function asRecord2(value) {
978
- return value && typeof value === "object" && !Array.isArray(value) ? value : null;
979
- }
980
- function asBool(value) {
981
- return value === true;
982
- }
983
- function asStringOrNull(value) {
984
- return typeof value === "string" && value.length > 0 ? value : null;
985
- }
986
- function checkLine(label, ok, detail) {
987
- const { glyph, color } = statusLabel(ok ? "success" : "needs-attention");
988
- return line(` ${glyph} ${label.padEnd(20)} ${detail}`, { fg: color });
989
- }
990
- var renderDist = (ctx) => {
991
- const lines = [];
992
- lines.push(line(ctx.snap.summary, { fg: RIG_UI.ink3 }));
993
- lines.push(blank());
994
- const details = ctx.details;
995
- const bun = asRecord2(details?.["bun"]);
996
- const rig = asRecord2(details?.["rig"]);
997
- const userBinDir = asStringOrNull(details?.["userBinDir"]);
998
- const userBinInPath = asBool(details?.["userBinInPath"]);
999
- const latestDistBinary = asStringOrNull(details?.["latestDistBinary"]);
1000
- const hasStructured = Boolean(bun || rig || userBinDir);
1001
- if (ctx.state.ran && hasStructured) {
1002
- const bunOk = asBool(bun?.["available"]);
1003
- const bunVersion = asStringOrNull(bun?.["version"]);
1004
- const rigOnPath = asBool(rig?.["onPath"]);
1005
- const rigRunnable = asBool(rig?.["runnable"]);
1006
- const rigPath = asStringOrNull(rig?.["path"]);
1007
- const installable = Boolean(latestDistBinary);
1008
- const ready = bunOk && installable;
1009
- const top = statusLabel(ready ? "success" : "needs-attention");
1010
- lines.push(line(`${top.glyph} DISTRIBUTION ${ready ? "READY" : "NEEDS ATTENTION"}`, { fg: top.color, bold: true }));
1011
- lines.push(blank());
1012
- lines.push(heading("READINESS"));
1013
- lines.push(checkLine("bun toolchain", bunOk, bunOk ? `ok${bunVersion ? ` \xB7 v${bunVersion}` : ""}` : "missing \u2014 build needs bun"));
1014
- lines.push(checkLine("rig on PATH", rigOnPath, rigOnPath ? rigPath ?? "present" : "not on PATH"));
1015
- lines.push(checkLine("rig runnable", rigRunnable, rigRunnable ? "responds to `rig help`" : "installed rig did not run"));
1016
- lines.push(checkLine("packaged binary", installable, installable ? "built \u2014 ready to install" : "none \u2014 run `dist build`"));
1017
- lines.push(blank());
1018
- lines.push(heading("INSTALL TARGET"));
1019
- if (userBinDir) {
1020
- lines.push(metric("user bin dir", userBinDir));
1021
- lines.push(metric("on PATH", userBinInPath ? "yes" : "no \u2014 add to PATH to run rig", { fg: userBinInPath ? RIG_UI.lime : RIG_UI.yellow }));
1022
- } else {
1023
- lines.push(line(" (install location unknown)", { fg: RIG_UI.ink4 }));
1024
- }
1025
- lines.push(metric("latest dist binary", latestDistBinary ?? "none built yet", { fg: latestDistBinary ? RIG_UI.ink2 : RIG_UI.ink4 }));
1026
- lines.push(blank());
1027
- } else if (ctx.state.ran) {
1028
- const probe = statusLabel(ctx.state.ok ? "success" : "needs-attention");
1029
- lines.push(line(`${probe.glyph} DOCTOR \xB7 rig dist ${ctx.state.subcommand?.join(" ") ?? "doctor"}`, { fg: probe.color, bold: true }));
1030
- if (ctx.state.lines.length === 0)
1031
- lines.push(line(" (no output)", { fg: RIG_UI.ink4 }));
1032
- else
1033
- for (const text of ctx.state.lines.slice(0, 40))
1034
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
1035
- lines.push(blank());
1036
- } else {
1037
- lines.push(line(" doctor probe did not run \u2014 select doctor below to inspect the build env", { fg: RIG_UI.ink4 }));
1038
- lines.push(blank());
1039
- }
1040
- lines.push(heading("ACTIONS"));
1041
- for (const sub of ctx.snap.subcommands) {
1042
- lines.push(ctx.cursor.deck({ label: sub.base.join(" ") || ctx.family, detail: actionDetail(sub) }, actionItemFor(ctx.family, sub)));
1043
- }
1044
- lines.push(blank());
1045
- lines.push(line("build packages the binary \xB7 install copies it onto PATH \xB7 doctor re-probes the env", { fg: RIG_UI.ink4 }));
1046
- return lines;
1047
- };
1048
-
1049
- // packages/cli/src/app-opentui/scenes/family-domains/browser.ts
1050
- var CONTRACT = {
1051
- attachUrl: "http://127.0.0.1:9333",
1052
- preset: "hp-next-local",
1053
- stateDir: ".tmp/rig-browser/hp-next"
1054
- };
1055
- var AGENT_HELPERS = [
1056
- "rig-browser-launch",
1057
- "rig-browser-check",
1058
- "rig-browser-attach-info"
1059
- ];
1060
- function isWorkstation(sub) {
1061
- return sub.base[0] === "hp-next";
1062
- }
1063
- var renderBrowser = (ctx) => {
1064
- const lines = [];
1065
- lines.push(line("BROWSER WORKSTATION \xB7 browser-required task contract", { fg: RIG_UI.cyan, bold: true }));
1066
- lines.push(blank());
1067
- lines.push(heading("WORKSTATION STATUS"));
1068
- const probed = ctx.state.ran;
1069
- const up = ctx.details?.up === true;
1070
- const probeUrl = detailText(ctx.details, "attachUrl") ?? CONTRACT.attachUrl;
1071
- const probePort = detailText(ctx.details, "port") ?? "(unknown)";
1072
- if (probed && up) {
1073
- lines.push(metric("status", `RUNNING on :${probePort}`, { fg: RIG_UI.lime, bold: true }));
1074
- const browser = detailText(ctx.details, "browser");
1075
- if (browser)
1076
- lines.push(metric("browser", browser, { fg: RIG_UI.ink }));
1077
- const pages = detailText(ctx.details, "pages");
1078
- if (pages !== undefined)
1079
- lines.push(metric("open page targets", pages, { fg: RIG_UI.ink2 }));
1080
- const activeUrl = detailText(ctx.details, "activeUrl");
1081
- if (activeUrl)
1082
- lines.push(metric("active page", activeUrl, { fg: RIG_UI.ink2 }));
1083
- lines.push(metric("attach url", probeUrl, { fg: RIG_UI.ink2 }));
1084
- } else if (probed) {
1085
- const reason = detailText(ctx.details, "reason") ?? "no CDP endpoint";
1086
- lines.push(metric("status", "DOWN \u2014 start the workstation", { fg: RIG_UI.red, bold: true }));
1087
- lines.push(metric("probe", `${probeUrl} \xB7 ${reason}`, { fg: RIG_UI.ink3 }));
1088
- lines.push(line(" \u2192 run hp-next start (or dev), then hp-next check before attaching MCP", { fg: RIG_UI.ink2 }));
1089
- } else {
1090
- lines.push(metric("status", "not probed yet", { fg: RIG_UI.ink3 }));
1091
- }
1092
- lines.push(blank());
1093
- lines.push(heading("ATTACH CONTRACT (documented defaults)"));
1094
- lines.push(metric("attach url", CONTRACT.attachUrl, { fg: RIG_UI.ink2 }));
1095
- lines.push(metric("preset / profile", CONTRACT.preset, { fg: RIG_UI.ink2 }));
1096
- lines.push(metric("state dir", CONTRACT.stateDir, { fg: RIG_UI.ink3 }));
1097
- lines.push(blank());
1098
- lines.push(heading("AGENT HELPERS (worker PATH)"));
1099
- for (const helper of AGENT_HELPERS)
1100
- lines.push(metric(helper, "\u2192 inside a run", { fg: RIG_UI.ink3 }));
1101
- lines.push(blank());
1102
- const workstation = [];
1103
- const helpDemo = [];
1104
- for (const sub of ctx.snap.subcommands) {
1105
- if (isWorkstation(sub))
1106
- workstation.push(sub);
1107
- else
1108
- helpDemo.push(sub);
1109
- }
1110
- lines.push(heading(up ? "HP-NEXT WORKSTATION (controls)" : "HP-NEXT WORKSTATION (start here)"));
1111
- if (workstation.length === 0) {
1112
- lines.push(line(" (no hp-next workstation actions in this catalog)", { fg: RIG_UI.ink4 }));
1113
- } else {
1114
- for (const sub of workstation) {
1115
- lines.push(ctx.cursor.deck({ label: sub.base.join(" ") || ctx.family, detail: actionDetail(sub) }, actionItemFor(ctx.family, sub)));
1116
- }
1117
- }
1118
- lines.push(blank());
1119
- lines.push(heading("HELP & DEMO"));
1120
- if (helpDemo.length === 0) {
1121
- lines.push(line(" (no help/demo actions in this catalog)", { fg: RIG_UI.ink4 }));
1122
- } else {
1123
- for (const sub of helpDemo) {
1124
- lines.push(ctx.cursor.deck({ label: sub.base.join(" ") || ctx.family, detail: actionDetail(sub) }, actionItemFor(ctx.family, sub)));
1125
- }
1126
- }
1127
- lines.push(blank());
1128
- lines.push(line("enter a row: direct commands run \xB7 parameterized commands open a form", { fg: RIG_UI.ink4 }));
1129
- return lines;
1130
- };
1131
-
1132
- // packages/cli/src/app-opentui/scenes/family-domains/github.ts
1133
- function asRecord3(value) {
1134
- return value && typeof value === "object" && !Array.isArray(value) ? value : null;
1135
- }
1136
- function asBool2(value) {
1137
- return value === true;
1138
- }
1139
- function asStringOrNull2(value) {
1140
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
1141
- }
1142
- function asScopes(value) {
1143
- if (!Array.isArray(value))
1144
- return [];
1145
- return value.filter((entry) => typeof entry === "string" && entry.trim().length > 0).map((entry) => entry.trim());
1146
- }
1147
- function isLoginAction(sub) {
1148
- const base = sub.base.join(" ");
1149
- return base.includes("import-gh") || base.includes("token");
1150
- }
1151
- function isStatusAction(sub) {
1152
- return sub.base.join(" ").includes("status");
1153
- }
1154
- function tokenSourceLabel(source) {
1155
- switch (source) {
1156
- case "oauth-device":
1157
- return "OAuth device flow";
1158
- case "manual-token":
1159
- return "manually stored token";
1160
- case "env":
1161
- return "environment (RIG_GITHUB_TOKEN)";
1162
- default:
1163
- return source ?? "\u2014";
1164
- }
1165
- }
1166
- var renderGithub = (ctx) => {
1167
- const lines = [];
1168
- lines.push(line(ctx.snap.summary, { fg: RIG_UI.ink3 }));
1169
- lines.push(blank());
1170
- const details = ctx.details;
1171
- const authenticated = asBool2(details?.["signedIn"]) || asBool2(details?.["authenticated"]);
1172
- const login = asStringOrNull2(details?.["login"]);
1173
- const userId = asStringOrNull2(details?.["userId"]);
1174
- const tokenSource = asStringOrNull2(details?.["tokenSource"]);
1175
- const scopes = asScopes(details?.["scopes"]);
1176
- const selectedRepo = asStringOrNull2(details?.["selectedRepo"]);
1177
- const oauthConfigured = asBool2(details?.["oauthConfigured"]);
1178
- const namespace = asRecord3(details?.["userNamespace"]);
1179
- const namespaceKey = asStringOrNull2(namespace?.["key"]);
1180
- const hasStructured = details !== null && (("signedIn" in details) || ("authenticated" in details) || ("login" in details) || ("tokenSource" in details));
1181
- if (ctx.state.ran && hasStructured) {
1182
- const top = statusLabel(authenticated ? "success" : "needs-attention");
1183
- lines.push(line(`${top.glyph} GITHUB ${authenticated ? "AUTHENTICATED" : "NOT AUTHENTICATED"}`, { fg: top.color, bold: true }));
1184
- lines.push(blank());
1185
- lines.push(heading("IDENTITY"));
1186
- if (authenticated) {
1187
- lines.push(metric("signed in as", login ? `@${login}` : "(login unknown)", { fg: login ? RIG_UI.lime : RIG_UI.ink2 }));
1188
- if (userId)
1189
- lines.push(metric("user id", userId));
1190
- } else {
1191
- lines.push(line(" no token stored on the selected server \u2014 log in below", { fg: RIG_UI.yellow }));
1192
- }
1193
- lines.push(blank());
1194
- lines.push(heading("TOKEN"));
1195
- lines.push(metric("source", authenticated ? tokenSourceLabel(tokenSource) : "\u2014", { fg: authenticated ? RIG_UI.ink2 : RIG_UI.ink4 }));
1196
- lines.push(metric("scopes", scopes.length > 0 ? scopes.join(" ") : authenticated ? "(none reported)" : "\u2014", { fg: scopes.length > 0 ? RIG_UI.ink2 : RIG_UI.ink4 }));
1197
- lines.push(metric("server OAuth", oauthConfigured ? "configured" : "not configured", { fg: oauthConfigured ? RIG_UI.lime : RIG_UI.ink4 }));
1198
- lines.push(blank());
1199
- if (selectedRepo || namespaceKey) {
1200
- lines.push(heading("SCOPE"));
1201
- if (selectedRepo)
1202
- lines.push(metric("selected repo", selectedRepo, { fg: RIG_UI.cyan }));
1203
- if (namespaceKey)
1204
- lines.push(metric("user namespace", namespaceKey));
1205
- lines.push(blank());
1206
- }
1207
- } else if (ctx.state.ran) {
1208
- const probe = statusLabel(ctx.state.ok ? "success" : "needs-attention");
1209
- lines.push(line(`${probe.glyph} AUTH \xB7 rig github ${ctx.state.subcommand?.join(" ") ?? "auth status"}`, { fg: probe.color, bold: true }));
1210
- if (ctx.state.lines.length === 0)
1211
- lines.push(line(" (no output)", { fg: RIG_UI.ink4 }));
1212
- else
1213
- for (const text of ctx.state.lines.slice(0, 40))
1214
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
1215
- lines.push(blank());
1216
- } else {
1217
- lines.push(line(" auth status probe did not run \u2014 select status below to check GitHub auth", { fg: RIG_UI.ink4 }));
1218
- lines.push(blank());
1219
- }
1220
- const subs = ctx.snap.subcommands;
1221
- const loginSubs = subs.filter(isLoginAction);
1222
- const statusSubs = subs.filter(isStatusAction);
1223
- const otherSubs = subs.filter((sub) => !isLoginAction(sub) && !isStatusAction(sub));
1224
- const ordered = authenticated || loginSubs.length === 0 ? subs : [...loginSubs, ...statusSubs, ...otherSubs];
1225
- lines.push(heading(authenticated ? "ACTIONS" : "LOG IN"));
1226
- for (const sub of ordered) {
1227
- const emphasizeLogin = !authenticated && isLoginAction(sub);
1228
- const detail = emphasizeLogin ? `${actionDetail(sub)} \xB7 authenticate now` : actionDetail(sub);
1229
- lines.push(ctx.cursor.deck({ label: sub.base.join(" ") || ctx.family, detail }, actionItemFor(ctx.family, sub)));
1230
- }
1231
- lines.push(blank());
1232
- lines.push(line("status re-probes the server \xB7 import-gh pulls your gh token \xB7 token stores one directly", { fg: RIG_UI.ink4 }));
1233
- return lines;
1234
- };
1235
-
1236
- // packages/cli/src/app-opentui/scenes/family-domains/setup.ts
1237
- function strOrNull2(value) {
1238
- return typeof value === "string" && value.length > 0 ? value : null;
1239
- }
1240
- function statusToken(status) {
1241
- switch (status) {
1242
- case "pass":
1243
- return "success";
1244
- case "warn":
1245
- return "needs-attention";
1246
- case "fail":
1247
- return "failed";
1248
- }
1249
- }
1250
- function readStatus(value) {
1251
- return value === "pass" || value === "warn" || value === "fail" ? value : null;
1252
- }
1253
- function readCheck(raw) {
1254
- if (typeof raw !== "object" || raw === null || Array.isArray(raw))
1255
- return null;
1256
- const record = raw;
1257
- const status = readStatus(record.status);
1258
- const label = strOrNull2(record.label);
1259
- if (!status || !label)
1260
- return null;
1261
- return {
1262
- id: strOrNull2(record.id) ?? label,
1263
- label,
1264
- status,
1265
- detail: strOrNull2(record.detail),
1266
- remediation: strOrNull2(record.remediation)
1267
- };
1268
- }
1269
- function readChecks(details) {
1270
- if (!details)
1271
- return null;
1272
- const raw = details.checks;
1273
- if (!Array.isArray(raw))
1274
- return null;
1275
- const checks = [];
1276
- for (const entry of raw) {
1277
- const check = readCheck(entry);
1278
- if (check)
1279
- checks.push(check);
1280
- }
1281
- return checks.length > 0 ? checks : null;
1282
- }
1283
- var renderSetup = (ctx) => {
1284
- const lines = [];
1285
- const checks = readChecks(ctx.details);
1286
- if (checks) {
1287
- const passed = checks.filter((c) => c.status === "pass").length;
1288
- const warned = checks.filter((c) => c.status === "warn").length;
1289
- const failed = checks.filter((c) => c.status === "fail").length;
1290
- const ok = failed === 0;
1291
- const headline = statusLabel(ok ? "success" : "failed");
1292
- lines.push(line(`${headline.glyph} SETUP STATUS \xB7 ${passed}/${checks.length} ready`, { fg: headline.color, bold: true }));
1293
- lines.push(blank());
1294
- lines.push(metric("ready", String(passed), { fg: RIG_UI.lime, bold: passed > 0 }));
1295
- lines.push(metric("attention", String(warned), { fg: warned > 0 ? RIG_UI.yellow : RIG_UI.ink2 }));
1296
- lines.push(metric("missing", String(failed), { fg: failed > 0 ? RIG_UI.red : RIG_UI.ink2 }));
1297
- lines.push(blank());
1298
- lines.push(heading("CHECKLIST"));
1299
- for (const check of checks) {
1300
- const label = statusLabel(statusToken(check.status));
1301
- const detail = check.detail ? ` ${check.detail}` : "";
1302
- lines.push(line(` ${label.glyph} ${check.label}${detail}`, { fg: label.color, bold: check.status === "fail" }));
1303
- if (check.status !== "pass" && check.remediation) {
1304
- lines.push(line(` \u2192 ${check.remediation}`, { fg: RIG_UI.ink3 }));
1305
- }
1306
- }
1307
- lines.push(blank());
1308
- } else if (ctx.state.ran && ctx.state.lines.length > 0) {
1309
- const headline = statusLabel(ctx.state.ok ? "success" : "failed");
1310
- lines.push(line(`${headline.glyph} SETUP STATUS`, { fg: headline.color, bold: true }));
1311
- lines.push(blank());
1312
- for (const text of ctx.state.lines.slice(0, 80))
1313
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
1314
- lines.push(blank());
1315
- } else {
1316
- lines.push(line("SETUP STATUS", { fg: RIG_UI.lime, bold: true }));
1317
- lines.push(line(" no setup check captured yet \u2014 run `setup check` below", { fg: RIG_UI.ink4 }));
1318
- lines.push(blank());
1319
- }
1320
- lines.push(...actionDeck(ctx, ctx.snap.subcommands, "ACTIONS"));
1321
- lines.push(blank());
1322
- lines.push(line("enter a row: direct commands run \xB7 parameterized commands open a form", { fg: RIG_UI.ink4 }));
1323
- return lines;
1324
- };
1325
-
1326
- // packages/cli/src/app-opentui/scenes/family-domains/profile.ts
1327
- var PROFILE_PRESETS = ["claude-code", "codex-cli", "pi"];
1328
- var PRESET_BLURB = {
1329
- "claude-code": "Claude Code runtime + plugin stack",
1330
- "codex-cli": "Codex CLI runtime + plugin stack",
1331
- pi: "Pi coding-agent runtime + plugin stack"
1332
- };
1333
- function presetPicker(ctx, activePlugin) {
1334
- const active = activePlugin ? activePlugin.toLowerCase() : null;
1335
- const out = [heading("SWITCH AGENT STACK")];
1336
- for (const preset of PROFILE_PRESETS) {
1337
- const isActive = active !== null && (active === preset || active.includes(preset));
1338
- const argv = ["profile", "set", preset];
1339
- const label = isActive ? `[\u25CF ${preset}]` : `[ ${preset}]`;
1340
- const item = {
1341
- id: `profile-preset:${preset}`,
1342
- label: `set profile preset ${preset}`,
1343
- intent: { scene: "command", argv, action: { kind: "command-run", label: `rig profile set ${preset}`, payload: { argv: [...argv], family: ctx.family } } },
1344
- message: `switch agent stack to ${preset}`
1345
- };
1346
- const content = line(` ${label.padEnd(18)} ${PRESET_BLURB[preset] ?? ""}`, {
1347
- fg: isActive ? RIG_UI.bg : RIG_UI.ink2,
1348
- bg: isActive ? RIG_UI.lime : undefined,
1349
- bold: isActive
1350
- });
1351
- out.push(ctx.cursor.row(content, item));
1352
- }
1353
- return out;
1354
- }
1355
- function parseKeyValue(text) {
1356
- const match = /^\s*([A-Za-z][A-Za-z _-]*?)\s*:\s+(.+?)\s*$/.exec(text);
1357
- if (!match)
1358
- return null;
1359
- const key = match[1]?.trim().toLowerCase();
1360
- const value = match[2]?.trim();
1361
- if (!key || !value)
1362
- return null;
1363
- return [key, value];
1364
- }
1365
- function readProfile(details, lines) {
1366
- const fromDetails = {
1367
- model: detailText(details, "model") ?? null,
1368
- runtime: detailText(details, "runtime") ?? null,
1369
- plugin: detailText(details, "plugin") ?? detailText(details, "agent_plugin") ?? null
1370
- };
1371
- if (fromDetails.model || fromDetails.runtime || fromDetails.plugin)
1372
- return fromDetails;
1373
- const map = new Map;
1374
- for (const text of lines) {
1375
- const kv = parseKeyValue(text);
1376
- if (kv)
1377
- map.set(kv[0], kv[1]);
1378
- }
1379
- return {
1380
- model: map.get("model") ?? null,
1381
- runtime: map.get("runtime") ?? null,
1382
- plugin: map.get("plugin") ?? null
1383
- };
1384
- }
1385
- function tile(label, value) {
1386
- return value ? metric(label, value, { fg: RIG_UI.ink, bold: true }) : metric(label, "\u2014", { fg: RIG_UI.ink4 });
1387
- }
1388
- var renderProfile = (ctx) => {
1389
- const lines = [];
1390
- const profile = readProfile(ctx.details, ctx.state.lines);
1391
- const captured = Boolean(profile.model || profile.runtime || profile.plugin);
1392
- if (captured) {
1393
- lines.push(line("RUNTIME PROFILE \xB7 active defaults", { fg: RIG_UI.lime, bold: true }));
1394
- lines.push(blank());
1395
- lines.push(heading("AGENT DEFAULTS"));
1396
- lines.push(tile("model", profile.model));
1397
- lines.push(tile("runtime", profile.runtime));
1398
- lines.push(tile("agent plugin", profile.plugin));
1399
- lines.push(blank());
1400
- } else if (ctx.state.ran && ctx.state.lines.length > 0) {
1401
- lines.push(line("RUNTIME PROFILE", { fg: RIG_UI.lime, bold: true }));
1402
- lines.push(blank());
1403
- for (const text of ctx.state.lines.slice(0, 40))
1404
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
1405
- lines.push(blank());
1406
- } else {
1407
- lines.push(line("RUNTIME PROFILE", { fg: RIG_UI.lime, bold: true }));
1408
- lines.push(line(" no profile captured yet \u2014 run show below", { fg: RIG_UI.ink4 }));
1409
- lines.push(blank());
1410
- }
1411
- lines.push(...presetPicker(ctx, profile.plugin));
1412
- lines.push(blank());
1413
- lines.push(...actionDeck(ctx, ctx.snap.subcommands, "ACTIONS"));
1414
- lines.push(blank());
1415
- lines.push(line("pick a stack cell to switch presets \xB7 show reloads \xB7 set opens the form for --model/--runtime", { fg: RIG_UI.ink4 }));
1416
- return lines;
1417
- };
1418
-
1419
- // packages/cli/src/app-opentui/scenes/family-domains/review.ts
1420
- var GATE_MODES = ["off", "advisory", "required"];
1421
- function setModeArgv(mode, provider) {
1422
- const argv = ["review", "set", mode];
1423
- if (provider)
1424
- argv.push("--provider", provider);
1425
- return argv;
1426
- }
1427
- function gateModeSegment(ctx, currentMode, provider) {
1428
- const active = currentMode ? currentMode.toLowerCase() : null;
1429
- const out = [heading("SET GATE MODE")];
1430
- for (const mode of GATE_MODES) {
1431
- const isActive = mode === active;
1432
- const argv = setModeArgv(mode, provider);
1433
- const label = isActive ? `[\u25CF ${mode}]` : `[ ${mode}]`;
1434
- const item = {
1435
- id: `review-mode:${mode}`,
1436
- label: `set gate ${mode}`,
1437
- intent: { scene: "command", argv, action: { kind: "command-run", label: `rig review set ${mode}`, payload: { argv: [...argv], family: ctx.family } } },
1438
- message: `set completion-review gate to ${mode}${provider ? ` (provider ${provider})` : ""}`
1439
- };
1440
- const content = line(` ${label.padEnd(16)} ${MODE_META[mode]?.gate ?? ""}`, {
1441
- fg: isActive ? RIG_UI.bg : RIG_UI.ink2,
1442
- bg: isActive ? RIG_UI.lime : undefined,
1443
- bold: isActive
1444
- });
1445
- out.push(ctx.cursor.row(content, item));
1446
- }
1447
- return out;
1448
- }
1449
- var MODE_META = {
1450
- off: { status: "needs-attention", gate: "NO GATE \xB7 completions are not reviewed" },
1451
- advisory: { status: "reviewing", gate: "ADVISORY \xB7 review runs, does not block completion" },
1452
- required: { status: "completed", gate: "ENFORCED \xB7 review must pass before completion" }
1453
- };
1454
- function strOrNull3(value) {
1455
- return value && value.length > 0 ? value : null;
1456
- }
1457
- function fromLines(lines, key) {
1458
- const prefix = `${key}:`;
1459
- for (const raw of lines) {
1460
- const trimmed = raw.trim();
1461
- if (trimmed.toLowerCase().startsWith(prefix)) {
1462
- const value = trimmed.slice(prefix.length).trim();
1463
- if (value.length > 0)
1464
- return value;
1465
- }
1466
- }
1467
- return null;
1468
- }
1469
- function readPolicy(details, lines) {
1470
- return {
1471
- mode: strOrNull3(detailText(details, "mode")) ?? fromLines(lines, "mode"),
1472
- provider: strOrNull3(detailText(details, "provider")) ?? fromLines(lines, "provider"),
1473
- file: strOrNull3(detailText(details, "file")) ?? fromLines(lines, "file")
1474
- };
1475
- }
1476
- var renderReview = (ctx) => {
1477
- const lines = [];
1478
- const policy = readPolicy(ctx.details, ctx.state.lines);
1479
- lines.push(line("COMPLETION REVIEW GATE", { fg: RIG_UI.lime, bold: true }));
1480
- lines.push(blank());
1481
- if (ctx.state.ran && policy.mode) {
1482
- const modeKey = policy.mode.toLowerCase();
1483
- const meta = MODE_META[modeKey] ?? { status: "default", gate: "unrecognized gate mode" };
1484
- const { glyph, color } = statusLabel(meta.status);
1485
- lines.push(heading("POLICY"));
1486
- lines.push(metric("gate mode", `${glyph} ${policy.mode.toUpperCase()}`, { fg: color, bold: true }));
1487
- lines.push(line(` ${meta.gate}`, { fg: RIG_UI.ink3 }));
1488
- lines.push(blank());
1489
- lines.push(heading("PROVIDER"));
1490
- lines.push(metric("review provider", policy.provider ?? "\u2014", { fg: policy.provider ? RIG_UI.cyan : RIG_UI.ink4 }));
1491
- lines.push(blank());
1492
- if (policy.file) {
1493
- lines.push(heading("SOURCE"));
1494
- lines.push(metric("policy file", policy.file, { fg: RIG_UI.ink2 }));
1495
- lines.push(blank());
1496
- }
1497
- } else if (ctx.state.ran && ctx.state.lines.length > 0) {
1498
- lines.push(heading("POLICY"));
1499
- for (const text of ctx.state.lines.slice(0, 40))
1500
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
1501
- lines.push(blank());
1502
- } else {
1503
- lines.push(line(" gate policy not captured yet \u2014 run `review show`", { fg: RIG_UI.ink4 }));
1504
- lines.push(blank());
1505
- }
1506
- lines.push(...gateModeSegment(ctx, policy.mode, policy.provider));
1507
- lines.push(blank());
1508
- lines.push(...actionDeck(ctx, ctx.snap.subcommands, "ACTIONS"));
1509
- lines.push(blank());
1510
- lines.push(line("pick a gate-mode cell above to set it \xB7 show re-reads policy \xB7 set opens the full form", { fg: RIG_UI.ink4 }));
1511
- return lines;
1512
- };
1513
-
1514
- // packages/cli/src/app-opentui/scenes/family-domains/git.ts
1515
- var FLOWS = [
1516
- { verb: "status", hint: "show task-scoped worktree state \xB7 [--task <id>]" },
1517
- { verb: "changed", hint: "list changed files \xB7 [--task <id>] [--scoped]" },
1518
- { verb: "preflight", hint: "gate before commit \xB7 [--task <id>] [--strict]" },
1519
- { verb: "sync-branch", hint: "ensure the task branch exists \xB7 [--task <id>]" },
1520
- { verb: "commit", hint: "scoped commit \xB7 [--target <monorepo|project|both>] [--message <m>]" },
1521
- { verb: "snapshot", hint: "write a worktree snapshot \xB7 [--output <file>]" },
1522
- { verb: "open-pr", hint: "open the task PR \xB7 [--reviewer <u>] [--base <b>] [--title <t>] [--draft]" }
1523
- ];
1524
- function parseGitStatus(rawLines) {
1525
- let task = null;
1526
- let expectedBranch = null;
1527
- const repos = [];
1528
- let current = null;
1529
- for (const raw of rawLines) {
1530
- const text = raw.replace(/\s+$/, "");
1531
- const taskMatch = /^Task:\s*(.+)$/.exec(text.trim());
1532
- if (taskMatch) {
1533
- const value = taskMatch[1].trim();
1534
- task = value === "(none active)" ? null : value;
1535
- continue;
1536
- }
1537
- const expectedMatch = /^Expected monorepo branch:\s*(.+)$/.exec(text.trim());
1538
- if (expectedMatch) {
1539
- expectedBranch = expectedMatch[1].trim();
1540
- continue;
1541
- }
1542
- const branchMatch = /^\s+branch:\s*(.+)$/.exec(text);
1543
- if (branchMatch && current) {
1544
- current.branch = branchMatch[1].trim();
1545
- continue;
1546
- }
1547
- const changedMatch = /^\s+changed files:\s*(.+)$/.exec(text);
1548
- if (changedMatch && current) {
1549
- current.changed = changedMatch[1].trim();
1550
- continue;
1551
- }
1552
- const warnMatch = /^\s+warning:\s*(.+)$/.exec(text);
1553
- if (warnMatch && current) {
1554
- current.warning = warnMatch[1].trim();
1555
- continue;
1556
- }
1557
- const labelMatch = /^([A-Za-z][\w-]*):$/.exec(text.trim());
1558
- if (labelMatch && !text.startsWith("===")) {
1559
- current = { label: labelMatch[1], branch: "", changed: "" };
1560
- repos.push(current);
1561
- }
1562
- }
1563
- return { task, expectedBranch, repos };
1564
- }
1565
- var renderGit = (ctx) => {
1566
- const lines = [];
1567
- lines.push(line("GIT-FLOW CONSOLE \xB7 rig git <args\u2026> \u2192 Rig git-flow helper", { fg: RIG_UI.cyan, bold: true }));
1568
- lines.push(blank());
1569
- const parsed = ctx.state.ran ? parseGitStatus(ctx.state.lines) : null;
1570
- lines.push(heading("WORKTREE STATUS"));
1571
- if (parsed && parsed.repos.length > 0) {
1572
- lines.push(metric("active task", parsed.task ?? "(none active)", { fg: parsed.task ? RIG_UI.lime : RIG_UI.ink3, bold: Boolean(parsed.task) }));
1573
- if (parsed.expectedBranch)
1574
- lines.push(metric("expected branch", parsed.expectedBranch, { fg: RIG_UI.ink3 }));
1575
- lines.push(blank());
1576
- for (const repo of parsed.repos) {
1577
- lines.push(metric(`${repo.label} \xB7 branch`, repo.branch || "unknown", { fg: RIG_UI.ink, bold: true }));
1578
- const dirty = repo.changed !== "0" && repo.changed !== "";
1579
- lines.push(metric(`${repo.label} \xB7 changed`, `${repo.changed} file${repo.changed === "1" ? "" : "s"}`, { fg: dirty ? RIG_UI.yellow : RIG_UI.ink2 }));
1580
- if (repo.warning)
1581
- lines.push(metric(`${repo.label} \xB7 warning`, repo.warning, { fg: RIG_UI.red }));
1582
- }
1583
- } else if (ctx.state.ran && !ctx.state.ok) {
1584
- lines.push(metric("live probe", "rig git status returned an error (not a git repo?)", { fg: RIG_UI.red }));
1585
- } else {
1586
- lines.push(metric("live probe", "not probed yet", { fg: RIG_UI.ink3 }));
1587
- }
1588
- lines.push(blank());
1589
- lines.push(heading("RUN A GIT-FLOW COMMAND"));
1590
- const subs = ctx.snap.subcommands;
1591
- if (subs.length === 0) {
1592
- lines.push(line(" (no passthrough action in this catalog)", { fg: RIG_UI.ink4 }));
1593
- } else {
1594
- for (const sub of subs) {
1595
- lines.push(ctx.cursor.deck({ label: "enter git args", detail: "open the form \xB7 type the git-flow verb + flags, then run rig git \u2026" }, actionItemFor(ctx.family, sub)));
1596
- }
1597
- }
1598
- lines.push(blank());
1599
- lines.push(heading("FLOWS (type one into the form above)"));
1600
- for (const flow of FLOWS) {
1601
- lines.push(line(` ${flow.verb.padEnd(13)} ${flow.hint}`, { fg: RIG_UI.ink3 }));
1602
- }
1603
- lines.push(blank());
1604
- lines.push(line("enter the run row \u2192 fill <args\u2026> with e.g. `status --task <id>` \u2192 run", { fg: RIG_UI.ink4 }));
1605
- return lines;
1606
- };
1607
-
1608
- // packages/cli/src/app-opentui/scenes/family-domains/harness.ts
1609
- var HARNESS_OPS = [
1610
- { seed: "info", verb: "info \xB7 scope \xB7 deps", detail: "inspect the active task: summary, file scope, dependencies" },
1611
- { seed: "status", verb: "status \xB7 lookup \xB7 artifacts", detail: "task status, id lookup, produced artifacts" },
1612
- { seed: "record", verb: "record \xB7 validate \xB7 verify", detail: "record a task, run validators, completion verification" },
1613
- { seed: "git", verb: "git <args...>", detail: "git flow: status \xB7 changed \xB7 commit \xB7 snapshot \xB7 open-pr \xB7 sync-branch" },
1614
- { seed: "repo", verb: "repo \xB7 sync \xB7 baseline \xB7 pins", detail: "repo ops: ensure/sync, baseline reset, pin discovery/verify" },
1615
- { seed: "memory", verb: "memory <args...>", detail: "shared-memory sync for the active task context" },
1616
- { seed: "profile", verb: "profile \xB7 review", detail: "show/set the agent and review profiles" },
1617
- { seed: "project-root", verb: "project-root \xB7 monorepo-root", detail: "resolve workspace path roots" }
1618
- ];
1619
- function opActionItem(family, sub, seed) {
1620
- const base = actionItemFor(family, sub);
1621
- return {
1622
- ...base,
1623
- id: `harness-op:${seed}`,
1624
- label: `harness ${seed} \u2026`,
1625
- message: `open the harness form to run rig ${family} ${seed} \u2026`
1626
- };
1627
- }
1628
- var renderHarness = (ctx) => {
1629
- const lines = [];
1630
- lines.push(line("HARNESS CONSOLE \xB7 rig harness <args\u2026> \u2192 runtime harness CLI", { fg: RIG_UI.cyan, bold: true }));
1631
- lines.push(blank());
1632
- lines.push(heading("CONTEXT"));
1633
- lines.push(metric("forwards to", "runtime harness CLI (executeHarnessCommand)", { fg: RIG_UI.ink2 }));
1634
- lines.push(metric("gating", "policy-gated \xB7 every run audited to controlled-bash.jsonl", { fg: RIG_UI.ink2 }));
1635
- lines.push(metric("live probe", "none \u2014 harness verbs write audit log, unsafe to auto-run", { fg: RIG_UI.ink3 }));
1636
- lines.push(blank());
1637
- const subs = ctx.snap.subcommands;
1638
- const passthrough = subs[0];
1639
- lines.push(heading("DISPATCH (select to open the form aimed at a group)"));
1640
- if (!passthrough) {
1641
- lines.push(line(" (no harness command registered)", { fg: RIG_UI.ink4 }));
1642
- } else {
1643
- for (const op of HARNESS_OPS) {
1644
- lines.push(ctx.cursor.deck({ label: op.verb, detail: op.detail }, opActionItem(ctx.family, passthrough, op.seed)));
1645
- }
1646
- }
1647
- lines.push(blank());
1648
- lines.push(heading("RAW PASSTHROUGH"));
1649
- if (!passthrough) {
1650
- lines.push(line(" (no harness command registered)", { fg: RIG_UI.ink4 }));
1651
- } else {
1652
- lines.push(ctx.cursor.deck({ label: "enter harness args", detail: "open the form \xB7 type any harness args, then run the gated command" }, actionItemFor(ctx.family, passthrough)));
1653
- }
1654
- lines.push(blank());
1655
- lines.push(line("select a dispatch group or the raw row to type the harness args, then run", { fg: RIG_UI.ink4 }));
1656
- return lines;
1657
- };
1658
-
1659
- // packages/cli/src/app-opentui/scenes/family-domains/index.ts
1660
- var DOMAIN_RENDERERS = {
1661
- stats: renderStats,
1662
- agent: renderAgent,
1663
- queue: renderQueue,
1664
- remote: renderRemote,
1665
- dist: renderDist,
1666
- browser: renderBrowser,
1667
- github: renderGithub,
1668
- setup: renderSetup,
1669
- profile: renderProfile,
1670
- review: renderReview,
1671
- git: renderGit,
1672
- harness: renderHarness
1673
- };
1674
- function bespokeRendererFor(family) {
1675
- return DOMAIN_RENDERERS[family];
1676
- }
1677
- export {
1678
- bespokeRendererFor,
1679
- DOMAIN_RENDERERS
1680
- };