@h-rig/cli 0.0.6-alpha.8 → 0.0.6-alpha.81

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 (198) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/build-rig-binaries.d.ts +2 -0
  3. package/dist/bin/rig.d.ts +2 -0
  4. package/dist/bin/rig.js +18374 -8205
  5. package/dist/src/app/board.d.ts +23 -0
  6. package/dist/src/app/board.js +1815 -0
  7. package/dist/src/app/drone-ui.d.ts +37 -0
  8. package/dist/src/app/drone-ui.js +294 -0
  9. package/dist/src/app/theme.d.ts +47 -0
  10. package/dist/src/app/theme.js +151 -0
  11. package/dist/src/app-opentui/adapters/common.d.ts +53 -0
  12. package/dist/src/app-opentui/adapters/common.js +149 -0
  13. package/dist/src/app-opentui/adapters/doctor.d.ts +11 -0
  14. package/dist/src/app-opentui/adapters/doctor.js +780 -0
  15. package/dist/src/app-opentui/adapters/fleet.d.ts +16 -0
  16. package/dist/src/app-opentui/adapters/fleet.js +874 -0
  17. package/dist/src/app-opentui/adapters/inbox.d.ts +33 -0
  18. package/dist/src/app-opentui/adapters/inbox.js +1454 -0
  19. package/dist/src/app-opentui/adapters/init.d.ts +13 -0
  20. package/dist/src/app-opentui/adapters/init.js +2357 -0
  21. package/dist/src/app-opentui/adapters/pi-attach.d.ts +16 -0
  22. package/dist/src/app-opentui/adapters/pi-attach.js +1295 -0
  23. package/dist/src/app-opentui/adapters/run-detail.d.ts +20 -0
  24. package/dist/src/app-opentui/adapters/run-detail.js +893 -0
  25. package/dist/src/app-opentui/adapters/server.d.ts +14 -0
  26. package/dist/src/app-opentui/adapters/server.js +798 -0
  27. package/dist/src/app-opentui/adapters/tasks.d.ts +55 -0
  28. package/dist/src/app-opentui/adapters/tasks.js +3472 -0
  29. package/dist/src/app-opentui/bootstrap.d.ts +16 -0
  30. package/dist/src/app-opentui/bootstrap.js +19509 -0
  31. package/dist/src/app-opentui/drone.d.ts +12 -0
  32. package/dist/src/app-opentui/drone.js +227 -0
  33. package/dist/src/app-opentui/events.d.ts +7 -0
  34. package/dist/src/app-opentui/events.js +28 -0
  35. package/dist/src/app-opentui/index.d.ts +8 -0
  36. package/dist/src/app-opentui/index.js +3477 -0
  37. package/dist/src/app-opentui/intent.d.ts +3 -0
  38. package/dist/src/app-opentui/intent.js +211 -0
  39. package/dist/src/app-opentui/layout.d.ts +15 -0
  40. package/dist/src/app-opentui/layout.js +44 -0
  41. package/dist/src/app-opentui/list-search.d.ts +8 -0
  42. package/dist/src/app-opentui/list-search.js +43 -0
  43. package/dist/src/app-opentui/pi-host-child.d.ts +2 -0
  44. package/dist/src/app-opentui/pi-host-child.js +778 -0
  45. package/dist/src/app-opentui/pi-pty-host.d.ts +64 -0
  46. package/dist/src/app-opentui/pi-pty-host.js +384 -0
  47. package/dist/src/app-opentui/registry.d.ts +4 -0
  48. package/dist/src/app-opentui/registry.js +6835 -0
  49. package/dist/src/app-opentui/render/graphics.d.ts +39 -0
  50. package/dist/src/app-opentui/render/graphics.js +537 -0
  51. package/dist/src/app-opentui/render/image-visual-layer-native-canvas.d.ts +2 -0
  52. package/dist/src/app-opentui/render/image-visual-layer-native-canvas.js +1480 -0
  53. package/dist/src/app-opentui/render/image-visual-layer-worker.d.ts +1 -0
  54. package/dist/src/app-opentui/render/image-visual-layer-worker.js +1541 -0
  55. package/dist/src/app-opentui/render/image-visual-layer.d.ts +93 -0
  56. package/dist/src/app-opentui/render/image-visual-layer.js +945 -0
  57. package/dist/src/app-opentui/render/panels.d.ts +10 -0
  58. package/dist/src/app-opentui/render/panels.js +201 -0
  59. package/dist/src/app-opentui/render/scene.d.ts +16 -0
  60. package/dist/src/app-opentui/render/scene.js +110 -0
  61. package/dist/src/app-opentui/render/text.d.ts +10 -0
  62. package/dist/src/app-opentui/render/text.js +121 -0
  63. package/dist/src/app-opentui/render/type-bar.d.ts +14 -0
  64. package/dist/src/app-opentui/render/type-bar.js +137 -0
  65. package/dist/src/app-opentui/runtime.d.ts +2 -0
  66. package/dist/src/app-opentui/runtime.js +3406 -0
  67. package/dist/src/app-opentui/scenes/doctor.d.ts +2 -0
  68. package/dist/src/app-opentui/scenes/doctor.js +91 -0
  69. package/dist/src/app-opentui/scenes/error.d.ts +2 -0
  70. package/dist/src/app-opentui/scenes/error.js +190 -0
  71. package/dist/src/app-opentui/scenes/fleet.d.ts +3 -0
  72. package/dist/src/app-opentui/scenes/fleet.js +207 -0
  73. package/dist/src/app-opentui/scenes/handoff.d.ts +2 -0
  74. package/dist/src/app-opentui/scenes/handoff.js +147 -0
  75. package/dist/src/app-opentui/scenes/help.d.ts +3 -0
  76. package/dist/src/app-opentui/scenes/help.js +138 -0
  77. package/dist/src/app-opentui/scenes/inbox.d.ts +2 -0
  78. package/dist/src/app-opentui/scenes/inbox.js +118 -0
  79. package/dist/src/app-opentui/scenes/init.d.ts +2 -0
  80. package/dist/src/app-opentui/scenes/init.js +94 -0
  81. package/dist/src/app-opentui/scenes/main.d.ts +2 -0
  82. package/dist/src/app-opentui/scenes/main.js +96 -0
  83. package/dist/src/app-opentui/scenes/run-detail.d.ts +2 -0
  84. package/dist/src/app-opentui/scenes/run-detail.js +139 -0
  85. package/dist/src/app-opentui/scenes/server.d.ts +2 -0
  86. package/dist/src/app-opentui/scenes/server.js +88 -0
  87. package/dist/src/app-opentui/scenes/tasks.d.ts +3 -0
  88. package/dist/src/app-opentui/scenes/tasks.js +230 -0
  89. package/dist/src/app-opentui/state.d.ts +4 -0
  90. package/dist/src/app-opentui/state.js +286 -0
  91. package/dist/src/app-opentui/theme.d.ts +36 -0
  92. package/dist/src/app-opentui/theme.js +88 -0
  93. package/dist/src/app-opentui/types.d.ts +188 -0
  94. package/dist/src/app-opentui/types.js +1 -0
  95. package/dist/src/commands/_async-ui.d.ts +13 -0
  96. package/dist/src/commands/_async-ui.js +223 -0
  97. package/dist/src/commands/_authority-runs.d.ts +22 -0
  98. package/dist/src/commands/_authority-runs.js +2 -3
  99. package/dist/src/commands/_cli-format.d.ts +49 -0
  100. package/dist/src/commands/_cli-format.js +447 -0
  101. package/dist/src/commands/_connection-state.d.ts +44 -0
  102. package/dist/src/commands/_connection-state.js +30 -11
  103. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  104. package/dist/src/commands/_doctor-checks.js +180 -44
  105. package/dist/src/commands/_help-catalog.d.ts +51 -0
  106. package/dist/src/commands/_help-catalog.js +442 -0
  107. package/dist/src/commands/_json-output.d.ts +11 -0
  108. package/dist/src/commands/_json-output.js +56 -0
  109. package/dist/src/commands/_operator-surface.d.ts +34 -0
  110. package/dist/src/commands/_operator-surface.js +220 -0
  111. package/dist/src/commands/_operator-view.d.ts +30 -0
  112. package/dist/src/commands/_operator-view.js +803 -73
  113. package/dist/src/commands/_parsers.d.ts +15 -0
  114. package/dist/src/commands/_parsers.js +18 -11
  115. package/dist/src/commands/_paths.d.ts +11 -0
  116. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  117. package/dist/src/commands/_pi-frontend.js +742 -0
  118. package/dist/src/commands/_pi-install.d.ts +42 -0
  119. package/dist/src/commands/_pi-install.js +5 -4
  120. package/dist/src/commands/_policy.d.ts +8 -0
  121. package/dist/src/commands/_policy.js +12 -5
  122. package/dist/src/commands/_preflight.d.ts +22 -0
  123. package/dist/src/commands/_preflight.js +190 -128
  124. package/dist/src/commands/_probes.d.ts +1 -0
  125. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  126. package/dist/src/commands/_run-driver-helpers.js +75 -22
  127. package/dist/src/commands/_run-replay.d.ts +24 -0
  128. package/dist/src/commands/_run-replay.js +142 -0
  129. package/dist/src/commands/_server-client.d.ts +186 -0
  130. package/dist/src/commands/_server-client.js +360 -61
  131. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  132. package/dist/src/commands/_snapshot-upload.js +163 -39
  133. package/dist/src/commands/_spinner.d.ts +25 -0
  134. package/dist/src/commands/_spinner.js +65 -0
  135. package/dist/src/commands/_task-picker.d.ts +9 -0
  136. package/dist/src/commands/_task-picker.js +172 -19
  137. package/dist/src/commands/agent.d.ts +3 -0
  138. package/dist/src/commands/agent.js +39 -20
  139. package/dist/src/commands/browser.d.ts +65 -0
  140. package/dist/src/commands/browser.js +334 -51
  141. package/dist/src/commands/connect.d.ts +7 -0
  142. package/dist/src/commands/connect.js +272 -33
  143. package/dist/src/commands/dist.d.ts +28 -0
  144. package/dist/src/commands/dist.js +19 -12
  145. package/dist/src/commands/doctor.d.ts +3 -0
  146. package/dist/src/commands/doctor.js +378 -45
  147. package/dist/src/commands/github.d.ts +3 -0
  148. package/dist/src/commands/github.js +375 -53
  149. package/dist/src/commands/inbox.d.ts +30 -0
  150. package/dist/src/commands/inbox.js +760 -70
  151. package/dist/src/commands/init.d.ts +74 -0
  152. package/dist/src/commands/init.js +963 -119
  153. package/dist/src/commands/inspect.d.ts +3 -0
  154. package/dist/src/commands/inspect.js +588 -32
  155. package/dist/src/commands/inspector.d.ts +3 -0
  156. package/dist/src/commands/inspector.js +20 -13
  157. package/dist/src/commands/pi.d.ts +3 -0
  158. package/dist/src/commands/pi.js +177 -0
  159. package/dist/src/commands/plugin.d.ts +16 -0
  160. package/dist/src/commands/plugin.js +95 -27
  161. package/dist/src/commands/profile-and-review.d.ts +4 -0
  162. package/dist/src/commands/profile-and-review.js +26 -19
  163. package/dist/src/commands/queue.d.ts +3 -0
  164. package/dist/src/commands/queue.js +32 -12
  165. package/dist/src/commands/remote.d.ts +3 -0
  166. package/dist/src/commands/remote.js +43 -36
  167. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  168. package/dist/src/commands/repo-git-harness.js +22 -15
  169. package/dist/src/commands/run.d.ts +3 -0
  170. package/dist/src/commands/run.js +1379 -159
  171. package/dist/src/commands/server.d.ts +7 -0
  172. package/dist/src/commands/server.js +502 -57
  173. package/dist/src/commands/setup.d.ts +16 -0
  174. package/dist/src/commands/setup.js +390 -63
  175. package/dist/src/commands/stats.d.ts +12 -0
  176. package/dist/src/commands/stats.js +1051 -0
  177. package/dist/src/commands/task-report-bug.d.ts +19 -0
  178. package/dist/src/commands/task-report-bug.js +260 -62
  179. package/dist/src/commands/task-run-driver.d.ts +132 -0
  180. package/dist/src/commands/task-run-driver.js +886 -130
  181. package/dist/src/commands/task.d.ts +14 -0
  182. package/dist/src/commands/task.js +1644 -314
  183. package/dist/src/commands/test.d.ts +3 -0
  184. package/dist/src/commands/test.js +15 -8
  185. package/dist/src/commands/workspace.d.ts +3 -0
  186. package/dist/src/commands/workspace.js +18 -11
  187. package/dist/src/commands.d.ts +29 -0
  188. package/dist/src/commands.js +10996 -6637
  189. package/dist/src/index.d.ts +4 -0
  190. package/dist/src/index.js +10197 -5787
  191. package/dist/src/launcher.d.ts +61 -0
  192. package/dist/src/launcher.js +77 -13
  193. package/dist/src/report-bug.d.ts +44 -0
  194. package/dist/src/report-bug.js +3 -3
  195. package/dist/src/runner.d.ts +47 -0
  196. package/dist/src/runner.js +16 -22
  197. package/dist/src/withMutedConsole.d.ts +2 -0
  198. package/package.json +16 -6
