@h-rig/cli 0.0.6-alpha.1 → 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 +15742 -7203
- 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 +95 -244
- 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 -235
- 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 +214 -245
- package/dist/src/commands/github.d.ts +3 -0
- package/dist/src/commands/github.js +237 -171
- 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 +941 -654
- 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 +17732 -618
- package/dist/src/commands/server.d.ts +3 -0
- package/dist/src/commands/server.js +166 -285
- package/dist/src/commands/setup.d.ts +16 -0
- package/dist/src/commands/setup.js +230 -267
- 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 +120 -1856
- package/dist/src/commands/task.d.ts +35 -0
- package/dist/src/commands/task.js +676 -1183
- 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 +16760 -7779
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +16880 -8223
- 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 +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 +19 -24
- package/dist/src/withMutedConsole.d.ts +2 -0
- package/package.json +21 -7
- package/dist/src/commands/_authority-runs.js +0 -110
- package/dist/src/commands/_operator-view.js +0 -322
- package/dist/src/commands/_preflight.js +0 -460
- package/dist/src/commands/_server-client.js +0 -364
- package/dist/src/commands/_snapshot-upload.js +0 -313
- 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
|
@@ -7,12 +7,19 @@ import { resolve as resolve5 } from "path";
|
|
|
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
|
-
|
|
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 requireNoExtraArgs(args, usage) {
|
|
17
24
|
if (args.length > 0) {
|
|
18
25
|
throw new CliError(`Unexpected arguments: ${args.join(" ")}
|
|
@@ -78,7 +85,7 @@ async function loadRigConfigOrNull(projectRoot) {
|
|
|
78
85
|
|
|
79
86
|
// packages/cli/src/commands/_paths.ts
|
|
80
87
|
import { resolve } from "path";
|
|
81
|
-
import { resolveMonorepoRoot } from "@rig/runtime/
|
|
88
|
+
import { resolveMonorepoRoot } from "@rig/runtime/layout";
|
|
82
89
|
function resolveControlPlaneMonorepoRoot(projectRoot) {
|
|
83
90
|
return resolveMonorepoRoot(projectRoot);
|
|
84
91
|
}
|
|
@@ -99,10 +106,10 @@ function resolveControlPlaneDefinitionRoot(projectRoot) {
|
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
// packages/cli/src/commands/_pi-install.ts
|
|
102
|
-
import { existsSync
|
|
109
|
+
import { existsSync } from "fs";
|
|
103
110
|
import { homedir } from "os";
|
|
104
111
|
import { resolve as resolve2 } from "path";
|
|
105
|
-
var PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
|
|
112
|
+
var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
|
|
106
113
|
async function defaultCommandRunner(command, options = {}) {
|
|
107
114
|
const proc = Bun.spawn(command, { cwd: options.cwd, stdout: "pipe", stderr: "pipe" });
|
|
108
115
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
@@ -141,27 +148,25 @@ async function checkPiRigInstall(input = {}) {
|
|
|
141
148
|
piRig: { ok: true, label: "pi-rig global extension", detail: extensionPath }
|
|
142
149
|
};
|
|
143
150
|
}
|
|
144
|
-
const exists = input.exists ?? existsSync;
|
|
145
151
|
const runner = input.commandRunner ?? defaultCommandRunner;
|
|
146
152
|
const piResult = await safeRun(runner, ["pi", "--version"]);
|
|
147
153
|
const piListResult = piResult.exitCode === 0 ? await safeRun(runner, ["pi", "list"]) : { exitCode: 1, stdout: "", stderr: "" };
|
|
148
|
-
const
|
|
154
|
+
const hasPiRig = piListResult.exitCode === 0 && piListContainsPiRig(`${piListResult.stdout}
|
|
149
155
|
${piListResult.stderr}`);
|
|
150
|
-
const
|
|
151
|
-
const hasPiRig = listedPiRig;
|
|
156
|
+
const hasLegacyBridgeScaffold = !hasPiRig && (input.exists ?? existsSync)(extensionPath);
|
|
152
157
|
return {
|
|
153
158
|
extensionPath,
|
|
154
159
|
pi: {
|
|
155
160
|
ok: piResult.exitCode === 0,
|
|
156
161
|
label: "pi",
|
|
157
162
|
detail: (piResult.stdout || piResult.stderr).trim() || undefined,
|
|
158
|
-
hint: piResult.exitCode === 0 ? undefined : "Install Pi or
|
|
163
|
+
hint: piResult.exitCode === 0 ? undefined : "Install Pi/OMP manually or set RIG_PI_INSTALL_COMMAND before verifying with bare `rig` / Cockpit \u2192 Doctor."
|
|
159
164
|
},
|
|
160
165
|
piRig: {
|
|
161
166
|
ok: hasPiRig,
|
|
162
167
|
label: "pi-rig global extension",
|
|
163
|
-
detail: hasPiRig ? piListResult.stdout.trim() || PI_RIG_PACKAGE_NAME :
|
|
164
|
-
hint: hasPiRig ? undefined :
|
|
168
|
+
detail: hasPiRig ? piListResult.stdout.trim() || PI_RIG_PACKAGE_NAME : hasLegacyBridgeScaffold ? `legacy bridge scaffold at ${extensionPath}` : undefined,
|
|
169
|
+
hint: hasPiRig ? undefined : `Install the Rig OMP extension with \`pi install ${PI_RIG_PACKAGE_NAME}\`, then verify with bare \`rig\` / Cockpit \u2192 Doctor.`
|
|
165
170
|
}
|
|
166
171
|
};
|
|
167
172
|
}
|
|
@@ -171,23 +176,13 @@ async function buildPiSetupChecks(input = {}) {
|
|
|
171
176
|
}
|
|
172
177
|
|
|
173
178
|
// packages/cli/src/commands/_doctor-checks.ts
|
|
174
|
-
import { existsSync as existsSync3, readFileSync as
|
|
179
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
175
180
|
import { resolve as resolve4 } from "path";
|
|
176
181
|
import { isSupportedBunVersion, MIN_SUPPORTED_BUN_VERSION } from "@rig/runtime/control-plane/setup-version";
|
|
177
182
|
|
|
178
183
|
// packages/cli/src/commands/_connection-state.ts
|
|
179
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync
|
|
180
|
-
import { homedir as homedir2 } from "os";
|
|
184
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
181
185
|
import { dirname, resolve as resolve3 } from "path";
|
|
182
|
-
function resolveGlobalConnectionsPath(env = process.env) {
|
|
183
|
-
const explicit = env.RIG_CONNECTIONS_FILE?.trim();
|
|
184
|
-
if (explicit)
|
|
185
|
-
return resolve3(explicit);
|
|
186
|
-
const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
|
|
187
|
-
if (stateDir)
|
|
188
|
-
return resolve3(stateDir, "connections.json");
|
|
189
|
-
return resolve3(homedir2(), ".rig", "connections.json");
|
|
190
|
-
}
|
|
191
186
|
function resolveRepoConnectionPath(projectRoot) {
|
|
192
187
|
return resolve3(projectRoot, ".rig", "state", "connection.json");
|
|
193
188
|
}
|
|
@@ -195,39 +190,10 @@ function readJsonFile(path) {
|
|
|
195
190
|
if (!existsSync2(path))
|
|
196
191
|
return null;
|
|
197
192
|
try {
|
|
198
|
-
return JSON.parse(
|
|
193
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
199
194
|
} catch (error) {
|
|
200
|
-
throw new
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function normalizeConnection(value) {
|
|
204
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
205
|
-
return null;
|
|
206
|
-
const record = value;
|
|
207
|
-
if (record.kind === "local")
|
|
208
|
-
return { kind: "local", mode: "auto" };
|
|
209
|
-
if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
|
|
210
|
-
const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
|
|
211
|
-
return { kind: "remote", baseUrl };
|
|
195
|
+
throw new CliError(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1, { hint: "Fix or delete that file, then re-select a server with `rig server use <alias|local>`." });
|
|
212
196
|
}
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
function readGlobalConnections(options = {}) {
|
|
216
|
-
const path = resolveGlobalConnectionsPath(options.env ?? process.env);
|
|
217
|
-
const payload = readJsonFile(path);
|
|
218
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
219
|
-
return { connections: {} };
|
|
220
|
-
}
|
|
221
|
-
const rawConnections = payload.connections;
|
|
222
|
-
const connections = {};
|
|
223
|
-
if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
|
|
224
|
-
for (const [alias, raw] of Object.entries(rawConnections)) {
|
|
225
|
-
const connection = normalizeConnection(raw);
|
|
226
|
-
if (connection)
|
|
227
|
-
connections[alias] = connection;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return { connections };
|
|
231
197
|
}
|
|
232
198
|
function readRepoConnection(projectRoot) {
|
|
233
199
|
const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
|
|
@@ -240,112 +206,68 @@ function readRepoConnection(projectRoot) {
|
|
|
240
206
|
return {
|
|
241
207
|
selected,
|
|
242
208
|
project: typeof record.project === "string" ? record.project : undefined,
|
|
243
|
-
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined
|
|
209
|
+
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
|
|
210
|
+
serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined,
|
|
211
|
+
serverProjectRootAlias: typeof record.serverProjectRootAlias === "string" && record.serverProjectRootAlias.trim() ? record.serverProjectRootAlias.trim() : undefined,
|
|
212
|
+
serverProjectRootBaseUrl: typeof record.serverProjectRootBaseUrl === "string" && record.serverProjectRootBaseUrl.trim() ? record.serverProjectRootBaseUrl.trim().replace(/\/+$/, "") : undefined
|
|
244
213
|
};
|
|
245
214
|
}
|
|
246
|
-
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
247
|
-
const repo = readRepoConnection(projectRoot);
|
|
248
|
-
if (!repo)
|
|
249
|
-
return null;
|
|
250
|
-
if (repo.selected === "local")
|
|
251
|
-
return { alias: "local", connection: { kind: "local", mode: "auto" } };
|
|
252
|
-
const global = readGlobalConnections(options);
|
|
253
|
-
const connection = global.connections[repo.selected];
|
|
254
|
-
if (!connection) {
|
|
255
|
-
throw new CliError2(`Selected Rig connection "${repo.selected}" was not found. Run \`rig connect list\` or \`rig connect use local\`.`, 1);
|
|
256
|
-
}
|
|
257
|
-
return { alias: repo.selected, connection };
|
|
258
|
-
}
|
|
259
215
|
|
|
260
|
-
// packages/cli/src/commands/
|
|
261
|
-
import {
|
|
262
|
-
|
|
263
|
-
|
|
216
|
+
// packages/cli/src/commands/_inprocess-services.ts
|
|
217
|
+
import {
|
|
218
|
+
beginGitHubDeviceFlow,
|
|
219
|
+
checkGitHubRepoPermissions,
|
|
220
|
+
createGitHubAuthStore,
|
|
221
|
+
listGitHubProjects,
|
|
222
|
+
pollGitHubDeviceFlow,
|
|
223
|
+
resolveGitHubAuthStatus,
|
|
224
|
+
resolveProjectStatusField,
|
|
225
|
+
saveGitHubTokenForProject
|
|
226
|
+
} from "@rig/runtime/control-plane/github/index";
|
|
227
|
+
var scopedGitHubBearerTokens = new Map;
|
|
264
228
|
function cleanToken(value) {
|
|
265
229
|
const trimmed = value?.trim();
|
|
266
230
|
return trimmed ? trimmed : null;
|
|
267
231
|
}
|
|
268
|
-
function
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
function mergeHeaders(headers, authToken) {
|
|
308
|
-
const merged = new Headers(headers);
|
|
309
|
-
if (authToken) {
|
|
310
|
-
merged.set("authorization", `Bearer ${authToken}`);
|
|
311
|
-
}
|
|
312
|
-
return merged;
|
|
313
|
-
}
|
|
314
|
-
function diagnosticMessage(payload) {
|
|
315
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
316
|
-
return null;
|
|
317
|
-
const record = payload;
|
|
318
|
-
const diagnostics = Array.isArray(record.diagnostics) ? record.diagnostics : [];
|
|
319
|
-
const messages = diagnostics.flatMap((entry) => {
|
|
320
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
321
|
-
return [];
|
|
322
|
-
const diagnostic = entry;
|
|
323
|
-
const kind = typeof diagnostic.kind === "string" ? diagnostic.kind : "task-source";
|
|
324
|
-
const message = typeof diagnostic.message === "string" ? diagnostic.message : null;
|
|
325
|
-
return message ? [`${kind}: ${message}`] : [];
|
|
326
|
-
});
|
|
327
|
-
return messages.length > 0 ? messages.join("; ") : null;
|
|
328
|
-
}
|
|
329
|
-
async function requestServerJson(context, pathname, init = {}) {
|
|
330
|
-
const server = await ensureServerForCli(context.projectRoot);
|
|
331
|
-
const response = await fetch(`${server.baseUrl}${pathname}`, {
|
|
332
|
-
...init,
|
|
333
|
-
headers: mergeHeaders(init.headers, server.authToken)
|
|
334
|
-
});
|
|
335
|
-
const text = await response.text();
|
|
336
|
-
const payload = text.trim().length > 0 ? (() => {
|
|
337
|
-
try {
|
|
338
|
-
return JSON.parse(text);
|
|
339
|
-
} catch {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
})() : null;
|
|
343
|
-
if (!response.ok) {
|
|
344
|
-
const diagnostics = diagnosticMessage(payload);
|
|
345
|
-
const detail = diagnostics ?? (text || response.statusText);
|
|
346
|
-
throw new CliError2(`Rig server request failed (${response.status}): ${detail}`, 1);
|
|
347
|
-
}
|
|
348
|
-
return payload;
|
|
232
|
+
function cleanString(value) {
|
|
233
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
234
|
+
}
|
|
235
|
+
function oauthClientId() {
|
|
236
|
+
return cleanToken(process.env.RIG_GITHUB_OAUTH_CLIENT_ID);
|
|
237
|
+
}
|
|
238
|
+
async function getGitHubAuthStatusInProcess(context) {
|
|
239
|
+
return { ok: true, ...resolveGitHubAuthStatus({ projectRoot: context.projectRoot, oauthConfigured: Boolean(oauthClientId()) }) };
|
|
240
|
+
}
|
|
241
|
+
async function requestGitHubAuthJsonInProcess(context, pathname, init = {}) {
|
|
242
|
+
const method = (init.method ?? "GET").toUpperCase();
|
|
243
|
+
if (pathname === "/api/github/auth/status")
|
|
244
|
+
return getGitHubAuthStatusInProcess(context);
|
|
245
|
+
if (pathname === "/api/github/repo/permissions") {
|
|
246
|
+
return checkGitHubRepoPermissions({ projectRoot: context.projectRoot, oauthConfigured: Boolean(oauthClientId()) });
|
|
247
|
+
}
|
|
248
|
+
if (pathname === "/api/github/auth/device/start" && method === "POST") {
|
|
249
|
+
const clientId = oauthClientId();
|
|
250
|
+
if (!clientId)
|
|
251
|
+
return { ok: false, oauthConfigured: false, error: "RIG_GITHUB_OAUTH_CLIENT_ID is not configured." };
|
|
252
|
+
const body = init.body ? JSON.parse(String(init.body)) : {};
|
|
253
|
+
return beginGitHubDeviceFlow({
|
|
254
|
+
projectRoot: context.projectRoot,
|
|
255
|
+
clientId,
|
|
256
|
+
scope: cleanString(body.scope) ?? undefined,
|
|
257
|
+
selectedRepo: cleanString(body.repoSlug)
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
if (pathname === "/api/github/auth/device/poll" && method === "POST") {
|
|
261
|
+
const clientId = oauthClientId();
|
|
262
|
+
if (!clientId)
|
|
263
|
+
return { ok: false, oauthConfigured: false, error: "RIG_GITHUB_OAUTH_CLIENT_ID is not configured." };
|
|
264
|
+
const body = init.body ? JSON.parse(String(init.body)) : {};
|
|
265
|
+
const pollId = cleanString(body.pollId);
|
|
266
|
+
if (!pollId)
|
|
267
|
+
return { ok: false, status: "error", error: "pollId is required" };
|
|
268
|
+
return pollGitHubDeviceFlow({ projectRoot: context.projectRoot, clientId, pollId, selectedRepo: cleanString(body.repoSlug) });
|
|
269
|
+
}
|
|
270
|
+
throw new Error(`No in-process GitHub auth API for ${method} ${pathname}`);
|
|
349
271
|
}
|
|
350
272
|
|
|
351
273
|
// packages/cli/src/commands/_doctor-checks.ts
|
|
@@ -367,23 +289,6 @@ function isAuthenticated(payload) {
|
|
|
367
289
|
const record = payload;
|
|
368
290
|
return record.signedIn === true || record.authenticated === true || record.status === "authenticated" || record.ok === true && typeof record.login === "string" && record.login.trim().length > 0;
|
|
369
291
|
}
|
|
370
|
-
function repoSlugFromConfig(config) {
|
|
371
|
-
const project = config?.project;
|
|
372
|
-
if (project && typeof project === "object" && !Array.isArray(project)) {
|
|
373
|
-
const record = project;
|
|
374
|
-
if (typeof record.repo === "string" && /^([^/\s]+)\/([^/\s]+)$/.test(record.repo))
|
|
375
|
-
return record.repo;
|
|
376
|
-
if (typeof record.name === "string" && /^([^/\s]+)\/([^/\s]+)$/.test(record.name))
|
|
377
|
-
return record.name;
|
|
378
|
-
}
|
|
379
|
-
const taskSource = config?.taskSource;
|
|
380
|
-
if (taskSource && typeof taskSource === "object" && !Array.isArray(taskSource)) {
|
|
381
|
-
const source = taskSource;
|
|
382
|
-
if (typeof source.owner === "string" && typeof source.repo === "string")
|
|
383
|
-
return `${source.owner}/${source.repo}`;
|
|
384
|
-
}
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
292
|
function loadFallbackConfig(projectRoot) {
|
|
388
293
|
const candidates = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
389
294
|
for (const name of candidates) {
|
|
@@ -391,7 +296,7 @@ function loadFallbackConfig(projectRoot) {
|
|
|
391
296
|
if (!existsSync3(path))
|
|
392
297
|
continue;
|
|
393
298
|
try {
|
|
394
|
-
const source =
|
|
299
|
+
const source = readFileSync2(path, "utf8");
|
|
395
300
|
if (name.endsWith(".json"))
|
|
396
301
|
return JSON.parse(source);
|
|
397
302
|
const owner = source.match(/owner\s*:\s*["']([^"']+)["']/)?.[1];
|
|
@@ -410,14 +315,11 @@ function loadFallbackConfig(projectRoot) {
|
|
|
410
315
|
}
|
|
411
316
|
return null;
|
|
412
317
|
}
|
|
413
|
-
function projectStatusSlug(projectRoot, config) {
|
|
414
|
-
return readRepoConnection(projectRoot)?.project ?? repoSlugFromConfig(config);
|
|
415
|
-
}
|
|
416
318
|
function githubProjectsCheck(config) {
|
|
417
319
|
const github = config?.github;
|
|
418
320
|
const projects = github?.projects;
|
|
419
321
|
if (!projects?.enabled) {
|
|
420
|
-
return check("github-projects", "GitHub Projects status sync", "warn", "disabled or not configured", "
|
|
322
|
+
return check("github-projects", "GitHub Projects status sync", "warn", "disabled or not configured", "Current OMP flow does not require GitHub Projects status sync; configure github.projects manually when Project status sync should be authoritative.");
|
|
421
323
|
}
|
|
422
324
|
if (projects.projectId && projects.statusFieldId) {
|
|
423
325
|
return check("github-projects", "GitHub Projects status sync", "pass", `project ${projects.projectId}`);
|
|
@@ -442,16 +344,6 @@ function permissionAllowsPr(payload) {
|
|
|
442
344
|
}
|
|
443
345
|
return null;
|
|
444
346
|
}
|
|
445
|
-
function labelsReady(payload) {
|
|
446
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
447
|
-
return null;
|
|
448
|
-
const record = payload;
|
|
449
|
-
if (record.ok === true || record.ready === true || record.labelsReady === true)
|
|
450
|
-
return true;
|
|
451
|
-
if (record.ok === false || record.ready === false || record.labelsReady === false)
|
|
452
|
-
return false;
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
455
347
|
function prMergeCheck(config) {
|
|
456
348
|
const pr = config?.pr;
|
|
457
349
|
const merge = config?.merge;
|
|
@@ -465,89 +357,48 @@ async function runRigDoctorChecks(options) {
|
|
|
465
357
|
const checks = [];
|
|
466
358
|
const which = options.which ?? ((binary) => Bun.which(binary));
|
|
467
359
|
const bunVersion = options.bunVersion ?? Bun.version;
|
|
468
|
-
const request = options.requestJson ?? ((pathname, init) =>
|
|
360
|
+
const request = options.requestJson ?? ((pathname, init) => requestGitHubAuthJsonInProcess({ projectRoot }, pathname, init));
|
|
469
361
|
const loadConfig = options.loadConfig ?? loadRigConfigOrNull;
|
|
362
|
+
const progress = options.onProgress ?? (() => {});
|
|
363
|
+
progress("Checking local toolchain\u2026");
|
|
470
364
|
checks.push(check("bun", `bun >= ${MIN_SUPPORTED_BUN_VERSION}`, isSupportedBunVersion(bunVersion) ? "pass" : "fail", `found ${bunVersion}`, `Install Bun ${MIN_SUPPORTED_BUN_VERSION} or newer.`), check("git", "git", which("git") ? "pass" : "fail", which("git") ?? undefined, "Install git and ensure it is on PATH."), check("jq", "jq", which("jq") ? "pass" : "warn", which("jq") ?? undefined, "Install jq (for example `brew install jq`)."));
|
|
365
|
+
progress("Loading rig.config\u2026");
|
|
471
366
|
const loadedConfig = await loadConfig(projectRoot).catch(() => null);
|
|
472
367
|
const config = loadedConfig ?? loadFallbackConfig(projectRoot);
|
|
473
368
|
const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync3(resolve4(projectRoot, name)));
|
|
474
|
-
checks.push(config ? check("config", "rig.config loadable", "pass") : check("config", "rig.config loadable", hasConfigFile ? "fail" : "fail", hasConfigFile ? "config file exists but failed to load" : "missing rig.config.ts/json", "
|
|
369
|
+
checks.push(config ? check("config", "rig.config loadable", "pass") : check("config", "rig.config loadable", hasConfigFile ? "fail" : "fail", hasConfigFile ? "config file exists but failed to load" : "missing rig.config.ts/json", "Create/fix rig.config.ts or use the OMP cockpit Start tab to scaffold one."));
|
|
475
370
|
const taskSourceKind = config?.taskSource?.kind;
|
|
476
371
|
checks.push(taskSourceKind ? check("task-source", "task source configured", "pass", taskSourceKind) : check("task-source", "task source configured", "fail", "missing taskSource", "Configure taskSource in rig.config.ts."));
|
|
477
372
|
const repo = readRepoConnection(projectRoot);
|
|
478
|
-
checks.push(repo ? check("project-link", "repo selected
|
|
479
|
-
const selected = (() => {
|
|
480
|
-
try {
|
|
481
|
-
return resolveSelectedConnection(projectRoot);
|
|
482
|
-
} catch {
|
|
483
|
-
return null;
|
|
484
|
-
}
|
|
485
|
-
})();
|
|
486
|
-
checks.push(selected ? check("connection", "selected server connection", "pass", selected.connection.kind === "remote" ? selected.connection.baseUrl : "local auto") : check("connection", "selected server connection", repo ? "fail" : "warn", repo ? "selected alias is missing" : "will auto-start local server", repo ? "Run `rig connect list` and `rig connect use <alias|local>`." : undefined));
|
|
487
|
-
let server = null;
|
|
373
|
+
checks.push(repo ? check("project-link", "repo selected for local setup", repo.project ? "pass" : "warn", `${repo.selected}${repo.project ? ` -> ${repo.project}` : ""}`, "Run `rig init --repo owner/repo` if this project should use GitHub Issues.") : check("project-link", "repo selected for local setup", "warn", "missing .rig/state/connection.json", "Current UX can run without this compatibility file; `rig init` recreates it for GitHub-backed projects."));
|
|
488
374
|
try {
|
|
489
|
-
|
|
490
|
-
|
|
375
|
+
progress("Checking GitHub auth\u2026");
|
|
376
|
+
const auth = await request("/api/github/auth/status");
|
|
377
|
+
checks.push(isAuthenticated(auth) ? check("github-auth", "GitHub auth", "pass") : check("github-auth", "GitHub auth", "fail", "not authenticated", "Run `rig github auth import-gh` or `rig github auth token --token <token>`."));
|
|
491
378
|
} catch (error) {
|
|
492
|
-
checks.push(check("
|
|
379
|
+
checks.push(check("github-auth", "GitHub auth", "fail", errorMessage(error), "Authenticate GitHub through Rig."));
|
|
493
380
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
try {
|
|
502
|
-
const auth = await request("/api/github/auth/status");
|
|
503
|
-
checks.push(isAuthenticated(auth) ? check("github-auth", "GitHub auth", "pass") : check("github-auth", "GitHub auth", "fail", "not authenticated", "Run `rig github auth import-gh` or `rig github auth token --token <token>`."));
|
|
504
|
-
} catch (error) {
|
|
505
|
-
checks.push(check("github-auth", "GitHub auth", "fail", errorMessage(error), "Authenticate GitHub through Rig and ensure the server exposes auth status."));
|
|
506
|
-
}
|
|
507
|
-
try {
|
|
508
|
-
const permissions = await request("/api/github/repo/permissions");
|
|
509
|
-
const allowed = permissionAllowsPr(permissions);
|
|
510
|
-
checks.push(allowed === true ? check("github-repo-permissions", "GitHub repo PR permissions", "pass", JSON.stringify(permissions).slice(0, 180)) : allowed === false ? check("github-repo-permissions", "GitHub repo PR permissions", "fail", JSON.stringify(permissions).slice(0, 180), "Grant the selected GitHub token permission to push branches, open PRs, and merge according to repo rules.") : check("github-repo-permissions", "GitHub repo PR permissions", "warn", JSON.stringify(permissions).slice(0, 180), "Confirm the selected token can push branches and open PRs."));
|
|
511
|
-
} catch (error) {
|
|
512
|
-
checks.push(check("github-repo-permissions", "GitHub repo PR permissions", "warn", errorMessage(error), "Ensure the server exposes repo permission checks and the token can open PRs."));
|
|
513
|
-
}
|
|
514
|
-
try {
|
|
515
|
-
const labels = await request("/api/workspace/task-labels");
|
|
516
|
-
const ready = labelsReady(labels);
|
|
517
|
-
checks.push(ready === false ? check("task-labels", "GitHub issue labels", "fail", JSON.stringify(labels).slice(0, 180), "Let Rig create required labels or create the configured lifecycle labels manually.") : check("task-labels", "GitHub issue labels", ready === true ? "pass" : "warn", JSON.stringify(labels).slice(0, 180), "Confirm required Rig lifecycle labels exist."));
|
|
518
|
-
} catch (error) {
|
|
519
|
-
checks.push(check("task-labels", "GitHub issue labels", "warn", errorMessage(error), "Run `rig init`/`rig doctor` after label setup is wired on the server."));
|
|
520
|
-
}
|
|
521
|
-
try {
|
|
522
|
-
const projection = await request("/api/workspace/task-projection");
|
|
523
|
-
checks.push(check("task-projection", "task projection", "pass", JSON.stringify(projection).slice(0, 180)));
|
|
524
|
-
} catch (error) {
|
|
525
|
-
checks.push(check("task-projection", "task projection", "warn", errorMessage(error), "Refresh task projection with `rig task list` or fix the task source."));
|
|
526
|
-
}
|
|
527
|
-
const slug = projectStatusSlug(projectRoot, config);
|
|
528
|
-
if (slug) {
|
|
529
|
-
try {
|
|
530
|
-
const project = await request(`/api/projects/${encodeURIComponent(slug)}`);
|
|
531
|
-
checks.push(check("remote-checkout", "server project checkout", "pass", JSON.stringify(project).slice(0, 180)));
|
|
532
|
-
} catch (error) {
|
|
533
|
-
checks.push(check("remote-checkout", "server project checkout", "warn", errorMessage(error), "Run `rig init --yes --repo owner/repo` to register/link the server project checkout."));
|
|
534
|
-
}
|
|
535
|
-
} else {
|
|
536
|
-
checks.push(check("remote-checkout", "server project checkout", "warn", "repo slug unknown", "Set project.repo or run `rig init --repo owner/repo`."));
|
|
537
|
-
}
|
|
381
|
+
try {
|
|
382
|
+
progress("Checking GitHub repo permissions\u2026");
|
|
383
|
+
const permissions = await request("/api/github/repo/permissions");
|
|
384
|
+
const allowed = permissionAllowsPr(permissions);
|
|
385
|
+
checks.push(allowed === true ? check("github-repo-permissions", "GitHub repo PR permissions", "pass", JSON.stringify(permissions).slice(0, 180)) : allowed === false ? check("github-repo-permissions", "GitHub repo PR permissions", "fail", JSON.stringify(permissions).slice(0, 180), "Grant the selected GitHub token permission to push branches, open PRs, and merge according to repo rules.") : check("github-repo-permissions", "GitHub repo PR permissions", "warn", JSON.stringify(permissions).slice(0, 180), "Confirm the selected token can push branches and open PRs."));
|
|
386
|
+
} catch (error) {
|
|
387
|
+
checks.push(check("github-repo-permissions", "GitHub repo PR permissions", "warn", errorMessage(error), "Ensure the token can open PRs."));
|
|
538
388
|
}
|
|
539
389
|
if (taskSourceKind === "github-issues") {
|
|
540
390
|
checks.push(check("gh", "gh CLI fallback", which("gh") ? "pass" : "warn", which("gh") ?? undefined, "Install gh for local/dev GitHub fallback operations."));
|
|
541
391
|
}
|
|
542
392
|
checks.push(githubProjectsCheck(config));
|
|
543
393
|
checks.push(prMergeCheck(config));
|
|
394
|
+
progress("Checking Pi installation\u2026");
|
|
544
395
|
const piChecks = await (options.piChecks ?? (() => buildPiSetupChecks()))().catch((error) => [{
|
|
545
396
|
ok: false,
|
|
546
397
|
label: "pi/pi-rig checks",
|
|
547
398
|
hint: errorMessage(error)
|
|
548
399
|
}]);
|
|
549
400
|
for (const pi of piChecks) {
|
|
550
|
-
checks.push(check(pi.label === "pi" ? "pi" : "pi-rig", pi.label, pi.ok ? "pass" : "warn", pi.detail, pi.hint ?? (pi.ok ? undefined : "
|
|
401
|
+
checks.push(check(pi.label === "pi" ? "pi" : "pi-rig", pi.label, pi.ok ? "pass" : "warn", pi.detail, pi.hint ?? (pi.ok ? undefined : "Install Pi/OMP and the Rig extension, then use bare `rig` or Cockpit \u2192 Doctor to verify.")));
|
|
551
402
|
}
|
|
552
403
|
return checks;
|
|
553
404
|
}
|
|
@@ -564,12 +415,130 @@ function countDoctorFailures(checks) {
|
|
|
564
415
|
return checks.filter((entry) => entry.status === "fail").length;
|
|
565
416
|
}
|
|
566
417
|
|
|
418
|
+
// packages/cli/src/commands/_async-ui.ts
|
|
419
|
+
import pc from "picocolors";
|
|
420
|
+
|
|
421
|
+
// packages/cli/src/commands/_spinner.ts
|
|
422
|
+
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
423
|
+
function createTtySpinner(input) {
|
|
424
|
+
const output = input.output ?? process.stdout;
|
|
425
|
+
const isTty = output.isTTY === true;
|
|
426
|
+
const frames = input.frames && input.frames.length > 0 ? input.frames : SPINNER_FRAMES;
|
|
427
|
+
let label = input.label;
|
|
428
|
+
let frame = 0;
|
|
429
|
+
let paused = false;
|
|
430
|
+
let stopped = false;
|
|
431
|
+
let lastPrintedLabel = "";
|
|
432
|
+
const render = () => {
|
|
433
|
+
if (stopped || paused)
|
|
434
|
+
return;
|
|
435
|
+
if (!isTty) {
|
|
436
|
+
if (label !== lastPrintedLabel) {
|
|
437
|
+
output.write(`${label}
|
|
438
|
+
`);
|
|
439
|
+
lastPrintedLabel = label;
|
|
440
|
+
}
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
frame = (frame + 1) % frames.length;
|
|
444
|
+
const glyph = frames[frame] ?? frames[0] ?? "";
|
|
445
|
+
output.write(`\r\x1B[2K${input.styleFrame ? input.styleFrame(glyph) : glyph} ${label}`);
|
|
446
|
+
};
|
|
447
|
+
const clearLine = () => {
|
|
448
|
+
if (isTty)
|
|
449
|
+
output.write("\r\x1B[2K");
|
|
450
|
+
};
|
|
451
|
+
render();
|
|
452
|
+
const timer = isTty ? setInterval(render, input.intervalMs ?? 16) : null;
|
|
453
|
+
return {
|
|
454
|
+
setLabel(next) {
|
|
455
|
+
label = next;
|
|
456
|
+
render();
|
|
457
|
+
},
|
|
458
|
+
pause() {
|
|
459
|
+
paused = true;
|
|
460
|
+
clearLine();
|
|
461
|
+
},
|
|
462
|
+
resume() {
|
|
463
|
+
if (stopped)
|
|
464
|
+
return;
|
|
465
|
+
paused = false;
|
|
466
|
+
render();
|
|
467
|
+
},
|
|
468
|
+
stop(finalLine) {
|
|
469
|
+
if (stopped)
|
|
470
|
+
return;
|
|
471
|
+
stopped = true;
|
|
472
|
+
if (timer)
|
|
473
|
+
clearInterval(timer);
|
|
474
|
+
clearLine();
|
|
475
|
+
if (finalLine)
|
|
476
|
+
output.write(`${finalLine}
|
|
477
|
+
`);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// packages/cli/src/commands/_async-ui.ts
|
|
483
|
+
var FRAMES = ["\u25D0", "\u25D3", "\u25D1", "\u25D2"];
|
|
484
|
+
var DONE_SYMBOL = pc.green("\u25C7");
|
|
485
|
+
var FAIL_SYMBOL = pc.red("\u25A0");
|
|
486
|
+
var activeUpdate = null;
|
|
487
|
+
async function withSpinner(label, work, options = {}) {
|
|
488
|
+
if (options.outputMode === "json") {
|
|
489
|
+
return work(() => {
|
|
490
|
+
return;
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
if (activeUpdate) {
|
|
494
|
+
activeUpdate(label);
|
|
495
|
+
return work(activeUpdate);
|
|
496
|
+
}
|
|
497
|
+
const output = options.output ?? process.stderr;
|
|
498
|
+
const isTty = output.isTTY === true;
|
|
499
|
+
let lastLabel = label;
|
|
500
|
+
if (!isTty) {
|
|
501
|
+
output.write(`${label}
|
|
502
|
+
`);
|
|
503
|
+
const update2 = (next) => {
|
|
504
|
+
lastLabel = next;
|
|
505
|
+
};
|
|
506
|
+
activeUpdate = update2;
|
|
507
|
+
try {
|
|
508
|
+
return await work(update2);
|
|
509
|
+
} finally {
|
|
510
|
+
activeUpdate = null;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const spinner = createTtySpinner({
|
|
514
|
+
label,
|
|
515
|
+
output,
|
|
516
|
+
frames: FRAMES,
|
|
517
|
+
styleFrame: (frame) => pc.cyan(frame)
|
|
518
|
+
});
|
|
519
|
+
const update = (next) => {
|
|
520
|
+
lastLabel = next;
|
|
521
|
+
spinner.setLabel(next);
|
|
522
|
+
};
|
|
523
|
+
activeUpdate = update;
|
|
524
|
+
try {
|
|
525
|
+
const result = await work(update);
|
|
526
|
+
spinner.stop(options.doneLabel ? `${DONE_SYMBOL} ${options.doneLabel}` : undefined);
|
|
527
|
+
return result;
|
|
528
|
+
} catch (error) {
|
|
529
|
+
spinner.stop(`${FAIL_SYMBOL} ${lastLabel}`);
|
|
530
|
+
throw error;
|
|
531
|
+
} finally {
|
|
532
|
+
activeUpdate = null;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
567
536
|
// packages/cli/src/commands/setup.ts
|
|
568
537
|
async function executeSetup(context, args) {
|
|
569
538
|
const [command = "check", ...rest] = args;
|
|
570
539
|
switch (command) {
|
|
571
540
|
case "bootstrap":
|
|
572
|
-
requireNoExtraArgs(rest, "
|
|
541
|
+
requireNoExtraArgs(rest, "rig setup bootstrap");
|
|
573
542
|
{
|
|
574
543
|
const hostBash = Bun.which("bash") || "/bin/bash";
|
|
575
544
|
const env = { ...process.env };
|
|
@@ -587,32 +556,26 @@ async function executeSetup(context, args) {
|
|
|
587
556
|
});
|
|
588
557
|
const exitCode = await proc.exited;
|
|
589
558
|
if (exitCode !== 0) {
|
|
590
|
-
throw new
|
|
559
|
+
throw new CliError(`Command failed (${exitCode}): ${hostBash} ./bootstrap.sh`, exitCode);
|
|
591
560
|
}
|
|
592
561
|
}
|
|
593
562
|
return { ok: true, group: "setup", command };
|
|
594
563
|
case "check":
|
|
595
|
-
requireNoExtraArgs(rest, `
|
|
564
|
+
requireNoExtraArgs(rest, `rig setup ${command}`);
|
|
596
565
|
{
|
|
597
|
-
const checks = await withMutedConsole(context.outputMode === "json", () => runSetupCheck(context.projectRoot));
|
|
566
|
+
const checks = await withMutedConsole(context.outputMode === "json", () => runSetupCheck(context.projectRoot, context.outputMode));
|
|
598
567
|
return { ok: true, group: "setup", command, details: { checks, failures: countDoctorFailures(checks) } };
|
|
599
568
|
}
|
|
600
569
|
case "setup":
|
|
601
|
-
requireNoExtraArgs(rest, "
|
|
570
|
+
requireNoExtraArgs(rest, "rig setup setup");
|
|
602
571
|
withMutedConsole(context.outputMode === "json", () => runSetupInit(context.projectRoot));
|
|
603
572
|
return { ok: true, group: "setup", command };
|
|
604
573
|
case "preflight":
|
|
605
|
-
requireNoExtraArgs(rest, "
|
|
606
|
-
await withMutedConsole(context.outputMode === "json", () => runSetupPreflight(context.projectRoot));
|
|
607
|
-
return { ok: true, group: "setup", command };
|
|
608
|
-
case "install-agent-shell":
|
|
609
|
-
requireNoExtraArgs(rest, "bun run rig setup install-agent-shell");
|
|
610
|
-
if (context.outputMode === "text") {
|
|
611
|
-
console.log("install-agent-shell is deprecated. Runtime shells now use compiled rig-agent directly.");
|
|
612
|
-
}
|
|
574
|
+
requireNoExtraArgs(rest, "rig setup preflight");
|
|
575
|
+
await withMutedConsole(context.outputMode === "json", () => runSetupPreflight(context.projectRoot, context.outputMode));
|
|
613
576
|
return { ok: true, group: "setup", command };
|
|
614
577
|
default:
|
|
615
|
-
throw new
|
|
578
|
+
throw new CliError(`Unknown setup command: ${command}`, 1, { hint: "Run `rig setup --help` \u2014 commands are bootstrap|check|preflight." });
|
|
616
579
|
}
|
|
617
580
|
}
|
|
618
581
|
function formatTaskSourceKinds(kinds) {
|
|
@@ -646,17 +609,17 @@ function runSetupInit(projectRoot) {
|
|
|
646
609
|
}
|
|
647
610
|
console.log("Harness directories ready.");
|
|
648
611
|
}
|
|
649
|
-
async function runSetupCheck(projectRoot) {
|
|
650
|
-
const doctorChecks = await runRigDoctorChecks({ projectRoot });
|
|
612
|
+
async function runSetupCheck(projectRoot, outputMode = "text") {
|
|
613
|
+
const doctorChecks = await withSpinner("Running setup checks\u2026", (update) => runRigDoctorChecks({ projectRoot, onProgress: update }), { outputMode });
|
|
651
614
|
console.log(formatDoctorChecks(doctorChecks));
|
|
652
615
|
const failures = countDoctorFailures(doctorChecks);
|
|
653
616
|
if (failures > 0) {
|
|
654
|
-
throw new
|
|
617
|
+
throw new CliError(`Setup check failed (${failures} failing doctor check${failures === 1 ? "" : "s"}).`, 1, { hint: "Legacy setup diagnostics failed; for current UX run bare `rig` and open Cockpit \u2192 Doctor for remediation details." });
|
|
655
618
|
}
|
|
656
619
|
return doctorChecks;
|
|
657
620
|
}
|
|
658
|
-
async function runSetupPreflight(projectRoot) {
|
|
659
|
-
await runSetupCheck(projectRoot);
|
|
621
|
+
async function runSetupPreflight(projectRoot, outputMode = "text") {
|
|
622
|
+
await runSetupCheck(projectRoot, outputMode);
|
|
660
623
|
const validationRoot = resolve5(resolveControlPlaneDefinitionRoot(projectRoot), "validation");
|
|
661
624
|
if (existsSync4(validationRoot)) {
|
|
662
625
|
const validators = readdirSync(validationRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|