@h-rig/cli 0.0.6-alpha.7 → 0.0.6-alpha.71

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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/rig.js +4507 -1506
  3. package/dist/src/commands/_async-ui.js +152 -0
  4. package/dist/src/commands/_authority-runs.js +2 -3
  5. package/dist/src/commands/_cli-format.js +369 -0
  6. package/dist/src/commands/_connection-state.js +30 -11
  7. package/dist/src/commands/_doctor-checks.js +177 -43
  8. package/dist/src/commands/_help-catalog.js +485 -0
  9. package/dist/src/commands/_json-output.js +56 -0
  10. package/dist/src/commands/_operator-surface.js +220 -0
  11. package/dist/src/commands/_operator-view.js +595 -72
  12. package/dist/src/commands/_parsers.js +18 -11
  13. package/dist/src/commands/_pi-frontend.js +411 -0
  14. package/dist/src/commands/_pi-install.js +4 -3
  15. package/dist/src/commands/_policy.js +12 -5
  16. package/dist/src/commands/_preflight.js +187 -127
  17. package/dist/src/commands/_run-driver-helpers.js +75 -22
  18. package/dist/src/commands/_run-replay.js +142 -0
  19. package/dist/src/commands/_server-client.js +343 -60
  20. package/dist/src/commands/_snapshot-upload.js +160 -38
  21. package/dist/src/commands/_spinner.js +65 -0
  22. package/dist/src/commands/_task-picker.js +44 -16
  23. package/dist/src/commands/agent.js +39 -20
  24. package/dist/src/commands/browser.js +28 -21
  25. package/dist/src/commands/connect.js +146 -33
  26. package/dist/src/commands/dist.js +19 -12
  27. package/dist/src/commands/doctor.js +304 -44
  28. package/dist/src/commands/github.js +301 -52
  29. package/dist/src/commands/inbox.js +679 -72
  30. package/dist/src/commands/init.js +622 -118
  31. package/dist/src/commands/inspect.js +515 -32
  32. package/dist/src/commands/inspector.js +20 -13
  33. package/dist/src/commands/pi.js +177 -0
  34. package/dist/src/commands/plugin.js +95 -27
  35. package/dist/src/commands/profile-and-review.js +26 -19
  36. package/dist/src/commands/queue.js +32 -12
  37. package/dist/src/commands/remote.js +43 -36
  38. package/dist/src/commands/repo-git-harness.js +22 -15
  39. package/dist/src/commands/run.js +1162 -158
  40. package/dist/src/commands/server.js +373 -56
  41. package/dist/src/commands/setup.js +316 -62
  42. package/dist/src/commands/stats.js +1030 -0
  43. package/dist/src/commands/task-report-bug.js +29 -22
  44. package/dist/src/commands/task-run-driver.js +862 -129
  45. package/dist/src/commands/task.js +1423 -311
  46. package/dist/src/commands/test.js +15 -8
  47. package/dist/src/commands/workspace.js +18 -11
  48. package/dist/src/commands.js +4446 -1499
  49. package/dist/src/index.js +4502 -1504
  50. package/dist/src/launcher.js +77 -13
  51. package/dist/src/report-bug.js +3 -3
  52. package/dist/src/runner.js +16 -22
  53. package/package.json +10 -5
@@ -7,12 +7,19 @@ import pc from "picocolors";
7
7
 
8
8
  // packages/cli/src/runner.ts
9
9
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
10
- import { CliError } from "@rig/runtime/control-plane/errors";
10
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
11
11
  import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
12
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
13
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
14
12
  import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
15
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
13
+
14
+ class CliError extends RuntimeCliError {
15
+ hint;
16
+ constructor(message, exitCode = 1, options = {}) {
17
+ super(message, exitCode);
18
+ if (options.hint?.trim()) {
19
+ this.hint = options.hint.trim();
20
+ }
21
+ }
22
+ }
16
23
  function formatCommand(parts) {
17
24
  return parts.map((part) => /[^a-zA-Z0-9_./:-]/.test(part) ? JSON.stringify(part) : part).join(" ");
18
25
  }
