@h-rig/cli 0.0.6-alpha.94 → 0.0.6-alpha.95
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 +6 -27
- package/bin/rig.js +16 -0
- package/package.json +14 -40
- package/dist/bin/build-rig-binaries.d.ts +0 -2
- package/dist/bin/build-rig-binaries.js +0 -119
- package/dist/bin/rig.d.ts +0 -72
- package/dist/bin/rig.js +0 -17855
- package/dist/config/rig-default-config.yml +0 -5
- package/dist/src/app/drone-ui.d.ts +0 -34
- package/dist/src/app/drone-ui.js +0 -278
- package/dist/src/commands/_async-ui.d.ts +0 -10
- package/dist/src/commands/_async-ui.js +0 -121
- package/dist/src/commands/_cli-format.d.ts +0 -56
- package/dist/src/commands/_cli-format.js +0 -319
- package/dist/src/commands/_connection-state.d.ts +0 -54
- package/dist/src/commands/_connection-state.js +0 -187
- package/dist/src/commands/_doctor-checks.d.ts +0 -46
- package/dist/src/commands/_doctor-checks.js +0 -352
- package/dist/src/commands/_help-catalog.d.ts +0 -51
- package/dist/src/commands/_help-catalog.js +0 -502
- package/dist/src/commands/_inprocess-services.d.ts +0 -33
- package/dist/src/commands/_inprocess-services.js +0 -102
- package/dist/src/commands/_json-output.d.ts +0 -11
- package/dist/src/commands/_json-output.js +0 -60
- package/dist/src/commands/_lazy-reconcile.d.ts +0 -34
- package/dist/src/commands/_lazy-reconcile.js +0 -102
- package/dist/src/commands/_parsers.d.ts +0 -15
- package/dist/src/commands/_parsers.js +0 -114
- package/dist/src/commands/_paths.d.ts +0 -11
- package/dist/src/commands/_paths.js +0 -50
- package/dist/src/commands/_pi-frontend.d.ts +0 -35
- package/dist/src/commands/_pi-frontend.js +0 -64
- package/dist/src/commands/_pi-install.d.ts +0 -42
- package/dist/src/commands/_pi-install.js +0 -167
- package/dist/src/commands/_policy.d.ts +0 -8
- package/dist/src/commands/_policy.js +0 -127
- package/dist/src/commands/_probes.d.ts +0 -1
- package/dist/src/commands/_probes.js +0 -13
- package/dist/src/commands/_run-bridge.d.ts +0 -114
- package/dist/src/commands/_run-bridge.js +0 -387
- package/dist/src/commands/_run-diagnostics.d.ts +0 -9
- package/dist/src/commands/_run-diagnostics.js +0 -51
- package/dist/src/commands/_run-driver-helpers.d.ts +0 -26
- package/dist/src/commands/_run-driver-helpers.js +0 -138
- package/dist/src/commands/_run-projection.d.ts +0 -50
- package/dist/src/commands/_run-projection.js +0 -349
- package/dist/src/commands/_run-subcommands.d.ts +0 -3
- package/dist/src/commands/_run-subcommands.js +0 -31
- package/dist/src/commands/_spinner.d.ts +0 -25
- package/dist/src/commands/_spinner.js +0 -65
- package/dist/src/commands/agent.d.ts +0 -3
- package/dist/src/commands/agent.js +0 -8837
- package/dist/src/commands/dist.d.ts +0 -28
- package/dist/src/commands/dist.js +0 -417
- package/dist/src/commands/doctor.d.ts +0 -3
- package/dist/src/commands/doctor.js +0 -480
- package/dist/src/commands/github.d.ts +0 -3
- package/dist/src/commands/github.js +0 -342
- package/dist/src/commands/inbox.d.ts +0 -28
- package/dist/src/commands/inbox.js +0 -579
- package/dist/src/commands/init.d.ts +0 -64
- package/dist/src/commands/init.js +0 -1541
- package/dist/src/commands/inspect.d.ts +0 -20
- package/dist/src/commands/inspect.js +0 -764
- package/dist/src/commands/pi.d.ts +0 -3
- package/dist/src/commands/pi.js +0 -177
- package/dist/src/commands/plugin.d.ts +0 -16
- package/dist/src/commands/plugin.js +0 -714
- package/dist/src/commands/profile-and-review.d.ts +0 -4
- package/dist/src/commands/profile-and-review.js +0 -223
- package/dist/src/commands/queue.d.ts +0 -3
- package/dist/src/commands/queue.js +0 -197
- package/dist/src/commands/remote.d.ts +0 -3
- package/dist/src/commands/remote.js +0 -1337
- package/dist/src/commands/repo-git-harness.d.ts +0 -5
- package/dist/src/commands/repo-git-harness.js +0 -271
- package/dist/src/commands/run.d.ts +0 -21
- package/dist/src/commands/run.js +0 -17847
- package/dist/src/commands/server.d.ts +0 -3
- package/dist/src/commands/server.js +0 -249
- package/dist/src/commands/setup.d.ts +0 -16
- package/dist/src/commands/setup.js +0 -644
- package/dist/src/commands/stats.d.ts +0 -15
- package/dist/src/commands/stats.js +0 -979
- package/dist/src/commands/task-run-driver.d.ts +0 -94
- package/dist/src/commands/task-run-driver.js +0 -203
- package/dist/src/commands/task.d.ts +0 -35
- package/dist/src/commands/task.js +0 -818
- package/dist/src/commands/test.d.ts +0 -3
- package/dist/src/commands/test.js +0 -46
- package/dist/src/commands/triage.d.ts +0 -11
- package/dist/src/commands/triage.js +0 -227
- package/dist/src/commands/workspace.d.ts +0 -3
- package/dist/src/commands/workspace.js +0 -130
- package/dist/src/commands.d.ts +0 -13
- package/dist/src/commands.js +0 -17979
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -17991
- package/dist/src/launcher.d.ts +0 -61
- package/dist/src/launcher.js +0 -199
- package/dist/src/operator-cli.d.ts +0 -2
- package/dist/src/operator-cli.js +0 -17847
- package/dist/src/operator-entry.d.ts +0 -1
- package/dist/src/operator-entry.js +0 -3
- package/dist/src/runner.d.ts +0 -47
- package/dist/src/runner.js +0 -267
- package/dist/src/withMutedConsole.d.ts +0 -2
- package/dist/src/withMutedConsole.js +0 -42
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/commands/github.ts
|
|
3
|
-
import { spawnSync } from "child_process";
|
|
4
|
-
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
5
|
-
import { dirname as dirname2, resolve as resolve3 } from "path";
|
|
6
|
-
|
|
7
|
-
// packages/cli/src/runner.ts
|
|
8
|
-
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
9
|
-
import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
|
|
10
|
-
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
11
|
-
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
12
|
-
|
|
13
|
-
class CliError extends RuntimeCliError {
|
|
14
|
-
hint;
|
|
15
|
-
constructor(message, exitCode = 1, options = {}) {
|
|
16
|
-
super(message, exitCode);
|
|
17
|
-
if (options.hint?.trim()) {
|
|
18
|
-
this.hint = options.hint.trim();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function takeOption(args, option) {
|
|
23
|
-
const rest = [];
|
|
24
|
-
let value;
|
|
25
|
-
for (let index = 0;index < args.length; index += 1) {
|
|
26
|
-
const current = args[index];
|
|
27
|
-
if (current === option) {
|
|
28
|
-
const next = args[index + 1];
|
|
29
|
-
if (!next || next.startsWith("-")) {
|
|
30
|
-
throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
|
|
31
|
-
}
|
|
32
|
-
value = next;
|
|
33
|
-
index += 1;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (current !== undefined) {
|
|
37
|
-
rest.push(current);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return { value, rest };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// packages/cli/src/commands/_inprocess-services.ts
|
|
44
|
-
import { resolve } from "path";
|
|
45
|
-
import {
|
|
46
|
-
beginGitHubDeviceFlow,
|
|
47
|
-
checkGitHubRepoPermissions,
|
|
48
|
-
createGitHubAuthStore,
|
|
49
|
-
listGitHubProjects,
|
|
50
|
-
pollGitHubDeviceFlow,
|
|
51
|
-
resolveGitHubAuthStatus,
|
|
52
|
-
resolveProjectStatusField,
|
|
53
|
-
saveGitHubTokenForProject
|
|
54
|
-
} from "@rig/runtime/control-plane/github/index";
|
|
55
|
-
var scopedGitHubBearerTokens = new Map;
|
|
56
|
-
function cleanToken(value) {
|
|
57
|
-
const trimmed = value?.trim();
|
|
58
|
-
return trimmed ? trimmed : null;
|
|
59
|
-
}
|
|
60
|
-
function oauthClientId() {
|
|
61
|
-
return cleanToken(process.env.RIG_GITHUB_OAUTH_CLIENT_ID);
|
|
62
|
-
}
|
|
63
|
-
function setGitHubBearerTokenForCurrentProcess(token, projectRoot) {
|
|
64
|
-
scopedGitHubBearerTokens.set(resolve(projectRoot ?? process.cwd()), cleanToken(token));
|
|
65
|
-
}
|
|
66
|
-
async function getGitHubAuthStatusInProcess(context) {
|
|
67
|
-
return { ok: true, ...resolveGitHubAuthStatus({ projectRoot: context.projectRoot, oauthConfigured: Boolean(oauthClientId()) }) };
|
|
68
|
-
}
|
|
69
|
-
async function postGitHubTokenInProcess(context, token, options = {}) {
|
|
70
|
-
const targetRoot = options.projectRoot?.trim() || context.projectRoot;
|
|
71
|
-
const result = await saveGitHubTokenForProject({
|
|
72
|
-
projectRoot: targetRoot,
|
|
73
|
-
token,
|
|
74
|
-
tokenSource: "manual-token",
|
|
75
|
-
selectedRepo: options.selectedRepo ?? null
|
|
76
|
-
});
|
|
77
|
-
const store = createGitHubAuthStore(targetRoot);
|
|
78
|
-
const session = store.createApiSession();
|
|
79
|
-
if (targetRoot !== context.projectRoot) {
|
|
80
|
-
store.copyToLocalProjectRoot(context.projectRoot);
|
|
81
|
-
}
|
|
82
|
-
return { ...result, authenticated: result.signedIn, apiSessionToken: session.token };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// packages/cli/src/commands/_connection-state.ts
|
|
86
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
87
|
-
import { dirname, resolve as resolve2 } from "path";
|
|
88
|
-
function resolveRepoConnectionPath(projectRoot) {
|
|
89
|
-
return resolve2(projectRoot, ".rig", "state", "connection.json");
|
|
90
|
-
}
|
|
91
|
-
function readJsonFile(path) {
|
|
92
|
-
if (!existsSync(path))
|
|
93
|
-
return null;
|
|
94
|
-
try {
|
|
95
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
96
|
-
} catch (error) {
|
|
97
|
-
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>`." });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function readRepoConnection(projectRoot) {
|
|
101
|
-
const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
|
|
102
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
103
|
-
return null;
|
|
104
|
-
const record = payload;
|
|
105
|
-
const selected = typeof record.selected === "string" ? record.selected.trim() : "";
|
|
106
|
-
if (!selected)
|
|
107
|
-
return null;
|
|
108
|
-
return {
|
|
109
|
-
selected,
|
|
110
|
-
project: typeof record.project === "string" ? record.project : undefined,
|
|
111
|
-
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
|
|
112
|
-
serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined,
|
|
113
|
-
serverProjectRootAlias: typeof record.serverProjectRootAlias === "string" && record.serverProjectRootAlias.trim() ? record.serverProjectRootAlias.trim() : undefined,
|
|
114
|
-
serverProjectRootBaseUrl: typeof record.serverProjectRootBaseUrl === "string" && record.serverProjectRootBaseUrl.trim() ? record.serverProjectRootBaseUrl.trim().replace(/\/+$/, "") : undefined
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// packages/cli/src/commands/_async-ui.ts
|
|
119
|
-
import pc from "picocolors";
|
|
120
|
-
|
|
121
|
-
// packages/cli/src/commands/_spinner.ts
|
|
122
|
-
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
123
|
-
function createTtySpinner(input) {
|
|
124
|
-
const output = input.output ?? process.stdout;
|
|
125
|
-
const isTty = output.isTTY === true;
|
|
126
|
-
const frames = input.frames && input.frames.length > 0 ? input.frames : SPINNER_FRAMES;
|
|
127
|
-
let label = input.label;
|
|
128
|
-
let frame = 0;
|
|
129
|
-
let paused = false;
|
|
130
|
-
let stopped = false;
|
|
131
|
-
let lastPrintedLabel = "";
|
|
132
|
-
const render = () => {
|
|
133
|
-
if (stopped || paused)
|
|
134
|
-
return;
|
|
135
|
-
if (!isTty) {
|
|
136
|
-
if (label !== lastPrintedLabel) {
|
|
137
|
-
output.write(`${label}
|
|
138
|
-
`);
|
|
139
|
-
lastPrintedLabel = label;
|
|
140
|
-
}
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
frame = (frame + 1) % frames.length;
|
|
144
|
-
const glyph = frames[frame] ?? frames[0] ?? "";
|
|
145
|
-
output.write(`\r\x1B[2K${input.styleFrame ? input.styleFrame(glyph) : glyph} ${label}`);
|
|
146
|
-
};
|
|
147
|
-
const clearLine = () => {
|
|
148
|
-
if (isTty)
|
|
149
|
-
output.write("\r\x1B[2K");
|
|
150
|
-
};
|
|
151
|
-
render();
|
|
152
|
-
const timer = isTty ? setInterval(render, input.intervalMs ?? 16) : null;
|
|
153
|
-
return {
|
|
154
|
-
setLabel(next) {
|
|
155
|
-
label = next;
|
|
156
|
-
render();
|
|
157
|
-
},
|
|
158
|
-
pause() {
|
|
159
|
-
paused = true;
|
|
160
|
-
clearLine();
|
|
161
|
-
},
|
|
162
|
-
resume() {
|
|
163
|
-
if (stopped)
|
|
164
|
-
return;
|
|
165
|
-
paused = false;
|
|
166
|
-
render();
|
|
167
|
-
},
|
|
168
|
-
stop(finalLine) {
|
|
169
|
-
if (stopped)
|
|
170
|
-
return;
|
|
171
|
-
stopped = true;
|
|
172
|
-
if (timer)
|
|
173
|
-
clearInterval(timer);
|
|
174
|
-
clearLine();
|
|
175
|
-
if (finalLine)
|
|
176
|
-
output.write(`${finalLine}
|
|
177
|
-
`);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// packages/cli/src/commands/_async-ui.ts
|
|
183
|
-
var FRAMES = ["\u25D0", "\u25D3", "\u25D1", "\u25D2"];
|
|
184
|
-
var DONE_SYMBOL = pc.green("\u25C7");
|
|
185
|
-
var FAIL_SYMBOL = pc.red("\u25A0");
|
|
186
|
-
var activeUpdate = null;
|
|
187
|
-
async function withSpinner(label, work, options = {}) {
|
|
188
|
-
if (options.outputMode === "json") {
|
|
189
|
-
return work(() => {
|
|
190
|
-
return;
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
if (activeUpdate) {
|
|
194
|
-
activeUpdate(label);
|
|
195
|
-
return work(activeUpdate);
|
|
196
|
-
}
|
|
197
|
-
const output = options.output ?? process.stderr;
|
|
198
|
-
const isTty = output.isTTY === true;
|
|
199
|
-
let lastLabel = label;
|
|
200
|
-
if (!isTty) {
|
|
201
|
-
output.write(`${label}
|
|
202
|
-
`);
|
|
203
|
-
const update2 = (next) => {
|
|
204
|
-
lastLabel = next;
|
|
205
|
-
};
|
|
206
|
-
activeUpdate = update2;
|
|
207
|
-
try {
|
|
208
|
-
return await work(update2);
|
|
209
|
-
} finally {
|
|
210
|
-
activeUpdate = null;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const spinner = createTtySpinner({
|
|
214
|
-
label,
|
|
215
|
-
output,
|
|
216
|
-
frames: FRAMES,
|
|
217
|
-
styleFrame: (frame) => pc.cyan(frame)
|
|
218
|
-
});
|
|
219
|
-
const update = (next) => {
|
|
220
|
-
lastLabel = next;
|
|
221
|
-
spinner.setLabel(next);
|
|
222
|
-
};
|
|
223
|
-
activeUpdate = update;
|
|
224
|
-
try {
|
|
225
|
-
const result = await work(update);
|
|
226
|
-
spinner.stop(options.doneLabel ? `${DONE_SYMBOL} ${options.doneLabel}` : undefined);
|
|
227
|
-
return result;
|
|
228
|
-
} catch (error) {
|
|
229
|
-
spinner.stop(`${FAIL_SYMBOL} ${lastLabel}`);
|
|
230
|
-
throw error;
|
|
231
|
-
} finally {
|
|
232
|
-
activeUpdate = null;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// packages/cli/src/commands/github.ts
|
|
237
|
-
function printPayload(context, payload, fallback) {
|
|
238
|
-
if (context.outputMode === "json")
|
|
239
|
-
console.log(JSON.stringify(payload, null, 2));
|
|
240
|
-
else
|
|
241
|
-
console.log(fallback);
|
|
242
|
-
}
|
|
243
|
-
function apiSessionTokenFrom(payload) {
|
|
244
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
245
|
-
return null;
|
|
246
|
-
return payloadString(payload, "apiSessionToken");
|
|
247
|
-
}
|
|
248
|
-
function payloadString(payload, key) {
|
|
249
|
-
const value = Reflect.get(payload, key);
|
|
250
|
-
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
251
|
-
}
|
|
252
|
-
function payloadRecord(payload, key) {
|
|
253
|
-
const value = Reflect.get(payload, key);
|
|
254
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
255
|
-
}
|
|
256
|
-
function remoteNamespaceMetadata(result) {
|
|
257
|
-
const namespace = payloadRecord(result, "userNamespace");
|
|
258
|
-
return {
|
|
259
|
-
...payloadString(result, "login") ? { login: payloadString(result, "login") } : {},
|
|
260
|
-
...payloadString(result, "userId") ? { userId: payloadString(result, "userId") } : {},
|
|
261
|
-
...namespace && payloadString(namespace, "key") ? { userNamespaceKey: payloadString(namespace, "key") } : {},
|
|
262
|
-
...namespace && payloadString(namespace, "root") ? { userNamespaceRoot: payloadString(namespace, "root") } : {},
|
|
263
|
-
...namespace && payloadString(namespace, "checkoutBaseDir") ? { checkoutBaseDir: payloadString(namespace, "checkoutBaseDir") } : {},
|
|
264
|
-
...namespace && payloadString(namespace, "snapshotBaseDir") ? { snapshotBaseDir: payloadString(namespace, "snapshotBaseDir") } : {}
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
function persistRemoteAuthSession(context, source, result, fallbackToken) {
|
|
268
|
-
const apiSessionToken = result.apiSessionToken || apiSessionTokenFrom(result);
|
|
269
|
-
setGitHubBearerTokenForCurrentProcess(apiSessionToken ?? fallbackToken, context.projectRoot);
|
|
270
|
-
if (!apiSessionToken)
|
|
271
|
-
return;
|
|
272
|
-
const repo = readRepoConnection(context.projectRoot);
|
|
273
|
-
const path = resolve3(context.projectRoot, ".rig", "state", "github-auth.json");
|
|
274
|
-
mkdirSync2(dirname2(path), { recursive: true });
|
|
275
|
-
writeFileSync2(path, `${JSON.stringify({
|
|
276
|
-
authenticated: true,
|
|
277
|
-
source,
|
|
278
|
-
storedOnServer: true,
|
|
279
|
-
...repo?.project ? { selectedRepo: repo.project } : {},
|
|
280
|
-
...remoteNamespaceMetadata(result),
|
|
281
|
-
apiSessionToken,
|
|
282
|
-
updatedAt: new Date().toISOString()
|
|
283
|
-
}, null, 2)}
|
|
284
|
-
`, "utf8");
|
|
285
|
-
}
|
|
286
|
-
function isSignedIn(status) {
|
|
287
|
-
return status.signedIn === true;
|
|
288
|
-
}
|
|
289
|
-
function readGhToken() {
|
|
290
|
-
const result = spawnSync("gh", ["auth", "token"], { encoding: "utf8" });
|
|
291
|
-
if (result.status !== 0) {
|
|
292
|
-
const detail = result.stderr?.trim() || result.stdout?.trim() || "gh auth token failed";
|
|
293
|
-
throw new CliError(`Could not import GitHub token from gh: ${detail}`, 1, { hint: "Sign in first with `gh auth login`, or store a token directly: `rig github auth token --token <token>`." });
|
|
294
|
-
}
|
|
295
|
-
const token = result.stdout.trim();
|
|
296
|
-
if (!token)
|
|
297
|
-
throw new CliError("gh auth token returned an empty token.", 1, { hint: "Sign in with `gh auth login`, then re-run `rig github auth import-gh`." });
|
|
298
|
-
return token;
|
|
299
|
-
}
|
|
300
|
-
async function executeGithub(context, args) {
|
|
301
|
-
const [group, command, ...rest] = args;
|
|
302
|
-
if (group !== "auth") {
|
|
303
|
-
throw new CliError("Usage: rig github auth <status|import-gh|token>", 1);
|
|
304
|
-
}
|
|
305
|
-
switch (command) {
|
|
306
|
-
case "status": {
|
|
307
|
-
if (rest.length > 0)
|
|
308
|
-
throw new CliError("Usage: rig github auth status", 1);
|
|
309
|
-
const status = await withSpinner("Checking GitHub auth on the server\u2026", () => getGitHubAuthStatusInProcess(context), { outputMode: context.outputMode });
|
|
310
|
-
printPayload(context, status, `GitHub auth: ${isSignedIn(status) ? "authenticated" : "unauthenticated"}`);
|
|
311
|
-
return { ok: true, group: "github", command: "auth status", details: status };
|
|
312
|
-
}
|
|
313
|
-
case "token": {
|
|
314
|
-
const parsed = takeOption(rest, "--token");
|
|
315
|
-
if (parsed.rest.length > 0)
|
|
316
|
-
throw new CliError("Usage: rig github auth token --token <token>", 1);
|
|
317
|
-
const token = parsed.value?.trim();
|
|
318
|
-
if (!token)
|
|
319
|
-
throw new CliError("Missing --token value.", 1, { hint: "Re-run as `rig github auth token --token <token>`." });
|
|
320
|
-
const repo = readRepoConnection(context.projectRoot);
|
|
321
|
-
const result = await withSpinner("Storing GitHub token on the server\u2026", () => postGitHubTokenInProcess(context, token, repo?.project ? { selectedRepo: repo.project } : {}), { outputMode: context.outputMode });
|
|
322
|
-
persistRemoteAuthSession(context, "token", result, token);
|
|
323
|
-
printPayload(context, result, "GitHub token stored on the selected server.");
|
|
324
|
-
return { ok: true, group: "github", command: "auth token", details: result };
|
|
325
|
-
}
|
|
326
|
-
case "import-gh": {
|
|
327
|
-
if (rest.length > 0)
|
|
328
|
-
throw new CliError("Usage: rig github auth import-gh", 1);
|
|
329
|
-
const importedToken = readGhToken();
|
|
330
|
-
const repo = readRepoConnection(context.projectRoot);
|
|
331
|
-
const result = await withSpinner("Storing GitHub token on the server\u2026", () => postGitHubTokenInProcess(context, importedToken, repo?.project ? { selectedRepo: repo.project } : {}), { outputMode: context.outputMode });
|
|
332
|
-
persistRemoteAuthSession(context, "gh", result, importedToken);
|
|
333
|
-
printPayload(context, result, "GitHub token imported from gh and stored on the selected server.");
|
|
334
|
-
return { ok: true, group: "github", command: "auth import-gh", details: result };
|
|
335
|
-
}
|
|
336
|
-
default:
|
|
337
|
-
throw new CliError("Usage: rig github auth <status|import-gh|token>", 1);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
export {
|
|
341
|
-
executeGithub
|
|
342
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type RunnerContext } from "../runner";
|
|
2
|
-
import type { CommandOutcome } from "@rig/runtime";
|
|
3
|
-
import { type RunProjectionRecord } from "./_run-projection";
|
|
4
|
-
export type InboxKind = "approvals" | "inputs";
|
|
5
|
-
export interface InboxFilters {
|
|
6
|
-
readonly run?: string;
|
|
7
|
-
readonly task?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface InboxRecord {
|
|
10
|
-
readonly runId: string;
|
|
11
|
-
readonly taskId: string | null;
|
|
12
|
-
readonly requestId: string;
|
|
13
|
-
readonly status: "pending";
|
|
14
|
-
readonly prompt: string;
|
|
15
|
-
readonly requestedAt: string;
|
|
16
|
-
readonly payload: unknown;
|
|
17
|
-
}
|
|
18
|
-
/** Every pending inbox request across discoverable runs, optionally filtered by run/task. */
|
|
19
|
-
export interface InboxDeps {
|
|
20
|
-
readonly listRuns?: (projectRoot: string) => Promise<RunProjectionRecord[]>;
|
|
21
|
-
}
|
|
22
|
-
export declare function listInboxRecords(context: Pick<RunnerContext, "projectRoot">, kind: InboxKind, filters?: InboxFilters, deps?: InboxDeps): Promise<InboxRecord[]>;
|
|
23
|
-
/** Pending-gate counts for proactive surfacing; null-safe for footer callers. */
|
|
24
|
-
export declare function readPendingInboxCounts(context: Pick<RunnerContext, "projectRoot">): Promise<{
|
|
25
|
-
approvals: number;
|
|
26
|
-
inputs: number;
|
|
27
|
-
} | null>;
|
|
28
|
-
export declare function executeInbox(context: RunnerContext, args: string[], deps?: InboxDeps): Promise<CommandOutcome>;
|