@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.
- 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 +15637 -7344
- 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/_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 +51 -0
- package/dist/src/commands/_help-catalog.js +502 -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 +8575 -236
- 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 +880 -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 +17701 -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 +979 -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 +16792 -8055
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +16862 -8450
- package/dist/src/launcher.d.ts +61 -0
- package/dist/src/launcher.js +81 -13
- package/dist/src/operator-cli.d.ts +2 -0
- package/dist/src/operator-cli.js +17837 -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,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 {
|