@h-rig/cli 0.0.6-alpha.28 → 0.0.6-alpha.281
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 -28
- package/package.json +11 -28
- package/dist/bin/build-rig-binaries.js +0 -107
- package/dist/bin/rig.js +0 -11739
- package/dist/src/commands/_authority-runs.js +0 -111
- package/dist/src/commands/_cli-format.js +0 -369
- package/dist/src/commands/_connection-state.js +0 -123
- package/dist/src/commands/_doctor-checks.js +0 -507
- package/dist/src/commands/_help-catalog.js +0 -364
- package/dist/src/commands/_operator-surface.js +0 -204
- package/dist/src/commands/_operator-view.js +0 -1147
- package/dist/src/commands/_parsers.js +0 -107
- package/dist/src/commands/_paths.js +0 -50
- package/dist/src/commands/_pi-frontend.js +0 -843
- package/dist/src/commands/_pi-install.js +0 -185
- package/dist/src/commands/_pi-worker-bridge-extension.js +0 -761
- package/dist/src/commands/_policy.js +0 -79
- package/dist/src/commands/_preflight.js +0 -403
- package/dist/src/commands/_probes.js +0 -13
- package/dist/src/commands/_run-driver-helpers.js +0 -289
- package/dist/src/commands/_server-client.js +0 -514
- package/dist/src/commands/_snapshot-upload.js +0 -318
- package/dist/src/commands/_task-picker.js +0 -76
- package/dist/src/commands/agent.js +0 -499
- package/dist/src/commands/browser.js +0 -890
- package/dist/src/commands/connect.js +0 -289
- package/dist/src/commands/dist.js +0 -402
- package/dist/src/commands/doctor.js +0 -517
- package/dist/src/commands/github.js +0 -281
- package/dist/src/commands/inbox.js +0 -482
- package/dist/src/commands/init.js +0 -1563
- package/dist/src/commands/inspect.js +0 -174
- package/dist/src/commands/inspector.js +0 -256
- package/dist/src/commands/plugin.js +0 -167
- package/dist/src/commands/profile-and-review.js +0 -178
- package/dist/src/commands/queue.js +0 -198
- package/dist/src/commands/remote.js +0 -507
- package/dist/src/commands/repo-git-harness.js +0 -221
- package/dist/src/commands/run.js +0 -1808
- package/dist/src/commands/server.js +0 -572
- package/dist/src/commands/setup.js +0 -687
- package/dist/src/commands/task-report-bug.js +0 -1083
- package/dist/src/commands/task-run-driver.js +0 -2600
- package/dist/src/commands/task.js +0 -2606
- package/dist/src/commands/test.js +0 -39
- package/dist/src/commands/workspace.js +0 -123
- package/dist/src/commands.js +0 -11418
- package/dist/src/index.js +0 -11757
- package/dist/src/launcher.js +0 -133
- package/dist/src/report-bug.js +0 -260
- package/dist/src/runner.js +0 -273
- package/dist/src/withMutedConsole.js +0 -42
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/commands/_snapshot-upload.ts
|
|
3
|
-
import { mkdir, readdir, readFile, writeFile } from "fs/promises";
|
|
4
|
-
import { dirname as dirname2, resolve as resolve3, relative, sep } from "path";
|
|
5
|
-
|
|
6
|
-
// packages/cli/src/commands/_server-client.ts
|
|
7
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
8
|
-
import { resolve as resolve2 } from "path";
|
|
9
|
-
|
|
10
|
-
// packages/cli/src/runner.ts
|
|
11
|
-
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
12
|
-
import { CliError } from "@rig/runtime/control-plane/errors";
|
|
13
|
-
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
14
|
-
import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
|
|
15
|
-
import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
|
|
16
|
-
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
17
|
-
import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
|
|
18
|
-
|
|
19
|
-
// packages/cli/src/commands/_server-client.ts
|
|
20
|
-
import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
|
|
21
|
-
|
|
22
|
-
// packages/cli/src/commands/_connection-state.ts
|
|
23
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
24
|
-
import { homedir } from "os";
|
|
25
|
-
import { dirname, resolve } from "path";
|
|
26
|
-
function resolveGlobalConnectionsPath(env = process.env) {
|
|
27
|
-
const explicit = env.RIG_CONNECTIONS_FILE?.trim();
|
|
28
|
-
if (explicit)
|
|
29
|
-
return resolve(explicit);
|
|
30
|
-
const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
|
|
31
|
-
if (stateDir)
|
|
32
|
-
return resolve(stateDir, "connections.json");
|
|
33
|
-
return resolve(homedir(), ".rig", "connections.json");
|
|
34
|
-
}
|
|
35
|
-
function resolveRepoConnectionPath(projectRoot) {
|
|
36
|
-
return resolve(projectRoot, ".rig", "state", "connection.json");
|
|
37
|
-
}
|
|
38
|
-
function readJsonFile(path) {
|
|
39
|
-
if (!existsSync(path))
|
|
40
|
-
return null;
|
|
41
|
-
try {
|
|
42
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
43
|
-
} catch (error) {
|
|
44
|
-
throw new CliError2(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function normalizeConnection(value) {
|
|
48
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
49
|
-
return null;
|
|
50
|
-
const record = value;
|
|
51
|
-
if (record.kind === "local")
|
|
52
|
-
return { kind: "local", mode: "auto" };
|
|
53
|
-
if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
|
|
54
|
-
const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
|
|
55
|
-
return { kind: "remote", baseUrl };
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
function readGlobalConnections(options = {}) {
|
|
60
|
-
const path = resolveGlobalConnectionsPath(options.env ?? process.env);
|
|
61
|
-
const payload = readJsonFile(path);
|
|
62
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
63
|
-
return { connections: {} };
|
|
64
|
-
}
|
|
65
|
-
const rawConnections = payload.connections;
|
|
66
|
-
const connections = {};
|
|
67
|
-
if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
|
|
68
|
-
for (const [alias, raw] of Object.entries(rawConnections)) {
|
|
69
|
-
const connection = normalizeConnection(raw);
|
|
70
|
-
if (connection)
|
|
71
|
-
connections[alias] = connection;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return { connections };
|
|
75
|
-
}
|
|
76
|
-
function readRepoConnection(projectRoot) {
|
|
77
|
-
const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
|
|
78
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
79
|
-
return null;
|
|
80
|
-
const record = payload;
|
|
81
|
-
const selected = typeof record.selected === "string" ? record.selected.trim() : "";
|
|
82
|
-
if (!selected)
|
|
83
|
-
return null;
|
|
84
|
-
return {
|
|
85
|
-
selected,
|
|
86
|
-
project: typeof record.project === "string" ? record.project : undefined,
|
|
87
|
-
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
91
|
-
const repo = readRepoConnection(projectRoot);
|
|
92
|
-
if (!repo)
|
|
93
|
-
return null;
|
|
94
|
-
if (repo.selected === "local")
|
|
95
|
-
return { alias: "local", connection: { kind: "local", mode: "auto" } };
|
|
96
|
-
const global = readGlobalConnections(options);
|
|
97
|
-
const connection = global.connections[repo.selected];
|
|
98
|
-
if (!connection) {
|
|
99
|
-
throw new CliError2(`Selected Rig server "${repo.selected}" was not found. Run \`rig server list\` or \`rig server use local\`.`, 1);
|
|
100
|
-
}
|
|
101
|
-
return { alias: repo.selected, connection };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// packages/cli/src/commands/_server-client.ts
|
|
105
|
-
var scopedGitHubBearerTokens = new Map;
|
|
106
|
-
function cleanToken(value) {
|
|
107
|
-
const trimmed = value?.trim();
|
|
108
|
-
return trimmed ? trimmed : null;
|
|
109
|
-
}
|
|
110
|
-
function readPrivateRemoteSessionToken(projectRoot) {
|
|
111
|
-
const path = resolve2(projectRoot, ".rig", "state", "github-auth.json");
|
|
112
|
-
if (!existsSync2(path))
|
|
113
|
-
return null;
|
|
114
|
-
try {
|
|
115
|
-
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
116
|
-
return cleanToken(typeof parsed.apiSessionToken === "string" ? parsed.apiSessionToken : typeof parsed.sessionToken === "string" ? parsed.sessionToken : undefined);
|
|
117
|
-
} catch {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function readGitHubBearerTokenForRemote(projectRoot) {
|
|
122
|
-
const scopedKey = resolve2(projectRoot);
|
|
123
|
-
if (scopedGitHubBearerTokens.has(scopedKey))
|
|
124
|
-
return scopedGitHubBearerTokens.get(scopedKey) ?? null;
|
|
125
|
-
const privateSession = readPrivateRemoteSessionToken(projectRoot);
|
|
126
|
-
if (privateSession)
|
|
127
|
-
return privateSession;
|
|
128
|
-
return cleanToken(process.env.RIG_SERVER_AUTH_TOKEN) ?? cleanToken(process.env.RIG_REMOTE_AUTH_TOKEN);
|
|
129
|
-
}
|
|
130
|
-
async function ensureServerForCli(projectRoot) {
|
|
131
|
-
try {
|
|
132
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
133
|
-
if (selected?.connection.kind === "remote") {
|
|
134
|
-
return {
|
|
135
|
-
baseUrl: selected.connection.baseUrl,
|
|
136
|
-
authToken: readGitHubBearerTokenForRemote(projectRoot),
|
|
137
|
-
connectionKind: "remote"
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
const connection = await ensureLocalRigServerConnection(projectRoot);
|
|
141
|
-
return {
|
|
142
|
-
baseUrl: connection.baseUrl,
|
|
143
|
-
authToken: connection.authToken,
|
|
144
|
-
connectionKind: "local"
|
|
145
|
-
};
|
|
146
|
-
} catch (error) {
|
|
147
|
-
if (error instanceof Error) {
|
|
148
|
-
throw new CliError2(error.message, 1);
|
|
149
|
-
}
|
|
150
|
-
throw error;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function mergeHeaders(headers, authToken) {
|
|
154
|
-
const merged = new Headers(headers);
|
|
155
|
-
if (authToken) {
|
|
156
|
-
merged.set("authorization", `Bearer ${authToken}`);
|
|
157
|
-
}
|
|
158
|
-
return merged;
|
|
159
|
-
}
|
|
160
|
-
function diagnosticMessage(payload) {
|
|
161
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
162
|
-
return null;
|
|
163
|
-
const record = payload;
|
|
164
|
-
const diagnostics = Array.isArray(record.diagnostics) ? record.diagnostics : [];
|
|
165
|
-
const messages = diagnostics.flatMap((entry) => {
|
|
166
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
167
|
-
return [];
|
|
168
|
-
const diagnostic = entry;
|
|
169
|
-
const kind = typeof diagnostic.kind === "string" ? diagnostic.kind : "task-source";
|
|
170
|
-
const message = typeof diagnostic.message === "string" ? diagnostic.message : null;
|
|
171
|
-
return message ? [`${kind}: ${message}`] : [];
|
|
172
|
-
});
|
|
173
|
-
return messages.length > 0 ? messages.join("; ") : null;
|
|
174
|
-
}
|
|
175
|
-
async function requestServerJson(context, pathname, init = {}) {
|
|
176
|
-
const server = await ensureServerForCli(context.projectRoot);
|
|
177
|
-
const response = await fetch(`${server.baseUrl}${pathname}`, {
|
|
178
|
-
...init,
|
|
179
|
-
headers: mergeHeaders(init.headers, server.authToken)
|
|
180
|
-
});
|
|
181
|
-
const text = await response.text();
|
|
182
|
-
const payload = text.trim().length > 0 ? (() => {
|
|
183
|
-
try {
|
|
184
|
-
return JSON.parse(text);
|
|
185
|
-
} catch {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
})() : null;
|
|
189
|
-
if (!response.ok) {
|
|
190
|
-
const diagnostics = diagnosticMessage(payload);
|
|
191
|
-
const detail = diagnostics ?? (text || response.statusText);
|
|
192
|
-
throw new CliError2(`Rig server request failed (${response.status}): ${detail}`, 1);
|
|
193
|
-
}
|
|
194
|
-
return payload;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// packages/cli/src/commands/_snapshot-upload.ts
|
|
198
|
-
var UPLOADED_SNAPSHOT_PR_MARKER = "<!-- rig:uploaded-snapshot -->";
|
|
199
|
-
var SNAPSHOT_ARCHIVE_VERSION = 1;
|
|
200
|
-
var SNAPSHOT_ARCHIVE_CONTENT_TYPE = "application/vnd.rig.snapshot+json";
|
|
201
|
-
var DEFAULT_EXCLUDED_DIRECTORIES = new Set([
|
|
202
|
-
".git",
|
|
203
|
-
".rig",
|
|
204
|
-
"node_modules",
|
|
205
|
-
".turbo",
|
|
206
|
-
".next",
|
|
207
|
-
".cache",
|
|
208
|
-
"coverage",
|
|
209
|
-
"dist",
|
|
210
|
-
"build",
|
|
211
|
-
"out"
|
|
212
|
-
]);
|
|
213
|
-
function toPosixPath(path) {
|
|
214
|
-
return path.split(sep).join("/");
|
|
215
|
-
}
|
|
216
|
-
function assertManifestPath(root, relativePath) {
|
|
217
|
-
if (!relativePath || relativePath.startsWith("/") || relativePath.includes("\x00")) {
|
|
218
|
-
throw new Error(`Invalid snapshot path: ${relativePath}`);
|
|
219
|
-
}
|
|
220
|
-
const resolved = resolve3(root, relativePath);
|
|
221
|
-
const relativeToRoot = relative(root, resolved);
|
|
222
|
-
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || resolve3(relativeToRoot) === resolved) {
|
|
223
|
-
throw new Error(`Snapshot path escapes project root: ${relativePath}`);
|
|
224
|
-
}
|
|
225
|
-
return resolved;
|
|
226
|
-
}
|
|
227
|
-
async function buildSnapshotUploadManifest(projectRoot, options = {}) {
|
|
228
|
-
const root = resolve3(projectRoot);
|
|
229
|
-
const excludedDirectories = [...new Set([
|
|
230
|
-
...DEFAULT_EXCLUDED_DIRECTORIES,
|
|
231
|
-
...options.excludedDirectories ?? []
|
|
232
|
-
])];
|
|
233
|
-
const excludedSet = new Set(excludedDirectories);
|
|
234
|
-
const files = [];
|
|
235
|
-
async function visit(dir) {
|
|
236
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
237
|
-
for (const entry of entries) {
|
|
238
|
-
if (entry.isDirectory() && excludedSet.has(entry.name))
|
|
239
|
-
continue;
|
|
240
|
-
const fullPath = resolve3(dir, entry.name);
|
|
241
|
-
if (entry.isDirectory()) {
|
|
242
|
-
await visit(fullPath);
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
if (!entry.isFile())
|
|
246
|
-
continue;
|
|
247
|
-
files.push(toPosixPath(relative(root, fullPath)));
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
await visit(root);
|
|
251
|
-
files.sort();
|
|
252
|
-
return { root, files, excludedDirectories };
|
|
253
|
-
}
|
|
254
|
-
async function createSnapshotUploadArchive(projectRoot, options = {}) {
|
|
255
|
-
const manifest = await buildSnapshotUploadManifest(projectRoot, options);
|
|
256
|
-
const files = await Promise.all(manifest.files.map(async (path) => {
|
|
257
|
-
const fullPath = assertManifestPath(manifest.root, path);
|
|
258
|
-
return {
|
|
259
|
-
path,
|
|
260
|
-
contentBase64: (await readFile(fullPath)).toString("base64")
|
|
261
|
-
};
|
|
262
|
-
}));
|
|
263
|
-
return {
|
|
264
|
-
version: SNAPSHOT_ARCHIVE_VERSION,
|
|
265
|
-
root: manifest.root,
|
|
266
|
-
files,
|
|
267
|
-
excludedDirectories: manifest.excludedDirectories,
|
|
268
|
-
createdAt: (options.now?.() ?? new Date).toISOString()
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
function encodeSnapshotUploadArchive(archive) {
|
|
272
|
-
return Buffer.from(JSON.stringify(archive), "utf8").toString("base64");
|
|
273
|
-
}
|
|
274
|
-
async function writeSnapshotUploadArchive(projectRoot, outputPath, options = {}) {
|
|
275
|
-
const archive = await createSnapshotUploadArchive(projectRoot, options);
|
|
276
|
-
const target = resolve3(outputPath);
|
|
277
|
-
await mkdir(dirname2(target), { recursive: true });
|
|
278
|
-
await writeFile(target, JSON.stringify(archive, null, 2), "utf8");
|
|
279
|
-
return archive;
|
|
280
|
-
}
|
|
281
|
-
async function uploadSnapshotArchiveViaServer(context, input) {
|
|
282
|
-
const payload = await requestServerJson(context, `/api/projects/${encodeURIComponent(input.repoSlug)}/upload-snapshot`, {
|
|
283
|
-
method: "POST",
|
|
284
|
-
headers: { "content-type": "application/json" },
|
|
285
|
-
body: JSON.stringify({
|
|
286
|
-
archiveContentBase64: encodeSnapshotUploadArchive(input.archive),
|
|
287
|
-
contentType: SNAPSHOT_ARCHIVE_CONTENT_TYPE,
|
|
288
|
-
baseDir: input.baseDir
|
|
289
|
-
})
|
|
290
|
-
});
|
|
291
|
-
return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
292
|
-
}
|
|
293
|
-
function appendUploadedSnapshotPrNotice(body) {
|
|
294
|
-
if (body.includes(UPLOADED_SNAPSHOT_PR_MARKER))
|
|
295
|
-
return body;
|
|
296
|
-
const prefix = body.trimEnd();
|
|
297
|
-
const notice = [
|
|
298
|
-
UPLOADED_SNAPSHOT_PR_MARKER,
|
|
299
|
-
"This PR was seeded from an uploaded local working-tree snapshot. Review local snapshot provenance before merging if repository policy requires it."
|
|
300
|
-
].join(`
|
|
301
|
-
`);
|
|
302
|
-
return prefix.length > 0 ? `${prefix}
|
|
303
|
-
|
|
304
|
-
${notice}
|
|
305
|
-
` : `${notice}
|
|
306
|
-
`;
|
|
307
|
-
}
|
|
308
|
-
export {
|
|
309
|
-
writeSnapshotUploadArchive,
|
|
310
|
-
uploadSnapshotArchiveViaServer,
|
|
311
|
-
encodeSnapshotUploadArchive,
|
|
312
|
-
createSnapshotUploadArchive,
|
|
313
|
-
buildSnapshotUploadManifest,
|
|
314
|
-
appendUploadedSnapshotPrNotice,
|
|
315
|
-
UPLOADED_SNAPSHOT_PR_MARKER,
|
|
316
|
-
SNAPSHOT_ARCHIVE_VERSION,
|
|
317
|
-
SNAPSHOT_ARCHIVE_CONTENT_TYPE
|
|
318
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/commands/_task-picker.ts
|
|
3
|
-
import { cancel, isCancel, select } from "@clack/prompts";
|
|
4
|
-
|
|
5
|
-
// packages/cli/src/commands/_operator-surface.ts
|
|
6
|
-
import { createInterface as createPromptInterface } from "readline/promises";
|
|
7
|
-
function taskId(task) {
|
|
8
|
-
return typeof task.id === "string" && task.id.trim() ? task.id : "<unknown>";
|
|
9
|
-
}
|
|
10
|
-
function taskTitle(task) {
|
|
11
|
-
return typeof task.title === "string" && task.title.trim() ? task.title : "Untitled task";
|
|
12
|
-
}
|
|
13
|
-
function taskStatus(task) {
|
|
14
|
-
return typeof task.status === "string" && task.status.trim() ? task.status : "unknown";
|
|
15
|
-
}
|
|
16
|
-
function renderTaskPickerRows(tasks) {
|
|
17
|
-
return tasks.map((task, index) => `${index + 1}. ${taskId(task)} \xB7 ${taskStatus(task)} \xB7 ${taskTitle(task)}`);
|
|
18
|
-
}
|
|
19
|
-
async function promptForTaskSelection(question) {
|
|
20
|
-
const rl = createPromptInterface({ input: process.stdin, output: process.stdout });
|
|
21
|
-
try {
|
|
22
|
-
return await rl.question(question);
|
|
23
|
-
} finally {
|
|
24
|
-
rl.close();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// packages/cli/src/commands/_task-picker.ts
|
|
29
|
-
function taskId2(task) {
|
|
30
|
-
return typeof task.id === "string" && task.id.trim() ? task.id : "<unknown>";
|
|
31
|
-
}
|
|
32
|
-
async function selectTaskWithTextPicker(tasks, io = {}) {
|
|
33
|
-
if (tasks.length === 0)
|
|
34
|
-
return null;
|
|
35
|
-
if (tasks.length === 1)
|
|
36
|
-
return tasks[0];
|
|
37
|
-
const isTty = io.isTty ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
38
|
-
if (!isTty) {
|
|
39
|
-
throw new Error("task run requires an interactive terminal to pick a task; pass --task <id>, --next, or --detach with a task id.");
|
|
40
|
-
}
|
|
41
|
-
if (io.prompt || io.renderer) {
|
|
42
|
-
const prompt = io.prompt ?? promptForTaskSelection;
|
|
43
|
-
const renderer = io.renderer ?? { writeLine: (line) => process.stdout.write(`${line}
|
|
44
|
-
`) };
|
|
45
|
-
renderer.writeLine("Select Rig task:");
|
|
46
|
-
for (const row of renderTaskPickerRows(tasks))
|
|
47
|
-
renderer.writeLine(` ${row}`);
|
|
48
|
-
const answer2 = (await prompt(`Task [1-${tasks.length}] or id: `)).trim();
|
|
49
|
-
if (!answer2)
|
|
50
|
-
return null;
|
|
51
|
-
if (/^\d+$/.test(answer2)) {
|
|
52
|
-
const index2 = Number.parseInt(answer2, 10) - 1;
|
|
53
|
-
return tasks[index2] ?? null;
|
|
54
|
-
}
|
|
55
|
-
return tasks.find((task) => taskId2(task) === answer2) ?? null;
|
|
56
|
-
}
|
|
57
|
-
const options = tasks.map((task, index2) => ({
|
|
58
|
-
value: `${index2}`,
|
|
59
|
-
label: `${taskId2(task)} \xB7 ${typeof task.title === "string" && task.title.trim() ? task.title.trim() : "Untitled task"}`,
|
|
60
|
-
hint: typeof task.status === "string" && task.status.trim() ? task.status.trim() : undefined
|
|
61
|
-
}));
|
|
62
|
-
const answer = await select({
|
|
63
|
-
message: "Select Rig task",
|
|
64
|
-
options
|
|
65
|
-
});
|
|
66
|
-
if (isCancel(answer)) {
|
|
67
|
-
cancel("No task selected.");
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
const index = Number.parseInt(String(answer), 10);
|
|
71
|
-
return Number.isFinite(index) ? tasks[index] ?? null : null;
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
selectTaskWithTextPicker,
|
|
75
|
-
renderTaskPickerRows
|
|
76
|
-
};
|