@h-rig/cli 0.0.6-alpha.27 → 0.0.6-alpha.29

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.
Files changed (42) hide show
  1. package/dist/bin/rig.js +1505 -907
  2. package/dist/src/commands/_cli-format.js +211 -6
  3. package/dist/src/commands/_connection-state.js +1 -3
  4. package/dist/src/commands/_doctor-checks.js +3 -5
  5. package/dist/src/commands/_help-catalog.js +251 -66
  6. package/dist/src/commands/_operator-view.js +1 -3
  7. package/dist/src/commands/_parsers.js +0 -2
  8. package/dist/src/commands/_pi-frontend.js +1 -3
  9. package/dist/src/commands/_pi-worker-bridge-extension.js +1 -3
  10. package/dist/src/commands/_policy.js +0 -2
  11. package/dist/src/commands/_preflight.js +2 -4
  12. package/dist/src/commands/_run-driver-helpers.js +0 -2
  13. package/dist/src/commands/_server-client.js +1 -3
  14. package/dist/src/commands/_snapshot-upload.js +1 -3
  15. package/dist/src/commands/agent.js +7 -9
  16. package/dist/src/commands/browser.js +4 -6
  17. package/dist/src/commands/connect.js +5 -6
  18. package/dist/src/commands/dist.js +4 -6
  19. package/dist/src/commands/doctor.js +3 -5
  20. package/dist/src/commands/github.js +1 -3
  21. package/dist/src/commands/inbox.js +351 -31
  22. package/dist/src/commands/init.js +3 -5
  23. package/dist/src/commands/inspect.js +10 -12
  24. package/dist/src/commands/inspector.js +2 -4
  25. package/dist/src/commands/plugin.js +76 -22
  26. package/dist/src/commands/profile-and-review.js +8 -10
  27. package/dist/src/commands/queue.js +1 -3
  28. package/dist/src/commands/remote.js +18 -20
  29. package/dist/src/commands/repo-git-harness.js +6 -8
  30. package/dist/src/commands/run.js +159 -41
  31. package/dist/src/commands/server.js +6 -7
  32. package/dist/src/commands/setup.js +7 -15
  33. package/dist/src/commands/task-report-bug.js +5 -7
  34. package/dist/src/commands/task-run-driver.js +1 -3
  35. package/dist/src/commands/task.js +483 -50
  36. package/dist/src/commands/test.js +3 -5
  37. package/dist/src/commands/workspace.js +4 -6
  38. package/dist/src/commands.js +1508 -901
  39. package/dist/src/index.js +1511 -916
  40. package/dist/src/report-bug.js +3 -3
  41. package/dist/src/runner.js +2 -17
  42. package/package.json +6 -6
@@ -1,14 +1,12 @@
1
1
  // @bun
2
2
  // packages/cli/src/commands/inbox.ts
3
- import { writeFileSync } from "fs";
4
- import { resolve } from "path";
3
+ import { writeFileSync as writeFileSync2 } from "fs";
4
+ import { resolve as resolve3 } from "path";
5
5
 
6
6
  // packages/cli/src/runner.ts
7
7
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
8
8
  import { CliError } from "@rig/runtime/control-plane/errors";
9
9
  import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
10
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
11
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
12
10
  import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
13
11
  import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
