@h-rig/cli 0.0.6-alpha.9 → 0.0.6-alpha.90
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/README.md +1 -1
- package/dist/bin/build-rig-binaries.d.ts +2 -0
- package/dist/bin/rig.d.ts +2 -0
- package/dist/bin/rig.js +11052 -6668
- package/dist/src/app/board.d.ts +23 -0
- package/dist/src/app/board.js +1786 -0
- package/dist/src/app/drone-ui.d.ts +37 -0
- package/dist/src/app/drone-ui.js +294 -0
- package/dist/src/app/theme.d.ts +47 -0
- package/dist/src/app/theme.js +150 -0
- package/dist/src/commands/_async-ui.d.ts +13 -0
- package/dist/src/commands/_async-ui.js +223 -0
- package/dist/src/commands/_authority-runs.d.ts +22 -0
- package/dist/src/commands/_authority-runs.js +2 -3
- package/dist/src/commands/_cli-format.d.ts +49 -0
- package/dist/src/commands/_cli-format.js +447 -0
- package/dist/src/commands/_connection-state.d.ts +44 -0
- package/dist/src/commands/_connection-state.js +30 -11
- package/dist/src/commands/_doctor-checks.d.ts +52 -0
- package/dist/src/commands/_doctor-checks.js +180 -44
- package/dist/src/commands/_help-catalog.d.ts +51 -0
- package/dist/src/commands/_help-catalog.js +442 -0
- package/dist/src/commands/_json-output.d.ts +11 -0
- package/dist/src/commands/_json-output.js +56 -0
- package/dist/src/commands/_operator-surface.d.ts +34 -0
- package/dist/src/commands/_operator-surface.js +220 -0
- package/dist/src/commands/_operator-view.d.ts +30 -0
- package/dist/src/commands/_operator-view.js +803 -73
- package/dist/src/commands/_parsers.d.ts +15 -0
- package/dist/src/commands/_parsers.js +18 -11
- package/dist/src/commands/_paths.d.ts +11 -0
- package/dist/src/commands/_pi-frontend.d.ts +27 -0
- package/dist/src/commands/_pi-frontend.js +742 -0
- package/dist/src/commands/_pi-install.d.ts +42 -0
- package/dist/src/commands/_pi-install.js +5 -4
- package/dist/src/commands/_policy.d.ts +8 -0
- package/dist/src/commands/_policy.js +12 -5
- package/dist/src/commands/_preflight.d.ts +22 -0
- package/dist/src/commands/_preflight.js +190 -128
- package/dist/src/commands/_probes.d.ts +1 -0
- package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
- package/dist/src/commands/_run-driver-helpers.js +75 -22
- package/dist/src/commands/_run-replay.d.ts +24 -0
- package/dist/src/commands/_run-replay.js +142 -0
- package/dist/src/commands/_server-client.d.ts +186 -0
- package/dist/src/commands/_server-client.js +360 -61
- package/dist/src/commands/_snapshot-upload.d.ts +39 -0
- package/dist/src/commands/_snapshot-upload.js +163 -39
- package/dist/src/commands/_spinner.d.ts +25 -0
- package/dist/src/commands/_spinner.js +65 -0
- package/dist/src/commands/_task-picker.d.ts +9 -0
- package/dist/src/commands/_task-picker.js +172 -19
- package/dist/src/commands/agent.d.ts +3 -0
- package/dist/src/commands/agent.js +39 -20
- package/dist/src/commands/browser.d.ts +65 -0
- package/dist/src/commands/browser.js +334 -51
- package/dist/src/commands/connect.d.ts +7 -0
- package/dist/src/commands/connect.js +272 -33
- package/dist/src/commands/dist.d.ts +28 -0
- package/dist/src/commands/dist.js +19 -12
- package/dist/src/commands/doctor.d.ts +3 -0
- package/dist/src/commands/doctor.js +378 -45
- package/dist/src/commands/github.d.ts +3 -0
- package/dist/src/commands/github.js +375 -53
- package/dist/src/commands/inbox.d.ts +30 -0
- package/dist/src/commands/inbox.js +760 -70
- package/dist/src/commands/init.d.ts +74 -0
- package/dist/src/commands/init.js +963 -119
- package/dist/src/commands/inspect.d.ts +3 -0
- package/dist/src/commands/inspect.js +588 -32
- package/dist/src/commands/inspector.d.ts +3 -0
- package/dist/src/commands/inspector.js +20 -13
- package/dist/src/commands/pi.d.ts +3 -0
- package/dist/src/commands/pi.js +177 -0
- package/dist/src/commands/plugin.d.ts +16 -0
- package/dist/src/commands/plugin.js +95 -27
- package/dist/src/commands/profile-and-review.d.ts +4 -0
- package/dist/src/commands/profile-and-review.js +26 -19
- package/dist/src/commands/queue.d.ts +3 -0
- package/dist/src/commands/queue.js +32 -12
- package/dist/src/commands/remote.d.ts +3 -0
- package/dist/src/commands/remote.js +43 -36
- package/dist/src/commands/repo-git-harness.d.ts +5 -0
- package/dist/src/commands/repo-git-harness.js +22 -15
- package/dist/src/commands/run.d.ts +3 -0
- package/dist/src/commands/run.js +1379 -159
- package/dist/src/commands/server.d.ts +7 -0
- package/dist/src/commands/server.js +502 -57
- package/dist/src/commands/setup.d.ts +16 -0
- package/dist/src/commands/setup.js +390 -63
- package/dist/src/commands/stats.d.ts +12 -0
- package/dist/src/commands/stats.js +1051 -0
- package/dist/src/commands/task-report-bug.d.ts +19 -0
- package/dist/src/commands/task-report-bug.js +260 -62
- package/dist/src/commands/task-run-driver.d.ts +132 -0
- package/dist/src/commands/task-run-driver.js +886 -130
- package/dist/src/commands/task.d.ts +14 -0
- package/dist/src/commands/task.js +1644 -314
- package/dist/src/commands/test.d.ts +3 -0
- package/dist/src/commands/test.js +15 -8
- package/dist/src/commands/workspace.d.ts +3 -0
- package/dist/src/commands/workspace.js +18 -11
- package/dist/src/commands.d.ts +29 -0
- package/dist/src/commands.js +10967 -6637
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +10168 -5787
- package/dist/src/launcher.d.ts +61 -0
- package/dist/src/launcher.js +77 -13
- package/dist/src/report-bug.d.ts +44 -0
- package/dist/src/report-bug.js +3 -3
- package/dist/src/runner.d.ts +47 -0
- package/dist/src/runner.js +16 -22
- package/dist/src/withMutedConsole.d.ts +2 -0
- package/package.json +13 -6
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/cli/src/commands/inspect.ts
|
|
3
|
-
import { existsSync, readFileSync } from "fs";
|
|
4
|
-
import { resolve } from "path";
|
|
3
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } 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
|
-
import { CliError } from "@rig/runtime/control-plane/errors";
|
|
8
|
+
import { CliError as RuntimeCliError } 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
|
+
|
|
12
|
+
class CliError extends RuntimeCliError {
|
|
13
|
+
hint;
|
|
14
|
+
constructor(message, exitCode = 1, options = {}) {
|
|
15
|
+
super(message, exitCode);
|
|
16
|
+
if (options.hint?.trim()) {
|
|
17
|
+
this.hint = options.hint.trim();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
14
21
|
function takeOption(args, option) {
|
|
15
22
|
const rest = [];
|
|
16
23
|
let value;
|
|
@@ -19,7 +26,7 @@ function takeOption(args, option) {
|
|
|
19
26
|
if (current === option) {
|
|
20
27
|
const next = args[index + 1];
|
|
21
28
|
if (!next || next.startsWith("-")) {
|
|
22
|
-
throw new CliError(`Missing value for ${option}`);
|
|
29
|
+
throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
|
|
23
30
|
}
|
|
24
31
|
value = next;
|
|
25
32
|
index += 1;
|
|
@@ -55,31 +62,580 @@ import {
|
|
|
55
62
|
import { changedFilesForTask } from "@rig/runtime/control-plane/native/task-ops";
|
|
56
63
|
import { resolveHarnessPaths, resolveMonorepoRoot, runCapture } from "@rig/runtime/control-plane/native/utils";
|
|
57
64
|
import { readTaskArtifactPreview } from "@rig/runtime/control-plane/native/workspace-ops";
|
|
65
|
+
|
|
66
|
+
// packages/cli/src/commands/_server-client.ts
|
|
67
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
68
|
+
import { resolve as resolve2 } from "path";
|
|
69
|
+
import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
|
|
70
|
+
|
|
71
|
+
// packages/cli/src/commands/_connection-state.ts
|
|
72
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
73
|
+
import { homedir } from "os";
|
|
74
|
+
import { dirname, resolve } from "path";
|
|
75
|
+
function resolveGlobalConnectionsPath(env = process.env) {
|
|
76
|
+
const explicit = env.RIG_CONNECTIONS_FILE?.trim();
|
|
77
|
+
if (explicit)
|
|
78
|
+
return resolve(explicit);
|
|
79
|
+
const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
|
|
80
|
+
if (stateDir)
|
|
81
|
+
return resolve(stateDir, "connections.json");
|
|
82
|
+
return resolve(homedir(), ".rig", "connections.json");
|
|
83
|
+
}
|
|
84
|
+
function resolveRepoConnectionPath(projectRoot) {
|
|
85
|
+
return resolve(projectRoot, ".rig", "state", "connection.json");
|
|
86
|
+
}
|
|
87
|
+
function readJsonFile(path) {
|
|
88
|
+
if (!existsSync(path))
|
|
89
|
+
return null;
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
92
|
+
} catch (error) {
|
|
93
|
+
throw new CliError(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1, { hint: "Fix or delete that file, then re-select a server with `rig server use <alias|local>`." });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function writeJsonFile(path, value) {
|
|
97
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
98
|
+
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
99
|
+
`, "utf8");
|
|
100
|
+
}
|
|
101
|
+
function normalizeConnection(value) {
|
|
102
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
103
|
+
return null;
|
|
104
|
+
const record = value;
|
|
105
|
+
if (record.kind === "local")
|
|
106
|
+
return { kind: "local", mode: "auto" };
|
|
107
|
+
if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
|
|
108
|
+
const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
|
|
109
|
+
return { kind: "remote", baseUrl };
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
function readGlobalConnections(options = {}) {
|
|
114
|
+
const path = resolveGlobalConnectionsPath(options.env ?? process.env);
|
|
115
|
+
const payload = readJsonFile(path);
|
|
116
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
117
|
+
return { connections: {} };
|
|
118
|
+
}
|
|
119
|
+
const rawConnections = payload.connections;
|
|
120
|
+
const connections = {};
|
|
121
|
+
if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
|
|
122
|
+
for (const [alias, raw] of Object.entries(rawConnections)) {
|
|
123
|
+
const connection = normalizeConnection(raw);
|
|
124
|
+
if (connection)
|
|
125
|
+
connections[alias] = connection;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return { connections };
|
|
129
|
+
}
|
|
130
|
+
function readRepoConnection(projectRoot) {
|
|
131
|
+
const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
|
|
132
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
133
|
+
return null;
|
|
134
|
+
const record = payload;
|
|
135
|
+
const selected = typeof record.selected === "string" ? record.selected.trim() : "";
|
|
136
|
+
if (!selected)
|
|
137
|
+
return null;
|
|
138
|
+
return {
|
|
139
|
+
selected,
|
|
140
|
+
project: typeof record.project === "string" ? record.project : undefined,
|
|
141
|
+
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
|
|
142
|
+
serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function writeRepoConnection(projectRoot, state) {
|
|
146
|
+
writeJsonFile(resolveRepoConnectionPath(projectRoot), state);
|
|
147
|
+
}
|
|
148
|
+
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
149
|
+
const repo = readRepoConnection(projectRoot);
|
|
150
|
+
if (!repo)
|
|
151
|
+
return null;
|
|
152
|
+
if (repo.selected === "local")
|
|
153
|
+
return { alias: "local", connection: { kind: "local", mode: "auto" }, serverProjectRoot: repo.serverProjectRoot };
|
|
154
|
+
const global = readGlobalConnections(options);
|
|
155
|
+
const connection = global.connections[repo.selected];
|
|
156
|
+
if (!connection) {
|
|
157
|
+
throw new CliError(`Selected Rig server "${repo.selected}" was not found. Run \`rig server list\` or \`rig server use local\`.`, 1);
|
|
158
|
+
}
|
|
159
|
+
return { alias: repo.selected, connection, serverProjectRoot: repo.serverProjectRoot };
|
|
160
|
+
}
|
|
161
|
+
function writeRepoServerProjectRoot(projectRoot, serverProjectRoot) {
|
|
162
|
+
const repo = readRepoConnection(projectRoot);
|
|
163
|
+
if (!repo)
|
|
164
|
+
return;
|
|
165
|
+
writeRepoConnection(projectRoot, { ...repo, serverProjectRoot });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// packages/cli/src/commands/_server-client.ts
|
|
169
|
+
var scopedGitHubBearerTokens = new Map;
|
|
170
|
+
var serverPhaseListener = null;
|
|
171
|
+
function setServerPhaseListener(listener) {
|
|
172
|
+
const previous = serverPhaseListener;
|
|
173
|
+
serverPhaseListener = listener;
|
|
174
|
+
return previous;
|
|
175
|
+
}
|
|
176
|
+
function reportServerPhase(label) {
|
|
177
|
+
serverPhaseListener?.(label);
|
|
178
|
+
}
|
|
179
|
+
function cleanToken(value) {
|
|
180
|
+
const trimmed = value?.trim();
|
|
181
|
+
return trimmed ? trimmed : null;
|
|
182
|
+
}
|
|
183
|
+
function readPrivateRemoteSessionToken(projectRoot) {
|
|
184
|
+
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
185
|
+
if (!existsSync2(path))
|
|
186
|
+
return null;
|
|
187
|
+
try {
|
|
188
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
189
|
+
return cleanToken(typeof parsed.apiSessionToken === "string" ? parsed.apiSessionToken : typeof parsed.sessionToken === "string" ? parsed.sessionToken : undefined);
|
|
190
|
+
} catch {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function readGitHubBearerTokenForRemote(projectRoot) {
|
|
195
|
+
const scopedKey = resolve2(projectRoot);
|
|
196
|
+
if (scopedGitHubBearerTokens.has(scopedKey))
|
|
197
|
+
return scopedGitHubBearerTokens.get(scopedKey) ?? null;
|
|
198
|
+
const privateSession = readPrivateRemoteSessionToken(projectRoot);
|
|
199
|
+
if (privateSession)
|
|
200
|
+
return privateSession;
|
|
201
|
+
return cleanToken(process.env.RIG_SERVER_AUTH_TOKEN) ?? cleanToken(process.env.RIG_REMOTE_AUTH_TOKEN);
|
|
202
|
+
}
|
|
203
|
+
function readStoredGitHubAuthToken(projectRoot) {
|
|
204
|
+
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
205
|
+
if (!existsSync2(path))
|
|
206
|
+
return null;
|
|
207
|
+
try {
|
|
208
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
209
|
+
return cleanToken(typeof parsed.token === "string" ? parsed.token : undefined);
|
|
210
|
+
} catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function readLocalConnectionFallbackToken(projectRoot) {
|
|
215
|
+
return readGitHubBearerTokenForRemote(projectRoot) ?? cleanToken(process.env.RIG_GITHUB_TOKEN) ?? readStoredGitHubAuthToken(projectRoot);
|
|
216
|
+
}
|
|
217
|
+
async function ensureServerForCli(projectRoot) {
|
|
218
|
+
try {
|
|
219
|
+
const selected = resolveSelectedConnection(projectRoot);
|
|
220
|
+
if (selected?.connection.kind === "remote") {
|
|
221
|
+
reportServerPhase(`Connecting to ${selected.alias}\u2026`);
|
|
222
|
+
const authToken = readGitHubBearerTokenForRemote(projectRoot);
|
|
223
|
+
const serverProjectRoot = selected.serverProjectRoot ?? await backfillRemoteServerProjectRoot(projectRoot, selected.connection.baseUrl, authToken);
|
|
224
|
+
return {
|
|
225
|
+
baseUrl: selected.connection.baseUrl,
|
|
226
|
+
authToken,
|
|
227
|
+
connectionKind: "remote",
|
|
228
|
+
serverProjectRoot
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
reportServerPhase("Starting local Rig server\u2026");
|
|
232
|
+
const connection = await ensureLocalRigServerConnection(projectRoot);
|
|
233
|
+
return {
|
|
234
|
+
baseUrl: connection.baseUrl,
|
|
235
|
+
authToken: connection.authToken ?? readLocalConnectionFallbackToken(projectRoot),
|
|
236
|
+
connectionKind: "local",
|
|
237
|
+
serverProjectRoot: resolve2(projectRoot)
|
|
238
|
+
};
|
|
239
|
+
} catch (error) {
|
|
240
|
+
if (error instanceof Error) {
|
|
241
|
+
throw new CliError(error.message, 1);
|
|
242
|
+
}
|
|
243
|
+
throw error;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async function backfillRemoteServerProjectRoot(projectRoot, baseUrl, authToken) {
|
|
247
|
+
const repo = readRepoConnection(projectRoot);
|
|
248
|
+
const slug = repo?.project?.trim();
|
|
249
|
+
if (!slug)
|
|
250
|
+
return null;
|
|
251
|
+
try {
|
|
252
|
+
const response = await fetch(`${baseUrl}/api/projects/${encodeURIComponent(slug)}`, {
|
|
253
|
+
headers: mergeHeaders(undefined, authToken)
|
|
254
|
+
});
|
|
255
|
+
if (!response.ok)
|
|
256
|
+
return null;
|
|
257
|
+
const payload = await response.json();
|
|
258
|
+
const project = payload.project && typeof payload.project === "object" && !Array.isArray(payload.project) ? payload.project : null;
|
|
259
|
+
const checkouts = Array.isArray(project?.checkouts) ? project.checkouts : [];
|
|
260
|
+
const latestCheckout = [...checkouts].reverse().find((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry) && typeof entry.path === "string"));
|
|
261
|
+
const path = typeof latestCheckout?.path === "string" && latestCheckout.path.trim() ? latestCheckout.path.trim() : null;
|
|
262
|
+
if (path)
|
|
263
|
+
writeRepoServerProjectRoot(projectRoot, path);
|
|
264
|
+
return path;
|
|
265
|
+
} catch {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function mergeHeaders(headers, authToken) {
|
|
270
|
+
const merged = new Headers(headers);
|
|
271
|
+
if (authToken) {
|
|
272
|
+
merged.set("authorization", `Bearer ${authToken}`);
|
|
273
|
+
}
|
|
274
|
+
return merged;
|
|
275
|
+
}
|
|
276
|
+
function diagnosticMessage(payload) {
|
|
277
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
278
|
+
return null;
|
|
279
|
+
const record = payload;
|
|
280
|
+
const diagnostics = Array.isArray(record.diagnostics) ? record.diagnostics : [];
|
|
281
|
+
const messages = diagnostics.flatMap((entry) => {
|
|
282
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
283
|
+
return [];
|
|
284
|
+
const diagnostic = entry;
|
|
285
|
+
const kind = typeof diagnostic.kind === "string" ? diagnostic.kind : "task-source";
|
|
286
|
+
const message = typeof diagnostic.message === "string" ? diagnostic.message : null;
|
|
287
|
+
return message ? [`${kind}: ${message}`] : [];
|
|
288
|
+
});
|
|
289
|
+
return messages.length > 0 ? messages.join("; ") : null;
|
|
290
|
+
}
|
|
291
|
+
var serverReachabilityCache = new Map;
|
|
292
|
+
async function probeServerReachability(baseUrl, authToken) {
|
|
293
|
+
try {
|
|
294
|
+
const response = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/server/status`, {
|
|
295
|
+
headers: mergeHeaders(undefined, authToken),
|
|
296
|
+
signal: AbortSignal.timeout(1500)
|
|
297
|
+
});
|
|
298
|
+
return response.ok;
|
|
299
|
+
} catch {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function cachedServerReachability(projectRoot, baseUrl, authToken) {
|
|
304
|
+
const key = resolve2(projectRoot);
|
|
305
|
+
const cached = serverReachabilityCache.get(key);
|
|
306
|
+
if (cached)
|
|
307
|
+
return cached;
|
|
308
|
+
const probe = probeServerReachability(baseUrl, authToken);
|
|
309
|
+
serverReachabilityCache.set(key, probe);
|
|
310
|
+
return probe;
|
|
311
|
+
}
|
|
312
|
+
function describeSelectedServer(projectRoot, server) {
|
|
313
|
+
try {
|
|
314
|
+
const selected = resolveSelectedConnection(projectRoot);
|
|
315
|
+
if (selected) {
|
|
316
|
+
return {
|
|
317
|
+
alias: selected.alias,
|
|
318
|
+
target: selected.connection.kind === "remote" ? selected.connection.baseUrl : server.baseUrl
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
} catch {}
|
|
322
|
+
return { alias: server.connectionKind === "remote" ? "remote" : "local", target: server.baseUrl };
|
|
323
|
+
}
|
|
324
|
+
async function buildServerFailureContext(projectRoot, server) {
|
|
325
|
+
const { alias, target } = describeSelectedServer(projectRoot, server);
|
|
326
|
+
const reachable = await cachedServerReachability(projectRoot, server.baseUrl, server.authToken);
|
|
327
|
+
const reachability = reachable ? "server is reachable" : "server is unreachable";
|
|
328
|
+
return {
|
|
329
|
+
contextLine: `Currently connected to: ${alias} at ${target} (${reachability}).`,
|
|
330
|
+
hint: "Check the selected server with `rig server status`, or switch with `rig server use <alias|local>`."
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
async function requestServerJson(context, pathname, init = {}) {
|
|
334
|
+
const server = await ensureServerForCli(context.projectRoot);
|
|
335
|
+
const headers = mergeHeaders(init.headers, server.authToken);
|
|
336
|
+
if (server.serverProjectRoot)
|
|
337
|
+
headers.set("x-rig-project-root", server.serverProjectRoot);
|
|
338
|
+
reportServerPhase(`${(init.method ?? "GET").toUpperCase()} ${pathname.split("?")[0]}\u2026`);
|
|
339
|
+
let response;
|
|
340
|
+
try {
|
|
341
|
+
response = await fetch(`${server.baseUrl}${pathname}`, {
|
|
342
|
+
...init,
|
|
343
|
+
headers
|
|
344
|
+
});
|
|
345
|
+
} catch (error) {
|
|
346
|
+
const failure = await buildServerFailureContext(context.projectRoot, server);
|
|
347
|
+
throw new CliError(`Rig server request failed: ${error instanceof Error ? error.message : String(error)}
|
|
348
|
+
${failure.contextLine}`, 1, { hint: failure.hint });
|
|
349
|
+
}
|
|
350
|
+
const text = await response.text();
|
|
351
|
+
const payload = text.trim().length > 0 ? (() => {
|
|
352
|
+
try {
|
|
353
|
+
return JSON.parse(text);
|
|
354
|
+
} catch {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
})() : null;
|
|
358
|
+
if (!response.ok) {
|
|
359
|
+
const diagnostics = diagnosticMessage(payload);
|
|
360
|
+
const rawDetail = diagnostics ?? (text || response.statusText);
|
|
361
|
+
const detail = diagnostics ? rawDetail : rawDetail.split(`
|
|
362
|
+
`).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
|
|
363
|
+
const failure = await buildServerFailureContext(context.projectRoot, server);
|
|
364
|
+
throw new CliError(`Rig server request failed (${response.status}): ${detail}
|
|
365
|
+
${failure.contextLine}`, 1, { hint: failure.hint });
|
|
366
|
+
}
|
|
367
|
+
return payload;
|
|
368
|
+
}
|
|
369
|
+
async function listRunsViaServer(context, options = {}) {
|
|
370
|
+
const url = new URL("http://rig.local/api/runs");
|
|
371
|
+
if (options.limit !== undefined)
|
|
372
|
+
url.searchParams.set("limit", String(options.limit));
|
|
373
|
+
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
374
|
+
const runs = Array.isArray(payload) ? payload : payload && typeof payload === "object" && !Array.isArray(payload) && Array.isArray(payload.runs) ? payload.runs : [];
|
|
375
|
+
return runs.filter((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry)));
|
|
376
|
+
}
|
|
377
|
+
async function getRunLogsViaServer(context, runId, options = {}) {
|
|
378
|
+
const url = new URL(`http://rig.local/api/runs/${encodeURIComponent(runId)}/logs`);
|
|
379
|
+
if (options.limit !== undefined)
|
|
380
|
+
url.searchParams.set("limit", String(options.limit));
|
|
381
|
+
if (options.cursor)
|
|
382
|
+
url.searchParams.set("cursor", options.cursor);
|
|
383
|
+
const payload = await requestServerJson(context, `${url.pathname}${url.search}`);
|
|
384
|
+
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : { entries: [] };
|
|
385
|
+
}
|
|
386
|
+
var RESUMABLE_RUN_STATUSES = new Set([
|
|
387
|
+
"created",
|
|
388
|
+
"preparing",
|
|
389
|
+
"running",
|
|
390
|
+
"validating",
|
|
391
|
+
"reviewing",
|
|
392
|
+
"stopped",
|
|
393
|
+
"failed",
|
|
394
|
+
"needs-attention",
|
|
395
|
+
"needs_attention"
|
|
396
|
+
]);
|
|
397
|
+
|
|
398
|
+
// packages/cli/src/commands/_async-ui.ts
|
|
399
|
+
import pc from "picocolors";
|
|
400
|
+
|
|
401
|
+
// packages/cli/src/commands/_spinner.ts
|
|
402
|
+
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
403
|
+
function createTtySpinner(input) {
|
|
404
|
+
const output = input.output ?? process.stdout;
|
|
405
|
+
const isTty = output.isTTY === true;
|
|
406
|
+
const frames = input.frames && input.frames.length > 0 ? input.frames : SPINNER_FRAMES;
|
|
407
|
+
let label = input.label;
|
|
408
|
+
let frame = 0;
|
|
409
|
+
let paused = false;
|
|
410
|
+
let stopped = false;
|
|
411
|
+
let lastPrintedLabel = "";
|
|
412
|
+
const render = () => {
|
|
413
|
+
if (stopped || paused)
|
|
414
|
+
return;
|
|
415
|
+
if (!isTty) {
|
|
416
|
+
if (label !== lastPrintedLabel) {
|
|
417
|
+
output.write(`${label}
|
|
418
|
+
`);
|
|
419
|
+
lastPrintedLabel = label;
|
|
420
|
+
}
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
frame = (frame + 1) % frames.length;
|
|
424
|
+
const glyph = frames[frame] ?? frames[0] ?? "";
|
|
425
|
+
output.write(`\r\x1B[2K${input.styleFrame ? input.styleFrame(glyph) : glyph} ${label}`);
|
|
426
|
+
};
|
|
427
|
+
const clearLine = () => {
|
|
428
|
+
if (isTty)
|
|
429
|
+
output.write("\r\x1B[2K");
|
|
430
|
+
};
|
|
431
|
+
render();
|
|
432
|
+
const timer = isTty ? setInterval(render, input.intervalMs ?? 120) : null;
|
|
433
|
+
return {
|
|
434
|
+
setLabel(next) {
|
|
435
|
+
label = next;
|
|
436
|
+
render();
|
|
437
|
+
},
|
|
438
|
+
pause() {
|
|
439
|
+
paused = true;
|
|
440
|
+
clearLine();
|
|
441
|
+
},
|
|
442
|
+
resume() {
|
|
443
|
+
if (stopped)
|
|
444
|
+
return;
|
|
445
|
+
paused = false;
|
|
446
|
+
render();
|
|
447
|
+
},
|
|
448
|
+
stop(finalLine) {
|
|
449
|
+
if (stopped)
|
|
450
|
+
return;
|
|
451
|
+
stopped = true;
|
|
452
|
+
if (timer)
|
|
453
|
+
clearInterval(timer);
|
|
454
|
+
clearLine();
|
|
455
|
+
if (finalLine)
|
|
456
|
+
output.write(`${finalLine}
|
|
457
|
+
`);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// packages/cli/src/app/theme.ts
|
|
463
|
+
var RIG_PALETTE = {
|
|
464
|
+
ink: "#f2f3f6",
|
|
465
|
+
ink2: "#aeb0ba",
|
|
466
|
+
ink3: "#6c6e79",
|
|
467
|
+
ink4: "#44464f",
|
|
468
|
+
accent: "#ccff4d",
|
|
469
|
+
accentDim: "#a9d63f",
|
|
470
|
+
cyan: "#56d8ff",
|
|
471
|
+
red: "#ff5d5d",
|
|
472
|
+
yellow: "#ffd24d"
|
|
473
|
+
};
|
|
474
|
+
function hexToRgb(hex) {
|
|
475
|
+
const value = hex.replace("#", "");
|
|
476
|
+
return [
|
|
477
|
+
Number.parseInt(value.slice(0, 2), 16),
|
|
478
|
+
Number.parseInt(value.slice(2, 4), 16),
|
|
479
|
+
Number.parseInt(value.slice(4, 6), 16)
|
|
480
|
+
];
|
|
481
|
+
}
|
|
482
|
+
function fg(hex) {
|
|
483
|
+
const [r, g, b] = hexToRgb(hex);
|
|
484
|
+
return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
|
|
485
|
+
}
|
|
486
|
+
var ink = fg(RIG_PALETTE.ink);
|
|
487
|
+
var ink2 = fg(RIG_PALETTE.ink2);
|
|
488
|
+
var ink3 = fg(RIG_PALETTE.ink3);
|
|
489
|
+
var ink4 = fg(RIG_PALETTE.ink4);
|
|
490
|
+
var accent = fg(RIG_PALETTE.accent);
|
|
491
|
+
var accentDim = fg(RIG_PALETTE.accentDim);
|
|
492
|
+
var cyan = fg(RIG_PALETTE.cyan);
|
|
493
|
+
var red = fg(RIG_PALETTE.red);
|
|
494
|
+
var yellow = fg(RIG_PALETTE.yellow);
|
|
495
|
+
function bold(text) {
|
|
496
|
+
return `\x1B[1m${text}\x1B[22m`;
|
|
497
|
+
}
|
|
498
|
+
var DRONE_ART = [
|
|
499
|
+
" .-=-. .-=-. ",
|
|
500
|
+
" ( !!! ) ( !!! ) ",
|
|
501
|
+
" '-=-'._ _.'-=-' ",
|
|
502
|
+
" '._ _.' ",
|
|
503
|
+
" '=$$$$$$$=.' ",
|
|
504
|
+
" =$$$$$$$$$$$= ",
|
|
505
|
+
" $$$@@@@@@@@@@$$$ ",
|
|
506
|
+
" $$$@@ @@$$$ ",
|
|
507
|
+
" $$@ ? @$$$ ",
|
|
508
|
+
" $$$@ '-' @$$$ ",
|
|
509
|
+
" $$$@@ @@$$$ ",
|
|
510
|
+
" $$$@@@@@@@@@@$$$ ",
|
|
511
|
+
" =$$$$$$$$$$$= ",
|
|
512
|
+
" '=$$$$$$$=.' ",
|
|
513
|
+
" _.' '._ ",
|
|
514
|
+
" .-=-.' '.-=-. ",
|
|
515
|
+
" ( !!! ) ( !!! ) ",
|
|
516
|
+
" '-=-' '-=-' "
|
|
517
|
+
];
|
|
518
|
+
var EYE_FRAMES = ["@", "o", "."];
|
|
519
|
+
var DRONE_WIDTH = DRONE_ART[0].length;
|
|
520
|
+
var DRONE_HEIGHT = DRONE_ART.length;
|
|
521
|
+
var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
|
|
522
|
+
function microDroneFrame(tick) {
|
|
523
|
+
const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
|
|
524
|
+
const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
|
|
525
|
+
return `(${blade})${eye}(${blade})`;
|
|
526
|
+
}
|
|
527
|
+
var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
|
|
528
|
+
function renderMicroDroneFrame(tick) {
|
|
529
|
+
const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
|
|
530
|
+
const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
|
|
531
|
+
return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// packages/cli/src/commands/_async-ui.ts
|
|
535
|
+
var DONE_SYMBOL = pc.green("\u25C7");
|
|
536
|
+
var FAIL_SYMBOL = pc.red("\u25A0");
|
|
537
|
+
var activeUpdate = null;
|
|
538
|
+
async function withSpinner(label, work, options = {}) {
|
|
539
|
+
if (options.outputMode === "json") {
|
|
540
|
+
return work(() => {});
|
|
541
|
+
}
|
|
542
|
+
if (activeUpdate) {
|
|
543
|
+
const outer = activeUpdate;
|
|
544
|
+
outer(label);
|
|
545
|
+
return work(outer);
|
|
546
|
+
}
|
|
547
|
+
const output = options.output ?? process.stderr;
|
|
548
|
+
const isTty = output.isTTY === true;
|
|
549
|
+
let lastLabel = label;
|
|
550
|
+
if (!isTty) {
|
|
551
|
+
output.write(`${label}
|
|
552
|
+
`);
|
|
553
|
+
const update2 = (next) => {
|
|
554
|
+
lastLabel = next;
|
|
555
|
+
};
|
|
556
|
+
activeUpdate = update2;
|
|
557
|
+
const previousListener2 = setServerPhaseListener(update2);
|
|
558
|
+
try {
|
|
559
|
+
return await work(update2);
|
|
560
|
+
} finally {
|
|
561
|
+
activeUpdate = null;
|
|
562
|
+
setServerPhaseListener(previousListener2);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
const spinner = createTtySpinner({
|
|
566
|
+
label,
|
|
567
|
+
output,
|
|
568
|
+
frames: MICRO_DRONE_FRAMES,
|
|
569
|
+
styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
|
|
570
|
+
});
|
|
571
|
+
const update = (next) => {
|
|
572
|
+
lastLabel = next;
|
|
573
|
+
spinner.setLabel(next);
|
|
574
|
+
};
|
|
575
|
+
activeUpdate = update;
|
|
576
|
+
const previousListener = setServerPhaseListener(update);
|
|
577
|
+
try {
|
|
578
|
+
const result = await work(update);
|
|
579
|
+
spinner.stop(options.doneLabel ? `${DONE_SYMBOL} ${options.doneLabel}` : undefined);
|
|
580
|
+
return result;
|
|
581
|
+
} catch (error) {
|
|
582
|
+
spinner.stop(`${FAIL_SYMBOL} ${lastLabel}`);
|
|
583
|
+
throw error;
|
|
584
|
+
} finally {
|
|
585
|
+
activeUpdate = null;
|
|
586
|
+
setServerPhaseListener(previousListener);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// packages/cli/src/commands/inspect.ts
|
|
58
591
|
async function executeInspect(context, args) {
|
|
59
592
|
const [command = "failures", ...rest] = args;
|
|
60
593
|
switch (command) {
|
|
61
594
|
case "logs": {
|
|
62
595
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
63
|
-
requireNoExtraArgs(remaining, "
|
|
64
|
-
const requiredTask = requireTask(task, "
|
|
596
|
+
requireNoExtraArgs(remaining, "rig inspect logs --task <task-id>");
|
|
597
|
+
const requiredTask = requireTask(task, "rig inspect logs --task <task-id>");
|
|
65
598
|
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
599
|
if (!latestRun) {
|
|
67
|
-
|
|
600
|
+
const fallback = await withSpinner(`Finding runs for ${requiredTask} on the server\u2026`, async (update) => {
|
|
601
|
+
const serverRuns = await listRunsViaServer(context, { limit: 200 }).catch(() => []);
|
|
602
|
+
const serverRun = serverRuns.filter((run) => String(run.taskId ?? "") === requiredTask).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")))[0];
|
|
603
|
+
if (!serverRun || typeof serverRun.runId !== "string")
|
|
604
|
+
return null;
|
|
605
|
+
update(`Reading logs for run ${serverRun.runId}\u2026`);
|
|
606
|
+
const page = await getRunLogsViaServer(context, serverRun.runId, { limit: 500 });
|
|
607
|
+
return { runId: serverRun.runId, page };
|
|
608
|
+
}, { outputMode: context.outputMode });
|
|
609
|
+
if (!fallback) {
|
|
610
|
+
throw new CliError(`No runs found for ${requiredTask} (local or on the selected server).`, 1, { hint: "Start one with `rig task run --task <id>`, or check `rig run list`." });
|
|
611
|
+
}
|
|
612
|
+
const entries = Array.isArray(fallback.page.entries) ? fallback.page.entries : [];
|
|
613
|
+
if (context.outputMode === "text") {
|
|
614
|
+
for (const entry of entries) {
|
|
615
|
+
const record = entry && typeof entry === "object" ? entry : {};
|
|
616
|
+
const title = String(record.title ?? "");
|
|
617
|
+
const detail = String(record.detail ?? "");
|
|
618
|
+
console.log([title, detail].filter(Boolean).join(" \u2014 "));
|
|
619
|
+
}
|
|
620
|
+
if (entries.length === 0)
|
|
621
|
+
console.log(`(no log entries for run ${fallback.runId})`);
|
|
622
|
+
}
|
|
623
|
+
return { ok: true, group: "inspect", command, details: { task: requiredTask, runId: fallback.runId, source: "server", entries } };
|
|
68
624
|
}
|
|
69
|
-
const logsPath =
|
|
70
|
-
if (!
|
|
71
|
-
throw new
|
|
625
|
+
const logsPath = resolve3(resolveAuthorityRunDir(context.projectRoot, latestRun.runId), "logs.jsonl");
|
|
626
|
+
if (!existsSync3(logsPath)) {
|
|
627
|
+
throw new CliError(`No logs found for run ${latestRun.runId}.`, 1, { hint: `Try \`rig run show ${latestRun.runId}\` or \`rig run replay ${latestRun.runId}\`.` });
|
|
72
628
|
}
|
|
73
629
|
await context.runCommand(["cat", logsPath]);
|
|
74
630
|
return { ok: true, group: "inspect", command, details: { task: requiredTask, runId: latestRun.runId } };
|
|
75
631
|
}
|
|
76
632
|
case "artifacts": {
|
|
77
633
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
78
|
-
requireNoExtraArgs(remaining, "
|
|
79
|
-
const requiredTask = requireTask(task, "
|
|
80
|
-
const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) =>
|
|
634
|
+
requireNoExtraArgs(remaining, "rig inspect artifacts --task <task-id>");
|
|
635
|
+
const requiredTask = requireTask(task, "rig inspect artifacts --task <task-id>");
|
|
636
|
+
const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync3(path));
|
|
81
637
|
if (!artifactRoot) {
|
|
82
|
-
throw new
|
|
638
|
+
throw new CliError(`No artifacts found for ${requiredTask}.`, 1, { hint: "Artifacts appear after a run completes; check `rig run list` for run state." });
|
|
83
639
|
}
|
|
84
640
|
await context.runCommand(["ls", "-la", artifactRoot]);
|
|
85
641
|
return { ok: true, group: "inspect", command, details: { task: requiredTask } };
|
|
@@ -90,10 +646,10 @@ async function executeInspect(context, args) {
|
|
|
90
646
|
previewPending = task.rest;
|
|
91
647
|
const file = takeOption(previewPending, "--file");
|
|
92
648
|
previewPending = file.rest;
|
|
93
|
-
requireNoExtraArgs(previewPending, "
|
|
94
|
-
const requiredTask = requireTask(task.value, "
|
|
649
|
+
requireNoExtraArgs(previewPending, "rig inspect artifact --task <task-id> --file <name>");
|
|
650
|
+
const requiredTask = requireTask(task.value, "rig inspect artifact --task <task-id> --file <name>");
|
|
95
651
|
if (!file.value) {
|
|
96
|
-
throw new
|
|
652
|
+
throw new CliError("Missing --file for rig inspect artifact.", 1, { hint: "List artifact files first: `rig inspect artifacts --task <id>`, then pass one with --file." });
|
|
97
653
|
}
|
|
98
654
|
const preview = readTaskArtifactPreview(context.projectRoot, requiredTask, file.value);
|
|
99
655
|
if (context.outputMode === "text") {
|
|
@@ -120,9 +676,9 @@ async function executeInspect(context, args) {
|
|
|
120
676
|
}
|
|
121
677
|
case "diff": {
|
|
122
678
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
123
|
-
requireNoExtraArgs(remaining, "
|
|
679
|
+
requireNoExtraArgs(remaining, "rig inspect diff [--task <task-id>]");
|
|
124
680
|
if (task) {
|
|
125
|
-
const files = changedFilesForTask(context.projectRoot, task, false);
|
|
681
|
+
const files = await withSpinner(`Computing changed files for ${task}\u2026`, async () => changedFilesForTask(context.projectRoot, task, false), { outputMode: context.outputMode });
|
|
126
682
|
for (const file of files) {
|
|
127
683
|
console.log(file);
|
|
128
684
|
}
|
|
@@ -132,33 +688,33 @@ async function executeInspect(context, args) {
|
|
|
132
688
|
return { ok: true, group: "inspect", command, details: { task: task || null } };
|
|
133
689
|
}
|
|
134
690
|
case "failures": {
|
|
135
|
-
requireNoExtraArgs(rest, "
|
|
691
|
+
requireNoExtraArgs(rest, "rig inspect failures");
|
|
136
692
|
const failed = resolveHarnessPaths(context.projectRoot).failedApproachesPath;
|
|
137
|
-
if (!
|
|
693
|
+
if (!existsSync3(failed)) {
|
|
138
694
|
console.log("No failures recorded.");
|
|
139
695
|
} else {
|
|
140
|
-
process.stdout.write(
|
|
696
|
+
process.stdout.write(readFileSync3(failed, "utf-8"));
|
|
141
697
|
}
|
|
142
698
|
return { ok: true, group: "inspect", command };
|
|
143
699
|
}
|
|
144
700
|
case "graph":
|
|
145
|
-
requireNoExtraArgs(rest, "
|
|
701
|
+
requireNoExtraArgs(rest, "rig inspect graph");
|
|
146
702
|
{
|
|
147
703
|
const monorepoRoot = resolveMonorepoRoot(context.projectRoot);
|
|
148
704
|
const result = runCapture(["br", "--no-db", "list", "--pretty"], monorepoRoot);
|
|
149
705
|
if (result.exitCode !== 0) {
|
|
150
|
-
throw new
|
|
706
|
+
throw new CliError(result.stderr || result.stdout || "Failed to inspect graph");
|
|
151
707
|
}
|
|
152
708
|
process.stdout.write(result.stdout);
|
|
153
709
|
}
|
|
154
710
|
return { ok: true, group: "inspect", command };
|
|
155
711
|
case "audit": {
|
|
156
|
-
requireNoExtraArgs(rest, "
|
|
157
|
-
const auditPath =
|
|
158
|
-
if (!
|
|
712
|
+
requireNoExtraArgs(rest, "rig inspect audit");
|
|
713
|
+
const auditPath = resolve3(resolveHarnessPaths(context.projectRoot).logsDir, "audit.jsonl");
|
|
714
|
+
if (!existsSync3(auditPath)) {
|
|
159
715
|
console.log("No audit log found.");
|
|
160
716
|
} else {
|
|
161
|
-
const lines =
|
|
717
|
+
const lines = readFileSync3(auditPath, "utf-8").split(/\r?\n/).filter(Boolean).slice(-20);
|
|
162
718
|
for (const line of lines) {
|
|
163
719
|
console.log(line);
|
|
164
720
|
}
|
|
@@ -166,7 +722,7 @@ async function executeInspect(context, args) {
|
|
|
166
722
|
return { ok: true, group: "inspect", command };
|
|
167
723
|
}
|
|
168
724
|
default:
|
|
169
|
-
throw new
|
|
725
|
+
throw new CliError(`Unknown inspect command: ${command}`, 1, { hint: "Run `rig inspect --help` to list inspect commands." });
|
|
170
726
|
}
|
|
171
727
|
}
|
|
172
728
|
export {
|