@h-rig/cli 0.0.6-alpha.82 → 0.0.6-alpha.84
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/build-rig-binaries.js +40 -8
- package/dist/bin/rig.js +23402 -14577
- package/dist/src/app/board.js +217 -41
- package/dist/src/app-opentui/adapters/command.d.ts +2 -0
- package/dist/src/app-opentui/adapters/command.js +329 -0
- package/dist/src/app-opentui/adapters/common.js +2 -2
- package/dist/src/app-opentui/adapters/doctor.d.ts +0 -2
- package/dist/src/app-opentui/adapters/doctor.js +64 -39
- package/dist/src/app-opentui/adapters/family.d.ts +62 -0
- package/dist/src/app-opentui/adapters/family.js +14305 -0
- package/dist/src/app-opentui/adapters/fleet.d.ts +0 -2
- package/dist/src/app-opentui/adapters/fleet.js +90 -60
- package/dist/src/app-opentui/adapters/inbox.d.ts +12 -2
- package/dist/src/app-opentui/adapters/inbox.js +137 -78
- package/dist/src/app-opentui/adapters/init.d.ts +0 -2
- package/dist/src/app-opentui/adapters/init.js +85 -47
- package/dist/src/app-opentui/adapters/inspect.d.ts +52 -0
- package/dist/src/app-opentui/adapters/inspect.js +1024 -0
- package/dist/src/app-opentui/adapters/pi-attach.d.ts +15 -6
- package/dist/src/app-opentui/adapters/pi-attach.js +442 -125
- package/dist/src/app-opentui/adapters/pi.d.ts +23 -0
- package/dist/src/app-opentui/adapters/pi.js +363 -0
- package/dist/src/app-opentui/adapters/plugin.d.ts +84 -0
- package/dist/src/app-opentui/adapters/plugin.js +544 -0
- package/dist/src/app-opentui/adapters/repo.d.ts +37 -0
- package/dist/src/app-opentui/adapters/repo.js +186 -0
- package/dist/src/app-opentui/adapters/run-detail.d.ts +9 -2
- package/dist/src/app-opentui/adapters/run-detail.js +180 -63
- package/dist/src/app-opentui/adapters/server.d.ts +10 -2
- package/dist/src/app-opentui/adapters/server.js +191 -45
- package/dist/src/app-opentui/adapters/tasks.d.ts +11 -2
- package/dist/src/app-opentui/adapters/tasks.js +1123 -143
- package/dist/src/app-opentui/adapters/workspace.d.ts +49 -0
- package/dist/src/app-opentui/adapters/workspace.js +333 -0
- package/dist/src/app-opentui/autocomplete.d.ts +20 -0
- package/dist/src/app-opentui/autocomplete.js +576 -0
- package/dist/src/app-opentui/bootstrap.d.ts +1 -6
- package/dist/src/app-opentui/bootstrap.js +25252 -16474
- package/dist/src/app-opentui/command-palette.d.ts +3 -0
- package/dist/src/app-opentui/command-palette.js +1010 -0
- package/dist/src/app-opentui/command-pty-host.d.ts +62 -0
- package/dist/src/app-opentui/command-pty-host.js +248 -0
- package/dist/src/app-opentui/drone.js +8 -6
- package/dist/src/app-opentui/events.js +1 -1
- package/dist/src/app-opentui/fleet-stats.d.ts +32 -0
- package/dist/src/app-opentui/fleet-stats.js +114 -0
- package/dist/src/app-opentui/focus-manager.d.ts +14 -0
- package/dist/src/app-opentui/focus-manager.js +24 -0
- package/dist/src/app-opentui/index.js +5431 -2797
- package/dist/src/app-opentui/intent.js +179 -50
- package/dist/src/app-opentui/keymap.d.ts +21 -0
- package/dist/src/app-opentui/keymap.js +1748 -0
- package/dist/src/app-opentui/launch-routing.d.ts +16 -0
- package/dist/src/app-opentui/launch-routing.js +55 -0
- package/dist/src/app-opentui/layout.d.ts +7 -0
- package/dist/src/app-opentui/layout.js +13 -6
- package/dist/src/app-opentui/list-search.d.ts +24 -0
- package/dist/src/app-opentui/list-search.js +88 -1
- package/dist/src/app-opentui/pi-host-child.js +99 -17
- package/dist/src/app-opentui/pi-pty-host.d.ts +14 -0
- package/dist/src/app-opentui/pi-pty-host.js +30 -14
- package/dist/src/app-opentui/react/App.d.ts +9 -0
- package/dist/src/app-opentui/react/App.js +5144 -0
- package/dist/src/app-opentui/react/Backdrop.d.ts +5 -0
- package/dist/src/app-opentui/react/Backdrop.js +1834 -0
- package/dist/src/app-opentui/react/ChromeHost.d.ts +5 -0
- package/dist/src/app-opentui/react/ChromeHost.js +2942 -0
- package/dist/src/app-opentui/react/SceneFrameView.d.ts +7 -0
- package/dist/src/app-opentui/react/SceneFrameView.js +529 -0
- package/dist/src/app-opentui/react/context.d.ts +17 -0
- package/dist/src/app-opentui/react/context.js +37 -0
- package/dist/src/app-opentui/react/launch.d.ts +2 -0
- package/dist/src/app-opentui/react/launch.js +5743 -0
- package/dist/src/app-opentui/react/nav.d.ts +18 -0
- package/dist/src/app-opentui/react/nav.js +54 -0
- package/dist/src/app-opentui/react/scroll.d.ts +12 -0
- package/dist/src/app-opentui/react/scroll.js +21 -0
- package/dist/src/app-opentui/react/syntax.d.ts +2 -0
- package/dist/src/app-opentui/react/syntax.js +64 -0
- package/dist/src/app-opentui/registry.js +20428 -4828
- package/dist/src/app-opentui/render/ascii-fleet.d.ts +15 -0
- package/dist/src/app-opentui/render/ascii-fleet.js +82 -0
- package/dist/src/app-opentui/render/constants.d.ts +31 -0
- package/dist/src/app-opentui/render/constants.js +66 -0
- package/dist/src/app-opentui/render/graphics.d.ts +2 -1
- package/dist/src/app-opentui/render/graphics.js +228 -46
- package/dist/src/app-opentui/render/image-visual-layer-worker.js +469 -930
- package/dist/src/app-opentui/render/image-visual-layer.d.ts +25 -10
- package/dist/src/app-opentui/render/image-visual-layer.js +448 -329
- package/dist/src/app-opentui/render/native-host.d.ts +37 -0
- package/dist/src/app-opentui/render/native-host.js +179 -0
- package/dist/src/app-opentui/render/panel-layout.d.ts +38 -0
- package/dist/src/app-opentui/render/panel-layout.js +48 -0
- package/dist/src/app-opentui/render/panels.d.ts +2 -0
- package/dist/src/app-opentui/render/panels.js +78 -38
- package/dist/src/app-opentui/render/preloader.d.ts +10 -0
- package/dist/src/app-opentui/render/preloader.js +165 -0
- package/dist/src/app-opentui/render/scene.d.ts +53 -1
- package/dist/src/app-opentui/render/scene.js +195 -6
- package/dist/src/app-opentui/render/text.d.ts +7 -1
- package/dist/src/app-opentui/render/text.js +15 -8
- package/dist/src/app-opentui/render/type-bar.d.ts +2 -1
- package/dist/src/app-opentui/render/type-bar.js +113 -39
- package/dist/src/app-opentui/runtime-resources.d.ts +16 -0
- package/dist/src/app-opentui/runtime-resources.js +62 -0
- package/dist/src/app-opentui/runtime.d.ts +44 -1
- package/dist/src/app-opentui/runtime.js +5415 -2738
- package/dist/src/app-opentui/scenes/command.d.ts +3 -0
- package/dist/src/app-opentui/scenes/command.js +117 -0
- package/dist/src/app-opentui/scenes/doctor.d.ts +2 -1
- package/dist/src/app-opentui/scenes/doctor.js +221 -17
- package/dist/src/app-opentui/scenes/error.js +60 -20
- package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/agent.js +348 -0
- package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/browser.js +195 -0
- package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/dist.js +243 -0
- package/dist/src/app-opentui/scenes/family-domains/git.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/git.js +195 -0
- package/dist/src/app-opentui/scenes/family-domains/github.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/github.js +274 -0
- package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/harness.js +152 -0
- package/dist/src/app-opentui/scenes/family-domains/index.d.ts +4 -0
- package/dist/src/app-opentui/scenes/family-domains/index.js +1679 -0
- package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +76 -0
- package/dist/src/app-opentui/scenes/family-domains/kit.js +305 -0
- package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/profile.js +212 -0
- package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/queue.js +146 -0
- package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/remote.js +518 -0
- package/dist/src/app-opentui/scenes/family-domains/review.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/review.js +280 -0
- package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/setup.js +267 -0
- package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/stats.js +370 -0
- package/dist/src/app-opentui/scenes/family.d.ts +3 -0
- package/dist/src/app-opentui/scenes/family.js +2144 -0
- package/dist/src/app-opentui/scenes/fleet.js +552 -43
- package/dist/src/app-opentui/scenes/handoff.js +342 -35
- package/dist/src/app-opentui/scenes/help.js +640 -56
- package/dist/src/app-opentui/scenes/inbox.d.ts +2 -1
- package/dist/src/app-opentui/scenes/inbox.js +329 -21
- package/dist/src/app-opentui/scenes/init.d.ts +2 -1
- package/dist/src/app-opentui/scenes/init.js +120 -34
- package/dist/src/app-opentui/scenes/inspect.d.ts +3 -0
- package/dist/src/app-opentui/scenes/inspect.js +793 -0
- package/dist/src/app-opentui/scenes/main.d.ts +2 -1
- package/dist/src/app-opentui/scenes/main.js +264 -29
- package/dist/src/app-opentui/scenes/pi.d.ts +3 -0
- package/dist/src/app-opentui/scenes/pi.js +508 -0
- package/dist/src/app-opentui/scenes/plugin.d.ts +3 -0
- package/dist/src/app-opentui/scenes/plugin.js +486 -0
- package/dist/src/app-opentui/scenes/repo.d.ts +3 -0
- package/dist/src/app-opentui/scenes/repo.js +424 -0
- package/dist/src/app-opentui/scenes/run-detail.d.ts +2 -1
- package/dist/src/app-opentui/scenes/run-detail.js +362 -35
- package/dist/src/app-opentui/scenes/server.d.ts +2 -1
- package/dist/src/app-opentui/scenes/server.js +243 -26
- package/dist/src/app-opentui/scenes/tasks.js +518 -41
- package/dist/src/app-opentui/scenes/workspace.d.ts +3 -0
- package/dist/src/app-opentui/scenes/workspace.js +426 -0
- package/dist/src/app-opentui/selectable.d.ts +19 -0
- package/dist/src/app-opentui/selectable.js +79 -0
- package/dist/src/app-opentui/state.js +129 -36
- package/dist/src/app-opentui/surface-catalog.d.ts +20 -0
- package/dist/src/app-opentui/surface-catalog.js +540 -0
- package/dist/src/app-opentui/terminal-capabilities.d.ts +7 -0
- package/dist/src/app-opentui/terminal-capabilities.js +15 -0
- package/dist/src/app-opentui/theme.d.ts +28 -6
- package/dist/src/app-opentui/theme.js +61 -8
- package/dist/src/app-opentui/types.d.ts +130 -5
- package/dist/src/commands/_authority-runs.d.ts +1 -1
- package/dist/src/commands/_authority-runs.js +2 -12
- package/dist/src/commands/_doctor-checks.js +62 -13
- package/dist/src/commands/_help-catalog.js +95 -15
- package/dist/src/commands/_operator-view.js +97 -15
- package/dist/src/commands/_pi-frontend.d.ts +2 -0
- package/dist/src/commands/_pi-frontend.js +97 -13
- package/dist/src/commands/_preflight.js +64 -14
- package/dist/src/commands/_server-client.js +82 -18
- package/dist/src/commands/_server-events.d.ts +26 -0
- package/dist/src/commands/_server-events.js +310 -0
- package/dist/src/commands/_snapshot-upload.js +62 -13
- package/dist/src/commands/agent.js +2 -12
- package/dist/src/commands/connect.js +7 -1
- package/dist/src/commands/doctor.js +62 -13
- package/dist/src/commands/github.js +144 -23
- package/dist/src/commands/inbox.js +62 -13
- package/dist/src/commands/init.js +82 -18
- package/dist/src/commands/inspect.js +62 -13
- package/dist/src/commands/run.js +100 -15
- package/dist/src/commands/server.js +71 -26
- package/dist/src/commands/setup.js +62 -13
- package/dist/src/commands/stats.js +157 -28
- package/dist/src/commands/task-run-driver.js +64 -25
- package/dist/src/commands/task.js +196 -43
- package/dist/src/commands.js +419 -123
- package/dist/src/index.js +426 -130
- package/package.json +11 -10
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.d.ts +0 -2
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.js +0 -1484
|
@@ -193,17 +193,21 @@ function setGitHubBearerTokenForCurrentProcess(token, projectRoot) {
|
|
|
193
193
|
const scopedKey = resolve2(projectRoot ?? process.cwd());
|
|
194
194
|
scopedGitHubBearerTokens.set(scopedKey, cleanToken(token ?? undefined));
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function readRemoteAuthState(projectRoot) {
|
|
197
197
|
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
198
198
|
if (!existsSync2(path))
|
|
199
199
|
return null;
|
|
200
200
|
try {
|
|
201
201
|
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
202
|
-
return
|
|
202
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
203
203
|
} catch {
|
|
204
204
|
return null;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
+
function readPrivateRemoteSessionToken(projectRoot) {
|
|
208
|
+
const parsed = readRemoteAuthState(projectRoot);
|
|
209
|
+
return parsed ? cleanToken(typeof parsed.apiSessionToken === "string" ? parsed.apiSessionToken : typeof parsed.sessionToken === "string" ? parsed.sessionToken : undefined) : null;
|
|
210
|
+
}
|
|
207
211
|
function readGitHubBearerTokenForRemote(projectRoot) {
|
|
208
212
|
const scopedKey = resolve2(projectRoot);
|
|
209
213
|
if (scopedGitHubBearerTokens.has(scopedKey))
|
|
@@ -214,15 +218,25 @@ function readGitHubBearerTokenForRemote(projectRoot) {
|
|
|
214
218
|
return cleanToken(process.env.RIG_SERVER_AUTH_TOKEN) ?? cleanToken(process.env.RIG_REMOTE_AUTH_TOKEN);
|
|
215
219
|
}
|
|
216
220
|
function readStoredGitHubAuthToken(projectRoot) {
|
|
217
|
-
const
|
|
218
|
-
|
|
221
|
+
const parsed = readRemoteAuthState(projectRoot);
|
|
222
|
+
return parsed ? cleanToken(typeof parsed.token === "string" ? parsed.token : undefined) : null;
|
|
223
|
+
}
|
|
224
|
+
function inferRemoteServerProjectRootFromAuthState(projectRoot) {
|
|
225
|
+
const repo = readRepoConnection(projectRoot);
|
|
226
|
+
const slug = repo?.project?.trim();
|
|
227
|
+
if (!slug || !/^[^/]+\/[^/]+$/.test(slug))
|
|
219
228
|
return null;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
229
|
+
const auth = readRemoteAuthState(projectRoot);
|
|
230
|
+
const authUpdatedAt = typeof auth?.updatedAt === "string" ? Date.parse(auth.updatedAt) : Number.NaN;
|
|
231
|
+
const repoLinkedAt = typeof repo?.linkedAt === "string" ? Date.parse(repo.linkedAt) : Number.NaN;
|
|
232
|
+
if (Number.isFinite(authUpdatedAt) && Number.isFinite(repoLinkedAt) && authUpdatedAt + 1000 < repoLinkedAt)
|
|
224
233
|
return null;
|
|
225
|
-
|
|
234
|
+
const checkoutBaseDir = typeof auth?.checkoutBaseDir === "string" && auth.checkoutBaseDir.trim() ? auth.checkoutBaseDir.trim() : null;
|
|
235
|
+
if (!checkoutBaseDir)
|
|
236
|
+
return null;
|
|
237
|
+
const inferred = `${checkoutBaseDir.replace(/\/+$/, "")}/${slug}`;
|
|
238
|
+
writeRepoServerProjectRoot(projectRoot, inferred);
|
|
239
|
+
return inferred;
|
|
226
240
|
}
|
|
227
241
|
function readLocalConnectionFallbackToken(projectRoot) {
|
|
228
242
|
return readGitHubBearerTokenForRemote(projectRoot) ?? cleanToken(process.env.RIG_GITHUB_TOKEN) ?? readStoredGitHubAuthToken(projectRoot);
|
|
@@ -233,7 +247,7 @@ async function ensureServerForCli(projectRoot) {
|
|
|
233
247
|
if (selected?.connection.kind === "remote") {
|
|
234
248
|
reportServerPhase(`Connecting to ${selected.alias}\u2026`);
|
|
235
249
|
const authToken = readGitHubBearerTokenForRemote(projectRoot);
|
|
236
|
-
const serverProjectRoot = selected.serverProjectRoot ?? await backfillRemoteServerProjectRoot(projectRoot, selected.connection.baseUrl, authToken);
|
|
250
|
+
const serverProjectRoot = selected.serverProjectRoot ?? inferRemoteServerProjectRootFromAuthState(projectRoot) ?? await backfillRemoteServerProjectRoot(projectRoot, selected.connection.baseUrl, authToken);
|
|
237
251
|
return {
|
|
238
252
|
baseUrl: selected.connection.baseUrl,
|
|
239
253
|
authToken,
|
|
@@ -262,7 +276,10 @@ async function backfillRemoteServerProjectRoot(projectRoot, baseUrl, authToken)
|
|
|
262
276
|
if (!slug)
|
|
263
277
|
return null;
|
|
264
278
|
try {
|
|
265
|
-
const
|
|
279
|
+
const url = new URL(`${baseUrl}/api/projects/${encodeURIComponent(slug)}`);
|
|
280
|
+
if (authToken && queryAuthFallbackEnabled())
|
|
281
|
+
url.searchParams.set("rt", authToken);
|
|
282
|
+
const response = await fetch(url, {
|
|
266
283
|
headers: mergeHeaders(undefined, authToken)
|
|
267
284
|
});
|
|
268
285
|
if (!response.ok)
|
|
@@ -279,10 +296,23 @@ async function backfillRemoteServerProjectRoot(projectRoot, baseUrl, authToken)
|
|
|
279
296
|
return null;
|
|
280
297
|
}
|
|
281
298
|
}
|
|
299
|
+
function mergeCookie(existing, name, value) {
|
|
300
|
+
const encoded = `${name}=${encodeURIComponent(value)}`;
|
|
301
|
+
if (!existing?.trim())
|
|
302
|
+
return encoded;
|
|
303
|
+
const parts = existing.split(";").map((part) => part.trim()).filter((part) => part && !part.startsWith(`${name}=`));
|
|
304
|
+
return [...parts, encoded].join("; ");
|
|
305
|
+
}
|
|
306
|
+
function queryAuthFallbackEnabled(env = process.env) {
|
|
307
|
+
return env.RIG_ENABLE_QUERY_AUTH_FALLBACK === "1" || env.RIG_QUERY_AUTH_FALLBACK === "1";
|
|
308
|
+
}
|
|
282
309
|
function mergeHeaders(headers, authToken) {
|
|
283
310
|
const merged = new Headers(headers);
|
|
284
311
|
if (authToken) {
|
|
285
|
-
|
|
312
|
+
const bearer = `Bearer ${authToken}`;
|
|
313
|
+
merged.set("authorization", bearer);
|
|
314
|
+
merged.set("x-auth", bearer);
|
|
315
|
+
merged.set("cookie", mergeCookie(merged.get("cookie"), "rig_auth", authToken));
|
|
286
316
|
}
|
|
287
317
|
return merged;
|
|
288
318
|
}
|
|
@@ -342,15 +372,34 @@ async function buildServerFailureContext(projectRoot, server) {
|
|
|
342
372
|
hint: "Check the selected server with `rig server status`, or switch with `rig server use <alias|local>`."
|
|
343
373
|
};
|
|
344
374
|
}
|
|
375
|
+
function isLoopbackRemoteBaseUrl(baseUrl) {
|
|
376
|
+
try {
|
|
377
|
+
const host = new URL(baseUrl).hostname.toLowerCase();
|
|
378
|
+
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
|
|
379
|
+
} catch {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function canUseRemoteWithoutProjectRoot(pathname) {
|
|
384
|
+
return pathname === "/health" || pathname === "/api/health" || pathname === "/api/server/status" || pathname === "/api/server/project-root" || pathname.startsWith("/api/github/auth/") || pathname === "/api/projects" || pathname.startsWith("/api/projects/");
|
|
385
|
+
}
|
|
345
386
|
async function requestServerJson(context, pathname, init = {}) {
|
|
346
387
|
const server = await ensureServerForCli(context.projectRoot);
|
|
388
|
+
const requestUrl = new URL(`${server.baseUrl}${pathname}`);
|
|
389
|
+
if (server.connectionKind === "remote" && !server.serverProjectRoot && !canUseRemoteWithoutProjectRoot(requestUrl.pathname) && (server.authToken || !isLoopbackRemoteBaseUrl(server.baseUrl))) {
|
|
390
|
+
const repo = readRepoConnection(context.projectRoot);
|
|
391
|
+
throw new CliError(`Remote server is selected for ${repo?.project ?? "this repo"}, but this checkout has no server-host project root link.`, 1, { hint: "Run `rig init --repair` or `rig init --yes --repo owner/repo --server remote` to repair the remote project link before task/run commands." });
|
|
392
|
+
}
|
|
347
393
|
const headers = mergeHeaders(init.headers, server.authToken);
|
|
348
394
|
if (server.serverProjectRoot)
|
|
349
395
|
headers.set("x-rig-project-root", server.serverProjectRoot);
|
|
396
|
+
if (server.connectionKind === "remote" && server.authToken && queryAuthFallbackEnabled()) {
|
|
397
|
+
requestUrl.searchParams.set("rt", server.authToken);
|
|
398
|
+
}
|
|
350
399
|
reportServerPhase(`${(init.method ?? "GET").toUpperCase()} ${pathname.split("?")[0]}\u2026`);
|
|
351
400
|
let response;
|
|
352
401
|
try {
|
|
353
|
-
response = await fetch(
|
|
402
|
+
response = await fetch(requestUrl, {
|
|
354
403
|
...init,
|
|
355
404
|
headers
|
|
356
405
|
});
|
|
@@ -379,11 +428,26 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
|
|
|
379
428
|
return payload;
|
|
380
429
|
}
|
|
381
430
|
async function postGitHubTokenViaServer(context, token, options = {}) {
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
431
|
+
const server = await ensureServerForCli(context.projectRoot);
|
|
432
|
+
const requestUrl = new URL(`${server.baseUrl}/api/github/auth/token`);
|
|
433
|
+
reportServerPhase("POST /api/github/auth/token\u2026");
|
|
434
|
+
let response;
|
|
435
|
+
try {
|
|
436
|
+
response = await fetch(requestUrl, {
|
|
437
|
+
method: "POST",
|
|
438
|
+
headers: { "content-type": "application/json" },
|
|
439
|
+
body: JSON.stringify({ token, selectedRepo: options.selectedRepo, projectRoot: options.projectRoot ?? server.serverProjectRoot ?? undefined })
|
|
440
|
+
});
|
|
441
|
+
} catch (error) {
|
|
442
|
+
const failure = await buildServerFailureContext(context.projectRoot, server);
|
|
443
|
+
throw new CliError(`Rig server auth bootstrap failed: ${error instanceof Error ? error.message : String(error)}
|
|
444
|
+
${failure.contextLine}`, 1, { hint: failure.hint });
|
|
445
|
+
}
|
|
446
|
+
const payload = await response.json().catch(() => null);
|
|
447
|
+
if (!response.ok) {
|
|
448
|
+
const detail = payload && typeof payload === "object" && !Array.isArray(payload) ? String(payload.error ?? JSON.stringify(payload)) : `HTTP ${response.status}`;
|
|
449
|
+
throw new CliError(`Rig server auth bootstrap failed (${response.status}): ${detail}`, 1, { hint: "Re-run `rig github auth import-gh`, or check the selected server with `rig server status`." });
|
|
450
|
+
}
|
|
387
451
|
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
388
452
|
}
|
|
389
453
|
async function prepareRemoteCheckoutViaServer(context, input) {
|
|
@@ -2203,20 +2267,11 @@ import { existsSync as existsSync6 } from "fs";
|
|
|
2203
2267
|
import { resolve as resolve7 } from "path";
|
|
2204
2268
|
|
|
2205
2269
|
// packages/cli/src/app-opentui/adapters/common.ts
|
|
2206
|
-
function adapterContextFromRuntime(runtime, renderer) {
|
|
2207
|
-
return {
|
|
2208
|
-
projectRoot: runtime.getState().projectRoot,
|
|
2209
|
-
renderer,
|
|
2210
|
-
ensureRuntime: () => runtime.getRunnerContext(),
|
|
2211
|
-
emit: (event) => runtime.emit(event),
|
|
2212
|
-
getState: () => runtime.getState()
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2215
2270
|
function projectRootOf(ctx) {
|
|
2216
2271
|
const root = ctx.rig?.projectRoot ?? ctx.projectRoot ?? ctx.getState().projectRoot;
|
|
2217
2272
|
if (typeof root === "string" && root.trim())
|
|
2218
2273
|
return root;
|
|
2219
|
-
throw new Error("
|
|
2274
|
+
throw new Error("App adapter requires a projectRoot.");
|
|
2220
2275
|
}
|
|
2221
2276
|
async function runtimeOf(ctx) {
|
|
2222
2277
|
if (ctx.rig && "runId" in ctx.rig && ctx.ensureRuntime === undefined) {
|
|
@@ -2224,7 +2279,7 @@ async function runtimeOf(ctx) {
|
|
|
2224
2279
|
}
|
|
2225
2280
|
if (ctx.ensureRuntime)
|
|
2226
2281
|
return ctx.ensureRuntime();
|
|
2227
|
-
throw new Error("
|
|
2282
|
+
throw new Error("App adapter requires ensureRuntime() before this action can run.");
|
|
2228
2283
|
}
|
|
2229
2284
|
function normalizeAppError(error) {
|
|
2230
2285
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -2285,22 +2340,6 @@ async function captureConsole(fn) {
|
|
|
2285
2340
|
}
|
|
2286
2341
|
|
|
2287
2342
|
// packages/cli/src/app-opentui/adapters/init.ts
|
|
2288
|
-
function createInitAdapter() {
|
|
2289
|
-
return {
|
|
2290
|
-
id: "init",
|
|
2291
|
-
async handleIntent(runtime, intent) {
|
|
2292
|
-
if (intent.scene !== "init" && intent.action.kind !== "init-start")
|
|
2293
|
-
return false;
|
|
2294
|
-
const ctx = adapterContextFromRuntime(runtime);
|
|
2295
|
-
if (intent.action.kind === "init-start" && intent.argv.includes("--yes")) {
|
|
2296
|
-
await runInitYes(ctx, ["--yes"]);
|
|
2297
|
-
return true;
|
|
2298
|
-
}
|
|
2299
|
-
await loadInitFacts(ctx);
|
|
2300
|
-
return true;
|
|
2301
|
-
}
|
|
2302
|
-
};
|
|
2303
|
-
}
|
|
2304
2343
|
function readInitFacts(ctx) {
|
|
2305
2344
|
const projectRoot = projectRootOf(ctx);
|
|
2306
2345
|
const configNames = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
@@ -2326,7 +2365,7 @@ async function loadInitFacts(ctx) {
|
|
|
2326
2365
|
}
|
|
2327
2366
|
}
|
|
2328
2367
|
async function runInitYes(ctx, args = ["--yes"]) {
|
|
2329
|
-
const label = "Initializing
|
|
2368
|
+
const label = "Initializing project";
|
|
2330
2369
|
emitStarted(ctx, label, { init: { status: "writing-config" } });
|
|
2331
2370
|
try {
|
|
2332
2371
|
const runtime = await runtimeOf(ctx);
|
|
@@ -2352,6 +2391,5 @@ export {
|
|
|
2352
2391
|
runInitYes,
|
|
2353
2392
|
readInitFacts,
|
|
2354
2393
|
loadInitFacts,
|
|
2355
|
-
createInitAdapter,
|
|
2356
2394
|
buildInitTypeBarSuggestions
|
|
2357
2395
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type AppAdapterContext } from "./common";
|
|
2
|
+
export type InspectView = "logs" | "timeline" | "artifacts" | "artifact" | "diff" | "failures" | "graph" | "audit";
|
|
3
|
+
export declare const INSPECT_VIEWS: readonly InspectView[];
|
|
4
|
+
export type AppInspectArtifact = {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly sizeBytes: number;
|
|
8
|
+
readonly isDir: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type AppInspectRunOption = {
|
|
11
|
+
readonly runId: string;
|
|
12
|
+
readonly status: string;
|
|
13
|
+
readonly title: string;
|
|
14
|
+
readonly taskId?: string;
|
|
15
|
+
readonly updatedAt?: string;
|
|
16
|
+
};
|
|
17
|
+
export type AppInspectSnapshot = {
|
|
18
|
+
readonly runId: string;
|
|
19
|
+
readonly taskId?: string;
|
|
20
|
+
readonly status: string;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly logs: readonly Record<string, unknown>[];
|
|
23
|
+
readonly timeline: readonly Record<string, unknown>[];
|
|
24
|
+
/** Unified diff text for the run's working changes (git diff), or "". */
|
|
25
|
+
readonly diff: string;
|
|
26
|
+
/** Log/timeline entries whose status reads as a failure, for the failures tab. */
|
|
27
|
+
readonly failures: readonly Record<string, unknown>[];
|
|
28
|
+
/** Artifact files for the run's task (resolveTaskArtifactDirs), for the artifacts tab. */
|
|
29
|
+
readonly artifacts: readonly AppInspectArtifact[];
|
|
30
|
+
/** Contents of the currently-selected artifact file, for the artifact tab. */
|
|
31
|
+
readonly artifactView?: {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly contents: string;
|
|
34
|
+
readonly truncated: boolean;
|
|
35
|
+
readonly sizeBytes: number;
|
|
36
|
+
};
|
|
37
|
+
/** Task graph (`br list --pretty`) text, for the graph tab. */
|
|
38
|
+
readonly graph: string;
|
|
39
|
+
readonly graphError?: string;
|
|
40
|
+
/** Last audit.jsonl entries, for the audit tab. */
|
|
41
|
+
readonly audit: readonly Record<string, unknown>[];
|
|
42
|
+
readonly refreshedAt: number;
|
|
43
|
+
readonly diffError?: string;
|
|
44
|
+
readonly artifactsError?: string;
|
|
45
|
+
};
|
|
46
|
+
/** The run PICKER data: recent runs the operator can pick to inspect in-place,
|
|
47
|
+
* patched into state.data.inspectRuns. Sourced from the same server run list the
|
|
48
|
+
* runs scene uses — but rendered as inspect targets, never bouncing scenes. */
|
|
49
|
+
export declare function loadInspectRuns(ctx: AppAdapterContext, options?: {
|
|
50
|
+
readonly limit?: number;
|
|
51
|
+
}): Promise<readonly AppInspectRunOption[]>;
|
|
52
|
+
export declare function loadInspect(ctx: AppAdapterContext, runId: string): Promise<AppInspectSnapshot>;
|