@h-rig/cli 0.0.6-alpha.10 → 0.0.6-alpha.100

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 (120) 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 +15683 -7361
  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/_config-env.d.ts +18 -0
  14. package/dist/src/commands/_config-env.js +22 -0
  15. package/dist/src/commands/_connection-state.d.ts +54 -0
  16. package/dist/src/commands/_connection-state.js +75 -11
  17. package/dist/src/commands/_doctor-checks.d.ts +46 -0
  18. package/dist/src/commands/_doctor-checks.js +100 -267
  19. package/dist/src/commands/_help-catalog.d.ts +29 -0
  20. package/dist/src/commands/_help-catalog.js +146 -0
  21. package/dist/src/commands/_inprocess-services.d.ts +33 -0
  22. package/dist/src/commands/_inprocess-services.js +102 -0
  23. package/dist/src/commands/_json-output.d.ts +11 -0
  24. package/dist/src/commands/_json-output.js +60 -0
  25. package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
  26. package/dist/src/commands/_lazy-reconcile.js +102 -0
  27. package/dist/src/commands/_parsers.d.ts +15 -0
  28. package/dist/src/commands/_parsers.js +18 -11
  29. package/dist/src/commands/_paths.d.ts +11 -0
  30. package/dist/src/commands/_paths.js +1 -1
  31. package/dist/src/commands/_pi-frontend.d.ts +35 -0
  32. package/dist/src/commands/_pi-frontend.js +64 -0
  33. package/dist/src/commands/_pi-install.d.ts +42 -0
  34. package/dist/src/commands/_pi-install.js +19 -36
  35. package/dist/src/commands/_policy.d.ts +8 -0
  36. package/dist/src/commands/_policy.js +67 -19
  37. package/dist/src/commands/_probes.d.ts +1 -0
  38. package/dist/src/commands/_run-bridge.d.ts +114 -0
  39. package/dist/src/commands/_run-bridge.js +387 -0
  40. package/dist/src/commands/_run-diagnostics.d.ts +9 -0
  41. package/dist/src/commands/_run-diagnostics.js +51 -0
  42. package/dist/src/commands/_run-driver-helpers.d.ts +26 -0
  43. package/dist/src/commands/_run-driver-helpers.js +79 -230
  44. package/dist/src/commands/_run-projection.d.ts +50 -0
  45. package/dist/src/commands/_run-projection.js +349 -0
  46. package/dist/src/commands/_run-subcommands.d.ts +3 -0
  47. package/dist/src/commands/_run-subcommands.js +31 -0
  48. package/dist/src/commands/_spinner.d.ts +25 -0
  49. package/dist/src/commands/_spinner.js +65 -0
  50. package/dist/src/commands/agent.d.ts +3 -0
  51. package/dist/src/commands/agent.js +8690 -236
  52. package/dist/src/commands/config.d.ts +3 -0
  53. package/dist/src/commands/config.js +181 -0
  54. package/dist/src/commands/dist.d.ts +28 -0
  55. package/dist/src/commands/dist.js +44 -29
  56. package/dist/src/commands/doctor.d.ts +3 -0
  57. package/dist/src/commands/doctor.js +219 -268
  58. package/dist/src/commands/github.d.ts +3 -0
  59. package/dist/src/commands/github.js +236 -188
  60. package/dist/src/commands/inbox.d.ts +28 -0
  61. package/dist/src/commands/inbox.js +530 -111
  62. package/dist/src/commands/init.d.ts +64 -0
  63. package/dist/src/commands/init.js +912 -705
  64. package/dist/src/commands/inspect.d.ts +20 -0
  65. package/dist/src/commands/inspect.js +709 -119
  66. package/dist/src/commands/pi.d.ts +3 -0
  67. package/dist/src/commands/pi.js +177 -0
  68. package/dist/src/commands/plugin.d.ts +16 -0
  69. package/dist/src/commands/plugin.js +576 -29
  70. package/dist/src/commands/profile-and-review.d.ts +4 -0
  71. package/dist/src/commands/profile-and-review.js +112 -67
  72. package/dist/src/commands/queue.d.ts +3 -0
  73. package/dist/src/commands/queue.js +20 -20
  74. package/dist/src/commands/remote.d.ts +3 -0
  75. package/dist/src/commands/remote.js +883 -50
  76. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  77. package/dist/src/commands/repo-git-harness.js +78 -28
  78. package/dist/src/commands/run.d.ts +21 -0
  79. package/dist/src/commands/run.js +17731 -661
  80. package/dist/src/commands/server.d.ts +3 -0
  81. package/dist/src/commands/server.js +166 -303
  82. package/dist/src/commands/setup.d.ts +16 -0
  83. package/dist/src/commands/setup.js +244 -299
  84. package/dist/src/commands/stats.d.ts +15 -0
  85. package/dist/src/commands/stats.js +632 -0
  86. package/dist/src/commands/task-run-driver.d.ts +94 -0
  87. package/dist/src/commands/task-run-driver.js +116 -1961
  88. package/dist/src/commands/task.d.ts +35 -0
  89. package/dist/src/commands/task.js +676 -1201
  90. package/dist/src/commands/test.d.ts +3 -0
  91. package/dist/src/commands/test.js +15 -8
  92. package/dist/src/commands/triage.d.ts +11 -0
  93. package/dist/src/commands/triage.js +227 -0
  94. package/dist/src/commands/workspace.d.ts +3 -0
  95. package/dist/src/commands/workspace.js +18 -11
  96. package/dist/src/commands.d.ts +13 -0
  97. package/dist/src/commands.js +16812 -8045
  98. package/dist/src/index.d.ts +4 -0
  99. package/dist/src/index.js +16817 -8377
  100. package/dist/src/launcher.d.ts +61 -0
  101. package/dist/src/launcher.js +77 -11
  102. package/dist/src/operator-cli.d.ts +2 -0
  103. package/dist/src/operator-cli.js +17867 -0
  104. package/dist/src/operator-entry.d.ts +1 -0
  105. package/dist/src/operator-entry.js +3 -0
  106. package/dist/src/runner.d.ts +47 -0
  107. package/dist/src/runner.js +16 -22
  108. package/dist/src/withMutedConsole.d.ts +2 -0
  109. package/package.json +21 -8
  110. package/dist/src/commands/_authority-runs.js +0 -111
  111. package/dist/src/commands/_operator-view.js +0 -340
  112. package/dist/src/commands/_preflight.js +0 -478
  113. package/dist/src/commands/_server-client.js +0 -382
  114. package/dist/src/commands/_snapshot-upload.js +0 -331
  115. package/dist/src/commands/_task-picker.js +0 -48
  116. package/dist/src/commands/browser.js +0 -890
  117. package/dist/src/commands/connect.js +0 -180
  118. package/dist/src/commands/inspector.js +0 -256
  119. package/dist/src/commands/task-report-bug.js +0 -1083
  120. package/dist/src/report-bug.js +0 -260