@@ -36,7 +43,7 @@ function takeOption(args, option) {
36
43
  if (current === option) {
37
44
  const next = args[index + 1];
38
45
  if (!next || next.startsWith("-")) {
39
- throw new CliError(`Missing value for ${option}`);
46
+ throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
40
47
  }
41
48
  value = next;
42
49
  index += 1;
@@ -241,15 +248,15 @@ function buildBugReportMarkdown(input, browser, screenshots, assets) {
241
248
  ...input.issueId ? [
242
249
  `- Canonical task assets live under \`artifacts/${input.issueId}/bug-report/\`.`,
243
250
  `- Start with \`artifacts/${input.issueId}/bug-report/task.md\` and the files in \`artifacts/${input.issueId}/bug-report/assets/\`.`,
244
- browserRequired ? `- Run \`bun run rig task info --task ${input.issueId}\` to confirm browser wiring before debugging.` : `- Run \`bun run rig task info --task ${input.issueId}\` to confirm scope and artifact links before debugging.`
251
+ browserRequired ? `- Run \`rig task info --task ${input.issueId}\` to confirm browser wiring before debugging.` : `- Run \`rig task info --task ${input.issueId}\` to confirm scope and artifact links before debugging.`
245
252
  ] : [
246
- "- Draft-only report: convert this into a beads task before assigning it to an agent run."
253
+ "- Draft-only report: convert this into a Rig task before assigning it to an agent run."
247
254
  ],
248
255
  "",
249
256
  "## Validation",
250
257
  "",
251
258
  "```bash",
252
- ...input.issueId ? [`bun run rig task validate --task ${input.issueId}`] : [],
259
+ ...input.issueId ? [`rig task validate --task ${input.issueId}`] : [],
253
260
  ...browserRequired ? [
254
261
  "bun run app:check:browser:hp-next",
255
262
  "bun run app:e2e:browser:hp-next"
@@ -344,7 +351,7 @@ async function executeTaskReportBug(context, args) {
344
351
  const noBrowserFlag = takeFlag(pending, "--no-browser");
345
352
  pending = noBrowserFlag.rest;
346
353
  if (browserFlag.value && noBrowserFlag.value) {
347
- throw new CliError2("Pass only one of --browser or --no-browser.");
354
+ throw new CliError("Pass only one of --browser or --no-browser.", 1, { hint: "Re-run `rig task report-bug` with just one of the flags." });
348
355
  }
349
356
  const overwriteFlag = takeFlag(pending, "--overwrite");
350
357
  pending = overwriteFlag.rest;
@@ -396,7 +403,7 @@ async function executeTaskReportBug(context, args) {
396
403
  pending = outputRootResult.rest;
397
404
  const slugResult = takeOption(pending, "--slug");
398
405
  pending = slugResult.rest;
399
- requireNoExtraArgs(pending, "bun run rig report-bug [--no-prompt] [--no-beads] [--browser|--no-browser] --title <text> --url <url> [--asset <dragged-file>]");
406
+ requireNoExtraArgs(pending, "rig report-bug [--no-prompt] [--no-beads] [--browser|--no-browser] --title <text> --url <url> [--asset <dragged-file>]");
400
407
  let draft = {
401
408
  outputRoot: outputRootResult.value || "",
402
409
  title: titleResult.value,
@@ -428,7 +435,7 @@ async function executeTaskReportBug(context, args) {
428
435
  const shouldPrompt = !noPromptFlag.value;
429
436
  if (shouldPrompt) {
430
437
  if (context.outputMode !== "text" || !process.stdin.isTTY || !process.stdout.isTTY) {
431
- throw new CliError2("Interactive bug reporting requires a TTY in text mode. Pass --no-prompt with flags for automation.");
438
+ throw new CliError("Interactive bug reporting requires a TTY in text mode. Pass --no-prompt with flags for automation.");
432
439
  }
433
440
  draft = await promptForBugReportDetails(draft);
434
441
  }
@@ -501,7 +508,7 @@ async function executeTaskReportBug(context, args) {
501
508
  console.log(`Evidence assets: ${result.assetDir}`);
502
509
  if (taskConfigPath) {
503
510
  console.log(`Task config: ${taskConfigPath}`);
504
- console.log(`Run: bun run rig task info --task ${issueId}`);
511
+ console.log(`Run: rig task info --task ${issueId}`);
505
512
  }
506
513
  }
507
514
  return {
@@ -532,7 +539,7 @@ function validateBugReportInputFiles(input) {
532
539
  for (const { path, label } of files.map((item) => ({ ...item, path: item.path.trim() })).filter((item) => item.path)) {
533
540
  const source = resolve3(input.projectRoot, path);
534
541
  if (!existsSync2(source)) {
535
- throw new CliError2(`${label} does not exist: ${source}`);
542
+ throw new CliError(`${label} does not exist: ${source}`, 1, { hint: "Check the path and re-run `rig task report-bug` with an existing file." });
536
543
  }
537
544
  }
538
545
  }
@@ -572,7 +579,7 @@ function createBugReportBeadsTask(monorepoRoot, input, draft) {
572
579
  const issue = tryRunBrJson(monorepoRoot, command);
573
580
  if (!issue.ok) {
574
581
  if (!isRecoverableBeadsJsonlFailure(issue.error)) {
575
- throw new CliError2(issue.error);
582
+ throw new CliError(issue.error);
576
583
  }
577
584
  return {
578
585
  issueId: generateBugReportIssueId(monorepoRoot, input.title),
@@ -583,7 +590,7 @@ function createBugReportBeadsTask(monorepoRoot, input, draft) {
583
590
  }
584
591
  const issueId = issue.value.id?.trim();
585
592
  if (!issueId) {
586
- throw new CliError2("br create did not return an issue id.");
593
+ throw new CliError("br create did not return an issue id.", 1, { hint: "Re-run `rig task report-bug`; if it persists, file the bug via your task source directly." });
587
594
  }
588
595
  return {
589
596
  issueId,
@@ -690,12 +697,12 @@ ${serializedEntry}
690
697
  }
691
698
  const insertAt = raw.lastIndexOf("}");
692
699
  if (insertAt < 0) {
693
- throw new CliError2(`Invalid task config JSON object: ${taskConfigPath}`);
700
+ throw new CliError(`Invalid task config JSON object: ${taskConfigPath}`, 1, { hint: "Fix or reset that file (it must be a JSON object), then re-run `rig task report-bug`." });
694
701
  }
695
702
  const before = raw.slice(0, insertAt).replace(/\s*$/, "");
696
703
  const after = raw.slice(insertAt + 1).trim();
697
704
  if (after) {
698
- throw new CliError2(`Invalid trailing content in task config: ${taskConfigPath}`);
705
+ throw new CliError(`Invalid trailing content in task config: ${taskConfigPath}`, 1, { hint: "Remove the trailing content so the file is a single JSON object, then retry." });
699
706
  }
700
707
  const comma = before.trim() === "{" ? "" : ",";
701
708
  writeFileSync2(taskConfigPath, `${before}${comma}
@@ -763,7 +770,7 @@ function generateBugReportIssueId(monorepoRoot, title) {
763
770
  return id;
764
771
  }
765
772
  }
766
- throw new CliError2("Could not generate a unique bug task id.");
773
+ throw new CliError("Could not generate a unique bug task id.", 1, { hint: "Re-run `rig task report-bug`; pass an explicit title to vary the generated id." });
767
774
  }
768
775
  function isRecoverableBeadsJsonlFailure(message) {
769
776
  return /Invalid JSON|missing field|JSONL is newer than DB|stale database/i.test(message);
@@ -771,7 +778,7 @@ function isRecoverableBeadsJsonlFailure(message) {
771
778
  function runBrJson(cwd, command) {
772
779
  const result = tryRunBrJson(cwd, command);
773
780
  if (!result.ok) {
774
- throw new CliError2(result.error);
781
+ throw new CliError(result.error);
775
782
  }
776
783
  return result.value;
777
784
  }
@@ -969,7 +976,7 @@ async function promptBugSelect(message, options, initialValue) {
969
976
  function unwrapClackPrompt(result) {
970
977
  if (clack.isCancel(result)) {
971
978
  clack.cancel("Bug report cancelled.");
972
- throw new CliError2("Bug report cancelled by user.");
979
+ throw new CliError("Bug report cancelled by user.");
973
980
  }
974
981
  return result;
975
982
  }
@@ -979,7 +986,7 @@ function normalizeBugEnvironmentChoice(environment) {
979
986
  function requireReportBugValue(value, option) {
980
987
  const normalized = value?.trim();
981
988
  if (!normalized) {
982
- throw new CliError2(`Missing ${option}. Run interactively or pass ${option} <value>.`);
989
+ throw new CliError(`Missing ${option}. Run interactively or pass ${option} <value>.`);
983
990
  }
984
991
  return normalized;
985
992
  }
@@ -1060,7 +1067,7 @@ function takeRepeatedOption(args, option) {
1060
1067
  if (current === option) {
1061
1068
  const next = args[index + 1];
1062
1069
  if (!next || next.startsWith("-")) {
1063
- throw new CliError2(`Missing value for ${option}`);
1070
+ throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
1064
1071
  }
1065
1072
  values.push(next);
1066
1073
  index += 1;