@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/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,171 @@ 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: "server",
|
|
10792
|
+
summary: "Choose, inspect, and start the Rig server that owns tasks and runs.",
|
|
10793
|
+
usage: ["rig server <status|list|add|use|start> [options]"],
|
|
10794
|
+
commands: [
|
|
10795
|
+
{ command: "status", description: "Show the selected server for this repo.", primary: true },
|
|
10796
|
+
{ command: "list", description: "List saved local/remote server aliases.", primary: true },
|
|
10797
|
+
{ command: "add <alias> <url>", description: "Save a remote Rig server URL.", primary: true },
|
|
10798
|
+
{ command: "use [alias|local]", description: "Select a server; prompts in an interactive TTY.", primary: true },
|
|
10799
|
+
{ command: "start [--host <host>] [--port <n>]", description: "Start a local rig-server process.", primary: true }
|
|
10800
|
+
],
|
|
10801
|
+
examples: [
|
|
10802
|
+
"rig server status",
|
|
10803
|
+
"rig server add prod https://where.rig-does.work",
|
|
10804
|
+
"rig server use prod",
|
|
10805
|
+
"rig server use local",
|
|
10806
|
+
"rig server start --port 3773"
|
|
10807
|
+
],
|
|
10808
|
+
next: ["Use `rig task list` to see server-owned work.", "Use `rig run list` or `rig run attach <id> --follow` to monitor runs."],
|
|
10809
|
+
advanced: ["Compatibility alias: `rig connect ...` remains callable."]
|
|
10810
|
+
},
|
|
10811
|
+
{
|
|
10812
|
+
name: "task",
|
|
10813
|
+
summary: "Find work, start Pi-backed runs, and validate task results.",
|
|
10814
|
+
usage: ["rig task <list|next|show|run> [options]"],
|
|
10815
|
+
commands: [
|
|
10816
|
+
{ command: "list [--assignee <login|@me>] [--state open|closed]", description: "List tasks from the selected server/source.", primary: true },
|
|
10817
|
+
{ command: "next [filters]", description: "Pick the next matching task.", primary: true },
|
|
10818
|
+
{ command: "show <id>|--task <id>", description: "Show task details.", primary: true },
|
|
10819
|
+
{ command: "run [#<issue>|<task-id>|--next|--task <id>]", description: "Submit a task run; interactive follows with bundled Pi.", primary: true },
|
|
10820
|
+
{ command: "validate|verify [--task <id>]", description: "Run configured task checks/review gates." },
|
|
10821
|
+
{ command: "artifacts|artifact-dir|artifact-write", description: "Inspect or write task artifacts." },
|
|
10822
|
+
{ command: "report-bug", description: "Create a structured bug report/task." }
|
|
10823
|
+
],
|
|
10824
|
+
examples: [
|
|
10825
|
+
"rig task list --assignee @me --limit 20",
|
|
10826
|
+
"rig task run --next",
|
|
10827
|
+
"rig task run #123 --runtime-adapter pi",
|
|
10828
|
+
"rig task run --title 'Investigate deploy drift' --initial-prompt 'Check server health'"
|
|
10829
|
+
],
|
|
10830
|
+
next: ["Use `--detach` to submit without attaching.", "Use `rig run attach <run-id> --follow` to rejoin a live run."]
|
|
10831
|
+
},
|
|
10832
|
+
{
|
|
10833
|
+
name: "run",
|
|
10834
|
+
summary: "Observe, attach to, and control Rig runs.",
|
|
10835
|
+
usage: ["rig run <list|status|show|attach|stop> [options]"],
|
|
10836
|
+
commands: [
|
|
10837
|
+
{ command: "list", description: "List recent runs from the selected server or local state.", primary: true },
|
|
10838
|
+
{ command: "status", description: "Summarize active and recent runs.", primary: true },
|
|
10839
|
+
{ command: "show --run <id>", description: "Show one run record.", primary: true },
|
|
10840
|
+
{ command: "attach <run-id>|--run <id> [--follow]", description: "Attach to the run; `--follow` launches native bundled Pi for live Pi runs.", primary: true },
|
|
10841
|
+
{ command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
|
|
10842
|
+
{ command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events." },
|
|
10843
|
+
{ command: "delete|cleanup", description: "Remove completed run records/artifacts." }
|
|
10844
|
+
],
|
|
10845
|
+
examples: [
|
|
10846
|
+
"rig run list",
|
|
10847
|
+
"rig run attach 01234567-89ab-cdef-0123-456789abcdef --follow",
|
|
10848
|
+
"rig run show --run <run-id>",
|
|
10849
|
+
"rig run stop <run-id>"
|
|
10850
|
+
],
|
|
10851
|
+
next: ["Use `rig task run --next` to create a new run.", "Use `--json` when scripts need the full structured record."]
|
|
10852
|
+
}
|
|
10853
|
+
];
|
|
10854
|
+
var ADVANCED_GROUPS = [
|
|
10855
|
+
{ name: "init", summary: "Initialize or repair Rig project state.", usage: ["rig init [options]"], commands: [{ command: "init", description: "Configure project/server/GitHub integration." }] },
|
|
10856
|
+
{ 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." }] },
|
|
10857
|
+
{ name: "github", summary: "GitHub auth helpers.", usage: ["rig github auth <status|import-gh|token>"], commands: [{ command: "auth status", description: "Show GitHub auth state." }] },
|
|
10858
|
+
{ name: "doctor", summary: "Diagnostics for project/server/GitHub/Pi state.", usage: ["rig doctor [check|run|shared|...]"], commands: [{ command: "check", description: "Run diagnostics." }] },
|
|
10859
|
+
{ name: "setup", summary: "Bootstrap/check local setup.", usage: ["rig setup <bootstrap|check|preflight>"], commands: [{ command: "bootstrap|check|preflight", description: "Setup helpers." }] },
|
|
10860
|
+
{ 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." }] },
|
|
10861
|
+
{ name: "repo", summary: "Repository sync/baseline helpers.", usage: ["rig repo <sync|reset-baseline>"], commands: [{ command: "sync", description: "Sync project repository state." }] },
|
|
10862
|
+
{ name: "profile", summary: "Runtime profile/model defaults.", usage: ["rig profile <show|set>"], commands: [{ command: "show", description: "Show active profile." }] },
|
|
10863
|
+
{ name: "review", summary: "Review policy configuration.", usage: ["rig review <show|set>"], commands: [{ command: "show", description: "Show review settings." }] },
|
|
10864
|
+
{ name: "browser", summary: "Browser/app diagnostics.", usage: ["rig browser <help|explain|demo|app>"], commands: [{ command: "help", description: "Browser command help." }] },
|
|
10865
|
+
{ name: "plugin", summary: "Plugin validation/listing.", usage: ["rig plugin <list|validate>"], commands: [{ command: "list", description: "List plugins." }] },
|
|
10866
|
+
{ name: "queue", summary: "Run task queues locally.", usage: ["rig queue run [options]"], commands: [{ command: "run", description: "Process queue work." }] },
|
|
10867
|
+
{ name: "agent", summary: "Runtime agent workspace helpers.", usage: ["rig agent <list|prepare|run|cleanup>"], commands: [{ command: "list", description: "List prepared agents." }] },
|
|
10868
|
+
{ name: "inspector", summary: "Event stream and drift scanners.", usage: ["rig inspector <stream|scan-upstream-drift>"], commands: [{ command: "stream", description: "Stream events." }] },
|
|
10869
|
+
{ name: "dist", summary: "Build/install packaged Rig CLI.", usage: ["rig dist <build|install|doctor>"], commands: [{ command: "build", description: "Build distribution." }] },
|
|
10870
|
+
{ name: "workspace", summary: "Workspace topology/service helpers.", usage: ["rig workspace <summary|topology|remote-hosts>"], commands: [{ command: "summary", description: "Show workspace summary." }] },
|
|
10871
|
+
{ name: "remote", summary: "Legacy remote orchestration controls.", usage: ["rig remote <status|watch|pause|resume|...>"], commands: [{ command: "status", description: "Show remote state." }] },
|
|
10872
|
+
{ name: "inbox", summary: "Approval/input inbox for blocked runs.", usage: ["rig inbox <approvals|approve|inputs|respond>"], commands: [{ command: "approvals", description: "List pending approvals." }] },
|
|
10873
|
+
{ name: "git", summary: "Pass through to Rig git-flow helper.", usage: ["rig git <args...>"], commands: [{ command: "<args...>", description: "Advanced git flow operations." }] },
|
|
10874
|
+
{ name: "harness", summary: "Pass through to runtime harness CLI.", usage: ["rig harness <args...>"], commands: [{ command: "<args...>", description: "Advanced harness operations." }] },
|
|
10875
|
+
{ name: "test", summary: "Project test wrappers.", usage: ["rig test <unit|e2e|all>"], commands: [{ command: "all", description: "Run configured project tests." }] }
|
|
10876
|
+
];
|
|
10877
|
+
var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
|
|
10878
|
+
function heading(title) {
|
|
10879
|
+
return pc4.bold(pc4.cyan(title));
|
|
10880
|
+
}
|
|
10881
|
+
function commandLine(command, description) {
|
|
10882
|
+
const commandColumn = command.length >= 34 ? `${command} ` : command.padEnd(34);
|
|
10883
|
+
return ` ${pc4.bold(commandColumn)} ${description}`;
|
|
10884
|
+
}
|
|
10885
|
+
function renderGroup(group) {
|
|
10886
|
+
const lines = [
|
|
10887
|
+
`${heading(`rig ${group.name}`)} \u2014 ${group.summary}`,
|
|
10888
|
+
"",
|
|
10889
|
+
pc4.bold("Usage"),
|
|
10890
|
+
...group.usage.map((line) => ` ${line}`),
|
|
10891
|
+
"",
|
|
10892
|
+
pc4.bold("Commands"),
|
|
10893
|
+
...group.commands.map((entry) => commandLine(entry.command, entry.description))
|
|
10894
|
+
];
|
|
10895
|
+
if (group.examples?.length) {
|
|
10896
|
+
lines.push("", pc4.bold("Examples"), ...group.examples.map((line) => ` ${pc4.dim("$")} ${line}`));
|
|
10897
|
+
}
|
|
10898
|
+
if (group.next?.length) {
|
|
10899
|
+
lines.push("", pc4.bold("Next steps"), ...group.next.map((line) => ` ${pc4.dim("\u203A")} ${line}`));
|
|
10900
|
+
}
|
|
10901
|
+
if (group.advanced?.length) {
|
|
10902
|
+
lines.push("", pc4.bold("Compatibility / advanced"), ...group.advanced.map((line) => ` ${pc4.dim("\u203A")} ${line}`));
|
|
10903
|
+
}
|
|
10904
|
+
return lines.join(`
|
|
10905
|
+
`);
|
|
10906
|
+
}
|
|
10907
|
+
function renderTopLevelHelp() {
|
|
10908
|
+
return [
|
|
10909
|
+
`${heading("rig")} \u2014 server-owned task/run control plane`,
|
|
10910
|
+
"",
|
|
10911
|
+
pc4.bold("Common workflows"),
|
|
10912
|
+
" rig server status Show selected local/remote server",
|
|
10913
|
+
" rig task list List available work",
|
|
10914
|
+
" rig task run --next Start next task and attach with native Pi",
|
|
10915
|
+
" rig run list List recent runs",
|
|
10916
|
+
" rig run attach <run-id> --follow Rejoin a live run",
|
|
10917
|
+
"",
|
|
10918
|
+
pc4.bold("Primary groups"),
|
|
10919
|
+
...PRIMARY_GROUPS.map((group) => commandLine(group.name, group.summary)),
|
|
10920
|
+
"",
|
|
10921
|
+
pc4.bold("Help"),
|
|
10922
|
+
" rig <group> --help Rich help for server, task, run, and other groups",
|
|
10923
|
+
" rig help --advanced Legacy/dev/compat command surface",
|
|
10924
|
+
" rig --version Print version",
|
|
10925
|
+
"",
|
|
10926
|
+
pc4.bold("Global options"),
|
|
10927
|
+
" --project <path> Use a project root instead of auto-discovery",
|
|
10928
|
+
" --json Output structured JSON",
|
|
10929
|
+
" --dry-run Print command execution plan only"
|
|
10930
|
+
].join(`
|
|
10931
|
+
`);
|
|
10932
|
+
}
|
|
10933
|
+
function renderAdvancedHelp() {
|
|
10934
|
+
return [
|
|
10935
|
+
`${heading("rig advanced")} \u2014 legacy, dev, and compatibility groups`,
|
|
10936
|
+
"",
|
|
10937
|
+
pc4.bold("Primary groups are still"),
|
|
10938
|
+
" server, task, run",
|
|
10939
|
+
"",
|
|
10940
|
+
pc4.bold("Advanced groups"),
|
|
10941
|
+
...ADVANCED_GROUPS.map((group) => commandLine(group.name, group.summary)),
|
|
10942
|
+
"",
|
|
10943
|
+
pc4.dim("All groups remain callable. Prefer `rig server`, `rig task`, and `rig run` for day-to-day work.")
|
|
10944
|
+
].join(`
|
|
10945
|
+
`);
|
|
10946
|
+
}
|
|
10947
|
+
function renderGroupHelp(groupName) {
|
|
10948
|
+
const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
|
|
10949
|
+
return group ? renderGroup(group) : null;
|
|
10950
|
+
}
|
|
10951
|
+
|
|
10691
10952
|
// packages/cli/src/commands.ts
|
|
10692
10953
|
import { ensureProjectMainFreshBeforeRun as ensureProjectMainFreshBeforeRun2 } from "@rig/runtime/control-plane/project-main-pre-run-sync";
|
|
10693
10954
|
var TOP_LEVEL_ALIASES = {
|
|
@@ -10755,102 +11016,13 @@ var GROUPS = new Set([
|
|
|
10755
11016
|
"test"
|
|
10756
11017
|
]);
|
|
10757
11018
|
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
|
-
`));
|
|
11019
|
+
console.log(renderGroupHelp(group) ?? helpText());
|
|
10783
11020
|
}
|
|
10784
11021
|
function isHelpArg(arg) {
|
|
10785
11022
|
return arg === "--help" || arg === "-h" || arg === "help";
|
|
10786
11023
|
}
|
|
10787
11024
|
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
|
-
`);
|
|
11025
|
+
return renderTopLevelHelp();
|
|
10854
11026
|
}
|
|
10855
11027
|
async function execute(context, args) {
|
|
10856
11028
|
if (args.length === 0) {
|
|
@@ -10864,6 +11036,14 @@ async function execute(context, args) {
|
|
|
10864
11036
|
${helpText()}`);
|
|
10865
11037
|
}
|
|
10866
11038
|
if (first === "help" || first === "--help" || first === "-h") {
|
|
11039
|
+
if (rest[0] === "--advanced") {
|
|
11040
|
+
console.log(renderAdvancedHelp());
|
|
11041
|
+
return { ok: true, group: "help", command: "advanced" };
|
|
11042
|
+
}
|
|
11043
|
+
if (rest[0]) {
|
|
11044
|
+
console.log(renderGroupHelp(rest[0]) ?? helpText());
|
|
11045
|
+
return { ok: true, group: "help", command: rest[0] };
|
|
11046
|
+
}
|
|
10867
11047
|
console.log(helpText());
|
|
10868
11048
|
return { ok: true, group: "help", command: "show" };
|
|
10869
11049
|
}
|