@h-rig/cli 0.0.6-alpha.9 → 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 (114) 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 +11052 -6668
  5. package/dist/src/app/board.d.ts +23 -0
  6. package/dist/src/app/board.js +1786 -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 +150 -0
  11. package/dist/src/commands/_async-ui.d.ts +13 -0
  12. package/dist/src/commands/_async-ui.js +223 -0
  13. package/dist/src/commands/_authority-runs.d.ts +22 -0
  14. package/dist/src/commands/_authority-runs.js +2 -3
  15. package/dist/src/commands/_cli-format.d.ts +49 -0
  16. package/dist/src/commands/_cli-format.js +447 -0
  17. package/dist/src/commands/_connection-state.d.ts +44 -0
  18. package/dist/src/commands/_connection-state.js +30 -11
  19. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  20. package/dist/src/commands/_doctor-checks.js +180 -44
  21. package/dist/src/commands/_help-catalog.d.ts +51 -0
  22. package/dist/src/commands/_help-catalog.js +442 -0
  23. package/dist/src/commands/_json-output.d.ts +11 -0
  24. package/dist/src/commands/_json-output.js +56 -0
  25. package/dist/src/commands/_operator-surface.d.ts +34 -0
  26. package/dist/src/commands/_operator-surface.js +220 -0
  27. package/dist/src/commands/_operator-view.d.ts +30 -0
  28. package/dist/src/commands/_operator-view.js +803 -73
  29. package/dist/src/commands/_parsers.d.ts +15 -0
  30. package/dist/src/commands/_parsers.js +18 -11
  31. package/dist/src/commands/_paths.d.ts +11 -0
  32. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  33. package/dist/src/commands/_pi-frontend.js +742 -0
  34. package/dist/src/commands/_pi-install.d.ts +42 -0
  35. package/dist/src/commands/_pi-install.js +5 -4
  36. package/dist/src/commands/_policy.d.ts +8 -0
  37. package/dist/src/commands/_policy.js +12 -5
  38. package/dist/src/commands/_preflight.d.ts +22 -0
  39. package/dist/src/commands/_preflight.js +190 -128
  40. package/dist/src/commands/_probes.d.ts +1 -0
  41. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  42. package/dist/src/commands/_run-driver-helpers.js +75 -22
  43. package/dist/src/commands/_run-replay.d.ts +24 -0
  44. package/dist/src/commands/_run-replay.js +142 -0
  45. package/dist/src/commands/_server-client.d.ts +186 -0
  46. package/dist/src/commands/_server-client.js +360 -61
  47. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  48. package/dist/src/commands/_snapshot-upload.js +163 -39
  49. package/dist/src/commands/_spinner.d.ts +25 -0
  50. package/dist/src/commands/_spinner.js +65 -0
  51. package/dist/src/commands/_task-picker.d.ts +9 -0
  52. package/dist/src/commands/_task-picker.js +172 -19
  53. package/dist/src/commands/agent.d.ts +3 -0
  54. package/dist/src/commands/agent.js +39 -20
  55. package/dist/src/commands/browser.d.ts +65 -0
  56. package/dist/src/commands/browser.js +334 -51
  57. package/dist/src/commands/connect.d.ts +7 -0
  58. package/dist/src/commands/connect.js +272 -33
  59. package/dist/src/commands/dist.d.ts +28 -0
  60. package/dist/src/commands/dist.js +19 -12
  61. package/dist/src/commands/doctor.d.ts +3 -0
  62. package/dist/src/commands/doctor.js +378 -45
  63. package/dist/src/commands/github.d.ts +3 -0
  64. package/dist/src/commands/github.js +375 -53
  65. package/dist/src/commands/inbox.d.ts +30 -0
  66. package/dist/src/commands/inbox.js +760 -70
  67. package/dist/src/commands/init.d.ts +74 -0
  68. package/dist/src/commands/init.js +963 -119
  69. package/dist/src/commands/inspect.d.ts +3 -0
  70. package/dist/src/commands/inspect.js +588 -32
  71. package/dist/src/commands/inspector.d.ts +3 -0
  72. package/dist/src/commands/inspector.js +20 -13
  73. package/dist/src/commands/pi.d.ts +3 -0
  74. package/dist/src/commands/pi.js +177 -0
  75. package/dist/src/commands/plugin.d.ts +16 -0
  76. package/dist/src/commands/plugin.js +95 -27
  77. package/dist/src/commands/profile-and-review.d.ts +4 -0
  78. package/dist/src/commands/profile-and-review.js +26 -19
  79. package/dist/src/commands/queue.d.ts +3 -0
  80. package/dist/src/commands/queue.js +32 -12
  81. package/dist/src/commands/remote.d.ts +3 -0
  82. package/dist/src/commands/remote.js +43 -36
  83. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  84. package/dist/src/commands/repo-git-harness.js +22 -15
  85. package/dist/src/commands/run.d.ts +3 -0
  86. package/dist/src/commands/run.js +1379 -159
  87. package/dist/src/commands/server.d.ts +7 -0
  88. package/dist/src/commands/server.js +502 -57
  89. package/dist/src/commands/setup.d.ts +16 -0
  90. package/dist/src/commands/setup.js +390 -63
  91. package/dist/src/commands/stats.d.ts +12 -0
  92. package/dist/src/commands/stats.js +1051 -0
  93. package/dist/src/commands/task-report-bug.d.ts +19 -0
  94. package/dist/src/commands/task-report-bug.js +260 -62
  95. package/dist/src/commands/task-run-driver.d.ts +132 -0
  96. package/dist/src/commands/task-run-driver.js +886 -130
  97. package/dist/src/commands/task.d.ts +14 -0
  98. package/dist/src/commands/task.js +1644 -314
  99. package/dist/src/commands/test.d.ts +3 -0
  100. package/dist/src/commands/test.js +15 -8
  101. package/dist/src/commands/workspace.d.ts +3 -0
  102. package/dist/src/commands/workspace.js +18 -11
  103. package/dist/src/commands.d.ts +29 -0
  104. package/dist/src/commands.js +10967 -6637
  105. package/dist/src/index.d.ts +4 -0
  106. package/dist/src/index.js +10168 -5787
  107. package/dist/src/launcher.d.ts +61 -0
  108. package/dist/src/launcher.js +77 -13
  109. package/dist/src/report-bug.d.ts +44 -0
  110. package/dist/src/report-bug.js +3 -3
  111. package/dist/src/runner.d.ts +47 -0
  112. package/dist/src/runner.js +16 -22
  113. package/dist/src/withMutedConsole.d.ts +2 -0
  114. package/package.json +13 -6
