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