@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
@@ -4,12 +4,19 @@ import { resolve as resolve2 } from "path";
4
4
 
5
5
  // packages/cli/src/runner.ts
6
6
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
7
- import { CliError } from "@rig/runtime/control-plane/errors";
7
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
8
8
  import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
9
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
10
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
11
9
  import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
12
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
10
+
11
+ class CliError extends RuntimeCliError {
12
+ hint;
13
+ constructor(message, exitCode = 1, options = {}) {
14
+ super(message, exitCode);
15
+ if (options.hint?.trim()) {
16
+ this.hint = options.hint.trim();
17
+ }
18
+ }
19
+ }
13
20
  function takeFlag(args, flag) {
14
21
  const rest = [];
15
22
  let value = false;
@@ -30,7 +37,7 @@ function takeOption(args, option) {
30
37
  if (current === option) {
31
38
  const next = args[index + 1];
32
39
  if (!next || next.startsWith("-")) {
33
- throw new CliError(`Missing value for ${option}`);
40
+ throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
34
41
  }
35
42
  value = next;
36
43
  index += 1;
@@ -64,8 +71,7 @@ import { resolve } from "path";
64
71
  import {
65
72
  readAuthorityRun,
66
73
  readJsonlFile,
67
- resolveAuthorityRunDir,
68
- writeJsonFile
74
+ writeAuthorityRunRecord
69
75
  } from "@rig/runtime/control-plane/authority-files";
70
76
 
71
77
  // packages/cli/src/commands/_paths.ts
@@ -159,7 +165,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
159
165
  } else if ("errorText" in next) {
160
166
  delete next.errorText;
161
167
  }
162
- writeJsonFile(resolve(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
168
+ writeAuthorityRunRecord(projectRoot, input.runId, next);
163
169
  return next;
164
170
  }
165
171
 
@@ -213,7 +219,7 @@ function parseIsolationMode(value, allowOff) {
213
219
  if (allowOff && value === "off") {
214
220
  return value;
215
221
  }
216
- throw new CliError2(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
222
+ throw new CliError(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
217
223
  }
218
224
 
219
225
  // packages/cli/src/commands/_preflight.ts
@@ -221,6 +227,19 @@ import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/proj
221
227
 
222
228
  // packages/cli/src/commands/_server-client.ts
223
229
  import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
230
+ var scopedGitHubBearerTokens = new Map;
231
+ var serverReachabilityCache = new Map;
232
+ var RESUMABLE_RUN_STATUSES = new Set([
233
+ "created",
234
+ "preparing",
235
+ "running",
236
+ "validating",
237
+ "reviewing",
238
+ "stopped",
239
+ "failed",
240
+ "needs-attention",
241
+ "needs_attention"
242
+ ]);
224
243
 
225
244
  // packages/cli/src/commands/_preflight.ts
226
245
  async function runProjectMainSyncPreflight(context, options) {
@@ -236,7 +255,7 @@ async function runProjectMainSyncPreflight(context, options) {
236
255
  runBootstrap: async () => {
237
256
  const bootstrap = await context.runCommand(["bun", "run", "bootstrap"]);
238
257
  if (bootstrap.exitCode !== 0) {
239
- throw new CliError2(bootstrap.stderr || bootstrap.stdout || "bun run bootstrap failed during project pre-run sync", bootstrap.exitCode || 1);
258
+ throw new CliError(bootstrap.stderr || bootstrap.stdout || "bun run bootstrap failed during project pre-run sync", bootstrap.exitCode || 1);
240
259
  }
241
260
  }
242
261
  });
@@ -289,7 +308,7 @@ async function executeAgent(context, args) {
289
308
  const [command = "list", ...rest] = args;
290
309
  switch (command) {
291
310
  case "list": {
292
- requireNoExtraArgs(rest, "bun run rig agent list");
311
+ requireNoExtraArgs(rest, "rig agent list");
293
312
  const runtimes = await listAgentRuntimes(context.projectRoot);
294
313
  if (context.outputMode === "text") {
295
314
  if (runtimes.length === 0) {
@@ -310,12 +329,12 @@ async function executeAgent(context, args) {
310
329
  pending = modeResult.rest;
311
330
  const taskResult = takeOption(pending, "--task");
312
331
  pending = taskResult.rest;
313
- requireNoExtraArgs(pending, "bun run rig agent prepare --task <id> [--id <id>] [--mode worktree]");
332
+ requireNoExtraArgs(pending, "rig agent prepare --task <id> [--id <id>] [--mode worktree]");
314
333
  const mode = parseIsolationMode(modeResult.value, false);
315
334
  const id = idResult.value || agentId("agent");
316
335
  const taskId = taskResult.value?.trim();
317
336
  if (!taskId) {
318
- throw new CliError2("Usage: bun run rig agent prepare --task <id> [--id <id>] [--mode worktree]");
337
+ throw new CliError("Usage: rig agent prepare --task <id> [--id <id>] [--mode worktree]");
319
338
  }
320
339
  const runtime = await withMutedConsole(context.outputMode === "json", () => ensureAgentRuntime({
321
340
  projectRoot: context.projectRoot,
@@ -333,7 +352,7 @@ async function executeAgent(context, args) {
333
352
  case "run": {
334
353
  const { options, commandParts } = splitAtDoubleDash(rest);
335
354
  if (commandParts.length === 0) {
336
- throw new CliError2("Usage: bun run rig agent run [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...>");
355
+ throw new CliError("Usage: rig agent run [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...>");
337
356
  }
338
357
  let pending = options;
339
358
  const idResult = takeOption(pending, "--id");
@@ -344,12 +363,12 @@ async function executeAgent(context, args) {
344
363
  pending = taskResult.rest;
345
364
  const skipProjectSyncResult = takeFlag(pending, "--skip-project-sync");
346
365
  pending = skipProjectSyncResult.rest;
347
- requireNoExtraArgs(pending, "bun run rig agent run --task <id> [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...>");
366
+ requireNoExtraArgs(pending, "rig agent run --task <id> [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...>");
348
367
  const mode = parseIsolationMode(modeResult.value, false);
349
368
  const id = idResult.value || agentId("agent-run");
350
369
  const taskId = taskResult.value?.trim();
351
370
  if (!taskId) {
352
- throw new CliError2("Usage: bun run rig agent run --task <id> [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...>");
371
+ throw new CliError("Usage: rig agent run --task <id> [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...>");
353
372
  }
354
373
  await runProjectMainSyncPreflight(context, { disabled: skipProjectSyncResult.value });
355
374
  const createdAt = new Date().toISOString();
@@ -408,7 +427,7 @@ async function executeAgent(context, args) {
408
427
  pid: process.pid,
409
428
  errorText: result.stderr ? result.stderr.trim() : `Agent runtime command failed (${result.exitCode})`
410
429
  });
411
- throw new CliError2(`Agent runtime command failed (${result.exitCode}) in ${runtime.id}${result.stderr ? `
430
+ throw new CliError(`Agent runtime command failed (${result.exitCode}) in ${runtime.id}${result.stderr ? `
412
431
  ${result.stderr.trim()}` : ""}`, result.exitCode);
413
432
  }
414
433
  const completedAt = new Date().toISOString();
@@ -463,9 +482,9 @@ ${result.stderr.trim()}` : ""}`, result.exitCode);
463
482
  pending = allResult.rest;
464
483
  const idResult = takeOption(pending, "--id");
465
484
  pending = idResult.rest;
466
- requireNoExtraArgs(pending, "bun run rig agent cleanup (--id <id> | --all)");
485
+ requireNoExtraArgs(pending, "rig agent cleanup (--id <id> | --all)");
467
486
  if (!allResult.value && !idResult.value) {
468
- throw new CliError2("Provide --id <id> or --all.");
487
+ throw new CliError("Provide --id <id> or --all.", 1, { hint: "Run `rig agent list` to find agent ids." });
469
488
  }
470
489
  const runtimes = await listAgentRuntimes(context.projectRoot);
471
490
  const targets = allResult.value ? runtimes.map((runtime) => runtime.id) : [idResult.value];
@@ -490,7 +509,7 @@ ${result.stderr.trim()}` : ""}`, result.exitCode);
490
509
  };
491
510
  }
492
511
  default:
493
- throw new CliError2(`Unknown agent command: ${command}`);
512
+ throw new CliError(`Unknown agent command: ${command}`, 1, { hint: "Run `rig agent --help` to list agent commands." });
494
513
  }
495
514
  }
496
515
  export {
@@ -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 {};