@h-rig/cli 0.0.6-alpha.28 → 0.0.6-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rig.js +421 -241
- package/dist/src/commands/_connection-state.js +0 -2
- package/dist/src/commands/_doctor-checks.js +0 -2
- package/dist/src/commands/_help-catalog.js +27 -3
- package/dist/src/commands/_operator-view.js +0 -2
- package/dist/src/commands/_parsers.js +0 -2
- package/dist/src/commands/_pi-frontend.js +0 -2
- package/dist/src/commands/_pi-worker-bridge-extension.js +0 -2
- package/dist/src/commands/_policy.js +0 -2
- package/dist/src/commands/_preflight.js +0 -2
- package/dist/src/commands/_run-driver-helpers.js +0 -2
- package/dist/src/commands/_server-client.js +0 -2
- package/dist/src/commands/_snapshot-upload.js +0 -2
- package/dist/src/commands/agent.js +0 -2
- package/dist/src/commands/browser.js +0 -2
- package/dist/src/commands/connect.js +0 -2
- package/dist/src/commands/dist.js +0 -2
- package/dist/src/commands/doctor.js +0 -2
- package/dist/src/commands/github.js +0 -2
- package/dist/src/commands/inbox.js +0 -2
- package/dist/src/commands/init.js +0 -2
- package/dist/src/commands/inspect.js +0 -2
- package/dist/src/commands/inspector.js +0 -2
- package/dist/src/commands/plugin.js +73 -19
- package/dist/src/commands/profile-and-review.js +0 -2
- package/dist/src/commands/queue.js +0 -2
- package/dist/src/commands/remote.js +0 -2
- package/dist/src/commands/repo-git-harness.js +2 -4
- package/dist/src/commands/run.js +2 -4
- package/dist/src/commands/server.js +0 -2
- package/dist/src/commands/setup.js +0 -8
- package/dist/src/commands/task-report-bug.js +0 -2
- package/dist/src/commands/task-run-driver.js +0 -2
- package/dist/src/commands/task.js +34 -7
- package/dist/src/commands/test.js +0 -2
- package/dist/src/commands/workspace.js +0 -2
- package/dist/src/commands.js +403 -214
- package/dist/src/index.js +415 -238
- package/dist/src/runner.js +2 -17
- package/package.json +6 -6
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
2
17
|
var __require = import.meta.require;
|
|
3
18
|
|
|
4
19
|
// packages/cli/src/runner.ts
|
|
@@ -8,8 +23,6 @@ import { resolve } from "path";
|
|
|
8
23
|
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
9
24
|
import { CliError } from "@rig/runtime/control-plane/errors";
|
|
10
25
|
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
11
|
-
import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
|
|
12
|
-
import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
|
|
13
26
|
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
14
27
|
import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
|
|
15
28
|
function withProjectRoot(projectRoot) {
|
|
@@ -18,7 +31,6 @@ function withProjectRoot(projectRoot) {
|
|
|
18
31
|
function formatCommand(parts) {
|
|
19
32
|
return parts.map((part) => /[^a-zA-Z0-9_./:-]/.test(part) ? JSON.stringify(part) : part).join(" ");
|
|
20
33
|
}
|
|
21
|
-
var AGENT_DISPATCH_SOURCE = "packages/runtime/bin/rig-agent-dispatch.ts";
|
|
22
34
|
function hasAgentDispatchSource(root) {
|
|
23
35
|
return existsSync(resolve(root, AGENT_DISPATCH_SOURCE));
|
|
24
36
|
}
|
|
@@ -63,13 +75,6 @@ async function ensureAgentShellBinary(projectRoot, options = {}) {
|
|
|
63
75
|
}
|
|
64
76
|
async function initializeRuntime(options) {
|
|
65
77
|
const eventBus = new EventBus({ projectRoot: options.projectRoot, runId: options.runId });
|
|
66
|
-
const runtimeContext = loadRuntimeContextFromEnv() ?? undefined;
|
|
67
|
-
const plugins = await PluginManager.load({
|
|
68
|
-
projectRoot: options.projectRoot,
|
|
69
|
-
runId: eventBus.getRunId(),
|
|
70
|
-
eventBus,
|
|
71
|
-
runtimeContext
|
|
72
|
-
});
|
|
73
78
|
const context = {
|
|
74
79
|
projectRoot: options.projectRoot,
|
|
75
80
|
dryRun: options.dryRun,
|
|
@@ -77,10 +82,8 @@ async function initializeRuntime(options) {
|
|
|
77
82
|
runId: eventBus.getRunId(),
|
|
78
83
|
policyMode: options.policyMode,
|
|
79
84
|
eventBus,
|
|
80
|
-
plugins,
|
|
81
85
|
emitEvent: async (type, payload) => {
|
|
82
|
-
|
|
83
|
-
await plugins.onEvent(event);
|
|
86
|
+
await eventBus.emit(type, payload);
|
|
84
87
|
}
|
|
85
88
|
};
|
|
86
89
|
context.runCommand = async (parts) => runCommand(context, parts);
|
|
@@ -89,8 +92,7 @@ async function initializeRuntime(options) {
|
|
|
89
92
|
outputMode: context.outputMode,
|
|
90
93
|
dryRun: context.dryRun,
|
|
91
94
|
policyMode: context.policyMode ?? loadPolicy(options.projectRoot).mode,
|
|
92
|
-
policyFile: resolve(options.projectRoot, "rig/policy/policy.json")
|
|
93
|
-
plugins: context.plugins.list()
|
|
95
|
+
policyFile: resolve(options.projectRoot, "rig/policy/policy.json")
|
|
94
96
|
});
|
|
95
97
|
return context;
|
|
96
98
|
}
|
|
@@ -141,7 +143,6 @@ async function runCommand(context, parts) {
|
|
|
141
143
|
});
|
|
142
144
|
throw new CliError(`Policy blocked command: ${formatted}`, 126);
|
|
143
145
|
}
|
|
144
|
-
await context.plugins.beforeCommand({ command: commandWithEnv, formattedCommand: formatted });
|
|
145
146
|
const startedAt = new Date;
|
|
146
147
|
await context.emitEvent("command.started", {
|
|
147
148
|
command: commandWithEnv,
|
|
@@ -161,7 +162,6 @@ async function runCommand(context, parts) {
|
|
|
161
162
|
if (context.outputMode === "text") {
|
|
162
163
|
console.log(`$ ${formatted}`);
|
|
163
164
|
}
|
|
164
|
-
await context.plugins.afterCommand(dryResult);
|
|
165
165
|
await context.emitEvent("command.finished", {
|
|
166
166
|
...dryResult,
|
|
167
167
|
dryRun: true
|
|
@@ -201,7 +201,6 @@ async function runCommand(context, parts) {
|
|
|
201
201
|
stdout: context.outputMode === "json" ? stdout : undefined,
|
|
202
202
|
stderr: context.outputMode === "json" ? stderr : undefined
|
|
203
203
|
};
|
|
204
|
-
await context.plugins.afterCommand(result);
|
|
205
204
|
if (exitCode !== 0) {
|
|
206
205
|
await context.emitEvent("command.failed", {
|
|
207
206
|
...result
|
|
@@ -260,11 +259,278 @@ Usage: ${usage}`);
|
|
|
260
259
|
}
|
|
261
260
|
return taskId;
|
|
262
261
|
}
|
|
262
|
+
var AGENT_DISPATCH_SOURCE = "packages/runtime/bin/rig-agent-dispatch.ts";
|
|
263
|
+
var init_runner = () => {};
|
|
264
|
+
|
|
265
|
+
// packages/cli/src/commands/_parsers.ts
|
|
266
|
+
import { homedir } from "os";
|
|
267
|
+
import { resolve as resolve7 } from "path";
|
|
268
|
+
function parsePositiveInt(value, option, fallback) {
|
|
269
|
+
if (!value) {
|
|
270
|
+
return fallback;
|
|
271
|
+
}
|
|
272
|
+
const parsed = Number.parseInt(value, 10);
|
|
273
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
274
|
+
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
275
|
+
}
|
|
276
|
+
return parsed;
|
|
277
|
+
}
|
|
278
|
+
function parseOptionalPositiveInt(value, option) {
|
|
279
|
+
if (!value) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const parsed = Number.parseInt(value, 10);
|
|
283
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
284
|
+
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
285
|
+
}
|
|
286
|
+
return parsed;
|
|
287
|
+
}
|
|
288
|
+
function parseRequiredPositiveInt(value, option) {
|
|
289
|
+
if (!value) {
|
|
290
|
+
throw new CliError2(`Missing value for ${option}.`);
|
|
291
|
+
}
|
|
292
|
+
const parsed = Number.parseInt(value, 10);
|
|
293
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
294
|
+
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
295
|
+
}
|
|
296
|
+
return parsed;
|
|
297
|
+
}
|
|
298
|
+
function parseAction(value) {
|
|
299
|
+
if (!value || value === "validate") {
|
|
300
|
+
return "validate";
|
|
301
|
+
}
|
|
302
|
+
if (value === "verify") {
|
|
303
|
+
return "verify";
|
|
304
|
+
}
|
|
305
|
+
if (value === "pipeline") {
|
|
306
|
+
return "pipeline";
|
|
307
|
+
}
|
|
308
|
+
throw new CliError2(`Invalid --action value: ${value}. Use validate, verify, or pipeline.`);
|
|
309
|
+
}
|
|
310
|
+
function parseIsolationMode(value, allowOff) {
|
|
311
|
+
if (!value) {
|
|
312
|
+
return "worktree";
|
|
313
|
+
}
|
|
314
|
+
if (value === "worktree") {
|
|
315
|
+
return value;
|
|
316
|
+
}
|
|
317
|
+
if (allowOff && value === "off") {
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
320
|
+
throw new CliError2(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
|
|
321
|
+
}
|
|
322
|
+
function parseInstallScope(value) {
|
|
323
|
+
if (!value || value === "user") {
|
|
324
|
+
return "user";
|
|
325
|
+
}
|
|
326
|
+
if (value === "system") {
|
|
327
|
+
return "system";
|
|
328
|
+
}
|
|
329
|
+
throw new CliError2(`Invalid --scope value: ${value}. Use user|system.`);
|
|
330
|
+
}
|
|
331
|
+
function resolveInstallDir(scope, explicitPath) {
|
|
332
|
+
if (explicitPath) {
|
|
333
|
+
return resolve7(explicitPath);
|
|
334
|
+
}
|
|
335
|
+
if (scope === "system") {
|
|
336
|
+
return "/usr/local/bin";
|
|
337
|
+
}
|
|
338
|
+
return resolve7(homedir(), ".local/bin");
|
|
339
|
+
}
|
|
340
|
+
async function loadRigConfigOrNull(projectRoot) {
|
|
341
|
+
try {
|
|
342
|
+
const { loadConfig } = await import("@rig/core/load-config");
|
|
343
|
+
return await loadConfig(projectRoot);
|
|
344
|
+
} catch {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
var init__parsers = __esm(() => {
|
|
349
|
+
init_runner();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// packages/cli/src/commands/plugin.ts
|
|
353
|
+
var exports_plugin = {};
|
|
354
|
+
__export(exports_plugin, {
|
|
355
|
+
resolvePluginCliCommand: () => resolvePluginCliCommand,
|
|
356
|
+
executePlugin: () => executePlugin
|
|
357
|
+
});
|
|
358
|
+
import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
|
|
359
|
+
async function executePlugin(context, args) {
|
|
360
|
+
const [command = "list", ...rest] = args;
|
|
361
|
+
switch (command) {
|
|
362
|
+
case "list": {
|
|
363
|
+
requireNoExtraArgs(rest, "rig plugin list");
|
|
364
|
+
const declarative = [];
|
|
365
|
+
const config = await loadRigConfigOrNull(context.projectRoot);
|
|
366
|
+
if (config && Array.isArray(config.plugins)) {
|
|
367
|
+
for (const plugin of config.plugins) {
|
|
368
|
+
const c = plugin.contributes ?? {};
|
|
369
|
+
declarative.push({
|
|
370
|
+
name: plugin.name,
|
|
371
|
+
version: plugin.version,
|
|
372
|
+
validators: (c.validators ?? []).map((v) => v.id),
|
|
373
|
+
hooks: (c.hooks ?? []).map((h) => h.id),
|
|
374
|
+
agentRoles: (c.agentRoles ?? []).map((r) => r.id),
|
|
375
|
+
repoSources: (c.repoSources ?? []).map((r) => r.id),
|
|
376
|
+
taskSources: (c.taskSources ?? []).map((s) => s.id),
|
|
377
|
+
skills: (c.skills ?? []).map((s) => s.id),
|
|
378
|
+
taskFieldExtensions: (c.taskFieldSchemas ?? []).map((f) => f.id),
|
|
379
|
+
cliCommands: (c.cliCommands ?? []).map((entry) => entry.id)
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (context.outputMode === "text") {
|
|
384
|
+
if (declarative.length === 0) {
|
|
385
|
+
console.log("No plugins loaded. Declare plugins in rig.config.ts.");
|
|
386
|
+
} else {
|
|
387
|
+
console.log("Plugins (rig.config.ts):");
|
|
388
|
+
for (const p of declarative) {
|
|
389
|
+
console.log(` ${p.name}@${p.version}`);
|
|
390
|
+
const lines = [];
|
|
391
|
+
if (p.validators.length)
|
|
392
|
+
lines.push(` validators: ${p.validators.join(", ")}`);
|
|
393
|
+
if (p.hooks.length)
|
|
394
|
+
lines.push(` hooks: ${p.hooks.join(", ")}`);
|
|
395
|
+
if (p.agentRoles.length)
|
|
396
|
+
lines.push(` agent-roles: ${p.agentRoles.join(", ")}`);
|
|
397
|
+
if (p.repoSources.length)
|
|
398
|
+
lines.push(` repo-sources: ${p.repoSources.join(", ")}`);
|
|
399
|
+
if (p.taskSources.length)
|
|
400
|
+
lines.push(` task-sources: ${p.taskSources.join(", ")}`);
|
|
401
|
+
if (p.skills.length)
|
|
402
|
+
lines.push(` skills: ${p.skills.join(", ")}`);
|
|
403
|
+
if (p.taskFieldExtensions.length)
|
|
404
|
+
lines.push(` task-fields: ${p.taskFieldExtensions.join(", ")}`);
|
|
405
|
+
if (p.cliCommands.length)
|
|
406
|
+
lines.push(` cli-commands: ${p.cliCommands.join(", ")} (run with \`rig plugin run <id>\`)`);
|
|
407
|
+
for (const line of lines)
|
|
408
|
+
console.log(line);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
ok: true,
|
|
414
|
+
group: "plugin",
|
|
415
|
+
command,
|
|
416
|
+
details: { declarative }
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
case "validate": {
|
|
420
|
+
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
421
|
+
requireNoExtraArgs(remaining, "rig plugin validate --task <task-id>");
|
|
422
|
+
const taskId = requireTask(task, "rig plugin validate --task <task-id>");
|
|
423
|
+
const hostCtx = await buildPluginHostContext(context.projectRoot);
|
|
424
|
+
if (!hostCtx) {
|
|
425
|
+
throw new CliError2(`No rig.config found at ${context.projectRoot}. Run \`rig init\` to set up plugins.`, 2);
|
|
426
|
+
}
|
|
427
|
+
const validators = hostCtx.validatorRegistry.list();
|
|
428
|
+
const results = [];
|
|
429
|
+
for (const validator of validators) {
|
|
430
|
+
try {
|
|
431
|
+
results.push(await validator.run({
|
|
432
|
+
taskId,
|
|
433
|
+
workspaceRoot: context.projectRoot,
|
|
434
|
+
scope: []
|
|
435
|
+
}));
|
|
436
|
+
} catch (error) {
|
|
437
|
+
results.push({
|
|
438
|
+
id: validator.id,
|
|
439
|
+
passed: false,
|
|
440
|
+
summary: `${validator.id} failed unexpectedly`,
|
|
441
|
+
details: `${error}`
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const passed = results.filter((result) => result.passed).length;
|
|
446
|
+
const failed = results.length - passed;
|
|
447
|
+
if (context.outputMode === "text") {
|
|
448
|
+
if (results.length === 0) {
|
|
449
|
+
console.log("No plugin validators registered.");
|
|
450
|
+
} else {
|
|
451
|
+
for (const result of results) {
|
|
452
|
+
const icon = result.passed ? "PASS" : "FAIL";
|
|
453
|
+
console.log(`[${icon}] ${result.id}: ${result.summary}`);
|
|
454
|
+
if (result.details && !result.passed) {
|
|
455
|
+
console.log(result.details);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (failed > 0) {
|
|
461
|
+
throw new CliError2(`Plugin validation failed for ${failed} validator(s).`, 2);
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
ok: true,
|
|
465
|
+
group: "plugin",
|
|
466
|
+
command,
|
|
467
|
+
details: {
|
|
468
|
+
taskId,
|
|
469
|
+
passed,
|
|
470
|
+
failed,
|
|
471
|
+
results
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
case "run": {
|
|
476
|
+
const [commandId, ...commandArgs] = rest;
|
|
477
|
+
if (!commandId) {
|
|
478
|
+
throw new CliError2("Usage: rig plugin run <command-id> [args...]");
|
|
479
|
+
}
|
|
480
|
+
const hostCtx = await buildPluginHostContext(context.projectRoot);
|
|
481
|
+
if (!hostCtx) {
|
|
482
|
+
throw new CliError2(`No rig.config found at ${context.projectRoot}. Run \`rig init\` to set up plugins.`, 2);
|
|
483
|
+
}
|
|
484
|
+
const registration = resolvePluginCliCommand(hostCtx.pluginHost.listCliCommands(), commandId);
|
|
485
|
+
if (!registration) {
|
|
486
|
+
const available = hostCtx.pluginHost.listCliCommands().map((entry) => entry.id);
|
|
487
|
+
throw new CliError2(available.length > 0 ? `Unknown plugin command "${commandId}". Available: ${available.join(", ")}` : `No plugin CLI commands are registered. Plugins contribute them via contributes.cliCommands.`, 2);
|
|
488
|
+
}
|
|
489
|
+
if (context.dryRun) {
|
|
490
|
+
if (context.outputMode === "text") {
|
|
491
|
+
console.log(`[dry-run] ${registration.command}${commandArgs.length ? ` ${commandArgs.join(" ")}` : ""}`);
|
|
492
|
+
}
|
|
493
|
+
return { ok: true, group: "plugin", command, details: { id: registration.id, dryRun: true } };
|
|
494
|
+
}
|
|
495
|
+
const proc = Bun.spawn(["bash", "-c", `${registration.command} "$@"`, registration.id, ...commandArgs], {
|
|
496
|
+
cwd: context.projectRoot,
|
|
497
|
+
env: process.env,
|
|
498
|
+
stdin: "inherit",
|
|
499
|
+
stdout: "inherit",
|
|
500
|
+
stderr: "inherit"
|
|
501
|
+
});
|
|
502
|
+
const exitCode = await proc.exited;
|
|
503
|
+
if (exitCode !== 0) {
|
|
504
|
+
throw new CliError2(`Plugin command "${registration.id}" exited with code ${exitCode}.`, exitCode);
|
|
505
|
+
}
|
|
506
|
+
return { ok: true, group: "plugin", command, details: { id: registration.id, exitCode } };
|
|
507
|
+
}
|
|
508
|
+
default:
|
|
509
|
+
throw new CliError2(`Unknown plugin command: ${command}`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function resolvePluginCliCommand(commands, requested) {
|
|
513
|
+
const exact = commands.find((entry) => entry.id === requested);
|
|
514
|
+
if (exact)
|
|
515
|
+
return exact;
|
|
516
|
+
const byLocalPart = commands.filter((entry) => entry.id.split(":").slice(1).join(":") === requested);
|
|
517
|
+
return byLocalPart.length === 1 ? byLocalPart[0] : undefined;
|
|
518
|
+
}
|
|
519
|
+
var init_plugin = __esm(() => {
|
|
520
|
+
init_runner();
|
|
521
|
+
init__parsers();
|
|
522
|
+
});
|
|
263
523
|
|
|
264
524
|
// packages/cli/src/commands.ts
|
|
525
|
+
init_runner();
|
|
526
|
+
import {
|
|
527
|
+
existsSync as existsSync14
|
|
528
|
+
} from "fs";
|
|
529
|
+
import { resolve as resolve23 } from "path";
|
|
265
530
|
import { readBuildConfig } from "@rig/runtime/build-time-config";
|
|
266
531
|
|
|
267
532
|
// packages/cli/src/commands/browser.ts
|
|
533
|
+
init_runner();
|
|
268
534
|
import { mkdirSync as mkdirSync3, rmSync as rmSync2 } from "fs";
|
|
269
535
|
import { resolve as resolve5 } from "path";
|
|
270
536
|
import { spawn } from "child_process";
|
|
@@ -275,6 +541,7 @@ import pc2 from "picocolors";
|
|
|
275
541
|
import { runCapture as runCapture2 } from "@rig/runtime/control-plane/native/utils";
|
|
276
542
|
|
|
277
543
|
// packages/cli/src/commands/task-report-bug.ts
|
|
544
|
+
init_runner();
|
|
278
545
|
import { existsSync as existsSync3, readFileSync, writeFileSync as writeFileSync2 } from "fs";
|
|
279
546
|
import { resolve as resolve4 } from "path";
|
|
280
547
|
import * as clack from "@clack/prompts";
|
|
@@ -2099,6 +2366,7 @@ async function stopBrowserDemo(child) {
|
|
|
2099
2366
|
}
|
|
2100
2367
|
|
|
2101
2368
|
// packages/cli/src/commands/profile-and-review.ts
|
|
2369
|
+
init_runner();
|
|
2102
2370
|
import {
|
|
2103
2371
|
setProfile,
|
|
2104
2372
|
setReviewProfile,
|
|
@@ -2238,10 +2506,12 @@ async function executeReview(context, args) {
|
|
|
2238
2506
|
}
|
|
2239
2507
|
|
|
2240
2508
|
// packages/cli/src/commands/repo-git-harness.ts
|
|
2509
|
+
init_runner();
|
|
2241
2510
|
import { executeHarnessCommand } from "@rig/runtime/control-plane/native/harness-cli";
|
|
2242
2511
|
import { repoEnsure, resetBaseline } from "@rig/runtime/control-plane/native/repo-ops";
|
|
2243
2512
|
|
|
2244
2513
|
// packages/cli/src/commands/_policy.ts
|
|
2514
|
+
init_runner();
|
|
2245
2515
|
import { appendFileSync, mkdirSync as mkdirSync4 } from "fs";
|
|
2246
2516
|
import { resolve as resolve6 } from "path";
|
|
2247
2517
|
import { evaluate as evaluate2, loadPolicy as loadPolicy2, resolveAction as resolveAction2 } from "@rig/runtime/control-plane/runtime/guard";
|
|
@@ -2336,7 +2606,7 @@ async function executeGit(context, args) {
|
|
|
2336
2606
|
return { ok: true, group: "git", command: args[0] ?? "git" };
|
|
2337
2607
|
}
|
|
2338
2608
|
try {
|
|
2339
|
-
await executeHarnessCommand(context.projectRoot,
|
|
2609
|
+
await executeHarnessCommand(context.projectRoot, ["git", ...args]);
|
|
2340
2610
|
} catch (error) {
|
|
2341
2611
|
throw new CliError2(error instanceof Error ? error.message : String(error), 2);
|
|
2342
2612
|
}
|
|
@@ -2357,214 +2627,27 @@ async function executeHarness(context, args) {
|
|
|
2357
2627
|
return { ok: true, group: "harness", command: args[0] ?? "harness" };
|
|
2358
2628
|
}
|
|
2359
2629
|
try {
|
|
2360
|
-
await executeHarnessCommand(context.projectRoot,
|
|
2630
|
+
await executeHarnessCommand(context.projectRoot, args);
|
|
2361
2631
|
} catch (error) {
|
|
2362
2632
|
throw new CliError2(error instanceof Error ? error.message : String(error), 2);
|
|
2363
2633
|
}
|
|
2364
2634
|
return { ok: true, group: "harness", command: args[0] ?? "harness" };
|
|
2365
2635
|
}
|
|
2366
2636
|
|
|
2367
|
-
// packages/cli/src/commands
|
|
2368
|
-
|
|
2369
|
-
import { resolve as resolve7 } from "path";
|
|
2370
|
-
function parsePositiveInt(value, option, fallback) {
|
|
2371
|
-
if (!value) {
|
|
2372
|
-
return fallback;
|
|
2373
|
-
}
|
|
2374
|
-
const parsed = Number.parseInt(value, 10);
|
|
2375
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
2376
|
-
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
2377
|
-
}
|
|
2378
|
-
return parsed;
|
|
2379
|
-
}
|
|
2380
|
-
function parseOptionalPositiveInt(value, option) {
|
|
2381
|
-
if (!value) {
|
|
2382
|
-
return;
|
|
2383
|
-
}
|
|
2384
|
-
const parsed = Number.parseInt(value, 10);
|
|
2385
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
2386
|
-
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
2387
|
-
}
|
|
2388
|
-
return parsed;
|
|
2389
|
-
}
|
|
2390
|
-
function parseRequiredPositiveInt(value, option) {
|
|
2391
|
-
if (!value) {
|
|
2392
|
-
throw new CliError2(`Missing value for ${option}.`);
|
|
2393
|
-
}
|
|
2394
|
-
const parsed = Number.parseInt(value, 10);
|
|
2395
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
2396
|
-
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
2397
|
-
}
|
|
2398
|
-
return parsed;
|
|
2399
|
-
}
|
|
2400
|
-
function parseAction(value) {
|
|
2401
|
-
if (!value || value === "validate") {
|
|
2402
|
-
return "validate";
|
|
2403
|
-
}
|
|
2404
|
-
if (value === "verify") {
|
|
2405
|
-
return "verify";
|
|
2406
|
-
}
|
|
2407
|
-
if (value === "pipeline") {
|
|
2408
|
-
return "pipeline";
|
|
2409
|
-
}
|
|
2410
|
-
throw new CliError2(`Invalid --action value: ${value}. Use validate, verify, or pipeline.`);
|
|
2411
|
-
}
|
|
2412
|
-
function parseIsolationMode(value, allowOff) {
|
|
2413
|
-
if (!value) {
|
|
2414
|
-
return "worktree";
|
|
2415
|
-
}
|
|
2416
|
-
if (value === "worktree") {
|
|
2417
|
-
return value;
|
|
2418
|
-
}
|
|
2419
|
-
if (allowOff && value === "off") {
|
|
2420
|
-
return value;
|
|
2421
|
-
}
|
|
2422
|
-
throw new CliError2(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
|
|
2423
|
-
}
|
|
2424
|
-
function parseInstallScope(value) {
|
|
2425
|
-
if (!value || value === "user") {
|
|
2426
|
-
return "user";
|
|
2427
|
-
}
|
|
2428
|
-
if (value === "system") {
|
|
2429
|
-
return "system";
|
|
2430
|
-
}
|
|
2431
|
-
throw new CliError2(`Invalid --scope value: ${value}. Use user|system.`);
|
|
2432
|
-
}
|
|
2433
|
-
function resolveInstallDir(scope, explicitPath) {
|
|
2434
|
-
if (explicitPath) {
|
|
2435
|
-
return resolve7(explicitPath);
|
|
2436
|
-
}
|
|
2437
|
-
if (scope === "system") {
|
|
2438
|
-
return "/usr/local/bin";
|
|
2439
|
-
}
|
|
2440
|
-
return resolve7(homedir(), ".local/bin");
|
|
2441
|
-
}
|
|
2442
|
-
async function loadRigConfigOrNull(projectRoot) {
|
|
2443
|
-
try {
|
|
2444
|
-
const { loadConfig } = await import("@rig/core/load-config");
|
|
2445
|
-
return await loadConfig(projectRoot);
|
|
2446
|
-
} catch {
|
|
2447
|
-
return null;
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
|
-
// packages/cli/src/commands/plugin.ts
|
|
2452
|
-
async function executePlugin(context, args) {
|
|
2453
|
-
const [command = "list", ...rest] = args;
|
|
2454
|
-
switch (command) {
|
|
2455
|
-
case "list": {
|
|
2456
|
-
requireNoExtraArgs(rest, "rig plugin list");
|
|
2457
|
-
const legacyPlugins = context.plugins.list();
|
|
2458
|
-
const declarative = [];
|
|
2459
|
-
const config = await loadRigConfigOrNull(context.projectRoot);
|
|
2460
|
-
if (config && Array.isArray(config.plugins)) {
|
|
2461
|
-
for (const plugin of config.plugins) {
|
|
2462
|
-
const c = plugin.contributes ?? {};
|
|
2463
|
-
declarative.push({
|
|
2464
|
-
name: plugin.name,
|
|
2465
|
-
version: plugin.version,
|
|
2466
|
-
validators: (c.validators ?? []).map((v) => v.id),
|
|
2467
|
-
hooks: (c.hooks ?? []).map((h) => h.id),
|
|
2468
|
-
agentRoles: (c.agentRoles ?? []).map((r) => r.id),
|
|
2469
|
-
repoSources: (c.repoSources ?? []).map((r) => r.id),
|
|
2470
|
-
taskSources: (c.taskSources ?? []).map((s) => s.id),
|
|
2471
|
-
skills: (c.skills ?? []).map((s) => s.id),
|
|
2472
|
-
taskFieldExtensions: (c.taskFieldSchemas ?? []).map((f) => f.id),
|
|
2473
|
-
cliCommands: (c.cliCommands ?? []).map((c2) => c2.id)
|
|
2474
|
-
});
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
if (context.outputMode === "text") {
|
|
2478
|
-
if (legacyPlugins.length === 0 && declarative.length === 0) {
|
|
2479
|
-
console.log("No plugins loaded.");
|
|
2480
|
-
}
|
|
2481
|
-
if (declarative.length > 0) {
|
|
2482
|
-
console.log("Declarative plugins (rig.config.ts):");
|
|
2483
|
-
for (const p of declarative) {
|
|
2484
|
-
console.log(` ${p.name}@${p.version}`);
|
|
2485
|
-
const lines = [];
|
|
2486
|
-
if (p.validators.length)
|
|
2487
|
-
lines.push(` validators: ${p.validators.join(", ")}`);
|
|
2488
|
-
if (p.hooks.length)
|
|
2489
|
-
lines.push(` hooks: ${p.hooks.join(", ")}`);
|
|
2490
|
-
if (p.agentRoles.length)
|
|
2491
|
-
lines.push(` agent-roles: ${p.agentRoles.join(", ")}`);
|
|
2492
|
-
if (p.repoSources.length)
|
|
2493
|
-
lines.push(` repo-sources: ${p.repoSources.join(", ")}`);
|
|
2494
|
-
if (p.taskSources.length)
|
|
2495
|
-
lines.push(` task-sources: ${p.taskSources.join(", ")}`);
|
|
2496
|
-
if (p.skills.length)
|
|
2497
|
-
lines.push(` skills: ${p.skills.join(", ")}`);
|
|
2498
|
-
if (p.taskFieldExtensions.length)
|
|
2499
|
-
lines.push(` task-fields: ${p.taskFieldExtensions.join(", ")}`);
|
|
2500
|
-
if (p.cliCommands.length)
|
|
2501
|
-
lines.push(` cli-commands: ${p.cliCommands.join(", ")}`);
|
|
2502
|
-
for (const line of lines)
|
|
2503
|
-
console.log(line);
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
if (legacyPlugins.length > 0) {
|
|
2507
|
-
console.log("Legacy disk-scan plugins (rig/plugins/):");
|
|
2508
|
-
for (const plugin of legacyPlugins) {
|
|
2509
|
-
const validators = plugin.validators.length > 0 ? plugin.validators.join(", ") : "none";
|
|
2510
|
-
console.log(` ${plugin.name} (validators: ${validators})`);
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
return {
|
|
2515
|
-
ok: true,
|
|
2516
|
-
group: "plugin",
|
|
2517
|
-
command,
|
|
2518
|
-
details: { declarative, legacy: legacyPlugins }
|
|
2519
|
-
};
|
|
2520
|
-
}
|
|
2521
|
-
case "validate": {
|
|
2522
|
-
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
2523
|
-
requireNoExtraArgs(remaining, "rig plugin validate --task <task-id>");
|
|
2524
|
-
const taskId = requireTask(task, "rig plugin validate --task <task-id>");
|
|
2525
|
-
const results = await context.plugins.runValidators(taskId);
|
|
2526
|
-
const passed = results.filter((result) => result.passed).length;
|
|
2527
|
-
const failed = results.length - passed;
|
|
2528
|
-
if (context.outputMode === "text") {
|
|
2529
|
-
if (results.length === 0) {
|
|
2530
|
-
console.log("No plugin validators registered.");
|
|
2531
|
-
} else {
|
|
2532
|
-
for (const result of results) {
|
|
2533
|
-
const icon = result.passed ? "PASS" : "FAIL";
|
|
2534
|
-
console.log(`[${icon}] ${result.id}: ${result.summary}`);
|
|
2535
|
-
if (result.details && !result.passed) {
|
|
2536
|
-
console.log(result.details);
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
}
|
|
2541
|
-
if (failed > 0) {
|
|
2542
|
-
throw new CliError2(`Plugin validation failed for ${failed} validator(s).`, 2);
|
|
2543
|
-
}
|
|
2544
|
-
return {
|
|
2545
|
-
ok: true,
|
|
2546
|
-
group: "plugin",
|
|
2547
|
-
command,
|
|
2548
|
-
details: {
|
|
2549
|
-
taskId,
|
|
2550
|
-
passed,
|
|
2551
|
-
failed,
|
|
2552
|
-
results
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
default:
|
|
2557
|
-
throw new CliError2(`Unknown plugin command: ${command}`);
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2637
|
+
// packages/cli/src/commands.ts
|
|
2638
|
+
init_plugin();
|
|
2560
2639
|
|
|
2561
2640
|
// packages/cli/src/commands/queue.ts
|
|
2641
|
+
init_runner();
|
|
2642
|
+
init__parsers();
|
|
2562
2643
|
import { runPriorityQueue } from "@rig/runtime/control-plane/runtime/queue";
|
|
2563
2644
|
|
|
2564
2645
|
// packages/cli/src/commands/_preflight.ts
|
|
2646
|
+
init_runner();
|
|
2565
2647
|
import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/project-main-pre-run-sync";
|
|
2566
2648
|
|
|
2567
2649
|
// packages/cli/src/commands/_connection-state.ts
|
|
2650
|
+
init_runner();
|
|
2568
2651
|
import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
2569
2652
|
import { homedir as homedir2 } from "os";
|
|
2570
2653
|
import { dirname, resolve as resolve8 } from "path";
|
|
@@ -2667,6 +2750,7 @@ function resolveSelectedConnection(projectRoot, options = {}) {
|
|
|
2667
2750
|
}
|
|
2668
2751
|
|
|
2669
2752
|
// packages/cli/src/commands/_server-client.ts
|
|
2753
|
+
init_runner();
|
|
2670
2754
|
import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
|
|
2671
2755
|
import { resolve as resolve9 } from "path";
|
|
2672
2756
|
import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
|
|
@@ -3315,6 +3399,7 @@ async function executeQueue(context, args) {
|
|
|
3315
3399
|
}
|
|
3316
3400
|
|
|
3317
3401
|
// packages/cli/src/commands/agent.ts
|
|
3402
|
+
init_runner();
|
|
3318
3403
|
import { resolve as resolve11 } from "path";
|
|
3319
3404
|
import {
|
|
3320
3405
|
agentId,
|
|
@@ -3422,6 +3507,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
|
|
|
3422
3507
|
}
|
|
3423
3508
|
|
|
3424
3509
|
// packages/cli/src/commands/agent.ts
|
|
3510
|
+
init__parsers();
|
|
3425
3511
|
function splitAtDoubleDash(args) {
|
|
3426
3512
|
const separatorIndex = args.indexOf("--");
|
|
3427
3513
|
if (separatorIndex === -1) {
|
|
@@ -3655,6 +3741,8 @@ ${result.stderr.trim()}` : ""}`, result.exitCode);
|
|
|
3655
3741
|
}
|
|
3656
3742
|
|
|
3657
3743
|
// packages/cli/src/commands/dist.ts
|
|
3744
|
+
init_runner();
|
|
3745
|
+
init__parsers();
|
|
3658
3746
|
import {
|
|
3659
3747
|
chmodSync,
|
|
3660
3748
|
copyFileSync as copyFileSync2,
|
|
@@ -3972,6 +4060,7 @@ async function executeDist(context, args) {
|
|
|
3972
4060
|
}
|
|
3973
4061
|
|
|
3974
4062
|
// packages/cli/src/commands/inbox.ts
|
|
4063
|
+
init_runner();
|
|
3975
4064
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
3976
4065
|
import { resolve as resolve13 } from "path";
|
|
3977
4066
|
import {
|
|
@@ -4494,6 +4583,7 @@ async function executeInbox(context, args) {
|
|
|
4494
4583
|
}
|
|
4495
4584
|
|
|
4496
4585
|
// packages/cli/src/commands/init.ts
|
|
4586
|
+
init_runner();
|
|
4497
4587
|
import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
4498
4588
|
import { spawnSync } from "child_process";
|
|
4499
4589
|
import { resolve as resolve17 } from "path";
|
|
@@ -4769,9 +4859,11 @@ async function uploadSnapshotArchiveViaServer(context, input) {
|
|
|
4769
4859
|
}
|
|
4770
4860
|
|
|
4771
4861
|
// packages/cli/src/commands/_doctor-checks.ts
|
|
4862
|
+
init_runner();
|
|
4772
4863
|
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "fs";
|
|
4773
4864
|
import { resolve as resolve16 } from "path";
|
|
4774
4865
|
import { isSupportedBunVersion, MIN_SUPPORTED_BUN_VERSION } from "@rig/runtime/control-plane/setup-version";
|
|
4866
|
+
init__parsers();
|
|
4775
4867
|
function check(id, label, status, detail, remediation) {
|
|
4776
4868
|
return {
|
|
4777
4869
|
id,
|
|
@@ -5714,6 +5806,7 @@ Usage: rig init`, 1);
|
|
|
5714
5806
|
}
|
|
5715
5807
|
|
|
5716
5808
|
// packages/cli/src/commands/connect.ts
|
|
5809
|
+
init_runner();
|
|
5717
5810
|
import { cancel as cancel2, isCancel as isCancel2, select as select2 } from "@clack/prompts";
|
|
5718
5811
|
function usageName(options) {
|
|
5719
5812
|
return `rig ${options.group}`;
|
|
@@ -5826,6 +5919,7 @@ async function executeConnect(context, args) {
|
|
|
5826
5919
|
}
|
|
5827
5920
|
|
|
5828
5921
|
// packages/cli/src/commands/github.ts
|
|
5922
|
+
init_runner();
|
|
5829
5923
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
5830
5924
|
function printPayload(context, payload, fallback) {
|
|
5831
5925
|
if (context.outputMode === "json")
|
|
@@ -5881,6 +5975,7 @@ async function executeGithub(context, args) {
|
|
|
5881
5975
|
}
|
|
5882
5976
|
|
|
5883
5977
|
// packages/cli/src/commands/doctor.ts
|
|
5978
|
+
init_runner();
|
|
5884
5979
|
async function executeDoctor(context, args) {
|
|
5885
5980
|
requireNoExtraArgs(args, "rig doctor");
|
|
5886
5981
|
const checks = await runRigDoctorChecks({ projectRoot: context.projectRoot });
|
|
@@ -5896,6 +5991,7 @@ async function executeDoctor(context, args) {
|
|
|
5896
5991
|
}
|
|
5897
5992
|
|
|
5898
5993
|
// packages/cli/src/commands/_run-driver-helpers.ts
|
|
5994
|
+
init_runner();
|
|
5899
5995
|
import { readFileSync as readFileSync7 } from "fs";
|
|
5900
5996
|
import { resolve as resolve18 } from "path";
|
|
5901
5997
|
import {
|
|
@@ -6123,6 +6219,7 @@ function renderSourceScopeValidation(task, validation) {
|
|
|
6123
6219
|
}
|
|
6124
6220
|
|
|
6125
6221
|
// packages/cli/src/commands/inspect.ts
|
|
6222
|
+
init_runner();
|
|
6126
6223
|
import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
|
|
6127
6224
|
import { resolve as resolve19 } from "path";
|
|
6128
6225
|
import {
|
|
@@ -6250,6 +6347,8 @@ async function executeInspect(context, args) {
|
|
|
6250
6347
|
}
|
|
6251
6348
|
|
|
6252
6349
|
// packages/cli/src/commands/inspector.ts
|
|
6350
|
+
init_runner();
|
|
6351
|
+
init__parsers();
|
|
6253
6352
|
import { iterateServerSentEvents } from "@rig/client";
|
|
6254
6353
|
import { ensureLocalRigServerConnection as ensureLocalRigServerConnection2 } from "@rig/runtime/local-server";
|
|
6255
6354
|
function formatInspectorStreamLine(payload) {
|
|
@@ -6440,6 +6539,8 @@ async function executeInspector(context, args) {
|
|
|
6440
6539
|
}
|
|
6441
6540
|
|
|
6442
6541
|
// packages/cli/src/commands/remote.ts
|
|
6542
|
+
init_runner();
|
|
6543
|
+
init__parsers();
|
|
6443
6544
|
import {
|
|
6444
6545
|
doctorManagedRemoteEndpoints,
|
|
6445
6546
|
listManagedRemoteEndpoints,
|
|
@@ -6866,6 +6967,8 @@ async function executeRemote(context, args) {
|
|
|
6866
6967
|
}
|
|
6867
6968
|
|
|
6868
6969
|
// packages/cli/src/commands/run.ts
|
|
6970
|
+
init_runner();
|
|
6971
|
+
init__parsers();
|
|
6869
6972
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
6870
6973
|
import {
|
|
6871
6974
|
listAuthorityRuns as listAuthorityRuns3,
|
|
@@ -6883,7 +6986,7 @@ import {
|
|
|
6883
6986
|
startRun,
|
|
6884
6987
|
defaultStartRunOptions
|
|
6885
6988
|
} from "@rig/runtime/control-plane/native/run-ops";
|
|
6886
|
-
import { loadRuntimeContextFromEnv
|
|
6989
|
+
import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
|
|
6887
6990
|
|
|
6888
6991
|
// packages/cli/src/commands/_operator-surface.ts
|
|
6889
6992
|
import { createInterface } from "readline";
|
|
@@ -7850,7 +7953,7 @@ async function promptForEpicSelection(projectRoot, command) {
|
|
|
7850
7953
|
}
|
|
7851
7954
|
async function executeRun(context, args) {
|
|
7852
7955
|
const [command = "status", ...rest] = args;
|
|
7853
|
-
const runtimeContext =
|
|
7956
|
+
const runtimeContext = loadRuntimeContextFromEnv() ?? undefined;
|
|
7854
7957
|
switch (command) {
|
|
7855
7958
|
case "list": {
|
|
7856
7959
|
requireNoExtraArgs(rest, "rig run list");
|
|
@@ -8151,6 +8254,7 @@ async function executeRun(context, args) {
|
|
|
8151
8254
|
}
|
|
8152
8255
|
|
|
8153
8256
|
// packages/cli/src/commands/server.ts
|
|
8257
|
+
init_runner();
|
|
8154
8258
|
async function executeServer(context, args, options) {
|
|
8155
8259
|
const [command = "status", ...rest] = args;
|
|
8156
8260
|
if (["status", "list", "add", "use"].includes(command)) {
|
|
@@ -8252,6 +8356,7 @@ async function executeServer(context, args, options) {
|
|
|
8252
8356
|
}
|
|
8253
8357
|
|
|
8254
8358
|
// packages/cli/src/commands/task.ts
|
|
8359
|
+
init_runner();
|
|
8255
8360
|
import { readFileSync as readFileSync9 } from "fs";
|
|
8256
8361
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
8257
8362
|
import { resolve as resolve20 } from "path";
|
|
@@ -8406,6 +8511,9 @@ var PRIMARY_GROUPS = [
|
|
|
8406
8511
|
{ command: "show <id>|--task <id> [--raw]", description: "Show a human task summary; --raw prints the full payload.", primary: true },
|
|
8407
8512
|
{ command: "run [#<issue>|<task-id>|--next|--task <id>]", description: "Submit a task run; interactive follows with bundled Pi.", primary: true },
|
|
8408
8513
|
{ command: "validate|verify [--task <id>]", description: "Run configured task checks/review gates." },
|
|
8514
|
+
{ command: "details --task <id>", description: "Show full task info from the configured source." },
|
|
8515
|
+
{ command: "reopen [--task <id> | --all] [--reason <text>]", description: "Reopen closed task(s) in the configured source." },
|
|
8516
|
+
{ command: "reset --task <id>", description: "Compatibility spelling of `reopen --task <id>`." },
|
|
8409
8517
|
{ command: "artifacts|artifact-dir|artifact-write", description: "Inspect or write task artifacts." },
|
|
8410
8518
|
{ command: "report-bug", description: "Create a structured bug report/task." }
|
|
8411
8519
|
],
|
|
@@ -8430,6 +8538,8 @@ var PRIMARY_GROUPS = [
|
|
|
8430
8538
|
{ command: "attach <run-id>|--run <id> [--follow]", description: "Attach to the run; --follow launches native bundled Pi for live Pi runs.", primary: true },
|
|
8431
8539
|
{ command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
|
|
8432
8540
|
{ command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events." },
|
|
8541
|
+
{ command: "resume", description: "Resume the most recent interrupted local run." },
|
|
8542
|
+
{ command: "restart", description: "Restart the most recent local run from a clean runtime." },
|
|
8433
8543
|
{ command: "delete|cleanup", description: "Remove completed run records/artifacts." }
|
|
8434
8544
|
],
|
|
8435
8545
|
examples: [
|
|
@@ -8516,8 +8626,28 @@ var ADVANCED_GROUPS = [
|
|
|
8516
8626
|
{ name: "inspect", summary: "Inspect logs, artifacts, graphs, failures.", usage: ["rig inspect <logs|artifacts|failures|graph|audit|diff>"], commands: [{ command: "logs --task <id>", description: "Inspect task logs." }] },
|
|
8517
8627
|
{ name: "repo", summary: "Repository sync/baseline helpers.", usage: ["rig repo <sync|reset-baseline>"], commands: [{ command: "sync", description: "Sync project repository state." }] },
|
|
8518
8628
|
{ name: "profile", summary: "Runtime profile/model defaults.", usage: ["rig profile <show|set>"], commands: [{ command: "show", description: "Show active profile." }] },
|
|
8519
|
-
{
|
|
8520
|
-
|
|
8629
|
+
{
|
|
8630
|
+
name: "browser",
|
|
8631
|
+
summary: "Browser/app diagnostics for browser-required tasks.",
|
|
8632
|
+
usage: ["rig browser <help|explain|demo|app|hp-next> [options]"],
|
|
8633
|
+
commands: [
|
|
8634
|
+
{ command: "help", description: "Rich browser command help (canonical: `rig browser help`)." },
|
|
8635
|
+
{ command: "explain", description: "Explain the browser-required task contract." },
|
|
8636
|
+
{ command: "demo", description: "Run browser demo flows against a local page." },
|
|
8637
|
+
{ command: "app", description: "Launch the Rig Browser workstation app." },
|
|
8638
|
+
{ command: "hp-next <dev|check|e2e|reset>", description: "Drive the hp-next browser test harness." }
|
|
8639
|
+
]
|
|
8640
|
+
},
|
|
8641
|
+
{
|
|
8642
|
+
name: "plugin",
|
|
8643
|
+
summary: "Plugin listing, validation, and plugin-contributed commands.",
|
|
8644
|
+
usage: ["rig plugin <list|validate|run> [options]"],
|
|
8645
|
+
commands: [
|
|
8646
|
+
{ command: "list", description: "List plugins declared in rig.config.ts and their contributions." },
|
|
8647
|
+
{ command: "validate --task <id>", description: "Run plugin-contributed validators for a task." },
|
|
8648
|
+
{ command: "run <command-id> [args...]", description: "Execute a plugin-contributed CLI command (also callable as `rig <command-id>`)." }
|
|
8649
|
+
]
|
|
8650
|
+
},
|
|
8521
8651
|
{ name: "queue", summary: "Run task queues locally.", usage: ["rig queue run [options]"], commands: [{ command: "run", description: "Process queue work." }] },
|
|
8522
8652
|
{ name: "agent", summary: "Runtime agent workspace helpers.", usage: ["rig agent <list|prepare|run|cleanup>"], commands: [{ command: "list", description: "List prepared agents." }] },
|
|
8523
8653
|
{ name: "inspector", summary: "Event stream and drift scanners.", usage: ["rig inspector <stream|scan-upstream-drift>"], commands: [{ command: "stream", description: "Stream events." }] },
|
|
@@ -8532,7 +8662,6 @@ var ADVANCED_COMMANDS = [
|
|
|
8532
8662
|
{ command: "rig server task-run ...", description: "Internal server-owned task execution entry point." },
|
|
8533
8663
|
{ command: "rig server notify-test [--event <type>]", description: "Internal event notification smoke command." },
|
|
8534
8664
|
{ command: "rig run start|start-serial|start-parallel", description: "Compatibility local run starters; prefer `rig task run ...`." },
|
|
8535
|
-
{ command: "rig setup install-agent-shell", description: "Development helper for materializing the agent shell." },
|
|
8536
8665
|
{ command: "rig remote orchestrate-*", description: "Compatibility remote orchestration commands." }
|
|
8537
8666
|
];
|
|
8538
8667
|
var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
|
|
@@ -8672,7 +8801,7 @@ function printGroupHelpDocument(groupName) {
|
|
|
8672
8801
|
}
|
|
8673
8802
|
|
|
8674
8803
|
// packages/cli/src/commands/task.ts
|
|
8675
|
-
import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
|
|
8804
|
+
import { buildPluginHostContext as buildPluginHostContext2 } from "@rig/runtime/control-plane/plugin-host-context";
|
|
8676
8805
|
import { loadConfig } from "@rig/core/load-config";
|
|
8677
8806
|
async function readStdin() {
|
|
8678
8807
|
const chunks = [];
|
|
@@ -8823,7 +8952,7 @@ function summarizeTask(task, options = {}) {
|
|
|
8823
8952
|
};
|
|
8824
8953
|
}
|
|
8825
8954
|
async function validatorRegistryForTaskCommands(projectRoot) {
|
|
8826
|
-
return
|
|
8955
|
+
return buildPluginHostContext2(projectRoot).then((ctx) => ctx?.validatorRegistry ?? undefined).catch(() => {
|
|
8827
8956
|
return;
|
|
8828
8957
|
});
|
|
8829
8958
|
}
|
|
@@ -9127,7 +9256,7 @@ async function executeTask(context, args, options) {
|
|
|
9127
9256
|
await context.runCommand(["rig", "task", "verify", ...task ? ["--task", task] : []]);
|
|
9128
9257
|
return { ok: true, group: "task", command, details: { task: task || "active" } };
|
|
9129
9258
|
}
|
|
9130
|
-
const ok = await withMutedConsole(context.outputMode === "json", () => taskVerify(context.projectRoot,
|
|
9259
|
+
const ok = await withMutedConsole(context.outputMode === "json", () => taskVerify(context.projectRoot, task || undefined));
|
|
9131
9260
|
if (!ok) {
|
|
9132
9261
|
throw new CliError2(`Verification rejected for ${task || "active task"}.`, 2);
|
|
9133
9262
|
}
|
|
@@ -9137,8 +9266,12 @@ async function executeTask(context, args, options) {
|
|
|
9137
9266
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
9138
9267
|
requireNoExtraArgs(remaining, "rig task reset --task <task-id>");
|
|
9139
9268
|
const requiredTask = requireTask(task, "rig task reset --task <task-id>");
|
|
9140
|
-
|
|
9141
|
-
|
|
9269
|
+
const summary = withMutedConsole(context.outputMode === "json", () => taskReopen(context.projectRoot, {
|
|
9270
|
+
all: false,
|
|
9271
|
+
taskId: requiredTask,
|
|
9272
|
+
dryRun: false
|
|
9273
|
+
}));
|
|
9274
|
+
return { ok: true, group: "task", command, details: summary };
|
|
9142
9275
|
}
|
|
9143
9276
|
case "details": {
|
|
9144
9277
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
@@ -9168,6 +9301,7 @@ async function executeTask(context, args, options) {
|
|
|
9168
9301
|
}
|
|
9169
9302
|
|
|
9170
9303
|
// packages/cli/src/commands/task-run-driver.ts
|
|
9304
|
+
init_runner();
|
|
9171
9305
|
import { copyFileSync as copyFileSync3, existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
9172
9306
|
import { resolve as resolve21 } from "path";
|
|
9173
9307
|
import { spawn as spawn2, spawnSync as spawnSync4 } from "child_process";
|
|
@@ -11184,6 +11318,7 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
|
|
|
11184
11318
|
}
|
|
11185
11319
|
|
|
11186
11320
|
// packages/cli/src/commands/test.ts
|
|
11321
|
+
init_runner();
|
|
11187
11322
|
async function executeTest(context, args) {
|
|
11188
11323
|
const [command = "unit", ...rest] = args;
|
|
11189
11324
|
switch (command) {
|
|
@@ -11205,6 +11340,7 @@ async function executeTest(context, args) {
|
|
|
11205
11340
|
}
|
|
11206
11341
|
|
|
11207
11342
|
// packages/cli/src/commands/setup.ts
|
|
11343
|
+
init_runner();
|
|
11208
11344
|
import { existsSync as existsSync13, mkdirSync as mkdirSync9, readdirSync as readdirSync2, writeFileSync as writeFileSync7 } from "fs";
|
|
11209
11345
|
import { resolve as resolve22 } from "path";
|
|
11210
11346
|
import { createPluginHost } from "@rig/core";
|
|
@@ -11212,6 +11348,7 @@ import {
|
|
|
11212
11348
|
isSupportedBunVersion as isSupportedBunVersion2,
|
|
11213
11349
|
MIN_SUPPORTED_BUN_VERSION as MIN_SUPPORTED_BUN_VERSION2
|
|
11214
11350
|
} from "@rig/runtime/control-plane/setup-version";
|
|
11351
|
+
init__parsers();
|
|
11215
11352
|
async function executeSetup(context, args) {
|
|
11216
11353
|
const [command = "check", ...rest] = args;
|
|
11217
11354
|
switch (command) {
|
|
@@ -11252,12 +11389,6 @@ async function executeSetup(context, args) {
|
|
|
11252
11389
|
requireNoExtraArgs(rest, "rig setup preflight");
|
|
11253
11390
|
await withMutedConsole(context.outputMode === "json", () => runSetupPreflight(context.projectRoot));
|
|
11254
11391
|
return { ok: true, group: "setup", command };
|
|
11255
|
-
case "install-agent-shell":
|
|
11256
|
-
requireNoExtraArgs(rest, "rig setup install-agent-shell");
|
|
11257
|
-
if (context.outputMode === "text") {
|
|
11258
|
-
console.log("install-agent-shell is deprecated. Runtime shells now use compiled rig-agent directly.");
|
|
11259
|
-
}
|
|
11260
|
-
return { ok: true, group: "setup", command };
|
|
11261
11392
|
default:
|
|
11262
11393
|
throw new CliError2(`Unknown setup command: ${command}`);
|
|
11263
11394
|
}
|
|
@@ -11308,6 +11439,7 @@ async function runSetupPreflight(projectRoot) {
|
|
|
11308
11439
|
}
|
|
11309
11440
|
|
|
11310
11441
|
// packages/cli/src/commands/workspace.ts
|
|
11442
|
+
init_runner();
|
|
11311
11443
|
import {
|
|
11312
11444
|
mutateWorkspaceServiceFabric,
|
|
11313
11445
|
readWorkspaceRemoteFleet,
|
|
@@ -11399,7 +11531,6 @@ var TOP_LEVEL_ALIASES = {
|
|
|
11399
11531
|
check: ["setup", "check"],
|
|
11400
11532
|
preflight: ["setup", "preflight"],
|
|
11401
11533
|
install: ["dist", "install"],
|
|
11402
|
-
"install-shell": ["setup", "install-agent-shell"],
|
|
11403
11534
|
status: ["run", "status"],
|
|
11404
11535
|
start: ["task", "run", "--next"],
|
|
11405
11536
|
"start-parallel": ["run", "start-parallel"],
|
|
@@ -11432,6 +11563,30 @@ var TOP_LEVEL_ALIASES = {
|
|
|
11432
11563
|
"remote-watch": ["remote", "watch"],
|
|
11433
11564
|
doctor: ["doctor", "check"]
|
|
11434
11565
|
};
|
|
11566
|
+
var PROJECT_REQUIRED_GROUPS = new Set([
|
|
11567
|
+
"task",
|
|
11568
|
+
"run",
|
|
11569
|
+
"inbox",
|
|
11570
|
+
"review",
|
|
11571
|
+
"queue",
|
|
11572
|
+
"agent",
|
|
11573
|
+
"repo",
|
|
11574
|
+
"inspect"
|
|
11575
|
+
]);
|
|
11576
|
+
var RIG_CONFIG_FILENAMES = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
11577
|
+
function hasInitializedRigProject(projectRoot) {
|
|
11578
|
+
return RIG_CONFIG_FILENAMES.some((name) => existsSync14(resolve23(projectRoot, name))) || existsSync14(resolve23(projectRoot, ".rig"));
|
|
11579
|
+
}
|
|
11580
|
+
function requireInitializedRigProject(context, group) {
|
|
11581
|
+
if (hasInitializedRigProject(context.projectRoot)) {
|
|
11582
|
+
return;
|
|
11583
|
+
}
|
|
11584
|
+
throw new CliError2([
|
|
11585
|
+
`No Rig project found at ${context.projectRoot} (expected rig.config.ts or a .rig/ state directory).`,
|
|
11586
|
+
"Run `rig init` to set up this repo, or pass --project <path> to point at an existing Rig project."
|
|
11587
|
+
].join(`
|
|
11588
|
+
`), 2);
|
|
11589
|
+
}
|
|
11435
11590
|
var GROUPS = new Set([
|
|
11436
11591
|
"init",
|
|
11437
11592
|
"setup",
|
|
@@ -11529,10 +11684,28 @@ ${helpText()}`);
|
|
|
11529
11684
|
}
|
|
11530
11685
|
return executeGroup(context, group, [command, ...aliasArgs, ...rest]);
|
|
11531
11686
|
}
|
|
11687
|
+
if (await matchesPluginCliCommand(context, first)) {
|
|
11688
|
+
return executeGroup(context, "plugin", ["run", first, ...rest]);
|
|
11689
|
+
}
|
|
11532
11690
|
throw new CliError2(`Unknown group or command: ${first}
|
|
11533
11691
|
|
|
11534
11692
|
${helpText()}`);
|
|
11535
11693
|
}
|
|
11694
|
+
async function matchesPluginCliCommand(context, requested) {
|
|
11695
|
+
if (!hasInitializedRigProject(context.projectRoot)) {
|
|
11696
|
+
return false;
|
|
11697
|
+
}
|
|
11698
|
+
try {
|
|
11699
|
+
const { buildPluginHostContext: buildPluginHostContext3 } = await import("@rig/runtime/control-plane/plugin-host-context");
|
|
11700
|
+
const hostCtx = await buildPluginHostContext3(context.projectRoot);
|
|
11701
|
+
if (!hostCtx)
|
|
11702
|
+
return false;
|
|
11703
|
+
const { resolvePluginCliCommand: resolvePluginCliCommand2 } = await Promise.resolve().then(() => (init_plugin(), exports_plugin));
|
|
11704
|
+
return Boolean(resolvePluginCliCommand2(hostCtx.pluginHost.listCliCommands(), requested));
|
|
11705
|
+
} catch {
|
|
11706
|
+
return false;
|
|
11707
|
+
}
|
|
11708
|
+
}
|
|
11536
11709
|
var GROUPS_WITH_CUSTOM_HELP = new Set(["browser"]);
|
|
11537
11710
|
async function executeGroup(context, group, args) {
|
|
11538
11711
|
if (isHelpArg(args[0]) && !GROUPS_WITH_CUSTOM_HELP.has(group)) {
|
|
@@ -11541,6 +11714,9 @@ async function executeGroup(context, group, args) {
|
|
|
11541
11714
|
}
|
|
11542
11715
|
return { ok: true, group, command: "help" };
|
|
11543
11716
|
}
|
|
11717
|
+
if (PROJECT_REQUIRED_GROUPS.has(group)) {
|
|
11718
|
+
requireInitializedRigProject(context, group);
|
|
11719
|
+
}
|
|
11544
11720
|
switch (group) {
|
|
11545
11721
|
case "setup":
|
|
11546
11722
|
return executeSetup(context, args);
|
|
@@ -11612,8 +11788,8 @@ var __testOnly = {
|
|
|
11612
11788
|
validateRequiredBugPromptValue
|
|
11613
11789
|
};
|
|
11614
11790
|
// packages/cli/src/launcher.ts
|
|
11615
|
-
import { existsSync as
|
|
11616
|
-
import { basename as basename2, resolve as
|
|
11791
|
+
import { existsSync as existsSync15 } from "fs";
|
|
11792
|
+
import { basename as basename2, resolve as resolve24 } from "path";
|
|
11617
11793
|
import { loadDotEnvSecrets } from "@rig/runtime/baked-secrets";
|
|
11618
11794
|
import { RIG_DEFINITION_DIRNAME, RIG_STATE_DIRNAME, resolveNearestRigProjectRoot } from "@rig/runtime/layout";
|
|
11619
11795
|
function parsePolicyMode(value) {
|
|
@@ -11626,7 +11802,7 @@ function parsePolicyMode(value) {
|
|
|
11626
11802
|
throw new Error(`Invalid --policy-mode value: ${value}. Use off|observe|enforce.`);
|
|
11627
11803
|
}
|
|
11628
11804
|
function hasRigProjectMarker(candidate) {
|
|
11629
|
-
return
|
|
11805
|
+
return existsSync15(resolve24(candidate, RIG_DEFINITION_DIRNAME)) || existsSync15(resolve24(candidate, RIG_STATE_DIRNAME)) || existsSync15(resolve24(candidate, "rig.config.ts")) || existsSync15(resolve24(candidate, "rig.config.json")) || existsSync15(resolve24(candidate, ".git"));
|
|
11630
11806
|
}
|
|
11631
11807
|
function resolveProjectRoot({
|
|
11632
11808
|
envProjectRoot,
|
|
@@ -11635,19 +11811,19 @@ function resolveProjectRoot({
|
|
|
11635
11811
|
cwd = process.cwd()
|
|
11636
11812
|
}) {
|
|
11637
11813
|
if (envProjectRoot) {
|
|
11638
|
-
return
|
|
11814
|
+
return resolve24(cwd, envProjectRoot);
|
|
11639
11815
|
}
|
|
11640
11816
|
const fallbackImportDir = importDir ?? cwd;
|
|
11641
11817
|
const execName = basename2(execPath).toLowerCase();
|
|
11642
|
-
const execCandidates = execName === "rig" || execName === "rig.exe" ? [
|
|
11643
|
-
const candidates = [cwd, ...execCandidates,
|
|
11818
|
+
const execCandidates = execName === "rig" || execName === "rig.exe" ? [resolve24(execPath, "..", "..")] : [];
|
|
11819
|
+
const candidates = [cwd, ...execCandidates, resolve24(fallbackImportDir, "..")];
|
|
11644
11820
|
for (const candidate of candidates) {
|
|
11645
11821
|
const nearest = resolveNearestRigProjectRoot(candidate);
|
|
11646
11822
|
if (hasRigProjectMarker(nearest)) {
|
|
11647
11823
|
return nearest;
|
|
11648
11824
|
}
|
|
11649
11825
|
}
|
|
11650
|
-
return
|
|
11826
|
+
return resolve24(cwd);
|
|
11651
11827
|
}
|
|
11652
11828
|
function normalizeCliErrorCode(message2, isCliError) {
|
|
11653
11829
|
if (message2.startsWith("Invalid --policy-mode value:")) {
|
|
@@ -11714,7 +11890,7 @@ async function runRigCli(module, options = {}) {
|
|
|
11714
11890
|
runId: context.runId,
|
|
11715
11891
|
outcome,
|
|
11716
11892
|
eventsFile: context.eventBus.getEventsFile(),
|
|
11717
|
-
policyFile:
|
|
11893
|
+
policyFile: resolve24(projectRoot, "rig", "policy", "policy.json"),
|
|
11718
11894
|
policyMode: context.policyMode ?? policyMode ?? module.loadPolicy(projectRoot).mode
|
|
11719
11895
|
}, null, 2));
|
|
11720
11896
|
}
|
|
@@ -11738,6 +11914,7 @@ function hydrateProcessEnvFromDotEnv(projectRoot) {
|
|
|
11738
11914
|
}
|
|
11739
11915
|
|
|
11740
11916
|
// packages/cli/src/index.ts
|
|
11917
|
+
init_runner();
|
|
11741
11918
|
var RIG_CLI_PACKAGE = "@rig/cli";
|
|
11742
11919
|
export {
|
|
11743
11920
|
withProjectRoot,
|