@h-rig/cli 0.0.6-alpha.77 → 0.0.6-alpha.79

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 (91) hide show
  1. package/dist/bin/build-rig-binaries.d.ts +2 -0
  2. package/dist/bin/rig.d.ts +2 -0
  3. package/dist/bin/rig.js +10214 -9309
  4. package/dist/src/app/board.d.ts +23 -0
  5. package/dist/src/app/board.js +1786 -0
  6. package/dist/src/app/drone-ui.d.ts +37 -0
  7. package/dist/src/app/drone-ui.js +294 -0
  8. package/dist/src/app/theme.d.ts +47 -0
  9. package/dist/src/{commands/_tui-theme.js → app/theme.js} +16 -1
  10. package/dist/src/commands/_async-ui.d.ts +13 -0
  11. package/dist/src/commands/_async-ui.js +74 -3
  12. package/dist/src/commands/_authority-runs.d.ts +22 -0
  13. package/dist/src/commands/_cli-format.d.ts +49 -0
  14. package/dist/src/commands/_cli-format.js +26 -8
  15. package/dist/src/commands/_connection-state.d.ts +44 -0
  16. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  17. package/dist/src/commands/_doctor-checks.js +3 -1
  18. package/dist/src/commands/_help-catalog.d.ts +51 -0
  19. package/dist/src/commands/_help-catalog.js +9 -70
  20. package/dist/src/commands/_json-output.d.ts +11 -0
  21. package/dist/src/commands/_operator-surface.d.ts +34 -0
  22. package/dist/src/commands/_operator-view.d.ts +30 -0
  23. package/dist/src/commands/_operator-view.js +184 -7
  24. package/dist/src/commands/_parsers.d.ts +15 -0
  25. package/dist/src/commands/_paths.d.ts +11 -0
  26. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  27. package/dist/src/commands/_pi-frontend.js +184 -7
  28. package/dist/src/commands/_pi-install.d.ts +42 -0
  29. package/dist/src/commands/_pi-install.js +1 -1
  30. package/dist/src/commands/_policy.d.ts +8 -0
  31. package/dist/src/commands/_preflight.d.ts +22 -0
  32. package/dist/src/commands/_preflight.js +3 -1
  33. package/dist/src/commands/_probes.d.ts +1 -0
  34. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  35. package/dist/src/commands/_run-replay.d.ts +24 -0
  36. package/dist/src/commands/_server-client.d.ts +186 -0
  37. package/dist/src/commands/_server-client.js +3 -1
  38. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  39. package/dist/src/commands/_snapshot-upload.js +3 -1
  40. package/dist/src/commands/_spinner.d.ts +25 -0
  41. package/dist/src/commands/_task-picker.d.ts +9 -0
  42. package/dist/src/commands/_task-picker.js +132 -7
  43. package/dist/src/commands/agent.d.ts +3 -0
  44. package/dist/src/commands/browser.d.ts +65 -0
  45. package/dist/src/commands/browser.js +306 -30
  46. package/dist/src/commands/connect.d.ts +7 -0
  47. package/dist/src/commands/connect.js +130 -64
  48. package/dist/src/commands/dist.d.ts +28 -0
  49. package/dist/src/commands/doctor.d.ts +3 -0
  50. package/dist/src/commands/doctor.js +77 -4
  51. package/dist/src/commands/github.d.ts +3 -0
  52. package/dist/src/commands/github.js +77 -4
  53. package/dist/src/commands/inbox.d.ts +30 -0
  54. package/dist/src/commands/inbox.js +101 -78
  55. package/dist/src/commands/init.d.ts +74 -0
  56. package/dist/src/commands/init.js +350 -10
  57. package/dist/src/commands/inspect.d.ts +3 -0
  58. package/dist/src/commands/inspect.js +77 -4
  59. package/dist/src/commands/inspector.d.ts +3 -0
  60. package/dist/src/commands/pi.d.ts +3 -0
  61. package/dist/src/commands/plugin.d.ts +16 -0
  62. package/dist/src/commands/profile-and-review.d.ts +4 -0
  63. package/dist/src/commands/queue.d.ts +3 -0
  64. package/dist/src/commands/remote.d.ts +3 -0
  65. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  66. package/dist/src/commands/run.d.ts +3 -0
  67. package/dist/src/commands/run.js +195 -69
  68. package/dist/src/commands/server.d.ts +7 -0
  69. package/dist/src/commands/server.js +133 -65
  70. package/dist/src/commands/setup.d.ts +16 -0
  71. package/dist/src/commands/setup.js +77 -4
  72. package/dist/src/commands/stats.d.ts +12 -0
  73. package/dist/src/commands/stats.js +57 -113
  74. package/dist/src/commands/task-report-bug.d.ts +19 -0
  75. package/dist/src/commands/task-report-bug.js +231 -40
  76. package/dist/src/commands/task-run-driver.d.ts +132 -0
  77. package/dist/src/commands/task-run-driver.js +26 -3
  78. package/dist/src/commands/task.d.ts +14 -0
  79. package/dist/src/commands/task.js +341 -229
  80. package/dist/src/commands/test.d.ts +3 -0
  81. package/dist/src/commands/workspace.d.ts +3 -0
  82. package/dist/src/commands.d.ts +29 -0
  83. package/dist/src/commands.js +10194 -9289
  84. package/dist/src/index.d.ts +4 -0
  85. package/dist/src/index.js +10200 -9295
  86. package/dist/src/launcher.d.ts +61 -0
  87. package/dist/src/report-bug.d.ts +44 -0
  88. package/dist/src/runner.d.ts +47 -0
  89. package/dist/src/withMutedConsole.d.ts +2 -0
  90. package/package.json +10 -9
  91. package/dist/src/commands/_operator-board.js +0 -730
