@h-rig/cli 0.0.6-alpha.25 → 0.0.6-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rig.js +435 -226
- package/dist/src/commands/_cli-format.js +71 -13
- package/dist/src/commands/_help-catalog.js +203 -0
- package/dist/src/commands/connect.js +131 -23
- package/dist/src/commands/run.js +20 -6
- package/dist/src/commands/server.js +206 -8
- package/dist/src/commands/task.js +32 -10
- package/dist/src/commands.js +435 -226
- package/dist/src/index.js +435 -226
- package/package.json +6 -6
package/dist/src/commands.js
CHANGED
|
@@ -5109,11 +5109,170 @@ Usage: rig init`, 1);
|
|
|
5109
5109
|
}
|
|
5110
5110
|
|
|
5111
5111
|
// packages/cli/src/commands/connect.ts
|
|
5112
|
-
|
|
5112
|
+
import { cancel as cancel2, isCancel as isCancel2, select as select2 } from "@clack/prompts";
|
|
5113
|
+
|
|
5114
|
+
// packages/cli/src/commands/_cli-format.ts
|
|
5115
|
+
import pc3 from "picocolors";
|
|
5116
|
+
function stringField(record, key, fallback = "") {
|
|
5117
|
+
const value = record[key];
|
|
5118
|
+
return typeof value === "string" && value.trim() ? value.trim() : fallback;
|
|
5119
|
+
}
|
|
5120
|
+
function arrayField(record, key) {
|
|
5121
|
+
const value = record[key];
|
|
5122
|
+
return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" && entry.trim() ? [entry.trim()] : []) : [];
|
|
5123
|
+
}
|
|
5124
|
+
function rawObject(record) {
|
|
5125
|
+
const raw = record.raw;
|
|
5126
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
5127
|
+
}
|
|
5128
|
+
function truncate(value, width) {
|
|
5129
|
+
if (value.length <= width)
|
|
5130
|
+
return value;
|
|
5131
|
+
if (width <= 1)
|
|
5132
|
+
return "\u2026";
|
|
5133
|
+
return `${value.slice(0, width - 1)}\u2026`;
|
|
5134
|
+
}
|
|
5135
|
+
function pad(value, width) {
|
|
5136
|
+
return value.length >= width ? value : `${value}${" ".repeat(width - value.length)}`;
|
|
5137
|
+
}
|
|
5138
|
+
function statusColor(status) {
|
|
5139
|
+
const normalized = status.toLowerCase();
|
|
5140
|
+
if (["completed", "merged", "closed", "done", "accepted", "pass", "selected"].includes(normalized))
|
|
5141
|
+
return pc3.green;
|
|
5142
|
+
if (["failed", "needs_attention", "needs-attention", "blocked", "error"].includes(normalized))
|
|
5143
|
+
return pc3.red;
|
|
5144
|
+
if (["running", "reviewing", "validating", "in_progress", "in-progress", "remote"].includes(normalized))
|
|
5145
|
+
return pc3.cyan;
|
|
5146
|
+
if (["ready", "open", "queued", "created", "preparing", "local"].includes(normalized))
|
|
5147
|
+
return pc3.yellow;
|
|
5148
|
+
return pc3.dim;
|
|
5149
|
+
}
|
|
5150
|
+
function formatStatusPill(status) {
|
|
5151
|
+
const label = status || "unknown";
|
|
5152
|
+
return statusColor(label)(`\u25CF ${label}`);
|
|
5153
|
+
}
|
|
5154
|
+
function formatSection(title, subtitle) {
|
|
5155
|
+
return `${pc3.bold(pc3.cyan("\u25C6"))} ${pc3.bold(title)}${subtitle ? pc3.dim(` \u2014 ${subtitle}`) : ""}`;
|
|
5156
|
+
}
|
|
5157
|
+
function formatSuccessCard(title, rows = []) {
|
|
5158
|
+
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}`);
|
|
5159
|
+
return [formatSection(title), ...body].join(`
|
|
5160
|
+
`);
|
|
5161
|
+
}
|
|
5162
|
+
function formatNextSteps(steps) {
|
|
5163
|
+
if (steps.length === 0)
|
|
5164
|
+
return [];
|
|
5165
|
+
return [pc3.bold("Next"), ...steps.map((step) => `${pc3.dim("\u203A")} ${step}`)];
|
|
5166
|
+
}
|
|
5167
|
+
function formatTaskList(tasks, options = {}) {
|
|
5168
|
+
if (options.raw)
|
|
5169
|
+
return tasks.map((task) => JSON.stringify(task)).join(`
|
|
5170
|
+
`);
|
|
5171
|
+
if (tasks.length === 0)
|
|
5172
|
+
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(`
|
|
5173
|
+
`);
|
|
5174
|
+
const rows = tasks.map((task) => {
|
|
5175
|
+
const raw = rawObject(task);
|
|
5176
|
+
const id = stringField(task, "id", "<unknown>");
|
|
5177
|
+
const status = stringField(task, "status", "unknown");
|
|
5178
|
+
const title = stringField(task, "title", "Untitled task");
|
|
5179
|
+
const source = stringField(task, "source", stringField(raw, "source", ""));
|
|
5180
|
+
const labels = arrayField(task, "labels").length > 0 ? arrayField(task, "labels") : arrayField(raw, "labels");
|
|
5181
|
+
return { id, status, title, source, labels };
|
|
5182
|
+
});
|
|
5183
|
+
const idWidth = Math.min(18, Math.max(4, ...rows.map((row) => row.id.length)));
|
|
5184
|
+
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
5185
|
+
const header = `${pc3.bold(pad("TASK", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
5186
|
+
const body = rows.map((row) => {
|
|
5187
|
+
const labels = row.labels.length > 0 ? pc3.dim(` ${row.labels.slice(0, 4).map((label) => `#${label}`).join(" ")}`) : "";
|
|
5188
|
+
const source = row.source ? pc3.dim(` ${row.source}`) : "";
|
|
5189
|
+
return [
|
|
5190
|
+
pc3.bold(pad(truncate(row.id, idWidth), idWidth)),
|
|
5191
|
+
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
5192
|
+
`${row.title}${labels}${source}`
|
|
5193
|
+
].join(" ");
|
|
5194
|
+
});
|
|
5195
|
+
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(`
|
|
5196
|
+
`);
|
|
5197
|
+
}
|
|
5198
|
+
function formatRunList(runs, options = {}) {
|
|
5199
|
+
if (runs.length === 0) {
|
|
5200
|
+
return [
|
|
5201
|
+
formatSection("Runs", "none recorded"),
|
|
5202
|
+
options.source === "server" ? pc3.dim("No runs recorded on the selected Rig server.") : pc3.dim("No runs recorded in .rig/runs."),
|
|
5203
|
+
"",
|
|
5204
|
+
...formatNextSteps(["Start one: `rig task run --next`", "Check server: `rig server status`"])
|
|
5205
|
+
].join(`
|
|
5206
|
+
`);
|
|
5207
|
+
}
|
|
5208
|
+
const rows = runs.map((run) => {
|
|
5209
|
+
const runId = stringField(run, "runId", stringField(run, "id", "(unknown-run)"));
|
|
5210
|
+
const status = stringField(run, "status", "unknown");
|
|
5211
|
+
const taskId = stringField(run, "taskId", "");
|
|
5212
|
+
const title = stringField(run, "title", taskId || "(untitled)");
|
|
5213
|
+
const runtime = stringField(run, "runtimeAdapter", "");
|
|
5214
|
+
return { runId, status, title, runtime };
|
|
5215
|
+
});
|
|
5216
|
+
const idWidth = Math.min(36, Math.max(6, ...rows.map((row) => row.runId.length)));
|
|
5217
|
+
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
5218
|
+
const header = `${pc3.bold(pad("RUN", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
5219
|
+
const body = rows.map((row) => [
|
|
5220
|
+
pc3.bold(pad(truncate(row.runId, idWidth), idWidth)),
|
|
5221
|
+
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
5222
|
+
`${row.title}${row.runtime ? pc3.dim(` ${row.runtime}`) : ""}`
|
|
5223
|
+
].join(" "));
|
|
5224
|
+
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(`
|
|
5225
|
+
`);
|
|
5226
|
+
}
|
|
5227
|
+
function formatSubmittedRun(input) {
|
|
5228
|
+
const rows = [["run", pc3.bold(input.runId)]];
|
|
5229
|
+
if (input.task) {
|
|
5230
|
+
const id = stringField(input.task, "id", "<unknown>");
|
|
5231
|
+
const status = stringField(input.task, "status", "unknown");
|
|
5232
|
+
const title = stringField(input.task, "title", "Untitled task");
|
|
5233
|
+
rows.push(["task", `${pc3.bold(id)} ${formatStatusPill(status)} ${title}`]);
|
|
5234
|
+
}
|
|
5235
|
+
return [
|
|
5236
|
+
formatSuccessCard("Run submitted", rows),
|
|
5237
|
+
"",
|
|
5238
|
+
...formatNextSteps([`Attach: \`rig run attach ${input.runId} --follow\``, `Inspect: \`rig run show --run ${input.runId}\``])
|
|
5239
|
+
].join(`
|
|
5240
|
+
`);
|
|
5241
|
+
}
|
|
5242
|
+
function formatConnectionList(connections) {
|
|
5243
|
+
const rows = [["local", { kind: "local", mode: "auto" }], ...Object.entries(connections)];
|
|
5244
|
+
const aliasWidth = Math.min(24, Math.max(5, ...rows.map(([alias]) => alias.length)));
|
|
5245
|
+
const lines = rows.map(([alias, connection]) => [
|
|
5246
|
+
pc3.bold(pad(truncate(alias, aliasWidth), aliasWidth)),
|
|
5247
|
+
formatStatusPill(connection.kind),
|
|
5248
|
+
connection.kind === "remote" ? connection.baseUrl ?? "" : connection.mode ?? "local"
|
|
5249
|
+
].join(" "));
|
|
5250
|
+
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(`
|
|
5251
|
+
`);
|
|
5252
|
+
}
|
|
5253
|
+
function formatConnectionStatus(selected, connections) {
|
|
5254
|
+
const connection = selected === "local" ? { kind: "local", mode: "auto" } : connections[selected];
|
|
5255
|
+
const target = !connection ? "not configured" : connection.kind === "remote" ? connection.baseUrl : "local";
|
|
5256
|
+
return [
|
|
5257
|
+
formatSection("Rig server", "selected for this repo"),
|
|
5258
|
+
`${pc3.dim("\u2502")} ${pc3.dim("selected ")} ${pc3.bold(selected)}`,
|
|
5259
|
+
`${pc3.dim("\u2502")} ${pc3.dim("kind ")} ${formatStatusPill(connection?.kind ?? "unknown")}`,
|
|
5260
|
+
`${pc3.dim("\u2502")} ${pc3.dim("target ")} ${target ?? "not configured"}`,
|
|
5261
|
+
"",
|
|
5262
|
+
...formatNextSteps(["Change: `rig server use <alias|local>`", "List saved servers: `rig server list`"])
|
|
5263
|
+
].join(`
|
|
5264
|
+
`);
|
|
5265
|
+
}
|
|
5266
|
+
|
|
5267
|
+
// packages/cli/src/commands/connect.ts
|
|
5268
|
+
function usageName(options) {
|
|
5269
|
+
return `rig ${options.group}`;
|
|
5270
|
+
}
|
|
5271
|
+
function parseConnection(alias, value, options) {
|
|
5113
5272
|
if (alias === "local" && !value)
|
|
5114
5273
|
return { kind: "local", mode: "auto" };
|
|
5115
5274
|
if (!value)
|
|
5116
|
-
throw new CliError2(
|
|
5275
|
+
throw new CliError2(`Missing remote server URL. Usage: ${usageName(options)} add <alias> <url>`, 1);
|
|
5117
5276
|
let parsed;
|
|
5118
5277
|
try {
|
|
5119
5278
|
parsed = new URL(value);
|
|
@@ -5132,54 +5291,89 @@ function printJsonOrText(context, payload, text2) {
|
|
|
5132
5291
|
console.log(text2);
|
|
5133
5292
|
}
|
|
5134
5293
|
}
|
|
5135
|
-
async function
|
|
5294
|
+
async function promptForConnectionAlias(context) {
|
|
5295
|
+
const state = readGlobalConnections();
|
|
5296
|
+
const repo = readRepoConnection(context.projectRoot);
|
|
5297
|
+
const options = [
|
|
5298
|
+
{ value: "local", label: "local", hint: "Use/start a local Rig server" },
|
|
5299
|
+
...Object.entries(state.connections).map(([alias, connection]) => ({
|
|
5300
|
+
value: alias,
|
|
5301
|
+
label: alias,
|
|
5302
|
+
hint: connection.kind === "remote" ? connection.baseUrl : "local"
|
|
5303
|
+
}))
|
|
5304
|
+
].filter((option, index, all) => all.findIndex((candidate) => candidate.value === option.value) === index);
|
|
5305
|
+
const answer = await select2({
|
|
5306
|
+
message: "Select Rig server for this repo",
|
|
5307
|
+
initialValue: repo?.selected ?? "local",
|
|
5308
|
+
options
|
|
5309
|
+
});
|
|
5310
|
+
if (isCancel2(answer)) {
|
|
5311
|
+
cancel2("No server selected.");
|
|
5312
|
+
throw new CliError2("No server selected.", 3);
|
|
5313
|
+
}
|
|
5314
|
+
return String(answer);
|
|
5315
|
+
}
|
|
5316
|
+
async function executeConnectionCommand(context, args, options) {
|
|
5136
5317
|
const [command, ...rest] = args;
|
|
5137
5318
|
switch (command ?? "status") {
|
|
5138
5319
|
case "list": {
|
|
5139
|
-
requireNoExtraArgs(rest,
|
|
5320
|
+
requireNoExtraArgs(rest, `${usageName(options)} list`);
|
|
5140
5321
|
const state = readGlobalConnections();
|
|
5141
|
-
printJsonOrText(context, state,
|
|
5142
|
-
|
|
5143
|
-
return { ok: true, group: "connect", command: "list", details: state };
|
|
5322
|
+
printJsonOrText(context, state, formatConnectionList(state.connections));
|
|
5323
|
+
return { ok: true, group: options.group, command: "list", details: state };
|
|
5144
5324
|
}
|
|
5145
5325
|
case "add": {
|
|
5146
5326
|
const [alias, url, ...extra] = rest;
|
|
5147
5327
|
if (!alias)
|
|
5148
|
-
throw new CliError2(
|
|
5149
|
-
requireNoExtraArgs(extra,
|
|
5150
|
-
const connection = parseConnection(alias, url);
|
|
5328
|
+
throw new CliError2(`Missing alias. Usage: ${usageName(options)} add <alias> <url>`, 1);
|
|
5329
|
+
requireNoExtraArgs(extra, `${usageName(options)} add <alias> <url>`);
|
|
5330
|
+
const connection = parseConnection(alias, url, options);
|
|
5151
5331
|
const state = upsertGlobalConnection(alias, connection);
|
|
5152
|
-
printJsonOrText(context, { alias, connection },
|
|
5153
|
-
|
|
5332
|
+
printJsonOrText(context, { alias, connection }, formatSuccessCard("Rig server saved", [
|
|
5333
|
+
["alias", alias],
|
|
5334
|
+
["target", connection.kind === "remote" ? connection.baseUrl : "local"],
|
|
5335
|
+
["next", `${usageName(options)} use ${alias}`]
|
|
5336
|
+
]));
|
|
5337
|
+
return { ok: true, group: options.group, command: "add", details: { alias, connection, count: Object.keys(state.connections).length } };
|
|
5154
5338
|
}
|
|
5155
5339
|
case "use": {
|
|
5156
|
-
|
|
5340
|
+
let [alias, ...extra] = rest;
|
|
5341
|
+
requireNoExtraArgs(extra, `${usageName(options)} use <alias|local>`);
|
|
5342
|
+
if (!alias && options.interactiveUse && context.outputMode === "text" && process.stdin.isTTY) {
|
|
5343
|
+
alias = await promptForConnectionAlias(context);
|
|
5344
|
+
}
|
|
5157
5345
|
if (!alias)
|
|
5158
|
-
throw new CliError2(
|
|
5159
|
-
requireNoExtraArgs(extra, "rig connect use <alias|local>");
|
|
5346
|
+
throw new CliError2(`Missing alias. Usage: ${usageName(options)} use <alias|local>`, 1);
|
|
5160
5347
|
if (alias !== "local") {
|
|
5161
5348
|
const state = readGlobalConnections();
|
|
5162
5349
|
if (!state.connections[alias])
|
|
5163
|
-
throw new CliError2(`Unknown Rig
|
|
5350
|
+
throw new CliError2(`Unknown Rig server: ${alias}`, 1);
|
|
5164
5351
|
}
|
|
5165
5352
|
const repoState = { selected: alias, linkedAt: new Date().toISOString() };
|
|
5166
5353
|
writeRepoConnection(context.projectRoot, repoState);
|
|
5167
|
-
printJsonOrText(context, repoState,
|
|
5168
|
-
|
|
5354
|
+
printJsonOrText(context, repoState, formatSuccessCard("Rig server selected", [
|
|
5355
|
+
["selected", alias],
|
|
5356
|
+
["scope", "this repo"],
|
|
5357
|
+
["next", "rig task list"]
|
|
5358
|
+
]));
|
|
5359
|
+
return { ok: true, group: options.group, command: "use", details: repoState };
|
|
5169
5360
|
}
|
|
5170
5361
|
case "status": {
|
|
5171
|
-
requireNoExtraArgs(rest,
|
|
5362
|
+
requireNoExtraArgs(rest, `${usageName(options)} status`);
|
|
5172
5363
|
const repo = readRepoConnection(context.projectRoot);
|
|
5173
5364
|
const global = readGlobalConnections();
|
|
5174
5365
|
const details = { selected: repo?.selected ?? "local", repo, connections: global.connections };
|
|
5175
|
-
printJsonOrText(context, details,
|
|
5176
|
-
return { ok: true, group:
|
|
5366
|
+
printJsonOrText(context, details, formatConnectionStatus(details.selected, global.connections));
|
|
5367
|
+
return { ok: true, group: options.group, command: "status", details };
|
|
5177
5368
|
}
|
|
5178
5369
|
default:
|
|
5179
|
-
throw new CliError2(`Unknown
|
|
5180
|
-
Usage:
|
|
5370
|
+
throw new CliError2(`Unknown ${options.group} command: ${String(command)}
|
|
5371
|
+
Usage: ${usageName(options)} <list|add|use|status>`, 1);
|
|
5181
5372
|
}
|
|
5182
5373
|
}
|
|
5374
|
+
async function executeConnect(context, args) {
|
|
5375
|
+
return executeConnectionCommand(context, args, { group: "connect" });
|
|
5376
|
+
}
|
|
5183
5377
|
|
|
5184
5378
|
// packages/cli/src/commands/github.ts
|
|
5185
5379
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
@@ -7114,107 +7308,6 @@ async function attachRunOperatorView(context, input) {
|
|
|
7114
7308
|
return { ...snapshot, steered, detached };
|
|
7115
7309
|
}
|
|
7116
7310
|
|
|
7117
|
-
// packages/cli/src/commands/_cli-format.ts
|
|
7118
|
-
import pc3 from "picocolors";
|
|
7119
|
-
function stringField(record, key, fallback = "") {
|
|
7120
|
-
const value = record[key];
|
|
7121
|
-
return typeof value === "string" && value.trim() ? value.trim() : fallback;
|
|
7122
|
-
}
|
|
7123
|
-
function arrayField(record, key) {
|
|
7124
|
-
const value = record[key];
|
|
7125
|
-
return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" && entry.trim() ? [entry.trim()] : []) : [];
|
|
7126
|
-
}
|
|
7127
|
-
function rawObject(record) {
|
|
7128
|
-
const raw = record.raw;
|
|
7129
|
-
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
7130
|
-
}
|
|
7131
|
-
function truncate(value, width) {
|
|
7132
|
-
if (value.length <= width)
|
|
7133
|
-
return value;
|
|
7134
|
-
if (width <= 1)
|
|
7135
|
-
return "\u2026";
|
|
7136
|
-
return `${value.slice(0, width - 1)}\u2026`;
|
|
7137
|
-
}
|
|
7138
|
-
function pad(value, width) {
|
|
7139
|
-
return value.length >= width ? value : `${value}${" ".repeat(width - value.length)}`;
|
|
7140
|
-
}
|
|
7141
|
-
function statusColor(status) {
|
|
7142
|
-
const normalized = status.toLowerCase();
|
|
7143
|
-
if (["completed", "merged", "closed", "done", "accepted"].includes(normalized))
|
|
7144
|
-
return pc3.green;
|
|
7145
|
-
if (["failed", "needs_attention", "needs-attention", "blocked"].includes(normalized))
|
|
7146
|
-
return pc3.red;
|
|
7147
|
-
if (["running", "reviewing", "validating", "in_progress", "in-progress"].includes(normalized))
|
|
7148
|
-
return pc3.cyan;
|
|
7149
|
-
if (["ready", "open", "queued", "created", "preparing"].includes(normalized))
|
|
7150
|
-
return pc3.yellow;
|
|
7151
|
-
return pc3.dim;
|
|
7152
|
-
}
|
|
7153
|
-
function formatTaskList(tasks, options = {}) {
|
|
7154
|
-
if (tasks.length === 0)
|
|
7155
|
-
return pc3.dim("No matching tasks.");
|
|
7156
|
-
if (options.raw)
|
|
7157
|
-
return tasks.map((task) => JSON.stringify(task)).join(`
|
|
7158
|
-
`);
|
|
7159
|
-
const rows = tasks.map((task) => {
|
|
7160
|
-
const raw = rawObject(task);
|
|
7161
|
-
const id = stringField(task, "id", "<unknown>");
|
|
7162
|
-
const status = stringField(task, "status", "unknown");
|
|
7163
|
-
const title = stringField(task, "title", "Untitled task");
|
|
7164
|
-
const source = stringField(task, "source", stringField(raw, "source", ""));
|
|
7165
|
-
const labels = arrayField(task, "labels").length > 0 ? arrayField(task, "labels") : arrayField(raw, "labels");
|
|
7166
|
-
return { id, status, title, source, labels };
|
|
7167
|
-
});
|
|
7168
|
-
const idWidth = Math.min(18, Math.max(4, ...rows.map((row) => row.id.length)));
|
|
7169
|
-
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
7170
|
-
const header = `${pc3.bold(pad("TASK", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
7171
|
-
const body = rows.map((row) => {
|
|
7172
|
-
const labels = row.labels.length > 0 ? pc3.dim(` ${row.labels.slice(0, 4).map((label) => `#${label}`).join(" ")}`) : "";
|
|
7173
|
-
const source = row.source ? pc3.dim(` ${row.source}`) : "";
|
|
7174
|
-
return [
|
|
7175
|
-
pc3.bold(pad(truncate(row.id, idWidth), idWidth)),
|
|
7176
|
-
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
7177
|
-
`${row.title}${labels}${source}`
|
|
7178
|
-
].join(" ");
|
|
7179
|
-
});
|
|
7180
|
-
return [pc3.bold("Rig tasks"), header, ...body].join(`
|
|
7181
|
-
`);
|
|
7182
|
-
}
|
|
7183
|
-
function formatRunList(runs, options = {}) {
|
|
7184
|
-
if (runs.length === 0) {
|
|
7185
|
-
return pc3.dim(options.source === "server" ? "No runs recorded on the selected Rig server." : "No runs recorded in .rig/runs.");
|
|
7186
|
-
}
|
|
7187
|
-
const rows = runs.map((run) => {
|
|
7188
|
-
const runId = stringField(run, "runId", stringField(run, "id", "(unknown-run)"));
|
|
7189
|
-
const status = stringField(run, "status", "unknown");
|
|
7190
|
-
const taskId2 = stringField(run, "taskId", "");
|
|
7191
|
-
const title = stringField(run, "title", taskId2 || "(untitled)");
|
|
7192
|
-
const runtime = stringField(run, "runtimeAdapter", "");
|
|
7193
|
-
return { runId, status, title, runtime };
|
|
7194
|
-
});
|
|
7195
|
-
const idWidth = Math.min(36, Math.max(6, ...rows.map((row) => row.runId.length)));
|
|
7196
|
-
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
7197
|
-
const header = `${pc3.bold(pad("RUN", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
7198
|
-
const body = rows.map((row) => [
|
|
7199
|
-
pc3.bold(pad(truncate(row.runId, idWidth), idWidth)),
|
|
7200
|
-
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
7201
|
-
`${row.title}${row.runtime ? pc3.dim(` ${row.runtime}`) : ""}`
|
|
7202
|
-
].join(" "));
|
|
7203
|
-
return [pc3.bold(options.source === "server" ? "Rig runs (server)" : "Rig runs"), header, ...body].join(`
|
|
7204
|
-
`);
|
|
7205
|
-
}
|
|
7206
|
-
function formatSubmittedRun(input) {
|
|
7207
|
-
const lines = [`${pc3.green("Run submitted")}: ${pc3.bold(input.runId)}`];
|
|
7208
|
-
if (input.task) {
|
|
7209
|
-
const id = stringField(input.task, "id", "<unknown>");
|
|
7210
|
-
const status = stringField(input.task, "status", "unknown");
|
|
7211
|
-
const title = stringField(input.task, "title", "Untitled task");
|
|
7212
|
-
lines.push(`${pc3.dim("task")} ${pc3.bold(id)} ${statusColor(status)(status)} ${title}`);
|
|
7213
|
-
}
|
|
7214
|
-
return lines.join(`
|
|
7215
|
-
`);
|
|
7216
|
-
}
|
|
7217
|
-
|
|
7218
7311
|
// packages/cli/src/commands/run.ts
|
|
7219
7312
|
function normalizeRemoteRunDetails(payload) {
|
|
7220
7313
|
const run = payload.run;
|
|
@@ -7617,7 +7710,10 @@ async function executeRun(context, args) {
|
|
|
7617
7710
|
|
|
7618
7711
|
// packages/cli/src/commands/server.ts
|
|
7619
7712
|
async function executeServer(context, args, options) {
|
|
7620
|
-
const [command = "
|
|
7713
|
+
const [command = "status", ...rest] = args;
|
|
7714
|
+
if (["status", "list", "add", "use"].includes(command)) {
|
|
7715
|
+
return executeConnectionCommand(context, [command, ...rest], { group: "server", interactiveUse: true });
|
|
7716
|
+
}
|
|
7621
7717
|
switch (command) {
|
|
7622
7718
|
case "start": {
|
|
7623
7719
|
let pending = rest;
|
|
@@ -7629,7 +7725,7 @@ async function executeServer(context, args, options) {
|
|
|
7629
7725
|
pending = pollResult.rest;
|
|
7630
7726
|
const authTokenResult = takeOption(pending, "--auth-token");
|
|
7631
7727
|
pending = authTokenResult.rest;
|
|
7632
|
-
requireNoExtraArgs(pending, "
|
|
7728
|
+
requireNoExtraArgs(pending, "rig server start [--host <host>] [--port <n>] [--poll-ms <n>] [--auth-token <token>]");
|
|
7633
7729
|
const commandParts = ["rig-server", "start"];
|
|
7634
7730
|
if (hostResult.value) {
|
|
7635
7731
|
commandParts.push("--host", hostResult.value);
|
|
@@ -7652,7 +7748,7 @@ async function executeServer(context, args, options) {
|
|
|
7652
7748
|
let pending = rest;
|
|
7653
7749
|
const eventResult = takeOption(pending, "--event");
|
|
7654
7750
|
pending = eventResult.rest;
|
|
7655
|
-
requireNoExtraArgs(pending, "
|
|
7751
|
+
requireNoExtraArgs(pending, "rig server notify-test [--event <type>]");
|
|
7656
7752
|
const commandParts = ["rig-server", "notify-test"];
|
|
7657
7753
|
if (eventResult.value) {
|
|
7658
7754
|
commandParts.push("--event", eventResult.value);
|
|
@@ -7680,7 +7776,7 @@ async function executeServer(context, args, options) {
|
|
|
7680
7776
|
pending = dirtyBaselineResult.rest;
|
|
7681
7777
|
const prResult = takeOption(pending, "--pr");
|
|
7682
7778
|
pending = prResult.rest;
|
|
7683
|
-
requireNoExtraArgs(pending, "
|
|
7779
|
+
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]");
|
|
7684
7780
|
if (!taskResult.value && !initialPromptResult.value && !titleResult.value) {
|
|
7685
7781
|
throw new CliError2("server task-run requires either --task <id> or --initial-prompt/--title for an ad hoc run.", 2);
|
|
7686
7782
|
}
|
|
@@ -7717,7 +7813,7 @@ async function executeServer(context, args, options) {
|
|
|
7717
7813
|
import { readFileSync as readFileSync9 } from "fs";
|
|
7718
7814
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
7719
7815
|
import { resolve as resolve19 } from "path";
|
|
7720
|
-
import { cancel as
|
|
7816
|
+
import { cancel as cancel4, confirm as confirm2, isCancel as isCancel4 } from "@clack/prompts";
|
|
7721
7817
|
import {
|
|
7722
7818
|
taskArtifactDir,
|
|
7723
7819
|
taskArtifacts,
|
|
@@ -7735,7 +7831,7 @@ import {
|
|
|
7735
7831
|
} from "@rig/runtime/control-plane/native/task-ops";
|
|
7736
7832
|
|
|
7737
7833
|
// packages/cli/src/commands/_task-picker.ts
|
|
7738
|
-
import { cancel as
|
|
7834
|
+
import { cancel as cancel3, isCancel as isCancel3, select as select3 } from "@clack/prompts";
|
|
7739
7835
|
function taskId2(task) {
|
|
7740
7836
|
return typeof task.id === "string" && task.id.trim() ? task.id : "<unknown>";
|
|
7741
7837
|
}
|
|
@@ -7769,12 +7865,12 @@ async function selectTaskWithTextPicker(tasks, io = {}) {
|
|
|
7769
7865
|
label: `${taskId2(task)} \xB7 ${typeof task.title === "string" && task.title.trim() ? task.title.trim() : "Untitled task"}`,
|
|
7770
7866
|
hint: typeof task.status === "string" && task.status.trim() ? task.status.trim() : undefined
|
|
7771
7867
|
}));
|
|
7772
|
-
const answer = await
|
|
7868
|
+
const answer = await select3({
|
|
7773
7869
|
message: "Select Rig task",
|
|
7774
7870
|
options
|
|
7775
7871
|
});
|
|
7776
|
-
if (
|
|
7777
|
-
|
|
7872
|
+
if (isCancel3(answer)) {
|
|
7873
|
+
cancel3("No task selected.");
|
|
7778
7874
|
return null;
|
|
7779
7875
|
}
|
|
7780
7876
|
const index = Number.parseInt(String(answer), 10);
|
|
@@ -7894,8 +7990,8 @@ async function resolveDirtyBaselineForTaskRun(context, explicit) {
|
|
|
7894
7990
|
message: "Include current uncommitted changes in run baseline?",
|
|
7895
7991
|
initialValue: false
|
|
7896
7992
|
});
|
|
7897
|
-
if (
|
|
7898
|
-
|
|
7993
|
+
if (isCancel4(answer)) {
|
|
7994
|
+
cancel4("Run cancelled.");
|
|
7899
7995
|
throw new CliError2("Run cancelled by user.", 1);
|
|
7900
7996
|
}
|
|
7901
7997
|
return { mode: answer ? "dirty-snapshot" : "head", state };
|
|
@@ -10481,6 +10577,200 @@ Warnings:`);
|
|
|
10481
10577
|
}
|
|
10482
10578
|
}
|
|
10483
10579
|
|
|
10580
|
+
// packages/cli/src/commands/_help-catalog.ts
|
|
10581
|
+
import pc4 from "picocolors";
|
|
10582
|
+
var PRIMARY_GROUPS = [
|
|
10583
|
+
{
|
|
10584
|
+
name: "init",
|
|
10585
|
+
summary: "Set up Rig for this repo: server, GitHub auth, checkout strategy, task source, and Pi wiring.",
|
|
10586
|
+
usage: ["rig init [--yes] [--server local|remote] [--repo owner/repo] [--remote-url <url>]"],
|
|
10587
|
+
commands: [
|
|
10588
|
+
{ command: "init", description: "Interactive setup wizard for a new or existing Rig repo.", primary: true },
|
|
10589
|
+
{ command: "init --yes", description: "Non-interactive setup using detected/default settings.", primary: true },
|
|
10590
|
+
{ command: "init --server remote --remote-url <url>", description: "Link this repo to a remote Rig server.", primary: true },
|
|
10591
|
+
{ command: "init --repair", description: "Repair missing private state without replacing project config." }
|
|
10592
|
+
],
|
|
10593
|
+
examples: [
|
|
10594
|
+
"rig init",
|
|
10595
|
+
"rig init --yes --repo humanity-org/humanwork",
|
|
10596
|
+
"rig init --server remote --remote-url https://where.rig-does.work --repo owner/repo"
|
|
10597
|
+
],
|
|
10598
|
+
next: ["After init, run `rig server status`.", "Then use `rig task list` and `rig task run --next` for day-to-day work."]
|
|
10599
|
+
},
|
|
10600
|
+
{
|
|
10601
|
+
name: "server",
|
|
10602
|
+
summary: "Choose, inspect, and start the Rig server that owns tasks and runs.",
|
|
10603
|
+
usage: ["rig server <status|list|add|use|start> [options]"],
|
|
10604
|
+
commands: [
|
|
10605
|
+
{ command: "status", description: "Show the selected server for this repo.", primary: true },
|
|
10606
|
+
{ command: "list", description: "List saved local/remote server aliases.", primary: true },
|
|
10607
|
+
{ command: "add <alias> <url>", description: "Save a remote Rig server URL.", primary: true },
|
|
10608
|
+
{ command: "use [alias|local]", description: "Select a server; prompts in an interactive TTY.", primary: true },
|
|
10609
|
+
{ command: "start [--host <host>] [--port <n>]", description: "Start a local rig-server process.", primary: true }
|
|
10610
|
+
],
|
|
10611
|
+
examples: [
|
|
10612
|
+
"rig server status",
|
|
10613
|
+
"rig server add prod https://where.rig-does.work",
|
|
10614
|
+
"rig server use prod",
|
|
10615
|
+
"rig server use local",
|
|
10616
|
+
"rig server start --port 3773"
|
|
10617
|
+
],
|
|
10618
|
+
next: ["Use `rig task list` to see server-owned work.", "Use `rig run list` or `rig run attach <id> --follow` to monitor runs."],
|
|
10619
|
+
advanced: ["Compatibility alias: `rig connect ...` remains callable."]
|
|
10620
|
+
},
|
|
10621
|
+
{
|
|
10622
|
+
name: "task",
|
|
10623
|
+
summary: "Find work, start Pi-backed runs, and validate task results.",
|
|
10624
|
+
usage: ["rig task <list|next|show|run> [options]"],
|
|
10625
|
+
commands: [
|
|
10626
|
+
{ command: "list [--assignee <login|@me>] [--state open|closed]", description: "List tasks from the selected server/source.", primary: true },
|
|
10627
|
+
{ command: "next [filters]", description: "Pick the next matching task.", primary: true },
|
|
10628
|
+
{ command: "show <id>|--task <id>", description: "Show task details.", primary: true },
|
|
10629
|
+
{ command: "run [#<issue>|<task-id>|--next|--task <id>]", description: "Submit a task run; interactive follows with bundled Pi.", primary: true },
|
|
10630
|
+
{ command: "validate|verify [--task <id>]", description: "Run configured task checks/review gates." },
|
|
10631
|
+
{ command: "artifacts|artifact-dir|artifact-write", description: "Inspect or write task artifacts." },
|
|
10632
|
+
{ command: "report-bug", description: "Create a structured bug report/task." }
|
|
10633
|
+
],
|
|
10634
|
+
examples: [
|
|
10635
|
+
"rig task list --assignee @me --limit 20",
|
|
10636
|
+
"rig task run --next",
|
|
10637
|
+
"rig task run #123 --runtime-adapter pi",
|
|
10638
|
+
"rig task run --title 'Investigate deploy drift' --initial-prompt 'Check server health'"
|
|
10639
|
+
],
|
|
10640
|
+
next: ["Use `--detach` to submit without attaching.", "Use `rig run attach <run-id> --follow` to rejoin a live run."]
|
|
10641
|
+
},
|
|
10642
|
+
{
|
|
10643
|
+
name: "run",
|
|
10644
|
+
summary: "Observe, attach to, and control Rig runs.",
|
|
10645
|
+
usage: ["rig run <list|status|show|attach|stop> [options]"],
|
|
10646
|
+
commands: [
|
|
10647
|
+
{ command: "list", description: "List recent runs from the selected server or local state.", primary: true },
|
|
10648
|
+
{ command: "status", description: "Summarize active and recent runs.", primary: true },
|
|
10649
|
+
{ command: "show --run <id>", description: "Show one run record.", primary: true },
|
|
10650
|
+
{ command: "attach <run-id>|--run <id> [--follow]", description: "Attach to the run; `--follow` launches native bundled Pi for live Pi runs.", primary: true },
|
|
10651
|
+
{ command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
|
|
10652
|
+
{ command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events." },
|
|
10653
|
+
{ command: "delete|cleanup", description: "Remove completed run records/artifacts." }
|
|
10654
|
+
],
|
|
10655
|
+
examples: [
|
|
10656
|
+
"rig run list",
|
|
10657
|
+
"rig run attach 01234567-89ab-cdef-0123-456789abcdef --follow",
|
|
10658
|
+
"rig run show --run <run-id>",
|
|
10659
|
+
"rig run stop <run-id>"
|
|
10660
|
+
],
|
|
10661
|
+
next: ["Use `rig task run --next` to create a new run.", "Use `--json` when scripts need the full structured record."]
|
|
10662
|
+
}
|
|
10663
|
+
];
|
|
10664
|
+
var ADVANCED_GROUPS = [
|
|
10665
|
+
{ 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." }] },
|
|
10666
|
+
{ name: "github", summary: "GitHub auth helpers.", usage: ["rig github auth <status|import-gh|token>"], commands: [{ command: "auth status", description: "Show GitHub auth state." }] },
|
|
10667
|
+
{ name: "doctor", summary: "Diagnostics for project/server/GitHub/Pi state.", usage: ["rig doctor [check|run|shared|...]"], commands: [{ command: "check", description: "Run diagnostics." }] },
|
|
10668
|
+
{ name: "setup", summary: "Bootstrap/check local setup.", usage: ["rig setup <bootstrap|check|preflight>"], commands: [{ command: "bootstrap|check|preflight", description: "Setup helpers." }] },
|
|
10669
|
+
{ 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." }] },
|
|
10670
|
+
{ name: "repo", summary: "Repository sync/baseline helpers.", usage: ["rig repo <sync|reset-baseline>"], commands: [{ command: "sync", description: "Sync project repository state." }] },
|
|
10671
|
+
{ name: "profile", summary: "Runtime profile/model defaults.", usage: ["rig profile <show|set>"], commands: [{ command: "show", description: "Show active profile." }] },
|
|
10672
|
+
{ name: "review", summary: "Review policy configuration.", usage: ["rig review <show|set>"], commands: [{ command: "show", description: "Show review settings." }] },
|
|
10673
|
+
{ name: "browser", summary: "Browser/app diagnostics.", usage: ["rig browser <help|explain|demo|app>"], commands: [{ command: "help", description: "Browser command help." }] },
|
|
10674
|
+
{ name: "plugin", summary: "Plugin validation/listing.", usage: ["rig plugin <list|validate>"], commands: [{ command: "list", description: "List plugins." }] },
|
|
10675
|
+
{ name: "queue", summary: "Run task queues locally.", usage: ["rig queue run [options]"], commands: [{ command: "run", description: "Process queue work." }] },
|
|
10676
|
+
{ name: "agent", summary: "Runtime agent workspace helpers.", usage: ["rig agent <list|prepare|run|cleanup>"], commands: [{ command: "list", description: "List prepared agents." }] },
|
|
10677
|
+
{ name: "inspector", summary: "Event stream and drift scanners.", usage: ["rig inspector <stream|scan-upstream-drift>"], commands: [{ command: "stream", description: "Stream events." }] },
|
|
10678
|
+
{ name: "dist", summary: "Build/install packaged Rig CLI.", usage: ["rig dist <build|install|doctor>"], commands: [{ command: "build", description: "Build distribution." }] },
|
|
10679
|
+
{ name: "workspace", summary: "Workspace topology/service helpers.", usage: ["rig workspace <summary|topology|remote-hosts>"], commands: [{ command: "summary", description: "Show workspace summary." }] },
|
|
10680
|
+
{ name: "remote", summary: "Legacy remote orchestration controls.", usage: ["rig remote <status|watch|pause|resume|...>"], commands: [{ command: "status", description: "Show remote state." }] },
|
|
10681
|
+
{ name: "inbox", summary: "Approval/input inbox for blocked runs.", usage: ["rig inbox <approvals|approve|inputs|respond>"], commands: [{ command: "approvals", description: "List pending approvals." }] },
|
|
10682
|
+
{ name: "git", summary: "Pass through to Rig git-flow helper.", usage: ["rig git <args...>"], commands: [{ command: "<args...>", description: "Advanced git flow operations." }] },
|
|
10683
|
+
{ name: "harness", summary: "Pass through to runtime harness CLI.", usage: ["rig harness <args...>"], commands: [{ command: "<args...>", description: "Advanced harness operations." }] },
|
|
10684
|
+
{ name: "test", summary: "Project test wrappers.", usage: ["rig test <unit|e2e|all>"], commands: [{ command: "all", description: "Run configured project tests." }] }
|
|
10685
|
+
];
|
|
10686
|
+
var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
|
|
10687
|
+
function heading(title) {
|
|
10688
|
+
return pc4.bold(pc4.cyan(title));
|
|
10689
|
+
}
|
|
10690
|
+
function commandLine(command, description) {
|
|
10691
|
+
const commandColumn = command.length >= 34 ? `${command} ` : command.padEnd(34);
|
|
10692
|
+
return `${pc4.dim("\u2502")} ${pc4.bold(commandColumn)} ${description}`;
|
|
10693
|
+
}
|
|
10694
|
+
function renderGroup(group) {
|
|
10695
|
+
const lines = [
|
|
10696
|
+
`${heading(`rig ${group.name}`)} \u2014 ${group.summary}`,
|
|
10697
|
+
"",
|
|
10698
|
+
pc4.bold("Usage"),
|
|
10699
|
+
...group.usage.map((line) => ` ${line}`),
|
|
10700
|
+
"",
|
|
10701
|
+
pc4.bold("Commands"),
|
|
10702
|
+
...group.commands.map((entry) => commandLine(entry.command, entry.description))
|
|
10703
|
+
];
|
|
10704
|
+
if (group.examples?.length) {
|
|
10705
|
+
lines.push("", pc4.bold("Examples"), ...group.examples.map((line) => ` ${pc4.dim("$")} ${line}`));
|
|
10706
|
+
}
|
|
10707
|
+
if (group.next?.length) {
|
|
10708
|
+
lines.push("", pc4.bold("Next steps"), ...group.next.map((line) => ` ${pc4.dim("\u203A")} ${line}`));
|
|
10709
|
+
}
|
|
10710
|
+
if (group.advanced?.length) {
|
|
10711
|
+
lines.push("", pc4.bold("Compatibility / advanced"), ...group.advanced.map((line) => ` ${pc4.dim("\u203A")} ${line}`));
|
|
10712
|
+
}
|
|
10713
|
+
return lines.join(`
|
|
10714
|
+
`);
|
|
10715
|
+
}
|
|
10716
|
+
function renderTopLevelHelp() {
|
|
10717
|
+
return [
|
|
10718
|
+
`${heading("rig")} ${pc4.dim("\u2014 server-owned task/run control plane for Pi-backed engineering work")}`,
|
|
10719
|
+
pc4.dim("A repo-local CLI for setup, server selection, task runs, live attach, and completion review."),
|
|
10720
|
+
"",
|
|
10721
|
+
`${pc4.bold(pc4.magenta("\u25C7 Start here"))} \u2014 ${pc4.dim("bootstrap a repo and choose where Rig runs")}`,
|
|
10722
|
+
commandLine("rig init", "Interactive setup: project config, GitHub auth, task source, server, checkout, Pi."),
|
|
10723
|
+
commandLine("rig init --yes", "Non-interactive setup using detected defaults; good for repeatable installs."),
|
|
10724
|
+
commandLine("rig server status", "Show whether this repo is using local Rig or a remote server."),
|
|
10725
|
+
commandLine("rig server use <alias|local>", "Switch the server that owns task/run state for this repo."),
|
|
10726
|
+
"",
|
|
10727
|
+
`${pc4.bold(pc4.magenta("\u25C7 Daily task loop"))} \u2014 ${pc4.dim("find work, start a worker, and rejoin it later")}`,
|
|
10728
|
+
commandLine("rig task list", "List tasks from the selected task source/server with status, labels, and source."),
|
|
10729
|
+
commandLine("rig task next", "Pick the next matching task without starting it."),
|
|
10730
|
+
commandLine("rig task run --next", "Start the next task and attach to the live bundled Pi frontend."),
|
|
10731
|
+
commandLine("rig task run #123 --detach", "Submit a specific issue/task and return immediately."),
|
|
10732
|
+
"",
|
|
10733
|
+
`${pc4.bold(pc4.magenta("\u25C7 Live run control"))} \u2014 ${pc4.dim("observe, steer, stop, or inspect active runs")}`,
|
|
10734
|
+
commandLine("rig run list", "Show recent/active runs from the selected server or local state."),
|
|
10735
|
+
commandLine("rig run attach <run-id> --follow", "Open the native Pi live view for a worker-backed run."),
|
|
10736
|
+
commandLine("rig run show --run <id>", "Print one run record; add `--json` for automation."),
|
|
10737
|
+
commandLine("rig run stop <run-id>", "Request cancellation for a running worker."),
|
|
10738
|
+
"",
|
|
10739
|
+
`${pc4.bold(pc4.magenta("\u25C7 Core groups"))} \u2014 ${pc4.dim("run `rig <group> --help` for detailed commands and examples")}`,
|
|
10740
|
+
...PRIMARY_GROUPS.map((group) => commandLine(group.name, group.summary)),
|
|
10741
|
+
commandLine("doctor", "Diagnose project/server/GitHub/task/Pi wiring when setup or runs misbehave."),
|
|
10742
|
+
"",
|
|
10743
|
+
`${pc4.bold(pc4.magenta("\u25C7 More"))}`,
|
|
10744
|
+
commandLine("rig help --advanced", "Legacy, dev, diagnostics, browser, queue, agent, remote, git, harness commands."),
|
|
10745
|
+
commandLine("rig <group> --help", "Rich per-group help with usage, descriptions, examples, and next steps."),
|
|
10746
|
+
commandLine("rig --version", "Print the installed Rig CLI version."),
|
|
10747
|
+
"",
|
|
10748
|
+
`${pc4.bold(pc4.magenta("\u25C7 Global options"))}`,
|
|
10749
|
+
commandLine("--project <path>", "Use a project root instead of auto-discovery."),
|
|
10750
|
+
commandLine("--json", "Emit structured output for scripts/agents."),
|
|
10751
|
+
commandLine("--dry-run", "Print the command plan without mutating state.")
|
|
10752
|
+
].join(`
|
|
10753
|
+
`);
|
|
10754
|
+
}
|
|
10755
|
+
function renderAdvancedHelp() {
|
|
10756
|
+
return [
|
|
10757
|
+
`${heading("rig advanced")} \u2014 legacy, dev, and compatibility groups`,
|
|
10758
|
+
"",
|
|
10759
|
+
pc4.bold("Primary groups are still"),
|
|
10760
|
+
" init, server, task, run",
|
|
10761
|
+
"",
|
|
10762
|
+
pc4.bold("Advanced groups"),
|
|
10763
|
+
...ADVANCED_GROUPS.map((group) => commandLine(group.name, group.summary)),
|
|
10764
|
+
"",
|
|
10765
|
+
pc4.dim("All groups remain callable. Prefer `rig server`, `rig task`, and `rig run` for day-to-day work.")
|
|
10766
|
+
].join(`
|
|
10767
|
+
`);
|
|
10768
|
+
}
|
|
10769
|
+
function renderGroupHelp(groupName) {
|
|
10770
|
+
const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
|
|
10771
|
+
return group ? renderGroup(group) : null;
|
|
10772
|
+
}
|
|
10773
|
+
|
|
10484
10774
|
// packages/cli/src/commands.ts
|
|
10485
10775
|
import { ensureProjectMainFreshBeforeRun as ensureProjectMainFreshBeforeRun2 } from "@rig/runtime/control-plane/project-main-pre-run-sync";
|
|
10486
10776
|
var TOP_LEVEL_ALIASES = {
|
|
@@ -10548,102 +10838,13 @@ var GROUPS = new Set([
|
|
|
10548
10838
|
"test"
|
|
10549
10839
|
]);
|
|
10550
10840
|
function printGroupHelp(group) {
|
|
10551
|
-
|
|
10552
|
-
`);
|
|
10553
|
-
const groupLineRe = new RegExp(`^ ${group}\\b`);
|
|
10554
|
-
const out = [`rig ${group} \u2014 command group`, ""];
|
|
10555
|
-
let inGroup = false;
|
|
10556
|
-
for (const line of lines) {
|
|
10557
|
-
if (groupLineRe.test(line)) {
|
|
10558
|
-
inGroup = true;
|
|
10559
|
-
out.push(line);
|
|
10560
|
-
continue;
|
|
10561
|
-
}
|
|
10562
|
-
if (inGroup) {
|
|
10563
|
-
if (line.startsWith(" ") || line.startsWith(" ")) {
|
|
10564
|
-
out.push(line);
|
|
10565
|
-
} else {
|
|
10566
|
-
break;
|
|
10567
|
-
}
|
|
10568
|
-
}
|
|
10569
|
-
}
|
|
10570
|
-
if (out.length === 2) {
|
|
10571
|
-
console.log(helpText());
|
|
10572
|
-
return;
|
|
10573
|
-
}
|
|
10574
|
-
console.log(out.join(`
|
|
10575
|
-
`));
|
|
10841
|
+
console.log(renderGroupHelp(group) ?? helpText());
|
|
10576
10842
|
}
|
|
10577
10843
|
function isHelpArg(arg) {
|
|
10578
10844
|
return arg === "--help" || arg === "-h" || arg === "help";
|
|
10579
10845
|
}
|
|
10580
10846
|
function helpText() {
|
|
10581
|
-
return
|
|
10582
|
-
"rig - Event-driven Bun control plane for Project Rig",
|
|
10583
|
-
"",
|
|
10584
|
-
"Usage:",
|
|
10585
|
-
" rig <group> <command> [options]",
|
|
10586
|
-
" rig <alias-command> [options]",
|
|
10587
|
-
" (compat: bun run rig ...)",
|
|
10588
|
-
"",
|
|
10589
|
-
"Groups:",
|
|
10590
|
-
" init [--server local|remote] [--remote-url <url>] [--repo owner/repo] [--github-auth gh|token|device|skip]",
|
|
10591
|
-
" [--github-token <token>] [--github-project off|<project-id>] [--github-project-status-field <id>]",
|
|
10592
|
-
" [--remote-checkout managed-clone|current-ref|uploaded-snapshot|existing-path] [--existing-path <path>] [--repair|--private-state-only] [--yes]",
|
|
10593
|
-
" connect list | add <alias> <url> | use <alias|local> | status",
|
|
10594
|
-
" github auth status | auth import-gh | auth token --token <token>",
|
|
10595
|
-
" doctor run shared server/project/GitHub/Projects/projection/labels/Pi/pi-rig/PR/checkout diagnostics",
|
|
10596
|
-
" setup bootstrap | check | setup | preflight | install-agent-shell",
|
|
10597
|
-
" run status | attach <run-id> [--message <text>] [--once|--follow] | start | start-parallel | start-serial | resume | stop | list | show --run <id> | timeline --run <id> [--follow]",
|
|
10598
|
-
" delete --run <id> [--purge-artifacts] | cleanup --all [--keep-artifacts] [--keep-runtimes] [--keep-queue]",
|
|
10599
|
-
" start flags: [--epic <id>] [--prompt-epic|--no-epic-prompt] [--ws-port <n>] [--server-host <host>] [--server-port <n>] [--poll-ms <n>] [--no-server]",
|
|
10600
|
-
" task list|next [--assignee <login|@me>] [--assigned-to <login|me|@me>] [--state <state>] [--status <status>] [--limit <n>]",
|
|
10601
|
-
" 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]",
|
|
10602
|
-
" info | scope [--files] | deps | ready | validate [--task <id>] | verify [--task <id>]",
|
|
10603
|
-
" lookup <id> | record <decision|failure> <text> | artifacts | reset --task <id> | details --task <id>",
|
|
10604
|
-
" artifact-dir | artifact-write <filename> [--file <path>]",
|
|
10605
|
-
" report-bug [--no-prompt] [--no-beads] [--browser|--no-browser] [--title <text>] [--url <url>] [--environment local|shared-dev|staging|production|custom]",
|
|
10606
|
-
" report-bug flags: [--summary <text>] [--steps <a;b>] [--expected <text>] [--actual <text>] [--evidence <a;b>] [--asset <dragged-file>] [--video <dragged-file>] [--screenshot <path>]",
|
|
10607
|
-
" [--priority P0-P4] [--labels <a,b>] [--parent <task-id>] [--assignee <name>] [--owner <email>]",
|
|
10608
|
-
" [--preset <name>] [--profile <name>] [--attach-url <url>] [--state-dir <path>] [--mode <mode>] [--viewport <WxH>]",
|
|
10609
|
-
" [--output-dir <path>] [--slug <slug>] [--overwrite]",
|
|
10610
|
-
" reopen [--task <id> | --all] [--reason <text>]",
|
|
10611
|
-
" inspect logs --task <id> | artifacts --task <id> | artifact --task <id> --file <name> | failures | graph | audit | diff [--task <id>]",
|
|
10612
|
-
" repo sync [--task <id>] | reset-baseline [--keep-task-status]",
|
|
10613
|
-
" profile show | set <claude-code|codex-cli|pi> | set [--model ...] [--runtime ...] [--plugin ...]",
|
|
10614
|
-
" review show | set <off|advisory|required> [--provider greptile]",
|
|
10615
|
-
" browser help | explain | demo | app <dev|start|check|e2e|reset> (set RIG_BROWSER_APP=<slug>) | cdp-probe | profile-persistence | profile-lock-check",
|
|
10616
|
-
" plugin list | validate --task <id>",
|
|
10617
|
-
" queue run [--workers <n>] [--max-tasks <n>] [--action validate|verify|pipeline] [--isolation off|worktree] [--no-runtime-reuse] [--fail-fast] [--skip-project-sync]",
|
|
10618
|
-
" agent list | prepare [--id <id>] [--mode worktree] | run [--id <id>] [--mode worktree] [--skip-project-sync] -- <command...> | cleanup (--id <id> | --all)",
|
|
10619
|
-
" cleanup is runtime-only; use run cleanup to remove authority runs, logs, artifacts, and queue state",
|
|
10620
|
-
" inspector stream [--once] [--seconds <n>] [--poll-ms <n>] | scan-upstream-drift [--scan-id <id>]",
|
|
10621
|
-
" server start [--host <host>] [--port <n>] [--poll-ms <n>] [--auth-token <token>]",
|
|
10622
|
-
" notify-test [--event <type>] | task-run [--task <id>] [--title <text>] [--runtime-adapter claude-code|codex|pi] [--model <model>]",
|
|
10623
|
-
" [--runtime-mode <mode>] [--interaction-mode <mode>] [--initial-prompt <text>]",
|
|
10624
|
-
" dist build [--output-dir <dir>] | install [--scope user|system] [--path <dir>] | doctor | rebuild-agent",
|
|
10625
|
-
" workspace summary | topology | remote-hosts | service-fabric <status|up|verify|down> [--service <name>]",
|
|
10626
|
-
" remote test | status | tasks | watch [--seconds <n>] [--event <type>] | pause | resume | stop | continue | refresh",
|
|
10627
|
-
" add-iterations --count <n> | remove-iterations --count <n> | prompt-preview --task <id> | iteration-output --task <id>",
|
|
10628
|
-
" orchestrate-start [--max-workers <n>] [--max-iterations <n>] [--direct-merge]",
|
|
10629
|
-
" orchestrate-pause --id <id> | orchestrate-resume --id <id> | orchestrate-stop --id <id> | orchestrate-state --id <id>",
|
|
10630
|
-
" 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",
|
|
10631
|
-
" endpoint flags: [--remote <alias>] [--host <host>] [--port <n>] [--token <token>]",
|
|
10632
|
-
" inbox approvals [--run <id>] [--task <id>] | approve --run <id> --request <id> --decision approve|reject [--note <text>]",
|
|
10633
|
-
" inputs [--run <id>] [--task <id>] | respond --run <id> --request <id> --answer key=value [--answer key=value]",
|
|
10634
|
-
" git <git-flow args...>",
|
|
10635
|
-
" harness <harness args...>",
|
|
10636
|
-
" test unit | e2e | all",
|
|
10637
|
-
"",
|
|
10638
|
-
"Global Options:",
|
|
10639
|
-
" --version, -V Print rig version and exit",
|
|
10640
|
-
" --help, -h Print this help (or `rig <group> --help` for group help)",
|
|
10641
|
-
" --project <path> Use this server/project root instead of auto-discovery or PROJECT_RIG_ROOT",
|
|
10642
|
-
" --dry-run Print command execution plan without running commands",
|
|
10643
|
-
" --json Output structured JSON result",
|
|
10644
|
-
" --policy-mode <m> Override policy mode: off|observe|enforce"
|
|
10645
|
-
].join(`
|
|
10646
|
-
`);
|
|
10847
|
+
return renderTopLevelHelp();
|
|
10647
10848
|
}
|
|
10648
10849
|
async function execute(context, args) {
|
|
10649
10850
|
if (args.length === 0) {
|
|
@@ -10657,6 +10858,14 @@ async function execute(context, args) {
|
|
|
10657
10858
|
${helpText()}`);
|
|
10658
10859
|
}
|
|
10659
10860
|
if (first === "help" || first === "--help" || first === "-h") {
|
|
10861
|
+
if (rest[0] === "--advanced") {
|
|
10862
|
+
console.log(renderAdvancedHelp());
|
|
10863
|
+
return { ok: true, group: "help", command: "advanced" };
|
|
10864
|
+
}
|
|
10865
|
+
if (rest[0]) {
|
|
10866
|
+
console.log(renderGroupHelp(rest[0]) ?? helpText());
|
|
10867
|
+
return { ok: true, group: "help", command: rest[0] };
|
|
10868
|
+
}
|
|
10660
10869
|
console.log(helpText());
|
|
10661
10870
|
return { ok: true, group: "help", command: "show" };
|
|
10662
10871
|
}
|