@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,16 +0,0 @@
1
- /**
2
- * Interactive CLI is app-shell first.
3
- *
4
- * Native scenes handle the common surfaces (project menu, runs, tasks, inbox,
5
- * server, init, doctor, Pi attach). Every other interactive command still
6
- * enters OpenTUI and is executed inside an embedded plain-CLI PTY, preserving
7
- * the exact existing options/actions/wizards without pretending unsupported
8
- * commands were handled by a read-only scene. Machine/internal paths stay plain.
9
- */
10
- export declare function isOpenTuiAppCommand(argv: readonly string[], env?: NodeJS.ProcessEnv): boolean;
11
- export declare function shouldLaunchTtyApp(input: {
12
- readonly argv: readonly string[];
13
- readonly stdoutIsTty?: boolean;
14
- readonly stdinIsTty?: boolean;
15
- readonly env?: NodeJS.ProcessEnv;
16
- }): boolean;
@@ -1,55 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/launch-routing.ts
3
- var GLOBAL_OPTIONS_WITH_VALUE = new Set(["--project", "--policy-mode", "--run-id"]);
4
- var GLOBAL_FLAGS = new Set(["--dry-run"]);
5
- function envTruthy(value) {
6
- if (!value)
7
- return false;
8
- const normalized = value.trim().toLowerCase();
9
- return normalized !== "0" && normalized !== "false" && normalized !== "no";
10
- }
11
- function stripGlobalAppOptions(argv) {
12
- const rest = [];
13
- for (let index = 0;index < argv.length; index += 1) {
14
- const arg = argv[index];
15
- if (GLOBAL_FLAGS.has(arg))
16
- continue;
17
- if (GLOBAL_OPTIONS_WITH_VALUE.has(arg)) {
18
- index += 1;
19
- continue;
20
- }
21
- rest.push(arg);
22
- }
23
- return rest;
24
- }
25
- function isOpenTuiAppCommand(argv, env = process.env) {
26
- const commandArgv = stripGlobalAppOptions(argv);
27
- const [group = "", command = ""] = commandArgv;
28
- const normalizedGroup = group.toLowerCase();
29
- const normalizedCommand = command.toLowerCase();
30
- if (!normalizedGroup)
31
- return true;
32
- if (normalizedGroup === "__opentui-pi-host" || normalizedGroup === "__rig-server")
33
- return false;
34
- if (normalizedGroup === "server" && normalizedCommand === "task-run")
35
- return false;
36
- if (normalizedGroup === "server" && normalizedCommand === "start" && env.RIG_SERVER_INTERNAL_EXEC === "1")
37
- return false;
38
- return true;
39
- }
40
- function shouldLaunchTtyApp(input) {
41
- const env = input.env ?? process.env;
42
- if (input.argv.includes("--json"))
43
- return false;
44
- if (env.RIG_CLI_PLAIN_HELP === "1" || env.RIG_PLAIN === "1")
45
- return false;
46
- if (envTruthy(env.CI))
47
- return false;
48
- if (!isOpenTuiAppCommand(input.argv, env))
49
- return false;
50
- return Boolean(input.stdoutIsTty && input.stdinIsTty);
51
- }
52
- export {
53
- shouldLaunchTtyApp,
54
- isOpenTuiAppCommand
55
- };
@@ -1,22 +0,0 @@
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
- /** Raw terminal is below the usable threshold; render a guidance message
12
- * instead of a scene that would clip into nothing (#18). */
13
- readonly tooSmall: boolean;
14
- };
15
- /** Below these raw dimensions, ad-terminal panels collapse below their 4×4
16
- * floor and the UI would blank silently. We show a "resize me" card instead. */
17
- export declare const MIN_TERMINAL_WIDTH = 48;
18
- export declare const MIN_TERMINAL_HEIGHT = 16;
19
- export declare function computeStageLayout(width: number, height: number): StageLayout;
20
- export declare function visibleWidth(text: string): number;
21
- export declare function alignText(text: string, width: number, align?: "left" | "center" | "right"): string;
22
- export declare function truncateText(text: string, width: number): string;
@@ -1,51 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/layout.ts
3
- var MIN_TERMINAL_WIDTH = 48;
4
- var MIN_TERMINAL_HEIGHT = 16;
5
- function computeStageLayout(width, height) {
6
- const rawWidth = Math.trunc(width || 80);
7
- const rawHeight = Math.trunc(height || 24);
8
- const tooSmall = rawWidth < MIN_TERMINAL_WIDTH || rawHeight < MIN_TERMINAL_HEIGHT;
9
- const safeWidth = Math.max(40, rawWidth);
10
- const safeHeight = Math.max(18, rawHeight);
11
- const compact = safeWidth < 92 || safeHeight < 30;
12
- const horizontalGutter = compact ? 1 : 2;
13
- const centerWidth = Math.max(36, safeWidth - horizontalGutter * 2);
14
- const centerLeft = horizontalGutter;
15
- const footerTop = Math.max(0, safeHeight - 1);
16
- const typeBarTop = Math.max(0, footerTop - 1);
17
- const centerTop = compact ? 1 : Math.max(1, Math.floor(safeHeight * 0.055));
18
- const centerHeight = Math.max(6, typeBarTop - centerTop);
19
- return { width: safeWidth, height: safeHeight, centerWidth, centerLeft, centerTop, centerHeight, typeBarTop, footerTop, compact, tooSmall };
20
- }
21
- function visibleWidth(text) {
22
- return [...text].length;
23
- }
24
- function alignText(text, width, align = "left") {
25
- const length = visibleWidth(text);
26
- if (length >= width)
27
- return text;
28
- const pad = width - length;
29
- if (align === "right")
30
- return `${" ".repeat(pad)}${text}`;
31
- if (align === "center") {
32
- const left = Math.floor(pad / 2);
33
- return `${" ".repeat(left)}${text}${" ".repeat(pad - left)}`;
34
- }
35
- return text;
36
- }
37
- function truncateText(text, width) {
38
- if (visibleWidth(text) <= width)
39
- return text;
40
- if (width <= 1)
41
- return "\u2026";
42
- return `${[...text].slice(0, Math.max(0, width - 1)).join("")}\u2026`;
43
- }
44
- export {
45
- visibleWidth,
46
- truncateText,
47
- computeStageLayout,
48
- alignText,
49
- MIN_TERMINAL_WIDTH,
50
- MIN_TERMINAL_HEIGHT
51
- };
@@ -1,36 +0,0 @@
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
- /** Table filtering from keyboard navigation has been removed: typing in the
6
- * command bar no longer live-filters the runs/tasks tables. This always returns
7
- * "" so the fleet/tasks scenes render the full (sorted) row set. The `_state`
8
- * arg is retained so callers stay source-compatible. */
9
- export declare function listSearchQuery(_state: AppState): string;
10
- export declare function filterRunsForSearch(runs: readonly AppRunRecord[], query: string): AppRunRecord[];
11
- export declare function filterTasksForSearch(tasks: readonly AppTaskRecord[], query: string): AppTaskRecord[];
12
- export declare function searchSummary(kind: "runs" | "tasks", query: string, visible: number, total: number): string;
13
- export type SortDir = "asc" | "desc";
14
- export type RunSortKey = "status" | "runId" | "title" | "age";
15
- export type RunSortSpec = {
16
- readonly key: RunSortKey;
17
- readonly dir: SortDir;
18
- };
19
- export type TaskSortKey = "status" | "id" | "priority" | "assignee" | "title";
20
- export type TaskSortSpec = {
21
- readonly key: TaskSortKey;
22
- readonly dir: SortDir;
23
- };
24
- /** Read a typed run sort spec off the data bag, narrowing the `unknown` slice. */
25
- export declare function runSortSpec(value: unknown): RunSortSpec | null;
26
- /** Read a typed task sort spec off the data bag, narrowing the `unknown` slice. */
27
- export declare function taskSortSpec(value: unknown): TaskSortSpec | null;
28
- /** Cycle a column's sort: clicking the active column flips asc→desc→default;
29
- * clicking a new column starts it ascending. `null` means "back to default". */
30
- export declare function cycleRunSort(current: RunSortSpec | null, key: RunSortKey): RunSortSpec | null;
31
- export declare function cycleTaskSort(current: TaskSortSpec | null, key: TaskSortKey): TaskSortSpec | null;
32
- /** Sort runs by a column. `spec === null` returns the input order unchanged. */
33
- export declare function sortRuns(runs: readonly AppRunRecord[], spec: RunSortSpec | null): AppRunRecord[];
34
- /** Sort tasks by a column, client-side over already-fetched records. `spec ===
35
- * null` returns the input order unchanged (server/adapter order is preserved). */
36
- export declare function sortTasks(tasks: readonly AppTaskRecord[], spec: TaskSortSpec | null): AppTaskRecord[];
@@ -1,130 +0,0 @@
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 "";
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
- function runSortSpec(value) {
38
- if (!value || typeof value !== "object" || Array.isArray(value))
39
- return null;
40
- const record = value;
41
- const key = record.key;
42
- const dir = record.dir;
43
- if ((key === "status" || key === "runId" || key === "title" || key === "age") && (dir === "asc" || dir === "desc")) {
44
- return { key, dir };
45
- }
46
- return null;
47
- }
48
- function taskSortSpec(value) {
49
- if (!value || typeof value !== "object" || Array.isArray(value))
50
- return null;
51
- const record = value;
52
- const key = record.key;
53
- const dir = record.dir;
54
- if ((key === "status" || key === "id" || key === "priority" || key === "assignee" || key === "title") && (dir === "asc" || dir === "desc")) {
55
- return { key, dir };
56
- }
57
- return null;
58
- }
59
- function cycleRunSort(current, key) {
60
- if (!current || current.key !== key)
61
- return { key, dir: "asc" };
62
- if (current.dir === "asc")
63
- return { key, dir: "desc" };
64
- return null;
65
- }
66
- function cycleTaskSort(current, key) {
67
- if (!current || current.key !== key)
68
- return { key, dir: "asc" };
69
- if (current.dir === "asc")
70
- return { key, dir: "desc" };
71
- return null;
72
- }
73
- function ageValue(updatedAt) {
74
- const parsed = Date.parse(updatedAt ?? "");
75
- return Number.isFinite(parsed) ? parsed : 0;
76
- }
77
- function applyDir(rows, compare, dir) {
78
- const sorted = [...rows].sort(compare);
79
- return dir === "desc" ? sorted.reverse() : sorted;
80
- }
81
- function sortRuns(runs, spec) {
82
- if (!spec)
83
- return [...runs];
84
- const { key, dir } = spec;
85
- if (key === "age") {
86
- const byNewest = applyDir(runs, (a, b) => ageValue(b.updatedAt) - ageValue(a.updatedAt) || a.runId.localeCompare(b.runId), "asc");
87
- return dir === "asc" ? byNewest : [...byNewest].reverse();
88
- }
89
- const compare = (a, b) => {
90
- if (key === "status")
91
- return a.status.localeCompare(b.status) || a.runId.localeCompare(b.runId);
92
- if (key === "title")
93
- return a.title.localeCompare(b.title, undefined, { sensitivity: "base" }) || a.runId.localeCompare(b.runId);
94
- return a.runId.localeCompare(b.runId, undefined, { numeric: true });
95
- };
96
- return applyDir(runs, compare, dir);
97
- }
98
- function sortTasks(tasks, spec) {
99
- if (!spec)
100
- return [...tasks];
101
- const { key, dir } = spec;
102
- const compare = (a, b) => {
103
- if (key === "status")
104
- return a.status.localeCompare(b.status) || a.id.localeCompare(b.id, undefined, { numeric: true });
105
- if (key === "priority") {
106
- const left = a.priority ?? Number.NEGATIVE_INFINITY;
107
- const right = b.priority ?? Number.NEGATIVE_INFINITY;
108
- return right - left || a.id.localeCompare(b.id, undefined, { numeric: true });
109
- }
110
- if (key === "assignee")
111
- return (a.assignees[0] ?? "").localeCompare(b.assignees[0] ?? "") || a.id.localeCompare(b.id, undefined, { numeric: true });
112
- if (key === "title")
113
- return a.title.localeCompare(b.title, undefined, { sensitivity: "base" }) || a.id.localeCompare(b.id, undefined, { numeric: true });
114
- return a.id.localeCompare(b.id, undefined, { numeric: true });
115
- };
116
- return applyDir(tasks, compare, dir);
117
- }
118
- export {
119
- taskSortSpec,
120
- sortTasks,
121
- sortRuns,
122
- searchSummary,
123
- runSortSpec,
124
- listSearchQuery,
125
- isListSearchScene,
126
- filterTasksForSearch,
127
- filterRunsForSearch,
128
- cycleTaskSort,
129
- cycleRunSort
130
- };
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- export declare function runOpenTuiPiHostChild(argv?: readonly string[]): Promise<void>;