@@ -0,0 +1,39 @@
1
+ export declare const UPLOADED_SNAPSHOT_PR_MARKER = "<!-- rig:uploaded-snapshot -->";
2
+ export declare const SNAPSHOT_ARCHIVE_VERSION = 1;
3
+ export declare const SNAPSHOT_ARCHIVE_CONTENT_TYPE = "application/vnd.rig.snapshot+json";
4
+ export type SnapshotUploadManifest = {
5
+ readonly root: string;
6
+ readonly files: readonly string[];
7
+ readonly excludedDirectories: readonly string[];
8
+ };
9
+ export type SnapshotUploadArchiveFile = {
10
+ readonly path: string;
11
+ readonly contentBase64: string;
12
+ };
13
+ export type SnapshotUploadArchive = {
14
+ readonly version: typeof SNAPSHOT_ARCHIVE_VERSION;
15
+ readonly root: string;
16
+ readonly files: readonly SnapshotUploadArchiveFile[];
17
+ readonly excludedDirectories: readonly string[];
18
+ readonly createdAt: string;
19
+ };
20
+ export declare function buildSnapshotUploadManifest(projectRoot: string, options?: {
21
+ readonly excludedDirectories?: readonly string[];
22
+ }): Promise<SnapshotUploadManifest>;
23
+ export declare function createSnapshotUploadArchive(projectRoot: string, options?: {
24
+ readonly excludedDirectories?: readonly string[];
25
+ readonly now?: () => Date;
26
+ }): Promise<SnapshotUploadArchive>;
27
+ export declare function encodeSnapshotUploadArchive(archive: SnapshotUploadArchive): string;
28
+ export declare function writeSnapshotUploadArchive(projectRoot: string, outputPath: string, options?: {
29
+ readonly excludedDirectories?: readonly string[];
30
+ readonly now?: () => Date;
31
+ }): Promise<SnapshotUploadArchive>;
32
+ export declare function uploadSnapshotArchiveViaServer(context: {
33
+ readonly projectRoot: string;
34
+ }, input: {
35
+ readonly repoSlug: string;
36
+ readonly archive: SnapshotUploadArchive;
37
+ readonly baseDir?: string;
38
+ }): Promise<Record<string, unknown>>;
39
+ export declare function appendUploadedSnapshotPrNotice(body: string): string;
@@ -310,7 +310,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
310
310
  })() : null;
