@h-rig/cli 0.0.6-alpha.19 → 0.0.6-alpha.20
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 +266 -56
- package/dist/src/commands/_cli-format.js +106 -0
- package/dist/src/commands/_doctor-checks.js +3 -2
- package/dist/src/commands/_pi-install.js +4 -3
- package/dist/src/commands/_pi-session.js +253 -0
- package/dist/src/commands/_preflight.js +3 -2
- package/dist/src/commands/_task-picker.js +31 -11
- package/dist/src/commands/doctor.js +3 -2
- package/dist/src/commands/init.js +4 -3
- package/dist/src/commands/run.js +169 -9
- package/dist/src/commands/setup.js +3 -2
- package/dist/src/commands/task.js +234 -42
- package/dist/src/commands.js +266 -56
- package/dist/src/index.js +266 -56
- package/package.json +5 -5
package/dist/src/index.js
CHANGED
|
@@ -2986,7 +2986,8 @@ async function submitTaskRunViaServer(context, input) {
|
|
|
2986
2986
|
import { existsSync as existsSync6, readFileSync as readFileSync4, rmSync as rmSync3 } from "fs";
|
|
2987
2987
|
import { homedir as homedir3 } from "os";
|
|
2988
2988
|
import { resolve as resolve10 } from "path";
|
|
2989
|
-
var PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
|
|
2989
|
+
var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
|
|
2990
|
+
var LEGACY_PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
|
|
2990
2991
|
var LEGACY_PI_RIG_MARKER = `// Managed by Rig. Source package: @rig/pi-rig.
|
|
2991
2992
|
export { default } from '@rig/pi-rig';
|
|
2992
2993
|
`;
|
|
@@ -3014,7 +3015,7 @@ function resolvePiHomeDir(inputHomeDir) {
|
|
|
3014
3015
|
function piListContainsPiRig(output) {
|
|
3015
3016
|
return output.split(/\r?\n/).some((line) => {
|
|
3016
3017
|
const normalized = line.trim();
|
|
3017
|
-
return normalized.includes(PI_RIG_PACKAGE_NAME) || /(?:^|[\\/])packages[\\/]pi-rig(?:$|\s)/.test(normalized);
|
|
3018
|
+
return normalized.includes(PI_RIG_PACKAGE_NAME) || normalized.includes(LEGACY_PI_RIG_PACKAGE_NAME) || /(?:^|[\\/])packages[\\/]pi-rig(?:$|\s)/.test(normalized);
|
|
3018
3019
|
});
|
|
3019
3020
|
}
|
|
3020
3021
|
async function safeRun(runner, command, options) {
|
|
@@ -3130,7 +3131,7 @@ async function ensureRemotePiRigInstalled(input) {
|
|
|
3130
3131
|
const payload = await input.requestJson("/api/pi-rig/install", {
|
|
3131
3132
|
method: "POST",
|
|
3132
3133
|
headers: { "content-type": "application/json" },
|
|
3133
|
-
body: JSON.stringify({ package:
|
|
3134
|
+
body: JSON.stringify({ package: PI_RIG_PACKAGE_NAME, scope: "global" })
|
|
3134
3135
|
});
|
|
3135
3136
|
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
3136
3137
|
const piOk = record.piOk === true || record.ok === true;
|
|
@@ -6672,6 +6673,193 @@ async function attachRunOperatorView(context, input) {
|
|
|
6672
6673
|
return { ...snapshot, steered, detached };
|
|
6673
6674
|
}
|
|
6674
6675
|
|
|
6676
|
+
// packages/cli/src/commands/_cli-format.ts
|
|
6677
|
+
import pc3 from "picocolors";
|
|
6678
|
+
function stringField(record, key, fallback = "") {
|
|
6679
|
+
const value = record[key];
|
|
6680
|
+
return typeof value === "string" && value.trim() ? value.trim() : fallback;
|
|
6681
|
+
}
|
|
6682
|
+
function arrayField(record, key) {
|
|
6683
|
+
const value = record[key];
|
|
6684
|
+
return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" && entry.trim() ? [entry.trim()] : []) : [];
|
|
6685
|
+
}
|
|
6686
|
+
function rawObject(record) {
|
|
6687
|
+
const raw = record.raw;
|
|
6688
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
6689
|
+
}
|
|
6690
|
+
function truncate(value, width) {
|
|
6691
|
+
if (value.length <= width)
|
|
6692
|
+
return value;
|
|
6693
|
+
if (width <= 1)
|
|
6694
|
+
return "\u2026";
|
|
6695
|
+
return `${value.slice(0, width - 1)}\u2026`;
|
|
6696
|
+
}
|
|
6697
|
+
function pad(value, width) {
|
|
6698
|
+
return value.length >= width ? value : `${value}${" ".repeat(width - value.length)}`;
|
|
6699
|
+
}
|
|
6700
|
+
function statusColor(status) {
|
|
6701
|
+
const normalized = status.toLowerCase();
|
|
6702
|
+
if (["completed", "merged", "closed", "done", "accepted"].includes(normalized))
|
|
6703
|
+
return pc3.green;
|
|
6704
|
+
if (["failed", "needs_attention", "needs-attention", "blocked"].includes(normalized))
|
|
6705
|
+
return pc3.red;
|
|
6706
|
+
if (["running", "reviewing", "validating", "in_progress", "in-progress"].includes(normalized))
|
|
6707
|
+
return pc3.cyan;
|
|
6708
|
+
if (["ready", "open", "queued", "created", "preparing"].includes(normalized))
|
|
6709
|
+
return pc3.yellow;
|
|
6710
|
+
return pc3.dim;
|
|
6711
|
+
}
|
|
6712
|
+
function formatTaskList(tasks, options = {}) {
|
|
6713
|
+
if (tasks.length === 0)
|
|
6714
|
+
return pc3.dim("No matching tasks.");
|
|
6715
|
+
if (options.raw)
|
|
6716
|
+
return tasks.map((task) => JSON.stringify(task)).join(`
|
|
6717
|
+
`);
|
|
6718
|
+
const rows = tasks.map((task) => {
|
|
6719
|
+
const raw = rawObject(task);
|
|
6720
|
+
const id = stringField(task, "id", "<unknown>");
|
|
6721
|
+
const status = stringField(task, "status", "unknown");
|
|
6722
|
+
const title = stringField(task, "title", "Untitled task");
|
|
6723
|
+
const source = stringField(task, "source", stringField(raw, "source", ""));
|
|
6724
|
+
const labels = arrayField(task, "labels").length > 0 ? arrayField(task, "labels") : arrayField(raw, "labels");
|
|
6725
|
+
return { id, status, title, source, labels };
|
|
6726
|
+
});
|
|
6727
|
+
const idWidth = Math.min(18, Math.max(4, ...rows.map((row) => row.id.length)));
|
|
6728
|
+
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
6729
|
+
const header = `${pc3.bold(pad("TASK", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
6730
|
+
const body = rows.map((row) => {
|
|
6731
|
+
const labels = row.labels.length > 0 ? pc3.dim(` ${row.labels.slice(0, 4).map((label) => `#${label}`).join(" ")}`) : "";
|
|
6732
|
+
const source = row.source ? pc3.dim(` ${row.source}`) : "";
|
|
6733
|
+
return [
|
|
6734
|
+
pc3.bold(pad(truncate(row.id, idWidth), idWidth)),
|
|
6735
|
+
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
6736
|
+
`${row.title}${labels}${source}`
|
|
6737
|
+
].join(" ");
|
|
6738
|
+
});
|
|
6739
|
+
return [pc3.bold("Rig tasks"), header, ...body].join(`
|
|
6740
|
+
`);
|
|
6741
|
+
}
|
|
6742
|
+
function formatRunList(runs, options = {}) {
|
|
6743
|
+
if (runs.length === 0) {
|
|
6744
|
+
return pc3.dim(options.source === "server" ? "No runs recorded on the selected Rig server." : "No runs recorded in .rig/runs.");
|
|
6745
|
+
}
|
|
6746
|
+
const rows = runs.map((run) => {
|
|
6747
|
+
const runId = stringField(run, "runId", stringField(run, "id", "(unknown-run)"));
|
|
6748
|
+
const status = stringField(run, "status", "unknown");
|
|
6749
|
+
const taskId2 = stringField(run, "taskId", "");
|
|
6750
|
+
const title = stringField(run, "title", taskId2 || "(untitled)");
|
|
6751
|
+
const runtime = stringField(run, "runtimeAdapter", "");
|
|
6752
|
+
return { runId, status, title, runtime };
|
|
6753
|
+
});
|
|
6754
|
+
const idWidth = Math.min(36, Math.max(6, ...rows.map((row) => row.runId.length)));
|
|
6755
|
+
const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
|
|
6756
|
+
const header = `${pc3.bold(pad("RUN", idWidth))} ${pc3.bold(pad("STATUS", statusWidth))} ${pc3.bold("TITLE")}`;
|
|
6757
|
+
const body = rows.map((row) => [
|
|
6758
|
+
pc3.bold(pad(truncate(row.runId, idWidth), idWidth)),
|
|
6759
|
+
statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
|
|
6760
|
+
`${row.title}${row.runtime ? pc3.dim(` ${row.runtime}`) : ""}`
|
|
6761
|
+
].join(" "));
|
|
6762
|
+
return [pc3.bold(options.source === "server" ? "Rig runs (server)" : "Rig runs"), header, ...body].join(`
|
|
6763
|
+
`);
|
|
6764
|
+
}
|
|
6765
|
+
function formatSubmittedRun(input) {
|
|
6766
|
+
const lines = [`${pc3.green("Run submitted")}: ${pc3.bold(input.runId)}`];
|
|
6767
|
+
if (input.task) {
|
|
6768
|
+
const id = stringField(input.task, "id", "<unknown>");
|
|
6769
|
+
const status = stringField(input.task, "status", "unknown");
|
|
6770
|
+
const title = stringField(input.task, "title", "Untitled task");
|
|
6771
|
+
lines.push(`${pc3.dim("task")} ${pc3.bold(id)} ${statusColor(status)(status)} ${title}`);
|
|
6772
|
+
}
|
|
6773
|
+
return lines.join(`
|
|
6774
|
+
`);
|
|
6775
|
+
}
|
|
6776
|
+
|
|
6777
|
+
// packages/cli/src/commands/_pi-session.ts
|
|
6778
|
+
import { spawn as spawn2 } from "child_process";
|
|
6779
|
+
function buildPiRigSessionEnv(input) {
|
|
6780
|
+
return {
|
|
6781
|
+
RIG_PROJECT_ROOT: input.projectRoot,
|
|
6782
|
+
PROJECT_RIG_ROOT: input.projectRoot,
|
|
6783
|
+
RIG_RUN_ID: input.runId,
|
|
6784
|
+
RIG_SERVER_RUN_ID: input.runId,
|
|
6785
|
+
RIG_RUNTIME_ADAPTER: "pi",
|
|
6786
|
+
RIG_SERVER_URL: input.serverUrl,
|
|
6787
|
+
RIG_SERVER_BASE_URL: input.serverUrl,
|
|
6788
|
+
RIG_STEERING_POLL_MS: process.env.RIG_STEERING_POLL_MS?.trim() || "1000",
|
|
6789
|
+
RIG_PI_OPERATOR_SESSION: "1",
|
|
6790
|
+
...input.taskId ? { RIG_TASK_ID: input.taskId } : {},
|
|
6791
|
+
...input.authToken ? { RIG_AUTH_TOKEN: input.authToken } : {}
|
|
6792
|
+
};
|
|
6793
|
+
}
|
|
6794
|
+
function shellBinary(name) {
|
|
6795
|
+
const explicit = process.env.RIG_PI_BINARY?.trim();
|
|
6796
|
+
if (explicit)
|
|
6797
|
+
return explicit;
|
|
6798
|
+
return Bun.which(name) || name;
|
|
6799
|
+
}
|
|
6800
|
+
function buildPiRigSessionCommand(input) {
|
|
6801
|
+
const configuredExtension = input.extensionSource ?? process.env.RIG_PI_RIG_EXTENSION_SOURCE?.trim();
|
|
6802
|
+
const extensionSource = configuredExtension && configuredExtension.length > 0 ? configuredExtension : resolvePiRigPackageSource(input.projectRoot);
|
|
6803
|
+
const initialCommand = `/rig attach ${input.runId}`;
|
|
6804
|
+
return [
|
|
6805
|
+
shellBinary("pi"),
|
|
6806
|
+
"--no-extensions",
|
|
6807
|
+
"--extension",
|
|
6808
|
+
extensionSource,
|
|
6809
|
+
initialCommand
|
|
6810
|
+
];
|
|
6811
|
+
}
|
|
6812
|
+
async function launchPiRigSession(context, input) {
|
|
6813
|
+
if (context.outputMode !== "text" || !process.stdin.isTTY || !process.stdout.isTTY) {
|
|
6814
|
+
return { launched: false, exitCode: null, command: [] };
|
|
6815
|
+
}
|
|
6816
|
+
if (process.env.RIG_DISABLE_PI_LAUNCH === "1") {
|
|
6817
|
+
return { launched: false, exitCode: null, command: [] };
|
|
6818
|
+
}
|
|
6819
|
+
const server = await ensureServerForCli(context.projectRoot);
|
|
6820
|
+
const command = buildPiRigSessionCommand({ ...input, projectRoot: context.projectRoot });
|
|
6821
|
+
const env = {
|
|
6822
|
+
...process.env,
|
|
6823
|
+
...buildPiRigSessionEnv({
|
|
6824
|
+
projectRoot: context.projectRoot,
|
|
6825
|
+
runId: input.runId,
|
|
6826
|
+
taskId: input.taskId,
|
|
6827
|
+
serverUrl: server.baseUrl,
|
|
6828
|
+
authToken: server.authToken
|
|
6829
|
+
})
|
|
6830
|
+
};
|
|
6831
|
+
process.stdout.write(`Launching Pi for Rig run ${input.runId}\u2026
|
|
6832
|
+
`);
|
|
6833
|
+
process.stdout.write(`Pi command: ${formatCommand(command)}
|
|
6834
|
+
`);
|
|
6835
|
+
const launchedAt = Date.now();
|
|
6836
|
+
const child = spawn2(command[0], command.slice(1), {
|
|
6837
|
+
cwd: context.projectRoot,
|
|
6838
|
+
env,
|
|
6839
|
+
stdio: "inherit"
|
|
6840
|
+
});
|
|
6841
|
+
const launchError = await new Promise((resolve20) => {
|
|
6842
|
+
child.once("error", (error) => {
|
|
6843
|
+
resolve20({ error: error.message });
|
|
6844
|
+
});
|
|
6845
|
+
child.once("close", (code) => resolve20({ code }));
|
|
6846
|
+
});
|
|
6847
|
+
if ("error" in launchError) {
|
|
6848
|
+
process.stderr.write(`Failed to launch Pi; falling back to Rig attach view: ${launchError.error}
|
|
6849
|
+
`);
|
|
6850
|
+
return { launched: false, exitCode: null, command, error: launchError.error };
|
|
6851
|
+
}
|
|
6852
|
+
const exitCode = launchError.code;
|
|
6853
|
+
const elapsedMs = Date.now() - launchedAt;
|
|
6854
|
+
if (typeof exitCode === "number" && exitCode !== 0 && elapsedMs < 5000) {
|
|
6855
|
+
const error = `Pi exited during startup with code ${exitCode}.`;
|
|
6856
|
+
process.stderr.write(`${error} Falling back to Rig attach view.
|
|
6857
|
+
`);
|
|
6858
|
+
return { launched: false, exitCode, command, error };
|
|
6859
|
+
}
|
|
6860
|
+
return { launched: true, exitCode, command };
|
|
6861
|
+
}
|
|
6862
|
+
|
|
6675
6863
|
// packages/cli/src/commands/run.ts
|
|
6676
6864
|
function normalizeRemoteRunDetails(payload) {
|
|
6677
6865
|
const run = payload.run;
|
|
@@ -6773,13 +6961,7 @@ async function executeRun(context, args) {
|
|
|
6773
6961
|
requireNoExtraArgs(rest, "bun run rig run list");
|
|
6774
6962
|
const { runs, source } = await listRunsForSelectedConnection(context, { limit: 100 });
|
|
6775
6963
|
if (context.outputMode === "text") {
|
|
6776
|
-
|
|
6777
|
-
console.log(source === "server" ? "No runs recorded on the selected Rig server." : "No runs recorded in .rig/runs.");
|
|
6778
|
-
} else {
|
|
6779
|
-
for (const run of runs) {
|
|
6780
|
-
console.log(`- ${runStringField(run, "runId", "(unknown-run)")} \xB7 ${runStringField(run, "status", "unknown")} \xB7 ${runDisplayTitle(run)}`);
|
|
6781
|
-
}
|
|
6782
|
-
}
|
|
6964
|
+
console.log(formatRunList(runs, { source }));
|
|
6783
6965
|
}
|
|
6784
6966
|
return { ok: true, group: "run", command, details: { runs, source } };
|
|
6785
6967
|
}
|
|
@@ -6901,14 +7083,26 @@ async function executeRun(context, args) {
|
|
|
6901
7083
|
if (!runId) {
|
|
6902
7084
|
throw new CliError2("run attach requires a run id.", 2);
|
|
6903
7085
|
}
|
|
7086
|
+
let steered = false;
|
|
7087
|
+
const shouldTryPiAttach = context.outputMode === "text" && follow.value && !once.value && Boolean(process.stdin.isTTY && process.stdout.isTTY) && process.env.RIG_DISABLE_PI_LAUNCH !== "1";
|
|
7088
|
+
if (shouldTryPiAttach && messageOption.value?.trim()) {
|
|
7089
|
+
await steerRunViaServer(context, runId, messageOption.value.trim());
|
|
7090
|
+
steered = true;
|
|
7091
|
+
}
|
|
7092
|
+
if (shouldTryPiAttach) {
|
|
7093
|
+
const piSession = await launchPiRigSession(context, { runId });
|
|
7094
|
+
if (piSession.launched) {
|
|
7095
|
+
return { ok: true, group: "run", command, details: { runId, steered, mode: "pi", ...piSession } };
|
|
7096
|
+
}
|
|
7097
|
+
}
|
|
6904
7098
|
const attached = await attachRunOperatorView(context, {
|
|
6905
7099
|
runId,
|
|
6906
|
-
message: messageOption.value ?? null,
|
|
7100
|
+
message: shouldTryPiAttach ? null : messageOption.value ?? null,
|
|
6907
7101
|
once: once.value,
|
|
6908
7102
|
follow: follow.value,
|
|
6909
7103
|
pollMs: parsePositiveInt(pollMs.value, "--poll-ms", 2000)
|
|
6910
7104
|
});
|
|
6911
|
-
return { ok: true, group: "run", command, details: attached };
|
|
7105
|
+
return { ok: true, group: "run", command, details: { ...attached, steered: attached.steered || steered } };
|
|
6912
7106
|
}
|
|
6913
7107
|
case "status": {
|
|
6914
7108
|
requireNoExtraArgs(rest, "bun run rig run status");
|
|
@@ -7174,8 +7368,8 @@ async function executeServer(context, args, options) {
|
|
|
7174
7368
|
// packages/cli/src/commands/task.ts
|
|
7175
7369
|
import { readFileSync as readFileSync9 } from "fs";
|
|
7176
7370
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
7177
|
-
import { createInterface as createInterface3 } from "readline/promises";
|
|
7178
7371
|
import { resolve as resolve20 } from "path";
|
|
7372
|
+
import { cancel as cancel3, confirm as confirm2, isCancel as isCancel3 } from "@clack/prompts";
|
|
7179
7373
|
import {
|
|
7180
7374
|
taskArtifactDir,
|
|
7181
7375
|
taskArtifacts,
|
|
@@ -7193,6 +7387,7 @@ import {
|
|
|
7193
7387
|
} from "@rig/runtime/control-plane/native/task-ops";
|
|
7194
7388
|
|
|
7195
7389
|
// packages/cli/src/commands/_task-picker.ts
|
|
7390
|
+
import { cancel as cancel2, isCancel as isCancel2, select as select2 } from "@clack/prompts";
|
|
7196
7391
|
function taskId2(task) {
|
|
7197
7392
|
return typeof task.id === "string" && task.id.trim() ? task.id : "<unknown>";
|
|
7198
7393
|
}
|
|
@@ -7205,20 +7400,37 @@ async function selectTaskWithTextPicker(tasks, io = {}) {
|
|
|
7205
7400
|
if (!isTty) {
|
|
7206
7401
|
throw new Error("task run requires an interactive terminal to pick a task; pass --task <id>, --next, or --detach with a task id.");
|
|
7207
7402
|
}
|
|
7208
|
-
|
|
7209
|
-
|
|
7403
|
+
if (io.prompt || io.renderer) {
|
|
7404
|
+
const prompt = io.prompt ?? promptForTaskSelection;
|
|
7405
|
+
const renderer = io.renderer ?? { writeLine: (line) => process.stdout.write(`${line}
|
|
7210
7406
|
`) };
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7407
|
+
renderer.writeLine("Select Rig task:");
|
|
7408
|
+
for (const row of renderTaskPickerRows(tasks))
|
|
7409
|
+
renderer.writeLine(` ${row}`);
|
|
7410
|
+
const answer2 = (await prompt(`Task [1-${tasks.length}] or id: `)).trim();
|
|
7411
|
+
if (!answer2)
|
|
7412
|
+
return null;
|
|
7413
|
+
if (/^\d+$/.test(answer2)) {
|
|
7414
|
+
const index2 = Number.parseInt(answer2, 10) - 1;
|
|
7415
|
+
return tasks[index2] ?? null;
|
|
7416
|
+
}
|
|
7417
|
+
return tasks.find((task) => taskId2(task) === answer2) ?? null;
|
|
7418
|
+
}
|
|
7419
|
+
const options = tasks.map((task, index2) => ({
|
|
7420
|
+
value: `${index2}`,
|
|
7421
|
+
label: `${taskId2(task)} \xB7 ${typeof task.title === "string" && task.title.trim() ? task.title.trim() : "Untitled task"}`,
|
|
7422
|
+
hint: typeof task.status === "string" && task.status.trim() ? task.status.trim() : undefined
|
|
7423
|
+
}));
|
|
7424
|
+
const answer = await select2({
|
|
7425
|
+
message: "Select Rig task",
|
|
7426
|
+
options
|
|
7427
|
+
});
|
|
7428
|
+
if (isCancel2(answer)) {
|
|
7429
|
+
cancel2("No task selected.");
|
|
7216
7430
|
return null;
|
|
7217
|
-
if (/^\d+$/.test(answer)) {
|
|
7218
|
-
const index = Number.parseInt(answer, 10) - 1;
|
|
7219
|
-
return tasks[index] ?? null;
|
|
7220
7431
|
}
|
|
7221
|
-
|
|
7432
|
+
const index = Number.parseInt(String(answer), 10);
|
|
7433
|
+
return Number.isFinite(index) ? tasks[index] ?? null : null;
|
|
7222
7434
|
}
|
|
7223
7435
|
|
|
7224
7436
|
// packages/cli/src/commands/task.ts
|
|
@@ -7330,13 +7542,15 @@ async function resolveDirtyBaselineForTaskRun(context, explicit) {
|
|
|
7330
7542
|
if (explicit)
|
|
7331
7543
|
return { mode: explicit, state };
|
|
7332
7544
|
if (context.outputMode === "text" && process.stdin.isTTY && process.stdout.isTTY) {
|
|
7333
|
-
const
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7545
|
+
const answer = await confirm2({
|
|
7546
|
+
message: "Include current uncommitted changes in run baseline?",
|
|
7547
|
+
initialValue: false
|
|
7548
|
+
});
|
|
7549
|
+
if (isCancel3(answer)) {
|
|
7550
|
+
cancel3("Run cancelled.");
|
|
7551
|
+
throw new CliError2("Run cancelled by user.", 1);
|
|
7339
7552
|
}
|
|
7553
|
+
return { mode: answer ? "dirty-snapshot" : "head", state };
|
|
7340
7554
|
}
|
|
7341
7555
|
return { mode: "head", state };
|
|
7342
7556
|
}
|
|
@@ -7371,10 +7585,7 @@ function summarizeTask(task, options = {}) {
|
|
|
7371
7585
|
};
|
|
7372
7586
|
}
|
|
7373
7587
|
function printTaskSummary(task) {
|
|
7374
|
-
|
|
7375
|
-
const title = readTaskString(task, "title") ?? "Untitled task";
|
|
7376
|
-
const status = readTaskString(task, "status") ?? "unknown";
|
|
7377
|
-
console.log(`- ${id} \xB7 ${status} \xB7 ${title}`);
|
|
7588
|
+
console.log(formatTaskList([task]));
|
|
7378
7589
|
}
|
|
7379
7590
|
async function validatorRegistryForTaskCommands(projectRoot) {
|
|
7380
7591
|
return buildPluginHostContext(projectRoot).then((ctx) => ctx?.validatorRegistry ?? undefined).catch(() => {
|
|
@@ -7392,16 +7603,8 @@ async function executeTask(context, args, options) {
|
|
|
7392
7603
|
requireNoExtraArgs(remaining, "bun run rig task list [--raw] [--assignee <login|@me>] [--assigned-to <login|me|@me>] [--state open|closed] [--status <status>] [--limit <n>]");
|
|
7393
7604
|
const tasks = await listWorkspaceTasksViaServer(context, filters);
|
|
7394
7605
|
if (context.outputMode === "text") {
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
} else {
|
|
7398
|
-
for (const task of tasks) {
|
|
7399
|
-
if (rawResult.value)
|
|
7400
|
-
console.log(JSON.stringify(summarizeTask(task, { raw: true })));
|
|
7401
|
-
else
|
|
7402
|
-
printTaskSummary(task);
|
|
7403
|
-
}
|
|
7404
|
-
}
|
|
7606
|
+
const renderedTasks = rawResult.value ? tasks.map((task) => summarizeTask(task, { raw: true })) : tasks.map((task) => summarizeTask(task));
|
|
7607
|
+
console.log(formatTaskList(renderedTasks, { raw: rawResult.value }));
|
|
7405
7608
|
}
|
|
7406
7609
|
return {
|
|
7407
7610
|
ok: true,
|
|
@@ -7620,16 +7823,23 @@ async function executeTask(context, args, options) {
|
|
|
7620
7823
|
});
|
|
7621
7824
|
let attachDetails = null;
|
|
7622
7825
|
if (!detachResult.value && context.outputMode === "text") {
|
|
7623
|
-
console.log(
|
|
7624
|
-
if (
|
|
7625
|
-
|
|
7826
|
+
console.log(formatSubmittedRun({ runId: submitted.runId, task: selectedTask ? summarizeTask(selectedTask) : null }));
|
|
7827
|
+
if (runtimeAdapter === "pi") {
|
|
7828
|
+
const piSession = await launchPiRigSession(context, {
|
|
7829
|
+
runId: submitted.runId,
|
|
7830
|
+
taskId: selectedTaskId,
|
|
7831
|
+
title: titleResult.value ?? readTaskString(selectedTask ?? {}, "title"),
|
|
7832
|
+
runtimeAdapter
|
|
7833
|
+
});
|
|
7834
|
+
attachDetails = { mode: "pi", ...piSession };
|
|
7835
|
+
if (!piSession.launched) {
|
|
7836
|
+
attachDetails = await attachRunOperatorView(context, { runId: submitted.runId, follow: true });
|
|
7837
|
+
}
|
|
7838
|
+
} else {
|
|
7839
|
+
attachDetails = await attachRunOperatorView(context, { runId: submitted.runId, follow: true });
|
|
7626
7840
|
}
|
|
7627
|
-
attachDetails = await attachRunOperatorView(context, { runId: submitted.runId, follow: true });
|
|
7628
7841
|
} else if (context.outputMode === "text") {
|
|
7629
|
-
console.log(
|
|
7630
|
-
if (selectedTask) {
|
|
7631
|
-
printTaskSummary(selectedTask);
|
|
7632
|
-
}
|
|
7842
|
+
console.log(formatSubmittedRun({ runId: submitted.runId, task: selectedTask ? summarizeTask(selectedTask) : null }));
|
|
7633
7843
|
}
|
|
7634
7844
|
return {
|
|
7635
7845
|
ok: true,
|
|
@@ -7714,7 +7924,7 @@ async function executeTask(context, args, options) {
|
|
|
7714
7924
|
// packages/cli/src/commands/task-run-driver.ts
|
|
7715
7925
|
import { copyFileSync as copyFileSync3, existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
7716
7926
|
import { resolve as resolve21 } from "path";
|
|
7717
|
-
import { spawn as
|
|
7927
|
+
import { spawn as spawn3, spawnSync as spawnSync4 } from "child_process";
|
|
7718
7928
|
import { createInterface as createLineInterface } from "readline";
|
|
7719
7929
|
import { loadConfig as loadConfig2 } from "@rig/core/load-config";
|
|
7720
7930
|
import {
|
|
@@ -7942,7 +8152,7 @@ async function runCheckedCommand(command, args, cwd, label = "git") {
|
|
|
7942
8152
|
}
|
|
7943
8153
|
function createCommandRunner(binary) {
|
|
7944
8154
|
return async (args, options) => {
|
|
7945
|
-
const child =
|
|
8155
|
+
const child = spawn3(binary, [...args], {
|
|
7946
8156
|
cwd: options?.cwd,
|
|
7947
8157
|
stdio: ["ignore", "pipe", "pipe"]
|
|
7948
8158
|
});
|
|
@@ -9056,7 +9266,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
9056
9266
|
}
|
|
9057
9267
|
for (let attempt = 1;!exit && attempt <= maxAttempts; attempt += 1) {
|
|
9058
9268
|
const attemptHostAgentCommand = buildHostAgentCommand(currentPrompt);
|
|
9059
|
-
const child =
|
|
9269
|
+
const child = spawn3(attemptHostAgentCommand[0], attemptHostAgentCommand.slice(1), {
|
|
9060
9270
|
cwd: context.projectRoot,
|
|
9061
9271
|
env: childEnv,
|
|
9062
9272
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -9403,7 +9613,7 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
|
|
|
9403
9613
|
});
|
|
9404
9614
|
emitServerRunEvent({ type: "log", runId: input.runId, title: "Steering Pi from PR feedback" });
|
|
9405
9615
|
const feedbackCommand = buildHostAgentCommand(message2);
|
|
9406
|
-
const child =
|
|
9616
|
+
const child = spawn3(feedbackCommand[0], feedbackCommand.slice(1), {
|
|
9407
9617
|
cwd: latestRuntimeWorkspace ?? context.projectRoot,
|
|
9408
9618
|
env: childEnv,
|
|
9409
9619
|
stdio: ["pipe", "pipe", "pipe"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/cli",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rig package",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@clack/prompts": "^1.2.0",
|
|
26
|
-
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.
|
|
27
|
-
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.
|
|
28
|
-
"@rig/client": "npm:@h-rig/client@0.0.6-alpha.
|
|
29
|
-
"@rig/server": "npm:@h-rig/server@0.0.6-alpha.
|
|
26
|
+
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.20",
|
|
27
|
+
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.20",
|
|
28
|
+
"@rig/client": "npm:@h-rig/client@0.0.6-alpha.20",
|
|
29
|
+
"@rig/server": "npm:@h-rig/server@0.0.6-alpha.20",
|
|
30
30
|
"picocolors": "^1.1.1"
|
|
31
31
|
}
|
|
32
32
|
}
|