@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.
- package/README.md +18 -19
- package/dist/bin/build-rig-binaries.d.ts +2 -0
- package/dist/bin/build-rig-binaries.js +22 -10
- package/dist/bin/rig.d.ts +72 -0
- package/dist/bin/rig.js +15683 -7361
- package/dist/config/rig-default-config.yml +5 -0
- package/dist/src/app/drone-ui.d.ts +34 -0
- package/dist/src/app/drone-ui.js +278 -0
- package/dist/src/commands/_async-ui.d.ts +10 -0
- package/dist/src/commands/_async-ui.js +121 -0
- package/dist/src/commands/_cli-format.d.ts +56 -0
- package/dist/src/commands/_cli-format.js +319 -0
- package/dist/src/commands/_config-env.d.ts +18 -0
- package/dist/src/commands/_config-env.js +22 -0
- package/dist/src/commands/_connection-state.d.ts +54 -0
- package/dist/src/commands/_connection-state.js +75 -11
- package/dist/src/commands/_doctor-checks.d.ts +46 -0
- package/dist/src/commands/_doctor-checks.js +100 -267
- package/dist/src/commands/_help-catalog.d.ts +29 -0
- package/dist/src/commands/_help-catalog.js +146 -0
- package/dist/src/commands/_inprocess-services.d.ts +33 -0
- package/dist/src/commands/_inprocess-services.js +102 -0
- package/dist/src/commands/_json-output.d.ts +11 -0
- package/dist/src/commands/_json-output.js +60 -0
- package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
- package/dist/src/commands/_lazy-reconcile.js +102 -0
- package/dist/src/commands/_parsers.d.ts +15 -0
- package/dist/src/commands/_parsers.js +18 -11
- package/dist/src/commands/_paths.d.ts +11 -0
- package/dist/src/commands/_paths.js +1 -1
- package/dist/src/commands/_pi-frontend.d.ts +35 -0
- package/dist/src/commands/_pi-frontend.js +64 -0
- package/dist/src/commands/_pi-install.d.ts +42 -0
- package/dist/src/commands/_pi-install.js +19 -36
- package/dist/src/commands/_policy.d.ts +8 -0
- package/dist/src/commands/_policy.js +67 -19
- package/dist/src/commands/_probes.d.ts +1 -0
- package/dist/src/commands/_run-bridge.d.ts +114 -0
- package/dist/src/commands/_run-bridge.js +387 -0
- package/dist/src/commands/_run-diagnostics.d.ts +9 -0
- package/dist/src/commands/_run-diagnostics.js +51 -0
- package/dist/src/commands/_run-driver-helpers.d.ts +26 -0
- package/dist/src/commands/_run-driver-helpers.js +79 -230
- package/dist/src/commands/_run-projection.d.ts +50 -0
- package/dist/src/commands/_run-projection.js +349 -0
- package/dist/src/commands/_run-subcommands.d.ts +3 -0
- package/dist/src/commands/_run-subcommands.js +31 -0
- package/dist/src/commands/_spinner.d.ts +25 -0
- package/dist/src/commands/_spinner.js +65 -0
- package/dist/src/commands/agent.d.ts +3 -0
- package/dist/src/commands/agent.js +8690 -236
- package/dist/src/commands/config.d.ts +3 -0
- package/dist/src/commands/config.js +181 -0
- package/dist/src/commands/dist.d.ts +28 -0
- package/dist/src/commands/dist.js +44 -29
- package/dist/src/commands/doctor.d.ts +3 -0
- package/dist/src/commands/doctor.js +219 -268
- package/dist/src/commands/github.d.ts +3 -0
- package/dist/src/commands/github.js +236 -188
- package/dist/src/commands/inbox.d.ts +28 -0
- package/dist/src/commands/inbox.js +530 -111
- package/dist/src/commands/init.d.ts +64 -0
- package/dist/src/commands/init.js +912 -705
- package/dist/src/commands/inspect.d.ts +20 -0
- package/dist/src/commands/inspect.js +709 -119
- package/dist/src/commands/pi.d.ts +3 -0
- package/dist/src/commands/pi.js +177 -0
- package/dist/src/commands/plugin.d.ts +16 -0
- package/dist/src/commands/plugin.js +576 -29
- package/dist/src/commands/profile-and-review.d.ts +4 -0
- package/dist/src/commands/profile-and-review.js +112 -67
- package/dist/src/commands/queue.d.ts +3 -0
- package/dist/src/commands/queue.js +20 -20
- package/dist/src/commands/remote.d.ts +3 -0
- package/dist/src/commands/remote.js +883 -50
- package/dist/src/commands/repo-git-harness.d.ts +5 -0
- package/dist/src/commands/repo-git-harness.js +78 -28
- package/dist/src/commands/run.d.ts +21 -0
- package/dist/src/commands/run.js +17731 -661
- package/dist/src/commands/server.d.ts +3 -0
- package/dist/src/commands/server.js +166 -303
- package/dist/src/commands/setup.d.ts +16 -0
- package/dist/src/commands/setup.js +244 -299
- package/dist/src/commands/stats.d.ts +15 -0
- package/dist/src/commands/stats.js +632 -0
- package/dist/src/commands/task-run-driver.d.ts +94 -0
- package/dist/src/commands/task-run-driver.js +116 -1961
- package/dist/src/commands/task.d.ts +35 -0
- package/dist/src/commands/task.js +676 -1201
- package/dist/src/commands/test.d.ts +3 -0
- package/dist/src/commands/test.js +15 -8
- package/dist/src/commands/triage.d.ts +11 -0
- package/dist/src/commands/triage.js +227 -0
- package/dist/src/commands/workspace.d.ts +3 -0
- package/dist/src/commands/workspace.js +18 -11
- package/dist/src/commands.d.ts +13 -0
- package/dist/src/commands.js +16812 -8045
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +16817 -8377
- package/dist/src/launcher.d.ts +61 -0
- package/dist/src/launcher.js +77 -11
- package/dist/src/operator-cli.d.ts +2 -0
- package/dist/src/operator-cli.js +17867 -0
- package/dist/src/operator-entry.d.ts +1 -0
- package/dist/src/operator-entry.js +3 -0
- package/dist/src/runner.d.ts +47 -0
- package/dist/src/runner.js +16 -22
- package/dist/src/withMutedConsole.d.ts +2 -0
- package/package.json +21 -8
- package/dist/src/commands/_authority-runs.js +0 -111
- package/dist/src/commands/_operator-view.js +0 -340
- package/dist/src/commands/_preflight.js +0 -478
- package/dist/src/commands/_server-client.js +0 -382
- package/dist/src/commands/_snapshot-upload.js +0 -331
- package/dist/src/commands/_task-picker.js +0 -48
- package/dist/src/commands/browser.js +0 -890
- package/dist/src/commands/connect.js +0 -180
- package/dist/src/commands/inspector.js +0 -256
- package/dist/src/commands/task-report-bug.js +0 -1083
- package/dist/src/report-bug.js +0 -260
|
@@ -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
|
-
|
|
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
|
|
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/
|
|
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
|
|
121
|
-
|
|
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/${
|
|
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
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
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, "
|
|
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, "--
|
|
215
|
+
const pathResult = takeOption(pending, "--dir");
|
|
201
216
|
pending = pathResult.rest;
|
|
202
|
-
requireNoExtraArgs(pending, "
|
|
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
|
|
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, "
|
|
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, "
|
|
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
|
|
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 {
|