@@ -0,0 +1,3 @@
1
+ import type { StageLayout } from "../layout";
2
+ import type { AppSceneFrame, AppState } from "../types";
3
+ export declare function renderTasksScene(state: AppState, layout?: StageLayout): AppSceneFrame;
@@ -0,0 +1,230 @@
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: "#101115",
15
+ glass: "#14161b",
16
+ ink: "#f2f3f6",
17
+ ink2: "#aeb0ba",
18
+ ink3: "#6c6e79",
19
+ ink4: "#44464f",
20
+ lime: "#ccff4d",
21
+ limeDim: "#a9d63f",
22
+ cyan: "#56d8ff",
23
+ red: "#ff5d5d",
24
+ yellow: "#ffd24d",
25
+ magenta: "#ff79b0"
26
+ };
27
+ var styles = {
28
+ ink: otuiFg(RIG_UI.ink),
29
+ ink2: otuiFg(RIG_UI.ink2),
30
+ ink3: otuiFg(RIG_UI.ink3),
31
+ ink4: otuiFg(RIG_UI.ink4),
32
+ lime: otuiFg(RIG_UI.lime),
33
+ limeDim: otuiFg(RIG_UI.limeDim),
34
+ cyan: otuiFg(RIG_UI.cyan),
35
+ red: otuiFg(RIG_UI.red),
36
+ yellow: otuiFg(RIG_UI.yellow),
37
+ magenta: otuiFg(RIG_UI.magenta)
38
+ };
39
+ function statusColor(status) {
40
+ switch (status) {
41
+ case "running":
42
+ case "success":
43
+ case "completed":
44
+ case "merged":
45
+ return RIG_UI.lime;
46
+ case "preparing":
47
+ case "created":
48
+ case "validating":
49
+ case "reviewing":
50
+ case "closing-out":
51
+ case "stopping":
52
+ case "loading":
53
+ case "action":
54
+ return RIG_UI.cyan;
55
+ case "needs-attention":
56
+ case "needs_attention":
57
+ return RIG_UI.yellow;
58
+ case "failed":
59
+ case "error":
60
+ return RIG_UI.red;
61
+ default:
62
+ return RIG_UI.ink3;
63
+ }
64
+ }
65
+
66
+ // packages/cli/src/app-opentui/render/scene.ts
67
+ function line(text, options = {}) {
68
+ return { text, ...options };
69
+ }
70
+ function makeSceneFrame(input) {
71
+ return input;
72
+ }
73
+
74
+ // packages/cli/src/app-opentui/list-search.ts
75
+ function isListSearchScene(scene) {
76
+ return scene === "fleet" || scene === "tasks";
77
+ }
78
+ function listSearchQuery(state) {
79
+ return isListSearchScene(state.scene) ? state.typeBar.value.trim() : "";
80
+ }
81
+ function valueText(value) {
82
+ if (value === undefined || value === null)
83
+ return "";
84
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
85
+ return String(value);
86
+ if (Array.isArray(value))
87
+ return value.map(valueText).join(" ");
88
+ if (typeof value === "object") {
89
+ const record = value;
90
+ return ["id", "runId", "taskId", "number", "title", "name", "summary", "status", "state", "label", "labels", "assignee", "assignees", "url"].map((key) => valueText(record[key])).join(" ");
91
+ }
92
+ return "";
93
+ }
94
+ function includesQuery(haystack, query) {
95
+ const needle = query.trim().toLowerCase();
96
+ if (!needle)
97
+ return true;
98
+ return haystack.map(valueText).join(" ").toLowerCase().includes(needle);
99
+ }
100
+ function filterTasksForSearch(tasks, query) {
101
+ return query.trim() ? tasks.filter((task) => includesQuery([task.id, task.status, task.title, task.priority, task.labels, task.assignees, task.raw], query)) : [...tasks];
102
+ }
103
+ function searchSummary(kind, query, visible, total) {
104
+ return query.trim() ? `search ${JSON.stringify(query)} \xB7 ${visible}/${total} ${kind}` : `${total} ${kind}`;
105
+ }
106
+
107
+ // packages/cli/src/app-opentui/scenes/tasks.ts
108
+ function taskView(state) {
109
+ const tasks = state.data.tasks;
110
+ return tasks && typeof tasks === "object" && !Array.isArray(tasks) ? tasks : null;
111
+ }
112
+ function taskRecords(state) {
113
+ const records = taskView(state)?.records;
114
+ return Array.isArray(records) ? records : [];
115
+ }
116
+ function panelWidth(layout) {
117
+ return layout?.centerWidth ?? 100;
118
+ }
119
+ function panelHeight(layout, top = 3) {
120
+ return Math.max(4, (layout?.centerHeight ?? 24) - top);
121
+ }
122
+ function clip(value, width) {
123
+ if (width <= 0)
124
+ return "";
125
+ return value.length <= width ? value : `${value.slice(0, Math.max(0, width - 1))}\u2026`;
126
+ }
127
+ function formatAssignee(value) {
128
+ return value.startsWith("@") ? value : `@${value}`;
129
+ }
130
+ function taskViewLabel(view) {
131
+ const filters = view?.filters && typeof view.filters === "object" && !Array.isArray(view.filters) ? view.filters : {};
132
+ const filter = typeof filters.preset === "string" && filters.preset !== "custom" ? filters.preset : [
133
+ typeof filters.state === "string" ? `state:${filters.state}` : null,
134
+ typeof filters.status === "string" ? `status:${filters.status}` : null,
135
+ typeof filters.assignee === "string" ? formatAssignee(filters.assignee) : null,
136
+ typeof filters.label === "string" ? `label:${filters.label}` : null,
137
+ typeof filters.search === "string" ? `search:${filters.search}` : null
138
+ ].filter(Boolean).join(" ") || "open";
139
+ const sort = typeof view?.sort === "string" ? view.sort : "priority";
140
+ const visible = typeof view?.visibleCount === "number" ? view.visibleCount : undefined;
141
+ const total = typeof view?.totalCount === "number" ? view.totalCount : undefined;
142
+ const count = visible !== undefined && total !== undefined ? `${visible}/${total}` : "syncing";
143
+ return `filter ${filter} \xB7 sort ${sort} \xB7 ${count}`;
144
+ }
145
+ function taskRow(width, task, index, active) {
146
+ const id = task.id.slice(0, 10).padEnd(11);
147
+ const status = task.status.replace(/[_-]/g, " ").slice(0, 11).padEnd(12);
148
+ const priority = task.priority === undefined ? "prio --" : `prio ${String(task.priority).slice(0, 3).padStart(2)}`;
149
+ const marker = active ? "\u258C" : " ";
150
+ const prefix = `${marker} ${id} ${status} ${priority.padEnd(8)} `;
151
+ const titleWidth = Math.max(12, width - prefix.length - 2);
152
+ return line(`${prefix}${clip(task.title, titleWidth)}`, {
153
+ fg: active ? RIG_UI.ink : statusColor(task.status),
154
+ bold: active,
155
+ selectableIndex: index
156
+ });
157
+ }
158
+ function emptyRows(query, total) {
159
+ if (query.trim() && total > 0) {
160
+ return [
161
+ line("No matching tasks.", { fg: RIG_UI.ink2, bold: true }),
162
+ line(`search ${JSON.stringify(query)} returned 0/${total}`, { fg: RIG_UI.ink3 }),
163
+ line("escape clears search", { fg: RIG_UI.ink4 })
164
+ ];
165
+ }
166
+ return [
167
+ line("No tasks loaded.", { fg: RIG_UI.ink2, bold: true }),
168
+ line("Check the task source or switch filters from Help.", { fg: RIG_UI.ink3 }),
169
+ line("tab switches screens", { fg: RIG_UI.ink4 })
170
+ ];
171
+ }
172
+ function degradedRows(state) {
173
+ if (!state.error)
174
+ return [];
175
+ return [
176
+ line(`status: ${state.error.message}`, { fg: RIG_UI.red, bold: true }),
177
+ ...state.error.hint ? [line(state.error.hint, { fg: RIG_UI.yellow })] : [],
178
+ line("", { fg: RIG_UI.ink3 })
179
+ ];
180
+ }
181
+ function renderTasksScene(state, layout) {
182
+ const width = panelWidth(layout);
183
+ const view = taskView(state);
184
+ const allTasks = taskRecords(state);
185
+ const query = listSearchQuery(state);
186
+ const tasks = filterTasksForSearch(allTasks, query);
187
+ const selected = typeof state.data.selectedTaskId === "string" && tasks.some((task) => task.id === state.data.selectedTaskId) ? state.data.selectedTaskId : tasks[0]?.id;
188
+ const selectedIndex = Math.max(0, tasks.findIndex((task) => task.id === selected));
189
+ const dispatch = state.data.dispatchingRun;
190
+ const dispatchLine = dispatch && typeof dispatch === "object" && !Array.isArray(dispatch) ? ` \xB7 ${dispatch.runId ?? "new"} ${dispatch.status ?? "dispatching"}` : "";
191
+ const panelTop = 0;
192
+ const contentWidth = Math.max(12, width - (layout?.compact ? 8 : 10));
193
+ const panelLines = [
194
+ line("TASK STATUS PRIORITY TITLE", { fg: RIG_UI.ink3, bold: true }),
195
+ line("", { fg: RIG_UI.ink3 }),
196
+ ...degradedRows(state),
197
+ ...query.trim() ? [line(searchSummary("tasks", query, tasks.length, allTasks.length), { fg: RIG_UI.ink4 }), line("", { fg: RIG_UI.ink3 })] : [],
198
+ ...tasks.length > 0 ? tasks.map((task, index) => taskRow(contentWidth, task, index, index === selectedIndex)) : emptyRows(query, allTasks.length)
199
+ ];
200
+ return makeSceneFrame({
201
+ scene: "tasks",
202
+ title: "Tasks",
203
+ lines: [
204
+ line("", { fg: RIG_UI.ink4 }),
205
+ line(query.trim() ? ` rig tasks --search ${JSON.stringify(query)}` : ` rig tasks \xB7 ${taskViewLabel(view)}${dispatchLine}`, { fg: RIG_UI.ink3 })
206
+ ],
207
+ panels: [{
208
+ id: "tasks-list",
209
+ top: panelTop,
210
+ width,
211
+ height: panelHeight(layout, panelTop),
212
+ lines: panelLines,
213
+ backgroundColor: RIG_UI.panel,
214
+ backgroundAlpha: 184,
215
+ opacity: 1,
216
+ border: false,
217
+ chrome: "ad-terminal",
218
+ headerText: query.trim() ? `rig tasks --search ${JSON.stringify(query)}` : `rig tasks \xB7 ${taskViewLabel(view)}${dispatchLine}`,
219
+ headerHeight: 3,
220
+ paddingX: layout?.compact ? 2 : 3,
221
+ paddingY: 1
222
+ }],
223
+ footer: { message: query.trim() ? searchSummary("tasks", query, tasks.length, allTasks.length) : taskViewLabel(view) },
224
+ typeBarPlaceholder: "search tasks\u2026",
225
+ live: true
226
+ });
227
+ }
228
+ export {
229
+ renderTasksScene
230
+ };
@@ -0,0 +1,4 @@
1
+ import type { AppEvent, AppLaunchOptions, AppState, AppStatePatch, AppStore } from "./types";
2
+ export declare function createInitialAppState(options: AppLaunchOptions): AppState;
3
+ export declare function createAppStore(initialState: AppState): AppStore;
4
+ export declare function reduceAppEvent(state: AppState, event: AppEvent): AppStatePatch;
@@ -0,0 +1,286 @@
1
+ // @bun
2
+ // packages/cli/src/app-opentui/intent.ts
3
+ var NAV_SCENES = new Map([
4
+ ["", "fleet"],
5
+ ["main", "fleet"],
6
+ ["home", "fleet"],
7
+ ["fleet", "fleet"],
8
+ ["runs", "fleet"],
9
+ ["run", "fleet"],
10
+ ["tasks", "tasks"],
11
+ ["task", "tasks"],
12
+ ["help", "help"]
13
+ ]);
14
+ var TASK_VIEW_COMMANDS = new Set([
15
+ "",
16
+ "all",
17
+ "open",
18
+ "ready",
19
+ "blocked",
20
+ "closed",
21
+ "done",
22
+ "mine",
23
+ "me",
24
+ "sort",
25
+ "status",
26
+ "state",
27
+ "assignee",
28
+ "assigned",
29
+ "label",
30
+ "search",
31
+ "q"
32
+ ]);
33
+ function isTaskViewCommand(command) {
34
+ return !command || TASK_VIEW_COMMANDS.has(command) || command.startsWith("-");
35
+ }
36
+ function intent(scene, argv, kind, payload, label, raw) {
37
+ return {
38
+ scene,
39
+ argv,
40
+ ...raw ? { raw } : {},
41
+ action: {
42
+ kind,
43
+ ...label ? { label } : {},
44
+ ...payload ? { payload } : {}
45
+ }
46
+ };
47
+ }
48
+ function unsupportedPlainCliIntent(argv, raw) {
49
+ const command = argv.join(" ").trim() || "command";
50
+ return intent("help", argv, "none", { unsupported: command }, `${command} is on the plain CLI path; exit Rig shell or rerun with RIG_PLAIN=1`, raw);
51
+ }
52
+ function firstValueAfter(args, option) {
53
+ const index = args.indexOf(option);
54
+ return index >= 0 ? args[index + 1] : undefined;
55
+ }
56
+ function firstNonOption(args) {
57
+ return args.find((part) => part.trim() && !part.startsWith("-"));
58
+ }
59
+ function explicitTaskIdArg(args) {
60
+ const taskValue = firstValueAfter(args, "--task");
61
+ if (taskValue && !taskValue.startsWith("-"))
62
+ return taskValue;
63
+ return args.find((part) => part.trim() && part !== "next" && part !== "--next" && part !== "--task" && !part.startsWith("-"));
64
+ }
65
+ function taskViewPayload(command, rest) {
66
+ const normalized = command.toLowerCase();
67
+ const args = command ? [command, ...rest] : rest;
68
+ const sort = firstValueAfter(args, "--sort") ?? firstValueAfter(args, "-s");
69
+ const state = firstValueAfter(args, "--state");
70
+ const status = firstValueAfter(args, "--status");
71
+ const assignee = firstValueAfter(args, "--assignee") ?? firstValueAfter(args, "--assigned");
72
+ const label = firstValueAfter(args, "--label");
73
+ const search = firstValueAfter(args, "--search") ?? firstValueAfter(args, "-q");
74
+ const optionPayload = {
75
+ ...sort ? { taskSort: sort } : {},
76
+ ...state ? { taskState: state, taskFilterPreset: "custom" } : {},
77
+ ...status ? { taskStatus: status, taskFilterPreset: "custom" } : {},
78
+ ...assignee ? { taskAssignee: assignee, taskFilterPreset: "custom" } : {},
79
+ ...label ? { taskLabel: label, taskFilterPreset: "custom" } : {},
80
+ ...search ? { taskSearch: search, taskFilterPreset: "custom" } : {}
81
+ };
82
+ if (normalized === "sort") {
83
+ const value = firstNonOption(rest) ?? sort ?? "priority";
84
+ return { payload: { ...optionPayload, taskSort: value }, label: `Sorting tasks by ${value}` };
85
+ }
86
+ if (normalized === "status") {
87
+ const value = firstNonOption(rest) ?? status ?? "open";
88
+ return { payload: { ...optionPayload, taskStatus: value, taskFilterPreset: "custom" }, label: `Filtering tasks by status ${value}` };
89
+ }
90
+ if (normalized === "state") {
91
+ const value = firstNonOption(rest) ?? state ?? "open";
92
+ return { payload: { ...optionPayload, taskState: value, taskFilterPreset: "custom" }, label: `Filtering tasks by state ${value}` };
93
+ }
94
+ if (normalized === "assignee" || normalized === "assigned" || normalized === "mine" || normalized === "me") {
95
+ const value = normalized === "mine" || normalized === "me" ? "me" : firstNonOption(rest) ?? assignee ?? "me";
96
+ return { payload: { ...optionPayload, taskAssignee: value, taskState: "open", taskFilterPreset: value === "me" ? "mine" : "custom" }, label: value === "me" ? "Filtering my tasks" : `Filtering tasks for ${value}` };
97
+ }
98
+ if (normalized === "label") {
99
+ const value = firstNonOption(rest) ?? label;
100
+ return { payload: { ...optionPayload, ...value ? { taskLabel: value } : {}, taskFilterPreset: "custom" }, label: value ? `Filtering tasks labeled ${value}` : "Filtering tasks by label" };
101
+ }
102
+ if (normalized === "search" || normalized === "q") {
103
+ const value = rest.join(" ").trim() || search;
104
+ return { payload: { ...optionPayload, ...value ? { taskSearch: value } : {}, taskFilterPreset: "custom" }, label: value ? `Searching tasks for ${value}` : "Searching tasks" };
105
+ }
106
+ if (["all", "open", "ready", "blocked", "closed", "done"].includes(normalized)) {
107
+ return { payload: { ...optionPayload, taskFilterPreset: normalized === "done" ? "closed" : normalized }, label: `Filtering tasks: ${normalized}` };
108
+ }
109
+ if (Object.keys(optionPayload).length > 0)
110
+ return { payload: optionPayload, label: "Filtering tasks" };
111
+ return { label: "Loading tasks" };
112
+ }
113
+ function taskViewIntent(argv, command = "", rest = [], raw) {
114
+ const { payload, label } = taskViewPayload(command, rest);
115
+ return intent("tasks", argv, "refresh", payload, label, raw);
116
+ }
117
+ function intentFromArgv(argv) {
118
+ const [group = "", command = "", ...rest] = argv;
119
+ const normalizedGroup = group.toLowerCase();
120
+ const normalizedCommand = command.toLowerCase();
121
+ if (!normalizedGroup)
122
+ return intent("fleet", argv, "refresh", undefined, "Opening runs");
123
+ if (normalizedGroup === "--help" || normalizedGroup === "-h" || normalizedGroup === "help") {
124
+ return argv.length === 1 ? intent("help", argv, "none", undefined, "Help") : unsupportedPlainCliIntent(argv);
125
+ }
126
+ if (normalizedGroup === "task") {
127
+ if (normalizedCommand === "run") {
128
+ if (rest.includes("--next") || rest.includes("next")) {
129
+ return intent("tasks", argv, "task-run-next", undefined, "Dispatching next task");
130
+ }
131
+ const task = explicitTaskIdArg(rest);
132
+ if (task)
133
+ return intent("tasks", argv, "task-run-id", { task }, `Dispatching ${task}`);
134
+ return intent("tasks", argv, "refresh", undefined, "Select a task, then press Enter; or use run next");
135
+ }
136
+ if (!isTaskViewCommand(normalizedCommand))
137
+ return unsupportedPlainCliIntent(argv);
138
+ return taskViewIntent(argv, normalizedCommand, rest);
139
+ }
140
+ if (normalizedGroup === "tasks") {
141
+ if (!isTaskViewCommand(normalizedCommand))
142
+ return unsupportedPlainCliIntent(argv);
143
+ return taskViewIntent(argv, normalizedCommand, rest);
144
+ }
145
+ if (normalizedGroup === "run") {
146
+ if (normalizedCommand === "attach") {
147
+ const runId = firstNonOption(rest);
148
+ return intent("handoff", argv, "run-attach", { runId }, runId ? `Attaching ${runId}` : "Attaching run");
149
+ }
150
+ if (!normalizedCommand)
151
+ return intent("fleet", argv, "refresh", undefined, "Loading fleet");
152
+ return unsupportedPlainCliIntent(argv);
153
+ }
154
+ if (normalizedGroup === "attach") {
155
+ const runId = firstNonOption([command, ...rest]);
156
+ return intent("handoff", argv, "run-attach", { runId }, runId ? `Attaching ${runId}` : "Attaching run");
157
+ }
158
+ const nav = NAV_SCENES.get(normalizedGroup);
159
+ if (nav)
160
+ return intent(nav, argv, "navigate", undefined, `Opening ${nav}`);
161
+ return unsupportedPlainCliIntent(argv);
162
+ }
163
+
164
+ // packages/cli/src/app-opentui/state.ts
165
+ function mergePatch(state, patch) {
166
+ return {
167
+ ...state,
168
+ ...patch,
169
+ typeBar: patch.typeBar ? { ...state.typeBar, ...patch.typeBar } : state.typeBar,
170
+ footer: patch.footer ? { ...state.footer, ...patch.footer } : state.footer,
171
+ selection: patch.selection ? { ...state.selection, ...patch.selection } : state.selection,
172
+ data: patch.data ? { ...state.data, ...patch.data } : state.data
173
+ };
174
+ }
175
+ function createInitialAppState(options) {
176
+ const initialIntent = intentFromArgv(options.argv);
177
+ const projectName = options.projectRoot.split(/[\\/]/).filter(Boolean).at(-1) ?? options.projectRoot;
178
+ return {
179
+ projectRoot: options.projectRoot,
180
+ scene: initialIntent.scene,
181
+ status: initialIntent.action.kind === "none" || initialIntent.action.kind === "navigate" ? "idle" : "loading",
182
+ tick: 0,
183
+ argv: options.argv,
184
+ intent: initialIntent,
185
+ typeBar: {
186
+ value: "",
187
+ placeholder: "runs \xB7 tasks \xB7 help \xB7 attach <run>"
188
+ },
189
+ footer: {
190
+ project: projectName,
191
+ ...options.initialFooter ?? {}
192
+ },
193
+ selection: { index: 0, count: 0 },
194
+ data: {
195
+ projectConfigured: options.projectConfigured ?? false
196
+ },
197
+ runtimeReady: false,
198
+ actionLabel: initialIntent.action.label
199
+ };
200
+ }
201
+ function createAppStore(initialState) {
202
+ let state = initialState;
203
+ const listeners = new Set;
204
+ const notify = () => {
205
+ for (const listener of [...listeners])
206
+ listener(state);
207
+ };
208
+ return {
209
+ getState() {
210
+ return state;
211
+ },
212
+ setState(next) {
213
+ state = next;
214
+ notify();
215
+ },
216
+ patch(patch) {
217
+ state = mergePatch(state, patch);
218
+ notify();
219
+ },
220
+ subscribe(listener) {
221
+ listeners.add(listener);
222
+ return () => listeners.delete(listener);
223
+ }
224
+ };
225
+ }
226
+ function reduceAppEvent(state, event) {
227
+ switch (event.type) {
228
+ case "scene.change":
229
+ return {
230
+ scene: event.scene,
231
+ ...event.intent ? { intent: event.intent, actionLabel: event.intent.action.label } : {},
232
+ status: "idle",
233
+ error: undefined,
234
+ typeBar: { message: undefined }
235
+ };
236
+ case "action.started":
237
+ return {
238
+ status: "action",
239
+ actionLabel: event.label,
240
+ error: undefined,
241
+ data: event.optimistic ?? {},
242
+ typeBar: { message: event.label }
243
+ };
244
+ case "action.progress":
245
+ return {
246
+ status: "action",
247
+ actionLabel: event.label,
248
+ data: event.data ?? {},
249
+ typeBar: { message: event.detail ?? event.label }
250
+ };
251
+ case "action.completed":
252
+ return {
253
+ status: "success",
254
+ actionLabel: event.label,
255
+ data: event.data ?? {},
256
+ typeBar: { message: `${event.label} complete` }
257
+ };
258
+ case "action.failed":
259
+ return {
260
+ status: "error",
261
+ actionLabel: event.label,
262
+ error: { message: event.message, hint: event.hint, cause: event.cause },
263
+ typeBar: { message: event.message, placeholder: event.hint ?? "runs \xB7 tasks \xB7 help" }
264
+ };
265
+ case "data.patch":
266
+ return { data: event.data };
267
+ case "footer.patch":
268
+ return { footer: event.footer };
269
+ case "typebar.patch":
270
+ return { typeBar: event.typeBar };
271
+ case "runtime.ready":
272
+ return { runtimeReady: true, footer: { message: "runtime ready" } };
273
+ case "runtime.failed":
274
+ return {
275
+ scene: "error",
276
+ status: "error",
277
+ runtimeReady: false,
278
+ error: { message: event.message, hint: event.hint, cause: event.cause }
279
+ };
280
+ }
281
+ }
282
+ export {
283
+ reduceAppEvent,
284
+ createInitialAppState,
285
+ createAppStore
286
+ };
@@ -0,0 +1,36 @@
1
+ import { bold as otuiBold, dim as otuiDim, fg as otuiFg, t, TextAttributes } from "@opentui/core";
2
+ export declare const RIG_UI: {
3
+ readonly bg: "#070809";
4
+ readonly bg2: "#0b0c0e";
5
+ readonly panel: "#101115";
6
+ readonly panel2: "#101115";
7
+ readonly glass: "#14161b";
8
+ readonly ink: "#f2f3f6";
9
+ readonly ink2: "#aeb0ba";
10
+ readonly ink3: "#6c6e79";
11
+ readonly ink4: "#44464f";
12
+ readonly lime: "#ccff4d";
13
+ readonly limeDim: "#a9d63f";
14
+ readonly cyan: "#56d8ff";
15
+ readonly red: "#ff5d5d";
16
+ readonly yellow: "#ffd24d";
17
+ readonly magenta: "#ff79b0";
18
+ };
19
+ export declare const RIG_SPINNER_FRAMES: readonly ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
20
+ export declare const styles: {
21
+ readonly ink: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
22
+ readonly ink2: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
23
+ readonly ink3: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
24
+ readonly ink4: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
25
+ readonly lime: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
26
+ readonly limeDim: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
27
+ readonly cyan: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
28
+ readonly red: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
29
+ readonly yellow: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
30
+ readonly magenta: (input: import("@opentui/core").StylableInput) => import("@opentui/core").TextChunk;
31
+ };
32
+ export { otuiBold as bold, otuiDim as dim, otuiFg as fg, t, TextAttributes };
33
+ export declare function statusColor(status: string): string;
34
+ export declare function sceneTitle(title: string): import("@opentui/core").StyledText;
35
+ export declare function commandText(command: string): import("@opentui/core").StyledText;
36
+ export declare function faint(text: string): import("@opentui/core").TextChunk;
@@ -0,0 +1,88 @@
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: "#101115",
15
+ glass: "#14161b",
16
+ ink: "#f2f3f6",
17
+ ink2: "#aeb0ba",
18
+ ink3: "#6c6e79",
19
+ ink4: "#44464f",
20
+ lime: "#ccff4d",
21
+ limeDim: "#a9d63f",
22
+ cyan: "#56d8ff",
23
+ red: "#ff5d5d",
24
+ yellow: "#ffd24d",
25
+ magenta: "#ff79b0"
26
+ };
27
+ var RIG_SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
28
+ var styles = {
29
+ ink: otuiFg(RIG_UI.ink),
30
+ ink2: otuiFg(RIG_UI.ink2),
31
+ ink3: otuiFg(RIG_UI.ink3),
32
+ ink4: otuiFg(RIG_UI.ink4),
33
+ lime: otuiFg(RIG_UI.lime),
34
+ limeDim: otuiFg(RIG_UI.limeDim),
35
+ cyan: otuiFg(RIG_UI.cyan),
36
+ red: otuiFg(RIG_UI.red),
37
+ yellow: otuiFg(RIG_UI.yellow),
38
+ magenta: otuiFg(RIG_UI.magenta)
39
+ };
40
+ function statusColor(status) {
41
+ switch (status) {
42
+ case "running":
43
+ case "success":
44
+ case "completed":
45
+ case "merged":
46
+ return RIG_UI.lime;
47
+ case "preparing":
48
+ case "created":
49
+ case "validating":
50
+ case "reviewing":
51
+ case "closing-out":
52
+ case "stopping":
53
+ case "loading":
54
+ case "action":
55
+ return RIG_UI.cyan;
56
+ case "needs-attention":
57
+ case "needs_attention":
58
+ return RIG_UI.yellow;
59
+ case "failed":
60
+ case "error":
61
+ return RIG_UI.red;
62
+ default:
63
+ return RIG_UI.ink3;
64
+ }
65
+ }
66
+ function sceneTitle(title) {
67
+ return t`${otuiBold(styles.ink(title))}`;
68
+ }
69
+ function commandText(command) {
70
+ return t`${styles.lime(command)}`;
71
+ }
72
+ function faint(text) {
73
+ return styles.ink4(text);
74
+ }
75
+ export {
76
+ t,
77
+ styles,
78
+ statusColor,
79
+ sceneTitle,
80
+ otuiFg as fg,
81
+ faint,
82
+ otuiDim as dim,
83
+ commandText,
84
+ otuiBold as bold,
85
+ TextAttributes,
86
+ RIG_UI,
87
+ RIG_SPINNER_FRAMES
88
+ };