@h-rig/cli 0.0.6-alpha.9 → 0.0.6-alpha.91

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 (116) hide show
  1. package/README.md +18 -19
  2. package/dist/bin/build-rig-binaries.d.ts +2 -0
  3. package/dist/bin/build-rig-binaries.js +22 -10
  4. package/dist/bin/rig.d.ts +72 -0
  5. package/dist/bin/rig.js +15637 -7344
  6. package/dist/config/rig-default-config.yml +5 -0
  7. package/dist/src/app/drone-ui.d.ts +34 -0
  8. package/dist/src/app/drone-ui.js +278 -0
  9. package/dist/src/commands/_async-ui.d.ts +10 -0
  10. package/dist/src/commands/_async-ui.js +121 -0
  11. package/dist/src/commands/_cli-format.d.ts +56 -0
  12. package/dist/src/commands/_cli-format.js +319 -0
  13. package/dist/src/commands/_connection-state.d.ts +54 -0
  14. package/dist/src/commands/_connection-state.js +75 -11
  15. package/dist/src/commands/_doctor-checks.d.ts +46 -0
  16. package/dist/src/commands/_doctor-checks.js +100 -267
  17. package/dist/src/commands/_help-catalog.d.ts +51 -0
  18. package/dist/src/commands/_help-catalog.js +502 -0
  19. package/dist/src/commands/_inprocess-services.d.ts +33 -0
  20. package/dist/src/commands/_inprocess-services.js +102 -0
  21. package/dist/src/commands/_json-output.d.ts +11 -0
  22. package/dist/src/commands/_json-output.js +60 -0
  23. package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
  24. package/dist/src/commands/_lazy-reconcile.js +102 -0
  25. package/dist/src/commands/_parsers.d.ts +15 -0
  26. package/dist/src/commands/_parsers.js +18 -11
  27. package/dist/src/commands/_paths.d.ts +11 -0
  28. package/dist/src/commands/_paths.js +1 -1
  29. package/dist/src/commands/_pi-frontend.d.ts +35 -0
  30. package/dist/src/commands/_pi-frontend.js +64 -0
  31. package/dist/src/commands/_pi-install.d.ts +42 -0
  32. package/dist/src/commands/_pi-install.js +19 -36
  33. package/dist/src/commands/_policy.d.ts +8 -0
  34. package/dist/src/commands/_policy.js +67 -19
  35. package/dist/src/commands/_probes.d.ts +1 -0
  36. package/dist/src/commands/_run-bridge.d.ts +114 -0
  37. package/dist/src/commands/_run-bridge.js +387 -0
  38. package/dist/src/commands/_run-diagnostics.d.ts +9 -0
  39. package/dist/src/commands/_run-diagnostics.js +51 -0
  40. package/dist/src/commands/_run-driver-helpers.d.ts +26 -0
  41. package/dist/src/commands/_run-driver-helpers.js +79 -230
  42. package/dist/src/commands/_run-projection.d.ts +50 -0
  43. package/dist/src/commands/_run-projection.js +349 -0
  44. package/dist/src/commands/_run-subcommands.d.ts +3 -0
  45. package/dist/src/commands/_run-subcommands.js +31 -0
  46. package/dist/src/commands/_spinner.d.ts +25 -0
  47. package/dist/src/commands/_spinner.js +65 -0
  48. package/dist/src/commands/agent.d.ts +3 -0
  49. package/dist/src/commands/agent.js +8575 -236
  50. package/dist/src/commands/dist.d.ts +28 -0
  51. package/dist/src/commands/dist.js +44 -29
  52. package/dist/src/commands/doctor.d.ts +3 -0
  53. package/dist/src/commands/doctor.js +219 -268
  54. package/dist/src/commands/github.d.ts +3 -0
  55. package/dist/src/commands/github.js +236 -188
  56. package/dist/src/commands/inbox.d.ts +28 -0
  57. package/dist/src/commands/inbox.js +530 -111
  58. package/dist/src/commands/init.d.ts +64 -0
  59. package/dist/src/commands/init.js +912 -705
  60. package/dist/src/commands/inspect.d.ts +20 -0
  61. package/dist/src/commands/inspect.js +709 -119
  62. package/dist/src/commands/pi.d.ts +3 -0
  63. package/dist/src/commands/pi.js +177 -0
  64. package/dist/src/commands/plugin.d.ts +16 -0
  65. package/dist/src/commands/plugin.js +576 -29
  66. package/dist/src/commands/profile-and-review.d.ts +4 -0
  67. package/dist/src/commands/profile-and-review.js +112 -67
  68. package/dist/src/commands/queue.d.ts +3 -0
  69. package/dist/src/commands/queue.js +20 -20
  70. package/dist/src/commands/remote.d.ts +3 -0
  71. package/dist/src/commands/remote.js +880 -50
  72. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  73. package/dist/src/commands/repo-git-harness.js +78 -28
  74. package/dist/src/commands/run.d.ts +21 -0
  75. package/dist/src/commands/run.js +17701 -661
  76. package/dist/src/commands/server.d.ts +3 -0
  77. package/dist/src/commands/server.js +166 -303
  78. package/dist/src/commands/setup.d.ts +16 -0
  79. package/dist/src/commands/setup.js +244 -299
  80. package/dist/src/commands/stats.d.ts +15 -0
  81. package/dist/src/commands/stats.js +979 -0
  82. package/dist/src/commands/task-run-driver.d.ts +94 -0
  83. package/dist/src/commands/task-run-driver.js +116 -1961
  84. package/dist/src/commands/task.d.ts +35 -0
  85. package/dist/src/commands/task.js +676 -1201
  86. package/dist/src/commands/test.d.ts +3 -0
  87. package/dist/src/commands/test.js +15 -8
  88. package/dist/src/commands/triage.d.ts +11 -0
  89. package/dist/src/commands/triage.js +227 -0
  90. package/dist/src/commands/workspace.d.ts +3 -0
  91. package/dist/src/commands/workspace.js +18 -11
  92. package/dist/src/commands.d.ts +13 -0
  93. package/dist/src/commands.js +16792 -8055
  94. package/dist/src/index.d.ts +4 -0
  95. package/dist/src/index.js +16862 -8450
  96. package/dist/src/launcher.d.ts +61 -0
  97. package/dist/src/launcher.js +81 -13
  98. package/dist/src/operator-cli.d.ts +2 -0
  99. package/dist/src/operator-cli.js +17837 -0
  100. package/dist/src/operator-entry.d.ts +1 -0
  101. package/dist/src/operator-entry.js +3 -0
  102. package/dist/src/runner.d.ts +47 -0
  103. package/dist/src/runner.js +16 -22
  104. package/dist/src/withMutedConsole.d.ts +2 -0
  105. package/package.json +21 -8
  106. package/dist/src/commands/_authority-runs.js +0 -111
  107. package/dist/src/commands/_operator-view.js +0 -340
  108. package/dist/src/commands/_preflight.js +0 -478
  109. package/dist/src/commands/_server-client.js +0 -382
  110. package/dist/src/commands/_snapshot-upload.js +0 -331
  111. package/dist/src/commands/_task-picker.js +0 -48
  112. package/dist/src/commands/browser.js +0 -890
  113. package/dist/src/commands/connect.js +0 -180
  114. package/dist/src/commands/inspector.js +0 -256
  115. package/dist/src/commands/task-report-bug.js +0 -1083
  116. package/dist/src/report-bug.js +0 -260