@@ -0,0 +1,223 @@
1
+ // @bun
2
+ // packages/cli/src/commands/_async-ui.ts
3
+ import pc from "picocolors";
4
+
5
+ // packages/cli/src/commands/_spinner.ts
6
+ var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
7
+ function createTtySpinner(input) {
8
+ const output = input.output ?? process.stdout;
9
+ const isTty = output.isTTY === true;
10
+ const frames = input.frames && input.frames.length > 0 ? input.frames : SPINNER_FRAMES;
11
+ let label = input.label;
12
+ let frame = 0;
13
+ let paused = false;
14
+ let stopped = false;
15
+ let lastPrintedLabel = "";
16
+ const render = () => {
17
+ if (stopped || paused)
18
+ return;
19
+ if (!isTty) {
20
+ if (label !== lastPrintedLabel) {
21
+ output.write(`${label}
22
+ `);
23
+ lastPrintedLabel = label;
24
+ }
25
+ return;
26
+ }
27
+ frame = (frame + 1) % frames.length;
28
+ const glyph = frames[frame] ?? frames[0] ?? "";
29
+ output.write(`\r\x1B[2K${input.styleFrame ? input.styleFrame(glyph) : glyph} ${label}`);
30
+ };
31
+ const clearLine = () => {
32
+ if (isTty)
33
+ output.write("\r\x1B[2K");
34
+ };
35
+ render();
36
+ const timer = isTty ? setInterval(render, input.intervalMs ?? 120) : null;
37
+ return {
38
+ setLabel(next) {
39
+ label = next;
40
+ render();
41
+ },
42
+ pause() {
43
+ paused = true;
44
+ clearLine();
45
+ },
46
+ resume() {
47
+ if (stopped)
48
+ return;
49
+ paused = false;
50
+ render();
51
+ },
52
+ stop(finalLine) {
53
+ if (stopped)
54
+ return;
55
+ stopped = true;
56
+ if (timer)
57
+ clearInterval(timer);
58
+ clearLine();
59
+ if (finalLine)
60
+ output.write(`${finalLine}
61
+ `);
62
+ }
63
+ };
64
+ }
65
+
66
+ // packages/cli/src/runner.ts
67
+ import { EventBus } from "@rig/runtime/control-plane/runtime/events";
68
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
69
+ import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
70
+ import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
71
+
72
+ // packages/cli/src/commands/_server-client.ts
73
+ import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
74
+ var scopedGitHubBearerTokens = new Map;
75
+ var serverPhaseListener = null;
76
+ function setServerPhaseListener(listener) {
77
+ const previous = serverPhaseListener;
78
+ serverPhaseListener = listener;
79
+ return previous;
80
+ }
81
+ var serverReachabilityCache = new Map;
82
+ var RESUMABLE_RUN_STATUSES = new Set([
83
+ "created",
84
+ "preparing",
85
+ "running",
86
+ "validating",
87
+ "reviewing",
88
+ "stopped",
89
+ "failed",
90
+ "needs-attention",
91
+ "needs_attention"
92
+ ]);
93
+
94
+ // packages/cli/src/app/theme.ts
95
+ var RIG_PALETTE = {
96
+ ink: "#f2f3f6",
97
+ ink2: "#aeb0ba",
98
+ ink3: "#6c6e79",
99
+ ink4: "#44464f",
100
+ accent: "#ccff4d",
101
+ accentDim: "#a9d63f",
102
+ cyan: "#56d8ff",
103
+ red: "#ff5d5d",
104
+ yellow: "#ffd24d"
105
+ };
106
+ function hexToRgb(hex) {
107
+ const value = hex.replace("#", "");
108
+ return [
109
+ Number.parseInt(value.slice(0, 2), 16),
110
+ Number.parseInt(value.slice(2, 4), 16),
111
+ Number.parseInt(value.slice(4, 6), 16)
112
+ ];
113
+ }
114
+ function fg(hex) {
115
+ const [r, g, b] = hexToRgb(hex);
116
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
117
+ }
118
+ var ink = fg(RIG_PALETTE.ink);
119
+ var ink2 = fg(RIG_PALETTE.ink2);
120
+ var ink3 = fg(RIG_PALETTE.ink3);
121
+ var ink4 = fg(RIG_PALETTE.ink4);
122
+ var accent = fg(RIG_PALETTE.accent);
123
+ var accentDim = fg(RIG_PALETTE.accentDim);
124
+ var cyan = fg(RIG_PALETTE.cyan);
125
+ var red = fg(RIG_PALETTE.red);
126
+ var yellow = fg(RIG_PALETTE.yellow);
127
+ function bold(text) {
128
+ return `\x1B[1m${text}\x1B[22m`;
129
+ }
130
+ var DRONE_ART = [
131
+ " .-=-. .-=-. ",
132
+ " ( !!! ) ( !!! ) ",
133
+ " '-=-'._ _.'-=-' ",
134
+ " '._ _.' ",
135
+ " '=$$$$$$$=.' ",
136
+ " =$$$$$$$$$$$= ",
137
+ " $$$@@@@@@@@@@$$$ ",
138
+ " $$$@@ @@$$$ ",
139
+ " $$@ ? @$$$ ",
140
+ " $$$@ '-' @$$$ ",
141
+ " $$$@@ @@$$$ ",
142
+ " $$$@@@@@@@@@@$$$ ",
143
+ " =$$$$$$$$$$$= ",
144
+ " '=$$$$$$$=.' ",
145
+ " _.' '._ ",
146
+ " .-=-.' '.-=-. ",
147
+ " ( !!! ) ( !!! ) ",
148
+ " '-=-' '-=-' "
149
+ ];
150
+ var EYE_FRAMES = ["@", "o", "."];
151
+ var DRONE_WIDTH = DRONE_ART[0].length;
152
+ var DRONE_HEIGHT = DRONE_ART.length;
153
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
154
+ function microDroneFrame(tick) {
155
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
156
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
157
+ return `(${blade})${eye}(${blade})`;
158
+ }
159
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
160
+ function renderMicroDroneFrame(tick) {
161
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
162
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
163
+ return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
164
+ }
165
+
166
+ // packages/cli/src/commands/_async-ui.ts
167
+ var DONE_SYMBOL = pc.green("\u25C7");
168
+ var FAIL_SYMBOL = pc.red("\u25A0");
169
+ var activeUpdate = null;
170
+ async function withSpinner(label, work, options = {}) {
171
+ if (options.outputMode === "json") {
172
+ return work(() => {});
173
+ }
174
+ if (activeUpdate) {
175
+ const outer = activeUpdate;
176
+ outer(label);
177
+ return work(outer);
178
+ }
179
+ const output = options.output ?? process.stderr;
180
+ const isTty = output.isTTY === true;
181
+ let lastLabel = label;
182
+ if (!isTty) {
183
+ output.write(`${label}
184
+ `);
185
+ const update2 = (next) => {
186
+ lastLabel = next;
187
+ };
188
+ activeUpdate = update2;
189
+ const previousListener2 = setServerPhaseListener(update2);
190
+ try {
191
+ return await work(update2);
192
+ } finally {
193
+ activeUpdate = null;
194
+ setServerPhaseListener(previousListener2);
195
+ }
196
+ }
197
+ const spinner = createTtySpinner({
198
+ label,
199
+ output,
200
+ frames: MICRO_DRONE_FRAMES,
201
+ styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
202
+ });
203
+ const update = (next) => {
204
+ lastLabel = next;
205
+ spinner.setLabel(next);
206
+ };
207
+ activeUpdate = update;
208
+ const previousListener = setServerPhaseListener(update);
209
+ try {
210
+ const result = await work(update);
211
+ spinner.stop(options.doneLabel ? `${DONE_SYMBOL} ${options.doneLabel}` : undefined);
212
+ return result;
213
+ } catch (error) {
214
+ spinner.stop(`${FAIL_SYMBOL} ${lastLabel}`);
215
+ throw error;
216
+ } finally {
217
+ activeUpdate = null;
218
+ setServerPhaseListener(previousListener);
219
+ }
220
+ }
221
+ export {
222
+ withSpinner
223
+ };
@@ -0,0 +1,22 @@
1
+ import { type AuthorityRunRecord } from "@rig/runtime/control-plane/authority-files";
2
+ import type { RunStatus } from "@rig/contracts";
3
+ export declare const RIG_WORKSPACE_ID = "rig-local-workspace";
4
+ export type RuntimeAdapter = "claude-code" | "codex" | "pi";
5
+ export declare function normalizeRuntimeAdapter(value: string | undefined): RuntimeAdapter;
6
+ export declare function readLatestBeadRecord(projectRoot: string, taskId: string): Record<string, unknown> | null;
7
+ export declare function upsertAgentAuthorityRun(projectRoot: string, input: {
8
+ runId: string;
9
+ taskId: string;
10
+ createdAt: string;
11
+ runtimeAdapter?: string;
12
+ status: RunStatus;
13
+ startedAt?: string | null;
14
+ completedAt?: string | null;
15
+ worktreePath?: string | null;
16
+ artifactRoot?: string | null;
17
+ logRoot?: string | null;
18
+ sessionPath?: string | null;
19
+ sessionLogPath?: string | null;
20
+ pid?: number | null;
21
+ errorText?: string | null;
22
+ }): AuthorityRunRecord & Record<string, unknown>;
@@ -5,8 +5,7 @@ import { resolve } from "path";
5
5
  import {
6
6
  readAuthorityRun,
7
7
  readJsonlFile,
8
- resolveAuthorityRunDir,
9
- writeJsonFile
8
+ writeAuthorityRunRecord
10
9
  } from "@rig/runtime/control-plane/authority-files";
