@h-rig/cli 0.0.6-alpha.25 → 0.0.6-alpha.27
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/dist/bin/rig.js +435 -226
- package/dist/src/commands/_cli-format.js +71 -13
- package/dist/src/commands/_help-catalog.js +203 -0
- package/dist/src/commands/connect.js +131 -23
- package/dist/src/commands/run.js +20 -6
- package/dist/src/commands/server.js +206 -8
- package/dist/src/commands/task.js +32 -10
- package/dist/src/commands.js +435 -226
- package/dist/src/index.js +435 -226
- package/package.json +6 -6
package/dist/bin/rig.js
CHANGED
|
@@ -5316,11 +5316,170 @@ Usage: rig init`, 1);
|
|
|
5316
5316
|
}
|
|
5317
5317
|
|
|
5318
5318
|
// packages/cli/src/commands/connect.ts
|
|
5319
|
-
|
|
5319
|
+
import { cancel as cancel2, isCancel as isCancel2, select as select2 } from "@clack/prompts";
|
|
5320
|
+
|
|
5321
|
+
// packages/cli/src/commands/_cli-format.ts
|
|
5322
|
+
import pc3 from "picocolors";
|
|
5323
|
+
function stringField(record, key, fallback = "") {
|
|
5324
|
+
const value = record[key];
|
|
5325
|
+
return typeof value === "string" && value.trim() ? value.trim() : fallback;
|
|
5326
|
+
}
|
|
5327
|
+
function arrayField(record, key) {
|
|
5328
|
+
const value = record[key];
|
|
5329
|
+
return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" && entry.trim() ? [entry.trim()] : []) : [];
|
|
5330
|
+
}
|
|
5331
|
+
function rawObject(record) {
|
|
5332
|
+
const raw = record.raw;
|
|
5333
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
5334
|
+
}
|
|
5335
|
+
function truncate(value, width) {
|
|
5336
|
+
if (value.length <= width)
|
|
5337
|
+
return value;
|
|
5338
|
+
if (width <= 1)
|
|
5339
|
+
return "\u2026";
|
|
5340
|
+
return `${value.slice(0, width - 1)}\u2026`;
|
|
5341
|
+
}
|
|
5342
|
+
function pad(value, width) {
|
|
5343
|
+
return value.length >= width ? value : `${value}${" ".repeat(width - value.length)}`;
|
|
5344
|
+
}
|
|
5345
|
+
function statusColor(status) {
|
|
5346
|
+
const normalized = status.toLowerCase();
|
|
5347
|
+
if (["completed", "merged", "closed", "done", "accepted", "pass", "selected"].includes(normalized))
|
|
5348
|
+
return pc3.green;
|
|
5349
|
+
if (["failed", "needs_attention", "needs-attention", "blocked", "error"].includes(normalized))
|
|
5350
|
+
return pc3.red;
|
|
5351
|
+
if (["running", "reviewing", "validating", "in_progress", "in-progress", "remote"].includes(normalized))
|
|
5352
|
+
return pc3.cyan;
|
|
5353
|
+
if (["ready", "open", "queued", "created", "preparing", "local"].includes(normalized))
|
|
5354
|
+
return pc3.yellow;
|
|
5355
|
+
return pc3.dim;
|
|
5356
|
+
}
|
|
5357
|
+
function formatStatusPill(status) {
|
|
5358
|
+
const label = status || "unknown";
|
|
5359
|
+
return statusColor(label)(`\u25CF ${label}`);
|
|
5360
|
+
}
|
|
5361
|
+
function formatSection(title, subtitle) {
|
|
5362
|
+
return `${pc3.bold(pc3.cyan("\u25C6"))} ${pc3.bold(title)}${subtitle ? pc3.dim(` \u2014 ${subtitle}`) : ""}`;
|
|
5363
|
+
}
|
|
5364
|
+
function formatSuccessCard(title, rows = []) {
|
|
5365
|
+
const body = rows.filter(([, value]) => value !== undefined && value !== null && String(value).length > 0).map(([key, value]) => `${pc3.dim("\u2502")} ${pc3.dim(key.padEnd(9))} ${value}`);
|
|
5366
|
+
return [formatSection(title), ...body].join(`
|
|
5367
|
+
`);
|
|
5368
|
+
}
|
|
5369
|
+
function formatNextSteps(steps) {
|
|
5370
|
+
if (steps.length === 0)
|
|
5371
|
+
return [];
|
|
5372
|
+
return [pc3.bold("Next"), ...steps.map((step) => `${pc3.dim("\u203A")} ${step}`)];
|
|
5373
|
+
}
|
|
5374
|
+
function formatTaskList(tasks, options = {}) {
|
|
5375
|
+
if (options.raw)
|
|
5376
|
+
return tasks.map((task) => JSON.stringify(task)).join(`
|
|
5377
|
+
`);
|
|
5378
|
+
if (tasks.length === 0)
|
|
5379
|
+
return [formatSection("Tasks", "none found"), ...formatNextSteps(["Try `rig server status` to confirm the selected server.", "Relax filters or run `rig task run --title ... --initial-prompt ...` for ad hoc work."])].join(`
|
|
5380
|
+
`);
|
|
5381
|
+
const rows = tasks.map((task) => {
|
|
5382
|
+
const raw = rawObject(task);
|
|
5383
|
+
const id = stringField(task, "id", "<unknown>");
|
|
5384
|
+
const status = stringField(task, "status", "unknown");
|
|
5385
|
+
const title = stringField(task, "title", "Untitled task");
|
|
5386
|
+
const source = stringField(task, "source", stringField(raw, "source", ""));
|
|
5387
|
+
const labels = arrayField(task, "labels").length > 0 ? arrayField(task, "labels") : arrayField(raw, "labels");
|
|
5388
|
+
return { id, status, title, source, labels };
|
|
5389
|
+
});
|
|
5390
|
+
const idWidth = Math.min(18, Math.max(4, ...rows.map((row) => row.id.length)));
|
|
5391
|
+
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
5392
|
+
const header = `${pc3.bold(pad("TASK", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
5393
|
+
const body = rows.map((row) => {
|
|
5394
|
+
const labels = row.labels.length > 0 ? pc3.dim(` ${row.labels.slice(0, 4).map((label) => `#${label}`).join(" ")}`) : "";
|
|
5395
|
+
const source = row.source ? pc3.dim(` ${row.source}`) : "";
|
|
5396
|
+
return [
|
|
5397
|
+
pc3.bold(pad(truncate(row.id, idWidth), idWidth)),
|
|
5398
|
+
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
5399
|
+
`${row.title}${labels}${source}`
|
|
5400
|
+
].join(" ");
|
|
5401
|
+
});
|
|
5402
|
+
return [formatSection("Tasks", `${rows.length} shown`), header, ...body, "", ...formatNextSteps(["Run one: `rig task run <id>` or `rig task run --next`", "Attach later: `rig run attach <run-id> --follow`"])].join(`
|
|
5403
|
+
`);
|
|
5404
|
+
}
|
|
5405
|
+
function formatRunList(runs, options = {}) {
|
|
5406
|
+
if (runs.length === 0) {
|
|
5407
|
+
return [
|
|
5408
|
+
formatSection("Runs", "none recorded"),
|
|
5409
|
+
options.source === "server" ? pc3.dim("No runs recorded on the selected Rig server.") : pc3.dim("No runs recorded in .rig/runs."),
|
|
5410
|
+
"",
|
|
5411
|
+
...formatNextSteps(["Start one: `rig task run --next`", "Check server: `rig server status`"])
|
|
5412
|
+
].join(`
|
|
5413
|
+
`);
|
|
5414
|
+
}
|
|
5415
|
+
const rows = runs.map((run) => {
|
|
5416
|
+
const runId = stringField(run, "runId", stringField(run, "id", "(unknown-run)"));
|
|
5417
|
+
const status = stringField(run, "status", "unknown");
|
|
5418
|
+
const taskId = stringField(run, "taskId", "");
|
|
5419
|
+
const title = stringField(run, "title", taskId || "(untitled)");
|
|
5420
|
+
const runtime = stringField(run, "runtimeAdapter", "");
|
|
5421
|
+
return { runId, status, title, runtime };
|
|
5422
|
+
});
|
|
5423
|
+
const idWidth = Math.min(36, Math.max(6, ...rows.map((row) => row.runId.length)));
|
|
5424
|
+
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
5425
|
+
const header = `${pc3.bold(pad("RUN", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
5426
|
+
const body = rows.map((row) => [
|
|
5427
|
+
pc3.bold(pad(truncate(row.runId, idWidth), idWidth)),
|
|
5428
|
+
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
5429
|
+
`${row.title}${row.runtime ? pc3.dim(` ${row.runtime}`) : ""}`
|
|
5430
|
+
].join(" "));
|
|
5431
|
+
return [formatSection("Runs", options.source === "server" ? "selected server" : "local state"), header, ...body, "", ...formatNextSteps(["Follow live: `rig run attach <run-id> --follow`", "Details: `rig run show --run <run-id>`"])].join(`
|
|
5432
|
+
`);
|
|
5433
|
+
}
|
|
5434
|
+
function formatSubmittedRun(input) {
|
|
5435
|
+
const rows = [["run", pc3.bold(input.runId)]];
|
|
5436
|
+
if (input.task) {
|
|
5437
|
+
const id = stringField(input.task, "id", "<unknown>");
|
|
5438
|
+
const status = stringField(input.task, "status", "unknown");
|
|
5439
|
+
const title = stringField(input.task, "title", "Untitled task");
|
|
5440
|
+
rows.push(["task", `${pc3.bold(id)} ${formatStatusPill(status)} ${title}`]);
|
|
5441
|
+
}
|
|
5442
|
+
return [
|
|
5443
|
+
formatSuccessCard("Run submitted", rows),
|
|
5444
|
+
"",
|
|
5445
|
+
...formatNextSteps([`Attach: \`rig run attach ${input.runId} --follow\``, `Inspect: \`rig run show --run ${input.runId}\``])
|
|
5446
|
+
].join(`
|
|
5447
|
+
`);
|
|
5448
|
+
}
|
|
5449
|
+
function formatConnectionList(connections) {
|
|
5450
|
+
const rows = [["local", { kind: "local", mode: "auto" }], ...Object.entries(connections)];
|
|
5451
|
+
const aliasWidth = Math.min(24, Math.max(5, ...rows.map(([alias]) => alias.length)));
|
|
5452
|
+
const lines = rows.map(([alias, connection]) => [
|
|
5453
|
+
pc3.bold(pad(truncate(alias, aliasWidth), aliasWidth)),
|
|
5454
|
+
formatStatusPill(connection.kind),
|
|
5455
|
+
connection.kind === "remote" ? connection.baseUrl ?? "" : connection.mode ?? "local"
|
|
5456
|
+
].join(" "));
|
|
5457
|
+
return [formatSection("Rig servers", `${rows.length} available`), `${pc3.bold(pad("ALIAS", aliasWidth))} ${pc3.bold("KIND")} ${pc3.bold("TARGET")}`, ...lines, "", ...formatNextSteps(["Select one: `rig server use <alias|local>`"])].join(`
|
|
5458
|
+
`);
|
|
5459
|
+
}
|
|
5460
|
+
function formatConnectionStatus(selected, connections) {
|
|
5461
|
+
const connection = selected === "local" ? { kind: "local", mode: "auto" } : connections[selected];
|
|
5462
|
+
const target = !connection ? "not configured" : connection.kind === "remote" ? connection.baseUrl : "local";
|
|
5463
|
+
return [
|
|
5464
|
+
formatSection("Rig server", "selected for this repo"),
|
|
5465
|
+
`${pc3.dim("\u2502")} ${pc3.dim("selected ")} ${pc3.bold(selected)}`,
|
|
5466
|
+
`${pc3.dim("\u2502")} ${pc3.dim("kind ")} ${formatStatusPill(connection?.kind ?? "unknown")}`,
|
|
5467
|
+
`${pc3.dim("\u2502")} ${pc3.dim("target ")} ${target ?? "not configured"}`,
|
|
5468
|
+
"",
|
|
5469
|
+
...formatNextSteps(["Change: `rig server use <alias|local>`", "List saved servers: `rig server list`"])
|
|
5470
|
+
].join(`
|
|
5471
|
+
`);
|
|
5472
|
+
}
|
|
5473
|
+
|
|
5474
|
+
// packages/cli/src/commands/connect.ts
|
|
5475
|
+
function usageName(options) {
|
|
5476
|
+
return `rig ${options.group}`;
|
|
5477
|
+
}
|
|
5478
|
+
function parseConnection(alias, value, options) {
|
|
5320
5479
|
if (alias === "local" && !value)
|
|
5321
5480
|
return { kind: "local", mode: "auto" };
|
|
5322
5481
|
if (!value)
|
|
5323
|
-
throw new CliError2(
|
|
5482
|
+
throw new CliError2(`Missing remote server URL. Usage: ${usageName(options)} add <alias> <url>`, 1);
|
|
5324
5483
|
let parsed;
|
|
5325
5484
|
try {
|
|
5326
5485
|
parsed = new URL(value);
|
|
@@ -5339,54 +5498,89 @@ function printJsonOrText(context, payload, text2) {
|
|
|
5339
5498
|
console.log(text2);
|
|
5340
5499
|
}
|
|
5341
5500
|
}
|
|
5342
|
-
async function
|
|
5501
|
+
async function promptForConnectionAlias(context) {
|
|
5502
|
+
const state = readGlobalConnections();
|
|
5503
|
+
const repo = readRepoConnection(context.projectRoot);
|
|
5504
|
+
const options = [
|
|
5505
|
+
{ value: "local", label: "local", hint: "Use/start a local Rig server" },
|
|
5506
|
+
...Object.entries(state.connections).map(([alias, connection]) => ({
|
|
5507
|
+
value: alias,
|
|
5508
|
+
label: alias,
|
|
5509
|
+
hint: connection.kind === "remote" ? connection.baseUrl : "local"
|
|
5510
|
+
}))
|
|
5511
|
+
].filter((option, index, all) => all.findIndex((candidate) => candidate.value === option.value) === index);
|
|
5512
|
+
const answer = await select2({
|
|
5513
|
+
message: "Select Rig server for this repo",
|
|
5514
|
+
initialValue: repo?.selected ?? "local",
|
|
5515
|
+
options
|
|
5516
|
+
});
|
|
5517
|
+
if (isCancel2(answer)) {
|
|
5518
|
+
cancel2("No server selected.");
|
|
5519
|
+
throw new CliError2("No server selected.", 3);
|
|
5520
|
+
}
|
|
5521
|
+
return String(answer);
|
|
5522
|
+
}
|
|
5523
|
+
async function executeConnectionCommand(context, args, options) {
|
|
5343
5524
|
const [command, ...rest] = args;
|
|
5344
5525
|
switch (command ?? "status") {
|
|
5345
5526
|
case "list": {
|
|
5346
|
-
requireNoExtraArgs(rest,
|
|
5527
|
+
requireNoExtraArgs(rest, `${usageName(options)} list`);
|
|
5347
5528
|
const state = readGlobalConnections();
|
|
5348
|
-
printJsonOrText(context, state,
|
|
5349
|
-
|
|
5350
|
-
return { ok: true, group: "connect", command: "list", details: state };
|
|
5529
|
+
printJsonOrText(context, state, formatConnectionList(state.connections));
|
|
5530
|
+
return { ok: true, group: options.group, command: "list", details: state };
|
|
5351
5531
|
}
|
|
5352
5532
|
case "add": {
|
|
5353
5533
|
const [alias, url, ...extra] = rest;
|
|
5354
5534
|
if (!alias)
|
|
5355
|
-
throw new CliError2(
|
|
5356
|
-
requireNoExtraArgs(extra,
|
|
5357
|
-
const connection = parseConnection(alias, url);
|
|
5535
|
+
throw new CliError2(`Missing alias. Usage: ${usageName(options)} add <alias> <url>`, 1);
|
|
5536
|
+
requireNoExtraArgs(extra, `${usageName(options)} add <alias> <url>`);
|
|
5537
|
+
const connection = parseConnection(alias, url, options);
|
|
5358
5538
|
const state = upsertGlobalConnection(alias, connection);
|
|
5359
|
-
printJsonOrText(context, { alias, connection },
|
|
5360
|
-
|
|
5539
|
+
printJsonOrText(context, { alias, connection }, formatSuccessCard("Rig server saved", [
|
|
5540
|
+
["alias", alias],
|
|
5541
|
+
["target", connection.kind === "remote" ? connection.baseUrl : "local"],
|
|
5542
|
+
["next", `${usageName(options)} use ${alias}`]
|
|
5543
|
+
]));
|
|
5544
|
+
return { ok: true, group: options.group, command: "add", details: { alias, connection, count: Object.keys(state.connections).length } };
|
|
5361
5545
|
}
|
|
5362
5546
|
case "use": {
|
|
5363
|
-
|
|
5547
|
+
let [alias, ...extra] = rest;
|
|
5548
|
+
requireNoExtraArgs(extra, `${usageName(options)} use <alias|local>`);
|
|
5549
|
+
if (!alias && options.interactiveUse && context.outputMode === "text" && process.stdin.isTTY) {
|
|
5550
|
+
alias = await promptForConnectionAlias(context);
|
|
5551
|
+
}
|
|
5364
5552
|
if (!alias)
|
|
5365
|
-
throw new CliError2(
|
|
5366
|
-
requireNoExtraArgs(extra, "rig connect use <alias|local>");
|
|
5553
|
+
throw new CliError2(`Missing alias. Usage: ${usageName(options)} use <alias|local>`, 1);
|
|
5367
5554
|
if (alias !== "local") {
|
|
5368
5555
|
const state = readGlobalConnections();
|
|
5369
5556
|
if (!state.connections[alias])
|
|
5370
|
-
throw new CliError2(`Unknown Rig
|
|
5557
|
+
throw new CliError2(`Unknown Rig server: ${alias}`, 1);
|
|
5371
5558
|
}
|
|
5372
5559
|
const repoState = { selected: alias, linkedAt: new Date().toISOString() };
|
|
5373
5560
|
writeRepoConnection(context.projectRoot, repoState);
|
|
5374
|
-
printJsonOrText(context, repoState,
|
|
5375
|
-
|
|
5561
|
+
printJsonOrText(context, repoState, formatSuccessCard("Rig server selected", [
|
|
5562
|
+
["selected", alias],
|
|
5563
|
+
["scope", "this repo"],
|
|
5564
|
+
["next", "rig task list"]
|
|
5565
|
+
]));
|
|
5566
|
+
return { ok: true, group: options.group, command: "use", details: repoState };
|
|
5376
5567
|
}
|
|
5377
5568
|
case "status": {
|
|
5378
|
-
requireNoExtraArgs(rest,
|
|
5569
|
+
requireNoExtraArgs(rest, `${usageName(options)} status`);
|
|
5379
5570
|
const repo = readRepoConnection(context.projectRoot);
|
|
5380
5571
|
const global = readGlobalConnections();
|
|
5381
5572
|
const details = { selected: repo?.selected ?? "local", repo, connections: global.connections };
|
|
5382
|
-
printJsonOrText(context, details,
|
|
5383
|
-
return { ok: true, group:
|
|
5573
|
+
printJsonOrText(context, details, formatConnectionStatus(details.selected, global.connections));
|
|
5574
|
+
return { ok: true, group: options.group, command: "status", details };
|
|
5384
5575
|
}
|
|
5385
5576
|
default:
|
|
5386
|
-
throw new CliError2(`Unknown
|
|
5387
|
-
Usage:
|
|
5577
|
+
throw new CliError2(`Unknown ${options.group} command: ${String(command)}
|
|
5578
|
+
Usage: ${usageName(options)} <list|add|use|status>`, 1);
|
|
5388
5579
|
}
|
|
5389
5580
|
}
|
|
5581
|
+
async function executeConnect(context, args) {
|
|
5582
|
+
return executeConnectionCommand(context, args, { group: "connect" });
|
|
5583
|
+
}
|
|
5390
5584
|
|
|
5391
5585
|
// packages/cli/src/commands/github.ts
|
|
5392
5586
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
@@ -7321,107 +7515,6 @@ async function attachRunOperatorView(context, input) {
|
|
|
7321
7515
|
return { ...snapshot, steered, detached };
|
|
7322
7516
|
}
|
|
7323
7517
|
|
|
7324
|
-
// packages/cli/src/commands/_cli-format.ts
|
|
7325
|
-
import pc3 from "picocolors";
|
|
7326
|
-
function stringField(record, key, fallback = "") {
|
|
7327
|
-
const value = record[key];
|
|
7328
|
-
return typeof value === "string" && value.trim() ? value.trim() : fallback;
|
|
7329
|
-
}
|
|
7330
|
-
function arrayField(record, key) {
|
|
7331
|
-
const value = record[key];
|
|
7332
|
-
return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" && entry.trim() ? [entry.trim()] : []) : [];
|
|
7333
|
-
}
|
|
7334
|
-
function rawObject(record) {
|
|
7335
|
-
const raw = record.raw;
|
|
7336
|
-
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
7337
|
-
}
|
|
7338
|
-
function truncate(value, width) {
|
|
7339
|
-
if (value.length <= width)
|
|
7340
|
-
return value;
|
|
7341
|
-
if (width <= 1)
|
|
7342
|
-
return "\u2026";
|
|
7343
|
-
return `${value.slice(0, width - 1)}\u2026`;
|
|
7344
|
-
}
|
|
7345
|
-
function pad(value, width) {
|
|
7346
|
-
return value.length >= width ? value : `${value}${" ".repeat(width - value.length)}`;
|
|
7347
|
-
}
|
|
7348
|
-
function statusColor(status) {
|
|
7349
|
-
const normalized = status.toLowerCase();
|
|
7350
|
-
if (["completed", "merged", "closed", "done", "accepted"].includes(normalized))
|
|
7351
|
-
return pc3.green;
|
|
7352
|
-
if (["failed", "needs_attention", "needs-attention", "blocked"].includes(normalized))
|
|
7353
|
-
return pc3.red;
|
|
7354
|
-
if (["running", "reviewing", "validating", "in_progress", "in-progress"].includes(normalized))
|
|
7355
|
-
return pc3.cyan;
|
|
7356
|
-
if (["ready", "open", "queued", "created", "preparing"].includes(normalized))
|
|
7357
|
-
return pc3.yellow;
|
|
7358
|
-
return pc3.dim;
|
|
7359
|
-
}
|
|
7360
|
-
function formatTaskList(tasks, options = {}) {
|
|
7361
|
-
if (tasks.length === 0)
|
|
7362
|
-
return pc3.dim("No matching tasks.");
|
|
7363
|
-
if (options.raw)
|
|
7364
|
-
return tasks.map((task) => JSON.stringify(task)).join(`
|
|
7365
|
-
`);
|
|
7366
|
-
const rows = tasks.map((task) => {
|
|
7367
|
-
const raw = rawObject(task);
|
|
7368
|
-
const id = stringField(task, "id", "<unknown>");
|
|
7369
|
-
const status = stringField(task, "status", "unknown");
|
|
7370
|
-
const title = stringField(task, "title", "Untitled task");
|
|
7371
|
-
const source = stringField(task, "source", stringField(raw, "source", ""));
|
|
7372
|
-
const labels = arrayField(task, "labels").length > 0 ? arrayField(task, "labels") : arrayField(raw, "labels");
|
|
7373
|
-
return { id, status, title, source, labels };
|
|
7374
|
-
});
|
|
7375
|
-
const idWidth = Math.min(18, Math.max(4, ...rows.map((row) => row.id.length)));
|
|
7376
|
-
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
7377
|
-
const header = `${pc3.bold(pad("TASK", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
7378
|
-
const body = rows.map((row) => {
|
|
7379
|
-
const labels = row.labels.length > 0 ? pc3.dim(` ${row.labels.slice(0, 4).map((label) => `#${label}`).join(" ")}`) : "";
|
|
7380
|
-
const source = row.source ? pc3.dim(` ${row.source}`) : "";
|
|
7381
|
-
return [
|
|
7382
|
-
pc3.bold(pad(truncate(row.id, idWidth), idWidth)),
|
|
7383
|
-
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
7384
|
-
`${row.title}${labels}${source}`
|
|
7385
|
-
].join(" ");
|
|
7386
|
-
});
|
|
7387
|
-
return [pc3.bold("Rig tasks"), header, ...body].join(`
|
|
7388
|
-
`);
|
|
7389
|
-
}
|
|
7390
|
-
function formatRunList(runs, options = {}) {
|
|
7391
|
-
if (runs.length === 0) {
|
|
7392
|
-
return pc3.dim(options.source === "server" ? "No runs recorded on the selected Rig server." : "No runs recorded in .rig/runs.");
|
|
7393
|
-
}
|
|
7394
|
-
const rows = runs.map((run) => {
|
|
7395
|
-
const runId = stringField(run, "runId", stringField(run, "id", "(unknown-run)"));
|
|
7396
|
-
const status = stringField(run, "status", "unknown");
|
|
7397
|
-
const taskId2 = stringField(run, "taskId", "");
|
|
7398
|
-
const title = stringField(run, "title", taskId2 || "(untitled)");
|
|
7399
|
-
const runtime = stringField(run, "runtimeAdapter", "");
|
|
7400
|
-
return { runId, status, title, runtime };
|
|
7401
|
-
});
|
|
7402
|
-
const idWidth = Math.min(36, Math.max(6, ...rows.map((row) => row.runId.length)));
|
|
7403
|
-
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
7404
|
-
const header = `${pc3.bold(pad("RUN", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
7405
|
-
const body = rows.map((row) => [
|
|
7406
|
-
pc3.bold(pad(truncate(row.runId, idWidth), idWidth)),
|
|
7407
|
-
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
7408
|
-
`${row.title}${row.runtime ? pc3.dim(` ${row.runtime}`) : ""}`
|
|
7409
|
-
].join(" "));
|
|
7410
|
-
return [pc3.bold(options.source === "server" ? "Rig runs (server)" : "Rig runs"), header, ...body].join(`
|
|
7411
|
-
`);
|
|
7412
|
-
}
|
|
7413
|
-
function formatSubmittedRun(input) {
|
|
7414
|
-
const lines = [`${pc3.green("Run submitted")}: ${pc3.bold(input.runId)}`];
|
|
7415
|
-
if (input.task) {
|
|
7416
|
-
const id = stringField(input.task, "id", "<unknown>");
|
|
7417
|
-
const status = stringField(input.task, "status", "unknown");
|
|
7418
|
-
const title = stringField(input.task, "title", "Untitled task");
|
|
7419
|
-
lines.push(`${pc3.dim("task")} ${pc3.bold(id)} ${statusColor(status)(status)} ${title}`);
|
|
7420
|
-
}
|
|
7421
|
-
return lines.join(`
|
|
7422
|
-
`);
|
|
7423
|
-
}
|
|
7424
|
-
|
|
7425
7518
|
// packages/cli/src/commands/run.ts
|
|
7426
7519
|
function normalizeRemoteRunDetails(payload) {
|
|
7427
7520
|
const run = payload.run;
|
|
@@ -7824,7 +7917,10 @@ async function executeRun(context, args) {
|
|
|
7824
7917
|
|
|
7825
7918
|
// packages/cli/src/commands/server.ts
|
|
7826
7919
|
async function executeServer(context, args, options) {
|
|
7827
|
-
const [command = "
|
|
7920
|
+
const [command = "status", ...rest] = args;
|
|
7921
|
+
if (["status", "list", "add", "use"].includes(command)) {
|
|
7922
|
+
return executeConnectionCommand(context, [command, ...rest], { group: "server", interactiveUse: true });
|
|
7923
|
+
}
|
|
7828
7924
|
switch (command) {
|
|
7829
7925
|
case "start": {
|
|
7830
7926
|
let pending = rest;
|
|
@@ -7836,7 +7932,7 @@ async function executeServer(context, args, options) {
|
|
|
7836
7932
|
pending = pollResult.rest;
|
|
7837
7933
|
const authTokenResult = takeOption(pending, "--auth-token");
|
|
7838
7934
|
pending = authTokenResult.rest;
|
|
7839
|
-
requireNoExtraArgs(pending, "
|
|
7935
|
+
requireNoExtraArgs(pending, "rig server start [--host <host>] [--port <n>] [--poll-ms <n>] [--auth-token <token>]");
|
|
7840
7936
|
const commandParts = ["rig-server", "start"];
|
|
7841
7937
|
if (hostResult.value) {
|
|
7842
7938
|
commandParts.push("--host", hostResult.value);
|
|
@@ -7859,7 +7955,7 @@ async function executeServer(context, args, options) {
|
|
|
7859
7955
|
let pending = rest;
|
|
7860
7956
|
const eventResult = takeOption(pending, "--event");
|
|
7861
7957
|
pending = eventResult.rest;
|
|
7862
|
-
requireNoExtraArgs(pending, "
|
|
7958
|
+
requireNoExtraArgs(pending, "rig server notify-test [--event <type>]");
|
|
7863
7959
|
const commandParts = ["rig-server", "notify-test"];
|
|
7864
7960
|
if (eventResult.value) {
|
|
7865
7961
|
commandParts.push("--event", eventResult.value);
|
|
@@ -7887,7 +7983,7 @@ async function executeServer(context, args, options) {
|
|
|
7887
7983
|
pending = dirtyBaselineResult.rest;
|
|
7888
7984
|
const prResult = takeOption(pending, "--pr");
|
|
7889
7985
|
pending = prResult.rest;
|
|
7890
|
-
requireNoExtraArgs(pending, "
|
|
7986
|
+
requireNoExtraArgs(pending, "rig --run-id <run-id> server task-run [--task <id>] [--title <text>] [--runtime-adapter claude-code|codex|pi] [--model <model>] [--runtime-mode <mode>] [--interaction-mode <mode>] [--initial-prompt <text>] [--dirty-baseline head|dirty-snapshot] [--pr auto|ask|off]");
|
|
7891
7987
|
if (!taskResult.value && !initialPromptResult.value && !titleResult.value) {
|
|
7892
7988
|
throw new CliError2("server task-run requires either --task <id> or --initial-prompt/--title for an ad hoc run.", 2);
|
|
7893
7989
|
}
|
|
@@ -7924,7 +8020,7 @@ async function executeServer(context, args, options) {
|
|
|
7924
8020
|
import { readFileSync as readFileSync9 } from "fs";
|
|
7925
8021
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
7926
8022
|
import { resolve as resolve20 } from "path";
|
|
7927
|
-
import { cancel as
|
|
8023
|
+
import { cancel as cancel4, confirm as confirm2, isCancel as isCancel4 } from "@clack/prompts";
|
|
7928
8024
|
import {
|
|
7929
8025
|
taskArtifactDir,
|
|
7930
8026
|
taskArtifacts,
|
|
@@ -7942,7 +8038,7 @@ import {
|
|
|
7942
8038
|
} from "@rig/runtime/control-plane/native/task-ops";
|
|
7943
8039
|
|
|
7944
8040
|
// packages/cli/src/commands/_task-picker.ts
|
|
7945
|
-
import { cancel as
|
|
8041
|
+
import { cancel as cancel3, isCancel as isCancel3, select as select3 } from "@clack/prompts";
|
|
7946
8042
|
function taskId2(task) {
|
|
7947
8043
|
return typeof task.id === "string" && task.id.trim() ? task.id : "<unknown>";
|
|
7948
8044
|
}
|
|
@@ -7976,12 +8072,12 @@ async function selectTaskWithTextPicker(tasks, io = {}) {
|
|
|
7976
8072
|
label: `${taskId2(task)} \xB7 ${typeof task.title === "string" && task.title.trim() ? task.title.trim() : "Untitled task"}`,
|
|
7977
8073
|
hint: typeof task.status === "string" && task.status.trim() ? task.status.trim() : undefined
|
|
7978
8074
|
}));
|
|
7979
|
-
const answer = await
|
|
8075
|
+
const answer = await select3({
|
|
7980
8076
|
message: "Select Rig task",
|
|
7981
8077
|
options
|
|
7982
8078
|
});
|
|
7983
|
-
if (
|
|
7984
|
-
|
|
8079
|
+
if (isCancel3(answer)) {
|
|
8080
|
+
cancel3("No task selected.");
|
|
7985
8081
|
return null;
|
|
7986
8082
|
}
|
|
7987
8083
|
const index = Number.parseInt(String(answer), 10);
|
|
@@ -8101,8 +8197,8 @@ async function resolveDirtyBaselineForTaskRun(context, explicit) {
|
|
|
8101
8197
|
message: "Include current uncommitted changes in run baseline?",
|
|
8102
8198
|
initialValue: false
|
|
8103
8199
|
});
|
|
8104
|
-
if (
|
|
8105
|
-
|
|
8200
|
+
if (isCancel4(answer)) {
|
|
8201
|
+
cancel4("Run cancelled.");
|
|
8106
8202
|
throw new CliError2("Run cancelled by user.", 1);
|
|
8107
8203
|
}
|
|
8108
8204
|
return { mode: answer ? "dirty-snapshot" : "head", state };
|
|
@@ -10688,6 +10784,200 @@ Warnings:`);
|
|
|
10688
10784
|
}
|
|
10689
10785
|
}
|
|
10690
10786
|
|
|
10787
|
+
// packages/cli/src/commands/_help-catalog.ts
|
|
10788
|
+
import pc4 from "picocolors";
|
|
10789
|
+
var PRIMARY_GROUPS = [
|
|
10790
|
+
{
|
|
10791
|
+
name: "init",
|
|
10792
|
+
summary: "Set up Rig for this repo: server, GitHub auth, checkout strategy, task source, and Pi wiring.",
|
|
10793
|
+
usage: ["rig init [--yes] [--server local|remote] [--repo owner/repo] [--remote-url <url>]"],
|
|
10794
|
+
commands: [
|
|
10795
|
+
{ command: "init", description: "Interactive setup wizard for a new or existing Rig repo.", primary: true },
|
|
10796
|
+
{ command: "init --yes", description: "Non-interactive setup using detected/default settings.", primary: true },
|
|
10797
|
+
{ command: "init --server remote --remote-url <url>", description: "Link this repo to a remote Rig server.", primary: true },
|
|
10798
|
+
{ command: "init --repair", description: "Repair missing private state without replacing project config." }
|
|
10799
|
+
],
|
|
10800
|
+
examples: [
|
|
10801
|
+
"rig init",
|
|
10802
|
+
"rig init --yes --repo humanity-org/humanwork",
|
|
10803
|
+
"rig init --server remote --remote-url https://where.rig-does.work --repo owner/repo"
|
|
10804
|
+
],
|
|
10805
|
+
next: ["After init, run `rig server status`.", "Then use `rig task list` and `rig task run --next` for day-to-day work."]
|
|
10806
|
+
},
|
|
10807
|
+
{
|
|
10808
|
+
name: "server",
|
|
10809
|
+
summary: "Choose, inspect, and start the Rig server that owns tasks and runs.",
|
|
10810
|
+
usage: ["rig server <status|list|add|use|start> [options]"],
|
|
10811
|
+
commands: [
|
|
10812
|
+
{ command: "status", description: "Show the selected server for this repo.", primary: true },
|
|
10813
|
+
{ command: "list", description: "List saved local/remote server aliases.", primary: true },
|
|
10814
|
+
{ command: "add <alias> <url>", description: "Save a remote Rig server URL.", primary: true },
|
|
10815
|
+
{ command: "use [alias|local]", description: "Select a server; prompts in an interactive TTY.", primary: true },
|
|
10816
|
+
{ command: "start [--host <host>] [--port <n>]", description: "Start a local rig-server process.", primary: true }
|
|
10817
|
+
],
|
|
10818
|
+
examples: [
|
|
10819
|
+
"rig server status",
|
|
10820
|
+
"rig server add prod https://where.rig-does.work",
|
|
10821
|
+
"rig server use prod",
|
|
10822
|
+
"rig server use local",
|
|
10823
|
+
"rig server start --port 3773"
|
|
10824
|
+
],
|
|
10825
|
+
next: ["Use `rig task list` to see server-owned work.", "Use `rig run list` or `rig run attach <id> --follow` to monitor runs."],
|
|
10826
|
+
advanced: ["Compatibility alias: `rig connect ...` remains callable."]
|
|
10827
|
+
},
|
|
10828
|
+
{
|
|
10829
|
+
name: "task",
|
|
10830
|
+
summary: "Find work, start Pi-backed runs, and validate task results.",
|
|
10831
|
+
usage: ["rig task <list|next|show|run> [options]"],
|
|
10832
|
+
commands: [
|
|
10833
|
+
{ command: "list [--assignee <login|@me>] [--state open|closed]", description: "List tasks from the selected server/source.", primary: true },
|
|
10834
|
+
{ command: "next [filters]", description: "Pick the next matching task.", primary: true },
|
|
10835
|
+
{ command: "show <id>|--task <id>", description: "Show task details.", primary: true },
|
|
10836
|
+
{ command: "run [#<issue>|<task-id>|--next|--task <id>]", description: "Submit a task run; interactive follows with bundled Pi.", primary: true },
|
|
10837
|
+
{ command: "validate|verify [--task <id>]", description: "Run configured task checks/review gates." },
|
|
10838
|
+
{ command: "artifacts|artifact-dir|artifact-write", description: "Inspect or write task artifacts." },
|
|
10839
|
+
{ command: "report-bug", description: "Create a structured bug report/task." }
|
|
10840
|
+
],
|
|
10841
|
+
examples: [
|
|
10842
|
+
"rig task list --assignee @me --limit 20",
|
|
10843
|
+
"rig task run --next",
|
|
10844
|
+
"rig task run #123 --runtime-adapter pi",
|
|
10845
|
+
"rig task run --title 'Investigate deploy drift' --initial-prompt 'Check server health'"
|
|
10846
|
+
],
|
|
10847
|
+
next: ["Use `--detach` to submit without attaching.", "Use `rig run attach <run-id> --follow` to rejoin a live run."]
|
|
10848
|
+
},
|
|
10849
|
+
{
|
|
10850
|
+
name: "run",
|
|
10851
|
+
summary: "Observe, attach to, and control Rig runs.",
|
|
10852
|
+
usage: ["rig run <list|status|show|attach|stop> [options]"],
|
|
10853
|
+
commands: [
|
|
10854
|
+
{ command: "list", description: "List recent runs from the selected server or local state.", primary: true },
|
|
10855
|
+
{ command: "status", description: "Summarize active and recent runs.", primary: true },
|
|
10856
|
+
{ command: "show --run <id>", description: "Show one run record.", primary: true },
|
|
10857
|
+
{ command: "attach <run-id>|--run <id> [--follow]", description: "Attach to the run; `--follow` launches native bundled Pi for live Pi runs.", primary: true },
|
|
10858
|
+
{ command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
|
|
10859
|
+
{ command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events." },
|
|
10860
|
+
{ command: "delete|cleanup", description: "Remove completed run records/artifacts." }
|
|
10861
|
+
],
|
|
10862
|
+
examples: [
|
|
10863
|
+
"rig run list",
|
|
10864
|
+
"rig run attach 01234567-89ab-cdef-0123-456789abcdef --follow",
|
|
10865
|
+
"rig run show --run <run-id>",
|
|
10866
|
+
"rig run stop <run-id>"
|
|
10867
|
+
],
|
|
10868
|
+
next: ["Use `rig task run --next` to create a new run.", "Use `--json` when scripts need the full structured record."]
|
|
10869
|
+
}
|
|
10870
|
+
];
|
|
10871
|
+
var ADVANCED_GROUPS = [
|
|
10872
|
+
{ name: "connect", summary: "Compatibility alias for `rig server` selection commands.", usage: ["rig connect <status|list|add|use>"], commands: [{ command: "status|list|add|use", description: "Use `rig server ...` for the primary UX." }] },
|
|
10873
|
+
{ name: "github", summary: "GitHub auth helpers.", usage: ["rig github auth <status|import-gh|token>"], commands: [{ command: "auth status", description: "Show GitHub auth state." }] },
|
|
10874
|
+
{ name: "doctor", summary: "Diagnostics for project/server/GitHub/Pi state.", usage: ["rig doctor [check|run|shared|...]"], commands: [{ command: "check", description: "Run diagnostics." }] },
|
|
10875
|
+
{ name: "setup", summary: "Bootstrap/check local setup.", usage: ["rig setup <bootstrap|check|preflight>"], commands: [{ command: "bootstrap|check|preflight", description: "Setup helpers." }] },
|
|
10876
|
+
{ name: "inspect", summary: "Inspect logs, artifacts, graphs, failures.", usage: ["rig inspect <logs|artifacts|failures|graph|audit|diff>"], commands: [{ command: "logs --task <id>", description: "Inspect task logs." }] },
|
|
10877
|
+
{ name: "repo", summary: "Repository sync/baseline helpers.", usage: ["rig repo <sync|reset-baseline>"], commands: [{ command: "sync", description: "Sync project repository state." }] },
|
|
10878
|
+
{ name: "profile", summary: "Runtime profile/model defaults.", usage: ["rig profile <show|set>"], commands: [{ command: "show", description: "Show active profile." }] },
|
|
10879
|
+
{ name: "review", summary: "Review policy configuration.", usage: ["rig review <show|set>"], commands: [{ command: "show", description: "Show review settings." }] },
|
|
10880
|
+
{ name: "browser", summary: "Browser/app diagnostics.", usage: ["rig browser <help|explain|demo|app>"], commands: [{ command: "help", description: "Browser command help." }] },
|
|
10881
|
+
{ name: "plugin", summary: "Plugin validation/listing.", usage: ["rig plugin <list|validate>"], commands: [{ command: "list", description: "List plugins." }] },
|
|
10882
|
+
{ name: "queue", summary: "Run task queues locally.", usage: ["rig queue run [options]"], commands: [{ command: "run", description: "Process queue work." }] },
|
|
10883
|
+
{ name: "agent", summary: "Runtime agent workspace helpers.", usage: ["rig agent <list|prepare|run|cleanup>"], commands: [{ command: "list", description: "List prepared agents." }] },
|
|
10884
|
+
{ name: "inspector", summary: "Event stream and drift scanners.", usage: ["rig inspector <stream|scan-upstream-drift>"], commands: [{ command: "stream", description: "Stream events." }] },
|
|
10885
|
+
{ name: "dist", summary: "Build/install packaged Rig CLI.", usage: ["rig dist <build|install|doctor>"], commands: [{ command: "build", description: "Build distribution." }] },
|
|
10886
|
+
{ name: "workspace", summary: "Workspace topology/service helpers.", usage: ["rig workspace <summary|topology|remote-hosts>"], commands: [{ command: "summary", description: "Show workspace summary." }] },
|
|
10887
|
+
{ name: "remote", summary: "Legacy remote orchestration controls.", usage: ["rig remote <status|watch|pause|resume|...>"], commands: [{ command: "status", description: "Show remote state." }] },
|
|
10888
|
+
{ name: "inbox", summary: "Approval/input inbox for blocked runs.", usage: ["rig inbox <approvals|approve|inputs|respond>"], commands: [{ command: "approvals", description: "List pending approvals." }] },
|
|
10889
|
+
{ name: "git", summary: "Pass through to Rig git-flow helper.", usage: ["rig git <args...>"], commands: [{ command: "<args...>", description: "Advanced git flow operations." }] },
|
|
10890
|
+
{ name: "harness", summary: "Pass through to runtime harness CLI.", usage: ["rig harness <args...>"], commands: [{ command: "<args...>", description: "Advanced harness operations." }] },
|
|
10891
|
+
{ name: "test", summary: "Project test wrappers.", usage: ["rig test <unit|e2e|all>"], commands: [{ command: "all", description: "Run configured project tests." }] }
|
|
10892
|
+
];
|
|
10893
|
+
var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
|
|
10894
|
+
function heading(title) {
|
|
10895
|
+
return pc4.bold(pc4.cyan(title));
|
|
10896
|
+
}
|
|
10897
|
+
function commandLine(command, description) {
|
|
10898
|
+
const commandColumn = command.length >= 34 ? `${command} ` : command.padEnd(34);
|
|
10899
|
+
return `${pc4.dim("\u2502")} ${pc4.bold(commandColumn)} ${description}`;
|
|
10900
|
+
}
|
|
10901
|
+
function renderGroup(group) {
|
|
10902
|
+
const lines = [
|
|
10903
|
+
`${heading(`rig ${group.name}`)} \u2014 ${group.summary}`,
|
|
10904
|
+
"",
|
|
10905
|
+
pc4.bold("Usage"),
|
|
10906
|
+
...group.usage.map((line) => ` ${line}`),
|
|
10907
|
+
"",
|
|
10908
|
+
pc4.bold("Commands"),
|
|
10909
|
+
...group.commands.map((entry) => commandLine(entry.command, entry.description))
|
|
10910
|
+
];
|
|
10911
|
+
if (group.examples?.length) {
|
|
10912
|
+
lines.push("", pc4.bold("Examples"), ...group.examples.map((line) => ` ${pc4.dim("$")} ${line}`));
|
|
10913
|
+
}
|
|
10914
|
+
if (group.next?.length) {
|
|
10915
|
+
lines.push("", pc4.bold("Next steps"), ...group.next.map((line) => ` ${pc4.dim("\u203A")} ${line}`));
|
|
10916
|
+
}
|
|
10917
|
+
if (group.advanced?.length) {
|
|
10918
|
+
lines.push("", pc4.bold("Compatibility / advanced"), ...group.advanced.map((line) => ` ${pc4.dim("\u203A")} ${line}`));
|
|
10919
|
+
}
|
|
10920
|
+
return lines.join(`
|
|
10921
|
+
`);
|
|
10922
|
+
}
|
|
10923
|
+
function renderTopLevelHelp() {
|
|
10924
|
+
return [
|
|
10925
|
+
`${heading("rig")} ${pc4.dim("\u2014 server-owned task/run control plane for Pi-backed engineering work")}`,
|
|
10926
|
+
pc4.dim("A repo-local CLI for setup, server selection, task runs, live attach, and completion review."),
|
|
10927
|
+
"",
|
|
10928
|
+
`${pc4.bold(pc4.magenta("\u25C7 Start here"))} \u2014 ${pc4.dim("bootstrap a repo and choose where Rig runs")}`,
|
|
10929
|
+
commandLine("rig init", "Interactive setup: project config, GitHub auth, task source, server, checkout, Pi."),
|
|
10930
|
+
commandLine("rig init --yes", "Non-interactive setup using detected defaults; good for repeatable installs."),
|
|
10931
|
+
commandLine("rig server status", "Show whether this repo is using local Rig or a remote server."),
|
|
10932
|
+
commandLine("rig server use <alias|local>", "Switch the server that owns task/run state for this repo."),
|
|
10933
|
+
"",
|
|
10934
|
+
`${pc4.bold(pc4.magenta("\u25C7 Daily task loop"))} \u2014 ${pc4.dim("find work, start a worker, and rejoin it later")}`,
|
|
10935
|
+
commandLine("rig task list", "List tasks from the selected task source/server with status, labels, and source."),
|
|
10936
|
+
commandLine("rig task next", "Pick the next matching task without starting it."),
|
|
10937
|
+
commandLine("rig task run --next", "Start the next task and attach to the live bundled Pi frontend."),
|
|
10938
|
+
commandLine("rig task run #123 --detach", "Submit a specific issue/task and return immediately."),
|
|
10939
|
+
"",
|
|
10940
|
+
`${pc4.bold(pc4.magenta("\u25C7 Live run control"))} \u2014 ${pc4.dim("observe, steer, stop, or inspect active runs")}`,
|
|
10941
|
+
commandLine("rig run list", "Show recent/active runs from the selected server or local state."),
|
|
10942
|
+
commandLine("rig run attach <run-id> --follow", "Open the native Pi live view for a worker-backed run."),
|
|
10943
|
+
commandLine("rig run show --run <id>", "Print one run record; add `--json` for automation."),
|
|
10944
|
+
commandLine("rig run stop <run-id>", "Request cancellation for a running worker."),
|
|
10945
|
+
"",
|
|
10946
|
+
`${pc4.bold(pc4.magenta("\u25C7 Core groups"))} \u2014 ${pc4.dim("run `rig <group> --help` for detailed commands and examples")}`,
|
|
10947
|
+
...PRIMARY_GROUPS.map((group) => commandLine(group.name, group.summary)),
|
|
10948
|
+
commandLine("doctor", "Diagnose project/server/GitHub/task/Pi wiring when setup or runs misbehave."),
|
|
10949
|
+
"",
|
|
10950
|
+
`${pc4.bold(pc4.magenta("\u25C7 More"))}`,
|
|
10951
|
+
commandLine("rig help --advanced", "Legacy, dev, diagnostics, browser, queue, agent, remote, git, harness commands."),
|
|
10952
|
+
commandLine("rig <group> --help", "Rich per-group help with usage, descriptions, examples, and next steps."),
|
|
10953
|
+
commandLine("rig --version", "Print the installed Rig CLI version."),
|
|
10954
|
+
"",
|
|
10955
|
+
`${pc4.bold(pc4.magenta("\u25C7 Global options"))}`,
|
|
10956
|
+
commandLine("--project <path>", "Use a project root instead of auto-discovery."),
|
|
10957
|
+
commandLine("--json", "Emit structured output for scripts/agents."),
|
|
10958
|
+
commandLine("--dry-run", "Print the command plan without mutating state.")
|
|
10959
|
+
].join(`
|
|
10960
|
+
`);
|
|
10961
|
+
}
|
|
10962
|
+
function renderAdvancedHelp() {
|
|
10963
|
+
return [
|
|
10964
|
+
`${heading("rig advanced")} \u2014 legacy, dev, and compatibility groups`,
|
|
10965
|
+
"",
|
|
10966
|
+
pc4.bold("Primary groups are still"),
|
|
10967
|
+
" init, server, task, run",
|
|
10968
|
+
"",
|
|
10969
|
+
pc4.bold("Advanced groups"),
|
|
10970
|
+
...ADVANCED_GROUPS.map((group) => commandLine(group.name, group.summary)),
|
|
10971
|
+
"",
|
|
10972
|
+
pc4.dim("All groups remain callable. Prefer `rig server`, `rig task`, and `rig run` for day-to-day work.")
|
|
10973
|
+
].join(`
|
|
10974
|
+
`);
|
|
10975
|
+
}
|
|
10976
|
+
function renderGroupHelp(groupName) {
|
|
10977
|
+
const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
|
|
10978
|
+
return group ? renderGroup(group) : null;
|
|
10979
|
+
}
|
|
10980
|
+
|
|
10691
10981
|
// packages/cli/src/commands.ts
|
|
10692
10982
|
import { ensureProjectMainFreshBeforeRun as ensureProjectMainFreshBeforeRun2 } from "@rig/runtime/control-plane/project-main-pre-run-sync";
|
|
10693
10983
|
var TOP_LEVEL_ALIASES = {
|
|
@@ -10755,102 +11045,13 @@ var GROUPS = new Set([
|
|
|
10755
11045
|
"test"
|
|
10756
11046
|
]);
|
|
10757
11047
|
function printGroupHelp(group) {
|
|
10758
|
-
|
|
10759
|
-
`);
|
|
10760
|
-
const groupLineRe = new RegExp(`^ ${group}\\b`);
|
|
10761
|
-
const out = [`rig ${group} \u2014 command group`, ""];
|
|
10762
|
-
let inGroup = false;
|
|
10763
|
-
for (const line of lines) {
|
|
10764
|
-
if (groupLineRe.test(line)) {
|
|
10765
|
-
inGroup = true;
|
|
10766
|
-
out.push(line);
|
|
10767
|
-
continue;
|
|
10768
|
-
}
|
|
10769
|
-
if (inGroup) {
|
|
10770
|
-
if (line.startsWith(" ") || line.startsWith(" ")) {
|
|
10771
|
-
out.push(line);
|
|
10772
|
-
} else {
|
|
10773
|
-
break;
|
|
10774
|
-
}
|
|
10775
|
-
}
|
|
10776
|
-
}
|
|
10777
|
-
if (out.length === 2) {
|
|
10778
|
-
console.log(helpText());
|
|
10779
|
-
return;
|
|
10780
|
-
}
|
|
10781
|
-
console.log(out.join(`
|
|
10782
|
-
`));
|
|
11048
|
+
console.log(renderGroupHelp(group) ?? helpText());
|
|
10783
11049
|
}
|
|
10784
11050
|
function isHelpArg(arg) {
|
|
10785
11051
|
return arg === "--help" || arg === "-h" || arg === "help";
|
|
10786
11052
|
}
|
|
10787
11053
|
function helpText() {
|
|
10788
|
-
return
|
|
10789
|
-
"rig - Event-driven Bun control plane for Project Rig",
|
|
10790
|
-
"",
|
|
10791
|
-
"Usage:",
|
|
10792
|
-
" rig <group> <command> [options]",
|
|
10793
|
-
" rig <alias-command> [options]",
|
|
10794
|
-
" (compat: bun run rig ...)",
|
|
10795
|
-
"",
|
|
10796
|
-
"Groups:",
|
|
10797
|
-
" init [--server local|remote] [--remote-url <url>] [--repo owner/repo] [--github-auth gh|token|device|skip]",
|
|
10798
|
-
" [--github-token <token>] [--github-project off|<project-id>] [--github-project-status-field <id>]",
|
|
10799
|
-
" [--remote-checkout managed-clone|current-ref|uploaded-snapshot|existing-path] [--existing-path <path>] [--repair|--private-state-only] [--yes]",
|
|
10800
|
-
" connect list | add <alias> <url> | use <alias|local> | status",
|
|
10801
|
-
" github auth status | auth import-gh | auth token --token <token>",
|
|
10802
|
-
" doctor run shared server/project/GitHub/Projects/projection/labels/Pi/pi-rig/PR/checkout diagnostics",
|
|
10803
|
-
" setup bootstrap | check | setup | preflight | install-agent-shell",
|
|
10804
|
-
" run status | attach <run-id> [--message <text>] [--once|--follow] | start | start-parallel | start-serial | resume | stop | list | show --run <id> | timeline --run <id> [--follow]",
|
|
10805
|
-
" delete --run <id> [--purge-artifacts] | cleanup --all [--keep-artifacts] [--keep-runtimes] [--keep-queue]",
|
|
10806
|
-
" start flags: [--epic <id>] [--prompt-epic|--no-epic-prompt] [--ws-port <n>] [--server-host <host>] [--server-port <n>] [--poll-ms <n>] [--no-server]",
|
|
10807
|
-
" task list|next [--assignee <login|@me>] [--assigned-to <login|me|@me>] [--state <state>] [--status <status>] [--limit <n>]",
|
|
10808
|
-
" run [#<issue>|<task-id>|--next|--task <id>] [--detach] [--assignee <login|@me>] [--assigned-to <login|me|@me>] [--state <state>] [--status <status>] [--limit <n>] [--skip-project-sync]",
|
|
10809
|
-
" info | scope [--files] | deps | ready | validate [--task <id>] | verify [--task <id>]",
|
|
10810
|
-
" lookup <id> | record <decision|failure> <text> | artifacts | reset --task <id> | details --task <id>",
|
|
10811
|
-
" artifact-dir | artifact-write <filename> [--file <path>]",
|
|
10812
|
-
" report-bug [--no-prompt] [--no-beads] [--browser|--no-browser] [--title <text>] [--url <url>] [--environment local|shared-dev|staging|production|custom]",
|
|
10813
|
-
" report-bug flags: [--summary <text>] [--steps <a;b>] [--expected <text>] [--actual <text>] [--evidence <a;b>] [--asset <dragged-file>] [--video <dragged-file>] [--screenshot <path>]",
|
|
10814
|
-
" [--priority P0-P4] [--labels <a,b>] [--parent <task-id>] [--assignee <name>] [--owner <email>]",
|
|
10815
|
-
" [--preset <name>] [--profile <name>] [--attach-url <url>] [--state-dir <path>] [--mode <mode>] [--viewport <WxH>]",
|
|
10816
|
-
" [--output-dir <path>] [--slug <slug>] [--overwrite]",
|
|
10817
|
-
" reopen [--task <id> | --all] [--reason <text>]",
|
|
10818
|
-
" inspect logs --task <id> | artifacts --task <id> | artifact --task <id> --file <name> | failures | graph | audit | diff [--task <id>]",
|
|
10819
|
-
" repo sync [--task <id>] | reset-baseline [--keep-task-status]",
|
|
10820
|
-
" profile show | set <claude-code|codex-cli|pi> | set [--model ...] [--runtime ...] [--plugin ...]",
|
|
10821
|
-
" review show | set <off|advisory|required> [--provider greptile]",
|
|
10822
|
-
" browser help | explain | demo | app <dev|start|check|e2e|reset> (set RIG_BROWSER_APP=<slug>) | cdp-probe | profile-persistence | profile-lock-check",
|
|
10823
|
-
" plugin list | validate --task <id>",
|
|
10824
|
-
" queue run [--workers <n>] [--max-tasks <n>] [--action validate|verify|pipeline] [--isolation off|worktree] [--no-runtime-reuse] [--fail-fast] [--skip-project-sync]",
|
|
10825
|
-
" agent list | prepare [--id <id>] [--mode worktree] | run [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...> | cleanup (--id <id> | --all)",
|
|
10826
|
-
" cleanup is runtime-only; use run cleanup to remove authority runs, logs, artifacts, and queue state",
|
|
10827
|
-
" inspector stream [--once] [--seconds <n>] [--poll-ms <n>] | scan-upstream-drift [--scan-id <id>]",
|
|
10828
|
-
" server start [--host <host>] [--port <n>] [--poll-ms <n>] [--auth-token <token>]",
|
|
10829
|
-
" notify-test [--event <type>] | task-run [--task <id>] [--title <text>] [--runtime-adapter claude-code|codex|pi] [--model <model>]",
|
|
10830
|
-
" [--runtime-mode <mode>] [--interaction-mode <mode>] [--initial-prompt <text>]",
|
|
10831
|
-
" dist build [--output-dir <dir>] | install [--scope user|system] [--path <dir>] | doctor | rebuild-agent",
|
|
10832
|
-
" workspace summary | topology | remote-hosts | service-fabric <status|up|verify|down> [--service <name>]",
|
|
10833
|
-
" remote test | status | tasks | watch [--seconds <n>] [--event <type>] | pause | resume | stop | continue | refresh",
|
|
10834
|
-
" add-iterations --count <n> | remove-iterations --count <n> | prompt-preview --task <id> | iteration-output --task <id>",
|
|
10835
|
-
" orchestrate-start [--max-workers <n>] [--max-iterations <n>] [--direct-merge]",
|
|
10836
|
-
" orchestrate-pause --id <id> | orchestrate-resume --id <id> | orchestrate-stop --id <id> | orchestrate-state --id <id>",
|
|
10837
|
-
" endpoint list | endpoint add --alias <a> --host <h> --port <n> --token <t> | endpoint update --id <id> [--alias <a>] [--host <h>] [--port <n>] [--token <t>] | endpoint remove --alias <a> | endpoint test --alias <a> | endpoint migrate | endpoint doctor",
|
|
10838
|
-
" endpoint flags: [--remote <alias>] [--host <host>] [--port <n>] [--token <token>]",
|
|
10839
|
-
" inbox approvals [--run <id>] [--task <id>] | approve --run <id> --request <id> --decision approve|reject [--note <text>]",
|
|
10840
|
-
" inputs [--run <id>] [--task <id>] | respond --run <id> --request <id> --answer key=value [--answer key=value]",
|
|
10841
|
-
" git <git-flow args...>",
|
|
10842
|
-
" harness <harness args...>",
|
|
10843
|
-
" test unit | e2e | all",
|
|
10844
|
-
"",
|
|
10845
|
-
"Global Options:",
|
|
10846
|
-
" --version, -V Print rig version and exit",
|
|
10847
|
-
" --help, -h Print this help (or `rig <group> --help` for group help)",
|
|
10848
|
-
" --project <path> Use this server/project root instead of auto-discovery or PROJECT_RIG_ROOT",
|
|
10849
|
-
" --dry-run Print command execution plan without running commands",
|
|
10850
|
-
" --json Output structured JSON result",
|
|
10851
|
-
" --policy-mode <m> Override policy mode: off|observe|enforce"
|
|
10852
|
-
].join(`
|
|
10853
|
-
`);
|
|
11054
|
+
return renderTopLevelHelp();
|
|
10854
11055
|
}
|
|
10855
11056
|
async function execute(context, args) {
|
|
10856
11057
|
if (args.length === 0) {
|
|
@@ -10864,6 +11065,14 @@ async function execute(context, args) {
|
|
|
10864
11065
|
${helpText()}`);
|
|
10865
11066
|
}
|
|
10866
11067
|
if (first === "help" || first === "--help" || first === "-h") {
|
|
11068
|
+
if (rest[0] === "--advanced") {
|
|
11069
|
+
console.log(renderAdvancedHelp());
|
|
11070
|
+
return { ok: true, group: "help", command: "advanced" };
|
|
11071
|
+
}
|
|
11072
|
+
if (rest[0]) {
|
|
11073
|
+
console.log(renderGroupHelp(rest[0]) ?? helpText());
|
|
11074
|
+
return { ok: true, group: "help", command: rest[0] };
|
|
11075
|
+
}
|
|
10867
11076
|
console.log(helpText());
|
|
10868
11077
|
return { ok: true, group: "help", command: "show" };
|
|
10869
11078
|
}
|