311
311
  if (!response.ok) {
312
312
  const diagnostics = diagnosticMessage(payload);
313
- const detail = diagnostics ?? (text || response.statusText);
313
+ const rawDetail = diagnostics ?? (text || response.statusText);
314
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
315
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
314
316
  const failure = await buildServerFailureContext(context.projectRoot, server);
315
317
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
316
318
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -0,0 +1,25 @@
1
+ export declare const SPINNER_FRAMES: readonly ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
2
+ export type TtySpinner = {
3
+ setLabel(label: string): void;
4
+ /** Erase the spinner line so other output can print cleanly. */
5
+ pause(): void;
6
+ /** Resume rendering after pause(). */
7
+ resume(): void;
8
+ /** Stop for good; optionally leave a final line. */
9
+ stop(finalLine?: string): void;
10
+ };
11
+ /**
12
+ * A line-rewriting spinner for async CLI waits. On non-TTY outputs it prints
13
+ * the label once (and label changes) so logs stay readable without ANSI.
14
+ */
15
+ export declare function createTtySpinner(input: {
16
+ label: string;
17
+ output?: Pick<NodeJS.WriteStream, "write"> & {
18
+ readonly isTTY?: boolean;
19
+ };
20
+ intervalMs?: number;
21
+ /** Frame glyph cycle; defaults to SPINNER_FRAMES. */
22
+ frames?: readonly string[];
23
+ /** Optional glyph decorator (e.g. color), applied on TTY renders only. */
24
+ styleFrame?: (frame: string) => string;
25
+ }): TtySpinner;
@@ -0,0 +1,9 @@
1
+ import type { WorkspaceTaskRecord } from "./_server-client";
2
+ import { renderTaskPickerRows, type TaskPickerRenderer } from "./_operator-surface";
3
+ export { renderTaskPickerRows, type TaskPickerRenderer };
4
+ export type TaskPickerIO = {
5
+ readonly isTty?: boolean;
6
+ readonly prompt?: (question: string) => Promise<string>;
7
+ readonly renderer?: TaskPickerRenderer;
8
+ };
9
+ export declare function selectTaskWithTextPicker(tasks: readonly WorkspaceTaskRecord[], io?: TaskPickerIO): Promise<WorkspaceTaskRecord | null>;
@@ -1,6 +1,131 @@
1
1
  // @bun
2
- // packages/cli/src/commands/_task-picker.ts
3
- import { cancel, isCancel, select } from "@clack/prompts";
2
+ // packages/cli/src/app/drone-ui.ts
3
+ import { ProcessTerminal, TUI, Text, Input, SelectList, matchesKey } from "@earendil-works/pi-tui";
4
+
5
+ // packages/cli/src/app/theme.ts
6
+ var RIG_PALETTE = {
7
+ ink: "#f2f3f6",
8
+ ink2: "#aeb0ba",
9
+ ink3: "#6c6e79",
10
+ ink4: "#44464f",
11
+ accent: "#ccff4d",
12
+ accentDim: "#a9d63f",
13
+ cyan: "#56d8ff",
14
+ red: "#ff5d5d",
15
+ yellow: "#ffd24d"
16
+ };
17
+ function hexToRgb(hex) {
18
+ const value = hex.replace("#", "");
19
+ return [
20
+ Number.parseInt(value.slice(0, 2), 16),
21
+ Number.parseInt(value.slice(2, 4), 16),
22
+ Number.parseInt(value.slice(4, 6), 16)
23
+ ];
24
+ }
25
+ function fg(hex) {
26
+ const [r, g, b] = hexToRgb(hex);
27
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
28
+ }
29
+ var ink = fg(RIG_PALETTE.ink);
30
+ var ink2 = fg(RIG_PALETTE.ink2);
31
+ var ink3 = fg(RIG_PALETTE.ink3);
32
+ var ink4 = fg(RIG_PALETTE.ink4);
33
+ var accent = fg(RIG_PALETTE.accent);
34
+ var accentDim = fg(RIG_PALETTE.accentDim);
35
+ var cyan = fg(RIG_PALETTE.cyan);
36
+ var red = fg(RIG_PALETTE.red);
37
+ var yellow = fg(RIG_PALETTE.yellow);
38
+ function bold(text) {
39
+ return `\x1B[1m${text}\x1B[22m`;
40
+ }
41
+ var DRONE_ART = [
42
+ " .-=-. .-=-. ",
43
+ " ( !!! ) ( !!! ) ",
44
+ " '-=-'._ _.'-=-' ",
45
+ " '._ _.' ",
46
+ " '=$$$$$$$=.' ",
47
+ " =$$$$$$$$$$$= ",
48
+ " $$$@@@@@@@@@@$$$ ",
49
+ " $$$@@ @@$$$ ",
50
+ " $$@ ? @$$$ ",
51
+ " $$$@ '-' @$$$ ",
52
+ " $$$@@ @@$$$ ",
53
+ " $$$@@@@@@@@@@$$$ ",
54
+ " =$$$$$$$$$$$= ",
55
+ " '=$$$$$$$=.' ",
56
+ " _.' '._ ",
57
+ " .-=-.' '.-=-. ",
58
+ " ( !!! ) ( !!! ) ",
59
+ " '-=-' '-=-' "
60
+ ];
61
+ var EYE_FRAMES = ["@", "o", "."];
62
+ var DRONE_WIDTH = DRONE_ART[0].length;
63
+ var DRONE_HEIGHT = DRONE_ART.length;
64
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
65
+ function microDroneFrame(tick) {
66
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
67
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
68
+ return `(${blade})${eye}(${blade})`;
69
+ }
70
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
71
+
72
+ // packages/cli/src/app/drone-ui.ts
73
+ var isTty = () => Boolean(process.stdout.isTTY);
74
+ function droneCancel(text) {
75
+ console.log(` ${red("\u2716")} ${ink3(text)}`);
76
+ }
77
+ var SELECT_THEME = {
78
+ selectedPrefix: (text) => accent(text),
79
+ selectedText: (text) => bold(ink(text)),
80
+ description: (text) => ink3(text),
81
+ scrollInfo: (text) => ink4(text),
82
+ noMatch: (text) => ink3(text)
83
+ };
84
+ async function runMiniTui(build) {
85
+ const terminal = new ProcessTerminal;
86
+ const tui = new TUI(terminal);
87
+ let settled = false;
88
+ return await new Promise((resolve) => {
89
+ const finish = (result) => {
90
+ if (settled)
91
+ return;
92
+ settled = true;
93
+ tui.stop();
94
+ resolve(result);
95
+ };
96
+ build(tui, finish);
97
+ tui.start();
98
+ });
99
+ }
100
+ async function droneSelect(input) {
101
+ if (!isTty() || input.options.length === 0) {
102
+ return input.initialValue ?? input.options[0]?.value ?? null;
103
+ }
104
+ return runMiniTui((tui, finish) => {
105
+ tui.addChild(new Text(` ${accent("\u258D")}${bold(ink(input.message))}`));
106
+ const items = input.options.map((option) => ({
107
+ value: option.value,
108
+ label: option.label,
109
+ ...option.hint ? { description: option.hint } : {}
110
+ }));
111
+ const list = new SelectList(items, Math.min(items.length, 12), SELECT_THEME);
112
+ const initialIndex = input.initialValue ? items.findIndex((item) => item.value === input.initialValue) : -1;
113
+ if (initialIndex > 0)
114
+ list.setSelectedIndex(initialIndex);
115
+ list.onSelect = (item) => finish(item.value);
116
+ list.onCancel = () => finish(null);
117
+ tui.addChild(list);
118
+ tui.addChild(new Text(ink4(" \u2191\u2193 navigate \xB7 enter select \xB7 esc cancel")));
119
+ tui.setFocus(list);
120
+ tui.addInputListener((data) => {
121
+ if (matchesKey(data, "ctrl+c") || matchesKey(data, "escape")) {
122
+ finish(null);
123
+ return { consume: true };
124
+ }
125
+ return;
126
+ });
127
+ });
128
+ }
4
129
 
5
130
  // packages/cli/src/commands/_operator-surface.ts
6
131
  import { createInterface as createPromptInterface } from "readline/promises";
@@ -34,8 +159,8 @@ async function selectTaskWithTextPicker(tasks, io = {}) {
34
159
  return null;
35
160
  if (tasks.length === 1)
36
161
  return tasks[0];
37
- const isTty = io.isTty ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
38
- if (!isTty) {
162
+ const isTty2 = io.isTty ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
163
+ if (!isTty2) {
39
164
  throw new Error("task run requires an interactive terminal to pick a task; pass --task <id>, --next, or --detach with a task id.");
40
165
  }
41
166
  if (io.prompt || io.renderer) {
@@ -59,12 +184,12 @@ async function selectTaskWithTextPicker(tasks, io = {}) {
59
184
  label: `${taskId2(task)} \xB7 ${typeof task.title === "string" && task.title.trim() ? task.title.trim() : "Untitled task"}`,
60
185
  hint: typeof task.status === "string" && task.status.trim() ? task.status.trim() : undefined
61
186
  }));
62
- const answer = await select({
187
+ const answer = await droneSelect({
63
188
  message: "Select Rig task",
64
189
  options
65
190
  });
66
- if (isCancel(answer)) {
67
- cancel("No task selected.");
191
+ if (answer === null) {
192
+ droneCancel("No task selected.");
68
193
  return null;
69
194
  }
70
195
  const index = Number.parseInt(String(answer), 10);
@@ -0,0 +1,3 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
3
+ export declare function executeAgent(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
@@ -0,0 +1,65 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
3
+ export type BrowserHelpOptions = {
4
+ color?: boolean;
5
+ };
6
+ export declare function browserHelpText(options?: BrowserHelpOptions): string;
7
+ type BrowserDemoRuntimeOptions = {
8
+ port?: number;
9
+ profile?: string;
10
+ stateDir?: string;
11
+ targetUrl?: string;
12
+ };
13
+ type BrowserDemoRuntime = {
14
+ attachUrl: string;
15
+ browserDir: string;
16
+ env: Record<string, string>;
17
+ helperCommands: string[];
18
+ port: number;
19
+ profile: string;
20
+ stateDir: string;
21
+ targetUrl: string;
22
+ };
23
+ type BrowserDemoAgentCommand = {
24
+ accepted: string[];
25
+ primary: string;
26
+ };
27
+ type BrowserDemoAgentCommands = {
28
+ attach: BrowserDemoAgentCommand;
29
+ attachInfo: BrowserDemoAgentCommand;
30
+ check: BrowserDemoAgentCommand;
31
+ launch: BrowserDemoAgentCommand;
32
+ };
33
+ export declare function buildBrowserDemoRuntime(projectRoot: string, options?: BrowserDemoRuntimeOptions): BrowserDemoRuntime;
34
+ export declare function buildBrowserDemoAgentCommands(runtime: Pick<BrowserDemoRuntime, "attachUrl">): BrowserDemoAgentCommands;
35
+ export declare function normalizeBrowserDemoCommand(value: string): string;
36
+ export declare function browserDemoCommandMatches(value: string, command: BrowserDemoAgentCommand): boolean;
37
+ export declare function browserDemoCommandCompletions(line: string, command: BrowserDemoAgentCommand): [string[], string];
38
+ export declare function formatBrowserDemoCommandOutput(command: string, output: string): string;
39
+ export declare function executeBrowser(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
40
+ export declare function executeBrowserDemo(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
41
+ type BrowserDemoVersionInfo = {
42
+ Browser?: string;
43
+ webSocketDebuggerUrl?: string;
44
+ };
45
+ type BrowserDemoTarget = {
46
+ id?: string;
47
+ title?: string;
48
+ type?: string;
49
+ url?: string;
50
+ webSocketDebuggerUrl?: string;
51
+ };
52
+ type BrowserDemoCdpResult = {
53
+ afterDomState: unknown;
54
+ beforeDomState: unknown;
55
+ consoleEvents: unknown[];
56
+ layoutMetrics: unknown;
57
+ mutationEvaluation: unknown;
58
+ title: string | undefined;
59
+ };
60
+ export declare function formatBrowserDemoCheckOutput(runtime: BrowserDemoRuntime, version: BrowserDemoVersionInfo, pageTarget: BrowserDemoTarget, targets: BrowserDemoTarget[]): string;
61
+ export declare function formatBrowserDemoCdpResult(result: BrowserDemoCdpResult): string;
62
+ export declare function findBrowserDemoPageTarget(runtime: Pick<BrowserDemoRuntime, "targetUrl">, targets: BrowserDemoTarget[]): (BrowserDemoTarget & {
63
+ webSocketDebuggerUrl: string;
64
+ }) | null;
65
+ export {};