11
10
 
12
11
  // packages/cli/src/commands/_paths.ts
@@ -100,7 +99,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
100
99
  } else if ("errorText" in next) {
101
100
  delete next.errorText;
102
101
  }
103
- writeJsonFile(resolve(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
102
+ writeAuthorityRunRecord(projectRoot, input.runId, next);
104
103
  return next;
105
104
  }
106
105
  export {
@@ -0,0 +1,49 @@
1
+ export type CliTaskLike = Record<string, unknown>;
2
+ export type CliRunLike = Record<string, unknown>;
3
+ export declare function printFormattedOutput(message: string, options?: {
4
+ title?: string;
5
+ }): void;
6
+ export declare function formatStatusPill(status: string): string;
7
+ export declare function formatSection(title: string, subtitle?: string): string;
8
+ export declare function formatSuccessCard(title: string, rows?: Array<[string, string | number | null | undefined]>): string;
9
+ export declare function formatNextSteps(steps: readonly string[]): string[];
10
+ export declare function formatTaskList(tasks: readonly CliTaskLike[], options?: {
11
+ raw?: boolean;
12
+ }): string;
13
+ export declare function formatTaskCard(task: CliTaskLike, options?: {
14
+ title?: string;
15
+ selected?: boolean;
16
+ }): string;
17
+ export declare function formatTaskDetails(task: CliTaskLike): string;
18
+ export declare function formatRunList(runs: readonly CliRunLike[], options?: {
19
+ source?: "local" | "server";
20
+ }): string;
21
+ export declare function formatSubmittedRun(input: {
22
+ runId: string;
23
+ task?: CliTaskLike | null;
24
+ runtimeAdapter?: string | null;
25
+ runtimeMode?: string | null;
26
+ interactionMode?: string | null;
27
+ detached?: boolean;
28
+ }): string;
29
+ export declare function formatRunCard(run: CliRunLike, options?: {
30
+ title?: string;
31
+ }): string;
32
+ export declare function formatRunStatus(summary: {
33
+ activeRuns?: CliRunLike[];
34
+ recentRuns?: CliRunLike[];
35
+ runs?: CliRunLike[];
36
+ }, options?: {
37
+ source?: "local" | "server";
38
+ }): string;
39
+ export declare function formatInboxList(kind: "approvals" | "inputs", entries: readonly Record<string, unknown>[]): string;
40
+ export declare function formatConnectionList(connections: Record<string, {
41
+ kind: string;
42
+ baseUrl?: string;
43
+ mode?: string;
44
+ }>): string;
45
+ export declare function formatConnectionStatus(selected: string, connections: Record<string, {
46
+ kind: string;
47
+ baseUrl?: string;
48
+ mode?: string;
49
+ }>): string;