@h-rig/cli 0.0.6-alpha.60 → 0.0.6-alpha.62
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 +316 -134
- package/dist/src/commands/_authority-runs.js +2 -3
- package/dist/src/commands/_help-catalog.js +1 -0
- package/dist/src/commands/_run-driver-helpers.js +12 -17
- package/dist/src/commands/_run-replay.js +142 -0
- package/dist/src/commands/agent.js +2 -3
- package/dist/src/commands/run.js +216 -38
- package/dist/src/commands/server.js +4 -5
- package/dist/src/commands/task-run-driver.js +29 -26
- package/dist/src/commands/task.js +4 -4
- package/dist/src/commands.js +308 -126
- package/dist/src/index.js +316 -134
- package/package.json +7 -7
|
@@ -52,11 +52,13 @@ import {
|
|
|
52
52
|
import { readFileSync } from "fs";
|
|
53
53
|
import { resolve as resolve3 } from "path";
|
|
54
54
|
import {
|
|
55
|
-
appendJsonlRecord,
|
|
56
55
|
appendRunLifecycleEvent,
|
|
56
|
+
appendRunLogEntry,
|
|
57
|
+
appendRunTimelineEntry,
|
|
58
|
+
patchAuthorityRunRecord,
|
|
57
59
|
readAuthorityRun as readAuthorityRun2,
|
|
58
|
-
resolveAuthorityRunDir
|
|
59
|
-
writeJsonFile
|
|
60
|
+
resolveAuthorityRunDir,
|
|
61
|
+
writeJsonFile
|
|
60
62
|
} from "@rig/runtime/control-plane/authority-files";
|
|
61
63
|
import { taskLookup } from "@rig/runtime/control-plane/native/task-ops";
|
|
62
64
|
import { readPriorPrProgressPromptSection } from "@rig/runtime/control-plane/prompt-context";
|
|
@@ -69,8 +71,7 @@ import { resolve as resolve2 } from "path";
|
|
|
69
71
|
import {
|
|
70
72
|
readAuthorityRun,
|
|
71
73
|
readJsonlFile,
|
|
72
|
-
|
|
73
|
-
writeJsonFile
|
|
74
|
+
writeAuthorityRunRecord
|
|
74
75
|
} from "@rig/runtime/control-plane/authority-files";
|
|
75
76
|
|
|
76
77
|
// packages/cli/src/commands/_paths.ts
|
|
@@ -168,22 +169,16 @@ function upsertAgentAuthorityRun(projectRoot, input) {
|
|
|
168
169
|
} else if ("errorText" in next) {
|
|
169
170
|
delete next.errorText;
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
+
writeAuthorityRunRecord(projectRoot, input.runId, next);
|
|
172
173
|
return next;
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
// packages/cli/src/commands/_run-driver-helpers.ts
|
|
176
177
|
function patchAuthorityRun(projectRoot, runId, patch) {
|
|
177
|
-
const
|
|
178
|
-
if (!
|
|
178
|
+
const next = patchAuthorityRunRecord(projectRoot, runId, patch);
|
|
179
|
+
if (!next) {
|
|
179
180
|
throw new CliError2(`Run not found: ${runId}`, 2);
|
|
180
181
|
}
|
|
181
|
-
const next = {
|
|
182
|
-
...current,
|
|
183
|
-
...patch,
|
|
184
|
-
updatedAt: new Date().toISOString()
|
|
185
|
-
};
|
|
186
|
-
writeJsonFile2(resolve3(resolveAuthorityRunDir2(projectRoot, runId), "run.json"), next);
|
|
187
182
|
return next;
|
|
188
183
|
}
|
|
189
184
|
function touchAuthorityRun(projectRoot, runId) {
|
|
@@ -191,21 +186,21 @@ function touchAuthorityRun(projectRoot, runId) {
|
|
|
191
186
|
if (!current) {
|
|
192
187
|
return;
|
|
193
188
|
}
|
|
194
|
-
|
|
189
|
+
writeJsonFile(resolve3(resolveAuthorityRunDir(projectRoot, runId), "run.json"), {
|
|
195
190
|
...current,
|
|
196
191
|
updatedAt: new Date().toISOString()
|
|
197
192
|
});
|
|
198
193
|
}
|
|
199
194
|
function appendRunTimeline(projectRoot, runId, value) {
|
|
200
|
-
|
|
195
|
+
appendRunTimelineEntry(projectRoot, runId, value);
|
|
201
196
|
touchAuthorityRun(projectRoot, runId);
|
|
202
197
|
}
|
|
203
198
|
function appendRunLog(projectRoot, runId, value) {
|
|
204
|
-
|
|
199
|
+
appendRunLogEntry(projectRoot, runId, value);
|
|
205
200
|
touchAuthorityRun(projectRoot, runId);
|
|
206
201
|
}
|
|
207
202
|
function appendRunAction(projectRoot, runId, value) {
|
|
208
|
-
|
|
203
|
+
appendRunTimelineEntry(projectRoot, runId, {
|
|
209
204
|
id: value.id,
|
|
210
205
|
type: "action",
|
|
211
206
|
actionType: value.actionType,
|
|
@@ -449,7 +444,7 @@ function readJsonFile(path) {
|
|
|
449
444
|
throw new CliError2(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1);
|
|
450
445
|
}
|
|
451
446
|
}
|
|
452
|
-
function
|
|
447
|
+
function writeJsonFile2(path, value) {
|
|
453
448
|
mkdirSync(dirname(path), { recursive: true });
|
|
454
449
|
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
455
450
|
`, "utf8");
|
|
@@ -499,7 +494,7 @@ function readRepoConnection(projectRoot) {
|
|
|
499
494
|
};
|
|
500
495
|
}
|
|
501
496
|
function writeRepoConnection(projectRoot, state) {
|
|
502
|
-
|
|
497
|
+
writeJsonFile2(resolveRepoConnectionPath(projectRoot), state);
|
|
503
498
|
}
|
|
504
499
|
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
505
500
|
const repo = readRepoConnection(projectRoot);
|
|
@@ -1530,6 +1525,8 @@ async function executeRigOwnedTaskRun(context, input) {
|
|
|
1530
1525
|
const runtimeTaskId = input.taskId?.trim() || `adhoc-${input.runId}`;
|
|
1531
1526
|
const existingRunRecord = readAuthorityRun3(context.projectRoot, input.runId);
|
|
1532
1527
|
const resumeMode = process.env.RIG_RUN_RESUME === "1";
|
|
1528
|
+
let latestPiSessionId = typeof existingRunRecord?.piSession?.sessionId === "string" && existingRunRecord.piSession.sessionId.trim() ? existingRunRecord.piSession.sessionId : null;
|
|
1529
|
+
const sessionAnchor = () => latestPiSessionId ? { sessionId: latestPiSessionId } : {};
|
|
1533
1530
|
const resumePreviousStatus = String(existingRunRecord?.status ?? "").toLowerCase();
|
|
1534
1531
|
const sourceTask = readRunSourceTaskContract(context.projectRoot, input.runId, input.taskId);
|
|
1535
1532
|
let prompt = buildRunPrompt({
|
|
@@ -1602,7 +1599,8 @@ async function executeRigOwnedTaskRun(context, input) {
|
|
|
1602
1599
|
type: "status",
|
|
1603
1600
|
runId: input.runId,
|
|
1604
1601
|
status: "preparing",
|
|
1605
|
-
detail: input.taskId ?? input.title ?? runtimeTaskId
|
|
1602
|
+
detail: input.taskId ?? input.title ?? runtimeTaskId,
|
|
1603
|
+
...sessionAnchor()
|
|
1606
1604
|
});
|
|
1607
1605
|
appendRunLog(context.projectRoot, input.runId, {
|
|
1608
1606
|
id: `log:${input.runId}:${resumeMode ? "resume" : "start"}`,
|
|
@@ -1723,7 +1721,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
1723
1721
|
return;
|
|
1724
1722
|
verificationStarted = true;
|
|
1725
1723
|
patchAuthorityRun(context.projectRoot, input.runId, { status: "validating" });
|
|
1726
|
-
emitServerRunEvent({ type: "status", runId: input.runId, status: "validating", detail: detail ?? null });
|
|
1724
|
+
emitServerRunEvent({ type: "status", runId: input.runId, status: "validating", detail: detail ?? null, ...sessionAnchor() });
|
|
1727
1725
|
verificationAction = startRunAction(context.projectRoot, input.runId, {
|
|
1728
1726
|
actionId: `action:${input.runId}:completion-verification`,
|
|
1729
1727
|
actionType: "completion-verification",
|
|
@@ -1736,7 +1734,7 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
1736
1734
|
return;
|
|
1737
1735
|
reviewStarted = true;
|
|
1738
1736
|
patchAuthorityRun(context.projectRoot, input.runId, { status: "reviewing" });
|
|
1739
|
-
emitServerRunEvent({ type: "status", runId: input.runId, status: "reviewing", detail: detail ?? null });
|
|
1737
|
+
emitServerRunEvent({ type: "status", runId: input.runId, status: "reviewing", detail: detail ?? null, ...sessionAnchor() });
|
|
1740
1738
|
reviewAction = startRunAction(context.projectRoot, input.runId, {
|
|
1741
1739
|
actionId: `action:${input.runId}:review-closeout`,
|
|
1742
1740
|
actionType: "run.review",
|
|
@@ -1826,7 +1824,8 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
1826
1824
|
type: "status",
|
|
1827
1825
|
runId: input.runId,
|
|
1828
1826
|
status: "running",
|
|
1829
|
-
detail: latestRuntimeWorkspace
|
|
1827
|
+
detail: latestRuntimeWorkspace,
|
|
1828
|
+
...sessionAnchor()
|
|
1830
1829
|
});
|
|
1831
1830
|
return true;
|
|
1832
1831
|
}
|
|
@@ -1909,6 +1908,9 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
1909
1908
|
piSessionPrivate: privateMetadata
|
|
1910
1909
|
});
|
|
1911
1910
|
const sessionId = typeof publicMetadata?.sessionId === "string" ? publicMetadata.sessionId : typeof privateMetadata.public === "object" && privateMetadata.public && !Array.isArray(privateMetadata.public) ? String(privateMetadata.public.sessionId ?? "") : "";
|
|
1911
|
+
if (sessionId) {
|
|
1912
|
+
latestPiSessionId = sessionId;
|
|
1913
|
+
}
|
|
1912
1914
|
appendRunLog(context.projectRoot, input.runId, {
|
|
1913
1915
|
id: `log:${input.runId}:pi-session-ready`,
|
|
1914
1916
|
title: "Worker Pi session ready",
|
|
@@ -2303,7 +2305,8 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
|
|
|
2303
2305
|
type: "status",
|
|
2304
2306
|
runId: input.runId,
|
|
2305
2307
|
status: "validating",
|
|
2306
|
-
detail: failureDetail
|
|
2308
|
+
detail: failureDetail,
|
|
2309
|
+
...sessionAnchor()
|
|
2307
2310
|
});
|
|
2308
2311
|
emitServerRunEvent({ type: "log", runId: input.runId, title: "Validate failed" });
|
|
2309
2312
|
emitServerRunEvent({ type: "log", runId: input.runId, title: `Steering Pi to retry validation (attempt ${attempt + 1}/${maxAttempts})` });
|
|
@@ -2441,7 +2444,7 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
|
|
|
2441
2444
|
payload: { runtimeWorkspace: latestRuntimeWorkspace, branch: latestRuntimeBranch }
|
|
2442
2445
|
});
|
|
2443
2446
|
emitServerRunEvent({ type: "log", runId: input.runId, title: "Server-owned closeout requested" });
|
|
2444
|
-
emitServerRunEvent({ type: "status", runId: input.runId, status: "reviewing", detail: "Server-owned closeout requested." });
|
|
2447
|
+
emitServerRunEvent({ type: "status", runId: input.runId, status: "reviewing", detail: "Server-owned closeout requested.", ...sessionAnchor() });
|
|
2445
2448
|
await context.emitEvent("command.finished", {
|
|
2446
2449
|
command: [
|
|
2447
2450
|
"rig",
|
|
@@ -78,8 +78,7 @@ import {
|
|
|
78
78
|
import {
|
|
79
79
|
readAuthorityRun,
|
|
80
80
|
readJsonlFile,
|
|
81
|
-
|
|
82
|
-
writeJsonFile
|
|
81
|
+
writeAuthorityRunRecord
|
|
83
82
|
} from "@rig/runtime/control-plane/authority-files";
|
|
84
83
|
|
|
85
84
|
// packages/cli/src/commands/_paths.ts
|
|
@@ -128,7 +127,7 @@ function readJsonFile(path) {
|
|
|
128
127
|
throw new CliError2(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1);
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
|
-
function
|
|
130
|
+
function writeJsonFile(path, value) {
|
|
132
131
|
mkdirSync(dirname(path), { recursive: true });
|
|
133
132
|
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
134
133
|
`, "utf8");
|
|
@@ -178,7 +177,7 @@ function readRepoConnection(projectRoot) {
|
|
|
178
177
|
};
|
|
179
178
|
}
|
|
180
179
|
function writeRepoConnection(projectRoot, state) {
|
|
181
|
-
|
|
180
|
+
writeJsonFile(resolveRepoConnectionPath(projectRoot), state);
|
|
182
181
|
}
|
|
183
182
|
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
184
183
|
const repo = readRepoConnection(projectRoot);
|
|
@@ -2156,6 +2155,7 @@ var PRIMARY_GROUPS = [
|
|
|
2156
2155
|
{ command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
|
|
2157
2156
|
{ command: "steer <run-id> --message <text>", description: "Queue a steering message into a live worker without attaching." },
|
|
2158
2157
|
{ command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events." },
|
|
2158
|
+
{ command: "replay <run-id>|--run <id> [--with-session]", description: "Print the run's consolidated run.jsonl as a merged timeline; --with-session interleaves the Pi session log." },
|
|
2159
2159
|
{ command: "resume", description: "Resume the most recent interrupted local run." },
|
|
2160
2160
|
{ command: "restart", description: "Restart the most recent local run from a clean runtime." },
|
|
2161
2161
|
{ command: "delete|cleanup", description: "Remove completed run records/artifacts." }
|