14
12
  function takeOption(args, option) {
@@ -44,6 +42,334 @@ import {
44
42
  readJsonlFile,
45
43
  resolveAuthorityRunDir
46
44
  } from "@rig/runtime/control-plane/authority-files";
45
+
46
+ // packages/cli/src/commands/_cli-format.ts
47
+ import { log, note } from "@clack/prompts";
48
+ import pc from "picocolors";
49
+ function stringField(record, key, fallback = "") {
50
+ const value = record[key];
51
+ return typeof value === "string" && value.trim() ? value.trim() : fallback;
52
+ }
53
+ function statusColor(status) {
54
+ const normalized = status.toLowerCase();
55
+ if (["completed", "merged", "closed", "done", "accepted", "pass", "selected", "approved"].includes(normalized))
56
+ return pc.green;
57
+ if (["failed", "needs_attention", "needs-attention", "blocked", "error", "rejected"].includes(normalized))
58
+ return pc.red;
59
+ if (["running", "reviewing", "validating", "in_progress", "in-progress", "remote"].includes(normalized))
60
+ return pc.cyan;
61
+ if (["ready", "open", "queued", "created", "preparing", "local", "pending"].includes(normalized))
62
+ return pc.yellow;
63
+ return pc.dim;
64
+ }
65
+ function firstString(record, keys, fallback = "") {
66
+ for (const key of keys) {
67
+ const value = stringField(record, key);
68
+ if (value)
69
+ return value;
70
+ }
71
+ return fallback;
72
+ }
73
+ function requestIdOf(entry) {
74
+ return firstString(entry, ["requestId", "id", "approvalId", "inputId"], "(unknown-request)");
75
+ }
76
+ function shouldUseClackOutput() {
77
+ return Boolean(process.stdout.isTTY) && process.env.RIG_CLI_PLAIN_HELP !== "1";
78
+ }
79
+ function printFormattedOutput(message, options = {}) {
80
+ if (!shouldUseClackOutput()) {
81
+ console.log(message);
82
+ return;
83
+ }
84
+ if (options.title)
85
+ note(message, options.title);
86
+ else
87
+ log.message(message);
88
+ }
89
+ function formatStatusPill(status) {
90
+ const label = status || "unknown";
91
+ return statusColor(label)(`\u25CF ${label}`);
92
+ }
93
+ function formatSection(title, subtitle) {
94
+ return `${pc.bold(pc.cyan("\u25C6"))} ${pc.bold(title)}${subtitle ? pc.dim(` \u2014 ${subtitle}`) : ""}`;
95
+ }
96
+ function formatNextSteps(steps) {
97
+ if (steps.length === 0)
98
+ return [];
99
+ return [pc.bold("Next"), ...steps.map((step) => `${pc.dim("\u203A")} ${step}`)];
100
+ }
101
+ function formatInboxList(kind, entries) {
102
+ const title = kind === "approvals" ? "Approval inbox" : "Input inbox";
103
+ if (entries.length === 0) {
104
+ return [
105
+ formatSection(title, "empty"),
106
+ pc.dim(kind === "approvals" ? "No pending approvals." : "No pending user-input requests."),
107
+ "",
108
+ ...formatNextSteps(["Check runs: `rig run status`", "Start work: `rig task run --next`"])
109
+ ].join(`
110
+ `);
111
+ }
112
+ const lines = [formatSection(title, `${entries.length} pending`)];
113
+ for (const entry of entries) {
114
+ const record = entry.record && typeof entry.record === "object" && !Array.isArray(entry.record) ? entry.record : entry;
115
+ const runId = firstString(entry, ["runId"], firstString(record, ["runId"]));
116
+ const taskId = firstString(entry, ["taskId"], firstString(record, ["taskId", "task"]));
117
+ const requestId = requestIdOf(record);
118
+ const status = firstString(record, ["status", "state"], "pending");
119
+ const prompt = firstString(record, ["prompt", "message", "reason", "title", "summary"], kind === "approvals" ? "Approval requested" : "Input requested");
120
+ lines.push(`${pc.dim("\u2502")} ${pc.bold(requestId)} ${formatStatusPill(status)} ${prompt}`);
121
+ lines.push(`${pc.dim("\u2502")} ${pc.dim("run ")} ${runId || "(unknown-run)"}${taskId ? pc.dim(` task ${taskId}`) : ""}`);
122
+ }
123
+ lines.push("", ...formatNextSteps(kind === "approvals" ? ["Resolve: `rig inbox approve --run <run-id> --request <request-id> --decision approve|reject`", "Rejoin: `rig run attach <run-id> --follow`"] : ["Respond: `rig inbox respond --run <run-id> --request <request-id> --answer key=value`", "Rejoin: `rig run attach <run-id> --follow`"]));
124
+ return lines.join(`
125
+ `);
126
+ }
127
+
128
+ // packages/cli/src/commands/_connection-state.ts
129
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
130
+ import { homedir } from "os";
131
+ import { dirname, resolve } from "path";
132
+ function resolveGlobalConnectionsPath(env = process.env) {
133
+ const explicit = env.RIG_CONNECTIONS_FILE?.trim();
134
+ if (explicit)
135
+ return resolve(explicit);
136
+ const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
137
+ if (stateDir)
138
+ return resolve(stateDir, "connections.json");
139
+ return resolve(homedir(), ".rig", "connections.json");
140
+ }
141
+ function resolveRepoConnectionPath(projectRoot) {
142
+ return resolve(projectRoot, ".rig", "state", "connection.json");
143
+ }
144
+ function readJsonFile(path) {
145
+ if (!existsSync(path))
146
+ return null;
147
+ try {
148
+ return JSON.parse(readFileSync(path, "utf8"));
149
+ } catch (error) {
150
+ throw new CliError2(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1);
151
+ }
152
+ }
153
+ function normalizeConnection(value) {
154
+ if (!value || typeof value !== "object" || Array.isArray(value))
155
+ return null;
156
+ const record = value;
157
+ if (record.kind === "local")
158
+ return { kind: "local", mode: "auto" };
159
+ if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
160
+ const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
161
+ return { kind: "remote", baseUrl };
162
+ }
163
+ return null;
164
+ }
165
+ function readGlobalConnections(options = {}) {
166
+ const path = resolveGlobalConnectionsPath(options.env ?? process.env);
167
+ const payload = readJsonFile(path);
168
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
169
+ return { connections: {} };
170
+ }
171
+ const rawConnections = payload.connections;
172
+ const connections = {};
173
+ if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
174
+ for (const [alias, raw] of Object.entries(rawConnections)) {
175
+ const connection = normalizeConnection(raw);
176
+ if (connection)
177
+ connections[alias] = connection;
178
+ }
179
+ }
180
+ return { connections };
181
+ }
182
+ function readRepoConnection(projectRoot) {
183
+ const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
184
+ if (!payload || typeof payload !== "object" || Array.isArray(payload))
185
+ return null;
186
+ const record = payload;
187
+ const selected = typeof record.selected === "string" ? record.selected.trim() : "";
188
+ if (!selected)
189
+ return null;
190
+ return {
191
+ selected,
192
+ project: typeof record.project === "string" ? record.project : undefined,
193
+ linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined
194
+ };
195
+ }
196
+ function resolveSelectedConnection(projectRoot, options = {}) {
197
+ const repo = readRepoConnection(projectRoot);
198
+ if (!repo)
199
+ return null;
200
+ if (repo.selected === "local")
201
+ return { alias: "local", connection: { kind: "local", mode: "auto" } };
202
+ const global = readGlobalConnections(options);
203
+ const connection = global.connections[repo.selected];
204
+ if (!connection) {
205
+ throw new CliError2(`Selected Rig server "${repo.selected}" was not found. Run \`rig server list\` or \`rig server use local\`.`, 1);
206
+ }
207
+ return { alias: repo.selected, connection };
208
+ }
209
+
210
+ // packages/cli/src/commands/_server-client.ts
211
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
212
+ import { resolve as resolve2 } from "path";
213
+ import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
214
+ var scopedGitHubBearerTokens = new Map;
215
+ function cleanToken(value) {
216
+ const trimmed = value?.trim();
217
+ return trimmed ? trimmed : null;
218
+ }
219
+ function readPrivateRemoteSessionToken(projectRoot) {
220
+ const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
221
+ if (!existsSync2(path))
222
+ return null;
223
+ try {
224
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
225
+ return cleanToken(typeof parsed.apiSessionToken === "string" ? parsed.apiSessionToken : typeof parsed.sessionToken === "string" ? parsed.sessionToken : undefined);
226
+ } catch {
227
+ return null;
228
+ }
229
+ }
230
+ function readGitHubBearerTokenForRemote(projectRoot) {
231
+ const scopedKey = resolve2(projectRoot);
232
+ if (scopedGitHubBearerTokens.has(scopedKey))
233
+ return scopedGitHubBearerTokens.get(scopedKey) ?? null;
234
+ const privateSession = readPrivateRemoteSessionToken(projectRoot);
235
+ if (privateSession)
236
+ return privateSession;
237
+ return cleanToken(process.env.RIG_SERVER_AUTH_TOKEN) ?? cleanToken(process.env.RIG_REMOTE_AUTH_TOKEN);
238
+ }
239
+ async function ensureServerForCli(projectRoot) {
240
+ try {
241
+ const selected = resolveSelectedConnection(projectRoot);
242
+ if (selected?.connection.kind === "remote") {
243
+ return {
244
+ baseUrl: selected.connection.baseUrl,
245
+ authToken: readGitHubBearerTokenForRemote(projectRoot),
246
+ connectionKind: "remote"
247
+ };
248
+ }
249
+ const connection = await ensureLocalRigServerConnection(projectRoot);
250
+ return {
251
+ baseUrl: connection.baseUrl,
252
+ authToken: connection.authToken,
253
+ connectionKind: "local"
254
+ };
255
+ } catch (error) {
256
+ if (error instanceof Error) {
257
+ throw new CliError2(error.message, 1);
258
+ }
259
+ throw error;
260
+ }
261
+ }
262
+ function mergeHeaders(headers, authToken) {
263
+ const merged = new Headers(headers);
264
+ if (authToken) {
265
+ merged.set("authorization", `Bearer ${authToken}`);
266
+ }
267
+ return merged;
268
+ }
269
+ function diagnosticMessage(payload) {
270
+ if (!payload || typeof payload !== "object" || Array.isArray(payload))
271
+ return null;
272
+ const record = payload;
273
+ const diagnostics = Array.isArray(record.diagnostics) ? record.diagnostics : [];
274
+ const messages = diagnostics.flatMap((entry) => {
275
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
276
+ return [];
277
+ const diagnostic = entry;
278
+ const kind = typeof diagnostic.kind === "string" ? diagnostic.kind : "task-source";
279
+ const message = typeof diagnostic.message === "string" ? diagnostic.message : null;
280
+ return message ? [`${kind}: ${message}`] : [];
281
+ });
282
+ return messages.length > 0 ? messages.join("; ") : null;
283
+ }
284
+ async function requestServerJson(context, pathname, init = {}) {
285
+ const server = await ensureServerForCli(context.projectRoot);
286
+ const response = await fetch(`${server.baseUrl}${pathname}`, {
287
+ ...init,
288
+ headers: mergeHeaders(init.headers, server.authToken)
289
+ });
290
+ const text = await response.text();
291
+ const payload = text.trim().length > 0 ? (() => {
292
+ try {
293
+ return JSON.parse(text);
294
+ } catch {
295
+ return null;
296
+ }
297
+ })() : null;
298
+ if (!response.ok) {
299
+ const diagnostics = diagnosticMessage(payload);
300
+ const detail = diagnostics ?? (text || response.statusText);
301
+ throw new CliError2(`Rig server request failed (${response.status}): ${detail}`, 1);
302
+ }
303
+ return payload;
304
+ }
305
+ async function listRunsViaServer(context, options = {}) {
306
+ const url = new URL("http://rig.local/api/runs");
307
+ if (options.limit !== undefined)
308
+ url.searchParams.set("limit", String(options.limit));
309
+ const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
310
+ const runs = Array.isArray(payload) ? payload : payload && typeof payload === "object" && !Array.isArray(payload) && Array.isArray(payload.runs) ? payload.runs : [];
311
+ return runs.filter((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry)));
312
+ }
313
+ async function getRunDetailsViaServer(context, runId) {
314
+ const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}`);
315
+ return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
316
+ }
317
+
318
+ // packages/cli/src/commands/inbox.ts
319
+ function isRemoteConnectionSelected(projectRoot) {
320
+ return resolveSelectedConnection(projectRoot)?.connection.kind === "remote";
321
+ }
322
+ function runMatches(entry, filters) {
323
+ const runId = typeof entry.runId === "string" ? entry.runId : typeof entry.id === "string" ? entry.id : "";
324
+ const taskId = typeof entry.taskId === "string" ? entry.taskId : "";
325
+ return (!filters.run || runId === filters.run) && (!filters.task || taskId === filters.task);
326
+ }
327
+ function normalizeRemoteRunDetails(payload) {
328
+ const run = payload.run;
329
+ if (run && typeof run === "object" && !Array.isArray(run)) {
330
+ return {
331
+ ...run,
332
+ ...Array.isArray(payload.timeline) ? { timeline: payload.timeline } : {},
333
+ ...Array.isArray(payload.approvals) ? { approvals: payload.approvals } : {},
334
+ ...Array.isArray(payload.userInputs) ? { userInputs: payload.userInputs } : {}
335
+ };
336
+ }
337
+ return payload;
338
+ }
339
+ function remoteRecordsFromRun(run, kind) {
340
+ const key = kind === "approvals" ? "approvals" : "userInputs";
341
+ const direct = run[key];
342
+ if (!Array.isArray(direct))
343
+ return [];
344
+ const runId = typeof run.runId === "string" ? run.runId : typeof run.id === "string" ? run.id : "";
345
+ const taskId = typeof run.taskId === "string" ? run.taskId : "";
346
+ return direct.filter((record) => Boolean(record && typeof record === "object" && !Array.isArray(record))).map((record) => ({ runId, taskId, record }));
347
+ }
348
+ async function listRemoteInboxRecords(context, kind, filters) {
349
+ const runs = (await listRunsViaServer(context, { limit: 100 })).filter((entry) => runMatches(entry, filters));
350
+ const records = [];
351
+ for (const run of runs) {
352
+ const runId = typeof run.runId === "string" ? run.runId : typeof run.id === "string" ? run.id : "";
353
+ const detailed = runId ? normalizeRemoteRunDetails(await getRunDetailsViaServer(context, runId).catch(() => run)) : run;
354
+ records.push(...remoteRecordsFromRun(detailed, kind));
355
+ }
356
+ return records;
357
+ }
358
+ function listLocalInboxRecords(context, kind, filters) {
359
+ const fileName = kind === "approvals" ? "approvals.jsonl" : "user-input.jsonl";
360
+ const runs = listAuthorityRuns(context.projectRoot).filter((entry) => (!filters.run || entry.runId === filters.run) && (!filters.task || entry.taskId === filters.task));
361
+ return runs.flatMap((entry) => readJsonlFile(resolve3(resolveAuthorityRunDir(context.projectRoot, entry.runId), fileName)).map((record) => ({
362
+ runId: entry.runId,
363
+ taskId: entry.taskId ?? undefined,
364
+ record
365
+ })));
366
+ }
367
+ async function listInboxRecords(context, kind, filters) {
368
+ if (isRemoteConnectionSelected(context.projectRoot)) {
369
+ return listRemoteInboxRecords(context, kind, filters);
370
+ }
371
+ return listLocalInboxRecords(context, kind, filters);
372
+ }
47
373
  async function executeInbox(context, args) {
48
374
  const [command = "approvals", ...rest] = args;
49
375
  switch (command) {
@@ -53,16 +379,10 @@ async function executeInbox(context, args) {
53
379
  pending = run.rest;
54
380
  const task = takeOption(pending, "--task");
55
381
  pending = task.rest;
56
- requireNoExtraArgs(pending, "bun run rig inbox approvals [--run <id>] [--task <id>]");
57
- const runs = listAuthorityRuns(context.projectRoot).filter((entry) => (!run.value || entry.runId === run.value) && (!task.value || entry.taskId === task.value));
58
- const approvals = runs.flatMap((entry) => readJsonlFile(resolve(resolveAuthorityRunDir(context.projectRoot, entry.runId), "approvals.jsonl")).map((record) => ({
59
- runId: entry.runId,
60
- record
61
- })));
382
+ requireNoExtraArgs(pending, "rig inbox approvals [--run <id>] [--task <id>]");
383
+ const approvals = await listInboxRecords(context, "approvals", { run: run.value, task: task.value });
62
384
  if (context.outputMode === "text") {
63
- for (const approval of approvals) {
64
- console.log(JSON.stringify(approval));
65
- }
385
+ printFormattedOutput(formatInboxList("approvals", approvals));
66
386
  }
67
387
  return { ok: true, group: "inbox", command, details: { approvals } };
68
388
  }
@@ -74,20 +394,23 @@ async function executeInbox(context, args) {
74
394
  pending = request.rest;
75
395
  const decision = takeOption(pending, "--decision");
76
396
  pending = decision.rest;
77
- const note = takeOption(pending, "--note");
78
- pending = note.rest;
79
- requireNoExtraArgs(pending, "bun run rig inbox approve --run <id> --request <id> --decision approve|reject [--note <text>]");
397
+ const note2 = takeOption(pending, "--note");
398
+ pending = note2.rest;
399
+ requireNoExtraArgs(pending, "rig inbox approve --run <id> --request <id> --decision approve|reject [--note <text>]");
80
400
  if (!run.value || !request.value || !decision.value) {
81
401
  throw new CliError2("approve requires --run, --request, and --decision.");
82
402
  }
83
403
  if (decision.value !== "approve" && decision.value !== "reject") {
84
404
  throw new CliError2("decision must be approve or reject.");
85
405
  }
86
- const approvalsPath = resolve(resolveAuthorityRunDir(context.projectRoot, run.value), "approvals.jsonl");
406
+ if (isRemoteConnectionSelected(context.projectRoot)) {
407
+ throw new CliError2("Remote approval resolution is not available from this CLI yet; use the server UI/API or switch to local state for direct JSONL edits.", 2);
408
+ }
409
+ const approvalsPath = resolve3(resolveAuthorityRunDir(context.projectRoot, run.value), "approvals.jsonl");
87
410
  const approvals = readJsonlFile(approvalsPath);
88
411
  const resolvedAt = new Date().toISOString();
89
- const next = approvals.map((entry) => entry.requestId === request.value || entry.id === request.value ? { ...entry, status: "resolved", decision: decision.value, note: note.value ?? null, resolvedAt } : entry);
90
- writeFileSync(approvalsPath, `${next.map((entry) => JSON.stringify(entry)).join(`
412
+ const next = approvals.map((entry) => entry.requestId === request.value || entry.id === request.value ? { ...entry, status: "resolved", decision: decision.value, note: note2.value ?? null, resolvedAt } : entry);
413
+ writeFileSync2(approvalsPath, `${next.map((entry) => JSON.stringify(entry)).join(`
91
414
  `)}
92
415
  `, "utf8");
93
416
  return { ok: true, group: "inbox", command, details: { runId: run.value, requestId: request.value, decision: decision.value } };
@@ -98,16 +421,10 @@ async function executeInbox(context, args) {
98
421
  pending = run.rest;
99
422
  const task = takeOption(pending, "--task");
100
423
  pending = task.rest;
101
- requireNoExtraArgs(pending, "bun run rig inbox inputs [--run <id>] [--task <id>]");
102
- const runs = listAuthorityRuns(context.projectRoot).filter((entry) => (!run.value || entry.runId === run.value) && (!task.value || entry.taskId === task.value));
103
- const requests = runs.flatMap((entry) => readJsonlFile(resolve(resolveAuthorityRunDir(context.projectRoot, entry.runId), "user-input.jsonl")).map((record) => ({
104
- runId: entry.runId,
105
- record
106
- })));
424
+ requireNoExtraArgs(pending, "rig inbox inputs [--run <id>] [--task <id>]");
425
+ const requests = await listInboxRecords(context, "inputs", { run: run.value, task: task.value });
107
426
  if (context.outputMode === "text") {
108
- for (const request of requests) {
109
- console.log(JSON.stringify(request));
110
- }
427
+ printFormattedOutput(formatInboxList("inputs", requests));
111
428
  }
112
429
  return { ok: true, group: "inbox", command, details: { requests } };
113
430
  }
@@ -134,19 +451,22 @@ async function executeInbox(context, args) {
134
451
  remaining.push(current);
135
452
  }
136
453
  }
137
- requireNoExtraArgs(remaining, "bun run rig inbox respond --run <id> --request <id> --answer key=value [--answer key=value]");
454
+ requireNoExtraArgs(remaining, "rig inbox respond --run <id> --request <id> --answer key=value [--answer key=value]");
138
455
  if (!run.value || !request.value || answers.length === 0) {
139
456
  throw new CliError2("respond requires --run, --request, and at least one --answer.");
140
457
  }
458
+ if (isRemoteConnectionSelected(context.projectRoot)) {
459
+ throw new CliError2("Remote input responses are not available from this CLI yet; use the server UI/API or switch to local state for direct JSONL edits.", 2);
460
+ }
141
461
  const parsedAnswers = Object.fromEntries(answers.map((entry) => {
142
462
  const [key, ...restValue] = entry.split("=");
143
463
  return [key, restValue.join("=")];
144
464
  }));
145
- const requestsPath = resolve(resolveAuthorityRunDir(context.projectRoot, run.value), "user-input.jsonl");
465
+ const requestsPath = resolve3(resolveAuthorityRunDir(context.projectRoot, run.value), "user-input.jsonl");
146
466
  const requests = readJsonlFile(requestsPath);
147
467
  const resolvedAt = new Date().toISOString();
148
468
  const next = requests.map((entry) => entry.requestId === request.value || entry.id === request.value ? { ...entry, status: "resolved", answers: parsedAnswers, respondedAt: resolvedAt, resolvedAt } : entry);
149
- writeFileSync(requestsPath, `${next.map((entry) => JSON.stringify(entry)).join(`
469
+ writeFileSync2(requestsPath, `${next.map((entry) => JSON.stringify(entry)).join(`
150
470
  `)}
151
471
  `, "utf8");
152
472
  return { ok: true, group: "inbox", command, details: { runId: run.value, requestId: request.value, answers: parsedAnswers } };
@@ -10,8 +10,6 @@ import { resolve as resolve6 } from "path";
10
10
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
11
11
  import { CliError } from "@rig/runtime/control-plane/errors";
12
12
  import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
13
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
14
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
15
13
  import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
16
14
  import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
17
15
  function takeFlag(args, flag) {
@@ -148,7 +146,7 @@ function resolveSelectedConnection(projectRoot, options = {}) {
148
146
  const global = readGlobalConnections(options);
149
147
  const connection = global.connections[repo.selected];
150
148
  if (!connection) {
151
- throw new CliError2(`Selected Rig connection "${repo.selected}" was not found. Run \`rig connect list\` or \`rig connect use local\`.`, 1);
149
+ throw new CliError2(`Selected Rig server "${repo.selected}" was not found. Run \`rig server list\` or \`rig server use local\`.`, 1);
152
150
  }
153
151
  return { alias: repo.selected, connection };
154
152
  }
@@ -751,7 +749,7 @@ async function runRigDoctorChecks(options) {
751
749
  const taskSourceKind = config?.taskSource?.kind;
752
750
  checks.push(taskSourceKind ? check("task-source", "task source configured", "pass", taskSourceKind) : check("task-source", "task source configured", "fail", "missing taskSource", "Configure taskSource in rig.config.ts."));
753
751
  const repo = readRepoConnection(projectRoot);
754
- checks.push(repo ? check("project-link", "repo selected Rig connection", repo.project ? "pass" : "warn", `${repo.selected}${repo.project ? ` -> ${repo.project}` : ""}`, "Run `rig init --yes --repo owner/repo` to link this checkout to a GitHub repo slug.") : check("project-link", "repo selected Rig connection", "fail", "missing .rig/state/connection.json", "Run `rig init` or `rig connect use <alias|local>`."));
752
+ checks.push(repo ? check("project-link", "repo selected Rig server", repo.project ? "pass" : "warn", `${repo.selected}${repo.project ? ` -> ${repo.project}` : ""}`, "Run `rig init --yes --repo owner/repo` to link this checkout to a GitHub repo slug.") : check("project-link", "repo selected Rig server", "fail", "missing .rig/state/connection.json", "Run `rig init` or `rig server use <alias|local>`."));
755
753
  const selected = (() => {
756
754
  try {
757
755
  return resolveSelectedConnection(projectRoot);
@@ -759,7 +757,7 @@ async function runRigDoctorChecks(options) {
759
757
  return null;
760
758
  }
761
759
  })();
762
- checks.push(selected ? check("connection", "selected server connection", "pass", selected.connection.kind === "remote" ? selected.connection.baseUrl : "local auto") : check("connection", "selected server connection", repo ? "fail" : "warn", repo ? "selected alias is missing" : "will auto-start local server", repo ? "Run `rig connect list` and `rig connect use <alias|local>`." : undefined));
760
+ checks.push(selected ? check("connection", "selected server connection", "pass", selected.connection.kind === "remote" ? selected.connection.baseUrl : "local auto") : check("connection", "selected server", repo ? "fail" : "warn", repo ? "selected alias is missing" : "will auto-start local server", repo ? "Run `rig server list` and `rig server use <alias|local>`." : undefined));
763
761
  let server = null;
764
762
  try {
765
763
  server = await (options.resolveServer ?? ensureServerForCli)(projectRoot);
@@ -7,8 +7,6 @@ import { resolve } from "path";
7
7
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
8
8
  import { CliError } from "@rig/runtime/control-plane/errors";
9
9
  import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
10
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
11
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
12
10
  import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
13
11
  import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
14
12
  function takeOption(args, option) {
@@ -60,8 +58,8 @@ async function executeInspect(context, args) {
60
58
  switch (command) {
61
59
  case "logs": {
62
60
  const { value: task, rest: remaining } = takeOption(rest, "--task");
63
- requireNoExtraArgs(remaining, "bun run rig inspect logs --task <beads-id>");
64
- const requiredTask = requireTask(task, "bun run rig inspect logs --task <beads-id>");
61
+ requireNoExtraArgs(remaining, "rig inspect logs --task <task-id>");
62
+ const requiredTask = requireTask(task, "rig inspect logs --task <task-id>");
65
63
  const latestRun = listAuthorityRuns(context.projectRoot).map((entry) => readAuthorityRun(context.projectRoot, entry.runId)).filter((run) => Boolean(run)).filter((run) => run.taskId === requiredTask).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")))[0];
66
64
  if (!latestRun) {
67
65
  throw new CliError2(`No runs found for ${requiredTask}.`);
@@ -75,8 +73,8 @@ async function executeInspect(context, args) {
75
73
  }
76
74
  case "artifacts": {
77
75
  const { value: task, rest: remaining } = takeOption(rest, "--task");
78
- requireNoExtraArgs(remaining, "bun run rig inspect artifacts --task <beads-id>");
79
- const requiredTask = requireTask(task, "bun run rig inspect artifacts --task <beads-id>");
76
+ requireNoExtraArgs(remaining, "rig inspect artifacts --task <task-id>");
77
+ const requiredTask = requireTask(task, "rig inspect artifacts --task <task-id>");
80
78
  const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync(path));
81
79
  if (!artifactRoot) {
82
80
  throw new CliError2(`No artifacts found for ${requiredTask}.`);
@@ -90,8 +88,8 @@ async function executeInspect(context, args) {
90
88
  previewPending = task.rest;
91
89
  const file = takeOption(previewPending, "--file");
92
90
  previewPending = file.rest;
93
- requireNoExtraArgs(previewPending, "bun run rig inspect artifact --task <beads-id> --file <name>");
94
- const requiredTask = requireTask(task.value, "bun run rig inspect artifact --task <beads-id> --file <name>");
91
+ requireNoExtraArgs(previewPending, "rig inspect artifact --task <task-id> --file <name>");
92
+ const requiredTask = requireTask(task.value, "rig inspect artifact --task <task-id> --file <name>");
95
93
  if (!file.value) {
96
94
  throw new CliError2("Missing --file for rig inspect artifact.");
97
95
  }
@@ -120,7 +118,7 @@ async function executeInspect(context, args) {
120
118
  }
121
119
  case "diff": {
122
120
  const { value: task, rest: remaining } = takeOption(rest, "--task");
123
- requireNoExtraArgs(remaining, "bun run rig inspect diff [--task <beads-id>]");
121
+ requireNoExtraArgs(remaining, "rig inspect diff [--task <task-id>]");
124
122
  if (task) {
125
123
  const files = changedFilesForTask(context.projectRoot, task, false);
126
124
  for (const file of files) {
@@ -132,7 +130,7 @@ async function executeInspect(context, args) {
132
130
  return { ok: true, group: "inspect", command, details: { task: task || null } };
133
131
  }
134
132
  case "failures": {
135
- requireNoExtraArgs(rest, "bun run rig inspect failures");
133
+ requireNoExtraArgs(rest, "rig inspect failures");
136
134
  const failed = resolveHarnessPaths(context.projectRoot).failedApproachesPath;
137
135
  if (!existsSync(failed)) {
138
136
  console.log("No failures recorded.");
@@ -142,7 +140,7 @@ async function executeInspect(context, args) {
142
140
  return { ok: true, group: "inspect", command };
143
141
  }
144
142
  case "graph":
145
- requireNoExtraArgs(rest, "bun run rig inspect graph");
143
+ requireNoExtraArgs(rest, "rig inspect graph");
146
144
  {
147
145
  const monorepoRoot = resolveMonorepoRoot(context.projectRoot);
148
146
  const result = runCapture(["br", "--no-db", "list", "--pretty"], monorepoRoot);
@@ -153,7 +151,7 @@ async function executeInspect(context, args) {
153
151
  }
154
152
  return { ok: true, group: "inspect", command };
155
153
  case "audit": {
156
- requireNoExtraArgs(rest, "bun run rig inspect audit");
154
+ requireNoExtraArgs(rest, "rig inspect audit");
157
155
  const auditPath = resolve(resolveHarnessPaths(context.projectRoot).logsDir, "audit.jsonl");
158
156
  if (!existsSync(auditPath)) {
159
157
  console.log("No audit log found.");
@@ -6,8 +6,6 @@ import { iterateServerSentEvents } from "@rig/client";
6
6
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
7
7
  import { CliError } from "@rig/runtime/control-plane/errors";
8
8
  import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
9
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
10
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
11
9
  import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
12
10
  import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
13
11
  function takeFlag(args, flag) {
@@ -104,7 +102,7 @@ async function executeInspector(context, args) {
104
102
  pending = secondsResult.rest;
105
103
  const pollMsResult = takeOption(pending, "--poll-ms");
106
104
  pending = pollMsResult.rest;
107
- requireNoExtraArgs(pending, "bun run rig inspector stream [--once] [--seconds <n>] [--poll-ms <n>]");
105
+ requireNoExtraArgs(pending, "rig inspector stream [--once] [--seconds <n>] [--poll-ms <n>]");
108
106
  const seconds = secondsResult.value ? parseRequiredPositiveInt(secondsResult.value, "--seconds") : null;
109
107
  const pollMs = pollMsResult.value ? parseRequiredPositiveInt(pollMsResult.value, "--poll-ms") : null;
110
108
  if (context.outputMode === "json" && !onceResult.value && !seconds) {
@@ -198,7 +196,7 @@ async function executeInspector(context, args) {
198
196
  let pending = rest;
199
197
  const scanIdResult = takeOption(pending, "--scan-id");
200
198
  pending = scanIdResult.rest;
201
- requireNoExtraArgs(pending, "bun run rig inspector scan-upstream-drift [--scan-id <id>]");
199
+ requireNoExtraArgs(pending, "rig inspector scan-upstream-drift [--scan-id <id>]");
202
200
  const connection = await ensureLocalRigServerConnection(context.projectRoot);
203
201
  const response = await fetch(new URL("/api/inspector/tools/invoke", connection.baseUrl), {
204
202
  method: "POST",