@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 { AppIntent } from "./types";
2
+ export declare function intentFromArgv(argv: readonly string[]): AppIntent;
3
+ export declare function intentFromTypeBar(value: string): AppIntent;
@@ -0,0 +1,211 @@
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
+ function intentFromTypeBar(value) {
164
+ const raw = value.trim();
165
+ if (!raw)
166
+ return intent("fleet", [], "refresh", undefined, "Opening runs", value);
167
+ const parts = raw.split(/\s+/).filter(Boolean);
168
+ const [first = "", second = "", ...rest] = parts;
169
+ const firstScene = NAV_SCENES.get(first.toLowerCase());
170
+ if (first === "tasks" || first === "task") {
171
+ if (second === "run") {
172
+ const task = explicitTaskIdArg(rest);
173
+ if (rest.includes("--next") || task === "next")
174
+ return intent("tasks", parts, "task-run-next", undefined, "Dispatching next task", value);
175
+ if (task)
176
+ return intent("tasks", parts, "task-run-id", { task }, `Dispatching ${task}`, value);
177
+ return intent("tasks", parts, "refresh", undefined, "Select a task, then press Enter; or use run next", value);
178
+ }
179
+ if (!isTaskViewCommand(second.toLowerCase()))
180
+ return unsupportedPlainCliIntent(parts, value);
181
+ return taskViewIntent(parts, second, rest, value);
182
+ }
183
+ if (first === "run") {
184
+ if (second === "next" || second === "--next")
185
+ return intent("tasks", parts, "task-run-next", undefined, "Dispatching next task", value);
186
+ if (second === "--task") {
187
+ const task = explicitTaskIdArg([second, ...rest]);
188
+ if (task)
189
+ return intent("tasks", parts, "task-run-id", { task }, `Dispatching ${task}`, value);
190
+ return intent("tasks", parts, "refresh", undefined, "Select a task, then press Enter; or use run next", value);
191
+ }
192
+ if (second && !second.startsWith("-"))
193
+ return intent("tasks", parts, "task-run-id", { task: second }, `Dispatching ${second}`, value);
194
+ return intent("tasks", parts, "refresh", undefined, "Select a task, then press Enter; or use run next", value);
195
+ }
196
+ if (firstScene && parts.length === 1) {
197
+ return intent(firstScene, parts, "navigate", undefined, `Opening ${firstScene}`, value);
198
+ }
199
+ if (first === "stop")
200
+ return intent("fleet", parts, "run-stop", { runId: second || undefined }, second ? `Stopping ${second}` : "Stopping run", value);
201
+ if (first === "attach") {
202
+ if (!second)
203
+ return intent("handoff", parts, "navigate", undefined, "Select a run to attach", value);
204
+ return intent("handoff", parts, "run-attach", { runId: second }, `Attaching ${second}`, value);
205
+ }
206
+ return intentFromArgv(parts);
207
+ }
208
+ export {
209
+ intentFromTypeBar,
210
+ intentFromArgv
211
+ };
@@ -0,0 +1,15 @@
1
+ export type StageLayout = {
2
+ readonly width: number;
3
+ readonly height: number;
4
+ readonly centerWidth: number;
5
+ readonly centerLeft: number;
6
+ readonly centerTop: number;
7
+ readonly centerHeight: number;
8
+ readonly typeBarTop: number;
9
+ readonly footerTop: number;
10
+ readonly compact: boolean;
11
+ };
12
+ export declare function computeStageLayout(width: number, height: number): StageLayout;
13
+ export declare function visibleWidth(text: string): number;
14
+ export declare function alignText(text: string, width: number, align?: "left" | "center" | "right"): string;
15
+ export declare function truncateText(text: string, width: number): string;
@@ -0,0 +1,44 @@
1
+ // @bun
2
+ // packages/cli/src/app-opentui/layout.ts
3
+ function computeStageLayout(width, height) {
4
+ const safeWidth = Math.max(40, Math.trunc(width || 80));
5
+ const safeHeight = Math.max(18, Math.trunc(height || 24));
6
+ const compact = safeWidth < 92 || safeHeight < 30;
7
+ const horizontalGutter = compact ? 1 : 2;
8
+ const centerWidth = Math.max(36, safeWidth - horizontalGutter * 2);
9
+ const centerLeft = horizontalGutter;
10
+ const typeBarTop = Math.max(0, safeHeight - 3);
11
+ const footerTop = Math.max(0, safeHeight - 1);
12
+ const centerTop = compact ? 1 : Math.max(1, Math.floor(safeHeight * 0.055));
13
+ const centerHeight = Math.max(8, typeBarTop - centerTop - 1);
14
+ return { width: safeWidth, height: safeHeight, centerWidth, centerLeft, centerTop, centerHeight, typeBarTop, footerTop, compact };
15
+ }
16
+ function visibleWidth(text) {
17
+ return [...text].length;
18
+ }
19
+ function alignText(text, width, align = "left") {
20
+ const length = visibleWidth(text);
21
+ if (length >= width)
22
+ return text;
23
+ const pad = width - length;
24
+ if (align === "right")
25
+ return `${" ".repeat(pad)}${text}`;
26
+ if (align === "center") {
27
+ const left = Math.floor(pad / 2);
28
+ return `${" ".repeat(left)}${text}${" ".repeat(pad - left)}`;
29
+ }
30
+ return text;
31
+ }
32
+ function truncateText(text, width) {
33
+ if (visibleWidth(text) <= width)
34
+ return text;
35
+ if (width <= 1)
36
+ return "\u2026";
37
+ return `${[...text].slice(0, Math.max(0, width - 1)).join("")}\u2026`;
38
+ }
39
+ export {
40
+ visibleWidth,
41
+ truncateText,
42
+ computeStageLayout,
43
+ alignText
44
+ };
@@ -0,0 +1,8 @@
1
+ import type { AppRunRecord } from "./adapters/fleet";
2
+ import type { AppTaskRecord } from "./adapters/tasks";
3
+ import type { AppSceneId, AppState } from "./types";
4
+ export declare function isListSearchScene(scene: AppSceneId): boolean;
5
+ export declare function listSearchQuery(state: AppState): string;
6
+ export declare function filterRunsForSearch(runs: readonly AppRunRecord[], query: string): AppRunRecord[];
7
+ export declare function filterTasksForSearch(tasks: readonly AppTaskRecord[], query: string): AppTaskRecord[];
8
+ export declare function searchSummary(kind: "runs" | "tasks", query: string, visible: number, total: number): string;
@@ -0,0 +1,43 @@
1
+ // @bun
2
+ // packages/cli/src/app-opentui/list-search.ts
3
+ function isListSearchScene(scene) {
4
+ return scene === "fleet" || scene === "tasks";
5
+ }
6
+ function listSearchQuery(state) {
7
+ return isListSearchScene(state.scene) ? state.typeBar.value.trim() : "";
8
+ }
9
+ function valueText(value) {
10
+ if (value === undefined || value === null)
11
+ return "";
12
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
13
+ return String(value);
14
+ if (Array.isArray(value))
15
+ return value.map(valueText).join(" ");
16
+ if (typeof value === "object") {
17
+ const record = value;
18
+ return ["id", "runId", "taskId", "number", "title", "name", "summary", "status", "state", "label", "labels", "assignee", "assignees", "url"].map((key) => valueText(record[key])).join(" ");
19
+ }
20
+ return "";
21
+ }
22
+ function includesQuery(haystack, query) {
23
+ const needle = query.trim().toLowerCase();
24
+ if (!needle)
25
+ return true;
26
+ return haystack.map(valueText).join(" ").toLowerCase().includes(needle);
27
+ }
28
+ function filterRunsForSearch(runs, query) {
29
+ return query.trim() ? runs.filter((run) => includesQuery([run.runId, run.status, run.title, run.taskId, run.raw], query)) : [...runs];
30
+ }
31
+ function filterTasksForSearch(tasks, query) {
32
+ return query.trim() ? tasks.filter((task) => includesQuery([task.id, task.status, task.title, task.priority, task.labels, task.assignees, task.raw], query)) : [...tasks];
33
+ }
34
+ function searchSummary(kind, query, visible, total) {
35
+ return query.trim() ? `search ${JSON.stringify(query)} \xB7 ${visible}/${total} ${kind}` : `${total} ${kind}`;
36
+ }
37
+ export {
38
+ searchSummary,
39
+ listSearchQuery,
40
+ isListSearchScene,
41
+ filterTasksForSearch,
42
+ filterRunsForSearch
43
+ };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export declare function runOpenTuiPiHostChild(argv?: readonly string[]): Promise<void>;