@@ -0,0 +1,3 @@
1
+ import type { CommandOutcome } from "@rig/runtime";
2
+ import { type RunnerContext } from "../runner";
3
+ export declare function executeConfig(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
@@ -0,0 +1,181 @@
1
+ // @bun
2
+ // packages/cli/src/commands/config.ts
3
+ import { existsSync, readFileSync, writeFileSync } from "fs";
4
+ import { resolve } from "path";
5
+ import { loadConfig } from "@rig/core/load-config";
6
+ import {
7
+ DEFAULT_RIG_RELAY_URL,
8
+ DEFAULT_RIG_REGISTRY_URL,
9
+ resolveRegistryBaseUrl,
10
+ resolveRegistrySecret,
11
+ resolveRelayUrl
12
+ } from "@rig/runtime/control-plane/remote";
13
+
14
+ // packages/cli/src/runner.ts
15
+ import { EventBus } from "@rig/runtime/control-plane/runtime/events";
16
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
17
+ import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
18
+ import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
19
+
20
+ class CliError extends RuntimeCliError {
21
+ hint;
22
+ constructor(message, exitCode = 1, options = {}) {
23
+ super(message, exitCode);
24
+ if (options.hint?.trim()) {
25
+ this.hint = options.hint.trim();
26
+ }
27
+ }
28
+ }
29
+ function requireNoExtraArgs(args, usage) {
30
+ if (args.length > 0) {
31
+ throw new CliError(`Unexpected arguments: ${args.join(" ")}
32
+ Usage: ${usage}`);
33
+ }
34
+ }
35
+
36
+ // packages/cli/src/commands/_cli-format.ts
37
+ import pc from "picocolors";
38
+ var dim = pc.dim;
39
+ var faintBar = pc.dim("\u2502");
40
+ var accent = pc.cyan;
41
+ function printFormattedOutput(message) {
42
+ console.log(message);
43
+ }
44
+
45
+ // packages/cli/src/commands/config.ts
46
+ var KNOBS = {
47
+ "runtime.server.relayUrl": { env: "RIG_COLLAB_RELAY", effective: () => resolveRelayUrl(), def: DEFAULT_RIG_RELAY_URL },
48
+ "runtime.server.registryUrl": { env: "RIG_REGISTRY_URL", effective: (r) => resolveRegistryBaseUrl(r), def: DEFAULT_RIG_REGISTRY_URL },
49
+ "runtime.server.registrySecret": { env: "RIG_REGISTRY_SHARED_SECRET", effective: (r) => resolveRegistrySecret(r), def: "(built-in default)" },
50
+ "runtime.server.sshTarget": { env: "RIG_SSH_TARGET", effective: () => process.env.RIG_SSH_TARGET?.trim() ?? "(none \u2014 local placement)", def: "(none)" }
51
+ };
52
+ var ALIASES = {
53
+ relayUrl: "runtime.server.relayUrl",
54
+ registryUrl: "runtime.server.registryUrl",
55
+ registrySecret: "runtime.server.registrySecret",
56
+ sshTarget: "runtime.server.sshTarget"
57
+ };
58
+ function canonicalKey(key) {
59
+ return ALIASES[key] ?? key;
60
+ }
61
+ async function loadProjectConfig(root) {
62
+ try {
63
+ return await loadConfig(root);
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+ function configHasKnob(config, canonical, envKey) {
69
+ if (!config)
70
+ return false;
71
+ const server = config.runtime?.server;
72
+ const field = canonical.replace("runtime.server.", "");
73
+ if (server && server[field] !== undefined)
74
+ return true;
75
+ if (server && server.host !== undefined && (field === "relayUrl" || field === "registryUrl"))
76
+ return true;
77
+ const envMap = config.env;
78
+ return Boolean(envMap && envMap[envKey] !== undefined);
79
+ }
80
+ function describe(root, config, canonical) {
81
+ const knob = KNOBS[canonical];
82
+ if (!knob) {
83
+ const val = process.env[canonical];
84
+ const fromConfig = Boolean(config?.env?.[canonical]);
85
+ return `${canonical} = ${val ?? "(unset)"} [${val === undefined ? "default" : fromConfig ? "rig.config.ts" : "env"}]`;
86
+ }
87
+ const value = knob.effective(root);
88
+ const inConfig = configHasKnob(config, canonical, knob.env);
89
+ const ambient = Boolean(process.env[knob.env]);
90
+ const source = inConfig ? "rig.config.ts" : ambient ? "env" : "default";
91
+ return `${canonical} = ${value} [${source}]`;
92
+ }
93
+ async function configGet(context, args) {
94
+ const root = context.projectRoot;
95
+ const config = await loadProjectConfig(root);
96
+ const text = context.outputMode === "text";
97
+ if (args[0]) {
98
+ const canonical = canonicalKey(args[0]);
99
+ requireNoExtraArgs(args.slice(1), "rig config get [<key>]");
100
+ if (text)
101
+ printFormattedOutput(describe(root, config, canonical));
102
+ return { ok: true, group: "config", command: "get", details: { key: canonical } };
103
+ }
104
+ const lines = ["\u25C6 Rig config \u2014 effective values (ambient env \u2192 rig.config.ts \u2192 default)"];
105
+ for (const canonical of Object.keys(KNOBS))
106
+ lines.push(` ${describe(root, config, canonical)}`);
107
+ const envMap = config?.env ?? {};
108
+ const envKeys = Object.keys(envMap);
109
+ lines.push(envKeys.length ? ` env overrides: ${envKeys.join(", ")}` : " env overrides: (none)");
110
+ if (text)
111
+ printFormattedOutput(lines.join(`
112
+ `));
113
+ return { ok: true, group: "config", command: "get", details: {} };
114
+ }
115
+ function writeEnvOverride(source, envKey, value) {
116
+ const entry = ` ${JSON.stringify(envKey)}: ${JSON.stringify(value)},`;
117
+ const envBlock = /env\s*:\s*\{([\s\S]*?)\}/m;
118
+ const m = envBlock.exec(source);
119
+ if (m) {
120
+ const body = m[1] ?? "";
121
+ const keyRe = new RegExp(`(^|\\n)\\s*${envKey.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\$&")}\\s*:\\s*[^,\\n]*,?`, "m");
122
+ const quotedRe = new RegExp(`(^|\\n)\\s*["']${envKey}["']\\s*:\\s*[^,\\n]*,?`, "m");
123
+ if (keyRe.test(body) || quotedRe.test(body)) {
124
+ const newBody = body.replace(quotedRe, `
125
+ ${entry}`).replace(keyRe, `
126
+ ${entry}`);
127
+ return source.replace(envBlock, `env: {${newBody}
128
+ }`);
129
+ }
130
+ return source.replace(envBlock, `env: {
131
+ ${entry}${body}}`);
132
+ }
133
+ const defRe = /defineConfig\s*\(\s*\{/m;
134
+ if (!defRe.test(source)) {
135
+ throw new CliError("Could not find `defineConfig({` in rig.config.ts to insert an env override.", 2, {
136
+ hint: `Add manually: env: { ${JSON.stringify(envKey)}: ${JSON.stringify(value)} }`
137
+ });
138
+ }
139
+ return source.replace(defRe, (match) => `${match}
140
+ env: {
141
+ ${entry}
142
+ },`);
143
+ }
144
+ async function configSet(context, args) {
145
+ const [rawKey, ...valueParts] = args;
146
+ if (!rawKey || valueParts.length === 0) {
147
+ throw new CliError("Usage: rig config set <key> <value>", 2, {
148
+ hint: `Keys: ${Object.keys(ALIASES).join(", ")}, or any RIG_* env var.`
149
+ });
150
+ }
151
+ const value = valueParts.join(" ");
152
+ const canonical = canonicalKey(rawKey);
153
+ const envKey = KNOBS[canonical]?.env ?? canonical;
154
+ const configPath = resolve(context.projectRoot, "rig.config.ts");
155
+ if (!existsSync(configPath)) {
156
+ throw new CliError(`No rig.config.ts at ${context.projectRoot}.`, 2, { hint: "Run `rig init` first." });
157
+ }
158
+ const source = readFileSync(configPath, "utf8");
159
+ const updated = writeEnvOverride(source, envKey, value);
160
+ writeFileSync(configPath, updated);
161
+ if (context.outputMode === "text") {
162
+ printFormattedOutput(`Set ${canonical} (env ${envKey}) = ${value} in rig.config.ts`);
163
+ }
164
+ return { ok: true, group: "config", command: "set", details: { key: canonical, env: envKey, value } };
165
+ }
166
+ async function executeConfig(context, args) {
167
+ const [sub, ...rest] = args;
168
+ switch (sub) {
169
+ case "get":
170
+ return configGet(context, rest);
171
+ case "set":
172
+ return configSet(context, rest);
173
+ default:
174
+ throw new CliError("Usage: rig config <get|set>", 2, {
175
+ hint: "rig config get [<key>] \u2014 effective value + source; rig config set <key> <value> \u2014 write to rig.config.ts"
176
+ });
177
+ }
178
+ }
179
+ export {
180
+ executeConfig
181
+ };
@@ -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>;