@@ -0,0 +1,28 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import type { CommandOutcome } from "@rig/runtime";
3
+ export type DistDoctorDetails = {
4
+ bun: {
5
+ available: boolean;
6
+ path: string | null;
7
+ version: string;
8
+ };
9
+ rig: {
10
+ onPath: boolean;
11
+ path: string | null;
12
+ runnable: boolean;
13
+ };
14
+ userBinDir: string;
15
+ userBinInPath: boolean;
16
+ latestDistBinary: string | null;
17
+ };
18
+ export type BuildTarget = {
19
+ source: string;
20
+ dest: string;
21
+ cwd: string;
22
+ };
23
+ export declare function collectRigValidatorBuildTargets(input: {
24
+ contextProjectRoot: string;
25
+ hostProjectRoot: string;
26
+ imageDir: string;
27
+ }): BuildTarget[];
28
+ export declare function executeDist(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
@@ -17,12 +17,19 @@ import { resolve as resolve3 } from "path";
17
17
 
18
18
  // packages/cli/src/runner.ts
19
19
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
20
- import { CliError } from "@rig/runtime/control-plane/errors";
20
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
21
21
  import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
22
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
23
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
24
22
  import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
25
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
23
+
24
+ class CliError extends RuntimeCliError {
25
+ hint;
26
+ constructor(message, exitCode = 1, options = {}) {
27
+ super(message, exitCode);
28
+ if (options.hint?.trim()) {
29
+ this.hint = options.hint.trim();
30
+ }
31
+ }
32
+ }
26
33
  function takeOption(args, option) {
27
34
  const rest = [];
28
35
  let value;
@@ -31,7 +38,7 @@ function takeOption(args, option) {
31
38
  if (current === option) {
32
39
  const next = args[index + 1];
33
40
  if (!next || next.startsWith("-")) {
34
- throw new CliError(`Missing value for ${option}`);
41
+ throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
35
42
  }
36
43
  value = next;
37
44
  index += 1;
@@ -51,11 +58,11 @@ Usage: ${usage}`);
51
58
  }
52
59
 
53
60
  // packages/cli/src/commands/dist.ts
54
- import { buildBinary as buildBinary2 } from "@rig/runtime/control-plane/runtime/isolation";
55
61
  import {
56
62
  computeRuntimeImageFingerprint,
57
63
  computeRuntimeImageId
58
64
  } from "@rig/runtime/control-plane/runtime/image/index";
65
+ import { buildBinary as buildBinary2 } from "@rig/runtime/control-plane/runtime/isolation";
59
66
 
60
67
  // packages/cli/src/commands/_parsers.ts
61
68
  import { homedir } from "os";
@@ -67,7 +74,7 @@ function parseInstallScope(value) {
67
74
  if (value === "system") {
68
75
  return "system";
69
76
  }
70
- throw new CliError2(`Invalid --scope value: ${value}. Use user|system.`);
77
+ throw new CliError(`Invalid --scope value: ${value}. Use user|system.`);
71
78
  }
72
79
  function resolveInstallDir(scope, explicitPath) {
73
80
  if (explicitPath) {
@@ -81,7 +88,7 @@ function resolveInstallDir(scope, explicitPath) {
81
88
 
82
89
  // packages/cli/src/commands/_paths.ts
83
90
  import { resolve as resolve2 } from "path";
84
- import { resolveMonorepoRoot } from "@rig/runtime/control-plane/native/utils";
91
+ import { resolveMonorepoRoot } from "@rig/runtime/layout";
85
92
  function resolveControlPlaneMonorepoRoot(projectRoot) {
86
93
  return resolveMonorepoRoot(projectRoot);
87
94
  }
@@ -117,8 +124,9 @@ function collectRigValidatorBuildTargets(input) {
117
124
  if (!existsSync(validatorsRoot))
118
125
  return [];
119
126
  const targets = [];
120
- const categories = readdirSync(validatorsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
121
- for (const category of categories) {
127
+ for (const category of readdirSync(validatorsRoot, { withFileTypes: true })) {
128
+ if (!category.isDirectory())
129
+ continue;
122
130
  const categoryDir = resolve3(validatorsRoot, category.name);
123
131
  for (const entry of readdirSync(categoryDir, { withFileTypes: true })) {
124
132
  if (!entry.isFile() || !entry.name.endsWith(".ts"))
@@ -126,9 +134,10 @@ function collectRigValidatorBuildTargets(input) {
126
134
  const check = entry.name.replace(/\.ts$/, "");
127
135
  if (!check || check === "index" || check === "shared")
128
136
  continue;
137
+ const validatorName = `${category.name}-${check}`;
129
138
  targets.push({
130
139
  source: `packages/runtime/src/control-plane/validators/${category.name}/${entry.name}`,
131
- dest: resolve3(input.imageDir, `bin/validators/${category.name}-${check}`),
140
+ dest: resolve3(input.imageDir, `bin/validators/${validatorName}`),
132
141
  cwd: input.hostProjectRoot
133
142
  });
134
143
  }
@@ -140,15 +149,22 @@ async function findLatestDistBinary(projectRoot) {
140
149
  if (!existsSync(distRoot)) {
141
150
  return null;
142
151
  }
143
- const entries = readdirSync(distRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("rig-")).map((entry) => ({
144
- name: entry.name,
145
- mtimeMs: statSync(resolve3(distRoot, entry.name)).mtimeMs
146
- })).sort((a, b) => b.mtimeMs - a.mtimeMs || b.name.localeCompare(a.name));
147
- for (const { name } of entries) {
148
- const candidate = resolve3(distRoot, name, "bin", "rig");
149
- if (existsSync(candidate) && await isRunnableRigBinary(candidate, projectRoot)) {
150
- return candidate;
151
- }
152
+ const candidates = [];
153
+ for (const entry of readdirSync(distRoot, { withFileTypes: true })) {
154
+ if (!entry.name.startsWith("rig-") && entry.name !== "rig")
155
+ continue;
156
+ const entryPath = resolve3(distRoot, entry.name);
157
+ const binary = entry.isDirectory() ? resolve3(entryPath, "bin", "rig") : entryPath;
158
+ try {
159
+ const stat = statSync(binary);
160
+ if (stat.isFile())
161
+ candidates.push({ path: binary, mtimeMs: stat.mtimeMs });
162
+ } catch {}
163
+ }
164
+ candidates.sort((a, b) => b.mtimeMs - a.mtimeMs);
165
+ for (const { path } of candidates) {
166
+ if (await isRunnableRigBinary(path, projectRoot))
167
+ return path;
152
168
  }
153
169
  return null;
154
170
  }
@@ -185,11 +201,10 @@ async function executeDist(context, args) {
185
201
  switch (command) {
186
202
  case "build": {
187
203
  const { value: outputDir, rest: pending } = takeOption(rest, "--output-dir");
188
- requireNoExtraArgs(pending, "bun run rig dist build [--output-dir <dir>]");
204
+ requireNoExtraArgs(pending, "rig dist build [--output-dir <dir>]");
189
205
  const commandParts = ["bun", "run", "packages/cli/bin/build-rig-binaries.ts"];
190
- if (outputDir) {
206
+ if (outputDir)
191
207
  commandParts.push("--output-dir", outputDir);
192
- }
193
208
  await context.runCommand(commandParts);
194
209
  return { ok: true, group: "dist", command, details: { outputDir: outputDir || null } };
195
210
  }
@@ -197,9 +212,9 @@ async function executeDist(context, args) {
197
212
  let pending = rest;
198
213
  const scopeResult = takeOption(pending, "--scope");
199
214
  pending = scopeResult.rest;
200
- const pathResult = takeOption(pending, "--path");
215
+ const pathResult = takeOption(pending, "--dir");
201
216
  pending = pathResult.rest;
202
- requireNoExtraArgs(pending, "bun run rig dist install [--scope user|system] [--path <dir>]");
217
+ requireNoExtraArgs(pending, "rig dist install [--scope user|system] [--dir <dir>]");
203
218
  const scope = parseInstallScope(scopeResult.value);
204
219
  const installDir = resolveInstallDir(scope, pathResult.value);
205
220
  mkdirSync(installDir, { recursive: true });
@@ -211,7 +226,7 @@ async function executeDist(context, args) {
211
226
  source = resolve3(buildDir, "bin", "rig");
212
227
  }
213
228
  if (!existsSync(source)) {
214
- throw new CliError2(`Unable to locate rig binary at ${source}.`, 2);
229
+ throw new CliError(`Unable to locate rig binary at ${source}.`, 2, { hint: "Build it first with `rig dist build`, then re-run `rig dist install`." });
215
230
  }
216
231
  const installedPath = resolve3(installDir, "rig");
217
232
  if (existsSync(installedPath)) {
@@ -242,7 +257,7 @@ async function executeDist(context, args) {
242
257
  };
243
258
  }
244
259
  case "doctor": {
245
- requireNoExtraArgs(rest, "bun run rig dist doctor");
260
+ requireNoExtraArgs(rest, "rig dist doctor");
246
261
  const details = await runDistDoctor(context.projectRoot);
247
262
  if (context.outputMode === "text") {
248
263
  console.log(`bun: ${details.bun.available ? `ok (${details.bun.version})` : "missing"}`);
@@ -253,7 +268,7 @@ async function executeDist(context, args) {
253
268
  return { ok: true, group: "dist", command, details };
254
269
  }
255
270
  case "rebuild-agent": {
256
- requireNoExtraArgs(rest, "bun run rig dist rebuild-agent");
271
+ requireNoExtraArgs(rest, "rig dist rebuild-agent");
257
272
  const fp = await computeRuntimeImageFingerprint(context.projectRoot);
258
273
  const currentId = computeRuntimeImageId(fp);
259
274
  const imagesDir = resolve3(resolveControlPlaneMonorepoRuntimeDir(context.projectRoot), "images");
@@ -393,7 +408,7 @@ async function executeDist(context, args) {
393
408
  return { ok: true, group: "dist", command, details: { imageId: currentId, count: targets.length } };
394
409
  }
395
410
  default:
396
- throw new CliError2(`Unknown dist command: ${command}`);
411
+ throw new CliError(`Unknown dist command: ${command}`, 1, { hint: "Run `rig dist --help` \u2014 commands are build|install|doctor|rebuild-agent." });
397
412
  }
398
413
  }
399
414
  export {
@@ -0,0 +1,3 @@
1
+ import type { CommandOutcome } from "@rig/runtime";
2
+ import { type RunnerContext } from "../runner";
3
+ export declare function executeDoctor(context: RunnerContext, args: string[]): Promise<CommandOutcome>;