@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,371 +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
-
43
- // packages/cli/src/app-opentui/drone.ts
44
- import { RGBA, StyledText, TextAttributes as TextAttributes2 } from "@opentui/core";
45
- var COLOR = {
46
- body: RGBA.fromHex(RIG_UI.lime),
47
- mini: RGBA.fromHex(RIG_UI.limeDim),
48
- rotor: RGBA.fromHex(RIG_UI.cyan),
49
- path: RGBA.fromHex(RIG_UI.cyan),
50
- eye: RGBA.fromHex(RIG_UI.ink),
51
- dim: RGBA.fromHex(RIG_UI.ink4),
52
- ink: RGBA.fromHex(RIG_UI.ink2)
53
- };
54
-
55
- // packages/cli/src/app-opentui/render/scene.ts
56
- function line(text, options = {}) {
57
- return { text, ...options };
58
- }
59
- function blank() {
60
- return { text: "" };
61
- }
62
-
63
- // packages/cli/src/app-opentui/fleet-stats.ts
64
- var ACTIVE_STATUSES = new Set([
65
- "running",
66
- "preparing",
67
- "created",
68
- "validating",
69
- "reviewing",
70
- "closing-out",
71
- "stopping",
72
- "loading"
73
- ]);
74
- var BAR_CHARS = ["\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589", "\u2588"];
75
- function barString(ratio, width) {
76
- if (width <= 0)
77
- return "";
78
- const clamped = Math.max(0, Math.min(1, ratio));
79
- const totalEighths = Math.round(clamped * width * 8);
80
- const full = Math.floor(totalEighths / 8);
81
- const remainder = totalEighths % 8;
82
- let bar = "\u2588".repeat(Math.min(width, full));
83
- if (full < width && remainder > 0)
84
- bar += BAR_CHARS[remainder - 1];
85
- return bar.padEnd(width, " ").slice(0, width);
86
- }
87
- function statusSegments(stats, width) {
88
- if (width <= 0 || stats.total === 0)
89
- return { active: "", done: "", failed: "", other: "" };
90
- const other = Math.max(0, stats.total - stats.active - stats.succeeded - stats.failed);
91
- const raw = [
92
- { key: "active", value: stats.active },
93
- { key: "done", value: stats.succeeded },
94
- { key: "failed", value: stats.failed },
95
- { key: "other", value: other }
96
- ];
97
- const exact = raw.map((entry) => ({ key: entry.key, exact: entry.value / stats.total * width }));
98
- const floored = exact.map((entry) => ({ key: entry.key, n: Math.floor(entry.exact), frac: entry.exact - Math.floor(entry.exact) }));
99
- let remaining = width - floored.reduce((sum, entry) => sum + entry.n, 0);
100
- for (const entry of [...floored].sort((a, b) => b.frac - a.frac)) {
101
- if (remaining <= 0)
102
- break;
103
- entry.n += 1;
104
- remaining -= 1;
105
- }
106
- const widths = new Map(floored.map((entry) => [entry.key, entry.n]));
107
- return {
108
- active: "\u2588".repeat(widths.get("active") ?? 0),
109
- done: "\u2588".repeat(widths.get("done") ?? 0),
110
- failed: "\u2588".repeat(widths.get("failed") ?? 0),
111
- other: "\u2592".repeat(widths.get("other") ?? 0)
112
- };
113
- }
114
-
115
- // packages/cli/src/app-opentui/scenes/family-domains/kit.ts
116
- function actionItemFor(family, sub) {
117
- const base = sub.base.join(" ");
118
- if (sub.direct) {
119
- const label = `run rig ${family} ${base}`.trim();
120
- return {
121
- id: `action:${sub.id}`,
122
- label,
123
- intent: { scene: "command", argv: [family, ...sub.base], action: { kind: "command-run", label: `Run rig ${family} ${base}`.trim(), payload: { argv: [family, ...sub.base], family } } },
124
- message: label
125
- };
126
- }
127
- return {
128
- id: `action:${sub.id}`,
129
- label: `configure ${family} ${base}`.trim(),
130
- intent: { scene: "family", argv: [family], action: { kind: "refresh", label: `Configure ${sub.template}`, payload: { family, formSub: sub.id } } },
131
- message: `configure & run rig ${family} ${sub.template}`
132
- };
133
- }
134
- function actionDetail(sub) {
135
- return sub.direct ? sub.description : `${sub.description} \xB7 ${sub.fields.length} field${sub.fields.length === 1 ? "" : "s"}`;
136
- }
137
- function actionDeck(ctx, subs, heading = "ACTIONS") {
138
- const out = [line(heading, { fg: RIG_UI.ink3, bold: true })];
139
- for (const sub of subs) {
140
- out.push(ctx.cursor.deck({ label: sub.base.join(" ") || ctx.family, detail: actionDetail(sub) }, actionItemFor(ctx.family, sub)));
141
- }
142
- return out;
143
- }
144
- function metric(label, value, opts = {}) {
145
- return line(` ${label.padEnd(22)} ${value}`, { fg: opts.fg ?? RIG_UI.ink2, bold: opts.bold });
146
- }
147
- function heading(text) {
148
- return line(text, { fg: RIG_UI.ink, bold: true });
149
- }
150
-
151
- // packages/cli/src/app-opentui/scenes/family-domains/stats.ts
152
- function num(value) {
153
- return typeof value === "number" && Number.isFinite(value) ? value : 0;
154
- }
155
- function numOrNull(value) {
156
- return typeof value === "number" && Number.isFinite(value) ? value : null;
157
- }
158
- function strOrNull(value) {
159
- return typeof value === "string" && value.length > 0 ? value : null;
160
- }
161
- function statusCounts(value) {
162
- if (typeof value !== "object" || value === null)
163
- return {};
164
- const out = {};
165
- for (const [key, raw] of Object.entries(value)) {
166
- if (typeof raw === "number" && Number.isFinite(raw))
167
- out[key] = raw;
168
- }
169
- return out;
170
- }
171
- function readStats(details) {
172
- if (!details)
173
- return null;
174
- if (typeof details.totalRuns !== "number")
175
- return null;
176
- return {
177
- since: strOrNull(details.since),
178
- totalRuns: num(details.totalRuns),
179
- statusCounts: statusCounts(details.statusCounts),
180
- completedRuns: num(details.completedRuns),
181
- failedRuns: num(details.failedRuns),
182
- needsAttentionRuns: num(details.needsAttentionRuns),
183
- completionRate: numOrNull(details.completionRate),
184
- failureRate: numOrNull(details.failureRate),
185
- needsAttentionRate: numOrNull(details.needsAttentionRate),
186
- medianCompletionMs: numOrNull(details.medianCompletionMs),
187
- steeringTotal: num(details.steeringTotal),
188
- steeringPerRun: numOrNull(details.steeringPerRun),
189
- stallTotal: num(details.stallTotal),
190
- approvalsRequested: num(details.approvalsRequested),
191
- approvalsApproved: num(details.approvalsApproved),
192
- approvalsRejected: num(details.approvalsRejected),
193
- approvalsPending: num(details.approvalsPending)
194
- };
195
- }
196
- function percent(value) {
197
- return value === null ? "\u2014" : `${(value * 100).toFixed(1)}%`;
198
- }
199
- function duration(ms) {
200
- if (ms === null)
201
- return "\u2014";
202
- if (ms < 1000)
203
- return `${Math.round(ms)}ms`;
204
- const seconds = ms / 1000;
205
- if (seconds < 60)
206
- return `${seconds.toFixed(0)}s`;
207
- const minutes = seconds / 60;
208
- if (minutes < 60)
209
- return `${Math.floor(minutes)}m ${Math.round(seconds % 60)}s`;
210
- const hours = Math.floor(minutes / 60);
211
- return `${hours}h ${Math.round(minutes % 60)}m`;
212
- }
213
- function perRun(value) {
214
- return value === null ? "\u2014" : `${value.toFixed(2)}/run`;
215
- }
216
- var ACTIVE_STATUSES2 = new Set([
217
- "running",
218
- "preparing",
219
- "created",
220
- "validating",
221
- "reviewing",
222
- "closing-out",
223
- "stopping",
224
- "loading"
225
- ]);
226
- function distributionStats(stats) {
227
- let active = 0;
228
- const byStatus = new Map;
229
- for (const [status, count] of Object.entries(stats.statusCounts)) {
230
- byStatus.set(status, count);
231
- if (ACTIVE_STATUSES2.has(status))
232
- active += count;
233
- }
234
- return {
235
- total: stats.totalRuns,
236
- active,
237
- succeeded: stats.completedRuns,
238
- failed: stats.failedRuns,
239
- byStatus,
240
- load: stats.totalRuns === 0 ? 0 : active / stats.totalRuns,
241
- sparkline: []
242
- };
243
- }
244
- function distributionBar(stats) {
245
- if (stats.totalRuns === 0)
246
- return [];
247
- const width = 40;
248
- const fleet = distributionStats(stats);
249
- const seg = statusSegments(fleet, width);
250
- const bar = `${seg.active}${seg.done}${seg.failed}${seg.other}`;
251
- const completionBar = barString(stats.completionRate ?? 0, width);
252
- const out = [heading("DISTRIBUTION")];
253
- out.push(line(` ${"completion".padEnd(12)} ${completionBar} ${percent(stats.completionRate)}`, { fg: RIG_UI.lime }));
254
- out.push(line(` ${"status mix".padEnd(12)} ${bar}`, { fg: RIG_UI.ink2 }));
255
- const other = Math.max(0, stats.totalRuns - fleet.active - fleet.succeeded - fleet.failed);
256
- 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 }));
257
- return out;
258
- }
259
- var SINCE_WINDOWS = [
260
- { key: "24h", label: "24h", arg: "1d" },
261
- { key: "7d", label: "7d", arg: "7d" },
262
- { key: "30d", label: "30d", arg: "30d" },
263
- { key: "all", label: "all", arg: null }
264
- ];
265
- function activeWindowKey(since) {
266
- if (since === null)
267
- return "all";
268
- const parsed = Date.parse(since);
269
- if (!Number.isFinite(parsed))
270
- return null;
271
- const ageDays = (Date.now() - parsed) / (24 * 60 * 60 * 1000);
272
- if (ageDays <= 1.5)
273
- return "24h";
274
- if (ageDays <= 14)
275
- return "7d";
276
- return "30d";
277
- }
278
- function sinceSwitcher(ctx, since) {
279
- const active = activeWindowKey(since);
280
- const out = [heading("WINDOW")];
281
- for (const window of SINCE_WINDOWS) {
282
- const isActive = window.key === active;
283
- const argv = window.arg ? ["stats", "show", "--since", window.arg] : ["stats", "show"];
284
- const label = isActive ? `[\u25CF ${window.label}]` : `[ ${window.label}]`;
285
- const item = {
286
- id: `stats-since:${window.key}`,
287
- label: `stats since ${window.label}`,
288
- intent: { scene: "command", argv: [...argv], action: { kind: "command-run", label: `rig ${argv.join(" ")}`, payload: { argv: [...argv], family: ctx.family } } },
289
- message: window.arg ? `recompute fleet stats over the last ${window.label}` : "recompute fleet stats over all time"
290
- };
291
- const content = line(` ${label.padEnd(10)} ${window.arg ? `since ${window.arg}` : "all time"}`, {
292
- fg: isActive ? RIG_UI.bg : RIG_UI.ink2,
293
- bg: isActive ? RIG_UI.lime : undefined,
294
- bold: isActive
295
- });
296
- out.push(ctx.cursor.row(content, item));
297
- }
298
- return out;
299
- }
300
- function volumeTile(label, value, status, fg) {
301
- return {
302
- id: `stats-volume:${status}`,
303
- label: `${label} runs`,
304
- intent: { scene: "fleet", argv: ["run", "list", "--status", status], action: { kind: "navigate", label: `Fleet \xB7 ${status}`, payload: { fleetStatusFilter: status } } },
305
- message: `open the fleet filtered to ${status} runs`,
306
- data: { fg, value }
307
- };
308
- }
309
- var renderStats = (ctx) => {
310
- const lines = [];
311
- const stats = readStats(ctx.details);
312
- if (stats) {
313
- const window = stats.since ? `since ${stats.since}` : "all time";
314
- lines.push(line(`FLEET STATS \xB7 ${window}`, { fg: RIG_UI.lime, bold: true }));
315
- lines.push(blank());
316
- lines.push(...sinceSwitcher(ctx, stats.since));
317
- lines.push(blank());
318
- const dist = distributionBar(stats);
319
- if (dist.length > 0) {
320
- lines.push(...dist);
321
- lines.push(blank());
322
- }
323
- lines.push(heading("VOLUME"));
324
- lines.push(metric("total runs", String(stats.totalRuns), { fg: RIG_UI.ink, bold: true }));
325
- 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)));
326
- 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)));
327
- 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)));
328
- lines.push(blank());
329
- lines.push(heading("FLOW"));
330
- lines.push(metric("median run time", duration(stats.medianCompletionMs), { fg: RIG_UI.cyan }));
331
- lines.push(metric("steering", `${stats.steeringTotal} total \xB7 ${perRun(stats.steeringPerRun)}`, { fg: RIG_UI.ink2 }));
332
- lines.push(metric("stalls", String(stats.stallTotal), {
333
- fg: stats.stallTotal > 0 ? RIG_UI.yellow : RIG_UI.ink2
334
- }));
335
- lines.push(blank());
336
- lines.push(heading("APPROVALS"));
337
- lines.push(metric("requested", String(stats.approvalsRequested), { fg: RIG_UI.ink2 }));
338
- lines.push(metric("approved", String(stats.approvalsApproved), { fg: RIG_UI.lime }));
339
- lines.push(metric("rejected", String(stats.approvalsRejected), { fg: RIG_UI.red }));
340
- lines.push(metric("pending", String(stats.approvalsPending), {
341
- fg: stats.approvalsPending > 0 ? RIG_UI.yellow : RIG_UI.ink2
342
- }));
343
- const other = Object.entries(stats.statusCounts).filter(([status]) => !["completed", "failed", "needs-attention"].includes(status)).sort(([, a], [, b]) => b - a);
344
- if (other.length > 0) {
345
- lines.push(blank());
346
- lines.push(heading("OTHER STATUSES"));
347
- for (const [status, count] of other)
348
- lines.push(metric(status, String(count), { fg: RIG_UI.ink2 }));
349
- }
350
- lines.push(blank());
351
- } else if (ctx.state.ran && ctx.state.lines.length > 0) {
352
- lines.push(line("FLEET STATS", { fg: RIG_UI.lime, bold: true }));
353
- lines.push(blank());
354
- lines.push(...sinceSwitcher(ctx, null));
355
- lines.push(blank());
356
- for (const text of ctx.state.lines.slice(0, 60))
357
- lines.push(line(` ${text}`, { fg: RIG_UI.ink2 }));
358
- lines.push(blank());
359
- } else {
360
- lines.push(line("FLEET STATS", { fg: RIG_UI.lime, bold: true }));
361
- lines.push(line(" no run data captured yet", { fg: RIG_UI.ink4 }));
362
- lines.push(blank());
363
- }
364
- lines.push(...actionDeck(ctx, ctx.snap.subcommands, "ACTIONS"));
365
- lines.push(blank());
366
- 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 }));
367
- return lines;
368
- };
369
- export {
370
- renderStats
371
- };
@@ -1,3 +0,0 @@
1
- import type { StageLayout } from "../layout";
2
- import type { AppSceneFrame, AppState } from "../types";
3
- export declare function renderFamilyScene(state: AppState, layout?: StageLayout): AppSceneFrame;